Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into kodey/bump-chain-selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
KodeyThomas authored Jul 10, 2024
2 parents bb85eae + 09c25c0 commit 7d8f00c
Show file tree
Hide file tree
Showing 39 changed files with 975 additions and 918 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ flake.lock @smartcontractkit/prodsec-public
# CCIP override
/core/ @smartcontractkit/ccip
/contracts/ @smartcontractkit/ccip-onchain @makramkd @elatoskinas @RayXpub
go.mod @smartcontractkit/ccip @smartcontractkit/prodsec-public @smartcontractkit/releng @smartcontractkit/foundations
go.sum @smartcontractkit/ccip @smartcontractkit/prodsec-public @smartcontractkit/releng @smartcontractkit/foundations
integration-tests/go.mod @smartcontractkit/ccip @smartcontractkit/prodsec-public
integration-tests/go.sum @smartcontractkit/ccip @smartcontractkit/prodsec-public

# leave snapshots & changeset as ownerless
/contracts/gas-snapshots/
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ccip-client-compatibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ jobs:
echo "Will test all EVM implementations"
echo "evm_implementations=geth,besu,nethermind,erigon" >> $GITHUB_OUTPUT
fi
- name: Select Chainlink version
- name: Select Chainlink CCIP version
id: select-chainlink-version
run: |
PATH=$PATH:$(go env GOPATH)/bin
export PATH
if [ "$GITHUB_EVENT_NAME" = "schedule" ]; then
echo "Fetching latest Chainlink stable version"
echo "Fetching latest Chainlink CCIP stable version"
implementations_arr=()
# we use 100 days since we really want the latest one, and it's highly improbable there won't be a release in last 100 days
chainlink_version=$(ghlatestreleasechecker "smartcontractkit/chainlink" 100)
chainlink_version=$(ghlatestreleasechecker "smartcontractkit/ccip" 100)
echo "chainlink_version=$chainlink_version" >> $GITHUB_OUTPUT
elif [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
echo "Fetching Chainlink version from input"
Expand Down
139 changes: 69 additions & 70 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre

/// @dev Struct to hold the configs for a destination chain
struct DestChainConfig {
DestChainDynamicConfig dynamicConfig; // ──╮ Dynamic configs for a destination chain
address prevOnRamp; // ────────────────────╯ Address of previous-version OnRamp
DestChainDynamicConfig dynamicConfig; // Dynamic configs for a destination chain
uint64 sequenceNumber; // The last used sequence number. This is zero in the case where no messages has been sent yet.
// 0 is not a valid sequence number for any real transaction.
/// @dev metadataHash is a lane-specific prefix for a message hash preimage which ensures global uniqueness
Expand All @@ -157,14 +156,12 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
bytes32 metadataHash;
}

/// @dev Struct to hold the dynamic configs, its destination chain selector and previous onRamp.
/// Same as DestChainConfig but with the destChainSelector and the prevOnRamp so that an array of these
/// @dev Struct to hold the dynamic configs, its destination chain selector. Same as DestChainConfig but with the destChainSelector so that an array of these
/// can be passed in the constructor and the applyDestChainConfigUpdates function
//solhint-disable gas-struct-packing
struct DestChainConfigArgs {
uint64 destChainSelector; // Destination chain selector
DestChainDynamicConfig dynamicConfig; // Struct to hold the configs for a destination chain
address prevOnRamp; // Address of previous-version OnRamp.
}

// STATIC CONFIG
Expand Down Expand Up @@ -761,11 +758,9 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
}

DestChainConfig storage destChainConfig = s_destChainConfig[destChainSelector];
address prevOnRamp = destChainConfigArg.prevOnRamp;

DestChainConfig memory newDestChainConfig = DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: prevOnRamp,
sequenceNumber: destChainConfig.sequenceNumber,
metadataHash: destChainConfig.metadataHash
});
Expand All @@ -776,11 +771,9 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
newDestChainConfig.metadataHash =
keccak256(abi.encode(Internal.EVM_2_ANY_MESSAGE_HASH, i_chainSelector, destChainSelector, address(this)));
destChainConfig.metadataHash = newDestChainConfig.metadataHash;
if (prevOnRamp != address(0)) destChainConfig.prevOnRamp = prevOnRamp;

