diff --git a/.changeset/gold-rats-hide.md b/.changeset/gold-rats-hide.md new file mode 100644 index 00000000000..b290847556a --- /dev/null +++ b/.changeset/gold-rats-hide.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +External peering core service diff --git a/.github/workflows/changeset.yml b/.github/workflows/changeset.yml index f077cee1285..8b881e18d23 100644 --- a/.github/workflows/changeset.yml +++ b/.github/workflows/changeset.yml @@ -34,21 +34,39 @@ jobs: - '!core/**/*.json' - '!core/chainlink.goreleaser.Dockerfile' - '!core/chainlink.Dockerfile' + contracts: + - contracts/**/*.sol core-changeset: - added: '.changeset/**' + contracts-changeset: + - added: 'contracts/.changeset/**' - name: Make a comment uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b # v1.3.0 if: ${{ (steps.files-changed.outputs.core == 'true' || steps.files-changed.outputs.shared == 'true') && steps.files-changed.outputs.core-changeset == 'false' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - msg: "I see you updated files related to core. Please run `pnpm changeset` to add a changeset." + msg: "I see you updated files related to `core`. Please run `pnpm changeset` in the root directory to add a changeset." check_for_duplicate_msg: true - - name: Check for new changeset + - name: Make a comment + uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b # v1.3.0 + if: ${{ steps.files-changed.outputs.contracts == 'true' && steps.files-changed.outputs.contracts-changeset == 'false' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "I see you updated files related to `contracts`. Please run `pnpm changeset` in the `contracts` directory to add a changeset." + check_for_duplicate_msg: true + - name: Check for new changeset for core if: ${{ (steps.files-changed.outputs.core == 'true' || steps.files-changed.outputs.shared == 'true') && steps.files-changed.outputs.core-changeset == 'false' }} shell: bash run: | - echo "Please run pnpm changeset to add a changeset." + echo "Please run pnpm changeset to add a changeset for core." + exit 1 + - name: Check for new changeset for contracts + if: ${{ steps.files-changed.outputs.contracts == 'true' && steps.files-changed.outputs.contracts-changeset == 'false' }} + shell: bash + run: | + echo "Please run pnpm changeset to add a changeset for contracts." exit 1 - name: Collect Metrics if: always() diff --git a/core/capabilities/syncer.go b/core/capabilities/syncer.go new file mode 100644 index 00000000000..a8cfb2c56f8 --- /dev/null +++ b/core/capabilities/syncer.go @@ -0,0 +1,80 @@ +package capabilities + +import ( + "context" + + "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink-common/pkg/types" + + "github.com/smartcontractkit/libocr/ragep2p" + ragetypes "github.com/smartcontractkit/libocr/ragep2p/types" + + "github.com/smartcontractkit/chainlink/v2/core/logger" + p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types" +) + +type registrySyncer struct { + peerWrapper p2ptypes.PeerWrapper + registry types.CapabilitiesRegistry + lggr logger.Logger +} + +var _ services.Service = ®istrySyncer{} + +// RegistrySyncer updates local Registry to match its onchain counterpart +func NewRegistrySyncer(peerWrapper p2ptypes.PeerWrapper, registry types.CapabilitiesRegistry, lggr logger.Logger) *registrySyncer { + return ®istrySyncer{ + peerWrapper: peerWrapper, + registry: registry, + lggr: lggr, + } +} + +func (s *registrySyncer) Start(ctx context.Context) error { + // NOTE: temporary hard-coded values + defaultStreamConfig := p2ptypes.StreamConfig{ + IncomingMessageBufferSize: 1000000, + OutgoingMessageBufferSize: 1000000, + MaxMessageLenBytes: 100000, + MessageRateLimiter: ragep2p.TokenBucketParams{ + Rate: 10.0, + Capacity: 1000, + }, + BytesRateLimiter: ragep2p.TokenBucketParams{ + Rate: 10.0, + Capacity: 1000, + }, + } + peerIDs := []string{ + "12D3KooWF3dVeJ6YoT5HFnYhmwQWWMoEwVFzJQ5kKCMX3ZityxMC", + "12D3KooWQsmok6aD8PZqt3RnJhQRrNzKHLficq7zYFRp7kZ1hHP8", + "12D3KooWJbZLiMuGeKw78s3LM5TNgBTJHcF39DraxLu14bucG9RN", + "12D3KooWGqfSPhHKmQycfhRjgUDE2vg9YWZN27Eue8idb2ZUk6EH", + } + peers := make(map[ragetypes.PeerID]p2ptypes.StreamConfig) + for _, peerID := range peerIDs { + var p ragetypes.PeerID + err := p.UnmarshalText([]byte(peerID)) + if err != nil { + return err + } + peers[p] = defaultStreamConfig + } + return s.peerWrapper.GetPeer().UpdateConnections(peers) +} + +func (s *registrySyncer) Close() error { + return s.peerWrapper.GetPeer().UpdateConnections(map[ragetypes.PeerID]p2ptypes.StreamConfig{}) +} + +func (s *registrySyncer) Ready() error { + return nil +} + +func (s *registrySyncer) HealthReport() map[string]error { + return nil +} + +func (s *registrySyncer) Name() string { + return "RegistrySyncer" +} diff --git a/core/capabilities/syncer_test.go b/core/capabilities/syncer_test.go new file mode 100644 index 00000000000..acfe0f00233 --- /dev/null +++ b/core/capabilities/syncer_test.go @@ -0,0 +1,28 @@ +package capabilities_test + +import ( + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + commonMocks "github.com/smartcontractkit/chainlink-common/pkg/types/mocks" + coreCapabilities "github.com/smartcontractkit/chainlink/v2/core/capabilities" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types/mocks" +) + +func TestSyncer_CleanStartClose(t *testing.T) { + lggr := logger.TestLogger(t) + ctx := testutils.Context(t) + peer := mocks.NewPeer(t) + peer.On("UpdateConnections", mock.Anything).Return(nil) + wrapper := mocks.NewPeerWrapper(t) + wrapper.On("GetPeer").Return(peer) + registry := commonMocks.NewCapabilitiesRegistry(t) + + syncer := coreCapabilities.NewRegistrySyncer(wrapper, registry, lggr) + require.NoError(t, syncer.Start(ctx)) + require.NoError(t, syncer.Close()) +} diff --git a/core/capabilities/targets/write_target_test.go b/core/capabilities/targets/write_target_test.go index c99e84beb75..c71c84e172e 100644 --- a/core/capabilities/targets/write_target_test.go +++ b/core/capabilities/targets/write_target_test.go @@ -9,7 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/capabilities/targets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" - evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm/mocks" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -17,13 +17,12 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -var forwardABI = evmtypes.MustGetABI(forwarder.KeystoneForwarderMetaData.ABI) +var forwardABI = types.MustGetABI(forwarder.KeystoneForwarderMetaData.ABI) func TestEvmWrite(t *testing.T) { chain := evmmocks.NewChain(t) @@ -34,12 +33,12 @@ func TestEvmWrite(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { a := testutils.NewAddress() - addr, err := ethkey.NewEIP55Address(a.Hex()) + addr, err := types.NewEIP55Address(a.Hex()) require.NoError(t, err) c.EVM[0].ChainWriter.FromAddress = &addr forwarderA := testutils.NewAddress() - forwarderAddr, err := ethkey.NewEIP55Address(forwarderA.Hex()) + forwarderAddr, err := types.NewEIP55Address(forwarderA.Hex()) require.NoError(t, err) c.EVM[0].ChainWriter.ForwarderAddress = &forwarderAddr }) diff --git a/core/chains/evm/config/chain_scoped_chain_writer.go b/core/chains/evm/config/chain_scoped_chain_writer.go index b84731314e1..1f1cdcecfa7 100644 --- a/core/chains/evm/config/chain_scoped_chain_writer.go +++ b/core/chains/evm/config/chain_scoped_chain_writer.go @@ -2,17 +2,17 @@ package config import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) type chainWriterConfig struct { c toml.ChainWriter } -func (b *chainWriterConfig) FromAddress() *ethkey.EIP55Address { +func (b *chainWriterConfig) FromAddress() *types.EIP55Address { return b.c.FromAddress } -func (b *chainWriterConfig) ForwarderAddress() *ethkey.EIP55Address { +func (b *chainWriterConfig) ForwarderAddress() *types.EIP55Address { return b.c.ForwarderAddress } diff --git a/core/chains/evm/config/config.go b/core/chains/evm/config/config.go index c9c3273f086..3c504f63ae7 100644 --- a/core/chains/evm/config/config.go +++ b/core/chains/evm/config/config.go @@ -10,8 +10,8 @@ import ( commonconfig "github.com/smartcontractkit/chainlink/v2/common/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) type EVM interface { @@ -130,8 +130,8 @@ type BlockHistory interface { } type ChainWriter interface { - FromAddress() *ethkey.EIP55Address - ForwarderAddress() *ethkey.EIP55Address + FromAddress() *types.EIP55Address + ForwarderAddress() *types.EIP55Address } type NodePool interface { diff --git a/core/chains/evm/config/config_test.go b/core/chains/evm/config/config_test.go index 0f3e0a9a9f8..c0457fbe850 100644 --- a/core/chains/evm/config/config_test.go +++ b/core/chains/evm/config/config_test.go @@ -16,13 +16,13 @@ import ( commonconfig "github.com/smartcontractkit/chainlink/v2/common/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func TestChainScopedConfig(t *testing.T) { @@ -89,7 +89,7 @@ func TestChainScopedConfig(t *testing.T) { gcfg2 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { overrides(c, s) c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(randomOtherAddr)), + {Key: ptr(types.EIP55AddressFromAddress(randomOtherAddr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: assets.GWei(850), }, @@ -124,7 +124,7 @@ func TestChainScopedConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(addr)), + {Key: ptr(types.EIP55AddressFromAddress(addr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: tt.val, }, @@ -143,7 +143,7 @@ func TestChainScopedConfig(t *testing.T) { gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.PriceMax = chainSpecificPrice c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(addr)), + {Key: ptr(types.EIP55AddressFromAddress(addr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: keySpecificPrice, }, @@ -160,7 +160,7 @@ func TestChainScopedConfig(t *testing.T) { gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.PriceMax = chainSpecificPrice c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(addr)), + {Key: ptr(types.EIP55AddressFromAddress(addr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: keySpecificPrice, }, @@ -175,7 +175,7 @@ func TestChainScopedConfig(t *testing.T) { keySpecificPrice := assets.GWei(900) gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(addr)), + {Key: ptr(types.EIP55AddressFromAddress(addr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: keySpecificPrice, }, @@ -192,7 +192,7 @@ func TestChainScopedConfig(t *testing.T) { gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.PriceMax = chainSpecificPrice c.EVM[0].KeySpecific = toml.KeySpecificConfig{ - {Key: ptr(ethkey.EIP55AddressFromAddress(addr)), + {Key: ptr(types.EIP55AddressFromAddress(addr)), GasEstimator: toml.KeySpecificGasEstimator{ PriceMax: keySpecificPrice, }, @@ -224,7 +224,7 @@ func TestChainScopedConfig(t *testing.T) { val := testutils.NewAddress() gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.EVM[0].LinkContractAddress = ptr(ethkey.EIP55AddressFromAddress(val)) + c.EVM[0].LinkContractAddress = ptr(types.EIP55AddressFromAddress(val)) }) cfg3 := evmtest.NewChainScopedConfig(t, gcfg3) @@ -241,7 +241,7 @@ func TestChainScopedConfig(t *testing.T) { val := testutils.NewAddress() gcfg3 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.EVM[0].OperatorFactoryAddress = ptr(ethkey.EIP55AddressFromAddress(val)) + c.EVM[0].OperatorFactoryAddress = ptr(types.EIP55AddressFromAddress(val)) }) cfg3 := evmtest.NewChainScopedConfig(t, gcfg3) diff --git a/core/chains/evm/config/mocks/chain_scoped_config.go b/core/chains/evm/config/mocks/chain_scoped_config.go index badba1d69f3..29b6d6f3f3e 100644 --- a/core/chains/evm/config/mocks/chain_scoped_config.go +++ b/core/chains/evm/config/mocks/chain_scoped_config.go @@ -80,6 +80,26 @@ func (_m *ChainScopedConfig) AutoPprof() coreconfig.AutoPprof { return r0 } +// Capabilities provides a mock function with given fields: +func (_m *ChainScopedConfig) Capabilities() coreconfig.Capabilities { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Capabilities") + } + + var r0 coreconfig.Capabilities + if rf, ok := ret.Get(0).(func() coreconfig.Capabilities); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(coreconfig.Capabilities) + } + } + + return r0 +} + // CosmosEnabled provides a mock function with given fields: func (_m *ChainScopedConfig) CosmosEnabled() bool { ret := _m.Called() diff --git a/core/chains/evm/config/toml/config.go b/core/chains/evm/config/toml/config.go index b84993b28a6..a81ef4d94ff 100644 --- a/core/chains/evm/config/toml/config.go +++ b/core/chains/evm/config/toml/config.go @@ -1,6 +1,7 @@ package toml import ( + "errors" "fmt" "net/url" "slices" @@ -17,13 +18,13 @@ import ( commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/common/config" - "github.com/smartcontractkit/chainlink/v2/core/chains" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) +var ErrNotFound = errors.New("not found") + type HasEVMConfigs interface { EVMConfigs() EVMConfigs } @@ -145,7 +146,7 @@ func (cs EVMConfigs) Node(name string) (types.Node, error) { } } } - return types.Node{}, fmt.Errorf("node %s: %w", name, chains.ErrNotFound) + return types.Node{}, fmt.Errorf("node %s: %w", name, ErrNotFound) } func (cs EVMConfigs) NodeStatus(name string) (commontypes.NodeStatus, error) { @@ -156,7 +157,7 @@ func (cs EVMConfigs) NodeStatus(name string) (commontypes.NodeStatus, error) { } } } - return commontypes.NodeStatus{}, fmt.Errorf("node %s: %w", name, chains.ErrNotFound) + return commontypes.NodeStatus{}, fmt.Errorf("node %s: %w", name, ErrNotFound) } func legacyNode(n *Node, chainID *big.Big) (v2 types.Node) { @@ -205,7 +206,7 @@ func (cs EVMConfigs) Nodes(chainID string) (ns []types.Node, err error) { } nodes := cs.nodes(chainID) if nodes == nil { - err = fmt.Errorf("no nodes: chain %q: %w", chainID, chains.ErrNotFound) + err = fmt.Errorf("no nodes: chain %q: %w", chainID, ErrNotFound) return } for _, n := range nodes { @@ -347,8 +348,8 @@ type Chain struct { ChainType *string FinalityDepth *uint32 FinalityTagEnabled *bool - FlagsContractAddress *ethkey.EIP55Address - LinkContractAddress *ethkey.EIP55Address + FlagsContractAddress *types.EIP55Address + LinkContractAddress *types.EIP55Address LogBackfillBatchSize *uint32 LogPollInterval *commonconfig.Duration LogKeepBlocksDepth *uint32 @@ -358,7 +359,7 @@ type Chain struct { MinContractPayment *commonassets.Link NonceAutoSync *bool NoNewHeadsThreshold *commonconfig.Duration - OperatorFactoryAddress *ethkey.EIP55Address + OperatorFactoryAddress *types.EIP55Address RPCDefaultBatchSize *uint32 RPCBlockQueryDelay *uint16 @@ -451,8 +452,8 @@ func (a *Automation) setFrom(f *Automation) { } type ChainWriter struct { - FromAddress *ethkey.EIP55Address `toml:",omitempty"` - ForwarderAddress *ethkey.EIP55Address `toml:",omitempty"` + FromAddress *types.EIP55Address `toml:",omitempty"` + ForwarderAddress *types.EIP55Address `toml:",omitempty"` } func (m *ChainWriter) setFrom(f *ChainWriter) { @@ -668,7 +669,7 @@ func (ks KeySpecificConfig) ValidateConfig() (err error) { } type KeySpecific struct { - Key *ethkey.EIP55Address + Key *types.EIP55Address GasEstimator KeySpecificGasEstimator `toml:",omitempty"` } diff --git a/core/chains/evm/gas/rollups/models.go b/core/chains/evm/gas/rollups/models.go index 8158ba2b906..7aa3d4059dd 100644 --- a/core/chains/evm/gas/rollups/models.go +++ b/core/chains/evm/gas/rollups/models.go @@ -6,8 +6,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" + "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" - "github.com/smartcontractkit/chainlink/v2/core/services" ) // L1Oracle provides interface for fetching L1-specific fee components if the chain is an L2. @@ -15,7 +15,7 @@ import ( // //go:generate mockery --quiet --name L1Oracle --output ./mocks/ --case=underscore type L1Oracle interface { - services.ServiceCtx + services.Service GasPrice(ctx context.Context) (*assets.Wei, error) GetGasCost(ctx context.Context, tx *types.Transaction, blockNum *big.Int) (*assets.Wei, error) diff --git a/core/chains/evm/keystore/eth.go b/core/chains/evm/keystore/eth.go new file mode 100644 index 00000000000..1e2b0c439bc --- /dev/null +++ b/core/chains/evm/keystore/eth.go @@ -0,0 +1,19 @@ +package keystore + +import ( + "context" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +// Eth is the external interface for EthKeyStore +// +//go:generate mockery --quiet --name Eth --output mocks/ --case=underscore +type Eth interface { + CheckEnabled(ctx context.Context, address common.Address, chainID *big.Int) error + EnabledAddressesForChain(ctx context.Context, chainID *big.Int) (addresses []common.Address, err error) + SignTx(ctx context.Context, fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) + SubscribeToKeyChanges(ctx context.Context) (ch chan struct{}, unsub func()) +} diff --git a/core/chains/evm/keystore/mocks/eth.go b/core/chains/evm/keystore/mocks/eth.go new file mode 100644 index 00000000000..48bd738fdbe --- /dev/null +++ b/core/chains/evm/keystore/mocks/eth.go @@ -0,0 +1,143 @@ +// Code generated by mockery v2.38.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + big "math/big" + + common "github.com/ethereum/go-ethereum/common" + + mock "github.com/stretchr/testify/mock" + + types "github.com/ethereum/go-ethereum/core/types" +) + +// Eth is an autogenerated mock type for the Eth type +type Eth struct { + mock.Mock +} + +// CheckEnabled provides a mock function with given fields: ctx, address, chainID +func (_m *Eth) CheckEnabled(ctx context.Context, address common.Address, chainID *big.Int) error { + ret := _m.Called(ctx, address, chainID) + + if len(ret) == 0 { + panic("no return value specified for CheckEnabled") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, common.Address, *big.Int) error); ok { + r0 = rf(ctx, address, chainID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// EnabledAddressesForChain provides a mock function with given fields: ctx, chainID +func (_m *Eth) EnabledAddressesForChain(ctx context.Context, chainID *big.Int) ([]common.Address, error) { + ret := _m.Called(ctx, chainID) + + if len(ret) == 0 { + panic("no return value specified for EnabledAddressesForChain") + } + + var r0 []common.Address + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) ([]common.Address, error)); ok { + return rf(ctx, chainID) + } + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) []common.Address); ok { + r0 = rf(ctx, chainID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]common.Address) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *big.Int) error); ok { + r1 = rf(ctx, chainID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SignTx provides a mock function with given fields: ctx, fromAddress, tx, chainID +func (_m *Eth) SignTx(ctx context.Context, fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) { + ret := _m.Called(ctx, fromAddress, tx, chainID) + + if len(ret) == 0 { + panic("no return value specified for SignTx") + } + + var r0 *types.Transaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Address, *types.Transaction, *big.Int) (*types.Transaction, error)); ok { + return rf(ctx, fromAddress, tx, chainID) + } + if rf, ok := ret.Get(0).(func(context.Context, common.Address, *types.Transaction, *big.Int) *types.Transaction); ok { + r0 = rf(ctx, fromAddress, tx, chainID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Transaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.Address, *types.Transaction, *big.Int) error); ok { + r1 = rf(ctx, fromAddress, tx, chainID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SubscribeToKeyChanges provides a mock function with given fields: ctx +func (_m *Eth) SubscribeToKeyChanges(ctx context.Context) (chan struct{}, func()) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for SubscribeToKeyChanges") + } + + var r0 chan struct{} + var r1 func() + if rf, ok := ret.Get(0).(func(context.Context) (chan struct{}, func())); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) chan struct{}); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(chan struct{}) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) func()); ok { + r1 = rf(ctx) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(func()) + } + } + + return r0, r1 +} + +// NewEth creates a new instance of Eth. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEth(t interface { + mock.TestingT + Cleanup(func()) +}) *Eth { + mock := &Eth{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/core/chains/evm/log/broadcaster.go b/core/chains/evm/log/broadcaster.go index c4db2a4826c..6a47d823ea6 100644 --- a/core/chains/evm/log/broadcaster.go +++ b/core/chains/evm/log/broadcaster.go @@ -2,6 +2,7 @@ package log import ( "context" + "database/sql" "fmt" "math/big" "sync" @@ -22,7 +23,6 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" - "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/pg" ) @@ -69,7 +69,7 @@ type ( BroadcasterInTest interface { Broadcaster - BackfillBlockNumber() null.Int64 + BackfillBlockNumber() sql.NullInt64 TrackedAddressesCount() uint32 // Pause pauses the eventLoop until Resume is called. Pause() @@ -98,7 +98,7 @@ type ( evmChainID big.Int // a block number to start backfill from - backfillBlockNumber null.Int64 + backfillBlockNumber sql.NullInt64 ethSubscriber *ethSubscriber registrations *registrations @@ -327,7 +327,7 @@ func (b *broadcaster) startResubscribeLoop() { if from < 0 { from = 0 } - b.backfillBlockNumber = null.NewInt64(from, true) + b.backfillBlockNumber = sql.NullInt64{Int64: from, Valid: true} } // Remove leftover unconsumed logs, maybe update pending broadcasts, and backfill sooner if necessary. @@ -337,7 +337,8 @@ func (b *broadcaster) startResubscribeLoop() { // No need to worry about r.highestNumConfirmations here because it's // already at minimum this deep due to the latest seen head check above if !b.backfillBlockNumber.Valid || *backfillStart < b.backfillBlockNumber.Int64 { - b.backfillBlockNumber.SetValid(*backfillStart) + b.backfillBlockNumber.Int64 = *backfillStart + b.backfillBlockNumber.Valid = true } } @@ -490,7 +491,8 @@ func (b *broadcaster) onReplayRequest(replayReq replayRequest) { // NOTE: This ignores r.highestNumConfirmations, but it is // generally assumed that this will only be performed rarely and // manually by someone who knows what he is doing - b.backfillBlockNumber.SetValid(replayReq.fromBlock) + b.backfillBlockNumber.Int64 = replayReq.fromBlock + b.backfillBlockNumber.Valid = true if replayReq.forceBroadcast { ctx, cancel := b.chStop.NewCtx() defer cancel() @@ -515,7 +517,8 @@ func (b *broadcaster) invalidatePool() int64 { b.logPool = newLogPool(b.logger) // Note: even if we crash right now, PendingMinBlock is preserved in the database and we will backfill the same. blockNum := int64(min.(Uint64)) - b.backfillBlockNumber.SetValid(blockNum) + b.backfillBlockNumber.Int64 = blockNum + b.backfillBlockNumber.Valid = true return blockNum } return -1 @@ -717,7 +720,7 @@ func (b *broadcaster) TrackedAddressesCount() uint32 { } // test only -func (b *broadcaster) BackfillBlockNumber() null.Int64 { +func (b *broadcaster) BackfillBlockNumber() sql.NullInt64 { return b.backfillBlockNumber } @@ -766,8 +769,8 @@ func (n *NullBroadcaster) Register(listener Listener, opts ListenerOpts) (unsubs // ReplayFromBlock implements the Broadcaster interface. func (n *NullBroadcaster) ReplayFromBlock(number int64, forceBroadcast bool) {} -func (n *NullBroadcaster) BackfillBlockNumber() null.Int64 { - return null.NewInt64(0, false) +func (n *NullBroadcaster) BackfillBlockNumber() sql.NullInt64 { + return sql.NullInt64{Int64: 0, Valid: false} } func (n *NullBroadcaster) TrackedAddressesCount() uint32 { return 0 diff --git a/core/chains/evm/log/eth_subscriber.go b/core/chains/evm/log/eth_subscriber.go index ff20a6e74e8..e5ba202dbf2 100644 --- a/core/chains/evm/log/eth_subscriber.go +++ b/core/chains/evm/log/eth_subscriber.go @@ -2,6 +2,7 @@ package log import ( "context" + "database/sql" "fmt" "math/big" "time" @@ -15,7 +16,6 @@ import ( evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" - "github.com/smartcontractkit/chainlink/v2/core/null" ) type ( @@ -39,7 +39,7 @@ func newEthSubscriber(ethClient evmclient.Client, config Config, lggr logger.Log // backfillLogs - fetches earlier logs either from a relatively recent block (latest minus BlockBackfillDepth) or from the given fromBlockOverride // note that the whole operation has no timeout - it relies on BlockBackfillSkip (set outside) to optionally prevent very deep, long backfills // Max runtime is: (10 sec + 1 min * numBlocks/batchSize) * 3 retries -func (sub *ethSubscriber) backfillLogs(fromBlockOverride null.Int64, addresses []common.Address, topics []common.Hash) (chBackfilledLogs chan types.Log, abort bool) { +func (sub *ethSubscriber) backfillLogs(fromBlockOverride sql.NullInt64, addresses []common.Address, topics []common.Hash) (chBackfilledLogs chan types.Log, abort bool) { sub.logger.Infow("backfilling logs", "from", fromBlockOverride, "addresses", addresses) if len(addresses) == 0 { sub.logger.Debug("LogBroadcaster: No addresses to backfill for, returning") diff --git a/core/chains/evm/monitor/balance.go b/core/chains/evm/monitor/balance.go index 16e2fd527bf..28bcdd9abdf 100644 --- a/core/chains/evm/monitor/balance.go +++ b/core/chains/evm/monitor/balance.go @@ -20,8 +20,8 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" ) //go:generate mockery --quiet --name BalanceMonitor --output ../mocks/ --case=underscore diff --git a/core/chains/evm/txmgr/attempts_test.go b/core/chains/evm/txmgr/attempts_test.go index ab8a5831b20..d5c8f577ce1 100644 --- a/core/chains/evm/txmgr/attempts_test.go +++ b/core/chains/evm/txmgr/attempts_test.go @@ -18,13 +18,13 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" gasmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" + ksmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" ) func NewEvmAddress() gethcommon.Address { diff --git a/core/chains/evm/txmgr/broadcaster_test.go b/core/chains/evm/txmgr/broadcaster_test.go index 0b76f7fc6d1..8c51c557fb5 100644 --- a/core/chains/evm/txmgr/broadcaster_test.go +++ b/core/chains/evm/txmgr/broadcaster_test.go @@ -35,6 +35,8 @@ import ( evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" gasmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" + ksmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" @@ -46,8 +48,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" ) // NewEthBroadcaster creates a new txmgr.EthBroadcaster for use in testing. diff --git a/core/chains/evm/txmgr/builder.go b/core/chains/evm/txmgr/builder.go index 58e37d633d9..cd8f5af884a 100644 --- a/core/chains/evm/txmgr/builder.go +++ b/core/chains/evm/txmgr/builder.go @@ -14,9 +14,9 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" ) // NewTxm constructs the necessary dependencies for the EvmTxm (broadcaster, confirmer, etc) and returns a new EvmTxManager diff --git a/core/chains/evm/txmgr/confirmer_test.go b/core/chains/evm/txmgr/confirmer_test.go index ec09085bc44..7307f5c35bb 100644 --- a/core/chains/evm/txmgr/confirmer_test.go +++ b/core/chains/evm/txmgr/confirmer_test.go @@ -31,6 +31,8 @@ import ( evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" gasmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" + ksmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" @@ -40,8 +42,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" ) func newTestChainScopedConfig(t *testing.T) evmconfig.ChainScopedConfig { diff --git a/core/chains/evm/txmgr/models.go b/core/chains/evm/txmgr/models.go index 4c622ec945a..6633841f40b 100644 --- a/core/chains/evm/txmgr/models.go +++ b/core/chains/evm/txmgr/models.go @@ -11,8 +11,8 @@ import ( "github.com/smartcontractkit/chainlink/v2/common/txmgr" txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" ) // Type aliases for EVM diff --git a/core/chains/evm/txmgr/tracker_test.go b/core/chains/evm/txmgr/tracker_test.go index d3083372789..ce249f9ea1f 100644 --- a/core/chains/evm/txmgr/tracker_test.go +++ b/core/chains/evm/txmgr/tracker_test.go @@ -6,13 +6,13 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" @@ -26,17 +26,12 @@ func newTestEvmTrackerSetup(t *testing.T) (*txmgr.Tracker, txmgr.TestEvmTxStore, txStore := cltest.NewTestTxStore(t, db, cfg.Database()) ethKeyStore := cltest.NewKeyStore(t, db, cfg.Database()).Eth() chainID := big.NewInt(0) - enabledAddresses := generateEnabledAddresses(t, ethKeyStore, chainID) - lggr := logger.TestLogger(t) - return txmgr.NewEvmTracker(txStore, ethKeyStore, chainID, lggr), txStore, ethKeyStore, enabledAddresses -} - -func generateEnabledAddresses(t *testing.T, keyStore keystore.Eth, chainID *big.Int) []common.Address { var enabledAddresses []common.Address - _, addr1 := cltest.MustInsertRandomKey(t, keyStore, *ubig.NewI(chainID.Int64())) - _, addr2 := cltest.MustInsertRandomKey(t, keyStore, *ubig.NewI(chainID.Int64())) + _, addr1 := cltest.MustInsertRandomKey(t, ethKeyStore, *ubig.NewI(chainID.Int64())) + _, addr2 := cltest.MustInsertRandomKey(t, ethKeyStore, *ubig.NewI(chainID.Int64())) enabledAddresses = append(enabledAddresses, addr1, addr2) - return enabledAddresses + lggr := logger.TestLogger(t) + return txmgr.NewEvmTracker(txStore, ethKeyStore, chainID, lggr), txStore, ethKeyStore, enabledAddresses } func containsID(txes []*txmgr.Tx, id int64) bool { diff --git a/core/chains/evm/txmgr/txmgr_test.go b/core/chains/evm/txmgr/txmgr_test.go index 332031bc776..7120a77728e 100644 --- a/core/chains/evm/txmgr/txmgr_test.go +++ b/core/chains/evm/txmgr/txmgr_test.go @@ -32,6 +32,8 @@ import ( evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" + ksmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -42,8 +44,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/pg" ) diff --git a/core/services/keystore/keys/ethkey/address.go b/core/chains/evm/types/address.go similarity index 99% rename from core/services/keystore/keys/ethkey/address.go rename to core/chains/evm/types/address.go index 0d93a4cdb29..4a77ce5f8db 100644 --- a/core/services/keystore/keys/ethkey/address.go +++ b/core/chains/evm/types/address.go @@ -1,4 +1,4 @@ -package ethkey +package types import ( "database/sql/driver" diff --git a/core/services/keystore/keys/ethkey/address_test.go b/core/chains/evm/types/address_test.go similarity index 76% rename from core/services/keystore/keys/ethkey/address_test.go rename to core/chains/evm/types/address_test.go index 15b502d1785..e6e6a4f37c9 100644 --- a/core/services/keystore/keys/ethkey/address_test.go +++ b/core/chains/evm/types/address_test.go @@ -1,4 +1,4 @@ -package ethkey_test +package types_test import ( "encoding/json" @@ -8,13 +8,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) func TestEIP55Address(t *testing.T) { t.Parallel() - address := ethkey.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e") + address := types.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e") assert.Equal(t, []byte{ 0xa0, 0x78, 0x8f, 0xc1, 0x7b, 0x1d, 0xee, 0x36, @@ -35,12 +35,12 @@ func TestEIP55Address(t *testing.T) { assert.Equal(t, "0xa0788FC17B1dEe36f057c42B6F373A34B014687e", address.String()) - zeroAddress := ethkey.EIP55Address("") + zeroAddress := types.EIP55Address("") err := json.Unmarshal([]byte(`"0xa0788FC17B1dEe36f057c42B6F373A34B014687e"`), &zeroAddress) assert.NoError(t, err) assert.Equal(t, "0xa0788FC17B1dEe36f057c42B6F373A34B014687e", zeroAddress.String()) - zeroAddress = ethkey.EIP55Address("") + zeroAddress = types.EIP55Address("") err = zeroAddress.UnmarshalText([]byte("0xa0788FC17B1dEe36f057c42B6F373A34B014687e")) assert.NoError(t, err) assert.Equal(t, "0xa0788FC17B1dEe36f057c42B6F373A34B014687e", zeroAddress.String()) @@ -64,7 +64,7 @@ func TestValidateEIP55Address(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - _, err := ethkey.NewEIP55Address(test.input) + _, err := types.NewEIP55Address(test.input) valid := err == nil assert.Equal(t, test.valid, valid) }) @@ -75,20 +75,20 @@ func TestEIP55AddressFromAddress(t *testing.T) { t.Parallel() addr := common.HexToAddress("0xa0788FC17B1dEe36f057c42B6F373A34B014687e") - eip55 := ethkey.EIP55AddressFromAddress(addr) + eip55 := types.EIP55AddressFromAddress(addr) assert.Equal(t, addr, eip55.Address()) } func TestEIP55Address_Scan_Value(t *testing.T) { t.Parallel() - eip55, err := ethkey.NewEIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e") + eip55, err := types.NewEIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e") assert.NoError(t, err) val, err := eip55.Value() assert.NoError(t, err) - var eip55New ethkey.EIP55Address + var eip55New types.EIP55Address err = eip55New.Scan(val) assert.NoError(t, err) @@ -98,15 +98,15 @@ func TestEIP55Address_Scan_Value(t *testing.T) { func TestEIP55AddressCollection_Scan_Value(t *testing.T) { t.Parallel() - collection := ethkey.EIP55AddressCollection{ - ethkey.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B0146111"), - ethkey.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B0146222"), + collection := types.EIP55AddressCollection{ + types.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B0146111"), + types.EIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B0146222"), } val, err := collection.Value() assert.NoError(t, err) - var collectionNew ethkey.EIP55AddressCollection + var collectionNew types.EIP55AddressCollection err = collectionNew.Scan(val) assert.NoError(t, err) @@ -116,9 +116,9 @@ func TestEIP55AddressCollection_Scan_Value(t *testing.T) { func TestEIP55Address_IsZero(t *testing.T) { t.Parallel() - eip55 := ethkey.EIP55AddressFromAddress(common.HexToAddress("0x0")) + eip55 := types.EIP55AddressFromAddress(common.HexToAddress("0x0")) assert.True(t, eip55.IsZero()) - eip55 = ethkey.EIP55AddressFromAddress(common.HexToAddress("0x1")) + eip55 = types.EIP55AddressFromAddress(common.HexToAddress("0x1")) assert.False(t, eip55.IsZero()) } diff --git a/core/chains/evm/types/models.go b/core/chains/evm/types/models.go index 7f312401f7d..4aeaec511d1 100644 --- a/core/chains/evm/types/models.go +++ b/core/chains/evm/types/models.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "database/sql" "database/sql/driver" "encoding/json" "fmt" @@ -24,7 +25,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types/internal/blocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - "github.com/smartcontractkit/chainlink/v2/core/null" ) // Head represents a BlockNumber, BlockHash. @@ -32,7 +32,7 @@ type Head struct { ID uint64 Hash common.Hash Number int64 - L1BlockNumber null.Int64 + L1BlockNumber sql.NullInt64 ParentHash common.Hash Parent *Head EVMChainID *ubig.Big @@ -285,7 +285,7 @@ func (h *Head) UnmarshalJSON(bs []byte) error { h.Timestamp = time.Unix(int64(jsonHead.Timestamp), 0).UTC() h.BaseFeePerGas = assets.NewWei((*big.Int)(jsonHead.BaseFeePerGas)) if jsonHead.L1BlockNumber != nil { - h.L1BlockNumber = null.Int64From((*big.Int)(jsonHead.L1BlockNumber).Int64()) + h.L1BlockNumber = sql.NullInt64{Int64: (*big.Int)(jsonHead.L1BlockNumber).Int64(), Valid: true} } h.ReceiptsRoot = jsonHead.ReceiptsRoot h.TransactionsRoot = jsonHead.TransactionsRoot diff --git a/core/chains/evm/types/models_test.go b/core/chains/evm/types/models_test.go index 4fc986ae9d3..38dbfa76a0a 100644 --- a/core/chains/evm/types/models_test.go +++ b/core/chains/evm/types/models_test.go @@ -2,6 +2,7 @@ package types_test import ( "bytes" + "database/sql" "encoding/json" "fmt" "math" @@ -17,6 +18,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/utils/hex" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -25,7 +27,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" - "github.com/smartcontractkit/chainlink/v2/core/null" ) func TestHead_NewHead(t *testing.T) { @@ -329,7 +330,20 @@ func TestHead_UnmarshalJSON(t *testing.T) { Number: 0x15156, ParentHash: common.HexToHash("0x923ad1e27c1d43cb2d2fb09e26d2502ca4b4914a2e0599161d279c6c06117d34"), Timestamp: time.Unix(0x60d0952d, 0).UTC(), - L1BlockNumber: null.Int64From(0x8652f9), + L1BlockNumber: sql.NullInt64{Int64: 0x8652f9, Valid: true}, + ReceiptsRoot: common.HexToHash("0x2c292672b8fc9d223647a2569e19721f0757c96a1421753a93e141f8e56cf504"), + TransactionsRoot: common.HexToHash("0x71448077f5ce420a8e24db62d4d58e8d8e6ad2c7e76318868e089d41f7e0faf3"), + StateRoot: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), + }, + }, + {"arbitrum_empty_l1BlockNumber", + `{"number":"0x15156","hash":"0x752dab43f7a2482db39227d46cd307623b26167841e2207e93e7566ab7ab7871","parentHash":"0x923ad1e27c1d43cb2d2fb09e26d2502ca4b4914a2e0599161d279c6c06117d34","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x71448077f5ce420a8e24db62d4d58e8d8e6ad2c7e76318868e089d41f7e0faf3","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x2c292672b8fc9d223647a2569e19721f0757c96a1421753a93e141f8e56cf504","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x0","gasLimit":"0x11278208","gasUsed":"0x3d1fe9","timestamp":"0x60d0952d","transactions":["0xa1ea93556b93ed3b45cb24f21c8deb584e6a9049c35209242651bf3533c23b98","0xfc6593c45ba92351d17173aa1381e84734d252ab0169887783039212c4a41024","0x85ee9d04fd0ebb5f62191eeb53cb45d9c0945d43eba444c3548de2ac8421682f","0x50d120936473e5b75f6e04829ad4eeca7a1df7d3c5026ebb5d34af936a39b29c"],"uncles":[]}`, + evmtypes.Head{ + Hash: common.HexToHash("0x752dab43f7a2482db39227d46cd307623b26167841e2207e93e7566ab7ab7871"), + Number: 0x15156, + ParentHash: common.HexToHash("0x923ad1e27c1d43cb2d2fb09e26d2502ca4b4914a2e0599161d279c6c06117d34"), + Timestamp: time.Unix(0x60d0952d, 0).UTC(), + L1BlockNumber: sql.NullInt64{Int64: 0, Valid: false}, ReceiptsRoot: common.HexToHash("0x2c292672b8fc9d223647a2569e19721f0757c96a1421753a93e141f8e56cf504"), TransactionsRoot: common.HexToHash("0x71448077f5ce420a8e24db62d4d58e8d8e6ad2c7e76318868e089d41f7e0faf3"), StateRoot: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), diff --git a/core/chains/legacyevm/chain.go b/core/chains/legacyevm/chain.go index f00f4b64b36..e7aac4701c3 100644 --- a/core/chains/legacyevm/chain.go +++ b/core/chains/legacyevm/chain.go @@ -24,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/keystore" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/monitor" @@ -32,7 +33,6 @@ import ( ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore" ) //go:generate mockery --quiet --name Chain --output ./mocks/ --case=underscore diff --git a/core/config/app_config.go b/core/config/app_config.go index 290e14dcc45..869477218db 100644 --- a/core/config/app_config.go +++ b/core/config/app_config.go @@ -35,6 +35,7 @@ type AppConfig interface { AuditLogger() AuditLogger AutoPprof() AutoPprof + Capabilities() Capabilities Database() Database Feature() Feature FluxMonitor() FluxMonitor diff --git a/core/config/capabilities_config.go b/core/config/capabilities_config.go new file mode 100644 index 00000000000..8cde986ccb7 --- /dev/null +++ b/core/config/capabilities_config.go @@ -0,0 +1,6 @@ +package config + +type Capabilities interface { + Peering() P2P + // NOTE: RegistrySyncer will need config with relay ID, chain ID and contract address when implemented +} diff --git a/core/config/docs/core.toml b/core/config/docs/core.toml index 95d59cca062..984080ea3f1 100644 --- a/core/config/docs/core.toml +++ b/core/config/docs/core.toml @@ -434,6 +434,47 @@ DeltaReconcile = '1m' # Default # but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended. ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +[Capabilities.Peering] +# IncomingMessageBufferSize is the per-remote number of incoming +# messages to buffer. Any additional messages received on top of those +# already in the queue will be dropped. +IncomingMessageBufferSize = 10 # Default +# OutgoingMessageBufferSize is the per-remote number of outgoing +# messages to buffer. Any additional messages send on top of those +# already in the queue will displace the oldest. +# NOTE: OutgoingMessageBufferSize should be comfortably smaller than remote's +# IncomingMessageBufferSize to give the remote enough space to process +# them all in case we regained connection and now send a bunch at once +OutgoingMessageBufferSize = 10 # Default +# PeerID is the default peer ID to use for OCR jobs. If unspecified, uses the first available peer ID. +PeerID = '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw' # Example +# TraceLogging enables trace level logging. +TraceLogging = false # Default + +[Capabilities.Peering.V2] +# Enabled enables P2P V2. +Enabled = false # Default +# AnnounceAddresses is the addresses the peer will advertise on the network in `host:port` form as accepted by the TCP version of Go’s `net.Dial`. +# The addresses should be reachable by other nodes on the network. When attempting to connect to another node, +# a node will attempt to dial all of the other node’s AnnounceAddresses in round-robin fashion. +AnnounceAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +# DefaultBootstrappers is the default bootstrapper peers for libocr's v2 networking stack. +# +# Oracle nodes typically only know each other’s PeerIDs, but not their hostnames, IP addresses, or ports. +# DefaultBootstrappers are special nodes that help other nodes discover each other’s `AnnounceAddresses` so they can communicate. +# Nodes continuously attempt to connect to bootstrappers configured in here. When a node wants to connect to another node +# (which it knows only by PeerID, but not by address), it discovers the other node’s AnnounceAddresses from communications +# received from its DefaultBootstrappers or other discovered nodes. To facilitate discovery, +# nodes will regularly broadcast signed announcements containing their PeerID and AnnounceAddresses. +DefaultBootstrappers = ['12D3KooWMHMRLQkgPbFSYHwD3NBuwtS1AmxhvKVUrcfyaGDASR4U@1.2.3.4:9999', '12D3KooWM55u5Swtpw9r8aFLQHEtw7HR4t44GdNs654ej5gRs2Dh@example.com:1234'] # Example +# DeltaDial controls how far apart Dial attempts are +DeltaDial = '15s' # Default +# DeltaReconcile controls how often a Reconcile message is sent to every peer. +DeltaReconcile = '1m' # Default +# ListenAddresses is the addresses the peer will listen to on the network in `host:port` form as accepted by `net.Listen()`, +# but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended. +ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example + [Keeper] # **ADVANCED** # DefaultTransactionQueueDepth controls the queue size for `DropOldestStrategy` in Keeper. Set to 0 to use `SendEvery` strategy instead. diff --git a/core/config/docs/docs_test.go b/core/config/docs/docs_test.go index 919113e1d93..35a78762e64 100644 --- a/core/config/docs/docs_test.go +++ b/core/config/docs/docs_test.go @@ -17,10 +17,10 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config/docs" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func TestDoc(t *testing.T) { @@ -51,7 +51,7 @@ func TestDoc(t *testing.T) { // clean up KeySpecific as a special case require.Equal(t, 1, len(docDefaults.KeySpecific)) - ks := evmcfg.KeySpecific{Key: new(ethkey.EIP55Address), + ks := evmcfg.KeySpecific{Key: new(types.EIP55Address), GasEstimator: evmcfg.KeySpecificGasEstimator{PriceMax: new(assets.Wei)}} require.Equal(t, ks, docDefaults.KeySpecific[0]) docDefaults.KeySpecific = nil diff --git a/core/config/ocr_config.go b/core/config/ocr_config.go index 9f891511dd3..bde2142c846 100644 --- a/core/config/ocr_config.go +++ b/core/config/ocr_config.go @@ -3,7 +3,7 @@ package config import ( "time" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) // OCR is a subset of global config relevant to OCR v1. @@ -16,7 +16,7 @@ type OCR interface { KeyBundleID() (string, error) ObservationTimeout() time.Duration SimulateTransactions() bool - TransmitterAddress() (ethkey.EIP55Address, error) // OCR2 can support non-evm changes + TransmitterAddress() (types.EIP55Address, error) // OCR2 can support non-evm changes // OCR1 config, cannot override in jobs TraceLogging() bool DefaultTransactionQueueDepth() uint32 diff --git a/core/config/toml/types.go b/core/config/toml/types.go index 08ebf68f59b..f56ab1e8c89 100644 --- a/core/config/toml/types.go +++ b/core/config/toml/types.go @@ -16,9 +16,9 @@ import ( commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/build" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/parse" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/sessions" "github.com/smartcontractkit/chainlink/v2/core/store/dialects" @@ -55,6 +55,7 @@ type Core struct { Insecure Insecure `toml:",omitempty"` Tracing Tracing `toml:",omitempty"` Mercury Mercury `toml:",omitempty"` + Capabilities Capabilities `toml:",omitempty"` } // SetFrom updates c with any non-nil values from f. (currently TOML field only!) @@ -84,6 +85,7 @@ func (c *Core) SetFrom(f *Core) { c.P2P.setFrom(&f.P2P) c.Keeper.setFrom(&f.Keeper) c.Mercury.setFrom(&f.Mercury) + c.Capabilities.setFrom(&f.Capabilities) c.AutoPprof.setFrom(&f.AutoPprof) c.Pyroscope.setFrom(&f.Pyroscope) @@ -974,7 +976,7 @@ type OCR struct { // Optional KeyBundleID *models.Sha256Hash SimulateTransactions *bool - TransmitterAddress *ethkey.EIP55Address + TransmitterAddress *types.EIP55Address CaptureEATelemetry *bool TraceLogging *bool } @@ -1386,6 +1388,14 @@ func (m *MercurySecrets) ValidateConfig() (err error) { return err } +type Capabilities struct { + Peering P2P `toml:",omitempty"` +} + +func (c *Capabilities) setFrom(f *Capabilities) { + c.Peering.setFrom(&f.Peering) +} + type ThresholdKeyShareSecrets struct { ThresholdKeyShare *models.Secret } diff --git a/core/internal/cltest/factories.go b/core/internal/cltest/factories.go index 02f56e756d9..1d715d349ac 100644 --- a/core/internal/cltest/factories.go +++ b/core/internal/cltest/factories.go @@ -49,9 +49,9 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/utils" ) -func NewEIP55Address() ethkey.EIP55Address { +func NewEIP55Address() evmtypes.EIP55Address { a := testutils.NewAddress() - e, err := ethkey.NewEIP55Address(a.Hex()) + e, err := evmtypes.NewEIP55Address(a.Hex()) if err != nil { panic(err) } @@ -327,7 +327,7 @@ func MustInsertHead(t *testing.T, db sqlutil.DataSource, number int64) evmtypes. func MustInsertV2JobSpec(t *testing.T, db *sqlx.DB, transmitterAddress common.Address) job.Job { t.Helper() - addr, err := ethkey.NewEIP55Address(transmitterAddress.Hex()) + addr, err := evmtypes.NewEIP55Address(transmitterAddress.Hex()) require.NoError(t, err) pipelineSpec := pipeline.Spec{} @@ -351,7 +351,7 @@ func MustInsertV2JobSpec(t *testing.T, db *sqlx.DB, transmitterAddress common.Ad return jb } -func MustInsertOffchainreportingOracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress ethkey.EIP55Address) job.OCROracleSpec { +func MustInsertOffchainreportingOracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress evmtypes.EIP55Address) job.OCROracleSpec { t.Helper() ocrKeyID := models.MustSha256HashFromHex(DefaultOCRKeyBundleID) @@ -376,7 +376,7 @@ func MakeDirectRequestJobSpec(t *testing.T) *job.Job { return spec } -func MustInsertKeeperJob(t *testing.T, db *sqlx.DB, korm keeper.ORM, from ethkey.EIP55Address, contract ethkey.EIP55Address) job.Job { +func MustInsertKeeperJob(t *testing.T, db *sqlx.DB, korm keeper.ORM, from evmtypes.EIP55Address, contract evmtypes.EIP55Address) job.Job { t.Helper() var keeperSpec job.KeeperSpec @@ -421,7 +421,7 @@ func MustInsertKeeperRegistry(t *testing.T, db *sqlx.DB, korm keeper.ORM, ethKey JobID: job.ID, KeeperIndex: keeperIndex, NumKeepers: numKeepers, - KeeperIndexMap: map[ethkey.EIP55Address]int32{ + KeeperIndexMap: map[evmtypes.EIP55Address]int32{ from: keeperIndex, }, } diff --git a/core/internal/cltest/job_factories.go b/core/internal/cltest/job_factories.go index 399e71ff216..4b2ea66f22d 100644 --- a/core/internal/cltest/job_factories.go +++ b/core/internal/cltest/job_factories.go @@ -10,10 +10,10 @@ import ( "github.com/jmoiron/sqlx" "github.com/smartcontractkit/chainlink/v2/core/bridges" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" ) @@ -38,7 +38,7 @@ const ( ` ) -func MinimalOCRNonBootstrapSpec(contractAddress, transmitterAddress ethkey.EIP55Address, peerID p2pkey.PeerID, keyBundleID string) string { +func MinimalOCRNonBootstrapSpec(contractAddress, transmitterAddress types.EIP55Address, peerID p2pkey.PeerID, keyBundleID string) string { return fmt.Sprintf(minimalOCRNonBootstrapTemplate, contractAddress, peerID, transmitterAddress.Hex(), keyBundleID) } diff --git a/core/internal/features/features_test.go b/core/internal/features/features_test.go index 9c6d9cb8b62..cd231450650 100644 --- a/core/internal/features/features_test.go +++ b/core/internal/features/features_test.go @@ -64,7 +64,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" @@ -815,7 +814,7 @@ func TestIntegration_OCR(t *testing.T) { ports := freeport.GetN(t, numOracles) for i := 0; i < numOracles; i++ { app, peerID, transmitter, key := setupNode(t, owner, ports[i], b, func(c *chainlink.Config, s *chainlink.Secrets) { - c.EVM[0].FlagsContractAddress = ptr(ethkey.EIP55AddressFromAddress(flagsContractAddress)) + c.EVM[0].FlagsContractAddress = ptr(evmtypes.EIP55AddressFromAddress(flagsContractAddress)) c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(test.eip1559) c.P2P.V2.DefaultBootstrappers = &[]ocrcommontypes.BootstrapperLocator{ @@ -1036,7 +1035,7 @@ func TestIntegration_OCR_ForwarderFlow(t *testing.T) { for i := 0; i < numOracles; i++ { app, peerID, transmitter, forwarder, key := setupForwarderEnabledNode(t, owner, ports[i], b, func(c *chainlink.Config, s *chainlink.Secrets) { c.Feature.LogPoller = ptr(true) - c.EVM[0].FlagsContractAddress = ptr(ethkey.EIP55AddressFromAddress(flagsContractAddress)) + c.EVM[0].FlagsContractAddress = ptr(evmtypes.EIP55AddressFromAddress(flagsContractAddress)) c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(true) c.P2P.V2.DefaultBootstrappers = &[]ocrcommontypes.BootstrapperLocator{ {PeerID: bootstrapPeerID, Addrs: []string{fmt.Sprintf("127.0.0.1:%d", bootstrapNodePortV2)}}, diff --git a/core/scripts/go.mod b/core/scripts/go.mod index e9f31ae2ed8..8b8a757a76c 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -170,10 +170,12 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/consul/sdk v0.14.1 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-envparse v0.1.0 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index d59e0db8d58..38d053c98fc 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -701,6 +701,7 @@ github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdm github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -709,6 +710,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= diff --git a/core/services/blockhashstore/batch_bhs.go b/core/services/blockhashstore/batch_bhs.go index ffaa22b2463..58b4467f50c 100644 --- a/core/services/blockhashstore/batch_bhs.go +++ b/core/services/blockhashstore/batch_bhs.go @@ -11,10 +11,10 @@ import ( txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) type batchBHSConfig interface { @@ -31,7 +31,7 @@ type BatchBlockhashStore struct { func NewBatchBHS( config batchBHSConfig, - fromAddresses []ethkey.EIP55Address, + fromAddresses []types.EIP55Address, txm txmgr.TxManager, batchbhs batch_blockhash_store.BatchBlockhashStoreInterface, chainID *big.Int, diff --git a/core/services/blockhashstore/bhs.go b/core/services/blockhashstore/bhs.go index 877e7b3dc25..d4dd52c5661 100644 --- a/core/services/blockhashstore/bhs.go +++ b/core/services/blockhashstore/bhs.go @@ -16,10 +16,10 @@ import ( txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/trusted_blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) var _ BHS = &BulletproofBHS{} @@ -38,7 +38,7 @@ type BulletproofBHS struct { config bpBHSConfig dbConfig bpBHSDatabaseConfig jobID uuid.UUID - fromAddresses []ethkey.EIP55Address + fromAddresses []types.EIP55Address txm txmgr.TxManager abi *abi.ABI trustedAbi *abi.ABI @@ -52,7 +52,7 @@ type BulletproofBHS struct { func NewBulletproofBHS( config bpBHSConfig, dbConfig bpBHSDatabaseConfig, - fromAddresses []ethkey.EIP55Address, + fromAddresses []types.EIP55Address, txm txmgr.TxManager, bhs blockhash_store.BlockhashStoreInterface, trustedBHS *trusted_blockhash_store.TrustedBlockhashStore, diff --git a/core/services/blockhashstore/bhs_test.go b/core/services/blockhashstore/bhs_test.go index f8d33b51a34..75424ee8059 100644 --- a/core/services/blockhashstore/bhs_test.go +++ b/core/services/blockhashstore/bhs_test.go @@ -9,6 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -18,7 +19,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/blockhashstore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -41,7 +41,7 @@ func TestStoreRotatesFromAddresses(t *testing.T) { require.NoError(t, err) k2, err := ks.Eth().Create(ctx, &cltest.FixtureChainID) require.NoError(t, err) - fromAddresses := []ethkey.EIP55Address{k1.EIP55Address, k2.EIP55Address} + fromAddresses := []types.EIP55Address{k1.EIP55Address, k2.EIP55Address} txm := new(txmmocks.MockEvmTxManager) bhsAddress := common.HexToAddress("0x31Ca8bf590360B3198749f852D5c516c642846F6") diff --git a/core/services/blockhashstore/common.go b/core/services/blockhashstore/common.go index a19a3b868f7..30208296a4f 100644 --- a/core/services/blockhashstore/common.go +++ b/core/services/blockhashstore/common.go @@ -8,8 +8,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) // Coordinator defines an interface for fetching request and fulfillment metadata from a VRF @@ -133,7 +133,7 @@ func GetSearchWindow(latestBlock, waitBlocks, lookbackBlocks int) (uint64, uint6 } // SendingKeys returns a list of sending keys (common.Address) given EIP55 addresses -func SendingKeys(fromAddresses []ethkey.EIP55Address) []common.Address { +func SendingKeys(fromAddresses []types.EIP55Address) []common.Address { var keys []common.Address for _, a := range fromAddresses { keys = append(keys, a.Address()) diff --git a/core/services/blockhashstore/delegate.go b/core/services/blockhashstore/delegate.go index c8954ad1c2b..9a11c057c32 100644 --- a/core/services/blockhashstore/delegate.go +++ b/core/services/blockhashstore/delegate.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" v1 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/solidity_vrf_coordinator_interface" @@ -18,7 +19,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -74,7 +74,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, jb job.Job) ([]job.Servi if len(keys) == 0 { return nil, fmt.Errorf("missing sending keys for chain ID: %v", chain.ID()) } - fromAddresses := []ethkey.EIP55Address{keys[0].EIP55Address} + fromAddresses := []types.EIP55Address{keys[0].EIP55Address} if jb.BlockhashStoreSpec.FromAddresses != nil { fromAddresses = jb.BlockhashStoreSpec.FromAddresses } diff --git a/core/services/blockhashstore/validate_test.go b/core/services/blockhashstore/validate_test.go index 48487bb5489..099e5db02ca 100644 --- a/core/services/blockhashstore/validate_test.go +++ b/core/services/blockhashstore/validate_test.go @@ -6,15 +6,15 @@ import ( "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func TestValidate(t *testing.T) { - v1Coordinator := ethkey.EIP55Address("0x1F72B4A5DCf7CC6d2E38423bF2f4BFA7db97d139") - v2Coordinator := ethkey.EIP55Address("0x2be990eE17832b59E0086534c5ea2459Aa75E38F") - fromAddresses := []ethkey.EIP55Address{("0x469aA2CD13e037DC5236320783dCfd0e641c0559")} + v1Coordinator := types.EIP55Address("0x1F72B4A5DCf7CC6d2E38423bF2f4BFA7db97d139") + v2Coordinator := types.EIP55Address("0x2be990eE17832b59E0086534c5ea2459Aa75E38F") + fromAddresses := []types.EIP55Address{("0x469aA2CD13e037DC5236320783dCfd0e641c0559")} var tests = []struct { name string @@ -45,7 +45,7 @@ fromAddresses = ["0x469aA2CD13e037DC5236320783dCfd0e641c0559"]`, os.BlockhashStoreSpec.CoordinatorV2Address) require.Equal(t, int32(59), os.BlockhashStoreSpec.WaitBlocks) require.Equal(t, int32(159), os.BlockhashStoreSpec.LookbackBlocks) - require.Equal(t, ethkey.EIP55Address("0x3e20Cef636EdA7ba135bCbA4fe6177Bd3cE0aB17"), + require.Equal(t, types.EIP55Address("0x3e20Cef636EdA7ba135bCbA4fe6177Bd3cE0aB17"), os.BlockhashStoreSpec.BlockhashStoreAddress) require.Equal(t, 23*time.Second, os.BlockhashStoreSpec.PollPeriod) require.Equal(t, 7*time.Second, os.BlockhashStoreSpec.RunTimeout) diff --git a/core/services/blockheaderfeeder/block_header_feeder.go b/core/services/blockheaderfeeder/block_header_feeder.go index d1bcab4297a..b1e8ba7f2f3 100644 --- a/core/services/blockheaderfeeder/block_header_feeder.go +++ b/core/services/blockheaderfeeder/block_header_feeder.go @@ -12,10 +12,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/blockhashstore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) var ( @@ -48,7 +48,7 @@ func NewBlockHeaderFeeder( gethks keystore.Eth, getBlockhashesBatchSize uint16, storeBlockhashesBatchSize uint16, - fromAddresses []ethkey.EIP55Address, + fromAddresses []types.EIP55Address, chainID *big.Int, ) *BlockHeaderFeeder { return &BlockHeaderFeeder{ @@ -86,7 +86,7 @@ type BlockHeaderFeeder struct { getBlockhashesBatchSize uint16 storeBlockhashesBatchSize uint16 gethks keystore.Eth - fromAddresses []ethkey.EIP55Address + fromAddresses []types.EIP55Address chainID *big.Int } diff --git a/core/services/blockheaderfeeder/block_header_feeder_test.go b/core/services/blockheaderfeeder/block_header_feeder_test.go index 1b855caf9d2..afd7525c9e2 100644 --- a/core/services/blockheaderfeeder/block_header_feeder_test.go +++ b/core/services/blockheaderfeeder/block_header_feeder_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/blockhashstore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" keystoremocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" ) @@ -200,7 +200,7 @@ func (test testCase) testFeeder(t *testing.T) { blockHeaderProvider := &blockhashstore.TestBlockHeaderProvider{} fromAddress := "0x469aA2CD13e037DC5236320783dCfd0e641c0559" - fromAddresses := []ethkey.EIP55Address{ethkey.EIP55Address(fromAddress)} + fromAddresses := []types.EIP55Address{types.EIP55Address(fromAddress)} ks := keystoremocks.NewEth(t) ks.On("GetRoundRobinAddress", mock.Anything, testutils.FixtureChainID, mock.Anything).Maybe().Return(common.HexToAddress(fromAddress), nil) @@ -244,7 +244,7 @@ func TestFeeder_CachesStoredBlocks(t *testing.T) { batchBHS := &blockhashstore.TestBatchBHS{Stored: []uint64{75}} blockHeaderProvider := &blockhashstore.TestBlockHeaderProvider{} fromAddress := "0x469aA2CD13e037DC5236320783dCfd0e641c0559" - fromAddresses := []ethkey.EIP55Address{ethkey.EIP55Address(fromAddress)} + fromAddresses := []types.EIP55Address{types.EIP55Address(fromAddress)} ks := keystoremocks.NewEth(t) ks.On("GetRoundRobinAddress", mock.Anything, testutils.FixtureChainID, mock.Anything).Maybe().Return(common.HexToAddress(fromAddress), nil) diff --git a/core/services/blockheaderfeeder/validate_test.go b/core/services/blockheaderfeeder/validate_test.go index cdab0322a40..66413a615bd 100644 --- a/core/services/blockheaderfeeder/validate_test.go +++ b/core/services/blockheaderfeeder/validate_test.go @@ -6,16 +6,16 @@ import ( "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func TestValidate(t *testing.T) { - v1Coordinator := ethkey.EIP55Address("0x1F72B4A5DCf7CC6d2E38423bF2f4BFA7db97d139") - v2Coordinator := ethkey.EIP55Address("0x2be990eE17832b59E0086534c5ea2459Aa75E38F") - v2PlusCoordinator := ethkey.EIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") - fromAddresses := []ethkey.EIP55Address{("0x469aA2CD13e037DC5236320783dCfd0e641c0559")} + v1Coordinator := types.EIP55Address("0x1F72B4A5DCf7CC6d2E38423bF2f4BFA7db97d139") + v2Coordinator := types.EIP55Address("0x2be990eE17832b59E0086534c5ea2459Aa75E38F") + v2PlusCoordinator := types.EIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") + fromAddresses := []types.EIP55Address{("0x469aA2CD13e037DC5236320783dCfd0e641c0559")} var tests = []struct { name string @@ -53,9 +53,9 @@ storeBlockhashesBatchSize = 10 os.BlockHeaderFeederSpec.CoordinatorV2PlusAddress) require.Equal(t, int32(2000), os.BlockHeaderFeederSpec.LookbackBlocks) require.Equal(t, int32(500), os.BlockHeaderFeederSpec.WaitBlocks) - require.Equal(t, ethkey.EIP55Address("0x3e20Cef636EdA7ba135bCbA4fe6177Bd3cE0aB17"), + require.Equal(t, types.EIP55Address("0x3e20Cef636EdA7ba135bCbA4fe6177Bd3cE0aB17"), os.BlockHeaderFeederSpec.BlockhashStoreAddress) - require.Equal(t, ethkey.EIP55Address("0xD04E5b2ea4e55AEbe6f7522bc2A69Ec6639bfc63"), + require.Equal(t, types.EIP55Address("0xD04E5b2ea4e55AEbe6f7522bc2A69Ec6639bfc63"), os.BlockHeaderFeederSpec.BatchBlockhashStoreAddress) require.Equal(t, 23*time.Second, os.BlockHeaderFeederSpec.PollPeriod) require.Equal(t, 7*time.Second, os.BlockHeaderFeederSpec.RunTimeout) diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index bb6c0030a95..ca8f118b149 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -49,6 +49,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/ocr2" "github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" + externalp2p "github.com/smartcontractkit/chainlink/v2/core/services/p2p/wrapper" "github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" @@ -191,6 +192,15 @@ func NewApplication(opts ApplicationOpts) (Application, error) { unrestrictedHTTPClient := opts.UnrestrictedHTTPClient registry := capabilities.NewRegistry(globalLogger) + if cfg.Capabilities().Peering().Enabled() { + externalPeerWrapper := externalp2p.NewExternalPeerWrapper(keyStore.P2P(), cfg.Capabilities().Peering(), globalLogger) + srvcs = append(srvcs, externalPeerWrapper) + + // NOTE: RegistrySyncer will depend on a Relayer when fully implemented + registrySyncer := capabilities.NewRegistrySyncer(externalPeerWrapper, registry, globalLogger) + srvcs = append(srvcs, registrySyncer) + } + // LOOPs can be created as options, in the case of LOOP relayers, or // as OCR2 job implementations, in the case of Median today. // We will have a non-nil registry here in LOOP relayers are being used, otherwise diff --git a/core/services/chainlink/config_capabilities.go b/core/services/chainlink/config_capabilities.go new file mode 100644 index 00000000000..d432d31ad18 --- /dev/null +++ b/core/services/chainlink/config_capabilities.go @@ -0,0 +1,16 @@ +package chainlink + +import ( + "github.com/smartcontractkit/chainlink/v2/core/config" + "github.com/smartcontractkit/chainlink/v2/core/config/toml" +) + +var _ config.Capabilities = (*capabilitiesConfig)(nil) + +type capabilitiesConfig struct { + c toml.Capabilities +} + +func (c *capabilitiesConfig) Peering() config.P2P { + return &p2p{c: c.c.Peering} +} diff --git a/core/services/chainlink/config_capabilities_test.go b/core/services/chainlink/config_capabilities_test.go new file mode 100644 index 00000000000..7ff3f3fed08 --- /dev/null +++ b/core/services/chainlink/config_capabilities_test.go @@ -0,0 +1,46 @@ +package chainlink + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/libocr/commontypes" +) + +func TestCapabilitiesConfig(t *testing.T) { + opts := GeneralConfigOpts{ + ConfigStrings: []string{fullTOML}, + } + cfg, err := opts.New() + require.NoError(t, err) + + p2p := cfg.Capabilities().Peering() + assert.Equal(t, "p2p_12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", p2p.PeerID().String()) + assert.Equal(t, 13, p2p.IncomingMessageBufferSize()) + assert.Equal(t, 17, p2p.OutgoingMessageBufferSize()) + assert.True(t, p2p.TraceLogging()) + + v2 := p2p.V2() + assert.False(t, v2.Enabled()) + assert.Equal(t, []string{"a", "b", "c"}, v2.AnnounceAddresses()) + assert.ElementsMatch( + t, + []commontypes.BootstrapperLocator{ + { + PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", + Addrs: []string{"test:99"}, + }, + { + PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", + Addrs: []string{"foo:42", "bar:10"}, + }, + }, + v2.DefaultBootstrappers(), + ) + assert.Equal(t, time.Minute, v2.DeltaDial().Duration()) + assert.Equal(t, 2*time.Second, v2.DeltaReconcile().Duration()) + assert.Equal(t, []string{"foo", "bar"}, v2.ListenAddresses()) +} diff --git a/core/services/chainlink/config_general.go b/core/services/chainlink/config_general.go index 97243926973..cae01c01cb7 100644 --- a/core/services/chainlink/config_general.go +++ b/core/services/chainlink/config_general.go @@ -397,6 +397,10 @@ func (g *generalConfig) AutoPprofProfileRoot() string { return s } +func (g *generalConfig) Capabilities() config.Capabilities { + return &capabilitiesConfig{c: g.c.Capabilities} +} + func (g *generalConfig) Database() coreconfig.Database { return &databaseConfig{c: g.c.Database, s: g.secrets.Secrets.Database, logSQL: g.logSQL} } diff --git a/core/services/chainlink/config_ocr.go b/core/services/chainlink/config_ocr.go index 072c724871a..cf6127e713a 100644 --- a/core/services/chainlink/config_ocr.go +++ b/core/services/chainlink/config_ocr.go @@ -5,9 +5,9 @@ import ( "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) var _ config.OCR = (*ocrConfig)(nil) @@ -48,7 +48,7 @@ func (o *ocrConfig) SimulateTransactions() bool { return *o.c.SimulateTransactions } -func (o *ocrConfig) TransmitterAddress() (ethkey.EIP55Address, error) { +func (o *ocrConfig) TransmitterAddress() (types.EIP55Address, error) { a := *o.c.TransmitterAddress if a.IsZero() { return a, errors.Wrap(config.ErrEnvUnset, "OCR.TransmitterAddress is not set") diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index 4422a743689..63ff68fa966 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -30,12 +30,12 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" legacy "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -209,8 +209,8 @@ func TestConfig_Marshal(t *testing.T) { require.NoError(t, err) return &d } - mustAddress := func(s string) *ethkey.EIP55Address { - a, err := ethkey.NewEIP55Address(s) + mustAddress := func(s string) *types.EIP55Address { + a, err := types.NewEIP55Address(s) require.NoError(t, err) return &a } @@ -403,7 +403,7 @@ func TestConfig_Marshal(t *testing.T) { DefaultTransactionQueueDepth: ptr[uint32](12), KeyBundleID: ptr(models.MustSha256HashFromHex("acdd42797a8b921b2910497badc50006")), SimulateTransactions: ptr(true), - TransmitterAddress: ptr(ethkey.MustEIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e")), + TransmitterAddress: ptr(types.MustEIP55Address("0xa0788FC17B1dEe36f057c42B6F373A34B014687e")), CaptureEATelemetry: ptr(false), TraceLogging: ptr(false), } @@ -424,6 +424,25 @@ func TestConfig_Marshal(t *testing.T) { ListenAddresses: &[]string{"foo", "bar"}, }, } + full.Capabilities = toml.Capabilities{ + Peering: toml.P2P{ + IncomingMessageBufferSize: ptr[int64](13), + OutgoingMessageBufferSize: ptr[int64](17), + PeerID: mustPeerID("12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw"), + TraceLogging: ptr(true), + V2: toml.P2PV2{ + Enabled: ptr(false), + AnnounceAddresses: &[]string{"a", "b", "c"}, + DefaultBootstrappers: &[]ocrcommontypes.BootstrapperLocator{ + {PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", Addrs: []string{"foo:42", "bar:10"}}, + {PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", Addrs: []string{"test:99"}}, + }, + DeltaDial: commoncfg.MustNewDuration(time.Minute), + DeltaReconcile: commoncfg.MustNewDuration(2 * time.Second), + ListenAddresses: &[]string{"foo", "bar"}, + }, + }, + } full.Keeper = toml.Keeper{ DefaultTransactionQueueDepth: ptr[uint32](17), GasPriceBufferPercent: ptr[uint16](12), @@ -1130,7 +1149,7 @@ func TestConfig_full(t *testing.T) { require.NoError(t, config.DecodeTOML(strings.NewReader(fullTOML), &got)) // Except for some EVM node fields. for c := range got.EVM { - addr, err := ethkey.NewEIP55Address("0x2a3e23c6f242F5345320814aC8a1b4E58707D292") + addr, err := types.NewEIP55Address("0x2a3e23c6f242F5345320814aC8a1b4E58707D292") require.NoError(t, err) if got.EVM[c].ChainWriter.FromAddress == nil { got.EVM[c].ChainWriter.FromAddress = &addr diff --git a/core/services/chainlink/mocks/general_config.go b/core/services/chainlink/mocks/general_config.go index 1dd85875395..a520a878d3c 100644 --- a/core/services/chainlink/mocks/general_config.go +++ b/core/services/chainlink/mocks/general_config.go @@ -86,6 +86,26 @@ func (_m *GeneralConfig) AutoPprof() config.AutoPprof { return r0 } +// Capabilities provides a mock function with given fields: +func (_m *GeneralConfig) Capabilities() config.Capabilities { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Capabilities") + } + + var r0 config.Capabilities + if rf, ok := ret.Get(0).(func() config.Capabilities); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(config.Capabilities) + } + } + + return r0 +} + // ConfigTOML provides a mock function with given fields: func (_m *GeneralConfig) ConfigTOML() (string, string) { ret := _m.Called() diff --git a/core/services/chainlink/testdata/config-empty-effective.toml b/core/services/chainlink/testdata/config-empty-effective.toml index 148f6b24ff5..8fdb2858cdb 100644 --- a/core/services/chainlink/testdata/config-empty-effective.toml +++ b/core/services/chainlink/testdata/config-empty-effective.toml @@ -228,3 +228,18 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' + +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] diff --git a/core/services/chainlink/testdata/config-full.toml b/core/services/chainlink/testdata/config-full.toml index c1606a5b067..cd8a17e538a 100644 --- a/core/services/chainlink/testdata/config-full.toml +++ b/core/services/chainlink/testdata/config-full.toml @@ -239,6 +239,21 @@ LatestReportDeadline = '1m42s' [Mercury.TLS] CertFile = '/path/to/cert.pem' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 13 +OutgoingMessageBufferSize = 17 +PeerID = '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw' +TraceLogging = true + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = ['a', 'b', 'c'] +DefaultBootstrappers = ['12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw@foo:42/bar:10', '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw@test:99'] +DeltaDial = '1m0s' +DeltaReconcile = '2s' +ListenAddresses = ['foo', 'bar'] + [[EVM]] ChainID = '1' Enabled = false diff --git a/core/services/chainlink/testdata/config-multi-chain-effective.toml b/core/services/chainlink/testdata/config-multi-chain-effective.toml index 9f69d4aa909..45d52432ee5 100644 --- a/core/services/chainlink/testdata/config-multi-chain-effective.toml +++ b/core/services/chainlink/testdata/config-multi-chain-effective.toml @@ -229,6 +229,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/core/services/directrequest/validate.go b/core/services/directrequest/validate.go index 271e720660f..8cb9899d3f9 100644 --- a/core/services/directrequest/validate.go +++ b/core/services/directrequest/validate.go @@ -5,15 +5,15 @@ import ( "github.com/pkg/errors" "github.com/smartcontractkit/chainlink-common/pkg/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type DirectRequestToml struct { - ContractAddress ethkey.EIP55Address `toml:"contractAddress"` + ContractAddress types.EIP55Address `toml:"contractAddress"` Requesters models.AddressCollection `toml:"requesters"` MinContractPayment *assets.Link `toml:"minContractPaymentLinkJuels"` EVMChainID *big.Big `toml:"evmChainID"` diff --git a/core/services/feeds/service.go b/core/services/feeds/service.go index fa5ad51a65a..abb85f39fe4 100644 --- a/core/services/feeds/service.go +++ b/core/services/feeds/service.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -26,7 +27,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/fluxmonitorv2" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" @@ -1101,7 +1101,7 @@ func (s *service) findExistingJobForOCR2(j *job.Job, qopts pg.QOpt) (int32, erro // findExistingJobForOCRFlux looks for existing job for OCR or flux func (s *service) findExistingJobForOCRFlux(j *job.Job, qopts pg.QOpt) (int32, error) { - var address ethkey.EIP55Address + var address types.EIP55Address var evmChainID *big.Big switch j.Type { diff --git a/core/services/feeds/service_test.go b/core/services/feeds/service_test.go index 0e590fa9038..afefc5b2df8 100644 --- a/core/services/feeds/service_test.go +++ b/core/services/feeds/service_test.go @@ -20,6 +20,7 @@ import ( commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -35,7 +36,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/job" jobmocks "github.com/smartcontractkit/chainlink/v2/core/services/job/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/csakey" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/keystest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocrkey" ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" @@ -1547,7 +1547,7 @@ func Test_Service_ListSpecsByJobProposalIDs(t *testing.T) { func Test_Service_ApproveSpec(t *testing.T) { var evmChainID *big.Big - address := ethkey.EIP55AddressFromAddress(common.Address{}) + address := types.EIP55AddressFromAddress(common.Address{}) externalJobID := uuid.New() var ( diff --git a/core/services/fluxmonitorv2/integrations_test.go b/core/services/fluxmonitorv2/integrations_test.go index 7f45e6eb19c..3fbbdd8925f 100644 --- a/core/services/fluxmonitorv2/integrations_test.go +++ b/core/services/fluxmonitorv2/integrations_test.go @@ -30,6 +30,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flags_wrapper" faw "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" @@ -623,7 +624,7 @@ func TestFluxMonitor_NewRound(t *testing.T) { app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) - flags := ethkey.EIP55AddressFromAddress(fa.flagsContractAddress) + flags := types.EIP55AddressFromAddress(fa.flagsContractAddress) c.EVM[0].FlagsContractAddress = &flags }) @@ -734,7 +735,7 @@ func TestFluxMonitor_HibernationMode(t *testing.T) { app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) - flags := ethkey.EIP55AddressFromAddress(fa.flagsContractAddress) + flags := types.EIP55AddressFromAddress(fa.flagsContractAddress) c.EVM[0].FlagsContractAddress = &flags }) diff --git a/core/services/functions/external_adapter_client.go b/core/services/functions/external_adapter_client.go index fb64924a922..9dc77ca78e9 100644 --- a/core/services/functions/external_adapter_client.go +++ b/core/services/functions/external_adapter_client.go @@ -10,6 +10,7 @@ import ( "net/url" "time" + "github.com/hashicorp/go-retryablehttp" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -42,8 +43,10 @@ type ExternalAdapterClient interface { } type externalAdapterClient struct { - adapterURL url.URL - maxResponseBytes int64 + adapterURL url.URL + maxResponseBytes int64 + maxRetries int + exponentialBackoffBase time.Duration } var _ ExternalAdapterClient = (*externalAdapterClient)(nil) @@ -54,9 +57,11 @@ type BridgeAccessor interface { } type bridgeAccessor struct { - bridgeORM bridges.ORM - bridgeName string - maxResponseBytes int64 + bridgeORM bridges.ORM + bridgeName string + maxResponseBytes int64 + maxRetries int + exponentialBackoffBase time.Duration } var _ BridgeAccessor = (*bridgeAccessor)(nil) @@ -112,10 +117,12 @@ var ( ) ) -func NewExternalAdapterClient(adapterURL url.URL, maxResponseBytes int64) ExternalAdapterClient { +func NewExternalAdapterClient(adapterURL url.URL, maxResponseBytes int64, maxRetries int, exponentialBackoffBase time.Duration) ExternalAdapterClient { return &externalAdapterClient{ - adapterURL: adapterURL, - maxResponseBytes: maxResponseBytes, + adapterURL: adapterURL, + maxResponseBytes: maxResponseBytes, + maxRetries: maxRetries, + exponentialBackoffBase: exponentialBackoffBase, } } @@ -190,7 +197,13 @@ func (ea *externalAdapterClient) request( req.Header.Set("Content-Type", "application/json") start := time.Now() - client := &http.Client{} + + // retry will only happen on a 5XX error response code (except 501) + retryClient := retryablehttp.NewClient() + retryClient.RetryMax = ea.maxRetries + retryClient.RetryWaitMin = ea.exponentialBackoffBase + + client := retryClient.StandardClient() resp, err := client.Do(req) if err != nil { promEAClientErrors.WithLabelValues(label).Inc() @@ -244,11 +257,13 @@ func (ea *externalAdapterClient) request( } } -func NewBridgeAccessor(bridgeORM bridges.ORM, bridgeName string, maxResponseBytes int64) BridgeAccessor { +func NewBridgeAccessor(bridgeORM bridges.ORM, bridgeName string, maxResponseBytes int64, maxRetries int, exponentialBackoffBase time.Duration) BridgeAccessor { return &bridgeAccessor{ - bridgeORM: bridgeORM, - bridgeName: bridgeName, - maxResponseBytes: maxResponseBytes, + bridgeORM: bridgeORM, + bridgeName: bridgeName, + maxResponseBytes: maxResponseBytes, + maxRetries: maxRetries, + exponentialBackoffBase: exponentialBackoffBase, } } @@ -257,5 +272,5 @@ func (b *bridgeAccessor) NewExternalAdapterClient() (ExternalAdapterClient, erro if err != nil { return nil, err } - return NewExternalAdapterClient(url.URL(bridge.URL), b.maxResponseBytes), nil + return NewExternalAdapterClient(url.URL(bridge.URL), b.maxResponseBytes, b.maxRetries, b.exponentialBackoffBase), nil } diff --git a/core/services/functions/external_adapter_client_test.go b/core/services/functions/external_adapter_client_test.go index 9fd40ba8280..4ce78ee3fc3 100644 --- a/core/services/functions/external_adapter_client_test.go +++ b/core/services/functions/external_adapter_client_test.go @@ -27,7 +27,7 @@ func runFetcherTest(t *testing.T, adapterJSONResponse, expectedSecrets, expected adapterUrl, err := url.Parse(ts.URL) assert.NoError(t, err, "Unexpected error") - ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000) + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 0, 0) encryptedSecrets, userError, err := ea.FetchEncryptedSecrets(testutils.Context(t), []byte("urls to secrets"), "requestID1234", "TestJob") if expectedError != nil { @@ -50,7 +50,7 @@ func runRequestTest(t *testing.T, adapterJSONResponse, expectedUserResult, expec adapterUrl, err := url.Parse(ts.URL) assert.NoError(t, err, "Unexpected error") - ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000) + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 0, 0) userResult, userError, domains, err := ea.RunComputation(testutils.Context(t), "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "", &functions.RequestData{}) if expectedError != nil { @@ -144,15 +144,7 @@ func TestFetchEncryptedSecrets_UnexpectedResult(t *testing.T) { } func TestRunComputation_Success(t *testing.T) { - runRequestTest(t, `{ - "result": "success", - "data": { - "result": "0x616263646566", - "error": "", - "domains": ["domain1", "domain2"] - }, - "statusCode": 200 - }`, "abcdef", "", []string{"domain1", "domain2"}, nil) + runRequestTest(t, runComputationSuccessResponse, "abcdef", "", []string{"domain1", "domain2"}, nil) } func TestRunComputation_MissingData(t *testing.T) { @@ -177,7 +169,7 @@ func TestRunComputation_CorrectAdapterRequest(t *testing.T) { adapterUrl, err := url.Parse(ts.URL) assert.NoError(t, err) - ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000) + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 0, 0) reqData := &functions.RequestData{ Source: "abcd", Language: 7, @@ -199,7 +191,7 @@ func TestRunComputation_HTTP500(t *testing.T) { adapterUrl, err := url.Parse(ts.URL) assert.NoError(t, err) - ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000) + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 0, 0) _, _, _, err = ea.RunComputation(testutils.Context(t), "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "secRETS", &functions.RequestData{}) assert.Error(t, err) } @@ -214,10 +206,96 @@ func TestRunComputation_ContextRespected(t *testing.T) { adapterUrl, err := url.Parse(ts.URL) assert.NoError(t, err) - ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000) + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 0, 0) ctx, cancel := context.WithTimeout(testutils.Context(t), 10*time.Millisecond) defer cancel() _, _, _, err = ea.RunComputation(ctx, "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "secRETS", &functions.RequestData{}) assert.Error(t, err) close(done) } + +func TestRunComputationRetrial(t *testing.T) { + + t.Run("OK-retry_succeeds_after_one_failure", func(t *testing.T) { + counter := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch counter { + case 0: + counter++ + w.WriteHeader(http.StatusInternalServerError) + return + case 1: + counter++ + fmt.Fprintln(w, runComputationSuccessResponse) + return + default: + t.Errorf("invalid amount of retries: %d", counter) + t.FailNow() + } + })) + defer ts.Close() + + adapterUrl, err := url.Parse(ts.URL) + assert.NoError(t, err) + + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 1, 1*time.Nanosecond) + _, _, _, err = ea.RunComputation(testutils.Context(t), "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "secRETS", &functions.RequestData{}) + assert.NoError(t, err) + }) + + t.Run("NOK-retry_fails_after_retrial", func(t *testing.T) { + counter := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch counter { + case 0, 1: + counter++ + w.WriteHeader(http.StatusInternalServerError) + return + default: + t.Errorf("invalid amount of retries: %d", counter) + t.FailNow() + } + })) + defer ts.Close() + + adapterUrl, err := url.Parse(ts.URL) + assert.NoError(t, err) + + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 1, 1*time.Nanosecond) + _, _, _, err = ea.RunComputation(testutils.Context(t), "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "secRETS", &functions.RequestData{}) + assert.Error(t, err) + }) + + t.Run("NOK-dont_retry_on_4XX_errors", func(t *testing.T) { + counter := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch counter { + case 0: + counter++ + w.WriteHeader(http.StatusBadRequest) + return + default: + t.Errorf("invalid amount of retries: %d", counter) + t.FailNow() + } + })) + defer ts.Close() + + adapterUrl, err := url.Parse(ts.URL) + assert.NoError(t, err) + + ea := functions.NewExternalAdapterClient(*adapterUrl, 100_000, 1, 1*time.Nanosecond) + _, _, _, err = ea.RunComputation(testutils.Context(t), "requestID1234", "TestJob", "SubOwner", 1, functions.RequestFlags{}, "secRETS", &functions.RequestData{}) + assert.Error(t, err) + }) +} + +const runComputationSuccessResponse = `{ + "result": "success", + "data": { + "result": "0x616263646566", + "error": "", + "domains": ["domain1", "domain2"] + }, + "statusCode": 200 + }` diff --git a/core/services/job/job_orm_test.go b/core/services/job/job_orm_test.go index 9716231868c..a8931796fd0 100644 --- a/core/services/job/job_orm_test.go +++ b/core/services/job/job_orm_test.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" @@ -483,7 +484,7 @@ func TestORM_CreateJob_VRFV2(t *testing.T) { actual = append(actual, common.BytesToAddress(b).String()) } require.ElementsMatch(t, fromAddresses, actual) - var vrfOwnerAddress ethkey.EIP55Address + var vrfOwnerAddress evmtypes.EIP55Address require.NoError(t, db.Get(&vrfOwnerAddress, `SELECT vrf_owner_address FROM vrf_specs LIMIT 1`)) require.Equal(t, "0x32891BD79647DC9136Fc0a59AAB48c7825eb624c", vrfOwnerAddress.Address().String()) require.NoError(t, jobORM.DeleteJob(jb.ID)) @@ -567,7 +568,7 @@ func TestORM_CreateJob_VRFV2Plus(t *testing.T) { actual = append(actual, common.BytesToAddress(b).String()) } require.ElementsMatch(t, fromAddresses, actual) - var vrfOwnerAddress ethkey.EIP55Address + var vrfOwnerAddress evmtypes.EIP55Address require.Error(t, db.Get(&vrfOwnerAddress, `SELECT vrf_owner_address FROM vrf_specs LIMIT 1`)) require.NoError(t, jobORM.DeleteJob(jb.ID)) cltest.AssertCount(t, db, "vrf_specs", 0) diff --git a/core/services/job/mocks/orm.go b/core/services/job/mocks/orm.go index 062c6e936bc..1068f511cdc 100644 --- a/core/services/job/mocks/orm.go +++ b/core/services/job/mocks/orm.go @@ -8,8 +8,6 @@ import ( context "context" - ethkey "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - job "github.com/smartcontractkit/chainlink/v2/core/services/job" mock "github.com/stretchr/testify/mock" @@ -18,6 +16,8 @@ import ( pipeline "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" + types "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + uuid "github.com/google/uuid" ) @@ -222,7 +222,7 @@ func (_m *ORM) FindJobByExternalJobID(_a0 uuid.UUID, qopts ...pg.QOpt) (job.Job, } // FindJobIDByAddress provides a mock function with given fields: address, evmChainID, qopts -func (_m *ORM) FindJobIDByAddress(address ethkey.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (int32, error) { +func (_m *ORM) FindJobIDByAddress(address types.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (int32, error) { _va := make([]interface{}, len(qopts)) for _i := range qopts { _va[_i] = qopts[_i] @@ -238,16 +238,16 @@ func (_m *ORM) FindJobIDByAddress(address ethkey.EIP55Address, evmChainID *big.B var r0 int32 var r1 error - if rf, ok := ret.Get(0).(func(ethkey.EIP55Address, *big.Big, ...pg.QOpt) (int32, error)); ok { + if rf, ok := ret.Get(0).(func(types.EIP55Address, *big.Big, ...pg.QOpt) (int32, error)); ok { return rf(address, evmChainID, qopts...) } - if rf, ok := ret.Get(0).(func(ethkey.EIP55Address, *big.Big, ...pg.QOpt) int32); ok { + if rf, ok := ret.Get(0).(func(types.EIP55Address, *big.Big, ...pg.QOpt) int32); ok { r0 = rf(address, evmChainID, qopts...) } else { r0 = ret.Get(0).(int32) } - if rf, ok := ret.Get(1).(func(ethkey.EIP55Address, *big.Big, ...pg.QOpt) error); ok { + if rf, ok := ret.Get(1).(func(types.EIP55Address, *big.Big, ...pg.QOpt) error); ok { r1 = rf(address, evmChainID, qopts...) } else { r1 = ret.Error(1) diff --git a/core/services/job/models.go b/core/services/job/models.go index 233912d09c2..218be21bc54 100644 --- a/core/services/job/models.go +++ b/core/services/job/models.go @@ -20,10 +20,10 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" clnull "github.com/smartcontractkit/chainlink/v2/core/null" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1" @@ -247,24 +247,24 @@ func (pr *PipelineRun) SetID(value string) error { // OCROracleSpec defines the job spec for OCR jobs. type OCROracleSpec struct { - ID int32 `toml:"-"` - ContractAddress ethkey.EIP55Address `toml:"contractAddress"` - P2PV2Bootstrappers pq.StringArray `toml:"p2pv2Bootstrappers" db:"p2pv2_bootstrappers"` - IsBootstrapPeer bool `toml:"isBootstrapPeer"` - EncryptedOCRKeyBundleID *models.Sha256Hash `toml:"keyBundleID"` - TransmitterAddress *ethkey.EIP55Address `toml:"transmitterAddress"` - ObservationTimeout models.Interval `toml:"observationTimeout"` - BlockchainTimeout models.Interval `toml:"blockchainTimeout"` - ContractConfigTrackerSubscribeInterval models.Interval `toml:"contractConfigTrackerSubscribeInterval"` - ContractConfigTrackerPollInterval models.Interval `toml:"contractConfigTrackerPollInterval"` - ContractConfigConfirmations uint16 `toml:"contractConfigConfirmations"` - EVMChainID *big.Big `toml:"evmChainID" db:"evm_chain_id"` - DatabaseTimeout *models.Interval `toml:"databaseTimeout"` - ObservationGracePeriod *models.Interval `toml:"observationGracePeriod"` - ContractTransmitterTransmitTimeout *models.Interval `toml:"contractTransmitterTransmitTimeout"` - CaptureEATelemetry bool `toml:"captureEATelemetry"` - CreatedAt time.Time `toml:"-"` - UpdatedAt time.Time `toml:"-"` + ID int32 `toml:"-"` + ContractAddress evmtypes.EIP55Address `toml:"contractAddress"` + P2PV2Bootstrappers pq.StringArray `toml:"p2pv2Bootstrappers" db:"p2pv2_bootstrappers"` + IsBootstrapPeer bool `toml:"isBootstrapPeer"` + EncryptedOCRKeyBundleID *models.Sha256Hash `toml:"keyBundleID"` + TransmitterAddress *evmtypes.EIP55Address `toml:"transmitterAddress"` + ObservationTimeout models.Interval `toml:"observationTimeout"` + BlockchainTimeout models.Interval `toml:"blockchainTimeout"` + ContractConfigTrackerSubscribeInterval models.Interval `toml:"contractConfigTrackerSubscribeInterval"` + ContractConfigTrackerPollInterval models.Interval `toml:"contractConfigTrackerPollInterval"` + ContractConfigConfirmations uint16 `toml:"contractConfigConfirmations"` + EVMChainID *big.Big `toml:"evmChainID" db:"evm_chain_id"` + DatabaseTimeout *models.Interval `toml:"databaseTimeout"` + ObservationGracePeriod *models.Interval `toml:"observationGracePeriod"` + ContractTransmitterTransmitTimeout *models.Interval `toml:"contractTransmitterTransmitTimeout"` + CaptureEATelemetry bool `toml:"captureEATelemetry"` + CreatedAt time.Time `toml:"-"` + UpdatedAt time.Time `toml:"-"` } // GetID is a getter function that returns the ID of the spec. @@ -443,7 +443,7 @@ func (w *WebhookSpec) SetID(value string) error { type DirectRequestSpec struct { ID int32 `toml:"-"` - ContractAddress ethkey.EIP55Address `toml:"contractAddress"` + ContractAddress evmtypes.EIP55Address `toml:"contractAddress"` MinIncomingConfirmations clnull.Uint32 `toml:"minIncomingConfirmations"` Requesters models.AddressCollection `toml:"requesters"` MinContractPayment *commonassets.Link `toml:"minContractPaymentLinkJuels"` @@ -473,9 +473,9 @@ func (s *CronSpec) SetID(value string) error { } type FluxMonitorSpec struct { - ID int32 `toml:"-"` - ContractAddress ethkey.EIP55Address `toml:"contractAddress"` - Threshold tomlutils.Float32 `toml:"threshold,float"` + ID int32 `toml:"-"` + ContractAddress evmtypes.EIP55Address `toml:"contractAddress"` + Threshold tomlutils.Float32 `toml:"threshold,float"` // AbsoluteThreshold is the maximum absolute change allowed in a fluxmonitored // value before a new round should be kicked off, so that the current value // can be reported on-chain. @@ -494,13 +494,13 @@ type FluxMonitorSpec struct { } type KeeperSpec struct { - ID int32 `toml:"-"` - ContractAddress ethkey.EIP55Address `toml:"contractAddress"` - MinIncomingConfirmations *uint32 `toml:"minIncomingConfirmations"` - FromAddress ethkey.EIP55Address `toml:"fromAddress"` - EVMChainID *big.Big `toml:"evmChainID"` - CreatedAt time.Time `toml:"-"` - UpdatedAt time.Time `toml:"-"` + ID int32 `toml:"-"` + ContractAddress evmtypes.EIP55Address `toml:"contractAddress"` + MinIncomingConfirmations *uint32 `toml:"minIncomingConfirmations"` + FromAddress evmtypes.EIP55Address `toml:"fromAddress"` + EVMChainID *big.Big `toml:"evmChainID"` + CreatedAt time.Time `toml:"-"` + UpdatedAt time.Time `toml:"-"` } type VRFSpec struct { @@ -508,7 +508,7 @@ type VRFSpec struct { // BatchCoordinatorAddress is the address of the batch vrf coordinator to use. // This is required if batchFulfillmentEnabled is set to true in the job spec. - BatchCoordinatorAddress *ethkey.EIP55Address `toml:"batchCoordinatorAddress"` + BatchCoordinatorAddress *evmtypes.EIP55Address `toml:"batchCoordinatorAddress"` // BatchFulfillmentEnabled indicates to the vrf job to use the batch vrf coordinator // for fulfilling requests. If set to true, batchCoordinatorAddress must be set in // the job spec. @@ -523,16 +523,16 @@ type VRFSpec struct { // VRFOwnerAddress is the address of the VRFOwner address to use. // // V2 only. - VRFOwnerAddress *ethkey.EIP55Address `toml:"vrfOwnerAddress"` + VRFOwnerAddress *evmtypes.EIP55Address `toml:"vrfOwnerAddress"` - CoordinatorAddress ethkey.EIP55Address `toml:"coordinatorAddress"` - PublicKey secp256k1.PublicKey `toml:"publicKey"` - MinIncomingConfirmations uint32 `toml:"minIncomingConfirmations"` - EVMChainID *big.Big `toml:"evmChainID"` - FromAddresses []ethkey.EIP55Address `toml:"fromAddresses"` - PollPeriod time.Duration `toml:"pollPeriod"` // For v2 jobs - RequestedConfsDelay int64 `toml:"requestedConfsDelay"` // For v2 jobs. Optional, defaults to 0 if not provided. - RequestTimeout time.Duration `toml:"requestTimeout"` // Optional, defaults to 24hr if not provided. + CoordinatorAddress evmtypes.EIP55Address `toml:"coordinatorAddress"` + PublicKey secp256k1.PublicKey `toml:"publicKey"` + MinIncomingConfirmations uint32 `toml:"minIncomingConfirmations"` + EVMChainID *big.Big `toml:"evmChainID"` + FromAddresses []evmtypes.EIP55Address `toml:"fromAddresses"` + PollPeriod time.Duration `toml:"pollPeriod"` // For v2 jobs + RequestedConfsDelay int64 `toml:"requestedConfsDelay"` // For v2 jobs. Optional, defaults to 0 if not provided. + RequestTimeout time.Duration `toml:"requestTimeout"` // Optional, defaults to 24hr if not provided. // GasLanePrice specifies the gas lane price for this VRF job. // If the specified keys in FromAddresses do not have the provided gas price the job @@ -563,15 +563,15 @@ type BlockhashStoreSpec struct { // CoordinatorV1Address is the VRF V1 coordinator to watch for unfulfilled requests. If empty, // no V1 coordinator will be watched. - CoordinatorV1Address *ethkey.EIP55Address `toml:"coordinatorV1Address"` + CoordinatorV1Address *evmtypes.EIP55Address `toml:"coordinatorV1Address"` // CoordinatorV2Address is the VRF V2 coordinator to watch for unfulfilled requests. If empty, // no V2 coordinator will be watched. - CoordinatorV2Address *ethkey.EIP55Address `toml:"coordinatorV2Address"` + CoordinatorV2Address *evmtypes.EIP55Address `toml:"coordinatorV2Address"` // CoordinatorV2PlusAddress is the VRF V2Plus coordinator to watch for unfulfilled requests. If empty, // no V2Plus coordinator will be watched. - CoordinatorV2PlusAddress *ethkey.EIP55Address `toml:"coordinatorV2PlusAddress"` + CoordinatorV2PlusAddress *evmtypes.EIP55Address `toml:"coordinatorV2PlusAddress"` // LookbackBlocks defines the maximum age of blocks whose hashes should be stored. LookbackBlocks int32 `toml:"lookbackBlocks"` @@ -587,10 +587,10 @@ type BlockhashStoreSpec struct { // BlockhashStoreAddress is the address of the BlockhashStore contract to store blockhashes // into. - BlockhashStoreAddress ethkey.EIP55Address `toml:"blockhashStoreAddress"` + BlockhashStoreAddress evmtypes.EIP55Address `toml:"blockhashStoreAddress"` // BatchBlockhashStoreAddress is the address of the trusted BlockhashStore contract to store blockhashes - TrustedBlockhashStoreAddress *ethkey.EIP55Address `toml:"trustedBlockhashStoreAddress"` + TrustedBlockhashStoreAddress *evmtypes.EIP55Address `toml:"trustedBlockhashStoreAddress"` // BatchBlockhashStoreBatchSize is the number of blockhashes to store in a single batch TrustedBlockhashStoreBatchSize int32 `toml:"trustedBlockhashStoreBatchSize"` @@ -605,7 +605,7 @@ type BlockhashStoreSpec struct { EVMChainID *big.Big `toml:"evmChainID"` // FromAddress is the sender address that should be used to store blockhashes. - FromAddresses []ethkey.EIP55Address `toml:"fromAddresses"` + FromAddresses []evmtypes.EIP55Address `toml:"fromAddresses"` // CreatedAt is the time this job was created. CreatedAt time.Time `toml:"-"` @@ -620,15 +620,15 @@ type BlockHeaderFeederSpec struct { // CoordinatorV1Address is the VRF V1 coordinator to watch for unfulfilled requests. If empty, // no V1 coordinator will be watched. - CoordinatorV1Address *ethkey.EIP55Address `toml:"coordinatorV1Address"` + CoordinatorV1Address *evmtypes.EIP55Address `toml:"coordinatorV1Address"` // CoordinatorV2Address is the VRF V2 coordinator to watch for unfulfilled requests. If empty, // no V2 coordinator will be watched. - CoordinatorV2Address *ethkey.EIP55Address `toml:"coordinatorV2Address"` + CoordinatorV2Address *evmtypes.EIP55Address `toml:"coordinatorV2Address"` // CoordinatorV2PlusAddress is the VRF V2Plus coordinator to watch for unfulfilled requests. If empty, // no V2Plus coordinator will be watched. - CoordinatorV2PlusAddress *ethkey.EIP55Address `toml:"coordinatorV2PlusAddress"` + CoordinatorV2PlusAddress *evmtypes.EIP55Address `toml:"coordinatorV2PlusAddress"` // LookbackBlocks defines the maximum age of blocks whose hashes should be stored. LookbackBlocks int32 `toml:"lookbackBlocks"` @@ -638,11 +638,11 @@ type BlockHeaderFeederSpec struct { // BlockhashStoreAddress is the address of the BlockhashStore contract to store blockhashes // into. - BlockhashStoreAddress ethkey.EIP55Address `toml:"blockhashStoreAddress"` + BlockhashStoreAddress evmtypes.EIP55Address `toml:"blockhashStoreAddress"` // BatchBlockhashStoreAddress is the address of the BatchBlockhashStore contract to store blockhashes // into. - BatchBlockhashStoreAddress ethkey.EIP55Address `toml:"batchBlockhashStoreAddress"` + BatchBlockhashStoreAddress evmtypes.EIP55Address `toml:"batchBlockhashStoreAddress"` // PollPeriod defines how often recent blocks should be scanned for blockhash storage. PollPeriod time.Duration `toml:"pollPeriod"` @@ -654,7 +654,7 @@ type BlockHeaderFeederSpec struct { EVMChainID *big.Big `toml:"evmChainID"` // FromAddress is the sender address that should be used to store blockhashes. - FromAddresses []ethkey.EIP55Address `toml:"fromAddresses"` + FromAddresses []evmtypes.EIP55Address `toml:"fromAddresses"` // GetBlockHashesBatchSize is the RPC call batch size for retrieving blockhashes GetBlockhashesBatchSize uint16 `toml:"getBlockhashesBatchSize"` @@ -675,7 +675,7 @@ type LegacyGasStationServerSpec struct { // ForwarderAddress is the address of EIP2771 forwarder that verifies signature // and forwards requests to target contracts - ForwarderAddress ethkey.EIP55Address `toml:"forwarderAddress"` + ForwarderAddress evmtypes.EIP55Address `toml:"forwarderAddress"` // EVMChainID defines the chain ID from which the meta-transaction request originates. EVMChainID *big.Big `toml:"evmChainID"` @@ -685,7 +685,7 @@ type LegacyGasStationServerSpec struct { CCIPChainSelector *big.Big `toml:"ccipChainSelector"` // FromAddress is the sender address that should be used to send meta-transactions - FromAddresses []ethkey.EIP55Address `toml:"fromAddresses"` + FromAddresses []evmtypes.EIP55Address `toml:"fromAddresses"` // CreatedAt is the time this job was created. CreatedAt time.Time `toml:"-"` @@ -700,10 +700,10 @@ type LegacyGasStationSidecarSpec struct { // ForwarderAddress is the address of EIP2771 forwarder that verifies signature // and forwards requests to target contracts - ForwarderAddress ethkey.EIP55Address `toml:"forwarderAddress"` + ForwarderAddress evmtypes.EIP55Address `toml:"forwarderAddress"` // OffRampAddress is the address of CCIP OffRamp for the given chainID - OffRampAddress ethkey.EIP55Address `toml:"offRampAddress"` + OffRampAddress evmtypes.EIP55Address `toml:"offRampAddress"` // LookbackBlocks defines the maximum number of blocks to search for on-chain events. LookbackBlocks int32 `toml:"lookbackBlocks"` @@ -785,13 +785,13 @@ type EALSpec struct { // ForwarderAddress is the address of EIP2771 forwarder that verifies signature // and forwards requests to target contracts - ForwarderAddress ethkey.EIP55Address `toml:"forwarderAddress"` + ForwarderAddress evmtypes.EIP55Address `toml:"forwarderAddress"` // EVMChainID defines the chain ID from which the meta-transaction request originates. EVMChainID *big.Big `toml:"evmChainID"` // FromAddress is the sender address that should be used to send meta-transactions - FromAddresses []ethkey.EIP55Address `toml:"fromAddresses"` + FromAddresses []evmtypes.EIP55Address `toml:"fromAddresses"` // LookbackBlocks defines the maximum age of blocks to lookback in status tracker LookbackBlocks int32 `toml:"lookbackBlocks"` diff --git a/core/services/job/orm.go b/core/services/job/orm.go index c608e2cc544..6c8533d1dee 100644 --- a/core/services/job/orm.go +++ b/core/services/job/orm.go @@ -22,12 +22,12 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" medianconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median/config" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" @@ -52,7 +52,7 @@ type ORM interface { FindJobTx(ctx context.Context, id int32) (Job, error) FindJob(ctx context.Context, id int32) (Job, error) FindJobByExternalJobID(uuid uuid.UUID, qopts ...pg.QOpt) (Job, error) - FindJobIDByAddress(address ethkey.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (int32, error) + FindJobIDByAddress(address evmtypes.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (int32, error) FindOCR2JobIDByAddress(contractID string, feedID *common.Hash, qopts ...pg.QOpt) (int32, error) FindJobIDsWithBridge(name string) ([]int32, error) DeleteJob(id int32, qopts ...pg.QOpt) error @@ -731,7 +731,7 @@ type OCRConfig interface { ContractSubscribeInterval() time.Duration KeyBundleID() (string, error) ObservationTimeout() time.Duration - TransmitterAddress() (ethkey.EIP55Address, error) + TransmitterAddress() (evmtypes.EIP55Address, error) } // LoadConfigVarsLocalOCR loads local OCR vars into the OCROracleSpec. @@ -842,7 +842,7 @@ func (o *orm) FindJobByExternalJobID(externalJobID uuid.UUID, qopts ...pg.QOpt) } // FindJobIDByAddress - finds a job id by contract address. Currently only OCR and FM jobs are supported -func (o *orm) FindJobIDByAddress(address ethkey.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (jobID int32, err error) { +func (o *orm) FindJobIDByAddress(address evmtypes.EIP55Address, evmChainID *big.Big, qopts ...pg.QOpt) (jobID int32, err error) { q := o.q.WithOpts(qopts...) err = q.Transaction(func(tx pg.Queryer) error { stmt := ` @@ -1321,7 +1321,7 @@ func toVRFSpecRow(spec *VRFSpec) vrfSpecRow { func (r vrfSpecRow) toVRFSpec() *VRFSpec { for _, a := range r.FromAddresses { r.VRFSpec.FromAddresses = append(r.VRFSpec.FromAddresses, - ethkey.EIP55AddressFromAddress(common.BytesToAddress(a))) + evmtypes.EIP55AddressFromAddress(common.BytesToAddress(a))) } return r.VRFSpec } @@ -1360,7 +1360,7 @@ func toBlockhashStoreSpecRow(spec *BlockhashStoreSpec) blockhashStoreSpecRow { func (r blockhashStoreSpecRow) toBlockhashStoreSpec() *BlockhashStoreSpec { for _, a := range r.FromAddresses { r.BlockhashStoreSpec.FromAddresses = append(r.BlockhashStoreSpec.FromAddresses, - ethkey.EIP55AddressFromAddress(common.BytesToAddress(a))) + evmtypes.EIP55AddressFromAddress(common.BytesToAddress(a))) } return r.BlockhashStoreSpec } @@ -1399,7 +1399,7 @@ func toBlockHeaderFeederSpecRow(spec *BlockHeaderFeederSpec) blockHeaderFeederSp func (r blockHeaderFeederSpecRow) toBlockHeaderFeederSpec() *BlockHeaderFeederSpec { for _, a := range r.FromAddresses { r.BlockHeaderFeederSpec.FromAddresses = append(r.BlockHeaderFeederSpec.FromAddresses, - ethkey.EIP55AddressFromAddress(common.BytesToAddress(a))) + evmtypes.EIP55AddressFromAddress(common.BytesToAddress(a))) } return r.BlockHeaderFeederSpec } @@ -1438,7 +1438,7 @@ func toLegacyGasStationServerSpecRow(spec *LegacyGasStationServerSpec) legacyGas func (r legacyGasStationServerSpecRow) toLegacyGasStationServerSpec() *LegacyGasStationServerSpec { for _, a := range r.FromAddresses { r.LegacyGasStationServerSpec.FromAddresses = append(r.LegacyGasStationServerSpec.FromAddresses, - ethkey.EIP55AddressFromAddress(common.BytesToAddress(a))) + evmtypes.EIP55AddressFromAddress(common.BytesToAddress(a))) } return r.LegacyGasStationServerSpec } diff --git a/core/services/job/runner_integration_test.go b/core/services/job/runner_integration_test.go index 2722e190e24..8c631984680 100644 --- a/core/services/job/runner_integration_test.go +++ b/core/services/job/runner_integration_test.go @@ -29,6 +29,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" @@ -38,7 +39,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" @@ -67,7 +67,7 @@ func TestRunner(t *testing.T) { require.NoError(t, err) kbid := models.MustSha256HashFromHex(kb.ID()) c.OCR.KeyBundleID = &kbid - taddress := ethkey.EIP55AddressFromAddress(transmitterAddress) + taddress := types.EIP55AddressFromAddress(transmitterAddress) c.OCR.TransmitterAddress = &taddress c.OCR2.DatabaseTimeout = commonconfig.MustNewDuration(time.Second) c.OCR2.ContractTransmitterTransmitTimeout = commonconfig.MustNewDuration(time.Second) diff --git a/core/services/keeper/integration_test.go b/core/services/keeper/integration_test.go index e92d2c2a58f..d78b1fb2ca5 100644 --- a/core/services/keeper/integration_test.go +++ b/core/services/keeper/integration_test.go @@ -20,6 +20,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/authorized_forwarder" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/basic_upkeep_contract" @@ -36,7 +37,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keeper" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" webpresenters "github.com/smartcontractkit/chainlink/v2/core/web/presenters" ) @@ -77,7 +77,7 @@ func deployKeeperRegistry( require.NoError(t, err) backend.Commit() - wrapper, err := keeper.NewRegistryWrapper(ethkey.EIP55AddressFromAddress(regAddr), backend) + wrapper, err := keeper.NewRegistryWrapper(evmtypes.EIP55AddressFromAddress(regAddr), backend) require.NoError(t, err) return regAddr, wrapper case keeper.RegistryVersion_1_2: @@ -104,7 +104,7 @@ func deployKeeperRegistry( ) require.NoError(t, err) backend.Commit() - wrapper, err := keeper.NewRegistryWrapper(ethkey.EIP55AddressFromAddress(regAddr), backend) + wrapper, err := keeper.NewRegistryWrapper(evmtypes.EIP55AddressFromAddress(regAddr), backend) require.NoError(t, err) return regAddr, wrapper case keeper.RegistryVersion_1_3: @@ -140,7 +140,7 @@ func deployKeeperRegistry( ) require.NoError(t, err) backend.Commit() - wrapper, err := keeper.NewRegistryWrapper(ethkey.EIP55AddressFromAddress(regAddr), backend) + wrapper, err := keeper.NewRegistryWrapper(evmtypes.EIP55AddressFromAddress(regAddr), backend) require.NoError(t, err) return regAddr, wrapper default: @@ -181,7 +181,7 @@ func TestKeeperEthIntegration(t *testing.T) { // setup node key nodeKey := cltest.MustGenerateRandomKey(t) nodeAddress := nodeKey.Address - nodeAddressEIP55 := ethkey.EIP55AddressFromAddress(nodeAddress) + nodeAddressEIP55 := evmtypes.EIP55AddressFromAddress(nodeAddress) // setup blockchain sergey := testutils.MustNewSimTransactor(t) // owns all the link @@ -254,7 +254,7 @@ func TestKeeperEthIntegration(t *testing.T) { require.NoError(t, app.Start(testutils.Context(t))) // create job - regAddrEIP55 := ethkey.EIP55AddressFromAddress(regAddr) + regAddrEIP55 := evmtypes.EIP55AddressFromAddress(regAddr) job := cltest.MustInsertKeeperJob(t, db, korm, nodeAddressEIP55, regAddrEIP55) err = app.JobSpawner().StartService(testutils.Context(t), job) require.NoError(t, err) @@ -333,7 +333,7 @@ func TestKeeperForwarderEthIntegration(t *testing.T) { // setup node key nodeKey := cltest.MustGenerateRandomKey(t) nodeAddress := nodeKey.Address - nodeAddressEIP55 := ethkey.EIP55AddressFromAddress(nodeAddress) + nodeAddressEIP55 := evmtypes.EIP55AddressFromAddress(nodeAddress) // setup blockchain sergey := testutils.MustNewSimTransactor(t) // owns all the link @@ -423,7 +423,7 @@ func TestKeeperForwarderEthIntegration(t *testing.T) { require.Equal(t, addr, fwdrAddress) // create job - regAddrEIP55 := ethkey.EIP55AddressFromAddress(regAddr) + regAddrEIP55 := evmtypes.EIP55AddressFromAddress(regAddr) jb := job.Job{ ID: 1, @@ -447,9 +447,9 @@ func TestKeeperForwarderEthIntegration(t *testing.T) { JobID: jb.ID, KeeperIndex: 0, NumKeepers: 2, - KeeperIndexMap: map[ethkey.EIP55Address]int32{ + KeeperIndexMap: map[evmtypes.EIP55Address]int32{ nodeAddressEIP55: 0, - ethkey.EIP55AddressFromAddress(nelly.From): 1, + evmtypes.EIP55AddressFromAddress(nelly.From): 1, }, } err = korm.UpsertRegistry(®istry) @@ -489,7 +489,7 @@ func TestMaxPerformDataSize(t *testing.T) { // setup node key nodeKey := cltest.MustGenerateRandomKey(t) nodeAddress := nodeKey.Address - nodeAddressEIP55 := ethkey.EIP55AddressFromAddress(nodeAddress) + nodeAddressEIP55 := evmtypes.EIP55AddressFromAddress(nodeAddress) // setup blockchain sergey := testutils.MustNewSimTransactor(t) // owns all the link @@ -558,7 +558,7 @@ func TestMaxPerformDataSize(t *testing.T) { require.NoError(t, app.Start(testutils.Context(t))) // create job - regAddrEIP55 := ethkey.EIP55AddressFromAddress(regAddr) + regAddrEIP55 := evmtypes.EIP55AddressFromAddress(regAddr) job := cltest.MustInsertKeeperJob(t, db, korm, nodeAddressEIP55, regAddrEIP55) err = app.JobSpawner().StartService(testutils.Context(t), job) require.NoError(t, err) diff --git a/core/services/keeper/models.go b/core/services/keeper/models.go index fe034bcc505..69bd0e6a577 100644 --- a/core/services/keeper/models.go +++ b/core/services/keeper/models.go @@ -8,20 +8,20 @@ import ( "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/null" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) -type KeeperIndexMap map[ethkey.EIP55Address]int32 +type KeeperIndexMap map[types.EIP55Address]int32 type Registry struct { ID int64 BlockCountPerTurn int32 CheckGas uint32 - ContractAddress ethkey.EIP55Address - FromAddress ethkey.EIP55Address + ContractAddress types.EIP55Address + FromAddress types.EIP55Address JobID int32 KeeperIndex int32 NumKeepers int32 diff --git a/core/services/keeper/orm.go b/core/services/keeper/orm.go index fc8770cd864..55dd6c52e68 100644 --- a/core/services/keeper/orm.go +++ b/core/services/keeper/orm.go @@ -7,9 +7,9 @@ import ( "github.com/lib/pq" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pg" ) @@ -40,7 +40,7 @@ func (korm ORM) Registries() ([]Registry, error) { } // RegistryByContractAddress returns a single registry based on provided address -func (korm ORM) RegistryByContractAddress(registryAddress ethkey.EIP55Address) (Registry, error) { +func (korm ORM) RegistryByContractAddress(registryAddress types.EIP55Address) (Registry, error) { var registry Registry err := korm.q.Get(®istry, `SELECT * FROM keeper_registries WHERE keeper_registries.contract_address = $1`, registryAddress) return registry, errors.Wrap(err, "failed to get registry") @@ -86,7 +86,7 @@ RETURNING * } // UpdateUpkeepLastKeeperIndex updates the last keeper index for an upkeep -func (korm ORM) UpdateUpkeepLastKeeperIndex(jobID int32, upkeepID *big.Big, fromAddress ethkey.EIP55Address) error { +func (korm ORM) UpdateUpkeepLastKeeperIndex(jobID int32, upkeepID *big.Big, fromAddress types.EIP55Address) error { _, err := korm.q.Exec(` UPDATE upkeep_registrations SET @@ -125,7 +125,7 @@ DELETE FROM upkeep_registrations WHERE registry_id IN ( // -- OR is it my buddy's turn AND they were the last keeper to do the perform for this upkeep // DEV: note we cast upkeep_id and binaryHash as 32 bits, even though both are 256 bit numbers when performing XOR. This is enough information // to distribute the upkeeps over the keepers so long as num keepers < 4294967296 -func (korm ORM) EligibleUpkeepsForRegistry(registryAddress ethkey.EIP55Address, blockNumber int64, gracePeriod int64, binaryHash string) (upkeeps []UpkeepRegistration, err error) { +func (korm ORM) EligibleUpkeepsForRegistry(registryAddress types.EIP55Address, blockNumber int64, gracePeriod int64, binaryHash string) (upkeeps []UpkeepRegistration, err error) { stmt := ` SELECT upkeep_registrations.* FROM upkeep_registrations @@ -212,7 +212,7 @@ WHERE registry_id = $1 } // SetLastRunInfoForUpkeepOnJob sets the last run block height and the associated keeper index only if the new block height is greater than the previous. -func (korm ORM) SetLastRunInfoForUpkeepOnJob(jobID int32, upkeepID *big.Big, height int64, fromAddress ethkey.EIP55Address, qopts ...pg.QOpt) (int64, error) { +func (korm ORM) SetLastRunInfoForUpkeepOnJob(jobID int32, upkeepID *big.Big, height int64, fromAddress types.EIP55Address, qopts ...pg.QOpt) (int64, error) { res, err := korm.q.WithOpts(qopts...).Exec(` UPDATE upkeep_registrations SET last_run_block_height = $1, diff --git a/core/services/keeper/orm_test.go b/core/services/keeper/orm_test.go index 2ce459886ae..ed58554ef0d 100644 --- a/core/services/keeper/orm_test.go +++ b/core/services/keeper/orm_test.go @@ -15,6 +15,7 @@ import ( "github.com/jmoiron/sqlx" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -23,7 +24,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keeper" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/utils" bigmath "github.com/smartcontractkit/chainlink/v2/core/utils/big_math" ) @@ -400,9 +400,9 @@ func TestKeeperDB_NewSetLastRunInfoForUpkeepOnJob(t *testing.T) { registry, j := cltest.MustInsertKeeperRegistry(t, db, orm, ethKeyStore, 0, 1, 20) upkeep := cltest.MustInsertUpkeepForRegistry(t, db, config.Database(), registry) registry.NumKeepers = 2 - registry.KeeperIndexMap = map[ethkey.EIP55Address]int32{ + registry.KeeperIndexMap = map[types.EIP55Address]int32{ registry.FromAddress: 0, - ethkey.EIP55AddressFromAddress(evmutils.ZeroAddress): 1, + types.EIP55AddressFromAddress(evmutils.ZeroAddress): 1, } err := orm.UpsertRegistry(®istry) require.NoError(t, err, "UPDATE keeper_registries") @@ -418,7 +418,7 @@ func TestKeeperDB_NewSetLastRunInfoForUpkeepOnJob(t *testing.T) { require.Equal(t, rowsAffected, int64(0)) assertLastRunHeight(t, db, upkeep, 100, 0) // update to same block height allowed - rowsAffected, err = orm.SetLastRunInfoForUpkeepOnJob(j.ID, upkeep.UpkeepID, 100, ethkey.EIP55AddressFromAddress(evmutils.ZeroAddress)) + rowsAffected, err = orm.SetLastRunInfoForUpkeepOnJob(j.ID, upkeep.UpkeepID, 100, types.EIP55AddressFromAddress(evmutils.ZeroAddress)) require.NoError(t, err) require.Equal(t, rowsAffected, int64(1)) assertLastRunHeight(t, db, upkeep, 100, 1) diff --git a/core/services/keeper/registry_interface.go b/core/services/keeper/registry_interface.go index fd1c2314a41..c80be29154a 100644 --- a/core/services/keeper/registry_interface.go +++ b/core/services/keeper/registry_interface.go @@ -17,7 +17,6 @@ import ( registry1_2 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" registry1_3 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" type_and_version "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/type_and_version_interface_wrapper" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) type RegistryVersion int32 @@ -53,7 +52,7 @@ type upkeepGetter interface { // RegistryWrapper implements a layer on top of different versions of registry wrappers // to provide a unified layer to rest of the codebase type RegistryWrapper struct { - Address ethkey.EIP55Address + Address evmtypes.EIP55Address Version RegistryVersion contract1_1 *registry1_1.KeeperRegistry contract1_2 *registry1_2.KeeperRegistry @@ -61,7 +60,7 @@ type RegistryWrapper struct { evmClient evmclient.Client } -func NewRegistryWrapper(address ethkey.EIP55Address, evmClient evmclient.Client) (*RegistryWrapper, error) { +func NewRegistryWrapper(address evmtypes.EIP55Address, evmClient evmclient.Client) (*RegistryWrapper, error) { interface_wrapper, err := type_and_version.NewTypeAndVersionInterface( address.Address(), evmClient, diff --git a/core/services/keeper/registry_synchronizer_process_logs.go b/core/services/keeper/registry_synchronizer_process_logs.go index 7b82f49ae4c..b0a3f6af5bd 100644 --- a/core/services/keeper/registry_synchronizer_process_logs.go +++ b/core/services/keeper/registry_synchronizer_process_logs.go @@ -7,11 +7,11 @@ import ( "github.com/pkg/errors" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" registry1_1 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" registry1_2 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" registry1_3 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func (rs *RegistrySynchronizer) processLogs() { @@ -144,7 +144,7 @@ func (rs *RegistrySynchronizer) handleUpkeepPerformed(broadcast log.Broadcast) e if err != nil { return errors.Wrap(err, "Unable to fetch upkeep ID from performed log") } - rowsAffected, err := rs.orm.SetLastRunInfoForUpkeepOnJob(rs.job.ID, big.New(log.UpkeepID), int64(broadcast.RawLog().BlockNumber), ethkey.EIP55AddressFromAddress(log.FromKeeper)) + rowsAffected, err := rs.orm.SetLastRunInfoForUpkeepOnJob(rs.job.ID, big.New(log.UpkeepID), int64(broadcast.RawLog().BlockNumber), types.EIP55AddressFromAddress(log.FromKeeper)) if err != nil { return errors.Wrap(err, "failed to set last run to 0") } @@ -152,7 +152,7 @@ func (rs *RegistrySynchronizer) handleUpkeepPerformed(broadcast log.Broadcast) e "jobID", rs.job.ID, "upkeepID", log.UpkeepID.String(), "blockNumber", int64(broadcast.RawLog().BlockNumber), - "fromAddr", ethkey.EIP55AddressFromAddress(log.FromKeeper), + "fromAddr", types.EIP55AddressFromAddress(log.FromKeeper), "rowsAffected", rowsAffected, ) return nil diff --git a/core/services/keeper/registry_synchronizer_sync.go b/core/services/keeper/registry_synchronizer_sync.go index 7614ed15edb..cdca9512976 100644 --- a/core/services/keeper/registry_synchronizer_sync.go +++ b/core/services/keeper/registry_synchronizer_sync.go @@ -7,9 +7,9 @@ import ( "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) func (rs *RegistrySynchronizer) fullSync() { @@ -130,7 +130,7 @@ func (rs *RegistrySynchronizer) syncUpkeep(getter upkeepGetter, registry Registr return errors.Wrap(err, "failed to upsert upkeep") } - if err := rs.orm.UpdateUpkeepLastKeeperIndex(rs.job.ID, upkeepID, ethkey.EIP55AddressFromAddress(upkeep.LastKeeper)); err != nil { + if err := rs.orm.UpdateUpkeepLastKeeperIndex(rs.job.ID, upkeepID, types.EIP55AddressFromAddress(upkeep.LastKeeper)); err != nil { return errors.Wrap(err, "failed to update upkeep last keeper index") } @@ -149,9 +149,9 @@ func (rs *RegistrySynchronizer) newRegistryFromChain() (Registry, error) { } keeperIndex := int32(-1) - keeperMap := map[ethkey.EIP55Address]int32{} + keeperMap := map[types.EIP55Address]int32{} for idx, address := range registryConfig.KeeperAddresses { - keeperMap[ethkey.EIP55AddressFromAddress(address)] = int32(idx) + keeperMap[types.EIP55AddressFromAddress(address)] = int32(idx) if address == fromAddress { keeperIndex = int32(idx) } @@ -174,7 +174,7 @@ func (rs *RegistrySynchronizer) newRegistryFromChain() (Registry, error) { // CalcPositioningConstant calculates a positioning constant. // The positioning constant is fixed because upkeepID and registryAddress are immutable -func CalcPositioningConstant(upkeepID *big.Big, registryAddress ethkey.EIP55Address) (int32, error) { +func CalcPositioningConstant(upkeepID *big.Big, registryAddress types.EIP55Address) (int32, error) { upkeepBytes := make([]byte, binary.MaxVarintLen64) binary.PutVarint(upkeepBytes, upkeepID.Mod(big.NewI(math.MaxInt64)).Int64()) bytesToHash := utils.ConcatBytes(upkeepBytes, registryAddress.Bytes()) diff --git a/core/services/keeper/registry_synchronizer_sync_test.go b/core/services/keeper/registry_synchronizer_sync_test.go index e6f42a83201..e4d8e44e20a 100644 --- a/core/services/keeper/registry_synchronizer_sync_test.go +++ b/core/services/keeper/registry_synchronizer_sync_test.go @@ -10,10 +10,10 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ) // GetUpkeepFailure implements the upkeepGetter interface with an induced error and nil @@ -32,7 +32,7 @@ func TestSyncUpkeepWithCallback_UpkeepNotFound(t *testing.T) { logger: log.(logger.SugaredLogger), } - addr := ethkey.EIP55Address(testutils.NewAddress().Hex()) + addr := types.EIP55Address(testutils.NewAddress().Hex()) registry := Registry{ ContractAddress: addr, } diff --git a/core/services/keeper/upkeep_executer_unit_test.go b/core/services/keeper/upkeep_executer_unit_test.go index 8589720ca5f..9b7a5609e94 100644 --- a/core/services/keeper/upkeep_executer_unit_test.go +++ b/core/services/keeper/upkeep_executer_unit_test.go @@ -7,10 +7,10 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" ) @@ -24,8 +24,8 @@ func (r *registry) PerformGasOverhead() uint32 { return r.pgo } func (r *registry) MaxPerformDataSize() uint32 { return r.mpds } func TestBuildJobSpec(t *testing.T) { - from := ethkey.EIP55Address(testutils.NewAddress().Hex()) - contract := ethkey.EIP55Address(testutils.NewAddress().Hex()) + from := types.EIP55Address(testutils.NewAddress().Hex()) + contract := types.EIP55Address(testutils.NewAddress().Hex()) chainID := "250" jb := job.Job{ ID: 10, diff --git a/core/services/keystore/keys/ethkey/export.go b/core/services/keystore/keys/ethkey/export.go index 451a7453433..dfa85dedc98 100644 --- a/core/services/keystore/keys/ethkey/export.go +++ b/core/services/keystore/keys/ethkey/export.go @@ -5,12 +5,13 @@ import ( "github.com/google/uuid" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/utils" ) type EncryptedEthKeyExport struct { KeyType string `json:"keyType"` - Address EIP55Address `json:"address"` + Address types.EIP55Address `json:"address"` Crypto keystore.CryptoJSON `json:"crypto"` } diff --git a/core/services/keystore/keys/ethkey/key.go b/core/services/keystore/keys/ethkey/key.go index 6335ed55adc..02f256b320d 100644 --- a/core/services/keystore/keys/ethkey/key.go +++ b/core/services/keystore/keys/ethkey/key.go @@ -4,6 +4,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) // NOTE: This model refers to the OLD key and is only used for migrations @@ -14,7 +15,7 @@ import ( // By default, a key is assumed to represent an ethereum account. type Key struct { ID int32 - Address EIP55Address + Address types.EIP55Address JSON sqlutil.JSON `json:"-"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` diff --git a/core/services/keystore/keys/ethkey/key_v2.go b/core/services/keystore/keys/ethkey/key_v2.go index 15dc15d3f02..88cc9185787 100644 --- a/core/services/keystore/keys/ethkey/key_v2.go +++ b/core/services/keystore/keys/ethkey/key_v2.go @@ -9,6 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) var curve = crypto.S256() @@ -22,7 +24,7 @@ func (raw Raw) Key() KeyV2 { privateKey.D = d privateKey.PublicKey.X, privateKey.PublicKey.Y = curve.ScalarBaseMult(d.Bytes()) address := crypto.PubkeyToAddress(privateKey.PublicKey) - eip55 := EIP55AddressFromAddress(address) + eip55 := types.EIP55AddressFromAddress(address) return KeyV2{ Address: address, EIP55Address: eip55, @@ -42,7 +44,7 @@ var _ fmt.GoStringer = &KeyV2{} type KeyV2 struct { Address common.Address - EIP55Address EIP55Address + EIP55Address types.EIP55Address privateKey *ecdsa.PrivateKey } @@ -56,7 +58,7 @@ func NewV2() (KeyV2, error) { func FromPrivateKey(privKey *ecdsa.PrivateKey) (key KeyV2) { address := crypto.PubkeyToAddress(privKey.PublicKey) - eip55 := EIP55AddressFromAddress(address) + eip55 := types.EIP55AddressFromAddress(address) return KeyV2{ Address: address, EIP55Address: eip55, diff --git a/core/services/keystore/keys/ethkey/key_v2_test.go b/core/services/keystore/keys/ethkey/key_v2_test.go index 82b1084eb97..79a470103ed 100644 --- a/core/services/keystore/keys/ethkey/key_v2_test.go +++ b/core/services/keystore/keys/ethkey/key_v2_test.go @@ -8,6 +8,8 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ) func TestEthKeyV2_ToKey(t *testing.T) { @@ -20,7 +22,7 @@ func TestEthKeyV2_ToKey(t *testing.T) { assert.Equal(t, k.privateKey, privateKeyECDSA) assert.Equal(t, k.privateKey.PublicKey.X, privateKeyECDSA.PublicKey.X) assert.Equal(t, k.privateKey.PublicKey.Y, privateKeyECDSA.PublicKey.Y) - assert.Equal(t, EIP55AddressFromAddress(crypto.PubkeyToAddress(privateKeyECDSA.PublicKey)).Hex(), k.ID()) + assert.Equal(t, types.EIP55AddressFromAddress(crypto.PubkeyToAddress(privateKeyECDSA.PublicKey)).Hex(), k.ID()) } func TestEthKeyV2_RawPrivateKey(t *testing.T) { diff --git a/core/services/keystore/keys/ethkey/models.go b/core/services/keystore/keys/ethkey/models.go index df4c474b7b9..43af2caffc5 100644 --- a/core/services/keystore/keys/ethkey/models.go +++ b/core/services/keystore/keys/ethkey/models.go @@ -3,12 +3,13 @@ package ethkey import ( "time" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" ) type State struct { ID int32 - Address EIP55Address + Address types.EIP55Address EVMChainID big.Big Disabled bool CreatedAt time.Time diff --git a/core/services/ocr/config_overrider.go b/core/services/ocr/config_overrider.go index ac87d0e3924..a58cb402695 100644 --- a/core/services/ocr/config_overrider.go +++ b/core/services/ocr/config_overrider.go @@ -14,8 +14,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -23,7 +23,7 @@ type ConfigOverriderImpl struct { services.StateMachine logger logger.Logger flags *ContractFlags - contractAddress ethkey.EIP55Address + contractAddress types.EIP55Address pollTicker utils.TickerBase lastStateChangeTimestamp time.Time @@ -49,7 +49,7 @@ type DeltaCConfig interface { func NewConfigOverriderImpl( logger logger.Logger, cfg DeltaCConfig, - contractAddress ethkey.EIP55Address, + contractAddress types.EIP55Address, flags *ContractFlags, pollTicker utils.TickerBase, ) (*ConfigOverriderImpl, error) { diff --git a/core/services/ocr/config_overrider_test.go b/core/services/ocr/config_overrider_test.go index e01102a62f8..1f782989e66 100644 --- a/core/services/ocr/config_overrider_test.go +++ b/core/services/ocr/config_overrider_test.go @@ -15,18 +15,18 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/mocks" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" "github.com/smartcontractkit/chainlink/v2/core/utils" ) type configOverriderUni struct { overrider *ocr.ConfigOverriderImpl - contractAddress ethkey.EIP55Address + contractAddress types.EIP55Address } type deltaCConfig struct{} @@ -164,10 +164,10 @@ func Test_OCRConfigOverrider(t *testing.T) { flagsContract := mocks.NewFlags(t) flags := &ocr.ContractFlags{FlagsInterface: flagsContract} - address1, err := ethkey.NewEIP55Address(common.BigToAddress(big.NewInt(10000)).Hex()) + address1, err := types.NewEIP55Address(common.BigToAddress(big.NewInt(10000)).Hex()) require.NoError(t, err) - address2, err := ethkey.NewEIP55Address(common.BigToAddress(big.NewInt(1234567890)).Hex()) + address2, err := types.NewEIP55Address(common.BigToAddress(big.NewInt(1234567890)).Hex()) require.NoError(t, err) overrider1a, err := ocr.NewConfigOverriderImpl(testLogger, deltaCConfig{}, address1, flags, nil) @@ -185,7 +185,7 @@ func Test_OCRConfigOverrider(t *testing.T) { }) } -func checkFlagsAddress(t *testing.T, contractAddress ethkey.EIP55Address) func(args mock.Arguments) { +func checkFlagsAddress(t *testing.T, contractAddress types.EIP55Address) func(args mock.Arguments) { return func(args mock.Arguments) { require.Equal(t, []common.Address{ evmutils.ZeroAddress, diff --git a/core/services/ocr/delegate.go b/core/services/ocr/delegate.go index 0411aea6923..bcdda397e20 100644 --- a/core/services/ocr/delegate.go +++ b/core/services/ocr/delegate.go @@ -21,12 +21,12 @@ import ( txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/offchain_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" @@ -323,7 +323,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, jb job.Job) (services [] return services, nil } -func (d *Delegate) maybeCreateConfigOverrider(logger logger.Logger, chain legacyevm.Chain, contractAddress ethkey.EIP55Address) (*ConfigOverriderImpl, error) { +func (d *Delegate) maybeCreateConfigOverrider(logger logger.Logger, chain legacyevm.Chain, contractAddress types.EIP55Address) (*ConfigOverriderImpl, error) { flagsContractAddress := chain.Config().EVM().FlagsContractAddress() if flagsContractAddress != "" { flags, err := NewFlags(flagsContractAddress, chain.Client()) diff --git a/core/services/ocr/validate.go b/core/services/ocr/validate.go index 0524ed24d0b..a0f2353eac1 100644 --- a/core/services/ocr/validate.go +++ b/core/services/ocr/validate.go @@ -12,9 +12,9 @@ import ( "github.com/smartcontractkit/chainlink/v2/common/config" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" ) @@ -29,7 +29,7 @@ type OCRValidationConfig interface { ContractSubscribeInterval() time.Duration KeyBundleID() (string, error) ObservationTimeout() time.Duration - TransmitterAddress() (ethkey.EIP55Address, error) + TransmitterAddress() (types.EIP55Address, error) } type insecureConfig interface { diff --git a/core/services/ocr2/database_test.go b/core/services/ocr2/database_test.go index b70ac629da1..486bf1fd708 100644 --- a/core/services/ocr2/database_test.go +++ b/core/services/ocr2/database_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" medianconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median/config" "github.com/stretchr/testify/assert" @@ -19,14 +20,13 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/testhelpers" ) const defaultPluginID = 0 -func MustInsertOCROracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress ethkey.EIP55Address) job.OCR2OracleSpec { +func MustInsertOCROracleSpec(t *testing.T, db *sqlx.DB, transmitterAddress types.EIP55Address) job.OCR2OracleSpec { t.Helper() spec := job.OCR2OracleSpec{} diff --git a/core/services/ocr2/plugins/functions/config/config.go b/core/services/ocr2/plugins/functions/config/config.go index e0e1ba3bfa0..2e18d6727f6 100644 --- a/core/services/ocr2/plugins/functions/config/config.go +++ b/core/services/ocr2/plugins/functions/config/config.go @@ -21,34 +21,36 @@ import ( // This config is part of the job spec and is loaded only once on node boot/job creation. type PluginConfig struct { - EnableRequestSignatureCheck bool `json:"enableRequestSignatureCheck"` - DONID string `json:"donID"` - ContractVersion uint32 `json:"contractVersion"` - MinRequestConfirmations uint32 `json:"minRequestConfirmations"` - MinResponseConfirmations uint32 `json:"minResponseConfirmations"` - MinIncomingConfirmations uint32 `json:"minIncomingConfirmations"` - PastBlocksToPoll uint32 `json:"pastBlocksToPoll"` - LogPollerCacheDurationSec uint32 `json:"logPollerCacheDurationSec"` // Duration to cache previously detected request or response logs such that they can be filtered when calling logpoller_wrapper.LatestEvents() - RequestTimeoutSec uint32 `json:"requestTimeoutSec"` - RequestTimeoutCheckFrequencySec uint32 `json:"requestTimeoutCheckFrequencySec"` - RequestTimeoutBatchLookupSize uint32 `json:"requestTimeoutBatchLookupSize"` - PruneMaxStoredRequests uint32 `json:"pruneMaxStoredRequests"` - PruneCheckFrequencySec uint32 `json:"pruneCheckFrequencySec"` - PruneBatchSize uint32 `json:"pruneBatchSize"` - ListenerEventHandlerTimeoutSec uint32 `json:"listenerEventHandlerTimeoutSec"` - ListenerEventsCheckFrequencyMillis uint32 `json:"listenerEventsCheckFrequencyMillis"` - ContractUpdateCheckFrequencySec uint32 `json:"contractUpdateCheckFrequencySec"` - MaxRequestSizeBytes uint32 `json:"maxRequestSizeBytes"` - MaxRequestSizesList []uint32 `json:"maxRequestSizesList"` - MaxSecretsSizesList []uint32 `json:"maxSecretsSizesList"` - MinimumSubscriptionBalance assets.Link `json:"minimumSubscriptionBalance"` - AllowedHeartbeatInitiators []string `json:"allowedHeartbeatInitiators"` - GatewayConnectorConfig *connector.ConnectorConfig `json:"gatewayConnectorConfig"` - OnchainAllowlist *allowlist.OnchainAllowlistConfig `json:"onchainAllowlist"` - OnchainSubscriptions *subscriptions.OnchainSubscriptionsConfig `json:"onchainSubscriptions"` - RateLimiter *common.RateLimiterConfig `json:"rateLimiter"` - S4Constraints *s4.Constraints `json:"s4Constraints"` - DecryptionQueueConfig *DecryptionQueueConfig `json:"decryptionQueueConfig"` + EnableRequestSignatureCheck bool `json:"enableRequestSignatureCheck"` + DONID string `json:"donID"` + ContractVersion uint32 `json:"contractVersion"` + MinRequestConfirmations uint32 `json:"minRequestConfirmations"` + MinResponseConfirmations uint32 `json:"minResponseConfirmations"` + MinIncomingConfirmations uint32 `json:"minIncomingConfirmations"` + PastBlocksToPoll uint32 `json:"pastBlocksToPoll"` + LogPollerCacheDurationSec uint32 `json:"logPollerCacheDurationSec"` // Duration to cache previously detected request or response logs such that they can be filtered when calling logpoller_wrapper.LatestEvents() + RequestTimeoutSec uint32 `json:"requestTimeoutSec"` + RequestTimeoutCheckFrequencySec uint32 `json:"requestTimeoutCheckFrequencySec"` + RequestTimeoutBatchLookupSize uint32 `json:"requestTimeoutBatchLookupSize"` + PruneMaxStoredRequests uint32 `json:"pruneMaxStoredRequests"` + PruneCheckFrequencySec uint32 `json:"pruneCheckFrequencySec"` + PruneBatchSize uint32 `json:"pruneBatchSize"` + ListenerEventHandlerTimeoutSec uint32 `json:"listenerEventHandlerTimeoutSec"` + ListenerEventsCheckFrequencyMillis uint32 `json:"listenerEventsCheckFrequencyMillis"` + ContractUpdateCheckFrequencySec uint32 `json:"contractUpdateCheckFrequencySec"` + MaxRequestSizeBytes uint32 `json:"maxRequestSizeBytes"` + MaxRequestSizesList []uint32 `json:"maxRequestSizesList"` + MaxSecretsSizesList []uint32 `json:"maxSecretsSizesList"` + MinimumSubscriptionBalance assets.Link `json:"minimumSubscriptionBalance"` + AllowedHeartbeatInitiators []string `json:"allowedHeartbeatInitiators"` + GatewayConnectorConfig *connector.ConnectorConfig `json:"gatewayConnectorConfig"` + OnchainAllowlist *allowlist.OnchainAllowlistConfig `json:"onchainAllowlist"` + OnchainSubscriptions *subscriptions.OnchainSubscriptionsConfig `json:"onchainSubscriptions"` + RateLimiter *common.RateLimiterConfig `json:"rateLimiter"` + S4Constraints *s4.Constraints `json:"s4Constraints"` + DecryptionQueueConfig *DecryptionQueueConfig `json:"decryptionQueueConfig"` + ExternalAdapterMaxRetries *uint32 `json:"externalAdapterMaxRetries"` + ExternalAdapterExponentialBackoffBaseSec *uint32 `json:"externalAdapterExponentialBackoffBaseSec"` } type DecryptionQueueConfig struct { diff --git a/core/services/ocr2/plugins/functions/plugin.go b/core/services/ocr2/plugins/functions/plugin.go index 5a7a152d950..92b15892885 100644 --- a/core/services/ocr2/plugins/functions/plugin.go +++ b/core/services/ocr2/plugins/functions/plugin.go @@ -57,6 +57,8 @@ const ( FunctionsS4Namespace string = "functions" MaxAdapterResponseBytes int64 = 1_000_000 DefaultOffchainTransmitterChannelSize uint32 = 1000 + DefaultMaxAdapterRetry int = 3 + DefaultExponentialBackoffBase = 5 * time.Second ) // Create all OCR2 plugin Oracles and all extra services needed to run a Functions job. @@ -106,7 +108,24 @@ func NewFunctionsServices(ctx context.Context, functionsOracleArgs, thresholdOra offchainTransmitter := functions.NewOffchainTransmitter(DefaultOffchainTransmitterChannelSize) listenerLogger := conf.Logger.Named("FunctionsListener") - bridgeAccessor := functions.NewBridgeAccessor(conf.BridgeORM, FunctionsBridgeName, MaxAdapterResponseBytes) + + var maxRetries int + if pluginConfig.ExternalAdapterMaxRetries != nil { + maxRetries = int(*pluginConfig.ExternalAdapterMaxRetries) + } else { + maxRetries = DefaultMaxAdapterRetry + } + conf.Logger.Debugf("external adapter maxRetries configured to: %d", maxRetries) + + var exponentialBackoffBase time.Duration + if pluginConfig.ExternalAdapterExponentialBackoffBaseSec != nil { + exponentialBackoffBase = time.Duration(*pluginConfig.ExternalAdapterExponentialBackoffBaseSec) * time.Second + } else { + exponentialBackoffBase = DefaultExponentialBackoffBase + } + conf.Logger.Debugf("external adapter exponentialBackoffBase configured to: %g sec", exponentialBackoffBase.Seconds()) + + bridgeAccessor := functions.NewBridgeAccessor(conf.BridgeORM, FunctionsBridgeName, MaxAdapterResponseBytes, maxRetries, exponentialBackoffBase) functionsListener := functions.NewFunctionsListener( conf.Job, conf.Chain.Client(), diff --git a/core/services/ocr2/plugins/ocr2keeper/util.go b/core/services/ocr2/plugins/ocr2keeper/util.go index 4fdddfe7f02..35bd62eeed8 100644 --- a/core/services/ocr2/plugins/ocr2keeper/util.go +++ b/core/services/ocr2/plugins/ocr2keeper/util.go @@ -18,10 +18,10 @@ import ( ocr2keepers20runner "github.com/smartcontractkit/chainlink-automation/pkg/v2/runner" ocr2keepers21 "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" evmregistry20 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v20" evmregistry21 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21" evmregistry21transmit "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/transmit" @@ -86,7 +86,7 @@ func EVMDependencies20( return nil, nil, nil, nil, err } - rAddr := ethkey.MustEIP55Address(spec.OCR2OracleSpec.ContractID).Address() + rAddr := evmtypes.MustEIP55Address(spec.OCR2OracleSpec.ContractID).Address() if registry, err = evmregistry20.NewEVMRegistryService(rAddr, chain, lggr); err != nil { return nil, nil, nil, nil, err } @@ -103,7 +103,7 @@ func EVMDependencies20( } func FilterNamesFromSpec20(spec *job.OCR2OracleSpec) (names []string, err error) { - addr, err := ethkey.NewEIP55Address(spec.ContractID) + addr, err := evmtypes.NewEIP55Address(spec.ContractID) if err != nil { return nil, err } @@ -117,7 +117,7 @@ func EVMDependencies21( } func FilterNamesFromSpec21(spec *job.OCR2OracleSpec) (names []string, err error) { - addr, err := ethkey.NewEIP55Address(spec.ContractID) + addr, err := evmtypes.NewEIP55Address(spec.ContractID) if err != nil { return nil, err } diff --git a/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator.go b/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator.go index e7dd3174413..4c4acc57ff8 100644 --- a/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator.go +++ b/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator.go @@ -37,7 +37,6 @@ import ( vrf_wrapper "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ocr2vrf/generated/vrf_coordinator" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" ocr2vrfconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2vrf/config" ) @@ -1142,16 +1141,16 @@ func filterName(beaconAddress, coordinatorAddress, dkgAddress common.Address) st func FilterNamesFromSpec(spec *job.OCR2OracleSpec) (names []string, err error) { var cfg ocr2vrfconfig.PluginConfig - var beaconAddress, coordinatorAddress, dkgAddress ethkey.EIP55Address + var beaconAddress, coordinatorAddress, dkgAddress evmtypes.EIP55Address if err = json.Unmarshal(spec.PluginConfig.Bytes(), &cfg); err != nil { err = errors.Wrap(err, "failed to unmarshal ocr2vrf plugin config") return nil, err } - if beaconAddress, err = ethkey.NewEIP55Address(spec.ContractID); err == nil { - if coordinatorAddress, err = ethkey.NewEIP55Address(cfg.VRFCoordinatorAddress); err == nil { - if dkgAddress, err = ethkey.NewEIP55Address(cfg.DKGContractAddress); err == nil { + if beaconAddress, err = evmtypes.NewEIP55Address(spec.ContractID); err == nil { + if coordinatorAddress, err = evmtypes.NewEIP55Address(cfg.VRFCoordinatorAddress); err == nil { + if dkgAddress, err = evmtypes.NewEIP55Address(cfg.DKGContractAddress); err == nil { return []string{filterName(beaconAddress.Address(), coordinatorAddress.Address(), dkgAddress.Address())}, nil } } diff --git a/core/services/ocrcommon/arbitrum_block_translator_test.go b/core/services/ocrcommon/arbitrum_block_translator_test.go index 1ad3a6c5950..fa6875fb798 100644 --- a/core/services/ocrcommon/arbitrum_block_translator_test.go +++ b/core/services/ocrcommon/arbitrum_block_translator_test.go @@ -1,6 +1,7 @@ package ocrcommon_test import ( + "database/sql" "math/big" mrand "math/rand" "testing" @@ -10,7 +11,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" "github.com/ethereum/go-ethereum/common" @@ -239,7 +239,7 @@ func generateDeterministicL2Blocks() (heads []evmtypes.Head) { for i := 0; i <= l2max; i++ { head := evmtypes.Head{ Number: int64(i), - L1BlockNumber: null.Int64From(l1BlockNumber), + L1BlockNumber: sql.NullInt64{Int64: l1BlockNumber, Valid: true}, Hash: utils.NewHash(), ParentHash: parentHash, } diff --git a/core/services/ocrcommon/telemetry_test.go b/core/services/ocrcommon/telemetry_test.go index caa8ccfcc01..e7a59622d97 100644 --- a/core/services/ocrcommon/telemetry_test.go +++ b/core/services/ocrcommon/telemetry_test.go @@ -19,11 +19,11 @@ import ( mercuryv1 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v1" mercuryv2 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v2" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" "github.com/smartcontractkit/chainlink/v2/core/services/synchronization" "github.com/smartcontractkit/chainlink/v2/core/services/synchronization/mocks" @@ -126,7 +126,7 @@ func TestGetContract(t *testing.T) { job: &j, lggr: nil, } - contractAddress := ethkey.EIP55Address(utils.RandomAddress().String()) + contractAddress := evmtypes.EIP55Address(utils.RandomAddress().String()) j.Type = job.Type(pipeline.OffchainReportingJobType) j.OCROracleSpec.ContractAddress = contractAddress @@ -208,7 +208,7 @@ func TestSendEATelemetry(t *testing.T) { jb := job.Job{ Type: job.Type(pipeline.OffchainReportingJobType), OCROracleSpec: &job.OCROracleSpec{ - ContractAddress: ethkey.EIP55AddressFromAddress(feedAddress), + ContractAddress: evmtypes.EIP55AddressFromAddress(feedAddress), CaptureEATelemetry: true, EVMChainID: (*ubig.Big)(big.NewInt(9)), }, diff --git a/core/services/p2p/types/mocks/peer_wrapper.go b/core/services/p2p/types/mocks/peer_wrapper.go new file mode 100644 index 00000000000..02347cf6b86 --- /dev/null +++ b/core/services/p2p/types/mocks/peer_wrapper.go @@ -0,0 +1,141 @@ +// Code generated by mockery v2.38.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + types "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types" + mock "github.com/stretchr/testify/mock" +) + +// PeerWrapper is an autogenerated mock type for the PeerWrapper type +type PeerWrapper struct { + mock.Mock +} + +// Close provides a mock function with given fields: +func (_m *PeerWrapper) Close() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Close") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetPeer provides a mock function with given fields: +func (_m *PeerWrapper) GetPeer() types.Peer { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetPeer") + } + + var r0 types.Peer + if rf, ok := ret.Get(0).(func() types.Peer); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(types.Peer) + } + } + + return r0 +} + +// HealthReport provides a mock function with given fields: +func (_m *PeerWrapper) HealthReport() map[string]error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HealthReport") + } + + var r0 map[string]error + if rf, ok := ret.Get(0).(func() map[string]error); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]error) + } + } + + return r0 +} + +// Name provides a mock function with given fields: +func (_m *PeerWrapper) Name() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Name") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Ready provides a mock function with given fields: +func (_m *PeerWrapper) Ready() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Ready") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Start provides a mock function with given fields: _a0 +func (_m *PeerWrapper) Start(_a0 context.Context) error { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Start") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewPeerWrapper creates a new instance of PeerWrapper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPeerWrapper(t interface { + mock.TestingT + Cleanup(func()) +}) *PeerWrapper { + mock := &PeerWrapper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/core/services/p2p/types/types.go b/core/services/p2p/types/types.go index 5c2e5fa39bb..0f395d75409 100644 --- a/core/services/p2p/types/types.go +++ b/core/services/p2p/types/types.go @@ -15,6 +15,12 @@ type Peer interface { Receive() <-chan Message } +//go:generate mockery --quiet --name PeerWrapper --output ./mocks/ --case=underscore +type PeerWrapper interface { + services.Service + GetPeer() Peer +} + type Message struct { Sender ragetypes.PeerID Payload []byte diff --git a/core/services/p2p/wrapper/wrapper.go b/core/services/p2p/wrapper/wrapper.go new file mode 100644 index 00000000000..138d1ef21fc --- /dev/null +++ b/core/services/p2p/wrapper/wrapper.go @@ -0,0 +1,120 @@ +package wrapper + +import ( + "context" + "fmt" + + "github.com/prometheus/client_golang/prometheus" + + "github.com/smartcontractkit/libocr/commontypes" + ragetypes "github.com/smartcontractkit/libocr/ragep2p/types" + + "github.com/smartcontractkit/chainlink/v2/core/config" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore" + "github.com/smartcontractkit/chainlink/v2/core/services/p2p" + "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types" +) + +type peerWrapper struct { + peer types.Peer + keystoreP2P keystore.P2P + p2pConfig config.P2P + lggr logger.Logger +} + +var _ types.PeerWrapper = &peerWrapper{} + +func NewExternalPeerWrapper(keystoreP2P keystore.P2P, p2pConfig config.P2P, lggr logger.Logger) *peerWrapper { + return &peerWrapper{ + keystoreP2P: keystoreP2P, + p2pConfig: p2pConfig, + lggr: lggr, + } +} + +func (e *peerWrapper) GetPeer() types.Peer { + return e.peer +} + +// convert to "external" P2P PeerConfig, which is independent of OCR +// this has to be done in Start() because keystore is not unlocked at construction time +func convertPeerConfig(keystoreP2P keystore.P2P, p2pConfig config.P2P) (p2p.PeerConfig, error) { + key, err := keystoreP2P.GetOrFirst(p2pConfig.PeerID()) + if err != nil { + return p2p.PeerConfig{}, err + } + + // TODO(KS-106): use real DB + discovererDB := p2p.NewInMemoryDiscovererDatabase() + bootstrappers, err := convertBootstrapperLocators(p2pConfig.V2().DefaultBootstrappers()) + if err != nil { + return p2p.PeerConfig{}, err + } + + peerConfig := p2p.PeerConfig{ + PrivateKey: key.PrivKey, + + ListenAddresses: p2pConfig.V2().ListenAddresses(), + AnnounceAddresses: p2pConfig.V2().AnnounceAddresses(), + Bootstrappers: bootstrappers, + + DeltaReconcile: p2pConfig.V2().DeltaReconcile().Duration(), + DeltaDial: p2pConfig.V2().DeltaDial().Duration(), + DiscovererDatabase: discovererDB, + + MetricsRegisterer: prometheus.DefaultRegisterer, + } + + return peerConfig, nil +} + +func convertBootstrapperLocators(bootstrappers []commontypes.BootstrapperLocator) ([]ragetypes.PeerInfo, error) { + infos := []ragetypes.PeerInfo{} + for _, b := range bootstrappers { + addrs := make([]ragetypes.Address, len(b.Addrs)) + for i, a := range b.Addrs { + addrs[i] = ragetypes.Address(a) + } + var rageID ragetypes.PeerID + err := rageID.UnmarshalText([]byte(b.PeerID)) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal v2 peer ID (%q) from BootstrapperLocator: %w", b.PeerID, err) + } + infos = append(infos, ragetypes.PeerInfo{ + ID: rageID, + Addrs: addrs, + }) + } + return infos, nil +} + +func (e *peerWrapper) Start(ctx context.Context) error { + cfg, err := convertPeerConfig(e.keystoreP2P, e.p2pConfig) + if err != nil { + return err + } + e.lggr.Info("Starting external P2P peer") + peer, err := p2p.NewPeer(cfg, e.lggr) + if err != nil { + return err + } + e.peer = peer + return e.peer.Start(ctx) +} + +func (e *peerWrapper) Close() error { + return e.peer.Close() +} + +func (e *peerWrapper) Ready() error { + return nil +} + +func (e *peerWrapper) HealthReport() map[string]error { + return nil +} + +func (e *peerWrapper) Name() string { + return "PeerWrapper" +} diff --git a/core/services/p2p/wrapper/wrapper_test.go b/core/services/p2p/wrapper/wrapper_test.go new file mode 100644 index 00000000000..dd91ecaee47 --- /dev/null +++ b/core/services/p2p/wrapper/wrapper_test.go @@ -0,0 +1,37 @@ +package wrapper_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/consul/sdk/freeport" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" + ksmocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" + "github.com/smartcontractkit/chainlink/v2/core/services/p2p/wrapper" +) + +func TestPeerWrapper_CleanStartClose(t *testing.T) { + lggr := logger.TestLogger(t) + port := freeport.GetOne(t) + cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { + enabled := true + c.Capabilities.Peering.V2.Enabled = &enabled + c.Capabilities.Peering.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", port)} + }) + keystoreP2P := ksmocks.NewP2P(t) + key, err := p2pkey.NewV2() + require.NoError(t, err) + keystoreP2P.On("GetOrFirst", mock.Anything).Return(key, nil) + + wrapper := wrapper.NewExternalPeerWrapper(keystoreP2P, cfg.Capabilities().Peering(), lggr) + require.NotNil(t, wrapper) + require.NoError(t, wrapper.Start(testutils.Context(t))) + require.NoError(t, wrapper.Close()) +} diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index 2819ae3f9e8..ddddb82aaed 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -25,10 +25,10 @@ import ( txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" txm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/llo" "github.com/smartcontractkit/chainlink/v2/core/services/llo/bm" lloconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/llo/config" @@ -374,8 +374,8 @@ func (r *Relayer) NewConfigProvider(args commontypes.RelayArgs) (configProvider } func FilterNamesFromRelayArgs(args commontypes.RelayArgs) (filterNames []string, err error) { - var addr ethkey.EIP55Address - if addr, err = ethkey.NewEIP55Address(args.ContractID); err != nil { + var addr evmtypes.EIP55Address + if addr, err = evmtypes.NewEIP55Address(args.ContractID); err != nil { return nil, err } var relayConfig types.RelayConfig diff --git a/core/services/relay/evm/ocr2keeper.go b/core/services/relay/evm/ocr2keeper.go index f6342df5280..8a62281c9e2 100644 --- a/core/services/relay/evm/ocr2keeper.go +++ b/core/services/relay/evm/ocr2keeper.go @@ -17,11 +17,11 @@ import ( commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" ac "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_v21_plus_common" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" evm "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/encoding" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider" @@ -105,7 +105,7 @@ func (r *ocr2keeperRelayer) NewOCR2KeeperProvider(rargs commontypes.RelayArgs, p services.configWatcher = cfgWatcher services.contractTransmitter = contractTransmitter - addr := ethkey.MustEIP55Address(rargs.ContractID).Address() + addr := evmtypes.MustEIP55Address(rargs.ContractID).Address() registryContract, err := ac.NewIAutomationV21PlusCommon(addr, client.Client()) if err != nil { diff --git a/core/services/vrf/v2/bhs_feeder_test.go b/core/services/vrf/v2/bhs_feeder_test.go index 0ce674f5168..b39fd0dec7f 100644 --- a/core/services/vrf/v2/bhs_feeder_test.go +++ b/core/services/vrf/v2/bhs_feeder_test.go @@ -10,11 +10,11 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" ) @@ -39,14 +39,14 @@ func TestStartHeartbeats(t *testing.T) { bhsKeyAddresses = append(bhsKeyAddresses, bhsKey.Address.String()) keys = append(keys, bhsKey) keySpecificOverrides = append(keySpecificOverrides, toml.KeySpecific{ - Key: ptr[ethkey.EIP55Address](bhsKey.EIP55Address), + Key: ptr[types.EIP55Address](bhsKey.EIP55Address), GasEstimator: toml.KeySpecificGasEstimator{PriceMax: gasLanePriceWei}, }) sendEth(t, ownerKey, uni.backend, bhsKey.Address, 10) } keySpecificOverrides = append(keySpecificOverrides, toml.KeySpecific{ // Gas lane. - Key: ptr[ethkey.EIP55Address](vrfKey.EIP55Address), + Key: ptr[types.EIP55Address](vrfKey.EIP55Address), GasEstimator: toml.KeySpecificGasEstimator{PriceMax: gasLanePriceWei}, }) diff --git a/core/services/vrf/v2/integration_helpers_test.go b/core/services/vrf/v2/integration_helpers_test.go index 71724b928c1..c67195d25aa 100644 --- a/core/services/vrf/v2/integration_helpers_test.go +++ b/core/services/vrf/v2/integration_helpers_test.go @@ -23,6 +23,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_consumer_v2_upgradeable_example" @@ -67,11 +68,11 @@ func testSingleConsumerHappyPath( config, db := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { simulatedOverrides(t, assets.GWei(10), toml.KeySpecific{ // Gas lane. - Key: ptr[ethkey.EIP55Address](key1.EIP55Address), + Key: ptr[types.EIP55Address](key1.EIP55Address), GasEstimator: toml.KeySpecificGasEstimator{PriceMax: gasLanePriceWei}, }, toml.KeySpecific{ // Gas lane. - Key: ptr[ethkey.EIP55Address](key2.EIP55Address), + Key: ptr[types.EIP55Address](key2.EIP55Address), GasEstimator: toml.KeySpecificGasEstimator{PriceMax: gasLanePriceWei}, })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) diff --git a/core/web/evm_chains_controller_test.go b/core/web/evm_chains_controller_test.go index ea3d5476cec..5d31374cfb7 100644 --- a/core/web/evm_chains_controller_test.go +++ b/core/web/evm_chains_controller_test.go @@ -12,12 +12,12 @@ import ( "github.com/stretchr/testify/require" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/web" "github.com/smartcontractkit/chainlink/v2/core/web/presenters" ) @@ -48,7 +48,7 @@ func Test_EVMChainsController_Show(t *testing.T) { }, RPCBlockQueryDelay: ptr[uint16](23), MinIncomingConfirmations: ptr[uint32](12), - LinkContractAddress: ptr(ethkey.EIP55AddressFromAddress(testutils.NewAddress())), + LinkContractAddress: ptr(types.EIP55AddressFromAddress(testutils.NewAddress())), }), }, wantStatusCode: http.StatusOK, diff --git a/core/web/jobs_controller_test.go b/core/web/jobs_controller_test.go index 0dc04ff34e8..1e83d60cb7e 100644 --- a/core/web/jobs_controller_test.go +++ b/core/web/jobs_controller_test.go @@ -28,13 +28,13 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/utils" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/directrequest" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/vrfkey" "github.com/smartcontractkit/chainlink/v2/core/services/pg" @@ -79,7 +79,7 @@ func TestJobsController_Create_ValidationFailure_OffchainReportingSpec(t *testin t.Run(tc.name, func(t *testing.T) { ta, client := setupJobsControllerTests(t) - var address ethkey.EIP55Address + var address types.EIP55Address if tc.taExists { key, _ := cltest.MustInsertRandomKey(t, ta.KeyStore.Eth()) address = key.EIP55Address @@ -191,7 +191,7 @@ func TestJobController_Create_HappyPath(t *testing.T) { assert.Equal(t, jb.OCROracleSpec.ContractConfigConfirmations, resource.OffChainReportingSpec.ContractConfigConfirmations) assert.NotNil(t, resource.PipelineSpec.DotDAGSource) // Sanity check to make sure it inserted correctly - require.Equal(t, ethkey.EIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C"), jb.OCROracleSpec.ContractAddress) + require.Equal(t, types.EIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C"), jb.OCROracleSpec.ContractAddress) }, }, { @@ -221,13 +221,13 @@ func TestJobController_Create_HappyPath(t *testing.T) { require.NoError(t, err) require.NotNil(t, jb.KeeperSpec) - require.Equal(t, ethkey.EIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba"), jb.KeeperSpec.ContractAddress) - require.Equal(t, ethkey.EIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e"), jb.KeeperSpec.FromAddress) + require.Equal(t, types.EIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba"), jb.KeeperSpec.ContractAddress) + require.Equal(t, types.EIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e"), jb.KeeperSpec.FromAddress) assert.Equal(t, nameAndExternalJobID, jb.Name.ValueOrZero()) // Sanity check to make sure it inserted correctly - require.Equal(t, ethkey.EIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba"), jb.KeeperSpec.ContractAddress) - require.Equal(t, ethkey.EIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e"), jb.KeeperSpec.FromAddress) + require.Equal(t, types.EIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba"), jb.KeeperSpec.ContractAddress) + require.Equal(t, types.EIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e"), jb.KeeperSpec.FromAddress) }, }, { @@ -286,7 +286,7 @@ func TestJobController_Create_HappyPath(t *testing.T) { assert.Equal(t, nameAndExternalJobID, jb.Name.ValueOrZero()) assert.NotNil(t, resource.PipelineSpec.DotDAGSource) // Sanity check to make sure it inserted correctly - require.Equal(t, ethkey.EIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C"), jb.DirectRequestSpec.ContractAddress) + require.Equal(t, types.EIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C"), jb.DirectRequestSpec.ContractAddress) require.Equal(t, jb.ExternalJobID.String(), nameAndExternalJobID) }, }, @@ -336,7 +336,7 @@ func TestJobController_Create_HappyPath(t *testing.T) { assert.Equal(t, nameAndExternalJobID, jb.Name.ValueOrZero()) assert.NotNil(t, jb.PipelineSpec.DotDagSource) - assert.Equal(t, ethkey.EIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42"), jb.FluxMonitorSpec.ContractAddress) + assert.Equal(t, types.EIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42"), jb.FluxMonitorSpec.ContractAddress) assert.Equal(t, time.Second, jb.FluxMonitorSpec.IdleTimerPeriod) assert.Equal(t, false, jb.FluxMonitorSpec.IdleTimerDisabled) assert.Equal(t, tomlutils.Float32(0.5), jb.FluxMonitorSpec.Threshold) diff --git a/core/web/presenters/eth_key_test.go b/core/web/presenters/eth_key_test.go index 46402141a4c..9ba7c432e6a 100644 --- a/core/web/presenters/eth_key_test.go +++ b/core/web/presenters/eth_key_test.go @@ -7,6 +7,7 @@ import ( commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" @@ -22,7 +23,7 @@ func TestETHKeyResource(t *testing.T) { addressStr = "0x2aCFF2ec69aa9945Ed84f4F281eCCF6911A3B0eD" address = common.HexToAddress(addressStr) ) - eip55address, err := ethkey.NewEIP55Address(addressStr) + eip55address, err := types.NewEIP55Address(addressStr) require.NoError(t, err) key := ethkey.KeyV2{ Address: address, diff --git a/core/web/presenters/job.go b/core/web/presenters/job.go index 7c8643015dd..ca4bec64bca 100644 --- a/core/web/presenters/job.go +++ b/core/web/presenters/job.go @@ -10,10 +10,10 @@ import ( commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" clnull "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1" @@ -43,7 +43,7 @@ const ( // DirectRequestSpec defines the spec details of a DirectRequest Job type DirectRequestSpec struct { - ContractAddress ethkey.EIP55Address `json:"contractAddress"` + ContractAddress types.EIP55Address `json:"contractAddress"` MinIncomingConfirmations clnull.Uint32 `json:"minIncomingConfirmations"` MinContractPayment *commonassets.Link `json:"minContractPaymentLinkJuels"` Requesters models.AddressCollection `json:"requesters"` @@ -72,20 +72,20 @@ func NewDirectRequestSpec(spec *job.DirectRequestSpec) *DirectRequestSpec { // FluxMonitorSpec defines the spec details of a FluxMonitor Job type FluxMonitorSpec struct { - ContractAddress ethkey.EIP55Address `json:"contractAddress"` - Threshold float32 `json:"threshold"` - AbsoluteThreshold float32 `json:"absoluteThreshold"` - PollTimerPeriod string `json:"pollTimerPeriod"` - PollTimerDisabled bool `json:"pollTimerDisabled"` - IdleTimerPeriod string `json:"idleTimerPeriod"` - IdleTimerDisabled bool `json:"idleTimerDisabled"` - DrumbeatEnabled bool `json:"drumbeatEnabled"` - DrumbeatSchedule *string `json:"drumbeatSchedule"` - DrumbeatRandomDelay *string `json:"drumbeatRandomDelay"` - MinPayment *commonassets.Link `json:"minPayment"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - EVMChainID *big.Big `json:"evmChainID"` + ContractAddress types.EIP55Address `json:"contractAddress"` + Threshold float32 `json:"threshold"` + AbsoluteThreshold float32 `json:"absoluteThreshold"` + PollTimerPeriod string `json:"pollTimerPeriod"` + PollTimerDisabled bool `json:"pollTimerDisabled"` + IdleTimerPeriod string `json:"idleTimerPeriod"` + IdleTimerDisabled bool `json:"idleTimerDisabled"` + DrumbeatEnabled bool `json:"drumbeatEnabled"` + DrumbeatSchedule *string `json:"drumbeatSchedule"` + DrumbeatRandomDelay *string `json:"drumbeatRandomDelay"` + MinPayment *commonassets.Link `json:"minPayment"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + EVMChainID *big.Big `json:"evmChainID"` } // NewFluxMonitorSpec initializes a new DirectFluxMonitorSpec from a @@ -120,23 +120,23 @@ func NewFluxMonitorSpec(spec *job.FluxMonitorSpec) *FluxMonitorSpec { // OffChainReportingSpec defines the spec details of a OffChainReporting Job type OffChainReportingSpec struct { - ContractAddress ethkey.EIP55Address `json:"contractAddress"` - P2PV2Bootstrappers pq.StringArray `json:"p2pv2Bootstrappers"` - IsBootstrapPeer bool `json:"isBootstrapPeer"` - EncryptedOCRKeyBundleID *models.Sha256Hash `json:"keyBundleID"` - TransmitterAddress *ethkey.EIP55Address `json:"transmitterAddress"` - ObservationTimeout models.Interval `json:"observationTimeout"` - BlockchainTimeout models.Interval `json:"blockchainTimeout"` - ContractConfigTrackerSubscribeInterval models.Interval `json:"contractConfigTrackerSubscribeInterval"` - ContractConfigTrackerPollInterval models.Interval `json:"contractConfigTrackerPollInterval"` - ContractConfigConfirmations uint16 `json:"contractConfigConfirmations"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - EVMChainID *big.Big `json:"evmChainID"` - DatabaseTimeout *models.Interval `json:"databaseTimeout"` - ObservationGracePeriod *models.Interval `json:"observationGracePeriod"` - ContractTransmitterTransmitTimeout *models.Interval `json:"contractTransmitterTransmitTimeout"` - CollectTelemetry bool `json:"collectTelemetry,omitempty"` + ContractAddress types.EIP55Address `json:"contractAddress"` + P2PV2Bootstrappers pq.StringArray `json:"p2pv2Bootstrappers"` + IsBootstrapPeer bool `json:"isBootstrapPeer"` + EncryptedOCRKeyBundleID *models.Sha256Hash `json:"keyBundleID"` + TransmitterAddress *types.EIP55Address `json:"transmitterAddress"` + ObservationTimeout models.Interval `json:"observationTimeout"` + BlockchainTimeout models.Interval `json:"blockchainTimeout"` + ContractConfigTrackerSubscribeInterval models.Interval `json:"contractConfigTrackerSubscribeInterval"` + ContractConfigTrackerPollInterval models.Interval `json:"contractConfigTrackerPollInterval"` + ContractConfigConfirmations uint16 `json:"contractConfigConfirmations"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + EVMChainID *big.Big `json:"evmChainID"` + DatabaseTimeout *models.Interval `json:"databaseTimeout"` + ObservationGracePeriod *models.Interval `json:"observationGracePeriod"` + ContractTransmitterTransmitTimeout *models.Interval `json:"contractTransmitterTransmitTimeout"` + CollectTelemetry bool `json:"collectTelemetry,omitempty"` } // NewOffChainReportingSpec initializes a new OffChainReportingSpec from a @@ -217,11 +217,11 @@ func NewPipelineSpec(spec *pipeline.Spec) PipelineSpec { // KeeperSpec defines the spec details of a Keeper Job type KeeperSpec struct { - ContractAddress ethkey.EIP55Address `json:"contractAddress"` - FromAddress ethkey.EIP55Address `json:"fromAddress"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - EVMChainID *big.Big `json:"evmChainID"` + ContractAddress types.EIP55Address `json:"contractAddress"` + FromAddress types.EIP55Address `json:"fromAddress"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + EVMChainID *big.Big `json:"evmChainID"` } // NewKeeperSpec generates a new KeeperSpec from a job.KeeperSpec @@ -266,13 +266,13 @@ func NewCronSpec(spec *job.CronSpec) *CronSpec { } type VRFSpec struct { - BatchCoordinatorAddress *ethkey.EIP55Address `json:"batchCoordinatorAddress"` + BatchCoordinatorAddress *types.EIP55Address `json:"batchCoordinatorAddress"` BatchFulfillmentEnabled bool `json:"batchFulfillmentEnabled"` CustomRevertsPipelineEnabled *bool `json:"customRevertsPipelineEnabled,omitempty"` BatchFulfillmentGasMultiplier float64 `json:"batchFulfillmentGasMultiplier"` - CoordinatorAddress ethkey.EIP55Address `json:"coordinatorAddress"` + CoordinatorAddress types.EIP55Address `json:"coordinatorAddress"` PublicKey secp256k1.PublicKey `json:"publicKey"` - FromAddresses []ethkey.EIP55Address `json:"fromAddresses"` + FromAddresses []types.EIP55Address `json:"fromAddresses"` PollPeriod commonconfig.Duration `json:"pollPeriod"` MinIncomingConfirmations uint32 `json:"confirmations"` CreatedAt time.Time `json:"createdAt"` @@ -284,7 +284,7 @@ type VRFSpec struct { BackoffMaxDelay commonconfig.Duration `json:"backoffMaxDelay"` GasLanePrice *assets.Wei `json:"gasLanePrice"` RequestedConfsDelay int64 `json:"requestedConfsDelay"` - VRFOwnerAddress *ethkey.EIP55Address `json:"vrfOwnerAddress,omitempty"` + VRFOwnerAddress *types.EIP55Address `json:"vrfOwnerAddress,omitempty"` } func NewVRFSpec(spec *job.VRFSpec) *VRFSpec { @@ -313,21 +313,21 @@ func NewVRFSpec(spec *job.VRFSpec) *VRFSpec { // BlockhashStoreSpec defines the job parameters for a blockhash store feeder job. type BlockhashStoreSpec struct { - CoordinatorV1Address *ethkey.EIP55Address `json:"coordinatorV1Address"` - CoordinatorV2Address *ethkey.EIP55Address `json:"coordinatorV2Address"` - CoordinatorV2PlusAddress *ethkey.EIP55Address `json:"coordinatorV2PlusAddress"` - WaitBlocks int32 `json:"waitBlocks"` - LookbackBlocks int32 `json:"lookbackBlocks"` - HeartbeatPeriod time.Duration `json:"heartbeatPeriod"` - BlockhashStoreAddress ethkey.EIP55Address `json:"blockhashStoreAddress"` - TrustedBlockhashStoreAddress *ethkey.EIP55Address `json:"trustedBlockhashStoreAddress"` - TrustedBlockhashStoreBatchSize int32 `json:"trustedBlockhashStoreBatchSize"` - PollPeriod time.Duration `json:"pollPeriod"` - RunTimeout time.Duration `json:"runTimeout"` - EVMChainID *big.Big `json:"evmChainID"` - FromAddresses []ethkey.EIP55Address `json:"fromAddresses"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + CoordinatorV1Address *types.EIP55Address `json:"coordinatorV1Address"` + CoordinatorV2Address *types.EIP55Address `json:"coordinatorV2Address"` + CoordinatorV2PlusAddress *types.EIP55Address `json:"coordinatorV2PlusAddress"` + WaitBlocks int32 `json:"waitBlocks"` + LookbackBlocks int32 `json:"lookbackBlocks"` + HeartbeatPeriod time.Duration `json:"heartbeatPeriod"` + BlockhashStoreAddress types.EIP55Address `json:"blockhashStoreAddress"` + TrustedBlockhashStoreAddress *types.EIP55Address `json:"trustedBlockhashStoreAddress"` + TrustedBlockhashStoreBatchSize int32 `json:"trustedBlockhashStoreBatchSize"` + PollPeriod time.Duration `json:"pollPeriod"` + RunTimeout time.Duration `json:"runTimeout"` + EVMChainID *big.Big `json:"evmChainID"` + FromAddresses []types.EIP55Address `json:"fromAddresses"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } // NewBlockhashStoreSpec creates a new BlockhashStoreSpec for the given parameters. @@ -351,19 +351,19 @@ func NewBlockhashStoreSpec(spec *job.BlockhashStoreSpec) *BlockhashStoreSpec { // BlockHeaderFeederSpec defines the job parameters for a blcok header feeder job. type BlockHeaderFeederSpec struct { - CoordinatorV1Address *ethkey.EIP55Address `json:"coordinatorV1Address"` - CoordinatorV2Address *ethkey.EIP55Address `json:"coordinatorV2Address"` - CoordinatorV2PlusAddress *ethkey.EIP55Address `json:"coordinatorV2PlusAddress"` - WaitBlocks int32 `json:"waitBlocks"` - LookbackBlocks int32 `json:"lookbackBlocks"` - BlockhashStoreAddress ethkey.EIP55Address `json:"blockhashStoreAddress"` - BatchBlockhashStoreAddress ethkey.EIP55Address `json:"batchBlockhashStoreAddress"` - PollPeriod time.Duration `json:"pollPeriod"` - RunTimeout time.Duration `json:"runTimeout"` - EVMChainID *big.Big `json:"evmChainID"` - FromAddresses []ethkey.EIP55Address `json:"fromAddresses"` - GetBlockhashesBatchSize uint16 `json:"getBlockhashesBatchSize"` - StoreBlockhashesBatchSize uint16 `json:"storeBlockhashesBatchSize"` + CoordinatorV1Address *types.EIP55Address `json:"coordinatorV1Address"` + CoordinatorV2Address *types.EIP55Address `json:"coordinatorV2Address"` + CoordinatorV2PlusAddress *types.EIP55Address `json:"coordinatorV2PlusAddress"` + WaitBlocks int32 `json:"waitBlocks"` + LookbackBlocks int32 `json:"lookbackBlocks"` + BlockhashStoreAddress types.EIP55Address `json:"blockhashStoreAddress"` + BatchBlockhashStoreAddress types.EIP55Address `json:"batchBlockhashStoreAddress"` + PollPeriod time.Duration `json:"pollPeriod"` + RunTimeout time.Duration `json:"runTimeout"` + EVMChainID *big.Big `json:"evmChainID"` + FromAddresses []types.EIP55Address `json:"fromAddresses"` + GetBlockhashesBatchSize uint16 `json:"getBlockhashesBatchSize"` + StoreBlockhashesBatchSize uint16 `json:"storeBlockhashesBatchSize"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` diff --git a/core/web/presenters/job_test.go b/core/web/presenters/job_test.go index b782452948b..963e5790110 100644 --- a/core/web/presenters/job_test.go +++ b/core/web/presenters/job_test.go @@ -15,10 +15,10 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/assets" evmassets "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" clnull "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" "github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -28,34 +28,34 @@ import ( func TestJob(t *testing.T) { // Used in multiple tests timestamp := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC) - contractAddress, err := ethkey.NewEIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba") + contractAddress, err := types.NewEIP55Address("0x9E40733cC9df84636505f4e6Db28DCa0dC5D1bba") require.NoError(t, err) cronSchedule := "0 0 0 1 1 *" evmChainID := big.NewI(42) - fromAddress, err := ethkey.NewEIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e") + fromAddress, err := types.NewEIP55Address("0xa8037A20989AFcBC51798de9762b351D63ff462e") require.NoError(t, err) // Used in OCR tests var ocrKeyBundleID = "f5bf259689b26f1374efb3c9a9868796953a0f814bb2d39b968d0e61b58620a5" ocrKeyID := models.MustSha256HashFromHex(ocrKeyBundleID) - transmitterAddress, err := ethkey.NewEIP55Address("0x27548a32b9aD5D64c5945EaE9Da5337bc3169D15") + transmitterAddress, err := types.NewEIP55Address("0x27548a32b9aD5D64c5945EaE9Da5337bc3169D15") require.NoError(t, err) // Used in blockhashstore test - v1CoordAddress, err := ethkey.NewEIP55Address("0x16988483b46e695f6c8D58e6e1461DC703e008e1") + v1CoordAddress, err := types.NewEIP55Address("0x16988483b46e695f6c8D58e6e1461DC703e008e1") require.NoError(t, err) - v2CoordAddress, err := ethkey.NewEIP55Address("0x2C409DD6D4eBDdA190B5174Cc19616DD13884262") + v2CoordAddress, err := types.NewEIP55Address("0x2C409DD6D4eBDdA190B5174Cc19616DD13884262") require.NoError(t, err) - v2PlusCoordAddress, err := ethkey.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") + v2PlusCoordAddress, err := types.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") require.NoError(t, err) // Used in blockheaderfeeder test - batchBHSAddress, err := ethkey.NewEIP55Address("0xF6bB415b033D19EFf24A872a4785c6e1C4426103") + batchBHSAddress, err := types.NewEIP55Address("0xF6bB415b033D19EFf24A872a4785c6e1C4426103") require.NoError(t, err) - trustedBlockhashStoreAddress, err := ethkey.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") + trustedBlockhashStoreAddress, err := types.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") require.NoError(t, err) trustedBlockhashStoreBatchSize := int32(20) @@ -489,7 +489,7 @@ func TestJob(t *testing.T) { CreatedAt: timestamp, UpdatedAt: timestamp, EVMChainID: evmChainID, - FromAddresses: []ethkey.EIP55Address{fromAddress}, + FromAddresses: []types.EIP55Address{fromAddress}, PublicKey: vrfPubKey, RequestedConfsDelay: 10, ChunkSize: 25, @@ -572,7 +572,7 @@ func TestJob(t *testing.T) { PollPeriod: 25 * time.Second, RunTimeout: 10 * time.Second, EVMChainID: big.NewI(4), - FromAddresses: []ethkey.EIP55Address{fromAddress}, + FromAddresses: []types.EIP55Address{fromAddress}, TrustedBlockhashStoreAddress: &trustedBlockhashStoreAddress, TrustedBlockhashStoreBatchSize: trustedBlockhashStoreBatchSize, }, @@ -652,7 +652,7 @@ func TestJob(t *testing.T) { PollPeriod: 25 * time.Second, RunTimeout: 10 * time.Second, EVMChainID: big.NewI(4), - FromAddresses: []ethkey.EIP55Address{fromAddress}, + FromAddresses: []types.EIP55Address{fromAddress}, GetBlockhashesBatchSize: 5, StoreBlockhashesBatchSize: 10, }, diff --git a/core/web/resolver/eth_key.go b/core/web/resolver/eth_key.go index a9c060ef0c1..d986374ec21 100644 --- a/core/web/resolver/eth_key.go +++ b/core/web/resolver/eth_key.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/graph-gophers/graphql-go" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/web/loader" @@ -13,7 +14,7 @@ import ( type ETHKey struct { state ethkey.State - addr ethkey.EIP55Address + addr types.EIP55Address chain legacyevm.Chain } diff --git a/core/web/resolver/eth_key_test.go b/core/web/resolver/eth_key_test.go index 7d1e3ff5025..40a60263f06 100644 --- a/core/web/resolver/eth_key_test.go +++ b/core/web/resolver/eth_key_test.go @@ -16,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" @@ -60,11 +61,11 @@ func TestResolver_ETHKeys(t *testing.T) { keys := []ethkey.KeyV2{ { Address: address, - EIP55Address: ethkey.EIP55AddressFromAddress(address), + EIP55Address: evmtypes.EIP55AddressFromAddress(address), }, { Address: secondAddress, - EIP55Address: ethkey.EIP55AddressFromAddress(secondAddress), + EIP55Address: evmtypes.EIP55AddressFromAddress(secondAddress), }, } gError := errors.New("error") @@ -82,7 +83,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.MustEIP55Address(address.Hex()), + Address: evmtypes.MustEIP55Address(address.Hex()), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), @@ -149,7 +150,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.MustEIP55Address(address.Hex()), + Address: evmtypes.MustEIP55Address(address.Hex()), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), @@ -243,7 +244,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.MustEIP55Address(address.Hex()), + Address: evmtypes.MustEIP55Address(address.Hex()), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), @@ -275,7 +276,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.MustEIP55Address(address.Hex()), + Address: evmtypes.MustEIP55Address(address.Hex()), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), @@ -306,7 +307,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.MustEIP55Address(address.Hex()), + Address: evmtypes.MustEIP55Address(address.Hex()), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), @@ -368,7 +369,7 @@ func TestResolver_ETHKeys(t *testing.T) { before: func(f *gqlTestFramework) { states := []ethkey.State{ { - Address: ethkey.EIP55AddressFromAddress(address), + Address: evmtypes.EIP55AddressFromAddress(address), EVMChainID: *big.NewI(12), Disabled: false, CreatedAt: f.Timestamp(), diff --git a/core/web/resolver/spec_test.go b/core/web/resolver/spec_test.go index 828e8538071..2fa8281e3c7 100644 --- a/core/web/resolver/spec_test.go +++ b/core/web/resolver/spec_test.go @@ -13,10 +13,10 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" clnull "github.com/smartcontractkit/chainlink/v2/core/null" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -81,7 +81,7 @@ func TestResolver_DirectRequestSpec(t *testing.T) { id = int32(1) requesterAddress = common.HexToAddress("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") ) - contractAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + contractAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) testCases := []GQLTestCase{ @@ -146,7 +146,7 @@ func TestResolver_FluxMonitorSpec(t *testing.T) { var ( id = int32(1) ) - contractAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + contractAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) testCases := []GQLTestCase{ @@ -296,7 +296,7 @@ func TestResolver_KeeperSpec(t *testing.T) { id = int32(1) fromAddress = common.HexToAddress("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") ) - contractAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + contractAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) testCases := []GQLTestCase{ @@ -311,7 +311,7 @@ func TestResolver_KeeperSpec(t *testing.T) { ContractAddress: contractAddress, CreatedAt: f.Timestamp(), EVMChainID: ubig.NewI(42), - FromAddress: ethkey.EIP55AddressFromAddress(fromAddress), + FromAddress: evmtypes.EIP55AddressFromAddress(fromAddress), }, }, nil) }, @@ -355,10 +355,10 @@ func TestResolver_OCRSpec(t *testing.T) { var ( id = int32(1) ) - contractAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + contractAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) - transmitterAddress, err := ethkey.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") + transmitterAddress, err := evmtypes.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") require.NoError(t, err) keyBundleID := models.MustSha256HashFromHex("f5bf259689b26f1374efb3c9a9868796953a0f814bb2d39b968d0e61b58620a5") @@ -452,10 +452,10 @@ func TestResolver_OCR2Spec(t *testing.T) { var ( id = int32(1) ) - contractAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + contractAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) - transmitterAddress, err := ethkey.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") + transmitterAddress, err := evmtypes.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") require.NoError(t, err) keyBundleID := models.MustSha256HashFromHex("f5bf259689b26f1374efb3c9a9868796953a0f814bb2d39b968d0e61b58620a5") @@ -555,16 +555,16 @@ func TestResolver_VRFSpec(t *testing.T) { var ( id = int32(1) ) - coordinatorAddress, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + coordinatorAddress, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) - batchCoordinatorAddress, err := ethkey.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") + batchCoordinatorAddress, err := evmtypes.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") require.NoError(t, err) - fromAddress1, err := ethkey.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") + fromAddress1, err := evmtypes.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") require.NoError(t, err) - fromAddress2, err := ethkey.NewEIP55Address("0x2301958F1BFbC9A068C2aC9c6166Bf483b95864C") + fromAddress2, err := evmtypes.NewEIP55Address("0x2301958F1BFbC9A068C2aC9c6166Bf483b95864C") require.NoError(t, err) pubKey, err := secp256k1.NewPublicKeyFromHex("0x9dc09a0f898f3b5e8047204e7ce7e44b587920932f08431e29c9bf6923b8450a01") @@ -586,7 +586,7 @@ func TestResolver_VRFSpec(t *testing.T) { CoordinatorAddress: coordinatorAddress, CreatedAt: f.Timestamp(), EVMChainID: ubig.NewI(42), - FromAddresses: []ethkey.EIP55Address{fromAddress1, fromAddress2}, + FromAddresses: []evmtypes.EIP55Address{fromAddress1, fromAddress2}, PollPeriod: 1 * time.Minute, PublicKey: pubKey, RequestedConfsDelay: 10, @@ -713,25 +713,25 @@ func TestResolver_BlockhashStoreSpec(t *testing.T) { var ( id = int32(1) ) - coordinatorV1Address, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + coordinatorV1Address, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) - coordinatorV2Address, err := ethkey.NewEIP55Address("0x2fcA960AF066cAc46085588a66dA2D614c7Cd337") + coordinatorV2Address, err := evmtypes.NewEIP55Address("0x2fcA960AF066cAc46085588a66dA2D614c7Cd337") require.NoError(t, err) - coordinatorV2PlusAddress, err := ethkey.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") + coordinatorV2PlusAddress, err := evmtypes.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") require.NoError(t, err) - fromAddress1, err := ethkey.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") + fromAddress1, err := evmtypes.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") require.NoError(t, err) - fromAddress2, err := ethkey.NewEIP55Address("0xD479d7c994D298cA05bF270136ED9627b7E684D3") + fromAddress2, err := evmtypes.NewEIP55Address("0xD479d7c994D298cA05bF270136ED9627b7E684D3") require.NoError(t, err) - blockhashStoreAddress, err := ethkey.NewEIP55Address("0xb26A6829D454336818477B946f03Fb21c9706f3A") + blockhashStoreAddress, err := evmtypes.NewEIP55Address("0xb26A6829D454336818477B946f03Fb21c9706f3A") require.NoError(t, err) - trustedBlockhashStoreAddress, err := ethkey.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") + trustedBlockhashStoreAddress, err := evmtypes.NewEIP55Address("0x0ad9FE7a58216242a8475ca92F222b0640E26B63") require.NoError(t, err) trustedBlockhashStoreBatchSize := int32(20) @@ -749,7 +749,7 @@ func TestResolver_BlockhashStoreSpec(t *testing.T) { CoordinatorV2PlusAddress: &coordinatorV2PlusAddress, CreatedAt: f.Timestamp(), EVMChainID: ubig.NewI(42), - FromAddresses: []ethkey.EIP55Address{fromAddress1, fromAddress2}, + FromAddresses: []evmtypes.EIP55Address{fromAddress1, fromAddress2}, PollPeriod: 1 * time.Minute, RunTimeout: 37 * time.Second, WaitBlocks: 100, @@ -821,22 +821,22 @@ func TestResolver_BlockHeaderFeederSpec(t *testing.T) { var ( id = int32(1) ) - coordinatorV1Address, err := ethkey.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") + coordinatorV1Address, err := evmtypes.NewEIP55Address("0x613a38AC1659769640aaE063C651F48E0250454C") require.NoError(t, err) - coordinatorV2Address, err := ethkey.NewEIP55Address("0x2fcA960AF066cAc46085588a66dA2D614c7Cd337") + coordinatorV2Address, err := evmtypes.NewEIP55Address("0x2fcA960AF066cAc46085588a66dA2D614c7Cd337") require.NoError(t, err) - coordinatorV2PlusAddress, err := ethkey.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") + coordinatorV2PlusAddress, err := evmtypes.NewEIP55Address("0x92B5e28Ac583812874e4271380c7d070C5FB6E6b") require.NoError(t, err) - fromAddress, err := ethkey.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") + fromAddress, err := evmtypes.NewEIP55Address("0x3cCad4715152693fE3BC4460591e3D3Fbd071b42") require.NoError(t, err) - blockhashStoreAddress, err := ethkey.NewEIP55Address("0xb26A6829D454336818477B946f03Fb21c9706f3A") + blockhashStoreAddress, err := evmtypes.NewEIP55Address("0xb26A6829D454336818477B946f03Fb21c9706f3A") require.NoError(t, err) - batchBHSAddress, err := ethkey.NewEIP55Address("0xd23BAE30019853Caf1D08b4C03291b10AD7743Df") + batchBHSAddress, err := evmtypes.NewEIP55Address("0xd23BAE30019853Caf1D08b4C03291b10AD7743Df") require.NoError(t, err) testCases := []GQLTestCase{ @@ -853,7 +853,7 @@ func TestResolver_BlockHeaderFeederSpec(t *testing.T) { CoordinatorV2PlusAddress: &coordinatorV2PlusAddress, CreatedAt: f.Timestamp(), EVMChainID: ubig.NewI(42), - FromAddresses: []ethkey.EIP55Address{fromAddress}, + FromAddresses: []evmtypes.EIP55Address{fromAddress}, PollPeriod: 1 * time.Minute, RunTimeout: 37 * time.Second, WaitBlocks: 100, diff --git a/core/web/resolver/testdata/config-empty-effective.toml b/core/web/resolver/testdata/config-empty-effective.toml index 148f6b24ff5..8fdb2858cdb 100644 --- a/core/web/resolver/testdata/config-empty-effective.toml +++ b/core/web/resolver/testdata/config-empty-effective.toml @@ -228,3 +228,18 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' + +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] diff --git a/core/web/resolver/testdata/config-full.toml b/core/web/resolver/testdata/config-full.toml index cdfb85a6f5c..a497428c06a 100644 --- a/core/web/resolver/testdata/config-full.toml +++ b/core/web/resolver/testdata/config-full.toml @@ -239,6 +239,21 @@ LatestReportDeadline = '1m42s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 13 +OutgoingMessageBufferSize = 17 +PeerID = '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw' +TraceLogging = true + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = ['a', 'b', 'c'] +DefaultBootstrappers = ['12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw@foo:42/bar:10', '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw@test:99'] +DeltaDial = '1m0s' +DeltaReconcile = '2s' +ListenAddresses = ['foo', 'bar'] + [[EVM]] ChainID = '1' Enabled = false diff --git a/core/web/resolver/testdata/config-multi-chain-effective.toml b/core/web/resolver/testdata/config-multi-chain-effective.toml index 9f69d4aa909..45d52432ee5 100644 --- a/core/web/resolver/testdata/config-multi-chain-effective.toml +++ b/core/web/resolver/testdata/config-multi-chain-effective.toml @@ -229,6 +229,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 025995f115b..732ed762be3 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -1188,6 +1188,105 @@ ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example ListenAddresses is the addresses the peer will listen to on the network in `host:port` form as accepted by `net.Listen()`, but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended. +## Capabilities.Peering +```toml +[Capabilities.Peering] +IncomingMessageBufferSize = 10 # Default +OutgoingMessageBufferSize = 10 # Default +PeerID = '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw' # Example +TraceLogging = false # Default +``` + + +### IncomingMessageBufferSize +```toml +IncomingMessageBufferSize = 10 # Default +``` +IncomingMessageBufferSize is the per-remote number of incoming +messages to buffer. Any additional messages received on top of those +already in the queue will be dropped. + +### OutgoingMessageBufferSize +```toml +OutgoingMessageBufferSize = 10 # Default +``` +OutgoingMessageBufferSize is the per-remote number of outgoing +messages to buffer. Any additional messages send on top of those +already in the queue will displace the oldest. +NOTE: OutgoingMessageBufferSize should be comfortably smaller than remote's +IncomingMessageBufferSize to give the remote enough space to process +them all in case we regained connection and now send a bunch at once + +### PeerID +```toml +PeerID = '12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw' # Example +``` +PeerID is the default peer ID to use for OCR jobs. If unspecified, uses the first available peer ID. + +### TraceLogging +```toml +TraceLogging = false # Default +``` +TraceLogging enables trace level logging. + +## Capabilities.Peering.V2 +```toml +[Capabilities.Peering.V2] +Enabled = false # Default +AnnounceAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +DefaultBootstrappers = ['12D3KooWMHMRLQkgPbFSYHwD3NBuwtS1AmxhvKVUrcfyaGDASR4U@1.2.3.4:9999', '12D3KooWM55u5Swtpw9r8aFLQHEtw7HR4t44GdNs654ej5gRs2Dh@example.com:1234'] # Example +DeltaDial = '15s' # Default +DeltaReconcile = '1m' # Default +ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +``` + + +### Enabled +```toml +Enabled = false # Default +``` +Enabled enables P2P V2. + +### AnnounceAddresses +```toml +AnnounceAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +``` +AnnounceAddresses is the addresses the peer will advertise on the network in `host:port` form as accepted by the TCP version of Go’s `net.Dial`. +The addresses should be reachable by other nodes on the network. When attempting to connect to another node, +a node will attempt to dial all of the other node’s AnnounceAddresses in round-robin fashion. + +### DefaultBootstrappers +```toml +DefaultBootstrappers = ['12D3KooWMHMRLQkgPbFSYHwD3NBuwtS1AmxhvKVUrcfyaGDASR4U@1.2.3.4:9999', '12D3KooWM55u5Swtpw9r8aFLQHEtw7HR4t44GdNs654ej5gRs2Dh@example.com:1234'] # Example +``` +DefaultBootstrappers is the default bootstrapper peers for libocr's v2 networking stack. + +Oracle nodes typically only know each other’s PeerIDs, but not their hostnames, IP addresses, or ports. +DefaultBootstrappers are special nodes that help other nodes discover each other’s `AnnounceAddresses` so they can communicate. +Nodes continuously attempt to connect to bootstrappers configured in here. When a node wants to connect to another node +(which it knows only by PeerID, but not by address), it discovers the other node’s AnnounceAddresses from communications +received from its DefaultBootstrappers or other discovered nodes. To facilitate discovery, +nodes will regularly broadcast signed announcements containing their PeerID and AnnounceAddresses. + +### DeltaDial +```toml +DeltaDial = '15s' # Default +``` +DeltaDial controls how far apart Dial attempts are + +### DeltaReconcile +```toml +DeltaReconcile = '1m' # Default +``` +DeltaReconcile controls how often a Reconcile message is sent to every peer. + +### ListenAddresses +```toml +ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example +``` +ListenAddresses is the addresses the peer will listen to on the network in `host:port` form as accepted by `net.Listen()`, +but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended. + ## Keeper ```toml [Keeper] diff --git a/go.mod b/go.mod index 979f6b03a4e..77d2b20c09e 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/hashicorp/consul/sdk v0.14.1 github.com/hashicorp/go-envparse v0.1.0 github.com/hashicorp/go-plugin v1.6.0 + github.com/hashicorp/go-retryablehttp v0.7.5 github.com/hdevalence/ed25519consensus v0.1.0 github.com/jackc/pgconn v1.14.1 github.com/jackc/pgtype v1.14.0 @@ -220,6 +221,7 @@ require ( github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect diff --git a/go.sum b/go.sum index 5784268d323..b64249e2094 100644 --- a/go.sum +++ b/go.sum @@ -692,6 +692,7 @@ github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdm github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -700,6 +701,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 5e4d46f2cf2..098434c09f9 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -257,6 +257,7 @@ require ( github.com/hashicorp/go-msgpack v0.5.5 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 34da71eadec..47d7ec120cd 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -913,6 +913,7 @@ github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdm github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -926,8 +927,8 @@ github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= -github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 5667c8a8ce9..3b90ec5bb15 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -239,6 +239,7 @@ require ( github.com/hashicorp/go-msgpack v0.5.5 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index dcfce6ff4fb..6ef7a2bb3ec 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -904,6 +904,7 @@ github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdm github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -917,8 +918,8 @@ github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= -github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= diff --git a/integration-tests/types/config/node/core.go b/integration-tests/types/config/node/core.go index 024a05f63e4..23efdf13a8b 100644 --- a/integration-tests/types/config/node/core.go +++ b/integration-tests/types/config/node/core.go @@ -18,10 +18,10 @@ import ( it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -214,7 +214,7 @@ func WithVRFv2EVMEstimator(addresses []string, maxGasPriceGWei int64) NodeConfig var keySpecicifArr []evmcfg.KeySpecific for _, addr := range addresses { keySpecicifArr = append(keySpecicifArr, evmcfg.KeySpecific{ - Key: ptr.Ptr(ethkey.EIP55Address(addr)), + Key: ptr.Ptr(types.EIP55Address(addr)), GasEstimator: evmcfg.KeySpecificGasEstimator{ PriceMax: est, }, diff --git a/testdata/scripts/node/validate/default.txtar b/testdata/scripts/node/validate/default.txtar index 8a3c99ee8da..dcf9c4dc154 100644 --- a/testdata/scripts/node/validate/default.txtar +++ b/testdata/scripts/node/validate/default.txtar @@ -241,6 +241,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + Invalid configuration: invalid secrets: 2 errors: - Database.URL: empty: must be provided and non-empty - Password.Keystore: empty: must be provided and non-empty diff --git a/testdata/scripts/node/validate/disk-based-logging-disabled.txtar b/testdata/scripts/node/validate/disk-based-logging-disabled.txtar index 873b9e91bc1..1f3ccefe51e 100644 --- a/testdata/scripts/node/validate/disk-based-logging-disabled.txtar +++ b/testdata/scripts/node/validate/disk-based-logging-disabled.txtar @@ -285,6 +285,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar b/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar index 0c00fbb7adc..1b72a05a311 100644 --- a/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar +++ b/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar @@ -285,6 +285,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/testdata/scripts/node/validate/disk-based-logging.txtar b/testdata/scripts/node/validate/disk-based-logging.txtar index 0bbddd6f40f..0110db3f373 100644 --- a/testdata/scripts/node/validate/disk-based-logging.txtar +++ b/testdata/scripts/node/validate/disk-based-logging.txtar @@ -285,6 +285,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/testdata/scripts/node/validate/invalid-ocr-p2p.txtar b/testdata/scripts/node/validate/invalid-ocr-p2p.txtar index 7f109b654d9..438d94be93b 100644 --- a/testdata/scripts/node/validate/invalid-ocr-p2p.txtar +++ b/testdata/scripts/node/validate/invalid-ocr-p2p.txtar @@ -270,7 +270,22 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + Invalid configuration: invalid configuration: P2P.V2.Enabled: invalid value (false): P2P required for OCR or OCR2. Please enable P2P or disable OCR/OCR2. -- err.txt -- -invalid configuration \ No newline at end of file +invalid configuration diff --git a/testdata/scripts/node/validate/invalid.txtar b/testdata/scripts/node/validate/invalid.txtar index 011298fcde7..3c6b514de90 100644 --- a/testdata/scripts/node/validate/invalid.txtar +++ b/testdata/scripts/node/validate/invalid.txtar @@ -275,6 +275,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/testdata/scripts/node/validate/valid.txtar b/testdata/scripts/node/validate/valid.txtar index e0bd015a184..07bf48bb084 100644 --- a/testdata/scripts/node/validate/valid.txtar +++ b/testdata/scripts/node/validate/valid.txtar @@ -282,6 +282,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + [[EVM]] ChainID = '1' AutoCreateKey = true diff --git a/testdata/scripts/node/validate/warnings.txtar b/testdata/scripts/node/validate/warnings.txtar index 01968ffd65d..bd84ced5f82 100644 --- a/testdata/scripts/node/validate/warnings.txtar +++ b/testdata/scripts/node/validate/warnings.txtar @@ -264,6 +264,21 @@ LatestReportDeadline = '5s' [Mercury.TLS] CertFile = '' +[Capabilities] +[Capabilities.Peering] +IncomingMessageBufferSize = 10 +OutgoingMessageBufferSize = 10 +PeerID = '' +TraceLogging = false + +[Capabilities.Peering.V2] +Enabled = false +AnnounceAddresses = [] +DefaultBootstrappers = [] +DeltaDial = '15s' +DeltaReconcile = '1m0s' +ListenAddresses = [] + # Configuration warning: Tracing.TLSCertPath: invalid value (something): must be empty when Tracing.Mode is 'unencrypted' Valid configuration.