diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 314e88a9b7f..1ead144d183 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -26,7 +26,7 @@ require ( github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-common v0.3.1-0.20241109002240-af894848b3b4 github.com/smartcontractkit/chainlink/deployment v0.0.0-00010101000000-000000000000 - github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 + github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 diff --git a/core/services/relay/evm/bindings/chain_config_factory.go b/core/services/relay/evm/bindings/chain_config_factory.go index 8bd30cf9d5b..4dfaffe80dc 100644 --- a/core/services/relay/evm/bindings/chain_config_factory.go +++ b/core/services/relay/evm/bindings/chain_config_factory.go @@ -2,6 +2,7 @@ package bindings import ( "github.com/ethereum/go-ethereum/common" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" ) diff --git a/core/services/relay/evm/chain_writer_historical_wrapper_test.go b/core/services/relay/evm/chain_writer_historical_wrapper_test.go index 669ec9e7953..233d7bc2e2f 100644 --- a/core/services/relay/evm/chain_writer_historical_wrapper_test.go +++ b/core/services/relay/evm/chain_writer_historical_wrapper_test.go @@ -2,12 +2,13 @@ package evm import ( "context" - "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/bindings" + "math/big" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" interfacetesttypes "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" - primitives "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" + "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" + "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/bindings" ) // This wrapper is required to enable the ChainReader to access historical data diff --git a/core/services/relay/evm/evmtesting/bindings_test_adapter.go b/core/services/relay/evm/evmtesting/bindings_test_adapter.go index 812f1bd9989..f75063f0012 100644 --- a/core/services/relay/evm/evmtesting/bindings_test_adapter.go +++ b/core/services/relay/evm/evmtesting/bindings_test_adapter.go @@ -4,8 +4,14 @@ import ( "context" "errors" "fmt" + "math/big" + "reflect" + "strings" + "testing" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/go-viper/mapstructure/v2" + "github.com/smartcontractkit/chainlink-common/pkg/codec" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" @@ -14,10 +20,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/bindings" evmcodec "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/codec" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" - "math/big" - "reflect" - "strings" - "testing" ) const contractName = "ChainReaderTester" @@ -25,7 +27,7 @@ const contractName = "ChainReaderTester" // Wraps EVMChainComponentsInterfaceTester to rely on the EVM bindings generated for CR/CW instead of going directly to CR/CW. This way we can reuse all existing tests. Transformation between expected // contract names and read keys will be done here as well as invocation delegation to generated code. func WrapContractReaderTesterWithBindings(t *testing.T, wrapped *EVMChainComponentsInterfaceTester[*testing.T]) interfacetests.ChainComponentsInterfaceTester[*testing.T] { - //Tests not yet supported by EVM bindings. + // Tests not yet supported by EVM bindings. wrapped.DisableTests([]string{ interfacetests.ContractReaderGetLatestValueAsValuesDotValue, interfacetests.ContractReaderGetLatestValueNoArgumentsAndPrimitiveReturnAsValuesDotValue, interfacetests.ContractReaderGetLatestValueNoArgumentsAndSliceReturnAsValueDotValue, interfacetests.ContractReaderGetLatestValueGetsLatestForEvent, interfacetests.ContractReaderGetLatestValueBasedOnConfidenceLevelForEvent, @@ -72,7 +74,7 @@ func newBindingsMapping() bindingsMapping { interfacetests.MethodReturningUint64: "GetDifferentPrimitiveValue", } - bindingsMapping := bindingsMapping{ + bm := bindingsMapping{ contractNameMapping: map[string]string{ interfacetests.AnyContractName: contractName, interfacetests.AnySecondContractName: contractName, @@ -82,10 +84,10 @@ func newBindingsMapping() bindingsMapping { chainWriterProxy: &chainWriterProxy, chainReaderTesters: map[string]*bindings.ChainReaderTester{}, } - contractReaderProxy.bm = &bindingsMapping - chainWriterProxy.bm = &bindingsMapping - bindingsMapping.createDelegates() - return bindingsMapping + contractReaderProxy.bm = &bm + chainWriterProxy.bm = &bm + bm.createDelegates() + return bm } func getChainReaderConfig(wrapped *EVMChainComponentsInterfaceTester[*testing.T]) types.ChainReaderConfig { @@ -195,11 +197,11 @@ func (b bindingContractReaderProxy) Bind(ctx context.Context, boundContracts []c } func (b bindingsMapping) translateContractNames(boundContracts []commontypes.BoundContract) []commontypes.BoundContract { - updatedBindings := []commontypes.BoundContract{} + updatedBindings := make([]commontypes.BoundContract, 0, len(boundContracts)) for _, boundContract := range boundContracts { updatedBindings = append(updatedBindings, commontypes.BoundContract{ - boundContract.Address, - b.translateContractName(boundContract.Name), + Address: boundContract.Address, + Name: b.translateContractName(boundContract.Name), }) } return updatedBindings @@ -235,15 +237,15 @@ func (b bindingChainWriterProxy) SubmitTransaction(ctx context.Context, contract switch method { case interfacetests.MethodSettingStruct: bindingsInput := bindings.AddTestStructInput{} - convertStruct(args, &bindingsInput) + _ = convertStruct(args, &bindingsInput) return chainReaderTesters.AddTestStruct(ctx, bindingsInput, transactionID, toAddress, meta) case interfacetests.MethodSettingUint64: bindingsInput := bindings.SetAlterablePrimitiveValueInput{} - convertStruct(args, &bindingsInput) + _ = convertStruct(args, &bindingsInput) return chainReaderTesters.SetAlterablePrimitiveValue(ctx, bindingsInput, transactionID, toAddress, meta) case interfacetests.MethodTriggeringEvent: bindingsInput := bindings.TriggerEventInput{} - convertStruct(args, &bindingsInput) + _ = convertStruct(args, &bindingsInput) return chainReaderTesters.TriggerEvent(ctx, bindingsInput, transactionID, toAddress, meta) default: return errors.New("No logic implemented for method: " + method) @@ -435,7 +437,7 @@ func (d Delegate) apply(ctx context.Context, readKey string, input any, confiden // Utility function to converted original types from and to bindings expected types. func convertStruct(src any, dst any) error { if reflect.TypeOf(src).Kind() == reflect.Ptr && reflect.TypeOf(dst).Kind() == reflect.Ptr && reflect.TypeOf(src).Elem() == reflect.TypeOf(interfacetests.LatestParams{}) && reflect.TypeOf(dst).Elem() == reflect.TypeOf(bindings.GetElementAtIndexInput{}) { - value := (*src.(*interfacetests.LatestParams)).I + value := src.(*interfacetests.LatestParams).I dst.(*bindings.GetElementAtIndexInput).I = big.NewInt(int64(value)) return nil } @@ -447,12 +449,13 @@ func convertStruct(src any, dst any) error { if err != nil { return err } - if reflect.TypeOf(dst).Elem() == reflect.TypeOf(interfacetests.TestStructWithExtraField{}) { + switch { + case reflect.TypeOf(dst).Elem() == reflect.TypeOf(interfacetests.TestStructWithExtraField{}): destTestStruct := dst.(*interfacetests.TestStructWithExtraField) if destTestStruct != nil { auxTestStruct := &interfacetests.TestStruct{} decoder, _ := createDecoder(auxTestStruct) - decoder.Decode(src) + _ = decoder.Decode(src) destTestStruct.TestStruct = *auxTestStruct sourceTestStruct := src.(bindings.TestStruct) destTestStruct.BigField = sourceTestStruct.BigField @@ -462,7 +465,7 @@ func convertStruct(src any, dst any) error { destTestStruct.NestedDynamicStruct.FixedBytes = sourceTestStruct.NestedDynamicStruct.FixedBytes destTestStruct.ExtraField = interfacetests.AnyExtraValue } - } else if reflect.TypeOf(dst).Elem() == reflect.TypeOf(interfacetests.TestStruct{}) { + case reflect.TypeOf(dst).Elem() == reflect.TypeOf(interfacetests.TestStruct{}): destTestStruct := dst.(*interfacetests.TestStruct) if destTestStruct != nil { sourceTestStruct := src.(bindings.TestStruct) @@ -472,7 +475,7 @@ func convertStruct(src any, dst any) error { destTestStruct.NestedDynamicStruct.Inner.I = int(sourceTestStruct.NestedDynamicStruct.Inner.IntVal) destTestStruct.NestedDynamicStruct.FixedBytes = sourceTestStruct.NestedDynamicStruct.FixedBytes } - } else if reflect.TypeOf(src) == reflect.TypeOf(interfacetests.TestStruct{}) && reflect.TypeOf(dst) == reflect.TypeOf(&bindings.AddTestStructInput{}) { + case reflect.TypeOf(src) == reflect.TypeOf(interfacetests.TestStruct{}) && reflect.TypeOf(dst) == reflect.TypeOf(&bindings.AddTestStructInput{}): destTestStruct := dst.(*bindings.AddTestStructInput) if destTestStruct != nil { sourceTestStruct := src.(interfacetests.TestStruct) @@ -482,7 +485,7 @@ func convertStruct(src any, dst any) error { destTestStruct.NestedDynamicStruct.Inner.IntVal = int64(sourceTestStruct.NestedDynamicStruct.Inner.I) destTestStruct.NestedDynamicStruct.FixedBytes = sourceTestStruct.NestedDynamicStruct.FixedBytes } - } else if reflect.TypeOf(src) == reflect.TypeOf(interfacetests.TestStruct{}) && reflect.TypeOf(dst) == reflect.TypeOf(&bindings.ReturnSeenInput{}) { + case reflect.TypeOf(src) == reflect.TypeOf(interfacetests.TestStruct{}) && reflect.TypeOf(dst) == reflect.TypeOf(&bindings.ReturnSeenInput{}): destTestStruct := dst.(*bindings.ReturnSeenInput) if destTestStruct != nil { sourceTestStruct := src.(interfacetests.TestStruct) diff --git a/core/services/relay/evm/evmtesting/run_tests.go b/core/services/relay/evm/evmtesting/run_tests.go index 43882ef93ac..5f3cdbb2fd7 100644 --- a/core/services/relay/evm/evmtesting/run_tests.go +++ b/core/services/relay/evm/evmtesting/run_tests.go @@ -295,14 +295,14 @@ func RunContractReaderInLoopTests[T TestingT[T]](t T, it ChainComponentsInterfac copy(val5[:], append(empty12Bytes[:], 5)) raw := []byte{9, 8} - var buf []byte - buf = binary.BigEndian.AppendUint32(buf, val1) - buf = binary.BigEndian.AppendUint32(buf, val2) - buf = binary.BigEndian.AppendUint32(buf, val3) - buf = binary.BigEndian.AppendUint64(buf, val4) - dataWordOnChainValueToQuery := buf[:] - - resExpected := append(buf, common.LeftPadBytes(val5[:], 32)...) + var resExpected []byte + resExpected = binary.BigEndian.AppendUint32(resExpected, val1) + resExpected = binary.BigEndian.AppendUint32(resExpected, val2) + resExpected = binary.BigEndian.AppendUint32(resExpected, val3) + resExpected = binary.BigEndian.AppendUint64(resExpected, val4) + dataWordOnChainValueToQuery := resExpected + + resExpected = append(resExpected, common.LeftPadBytes(val5[:], 32)...) resExpected = append(resExpected, common.LeftPadBytes(val6[:], 32)...) resExpected = append(resExpected, common.LeftPadBytes(val7[:], 32)...) resExpected = append(resExpected, raw...) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 7bf5a0e1c36..d00dc09aeed 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -45,7 +45,7 @@ require ( github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.5 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 github.com/smartcontractkit/chainlink/deployment v0.0.0-00010101000000-000000000000 - github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 + github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 441c6eaa4e1..c56e6296c38 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -23,7 +23,7 @@ require ( github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 github.com/smartcontractkit/chainlink/deployment v0.0.0-00010101000000-000000000000 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241030133659-9ec788e78b4f - github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 + github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20241009055228-33d0c0bf38de github.com/stretchr/testify v1.9.0 github.com/wiremock/go-wiremock v1.9.0