emit DestChainAdded(destChainSelector, destChainConfig);
} else {
if (destChainConfig.prevOnRamp != prevOnRamp) revert InvalidDestChainConfig(destChainSelector);
if (destChainConfigArg.dynamicConfig.defaultTokenDestBytesOverhead < Pool.CCIP_LOCK_OR_BURN_V1_RET_BYTES) {
revert InvalidDestBytesOverhead(address(0), destChainConfigArg.dynamicConfig.defaultTokenDestBytesOverhead);
}
Expand Down
1 change: 0 additions & 1 deletion contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ contract NonceManager_OnRampUpgrade is EVM2EVMMultiOnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
destChainConfigArgs[0].prevOnRamp = address(s_prevOnRamp);

(s_onRamp, s_metadataHash) = _deployOnRamp(
SOURCE_CHAIN_SELECTOR, address(s_sourceRouter), address(s_outboundNonceManager), address(s_tokenAdminRegistry)
Expand Down
20 changes: 20 additions & 0 deletions contracts/src/v0.8/ccip/test/helpers/MessageHasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Internal} from "../../libraries/Internal.sol";

/// @notice MessageHasher is a contract that utility functions to hash an Any2EVMRampMessage
/// and encode various preimages for the final hash of the message.
/// @dev This is only deployed in tests and is not part of the production contracts.
contract MessageHasher {
function hash(Internal.Any2EVMRampMessage memory message, bytes memory onRamp) public pure returns (bytes32) {
return Internal._hash(message, onRamp);
Expand Down Expand Up @@ -48,4 +49,23 @@ contract MessageHasher {
) public pure returns (bytes memory) {
return abi.encode(leafDomainSeparator, implicitMetadataHash, fixedSizeFieldsHash, dataHash, tokenAmountsHash);
}

function encodeEVMExtraArgsV1(Client.EVMExtraArgsV1 memory extraArgs) public pure returns (bytes memory) {
return Client._argsToBytes(extraArgs);
}

function encodeEVMExtraArgsV2(Client.EVMExtraArgsV2 memory extraArgs) public pure returns (bytes memory) {
return Client._argsToBytes(extraArgs);
}

function decodeEVMExtraArgsV1(uint256 gasLimit) public pure returns (Client.EVMExtraArgsV1 memory) {
return Client.EVMExtraArgsV1(gasLimit);
}

function decodeEVMExtraArgsV2(
uint256 gasLimit,
bool allowOutOfOrderExecution
) public pure returns (Client.EVMExtraArgsV2 memory) {
return Client.EVMExtraArgsV2(gasLimit, allowOutOfOrderExecution);
}
}
28 changes: 3 additions & 25 deletions contracts/src/v0.8/ccip/test/onRamp/EVM2EVMMultiOnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ contract EVM2EVMMultiOnRamp_constructor is EVM2EVMMultiOnRampSetup {
DEST_CHAIN_SELECTOR,
EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: ""
})
Expand All @@ -61,7 +60,6 @@ contract EVM2EVMMultiOnRamp_constructor is EVM2EVMMultiOnRampSetup {

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -197,18 +195,13 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet
);
destChainConfigArgs.dynamicConfig.chainFamilySelector = Internal.CHAIN_FAMILY_SELECTOR_EVM;

bool isNewChain = true;
bool isNewChain = destChainConfigArgs.destChainSelector != DEST_CHAIN_SELECTOR;

if (destChainConfigArgs.destChainSelector == DEST_CHAIN_SELECTOR) {
destChainConfigArgs.prevOnRamp = address(0);
isNewChain = false;
}
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory newDestChainConfigArgs =
new EVM2EVMMultiOnRamp.DestChainConfigArgs[](1);
newDestChainConfigArgs[0] = destChainConfigArgs;
EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs.dynamicConfig,
prevOnRamp: destChainConfigArgs.prevOnRamp,
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -244,7 +237,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig0 = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs[0].dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand All @@ -258,7 +250,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig1 = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs[1].dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -320,17 +311,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
}

function test_InvalidDestChainConfigNewPrevOnRampOnExistingChain_Revert() public {
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
EVM2EVMMultiOnRamp.DestChainConfigArgs memory destChainConfigArg = destChainConfigArgs[0];

destChainConfigArg.prevOnRamp = address(1);
vm.expectRevert(
abi.encodeWithSelector(EVM2EVMMultiOnRamp.InvalidDestChainConfig.selector, destChainConfigArg.destChainSelector)
);
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
}

