Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into improve-return-val…
Browse files Browse the repository at this point in the history
…ue-get-allowlist

# Conflicts:
#	contracts/gas-snapshots/ccip.gas-snapshot
#	core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt
  • Loading branch information
RensR committed Oct 22, 2024
2 parents 8e2f3d7 + 1636059 commit 4b90ba2
Show file tree
Hide file tree
Showing 66 changed files with 1,025 additions and 345 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-squids-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

FHE empty reward fix #internal
5 changes: 5 additions & 0 deletions .changeset/olive-bugs-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

add address bytes to string modifier to chainReader. #internal
15 changes: 14 additions & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,21 @@ jobs:
gc-host: ${{ secrets.GRAFANA_INTERNAL_HOST }}
gc-org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}

- name: Check Time For Slack Notify
if: ${{ failure() && github.event.schedule != ''}}
id: check-time
shell: bash
run: |
# Get the current hour (24-hour format)
current_hour=$(date +"%H")
# Check if the current hour is 00 (midnight)
if [ "$current_hour" -eq "00" ]; then
echo "midnight=true" >> $GITHUB_OUTPUT
fi
- name: Notify Slack
if: ${{ failure() && github.event.schedule != '' }}
if: ${{ failure() && github.event.schedule != '' && steps.check-time.outputs.midnight == 'true' }}
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
env:
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}
Expand Down
10 changes: 10 additions & 0 deletions contracts/.changeset/happy-planets-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@chainlink/contracts': minor
---

add accountStr to chainReader test contract struct in order to test the new address bytes to string modifier. #internal


PR issue: BCFR-147

Solidity Review issue: BCFR-957
13 changes: 7 additions & 6 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,13 @@ NonceManager_OnRampUpgrade:test_UpgradeNonceNewSenderStartsAtZero_Success() (gas
NonceManager_OnRampUpgrade:test_UpgradeNonceStartsAtV1Nonce_Success() (gas: 195673)
NonceManager_OnRampUpgrade:test_UpgradeSenderNoncesReadsPreviousRamp_Success() (gas: 139139)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 105187)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 123141)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOffRamp_Revert() (gas: 43073)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRampAndOffRamp_Revert() (gas: 64380)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRamp_Revert() (gas: 42915)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate() (gas: 66660)
NonceManager_applyPreviousRampsUpdates:test_ZeroInput() (gas: 12090)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates_success() (gas: 123118)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOffRamp_Revert() (gas: 43282)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRampAndOffRamp_Revert() (gas: 64610)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRamp_Revert() (gas: 43102)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySet_overrideAllowed_success() (gas: 45875)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate_success() (gas: 66658)
NonceManager_applyPreviousRampsUpdates:test_ZeroInput_success() (gas: 12114)
NonceManager_typeAndVersion:test_typeAndVersion() (gas: 9705)
OffRamp_afterOC3ConfigSet:test_afterOCR3ConfigSet_SignatureVerificationDisabled_Revert() (gas: 5917222)
OffRamp_applySourceChainConfigUpdates:test_AddMultipleChains_Success() (gas: 626106)
Expand Down
8 changes: 6 additions & 2 deletions contracts/src/v0.8/ccip/NonceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {
/// @dev Struct that contains the chain selector and the previous on/off ramps, same as PreviousRamps but with the chain selector
/// so that an array of these can be passed to the applyPreviousRampsUpdates function
struct PreviousRampsArgs {
uint64 remoteChainSelector; // Chain selector
uint64 remoteChainSelector; // ──╮ Chain selector
bool overrideExistingRamps; // ──╯ Whether to override existing ramps
PreviousRamps prevRamps; // Previous on/off ramps
}

Expand Down Expand Up @@ -137,7 +138,10 @@ contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {
// In versions prior to the introduction of the NonceManager contract, nonces were tracked in the on/off ramps.
// This config does a 1-time migration to move the nonce from on/off ramps into NonceManager
if (prevRamps.prevOnRamp != address(0) || prevRamps.prevOffRamp != address(0)) {
revert PreviousRampAlreadySet();
// We do allow explicit overrides as an escape hatch in the case of a misconfiguration.
if (!previousRampsArg.overrideExistingRamps) {
revert PreviousRampAlreadySet();
}
}

prevRamps.prevOnRamp = previousRampsArg.prevRamps.prevOnRamp;
Expand Down
104 changes: 78 additions & 26 deletions contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ contract NonceManager_NonceIncrementation is BaseTest {
}

contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
function test_SingleRampUpdate() public {
function test_SingleRampUpdate_success() public {
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp, prevOffRamp));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp, prevOffRamp),
overrideExistingRamps: false
});

