Skip to content

Commit

Permalink
Merge branch 'develop' into tt_951_multiple_evm_versions_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Mar 15, 2024
2 parents 8932867 + 346354b commit 4684272
Show file tree
Hide file tree
Showing 129 changed files with 1,758 additions and 509 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-rats-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

External peering core service
24 changes: 21 additions & 3 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
80 changes: 80 additions & 0 deletions core/capabilities/syncer.go
Original file line number Diff line number Diff line change
@@ -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 = &registrySyncer{}

// RegistrySyncer updates local Registry to match its onchain counterpart
func NewRegistrySyncer(peerWrapper p2ptypes.PeerWrapper, registry types.CapabilitiesRegistry, lggr logger.Logger) *registrySyncer {
return &registrySyncer{
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"
}
28 changes: 28 additions & 0 deletions core/capabilities/syncer_test.go
Original file line number Diff line number Diff line change
@@ -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())
}
9 changes: 4 additions & 5 deletions core/capabilities/targets/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ 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"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest"
"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)
Expand All @@ -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
})
Expand Down
6 changes: 3 additions & 3 deletions core/chains/evm/config/chain_scoped_chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
},
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
20 changes: 20 additions & 0 deletions core/chains/evm/config/mocks/chain_scoped_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4684272

Please sign in to comment.