function test_InvalidDestBytesOverhead_Revert() public {
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
EVM2EVMMultiOnRamp.DestChainConfigArgs memory destChainConfigArg = destChainConfigArgs[0];
Expand Down Expand Up @@ -1100,8 +1080,7 @@ contract EVM2EVMMultiOnRamp_getDataAvailabilityCost is EVM2EVMMultiOnRamp_getFee
EVM2EVMMultiOnRamp.DestChainConfig memory destChainConfig = s_onRamp.getDestChainConfig(destChainSelector);
destChainConfigArgs[0] = EVM2EVMMultiOnRamp.DestChainConfigArgs({
destChainSelector: destChainSelector,
dynamicConfig: destChainConfig.dynamicConfig,
prevOnRamp: destChainConfig.prevOnRamp
dynamicConfig: destChainConfig.dynamicConfig
});
destChainConfigArgs[0].dynamicConfig.destDataAvailabilityOverheadGas = destDataAvailabilityOverheadGas;
destChainConfigArgs[0].dynamicConfig.destGasPerDataAvailabilityByte = destGasPerDataAvailabilityByte;
Expand Down Expand Up @@ -1173,8 +1152,7 @@ contract EVM2EVMMultiOnRamp_getFee is EVM2EVMMultiOnRamp_getFeeSetup {
EVM2EVMMultiOnRamp.DestChainConfig memory destChainConfig = s_onRamp.getDestChainConfig(DEST_CHAIN_SELECTOR);
destChainConfigArgs[0] = EVM2EVMMultiOnRamp.DestChainConfigArgs({
destChainSelector: DEST_CHAIN_SELECTOR,
dynamicConfig: destChainConfig.dynamicConfig,
prevOnRamp: destChainConfig.prevOnRamp
dynamicConfig: destChainConfig.dynamicConfig
});
destChainConfigArgs[0].dynamicConfig.destDataAvailabilityMultiplierBps = 0;
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistrySetup {
networkFeeUSDCents: 1_00,
enforceOutOfOrder: false,
chainFamilySelector: Internal.CHAIN_FAMILY_SELECTOR_EVM
}),
prevOnRamp: address(0)
})
});
return destChainConfigs;
}
Expand Down Expand Up @@ -367,7 +366,6 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistrySetup {
assertEq(a.dynamicConfig.defaultTokenDestGasOverhead, b.dynamicConfig.defaultTokenDestGasOverhead);
assertEq(a.dynamicConfig.defaultTokenDestBytesOverhead, b.dynamicConfig.defaultTokenDestBytesOverhead);
assertEq(a.dynamicConfig.defaultTxGasLimit, b.dynamicConfig.defaultTxGasLimit);
assertEq(a.prevOnRamp, b.prevOnRamp);
assertEq(a.sequenceNumber, b.sequenceNumber);
assertEq(a.metadataHash, b.metadataHash);
}
Expand Down
4 changes: 4 additions & 0 deletions core/capabilities/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type Registry struct {
mu sync.RWMutex
}

func (r *Registry) GetLocalNode(_ context.Context) (capabilities.Node, error) {
return capabilities.Node{}, nil
}

// Get gets a capability from the registry.
func (r *Registry) Get(_ context.Context, id string) (capabilities.BaseCapability, error) {
r.mu.RLock()
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/remote/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

commonMocks "github.com/smartcontractkit/chainlink-common/pkg/types/mocks"
commonMocks "github.com/smartcontractkit/chainlink-common/pkg/types/core/mocks"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/remote"
remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/remote/types/messages.pb.go

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

3 changes: 1 addition & 2 deletions core/chains/evm/headtracker/head_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ func TestHeadTracker_Start(t *testing.T) {

func TestHeadTracker_CallsHeadTrackableCallbacks(t *testing.T) {
t.Parallel()
g := gomega.NewWithT(t)

db := pgtest.NewSqlxDB(t)
config := testutils.NewTestChainScopedConfig(t, nil)
Expand Down Expand Up @@ -360,7 +359,7 @@ func TestHeadTracker_CallsHeadTrackableCallbacks(t *testing.T) {

headers := <-chchHeaders
headers.TrySend(&evmtypes.Head{Number: 1, Hash: utils.NewHash(), EVMChainID: ubig.New(testutils.FixtureChainID)})
g.Eventually(checker.OnNewLongestChainCount).Should(gomega.Equal(int32(1)))
tests.AssertEventually(t, func() bool { return checker.OnNewLongestChainCount() == 1 })

ht.Stop(t)
assert.Equal(t, int32(1), checker.OnNewLongestChainCount())
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 7d8f00c

Please sign in to comment.