vm.expectEmit();
emit NonceManager.PreviousRampsUpdated(DEST_CHAIN_SELECTOR, previousRamps[0].prevRamps);
Expand All @@ -104,16 +107,22 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
_assertPreviousRampsEqual(s_outboundNonceManager.getPreviousRamps(DEST_CHAIN_SELECTOR), previousRamps[0].prevRamps);
}

function test_MultipleRampsUpdates() public {
function test_MultipleRampsUpdates_success() public {
address prevOnRamp1 = makeAddr("prevOnRamp1");
address prevOnRamp2 = makeAddr("prevOnRamp2");
address prevOffRamp1 = makeAddr("prevOffRamp1");
address prevOffRamp2 = makeAddr("prevOffRamp2");
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](2);
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp1, prevOffRamp1));
previousRamps[1] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR + 1, NonceManager.PreviousRamps(prevOnRamp2, prevOffRamp2));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp1, prevOffRamp1),
overrideExistingRamps: false
});
previousRamps[1] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR + 1,
prevRamps: NonceManager.PreviousRamps(prevOnRamp2, prevOffRamp2),
overrideExistingRamps: false
});

vm.expectEmit();
emit NonceManager.PreviousRampsUpdated(DEST_CHAIN_SELECTOR, previousRamps[0].prevRamps);
Expand All @@ -128,7 +137,27 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
);
}

function test_ZeroInput() public {
function test_PreviousRampAlreadySet_overrideAllowed_success() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOffRamp = makeAddr("prevOffRamp");
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(address(0), prevOffRamp),
overrideExistingRamps: true
});

s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(address(0), prevOffRamp),
overrideExistingRamps: true
});

s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
}

function test_ZeroInput_success() public {
vm.recordLogs();
s_outboundNonceManager.applyPreviousRampsUpdates(new NonceManager.PreviousRampsArgs[](0));

Expand All @@ -138,13 +167,19 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
function test_PreviousRampAlreadySetOnRamp_Revert() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp, address(0)));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp, address(0)),
overrideExistingRamps: false
});

s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp, address(0)));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp, address(0)),
overrideExistingRamps: false
});

vm.expectRevert(NonceManager.PreviousRampAlreadySet.selector);
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
Expand All @@ -153,13 +188,19 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
function test_PreviousRampAlreadySetOffRamp_Revert() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOffRamp = makeAddr("prevOffRamp");
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(address(0), prevOffRamp));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(address(0), prevOffRamp),
overrideExistingRamps: false
});

s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(address(0), prevOffRamp));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(address(0), prevOffRamp),
overrideExistingRamps: false
});

vm.expectRevert(NonceManager.PreviousRampAlreadySet.selector);
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
Expand All @@ -169,13 +210,19 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp, prevOffRamp));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp, prevOffRamp),
overrideExistingRamps: false
});

s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(prevOnRamp, prevOffRamp));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(prevOnRamp, prevOffRamp),
overrideExistingRamps: false
});

vm.expectRevert(NonceManager.PreviousRampAlreadySet.selector);
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
Expand Down Expand Up @@ -205,8 +252,11 @@ contract NonceManager_OnRampUpgrade is OnRampSetup {
vm.mockCall(address(s_prevOnRamp), abi.encodeWithSelector(IEVM2AnyOnRamp.getSenderNonce.selector), abi.encode(0));

NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
previousRamps[0] =
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(address(s_prevOnRamp), address(0)));
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: DEST_CHAIN_SELECTOR,
prevRamps: NonceManager.PreviousRamps(address(s_prevOnRamp), address(0)),
overrideExistingRamps: false
});
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

