Skip to content

Commit f71382a

Browse files
committed
Base 4 commit for v2.4.0
1 parent 89c5be6 commit f71382a

File tree

76 files changed

+1376
-1273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1376
-1273
lines changed

common/txmgr/confirmer.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) pro
339339
ec.lggr.Debugw("Finished RebroadcastWhereNecessary", "headNum", head.BlockNumber(), "time", time.Since(mark), "id", "confirmer")
340340
mark = time.Now()
341341

342-
if err := ec.EnsureConfirmedTransactionsInLongestChain(ctx, head, latestFinalizedHead.BlockNumber()); err != nil {
342+
if err := ec.EnsureConfirmedTransactionsInLongestChain(ctx, head); err != nil {
343343
return fmt.Errorf("EnsureConfirmedTransactionsInLongestChain failed: %w", err)
344344
}
345345

@@ -913,7 +913,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) att
913913
}
914914
return attempt, fmt.Errorf("invariant violation: Tx %v was unconfirmed but didn't have any attempts. "+
915915
"Falling back to default gas price instead."+
916-
"This is a bug! Please report to https://github.com/goplugin/pluginv3.0/issues", etx.ID)
916+
"This is a bug! Please report to https://github.com/goplugin/plugin/issues", etx.ID)
917917
}
918918

