diff --git a/go.mod b/go.mod index ffcf04e250..36000cee52 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/VictoriaMetrics/fastcache v1.10.0 - github.com/ava-labs/avalanchego v1.10.15-0.20231027221648-efd633e292ee + github.com/ava-labs/avalanchego v1.10.15-rc.1 github.com/cespare/cp v0.1.0 github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index 876d93ec65..30925fc227 100644 --- a/go.sum +++ b/go.sum @@ -55,8 +55,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.10.15-0.20231027221648-efd633e292ee h1:eSjxL/eA6/dj+tL1lT5zDWF2ECcYrZVwR4nbReiGV0A= -github.com/ava-labs/avalanchego v1.10.15-0.20231027221648-efd633e292ee/go.mod h1:AoVh5J/z6Mv5+Gfx3rvnF79ukO4HU6LM7vhXIcFp/MI= +github.com/ava-labs/avalanchego v1.10.15-rc.1 h1:5MQ6JAojk1oxTkD/Fj833+X3/4ARM1oOuLwNOuOFjKc= +github.com/ava-labs/avalanchego v1.10.15-rc.1/go.mod h1:IT0UDCv0JjeAog/wSC8eFbr/wsmiUhdDZ2wpYVGIFE0= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/plugin/evm/syncervm_test.go b/plugin/evm/syncervm_test.go index 34fd55023f..0b27086c0d 100644 --- a/plugin/evm/syncervm_test.go +++ b/plugin/evm/syncervm_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/chains/atomic" - "github.com/ava-labs/avalanchego/database/manager" + "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" @@ -130,7 +130,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) { if err := syncDisabledVM.Initialize( context.Background(), vmSetup.syncerVM.ctx, - vmSetup.syncerDBManager, + vmSetup.syncerDB, []byte(genesisJSONLatest), nil, []byte(stateSyncDisabledConfigJSON), @@ -193,7 +193,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) { if err := syncReEnabledVM.Initialize( context.Background(), vmSetup.syncerVM.ctx, - vmSetup.syncerDBManager, + vmSetup.syncerDB, []byte(genesisJSONLatest), nil, []byte(configJSON), @@ -342,7 +342,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest) *syncVMSetup { // initialise [syncerVM] with blank genesis state stateSyncEnabledJSON := fmt.Sprintf(`{"state-sync-enabled":true, "state-sync-min-blocks": %d}`, test.stateSyncMinBlocks) - syncerEngineChan, syncerVM, syncerDBManager, syncerAtomicMemory, syncerAppSender := GenesisVMWithUTXOs( + syncerEngineChan, syncerVM, syncerDB, syncerAtomicMemory, syncerAppSender := GenesisVMWithUTXOs( t, false, "", stateSyncEnabledJSON, "", alloc, ) shutdownOnceSyncerVM := &shutdownOnceVM{VM: syncerVM} @@ -395,7 +395,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest) *syncVMSetup { }, fundedAccounts: accounts, syncerVM: syncerVM, - syncerDBManager: syncerDBManager, + syncerDB: syncerDB, syncerEngineChan: syncerEngineChan, syncerAtomicMemory: syncerAtomicMemory, shutdownOnceSyncerVM: shutdownOnceSyncerVM, @@ -412,7 +412,7 @@ type syncVMSetup struct { fundedAccounts map[*keystore.Key]*types.StateAccount syncerVM *VM - syncerDBManager manager.Manager + syncerDB database.Database syncerEngineChan <-chan commonEng.Message syncerAtomicMemory *atomic.Memory shutdownOnceSyncerVM *shutdownOnceVM diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 8ef1a72f46..af5d43a829 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -66,7 +66,6 @@ import ( "github.com/ava-labs/avalanchego/codec" "github.com/ava-labs/avalanchego/codec/linearcodec" "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/avalanchego/database/manager" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" @@ -358,7 +357,7 @@ func (vm *VM) GetActivationTime() time.Time { func (vm *VM) Initialize( _ context.Context, chainCtx *snow.Context, - dbManager manager.Manager, + db database.Database, genesisBytes []byte, upgradeBytes []byte, configBytes []byte, @@ -414,11 +413,10 @@ func (vm *VM) Initialize( vm.toEngine = toEngine vm.shutdownChan = make(chan struct{}, 1) - baseDB := dbManager.Current().Database // Use NewNested rather than New so that the structure of the database // remains the same regardless of the provided baseDB type. - vm.chaindb = Database{prefixdb.NewNested(ethDBPrefix, baseDB)} - vm.db = versiondb.New(baseDB) + vm.chaindb = Database{prefixdb.NewNested(ethDBPrefix, db)} + vm.db = versiondb.New(db) vm.acceptedBlockDB = prefixdb.New(acceptedPrefix, vm.db) vm.metadataDB = prefixdb.New(metadataPrefix, vm.db) diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index 130d66c285..42050e1162 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -36,7 +36,8 @@ import ( "github.com/ava-labs/avalanchego/api/keystore" "github.com/ava-labs/avalanchego/chains/atomic" - "github.com/ava-labs/avalanchego/database/manager" + "github.com/ava-labs/avalanchego/database" + "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" @@ -50,7 +51,6 @@ import ( "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/avalanchego/version" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/chain" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -176,7 +176,7 @@ func NewContext() *snow.Context { func setupGenesis(t *testing.T, genesisJSON string, ) (*snow.Context, - manager.Manager, + database.Database, []byte, chan engCommon.Message, *atomic.Memory) { @@ -186,13 +186,9 @@ func setupGenesis(t *testing.T, genesisBytes := BuildGenesisTest(t, genesisJSON) ctx := NewContext() - baseDBManager := manager.NewMemDB(&version.Semantic{ - Major: 1, - Minor: 4, - Patch: 5, - }) + baseDB := memdb.New() - m := atomic.NewMemory(prefixdb.New([]byte{0}, baseDBManager.Current().Database)) + m := atomic.NewMemory(prefixdb.New([]byte{0}, baseDB)) ctx.SharedMemory = m.NewSharedMemory(ctx.ChainID) // NB: this lock is intentionally left locked when this function returns. @@ -201,11 +197,7 @@ func setupGenesis(t *testing.T, userKeystore := keystore.New( logging.NoLog{}, - manager.NewMemDB(&version.Semantic{ - Major: 1, - Minor: 4, - Patch: 5, - }), + memdb.New(), ) if err := userKeystore.CreateUser(username, password); err != nil { t.Fatal(err) @@ -213,8 +205,8 @@ func setupGenesis(t *testing.T, ctx.Keystore = userKeystore.NewBlockchainKeyStore(ctx.ChainID) issuer := make(chan engCommon.Message, 1) - prefixedDBManager := baseDBManager.NewPrefixDBManager([]byte{1}) - return ctx, prefixedDBManager, genesisBytes, issuer, m + prefixedDB := prefixdb.New([]byte{1}, baseDB) + return ctx, prefixedDB, genesisBytes, issuer, m } // GenesisVM creates a VM instance with the genesis test bytes and returns @@ -226,18 +218,18 @@ func GenesisVM(t *testing.T, configJSON string, upgradeJSON string, ) (chan engCommon.Message, - *VM, manager.Manager, + *VM, database.Database, *atomic.Memory, *engCommon.SenderTest) { vm := &VM{} - ctx, dbManager, genesisBytes, issuer, m := setupGenesis(t, genesisJSON) + ctx, db, genesisBytes, issuer, m := setupGenesis(t, genesisJSON) appSender := &engCommon.SenderTest{T: t} appSender.CantSendAppGossip = true appSender.SendAppGossipF = func(context.Context, []byte) error { return nil } if err := vm.Initialize( context.Background(), ctx, - dbManager, + db, genesisBytes, []byte(upgradeJSON), []byte(configJSON), @@ -253,7 +245,7 @@ func GenesisVM(t *testing.T, assert.NoError(t, vm.SetState(context.Background(), snow.NormalOp)) } - return issuer, vm, dbManager, m, appSender + return issuer, vm, db, m, appSender } func addUTXO(sharedMemory *atomic.Memory, ctx *snow.Context, txID ids.ID, index uint32, assetID ids.ID, amount uint64, addr ids.ShortID) (*avax.UTXO, error) { @@ -294,8 +286,8 @@ func addUTXO(sharedMemory *atomic.Memory, ctx *snow.Context, txID ids.ID, index // GenesisVMWithUTXOs creates a GenesisVM and generates UTXOs in the X-Chain Shared Memory containing AVAX based on the [utxos] map // Generates UTXOIDs by using a hash of the address in the [utxos] map such that the UTXOs will be generated deterministically. // If [genesisJSON] is empty, defaults to using [genesisJSONLatest] -func GenesisVMWithUTXOs(t *testing.T, finishBootstrapping bool, genesisJSON string, configJSON string, upgradeJSON string, utxos map[ids.ShortID]uint64) (chan engCommon.Message, *VM, manager.Manager, *atomic.Memory, *engCommon.SenderTest) { - issuer, vm, dbManager, sharedMemory, sender := GenesisVM(t, finishBootstrapping, genesisJSON, configJSON, upgradeJSON) +func GenesisVMWithUTXOs(t *testing.T, finishBootstrapping bool, genesisJSON string, configJSON string, upgradeJSON string, utxos map[ids.ShortID]uint64) (chan engCommon.Message, *VM, database.Database, *atomic.Memory, *engCommon.SenderTest) { + issuer, vm, db, sharedMemory, sender := GenesisVM(t, finishBootstrapping, genesisJSON, configJSON, upgradeJSON) for addr, avaxAmount := range utxos { txID, err := ids.ToID(hashing.ComputeHash256(addr.Bytes())) if err != nil { @@ -306,7 +298,7 @@ func GenesisVMWithUTXOs(t *testing.T, finishBootstrapping bool, genesisJSON stri } } - return issuer, vm, dbManager, sharedMemory, sender + return issuer, vm, db, sharedMemory, sender } func TestVMConfig(t *testing.T) { diff --git a/scripts/versions.sh b/scripts/versions.sh index d3c6ab5a3e..9086e54fba 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Don't export them as they're used in the context of other calls -avalanche_version=${AVALANCHE_VERSION:-'826f9415'} +avalanche_version=${AVALANCHE_VERSION:-'v1.10.15-rc.1'}