(s_onRamp, s_metadataHash) = _deployOnRamp(
Expand Down Expand Up @@ -289,9 +339,11 @@ contract NonceManager_OffRampUpgrade is OffRampSetup {
s_prevOffRamp = new EVM2EVMOffRampHelper();

NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
previousRamps[0] = NonceManager.PreviousRampsArgs(
SOURCE_CHAIN_SELECTOR_1, NonceManager.PreviousRamps(address(0), address(s_prevOffRamp))
);
previousRamps[0] = NonceManager.PreviousRampsArgs({
remoteChainSelector: SOURCE_CHAIN_SELECTOR_1,
prevRamps: NonceManager.PreviousRamps(address(0), address(s_prevOffRamp)),
overrideExistingRamps: false
});

s_inboundNonceManager.applyPreviousRampsUpdates(previousRamps);

Expand Down
8 changes: 8 additions & 0 deletions contracts/src/v0.8/shared/test/helpers/ChainReaderTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct TestStruct {
uint8 OracleId;
uint8[32] OracleIds;
address Account;
address AccountStr;
address[] Accounts;
int192 BigField;
MidLevelDynamicTestStruct NestedDynamicStruct;
Expand Down Expand Up @@ -42,6 +43,7 @@ contract ChainReaderTester {
MidLevelStaticTestStruct nestedStaticStruct,
uint8[32] oracleIds,
address Account,
address AccountStr,
address[] Accounts,
string differentField,
int192 bigField
Expand Down Expand Up @@ -74,6 +76,7 @@ contract ChainReaderTester {
uint8 oracleId,
uint8[32] calldata oracleIds,
address account,
address accountStr,
address[] calldata accounts,
int192 bigField,
MidLevelDynamicTestStruct calldata nestedDynamicStruct,
Expand All @@ -86,6 +89,7 @@ contract ChainReaderTester {
oracleId,
oracleIds,
account,
accountStr,
accounts,
bigField,
nestedDynamicStruct,
Expand All @@ -104,6 +108,7 @@ contract ChainReaderTester {
uint8 oracleId,
uint8[32] calldata oracleIds,
address account,
address accountStr,
address[] calldata accounts,
int192 bigField,
MidLevelDynamicTestStruct calldata nestedDynamicStruct,
Expand All @@ -116,6 +121,7 @@ contract ChainReaderTester {
oracleId,
oracleIds,
account,
accountStr,
accounts,
bigField,
nestedDynamicStruct,
Expand Down Expand Up @@ -154,6 +160,7 @@ contract ChainReaderTester {
MidLevelStaticTestStruct calldata nestedStaticStruct,
uint8[32] calldata oracleIds,
address account,
address accountStr,
address[] calldata accounts,
string calldata differentField,
int192 bigField
Expand All @@ -165,6 +172,7 @@ contract ChainReaderTester {
nestedStaticStruct,
oracleIds,
account,
accountStr,
accounts,
differentField,
bigField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

mapset "github.com/deckarep/golang-set/v2"
"github.com/onsi/gomega"

"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccip_integration_tests/integrationhelpers"

Expand Down Expand Up @@ -56,10 +55,10 @@ func TestHomeChainReader_ChainConfigs(t *testing.T) {
require.Len(t, chainConfigInfos, len(inputConfig))

// Wait for the home chain reader to read the expected amount of chain configs.
gomega.NewWithT(t).Eventually(func() bool {
require.Eventually(t, func() bool {
configs, _ := uni.HomeChainReader.GetAllChainConfigs()
return len(configs) == len(inputConfig)
}, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue())
}, testutils.WaitTimeout(t), 1*time.Second)

t.Logf("homchain reader is ready")

Expand All @@ -85,10 +84,10 @@ func TestHomeChainReader_ChainConfigs(t *testing.T) {
uni.Backend.Commit()

// Wait for the home chain reader to read the expected amount of chain configs.
gomega.NewWithT(t).Eventually(func() bool {
require.Eventually(t, func() bool {
chainConfigs, _ := uni.HomeChainReader.GetAllChainConfigs()
return len(chainConfigs) == len(inputConfig)-1
}, testutils.WaitTimeout(t), 1*time.Second).Should(gomega.BeTrue())
}, testutils.WaitTimeout(t), 1*time.Second)
configs, err = uni.HomeChainReader.GetAllChainConfigs()
require.NoError(t, err)

Expand Down
5 changes: 2 additions & 3 deletions core/capabilities/ccip/launcher/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types"

"github.com/onsi/gomega"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
Expand Down Expand Up @@ -90,9 +89,9 @@ func TestIntegration_Launcher(t *testing.T) {
it.FChainA,
p2pIDs)

gomega.NewWithT(t).Eventually(func() bool {
require.Eventually(t, func() bool {
return len(launcher.runningDONIDs()) == 1
}, testutils.WaitTimeout(t), testutils.TestInterval).Should(gomega.BeTrue())
}, testutils.WaitTimeout(t), testutils.TestInterval)
}

type oraclePrints struct {
Expand Down
Loading

0 comments on commit 4b90ba2

Please sign in to comment.