919919
func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) logFieldsPreviousAttempt(attempt txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) []interface{} {
@@ -1072,19 +1072,20 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) han
10721072
//
10731073
// If any of the confirmed transactions does not have a receipt in the chain, it has been
10741074
// re-org'd out and will be rebroadcast.
1075-
func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) EnsureConfirmedTransactionsInLongestChain(ctx context.Context, head types.Head[BLOCK_HASH], latestFinalizedHeadNumber int64) error {
1075+
func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) EnsureConfirmedTransactionsInLongestChain(ctx context.Context, head types.Head[BLOCK_HASH]) error {
10761076
logArgs := []interface{}{
1077-
"chainLength", head.ChainLength(), "latestFinalizedHead number", latestFinalizedHeadNumber,
1078-
}
1079-
1080-
if head.BlockNumber() < latestFinalizedHeadNumber {
1081-
errMsg := "current head is shorter than latest finalized head"
1082-
ec.lggr.Errorw(errMsg, append(logArgs, "head block number", head.BlockNumber())...)
1083-
return errors.New(errMsg)
1084-
}
1085-
1086-
calculatedFinalityDepth := uint32(head.BlockNumber() - latestFinalizedHeadNumber)
1087-
if head.ChainLength() < calculatedFinalityDepth {
1077+
"chainLength", head.ChainLength(),
1078+
}
1079+
1080+
//Here, we rely on the finalized block provided in the chain instead of the one
1081+
//provided via a dedicated method to avoid the false warning of the chain being
1082+
//too short. When `FinalityTagBypass = true,` HeadTracker tracks `finality depth
1083+
//+ history depth` to prevent excessive CPU usage. Thus, the provided chain may
1084+
//be shorter than the chain from the latest to the latest finalized, marked with
1085+
//a tag. A proper fix of this issue and complete switch to finality tag support
1086+
//will be introduced in BCFR-620
1087+
latestFinalized := head.LatestFinalizedHead()
1088+
if latestFinalized == nil || !latestFinalized.IsValid() {
10881089
if ec.nConsecutiveBlocksChainTooShort > logAfterNConsecutiveBlocksChainTooShort {
10891090
warnMsg := "Chain length supplied for re-org detection was shorter than the depth from the latest head to the finalized head. Re-org protection is not working properly. This could indicate a problem with the remote RPC endpoint, a compatibility issue with a particular blockchain, a bug with this particular blockchain, heads table being truncated too early, remote node out of sync, or something else. If this happens a lot please raise a bug with the Plugin team including a log output sample and details of the chain and RPC endpoint you are using."
10901091
ec.lggr.Warnw(warnMsg, append(logArgs, "nConsecutiveBlocksChainTooShort", ec.nConsecutiveBlocksChainTooShort)...)

contracts/.changeset/nice-rocks-trade.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

contracts/CHANGELOG.md

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

contracts/gas-snapshots/ccip.gas-snapshot

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

contracts/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/src/v0.8/automation/test/v2_3/AutomationRegistry2_3.t.sol

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ contract SetUp is BaseTest {
2222
AutomationRegistryBase2_3.OnchainConfig internal config;
2323
bytes internal constant offchainConfigBytes = abi.encode(1234, ZERO_ADDRESS);
2424

25-
uint256 internal linkUpkeepID;
26-
uint256 internal linkUpkeepID2; // 2 upkeeps use the same billing token (PLI) to test migration scenario
25+
uint256 internal pliUpkeepID;
26+
uint256 internal pliUpkeepID2; // 2 upkeeps use the same billing token (PLI) to test migration scenario
2727
uint256 internal usdUpkeepID18; // 1 upkeep uses ERC20 token with 18 decimals
2828
uint256 internal usdUpkeepID6; // 1 upkeep uses ERC20 token with 6 decimals
2929
uint256 internal nativeUpkeepID;
@@ -34,23 +34,23 @@ contract SetUp is BaseTest {
3434
config = registry.getConfig();
3535

3636
vm.startPrank(OWNER);
37-
linkToken.approve(address(registry), type(uint256).max);
37+
pliToken.approve(address(registry), type(uint256).max);
3838
usdToken6.approve(address(registry), type(uint256).max);
3939
usdToken18.approve(address(registry), type(uint256).max);
4040
weth.approve(address(registry), type(uint256).max);
4141
vm.startPrank(UPKEEP_ADMIN);
42-
linkToken.approve(address(registry), type(uint256).max);
42+
pliToken.approve(address(registry), type(uint256).max);
4343
usdToken6.approve(address(registry), type(uint256).max);
4444
usdToken18.approve(address(registry), type(uint256).max);
4545
weth.approve(address(registry), type(uint256).max);
4646
vm.startPrank(STRANGER);
47-
linkToken.approve(address(registry), type(uint256).max);
47+
pliToken.approve(address(registry), type(uint256).max);
4848
usdToken6.approve(address(registry), type(uint256).max);
4949
usdToken18.approve(address(registry), type(uint256).max);
5050
weth.approve(address(registry), type(uint256).max);
5151
vm.stopPrank();
5252

53-
linkUpkeepID = registry.registerUpkeep(
53+
pliUpkeepID = registry.registerUpkeep(
5454
address(TARGET1),
5555
config.maxPerformGas,
5656
UPKEEP_ADMIN,
@@ -61,7 +61,7 @@ contract SetUp is BaseTest {
6161
""
6262
);
6363

64-
linkUpkeepID2 = registry.registerUpkeep(
64+
pliUpkeepID2 = registry.registerUpkeep(
6565
address(TARGET1),
6666
config.maxPerformGas,
6767
UPKEEP_ADMIN,
@@ -162,7 +162,7 @@ contract WithdrawFunds is SetUp {
162162
registry.cancelUpkeep(linkUpkeepID);
163163
vm.roll(100 + block.number);
164164

165-
uint256 startUpkeepAdminBalance = linkToken.balanceOf(UPKEEP_ADMIN);
165+
uint256 startUpkeepAdminBalance = pliToken.balanceOf(UPKEEP_ADMIN);
166166
uint256 startLinkReserveAmountBalance = registry.getReserveAmount(address(linkToken));
167167

168168
uint256 upkeepBalance = registry.getBalance(linkUpkeepID);
@@ -248,7 +248,7 @@ contract AddFunds is SetUp {
248248
function test_movesFundFromCorrectToken() public {
249249
vm.startPrank(UPKEEP_ADMIN);
250250

251-
uint256 startPLIRegistryBalance = linkToken.balanceOf(address(registry));
251+
uint256 startPLIRegistryBalance = pliToken.balanceOf(address(registry));
252252
uint256 startUSDRegistryBalance = usdToken18.balanceOf(address(registry));
253253
uint256 startLinkUpkeepBalance = registry.getBalance(linkUpkeepID);
254254
uint256 startUSDUpkeepBalance = registry.getBalance(usdUpkeepID18);
@@ -278,16 +278,16 @@ contract Withdraw is SetUp {
278278
address internal aMockAddress = randomAddress();
279279

280280
function testLinkAvailableForPaymentReturnsLinkBalance() public {
281-
uint256 startBalance = linkToken.balanceOf(address(registry));
281+
uint256 startBalance = pliToken.balanceOf(address(registry));
282282
int256 startLinkAvailable = registry.linkAvailableForPayment();
283283

284-
//simulate a deposit of link to the liquidity pool
284+
//simulate a deposit of pli to the liquidity pool
285285
_mintLink(address(registry), 1e10);
286286

287287
//check there's a balance
288288
assertEq(linkToken.balanceOf(address(registry)), startBalance + 1e10);
289289

290-
//check the link available has increased by the same amount
290+
//check the pli available has increased by the same amount
291291
assertEq(uint256(registry.linkAvailableForPayment()), uint256(startLinkAvailable) + 1e10);
292292
}
293293

@@ -299,7 +299,7 @@ contract Withdraw is SetUp {
299299
function testWithdrawLinkRevertsBecauseOfInsufficientBalance() public {
300300
vm.startPrank(FINANCE_ADMIN);
301301

302-
// try to withdraw 1 link while there is 0 balance
302+
// try to withdraw 1 pli while there is 0 balance
303303
vm.expectRevert(abi.encodeWithSelector(Registry.InsufficientBalance.selector, 0, 1));
304304
registry.withdrawLink(aMockAddress, 1);
305305

@@ -309,21 +309,21 @@ contract Withdraw is SetUp {
309309
function testWithdrawLinkRevertsBecauseOfInvalidRecipient() public {
310310
vm.startPrank(FINANCE_ADMIN);
311311

312-
// try to withdraw 1 link while there is 0 balance
312+
// try to withdraw 1 pli while there is 0 balance
313313
vm.expectRevert(abi.encodeWithSelector(Registry.InvalidRecipient.selector));
314314
registry.withdrawLink(ZERO_ADDRESS, 1);
315315

316316
vm.stopPrank();
317317
}
318318

319319
function testWithdrawLinkSuccess() public {
320-
//simulate a deposit of link to the liquidity pool
320+
//simulate a deposit of pli to the liquidity pool
321321
_mintLink(address(registry), 1e10);
322-
uint256 startBalance = linkToken.balanceOf(address(registry));
322+
uint256 startBalance = pliToken.balanceOf(address(registry));
323323

324324
vm.startPrank(FINANCE_ADMIN);
325325

326-
// try to withdraw 1 link while there is a ton of link available
326+
// try to withdraw 1 pli while there is a ton of pli available
327327
registry.withdrawLink(aMockAddress, 1);
328328

329329
vm.stopPrank();
@@ -344,7 +344,7 @@ contract Withdraw is SetUp {
344344
vm.startPrank(FINANCE_ADMIN);
345345
vm.expectRevert(Registry.InvalidToken.selector);
346346
registry.withdrawERC20Fees(address(linkToken), FINANCE_ADMIN, 1); // should revert
347-
registry.withdrawLink(FINANCE_ADMIN, 1); // but using link withdraw functions succeeds
347+
registry.withdrawLink(FINANCE_ADMIN, 1); // but using pli withdraw functions succeeds
348348
}
349349

350350
// default is ON_CHAIN mode
@@ -773,7 +773,7 @@ contract SetConfig is SetUp {
773773
priceFeed: address(USDTOKEN_USD_FEED),
774774
fallbackPrice: 2_000_000_000, // $20
775775
minSpend: 100_000,
776-
decimals: 6 // link token should have 18 decimals
776+
decimals: 6 // pli token should have 18 decimals
777777
});
778778

779779
vm.expectRevert(abi.encodeWithSelector(Registry.InvalidToken.selector));
@@ -989,7 +989,7 @@ contract NOPsSettlement is SetUp {
989989
registry.settleNOPsOffchain();
990990
}
991991

992-
// 1. transmitter balance zeroed after settlement, 2. admin can withdraw ERC20, 3. switch to onchain mode, 4. link amount owed to NOPs stays the same
992+
// 1. transmitter balance zeroed after settlement, 2. admin can withdraw ERC20, 3. switch to onchain mode, 4. pli amount owed to NOPs stays the same
993993
function testSettleNOPsOffchainSuccessWithERC20MultiSteps() public {
994994
// deploy and configure a registry with OFF_CHAIN payout
995995
(Registry registry, ) = deployAndConfigureRegistryAndRegistrar(AutoBase.PayoutMode.OFF_CHAIN);
@@ -1059,13 +1059,13 @@ contract NOPsSettlement is SetUp {
10591059
vm.startPrank(registry.owner());
10601060
registry.disableOffchainPayments();
10611061

1062-
// finance admin comes to withdraw all available ERC20s, should revert bc of insufficient link liquidity
1062+
// finance admin comes to withdraw all available ERC20s, should revert bc of insufficient pli liquidity
10631063
vm.startPrank(FINANCE_ADMIN);
10641064
uint256 erc20ForPayment4 = registry.getAvailableERC20ForPayment(address(usdToken18));
10651065
vm.expectRevert(abi.encodeWithSelector(Registry.InsufficientLinkLiquidity.selector));
10661066
registry.withdrawERC20Fees(address(usdToken18), FINANCE_ADMIN, erc20ForPayment4);
10671067

1068-
// reserved link amount to NOPs should stay the same after switching to onchain mode
1068+
// reserved pli amount to NOPs should stay the same after switching to onchain mode
10691069
assertEq(registry.getReserveAmount(address(linkToken)), reservedLink);
10701070
// available ERC20 for payment should be 0 since finance admin withdrew all already
10711071
assertEq(erc20ForPayment4, 0);
@@ -1659,15 +1659,15 @@ contract Transmit is SetUp {
16591659
prevUpkeepBalances[1] = registry.getBalance(usdUpkeepID18);
16601660
prevUpkeepBalances[2] = registry.getBalance(nativeUpkeepID);
16611661
uint256[] memory prevTokenBalances = new uint256[](3);
1662-
prevTokenBalances[0] = linkToken.balanceOf(address(registry));
1662+
prevTokenBalances[0] = pliToken.balanceOf(address(registry));
16631663
prevTokenBalances[1] = usdToken18.balanceOf(address(registry));
16641664
prevTokenBalances[2] = weth.balanceOf(address(registry));
16651665
uint256[] memory prevReserveBalances = new uint256[](3);
16661666
prevReserveBalances[0] = registry.getReserveAmount(address(linkToken));
16671667
prevReserveBalances[1] = registry.getReserveAmount(address(usdToken18));
16681668
prevReserveBalances[2] = registry.getReserveAmount(address(weth));
16691669
uint256[] memory upkeepIDs = new uint256[](3);
1670-
upkeepIDs[0] = linkUpkeepID;
1670+
upkeepIDs[0] = pliUpkeepID;
16711671
upkeepIDs[1] = usdUpkeepID18;
16721672
upkeepIDs[2] = nativeUpkeepID;
16731673

@@ -1690,14 +1690,14 @@ contract Transmit is SetUp {
16901690
require(prevUpkeepBalances[1] > registry.getBalance(usdUpkeepID18), "usd upkeep balance should have decreased");
16911691
require(prevUpkeepBalances[2] > registry.getBalance(nativeUpkeepID), "native upkeep balance should have decreased");
16921692
// assert token balances have not changed
1693-
assertEq(prevTokenBalances[0], linkToken.balanceOf(address(registry)));
1693+
assertEq(prevTokenBalances[0], pliToken.balanceOf(address(registry)));
16941694
assertEq(prevTokenBalances[1], usdToken18.balanceOf(address(registry)));
16951695
assertEq(prevTokenBalances[2], weth.balanceOf(address(registry)));
16961696
// assert reserve amounts have adjusted accordingly
16971697
require(
16981698
prevReserveBalances[0] < registry.getReserveAmount(address(linkToken)),
16991699
"usd reserve amount should have increased"
1700-
); // link reserve amount increases in value equal to the decrease of the other reserve amounts
1700+
); // pli reserve amount increases in value equal to the decrease of the other reserve amounts
17011701
require(
17021702
prevReserveBalances[1] > registry.getReserveAmount(address(usdToken18)),
17031703
"usd reserve amount should have decreased"
@@ -1746,13 +1746,13 @@ contract Transmit is SetUp {
17461746
uint96 gasReimbursementInJuels,
17471747
uint96 premiumInJuels,
17481748
address billingToken,
1749-
uint96 linkUSD,
1749+
uint96 pliUSD,
17501750
uint96 nativeUSD,
17511751
uint96 billingUSD
17521752
) = abi.decode(l1.data, (uint96, uint96, uint96, uint96, address, uint96, uint96, uint96));
17531753

17541754
assertEq(gasChargeInBillingToken, balance);
1755-
assertEq(gasReimbursementInJuels, (balance * billingUSD) / linkUSD);
1755+
assertEq(gasReimbursementInJuels, (balance * billingUSD) / pliUSD);
17561756
assertEq(premiumInJuels, 0);
17571757
assertEq(premiumInBillingToken, 0);
17581758
}
@@ -1797,13 +1797,13 @@ contract Transmit is SetUp {
17971797
uint96 gasReimbursementInJuels,
17981798
uint96 premiumInJuels,
17991799
address billingToken,
1800-
uint96 linkUSD,
1800+
uint96 pliUSD,
18011801
uint96 nativeUSD,
18021802
uint96 billingUSD
18031803
) = abi.decode(l1.data, (uint96, uint96, uint96, uint96, address, uint96, uint96, uint96));
18041804

1805-
assertEq(premiumInJuels, (balance * billingUSD * 1e12) / linkUSD - gasReimbursementInJuels); // scale to 18 decimals
1806-
assertEq(premiumInBillingToken, (premiumInJuels * linkUSD + (billingUSD * 1e12 - 1)) / (billingUSD * 1e12));
1805+
assertEq(premiumInJuels, (balance * billingUSD * 1e12) / pliUSD - gasReimbursementInJuels); // scale to 18 decimals
1806+
assertEq(premiumInBillingToken, (premiumInJuels * pliUSD + (billingUSD * 1e12 - 1)) / (billingUSD * 1e12));
18071807
}
18081808
}
18091809

@@ -1890,7 +1890,7 @@ contract MigrateReceive is SetUp {
18901890
prevReserveBalances[1] = registry.getReserveAmount(address(usdToken18));
18911891
prevReserveBalances[2] = registry.getReserveAmount(address(weth));
18921892
uint256[] memory prevTokenBalances = new uint256[](3);
1893-
prevTokenBalances[0] = linkToken.balanceOf(address(registry));
1893+
prevTokenBalances[0] = pliToken.balanceOf(address(registry));
18941894
prevTokenBalances[1] = usdToken18.balanceOf(address(registry));
18951895
prevTokenBalances[2] = weth.balanceOf(address(registry));
18961896
bytes[] memory prevUpkeepData = new bytes[](4);
@@ -1957,12 +1957,12 @@ contract MigrateReceive is SetUp {
19571957

19581958
// assert token have been transferred
19591959
assertEq(
1960-
linkToken.balanceOf(address(newRegistry)),
1960+
pliToken.balanceOf(address(newRegistry)),
19611961
newRegistry.getBalance(linkUpkeepID) + newRegistry.getBalance(linkUpkeepID2)
19621962
);
19631963
assertEq(usdToken18.balanceOf(address(newRegistry)), newRegistry.getBalance(usdUpkeepID18));
19641964
assertEq(weth.balanceOf(address(newRegistry)), newRegistry.getBalance(nativeUpkeepID));
1965-
assertEq(linkToken.balanceOf(address(registry)), prevTokenBalances[0] - linkToken.balanceOf(address(newRegistry)));
1965+
assertEq(linkToken.balanceOf(address(registry)), prevTokenBalances[0] - pliToken.balanceOf(address(newRegistry)));
19661966
assertEq(
19671967
usdToken18.balanceOf(address(registry)),
19681968
prevTokenBalances[1] - usdToken18.balanceOf(address(newRegistry))
@@ -2747,7 +2747,7 @@ contract GetActiveUpkeepIDs is SetUp {
27472747
function test_ReturnsUpkeeps_BoundByMaxCount() external {
27482748
uint256[] memory uids = registry.getActiveUpkeepIDs(1, 2);
27492749
assertEq(2, uids.length);
2750-
assertEq(uids[0], linkUpkeepID2);
2750+
assertEq(uids[0], pliUpkeepID2);
27512751
assertEq(uids[1], usdUpkeepID18);
27522752
}
27532753
}

0 commit comments

Comments
 (0)