diff --git a/go.mod b/go.mod index 6b67463c7b..2487d92562 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.12 require ( github.com/VictoriaMetrics/fastcache v1.12.1 - github.com/ava-labs/avalanchego v1.11.10-prerelease + github.com/ava-labs/avalanchego v1.11.11-0.20240805141503-7e985b530bef github.com/cespare/cp v0.1.0 github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index 12b0fb5d68..d7ba29072d 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.11.10-prerelease h1:QUhVqvxrwDmsTvXXnKoePe5WU3Eh8GXB/QE2R2xHa0c= -github.com/ava-labs/avalanchego v1.11.10-prerelease/go.mod h1:ryRFbHr7sKmez4792NxzJS7AGiE+vd0Tez+qs2kmezE= +github.com/ava-labs/avalanchego v1.11.11-0.20240805141503-7e985b530bef h1:w0N/YXgNoXjDUwdFHGpWYq41uHxvBneHaJ+X0BxSj2w= +github.com/ava-labs/avalanchego v1.11.11-0.20240805141503-7e985b530bef/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/peer/network_test.go b/peer/network_test.go index 51060dac4c..c431d27488 100644 --- a/peer/network_test.go +++ b/peer/network_test.go @@ -14,6 +14,7 @@ import ( "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/snow/engine/enginetest" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" ethcommon "github.com/ethereum/go-ethereum/common" @@ -510,7 +511,7 @@ func TestHandleInvalidMessages(t *testing.T) { nodeID := ids.GenerateTestNodeID() requestID := uint32(1) - sender := &common.SenderTest{ + sender := &enginetest.Sender{ SendAppErrorF: func(context.Context, ids.NodeID, uint32, int32, string) error { return nil }, diff --git a/plugin/evm/syncervm_test.go b/plugin/evm/syncervm_test.go index c4f5ee304e..11b66802a5 100644 --- a/plugin/evm/syncervm_test.go +++ b/plugin/evm/syncervm_test.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/snow/engine/enginetest" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/set" @@ -127,7 +128,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) { test.expectedErr = nil syncDisabledVM := &VM{} - appSender := &commonEng.SenderTest{T: t} + appSender := &enginetest.Sender{T: t} appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil } appSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error { nodeID, hasItem := nodeSet.Pop() @@ -421,7 +422,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest, numBlocks int) *s // off of a server VM. type syncVMSetup struct { serverVM *VM - serverAppSender *commonEng.SenderTest + serverAppSender *enginetest.Sender includedAtomicTxs []*Tx fundedAccounts map[*keystore.Key]*types.StateAccount diff --git a/plugin/evm/tx_gossip_test.go b/plugin/evm/tx_gossip_test.go index 67f3868435..4da9713d68 100644 --- a/plugin/evm/tx_gossip_test.go +++ b/plugin/evm/tx_gossip_test.go @@ -19,7 +19,9 @@ import ( "github.com/ava-labs/avalanchego/proto/pb/sdk" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/snow/engine/enginetest" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorstest" agoUtils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/logging" @@ -41,7 +43,7 @@ func TestEthTxGossip(t *testing.T) { require := require.New(t) ctx := context.Background() snowCtx := utils.TestSnowContext() - validatorState := &validators.TestState{} + validatorState := &validatorstest.State{} snowCtx.ValidatorState = validatorState pk, err := secp256k1.NewPrivateKey() @@ -51,7 +53,7 @@ func TestEthTxGossip(t *testing.T) { genesisBytes, err := genesis.MarshalJSON() require.NoError(err) - responseSender := &common.FakeSender{ + responseSender := &enginetest.SenderStub{ SentAppResponse: make(chan []byte, 1), } vm := &VM{ @@ -69,7 +71,7 @@ func TestEthTxGossip(t *testing.T) { nil, make(chan common.Message), nil, - &common.SenderTest{}, + &enginetest.Sender{}, )) require.NoError(vm.SetState(ctx, snow.NormalOp)) @@ -78,7 +80,7 @@ func TestEthTxGossip(t *testing.T) { }() // sender for the peer requesting gossip from [vm] - peerSender := &common.FakeSender{ + peerSender := &enginetest.SenderStub{ SentAppRequest: make(chan []byte, 1), } @@ -168,7 +170,7 @@ func TestAtomicTxGossip(t *testing.T) { snowCtx := utils.TestSnowContext() snowCtx.AVAXAssetID = ids.GenerateTestID() snowCtx.XChainID = ids.GenerateTestID() - validatorState := &validators.TestState{ + validatorState := &validatorstest.State{ GetSubnetIDF: func(context.Context, ids.ID) (ids.ID, error) { return ids.Empty, nil }, @@ -184,7 +186,7 @@ func TestAtomicTxGossip(t *testing.T) { genesisBytes, err := genesis.MarshalJSON() require.NoError(err) - responseSender := &common.FakeSender{ + responseSender := &enginetest.SenderStub{ SentAppResponse: make(chan []byte, 1), } vm := &VM{ @@ -202,7 +204,7 @@ func TestAtomicTxGossip(t *testing.T) { nil, make(chan common.Message), nil, - &common.SenderTest{}, + &enginetest.Sender{}, )) require.NoError(vm.SetState(ctx, snow.NormalOp)) @@ -211,7 +213,7 @@ func TestAtomicTxGossip(t *testing.T) { }() // sender for the peer requesting gossip from [vm] - peerSender := &common.FakeSender{ + peerSender := &enginetest.SenderStub{ SentAppRequest: make(chan []byte, 1), } network, err := p2p.NewNetwork(logging.NoLog{}, peerSender, prometheus.NewRegistry(), "") @@ -306,7 +308,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) { require := require.New(t) ctx := context.Background() snowCtx := utils.TestSnowContext() - snowCtx.ValidatorState = &validators.TestState{ + snowCtx.ValidatorState = &validatorstest.State{ GetCurrentHeightF: func(context.Context) (uint64, error) { return 0, nil }, @@ -314,7 +316,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) { return nil, nil }, } - sender := &common.FakeSender{ + sender := &enginetest.SenderStub{ SentAppGossip: make(chan []byte, 1), } @@ -377,7 +379,7 @@ func TestEthTxPushGossipInbound(t *testing.T) { ctx := context.Background() snowCtx := utils.TestSnowContext() - sender := &common.SenderTest{} + sender := &enginetest.Sender{} vm := &VM{ p2pSender: sender, ethTxPullGossiper: gossip.NoOpGossiper{}, @@ -439,7 +441,7 @@ func TestAtomicTxPushGossipOutbound(t *testing.T) { snowCtx := utils.TestSnowContext() snowCtx.AVAXAssetID = ids.GenerateTestID() snowCtx.XChainID = ids.GenerateTestID() - validatorState := &validators.TestState{ + validatorState := &validatorstest.State{ GetSubnetIDF: func(context.Context, ids.ID) (ids.ID, error) { return ids.Empty, nil }, @@ -455,7 +457,7 @@ func TestAtomicTxPushGossipOutbound(t *testing.T) { genesisBytes, err := genesis.MarshalJSON() require.NoError(err) - sender := &common.FakeSender{ + sender := &enginetest.SenderStub{ SentAppGossip: make(chan []byte, 1), } vm := &VM{ @@ -473,7 +475,7 @@ func TestAtomicTxPushGossipOutbound(t *testing.T) { nil, make(chan common.Message), nil, - &common.FakeSender{}, + &enginetest.SenderStub{}, )) require.NoError(vm.SetState(ctx, snow.NormalOp)) @@ -517,7 +519,7 @@ func TestAtomicTxPushGossipInbound(t *testing.T) { snowCtx := utils.TestSnowContext() snowCtx.AVAXAssetID = ids.GenerateTestID() snowCtx.XChainID = ids.GenerateTestID() - validatorState := &validators.TestState{ + validatorState := &validatorstest.State{ GetSubnetIDF: func(context.Context, ids.ID) (ids.ID, error) { return ids.Empty, nil }, @@ -533,7 +535,7 @@ func TestAtomicTxPushGossipInbound(t *testing.T) { genesisBytes, err := genesis.MarshalJSON() require.NoError(err) - sender := &common.SenderTest{} + sender := &enginetest.Sender{} vm := &VM{ p2pSender: sender, ethTxPullGossiper: gossip.NoOpGossiper{}, @@ -549,7 +551,7 @@ func TestAtomicTxPushGossipInbound(t *testing.T) { nil, make(chan common.Message), nil, - &common.FakeSender{}, + &enginetest.SenderStub{}, )) require.NoError(vm.SetState(ctx, snow.NormalOp)) diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index e14b04ddc0..1137774f1e 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -41,7 +41,7 @@ import ( "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/utils/cb58" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" @@ -56,6 +56,7 @@ import ( "github.com/ava-labs/avalanchego/vms/secp256k1fx" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/snow/engine/enginetest" constantsEng "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/coreth/consensus/dummy" @@ -216,7 +217,7 @@ func NewContext() *snow.Context { _ = aliaser.Alias(testCChainID, testCChainID.String()) _ = aliaser.Alias(testXChainID, "X") _ = aliaser.Alias(testXChainID, testXChainID.String()) - ctx.ValidatorState = &validators.TestState{ + ctx.ValidatorState = &validatorstest.State{ GetSubnetIDF: func(_ context.Context, chainID ids.ID) (ids.ID, error) { subnetID, ok := map[ids.ID]ids.ID{ constantsEng.PlatformChainID: constantsEng.PrimaryNetworkID, @@ -285,10 +286,11 @@ func GenesisVM(t *testing.T, genesisJSON string, configJSON string, upgradeJSON string, -) (chan commonEng.Message, +) ( + chan commonEng.Message, *VM, database.Database, *atomic.Memory, - *commonEng.SenderTest, + *enginetest.Sender, ) { return GenesisVMWithClock(t, finishBootstrapping, genesisJSON, configJSON, upgradeJSON, mockable.Clock{}) } @@ -302,15 +304,16 @@ func GenesisVMWithClock( configJSON string, upgradeJSON string, clock mockable.Clock, -) (chan commonEng.Message, +) ( + chan commonEng.Message, *VM, database.Database, *atomic.Memory, - *commonEng.SenderTest, + *enginetest.Sender, ) { vm := &VM{clock: clock} - vm.p2pSender = &commonEng.FakeSender{} + vm.p2pSender = &enginetest.SenderStub{} ctx, dbManager, genesisBytes, issuer, m := setupGenesis(t, genesisJSON) - appSender := &commonEng.SenderTest{T: t} + appSender := &enginetest.Sender{T: t} appSender.CantSendAppGossip = true appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil } err := vm.Initialize( @@ -372,7 +375,7 @@ 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 commonEng.Message, *VM, database.Database, *atomic.Memory, *commonEng.SenderTest) { +func GenesisVMWithUTXOs(t *testing.T, finishBootstrapping bool, genesisJSON string, configJSON string, upgradeJSON string, utxos map[ids.ShortID]uint64) (chan commonEng.Message, *VM, database.Database, *atomic.Memory, *enginetest.Sender) { issuer, vm, db, sharedMemory, sender := GenesisVM(t, finishBootstrapping, genesisJSON, configJSON, upgradeJSON) for addr, avaxAmount := range utxos { txID, err := ids.ToID(hashing.ComputeHash256(addr.Bytes())) @@ -3298,7 +3301,7 @@ func TestConfigureLogLevel(t *testing.T) { t.Run(test.name, func(t *testing.T) { vm := &VM{} ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, test.genesisJSON) - appSender := &commonEng.SenderTest{T: t} + appSender := &enginetest.Sender{T: t} appSender.CantSendAppGossip = true appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil } err := vm.Initialize( diff --git a/plugin/evm/vm_warp_test.go b/plugin/evm/vm_warp_test.go index 7d93d69699..a447950d07 100644 --- a/plugin/evm/vm_warp_test.go +++ b/plugin/evm/vm_warp_test.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/set" @@ -262,7 +263,7 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned minimumValidPChainHeight := uint64(10) getValidatorSetTestErr := errors.New("can't get validator set test error") - vm.ctx.ValidatorState = &validators.TestState{ + vm.ctx.ValidatorState = &validatorstest.State{ // TODO: test both Primary Network / C-Chain and non-Primary Network GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { return ids.Empty, nil @@ -425,7 +426,7 @@ func TestReceiveWarpMessage(t *testing.T) { minimumValidPChainHeight := uint64(10) getValidatorSetTestErr := errors.New("can't get validator set test error") - vm.ctx.ValidatorState = &validators.TestState{ + vm.ctx.ValidatorState = &validatorstest.State{ GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { return ids.Empty, nil }, diff --git a/precompile/contracts/warp/predicate_test.go b/precompile/contracts/warp/predicate_test.go index b0af56447e..d0351b844b 100644 --- a/precompile/contracts/warp/predicate_test.go +++ b/precompile/contracts/warp/predicate_test.go @@ -13,6 +13,7 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorstest" agoUtils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -197,7 +198,7 @@ func createSnowCtx(validatorRanges []validatorRange) *snow.Context { } snowCtx := utils.TestSnowContext() - state := &validators.TestState{ + state := &validatorstest.State{ GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { return sourceSubnetID, nil }, @@ -266,7 +267,7 @@ func TestWarpMessageFromPrimaryNetwork(t *testing.T) { snowCtx.ChainID = ids.GenerateTestID() snowCtx.CChainID = cChainID snowCtx.NetworkID = networkID - snowCtx.ValidatorState = &validators.TestState{ + snowCtx.ValidatorState = &validatorstest.State{ GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { require.Equal(chainID, cChainID) return constants.PrimaryNetworkID, nil // Return Primary Network SubnetID @@ -666,7 +667,7 @@ func initWarpPredicateTests() { snowCtx := utils.TestSnowContext() snowCtx.NetworkID = networkID - state := &validators.TestState{ + state := &validatorstest.State{ GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { return sourceSubnetID, nil }, diff --git a/scripts/versions.sh b/scripts/versions.sh index 6d6d53d2db..7ca0515428 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -6,4 +6,4 @@ set -euo pipefail # Don't export them as they're used in the context of other calls -AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.10-prerelease'} +AVALANCHE_VERSION=${AVALANCHE_VERSION:-'7e985b530beff5afe03967f5fa94a2eee998cb7a'} diff --git a/utils/snow.go b/utils/snow.go index 96c13708d3..92a1d236c1 100644 --- a/utils/snow.go +++ b/utils/snow.go @@ -7,7 +7,7 @@ import ( "github.com/ava-labs/avalanchego/api/metrics" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/logging" ) @@ -28,6 +28,6 @@ func TestSnowContext() *snow.Context { BCLookup: ids.NewAliaser(), Metrics: metrics.NewMultiGatherer(), ChainDataDir: "", - ValidatorState: &validators.TestState{}, + ValidatorState: &validatorstest.State{}, } }