diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index c5e1fc5e4d0..b0655915612 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -341,7 +341,7 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn keyStore := keystore.NewInMemory(db, utils.FastScryptParams, lggr, cfg.Database()) - mailMon := mailbox.NewMonitor(cfg.AppID().String()) + mailMon := mailbox.NewMonitor(cfg.AppID().String(), logger.TestLogger(t)) loopRegistry := plugins.NewLoopRegistry(lggr, nil) mercuryPool := wsrpc.NewPool(lggr, cache.Config{ diff --git a/core/internal/testutils/evmtest/evmtest.go b/core/internal/testutils/evmtest/evmtest.go index eb1a03530ae..a88679d0e94 100644 --- a/core/internal/testutils/evmtest/evmtest.go +++ b/core/internal/testutils/evmtest/evmtest.go @@ -119,7 +119,7 @@ func NewChainRelayExtOpts(t testing.TB, testopts TestChainOpts) legacyevm.ChainR } } if opts.MailMon == nil { - opts.MailMon = servicetest.Run(t, mailbox.NewMonitor(t.Name())) + opts.MailMon = servicetest.Run(t, mailbox.NewMonitor(t.Name(), logger.TestLogger(t))) } if testopts.GasEstimator != nil { opts.GenGasEstimator = func(*big.Int) gas.EvmFeeEstimator { diff --git a/core/scripts/go.mod b/core/scripts/go.mod index f084fb66b58..d2bc3922ed3 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -236,10 +236,10 @@ require ( github.com/shirou/gopsutil/v3 v3.23.11 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f // indirect + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 // indirect - github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb // indirect + github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 91950026596..31ba2833cba 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1150,14 +1150,14 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f h1:WZkIB1/XFNvp7BCpxMHzip9GWBjO21O+54w4u1sGiFU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb h1:fMT2rdyUa6PRKTJCI30Gu1e0wfrG5PpIrRS0TJJoS+s= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 h1:WZuC6bBM30RoU4gosJmDWZWegSpGg+/+i4Hx5Dh5eLU= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657/go.mod h1:auN7dRwsZNRQhCvNwtRKCjrXypH7v6OeheN2mO4Qh5g= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb h1:6qnSoCTBtiHcqaILLTvUWd9DIp+TnTkzt+xXcooj/Yw= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 h1:UUHT19viW3IIxsELz3jsvlk5MnID7cMFZlmor4seTKE= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 h1:YHvugDUtaJUzG3itrrvbmn5cU/aPaN2rSYIwWDnlN34= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181/go.mod h1:kY435jBtHbyzhe+ImAxZ6G229uHbB0ablA+A0tJkDn8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea h1:WzMa0O6DEauMYMIjzS/T1JF8zvFDt4aG6EUTDlStaZo= diff --git a/core/services/relay/evm/binding.go b/core/services/relay/evm/binding.go index 465a10b368d..32699516e18 100644 --- a/core/services/relay/evm/binding.go +++ b/core/services/relay/evm/binding.go @@ -130,7 +130,7 @@ func (e *eventBinding) GetLatestValue(_ context.Context, _ any) ([]byte, error) if err != nil { errStr := err.Error() if strings.Contains(errStr, "not found") || strings.Contains(errStr, "no rows") { - return nil, nil + return nil, fmt.Errorf("%w: %w", commontypes.ErrNotFound, err) } return nil, err } diff --git a/core/services/relay/evm/codec.go b/core/services/relay/evm/codec.go index b953d382d83..19b9c6e4f40 100644 --- a/core/services/relay/evm/codec.go +++ b/core/services/relay/evm/codec.go @@ -73,7 +73,7 @@ func (c *evmCodec) CreateType(itemType string, forEncoding bool) (any, error) { def, ok := itemTypes[itemType] if !ok { - return nil, commontypes.ErrInvalidType + return nil, fmt.Errorf("%w: cannot find type name %s", commontypes.ErrInvalidType, itemType) } return reflect.New(def.checkedType).Interface(), nil diff --git a/core/services/relay/evm/codec_entry.go b/core/services/relay/evm/codec_entry.go index 1ef5d4f0591..17289844b4b 100644 --- a/core/services/relay/evm/codec_entry.go +++ b/core/services/relay/evm/codec_entry.go @@ -61,7 +61,7 @@ func (entry *codecEntry) Init() error { func (entry *codecEntry) GetMaxSize(n int) (int, error) { if entry == nil { - return 0, commontypes.ErrInvalidType + return 0, fmt.Errorf("%w: nil entry", commontypes.ErrInvalidType) } return GetMaxSize(n, entry.Args) } @@ -104,7 +104,8 @@ func getNativeAndCheckedTypes(curType *abi.Type) (reflect.Type, reflect.Type, er } curType = curType.Elem default: - return nil, nil, commontypes.ErrInvalidType + return nil, nil, fmt.Errorf( + "%w: cannot create type for kind %v", commontypes.ErrInvalidType, curType.GetType().Kind()) } } base, ok := types.GetType(curType.String()) diff --git a/core/services/relay/evm/decoder.go b/core/services/relay/evm/decoder.go index 96f560ae9a8..1b717b1a445 100644 --- a/core/services/relay/evm/decoder.go +++ b/core/services/relay/evm/decoder.go @@ -2,6 +2,8 @@ package evm import ( "context" + "encoding/json" + "fmt" "reflect" "github.com/mitchellh/mapstructure" @@ -18,7 +20,7 @@ var _ commontypes.Decoder = &decoder{} func (m *decoder) Decode(ctx context.Context, raw []byte, into any, itemType string) error { info, ok := m.Definitions[itemType] if !ok { - return commontypes.ErrInvalidType + return fmt.Errorf("%w: cannot find definition for %s", commontypes.ErrInvalidType, itemType) } decode, err := extractDecoding(info, raw) @@ -53,7 +55,8 @@ func (m *decoder) GetMaxDecodingSize(ctx context.Context, n int, itemType string func extractDecoding(info *codecEntry, raw []byte) (any, error) { unpacked := map[string]any{} if err := info.Args.UnpackIntoMap(unpacked, raw); err != nil { - return nil, commontypes.ErrInvalidEncoding + argsJson, _ := json.Marshal(info.Args) + return nil, fmt.Errorf("%w: %w: for args %s", commontypes.ErrInvalidEncoding, err, argsJson) } var decode any = unpacked @@ -79,8 +82,13 @@ func mapstructureDecode(src, dest any) error { Result: dest, Squash: true, }) - if err != nil || mDecoder.Decode(src) != nil { - return commontypes.ErrInvalidType + if err != nil { + return fmt.Errorf("%w: %w", commontypes.ErrInvalidType, err) + } + + if err = mDecoder.Decode(src); err != nil { + return fmt.Errorf("%w: %w", commontypes.ErrInvalidType, err) } + return nil } diff --git a/core/services/relay/evm/encoder.go b/core/services/relay/evm/encoder.go index b3ad6d70fe6..58b6160bb8a 100644 --- a/core/services/relay/evm/encoder.go +++ b/core/services/relay/evm/encoder.go @@ -2,6 +2,7 @@ package evm import ( "context" + "fmt" "reflect" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" @@ -16,7 +17,7 @@ var _ commontypes.Encoder = &encoder{} func (e *encoder) Encode(ctx context.Context, item any, itemType string) ([]byte, error) { info, ok := e.Definitions[itemType] if !ok { - return nil, commontypes.ErrInvalidType + return nil, fmt.Errorf("%w: cannot find definition for %s", commontypes.ErrInvalidType, itemType) } if item == nil { @@ -42,7 +43,7 @@ func encode(item reflect.Value, info *codecEntry) ([]byte, error) { case reflect.Struct, reflect.Map: return encodeItem(item, info) default: - return nil, commontypes.ErrInvalidEncoding + return nil, fmt.Errorf("%w: cannot encode kind %v", commontypes.ErrInvalidType, item.Kind()) } } @@ -58,7 +59,7 @@ func encodeArray(item reflect.Value, info *codecEntry) ([]byte, error) { case reflect.Slice: native = reflect.MakeSlice(info.nativeType, length, length) default: - return nil, commontypes.ErrInvalidType + return nil, fmt.Errorf("%w: cannot encode %v as array", commontypes.ErrInvalidType, info.checkedType.Kind()) } checkedElm := info.checkedType.Elem() @@ -99,11 +100,12 @@ func encodeItem(item reflect.Value, info *codecEntry) ([]byte, error) { } func pack(info *codecEntry, values ...any) ([]byte, error) { - if bytes, err := info.Args.Pack(values...); err == nil { - withPrefix := make([]byte, 0, len(info.encodingPrefix)+len(bytes)) - withPrefix = append(withPrefix, info.encodingPrefix...) - return append(withPrefix, bytes...), nil + bytes, err := info.Args.Pack(values...) + if err != nil { + return nil, fmt.Errorf("%w: %w", commontypes.ErrInvalidType, err) } - return nil, commontypes.ErrInvalidType + withPrefix := make([]byte, 0, len(info.encodingPrefix)+len(bytes)) + withPrefix = append(withPrefix, info.encodingPrefix...) + return append(withPrefix, bytes...), nil } diff --git a/go.mod b/go.mod index c09f4f7bf71..8f04f5d1fa0 100644 --- a/go.mod +++ b/go.mod @@ -65,10 +65,10 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 - github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb + github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 diff --git a/go.sum b/go.sum index bc4737364a7..906e051e042 100644 --- a/go.sum +++ b/go.sum @@ -1134,14 +1134,14 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f h1:WZkIB1/XFNvp7BCpxMHzip9GWBjO21O+54w4u1sGiFU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb h1:fMT2rdyUa6PRKTJCI30Gu1e0wfrG5PpIrRS0TJJoS+s= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 h1:WZuC6bBM30RoU4gosJmDWZWegSpGg+/+i4Hx5Dh5eLU= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657/go.mod h1:auN7dRwsZNRQhCvNwtRKCjrXypH7v6OeheN2mO4Qh5g= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb h1:6qnSoCTBtiHcqaILLTvUWd9DIp+TnTkzt+xXcooj/Yw= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 h1:UUHT19viW3IIxsELz3jsvlk5MnID7cMFZlmor4seTKE= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 h1:YHvugDUtaJUzG3itrrvbmn5cU/aPaN2rSYIwWDnlN34= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181/go.mod h1:kY435jBtHbyzhe+ImAxZ6G229uHbB0ablA+A0tJkDn8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea h1:WzMa0O6DEauMYMIjzS/T1JF8zvFDt4aG6EUTDlStaZo= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index abb5fab2a77..7088c64e2c8 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -24,7 +24,7 @@ require ( github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb github.com/smartcontractkit/chainlink-testing-framework v1.22.0 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 @@ -346,7 +346,7 @@ require ( github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 // indirect - github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb // indirect + github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 // indirect github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index d7a9d958111..f1037c70547 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1432,14 +1432,14 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f h1:WZkIB1/XFNvp7BCpxMHzip9GWBjO21O+54w4u1sGiFU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221185953-a3a9e0db479f/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb h1:fMT2rdyUa6PRKTJCI30Gu1e0wfrG5PpIrRS0TJJoS+s= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231221211534-bc22ca78a8fb/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657 h1:WZuC6bBM30RoU4gosJmDWZWegSpGg+/+i4Hx5Dh5eLU= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231221191441-469c5f7cd657/go.mod h1:auN7dRwsZNRQhCvNwtRKCjrXypH7v6OeheN2mO4Qh5g= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1/go.mod h1:GuPvyXryvbiUZIHmPeLBz4L+yJKeyGUjrDfd1KNne+o= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb h1:6qnSoCTBtiHcqaILLTvUWd9DIp+TnTkzt+xXcooj/Yw= -github.com/smartcontractkit/chainlink-feeds v0.0.0-20231221200551-fa8f14d072cb/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105 h1:UUHT19viW3IIxsELz3jsvlk5MnID7cMFZlmor4seTKE= +github.com/smartcontractkit/chainlink-feeds v0.0.0-20231222013040-c93f24a1b105/go.mod h1:vQIT9tsN85b4DNgdweUilSUPX7R6gosvCmK5fvFgJAs= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181 h1:YHvugDUtaJUzG3itrrvbmn5cU/aPaN2rSYIwWDnlN34= github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231221190253-3d670c36e181/go.mod h1:kY435jBtHbyzhe+ImAxZ6G229uHbB0ablA+A0tJkDn8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231221191127-1f32389044ea h1:WzMa0O6DEauMYMIjzS/T1JF8zvFDt4aG6EUTDlStaZo= diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 4bc14f445bb..f8217731142 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -21,81 +21,95 @@ import ( // Tests a basic OCRv2 median feed func TestOCRv2Basic(t *testing.T) { t.Parallel() - l := logging.GetTestLogger(t) - - network, err := actions.EthereumNetworkConfigFromEnvOrDefault(l) - require.NoError(t, err, "Error building ethereum network config") - - env, err := test_env.NewCLTestEnvBuilder(). - WithTestInstance(t). - WithPrivateEthereumNetwork(network). - WithMockAdapter(). - WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), - node.WithOCR2(), - node.WithP2Pv2(), - node.WithTracing(), - )). - WithCLNodes(6). - WithFunding(big.NewFloat(.1)). - WithStandardCleanup(). - WithLogStream(). - Build() - require.NoError(t, err) - - env.ParallelTransactions(true) - - nodeClients := env.ClCluster.NodeAPIs() - bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:] - - linkToken, err := env.ContractDeployer.DeployLinkTokenContract() - require.NoError(t, err, "Deploying Link Token Contract shouldn't fail") - err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05)) - require.NoError(t, err, "Error funding Chainlink nodes") - - // Gather transmitters - var transmitters []string - for _, node := range workerNodes { - addr, err := node.PrimaryEthAddress() - if err != nil { - require.NoError(t, fmt.Errorf("error getting node's primary ETH address: %w", err)) - } - transmitters = append(transmitters, addr) + for _, test := range []struct { + name string + chainReaderAndCodec bool + }{ + {"legacy", false}, + {"chain-reader", true}, + } { + test := test + t.Run(test.name, func(t *testing.T) { + t.Parallel() + + l := logging.GetTestLogger(t) + + network, err := actions.EthereumNetworkConfigFromEnvOrDefault(l) + require.NoError(t, err, "Error building ethereum network config") + + env, err := test_env.NewCLTestEnvBuilder(). + WithTestInstance(t). + WithPrivateEthereumNetwork(network). + WithMockAdapter(). + WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(), + node.WithOCR2(), + node.WithP2Pv2(), + node.WithTracing(), + )). + WithCLNodes(6). + WithFunding(big.NewFloat(.1)). + WithStandardCleanup(). + WithLogStream(). + Build() + require.NoError(t, err) + + env.ParallelTransactions(true) + + nodeClients := env.ClCluster.NodeAPIs() + bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:] + + linkToken, err := env.ContractDeployer.DeployLinkTokenContract() + require.NoError(t, err, "Deploying Link Token Contract shouldn't fail") + + err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05)) + require.NoError(t, err, "Error funding Chainlink nodes") + + // Gather transmitters + var transmitters []string + for _, node := range workerNodes { + addr, err := node.PrimaryEthAddress() + if err != nil { + require.NoError(t, fmt.Errorf("error getting node's primary ETH address: %w", err)) + } + transmitters = append(transmitters, addr) + } + + ocrOffchainOptions := contracts.DefaultOffChainAggregatorOptions() + aggregatorContracts, err := actions.DeployOCRv2Contracts(1, linkToken, env.ContractDeployer, transmitters, env.EVMClient, ocrOffchainOptions) + require.NoError(t, err, "Error deploying OCRv2 aggregator contracts") + + err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false, test.chainReaderAndCodec) + require.NoError(t, err, "Error creating OCRv2 jobs") + + ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions) + require.NoError(t, err, "Error building OCRv2 config") + + err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts) + require.NoError(t, err, "Error configuring OCRv2 aggregator contracts") + + err = actions.WatchNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l) + require.NoError(t, err, "Error starting new OCR2 round") + roundData, err := aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(1)) + require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") + require.Equal(t, int64(5), roundData.Answer.Int64(), + "Expected latest answer from OCR contract to be 5 but got %d", + roundData.Answer.Int64(), + ) + + err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10) + require.NoError(t, err) + err = actions.WatchNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l) + require.NoError(t, err) + + roundData, err = aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(2)) + require.NoError(t, err, "Error getting latest OCR answer") + require.Equal(t, int64(10), roundData.Answer.Int64(), + "Expected latest answer from OCR contract to be 10 but got %d", + roundData.Answer.Int64(), + ) + }) } - - ocrOffchainOptions := contracts.DefaultOffChainAggregatorOptions() - aggregatorContracts, err := actions.DeployOCRv2Contracts(1, linkToken, env.ContractDeployer, transmitters, env.EVMClient, ocrOffchainOptions) - require.NoError(t, err, "Error deploying OCRv2 aggregator contracts") - - err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false, false) - require.NoError(t, err, "Error creating OCRv2 jobs") - - ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions) - require.NoError(t, err, "Error building OCRv2 config") - - err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts) - require.NoError(t, err, "Error configuring OCRv2 aggregator contracts") - - err = actions.WatchNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l) - require.NoError(t, err, "Error starting new OCR2 round") - roundData, err := aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(1)) - require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") - require.Equal(t, int64(5), roundData.Answer.Int64(), - "Expected latest answer from OCR contract to be 5 but got %d", - roundData.Answer.Int64(), - ) - - err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10) - require.NoError(t, err) - err = actions.WatchNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l) - require.NoError(t, err) - - roundData, err = aggregatorContracts[0].GetRound(testcontext.Get(t), big.NewInt(2)) - require.NoError(t, err, "Error getting latest OCR answer") - require.Equal(t, int64(10), roundData.Answer.Int64(), - "Expected latest answer from OCR contract to be 10 but got %d", - roundData.Answer.Int64(), - ) } // Tests that just calling requestNewRound() will properly induce more rounds