From f28f99d2ccb08a07e25dfa42a5f0ce848da96734 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Wed, 28 Aug 2024 07:07:20 -0700 Subject: [PATCH 1/2] bump avalanchego to master --- go.mod | 2 +- go.sum | 2 + precompile/contracts/warp/predicate_test.go | 11 ----- .../warp/signature_verification_test.go | 44 ++++++++++++------- scripts/versions.sh | 2 +- warp/validators/state_test.go | 3 +- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index f033cf4918..2e56608d7d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21.12 require ( github.com/VictoriaMetrics/fastcache v1.12.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/avalanchego v1.11.11-0.20240821175119-35c66e33f0dc + github.com/ava-labs/avalanchego v1.11.11-monitoring-url.0.20240827194054-0117ab96791c 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 17e8f63025..2aa5b13464 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/ava-labs/avalanchego v1.11.11-0.20240821175119-35c66e33f0dc h1:cUz1N+LJIeQAR0Z6zTBiuZ7s8GqIE5QQbRWs423VFRA= github.com/ava-labs/avalanchego v1.11.11-0.20240821175119-35c66e33f0dc/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM= +github.com/ava-labs/avalanchego v1.11.11-monitoring-url.0.20240827194054-0117ab96791c h1:WAbq2clkTkoxELkCePFe7sqwOvD32SZPzoWtciUmzQI= +github.com/ava-labs/avalanchego v1.11.11-monitoring-url.0.20240827194054-0117ab96791c/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM= github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk= github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180/go.mod h1:/wNBVq7J7wlC2Kbov7kk6LV5xZvau7VF9zwTVOeyAjY= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= diff --git a/precompile/contracts/warp/predicate_test.go b/precompile/contracts/warp/predicate_test.go index 23b82644a5..1c7b08a7c0 100644 --- a/precompile/contracts/warp/predicate_test.go +++ b/precompile/contracts/warp/predicate_test.go @@ -25,7 +25,6 @@ import ( "github.com/ava-labs/subnet-evm/predicate" "github.com/ava-labs/subnet-evm/utils" "github.com/stretchr/testify/require" - "go.uber.org/mock/gomock" ) const pChainHeight uint64 = 1337 @@ -49,7 +48,6 @@ var ( numTestVdrs = 10_000 testVdrs []*testValidator vdrs map[ids.NodeID]*validators.GetValidatorOutput - tests []signatureTest predicateTests = make(map[string]testutils.PredicateTest) ) @@ -132,15 +130,6 @@ func newTestValidator() *testValidator { } } -type signatureTest struct { - name string - stateF func(*gomock.Controller) validators.State - quorumNum uint64 - quorumDen uint64 - msgF func(*require.Assertions) *avalancheWarp.Message - err error -} - // createWarpMessage constructs a signed warp message using the global variable [unsignedMsg] // and the first [numKeys] signatures from [blsSignatures] func createWarpMessage(numKeys int) *avalancheWarp.Message { diff --git a/precompile/contracts/warp/signature_verification_test.go b/precompile/contracts/warp/signature_verification_test.go index dadefeb4d6..5b54cd29b8 100644 --- a/precompile/contracts/warp/signature_verification_test.go +++ b/precompile/contracts/warp/signature_verification_test.go @@ -10,6 +10,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorsmock" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/set" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" @@ -17,14 +18,23 @@ import ( "go.uber.org/mock/gomock" ) -// This test copies the test coverage from https://github.com/ava-labs/avalanchego/blob/v1.10.0/vms/platformvm/warp/signature_test.go#L137. +type signatureTest struct { + name string + stateF func(*gomock.Controller) validators.State + quorumNum uint64 + quorumDen uint64 + msgF func(*require.Assertions) *avalancheWarp.Message + err error +} + +// This test copies the test coverage from https://github.com/ava-labs/avalanchego/blob/0117ab96/vms/platformvm/warp/signature_test.go#L137. // These tests are only expected to fail if there is a breaking change in AvalancheGo that unexpectedly changes behavior. func TestSignatureVerification(t *testing.T) { - tests = []signatureTest{ + tests := []signatureTest{ { name: "can't get subnetID", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, errTest) return state }, @@ -50,7 +60,7 @@ func TestSignatureVerification(t *testing.T) { { name: "can't get validator set", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(nil, errTest) return state @@ -77,7 +87,7 @@ func TestSignatureVerification(t *testing.T) { { name: "weight overflow", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(map[ids.NodeID]*validators.GetValidatorOutput{ testVdrs[0].nodeID: { @@ -117,7 +127,7 @@ func TestSignatureVerification(t *testing.T) { { name: "invalid bit set index", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -147,7 +157,7 @@ func TestSignatureVerification(t *testing.T) { { name: "unknown index", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -180,7 +190,7 @@ func TestSignatureVerification(t *testing.T) { { name: "insufficient weight", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -224,7 +234,7 @@ func TestSignatureVerification(t *testing.T) { { name: "can't parse sig", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -258,7 +268,7 @@ func TestSignatureVerification(t *testing.T) { { name: "no validators", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(nil, nil) return state @@ -293,7 +303,7 @@ func TestSignatureVerification(t *testing.T) { { name: "invalid signature (substitute)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -337,7 +347,7 @@ func TestSignatureVerification(t *testing.T) { { name: "invalid signature (missing one)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -377,7 +387,7 @@ func TestSignatureVerification(t *testing.T) { { name: "invalid signature (extra one)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -422,7 +432,7 @@ func TestSignatureVerification(t *testing.T) { { name: "valid signature", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -466,7 +476,7 @@ func TestSignatureVerification(t *testing.T) { { name: "valid signature (boundary)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(vdrs, nil) return state @@ -510,7 +520,7 @@ func TestSignatureVerification(t *testing.T) { { name: "valid signature (missing key)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(map[ids.NodeID]*validators.GetValidatorOutput{ testVdrs[0].nodeID: { @@ -571,7 +581,7 @@ func TestSignatureVerification(t *testing.T) { { name: "valid signature (duplicate key)", stateF: func(ctrl *gomock.Controller) validators.State { - state := validators.NewMockState(ctrl) + state := validatorsmock.NewState(ctrl) state.EXPECT().GetSubnetID(gomock.Any(), sourceChainID).Return(sourceSubnetID, nil) state.EXPECT().GetValidatorSet(gomock.Any(), pChainHeight, sourceSubnetID).Return(map[ids.NodeID]*validators.GetValidatorOutput{ testVdrs[0].nodeID: { diff --git a/scripts/versions.sh b/scripts/versions.sh index 908b8603ee..faee809b7c 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -4,7 +4,7 @@ # shellcheck disable=SC2034 # Don't export them as they're used in the context of other calls -AVALANCHE_VERSION=${AVALANCHE_VERSION:-'35c66e33'} +AVALANCHE_VERSION=${AVALANCHE_VERSION:-'0117ab96'} GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'} # This won't be used, but it's here to make code syncs easier diff --git a/warp/validators/state_test.go b/warp/validators/state_test.go index b3dc67ac51..2a67415865 100644 --- a/warp/validators/state_test.go +++ b/warp/validators/state_test.go @@ -9,6 +9,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/snow/validators/validatorsmock" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/subnet-evm/utils" "github.com/stretchr/testify/require" @@ -22,7 +23,7 @@ func TestGetValidatorSetPrimaryNetwork(t *testing.T) { mySubnetID := ids.GenerateTestID() otherSubnetID := ids.GenerateTestID() - mockState := validators.NewMockState(ctrl) + mockState := validatorsmock.NewState(ctrl) snowCtx := utils.TestSnowContext() snowCtx.SubnetID = mySubnetID snowCtx.ValidatorState = mockState From d9163843deb42782cb29e07b08a33e1d781161d5 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Wed, 28 Aug 2024 07:08:12 -0700 Subject: [PATCH 2/2] go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 2aa5b13464..e4768cae01 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.11.11-0.20240821175119-35c66e33f0dc h1:cUz1N+LJIeQAR0Z6zTBiuZ7s8GqIE5QQbRWs423VFRA= -github.com/ava-labs/avalanchego v1.11.11-0.20240821175119-35c66e33f0dc/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM= github.com/ava-labs/avalanchego v1.11.11-monitoring-url.0.20240827194054-0117ab96791c h1:WAbq2clkTkoxELkCePFe7sqwOvD32SZPzoWtciUmzQI= github.com/ava-labs/avalanchego v1.11.11-monitoring-url.0.20240827194054-0117ab96791c/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM= github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk=