Skip to content

Commit b5b326f

Browse files
authored
feat: Bump SDK version (#2491)
* feat: Bump SDK version * Fixed test * Bump sdk version * Updated isChainDisabled usage * remove index * Removed unnecessary tests * lint * check startBlock === endBlock instead * lint
1 parent d7e3666 commit b5b326f

9 files changed

+20
-361
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@across-protocol/constants": "^3.1.72",
1414
"@across-protocol/contracts": "^4.1.5",
15-
"@across-protocol/sdk": "4.3.58",
15+
"@across-protocol/sdk": "4.3.59",
1616
"@arbitrum/sdk": "^4.0.2",
1717
"@consensys/linea-sdk": "^0.3.0",
1818
"@coral-xyz/anchor": "^0.31.1",
@@ -79,7 +79,8 @@
7979
"deposit": "yarn ts-node ./scripts/spokepool.ts deposit",
8080
"dispute": "yarn ts-node ./scripts/hubpool.ts dispute",
8181
"update": "git pull && yarn reinstall && yarn version --non-interactive && git show --quiet",
82-
"update-addresses": "yarn ts-node ./scripts/fetch-addresses.ts"
82+
"update-addresses": "yarn ts-node ./scripts/fetch-addresses.ts",
83+
"validate-root-bundle": "yarn ts-node src/scripts/validateRootBundle.ts"
8384
},
8485
"devDependencies": {
8586
"@nomiclabs/hardhat-ethers": "^2.2.3",

src/dataworker/PoolRebalanceUtils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
winston,
1313
assert,
1414
getNetworkName,
15-
isChainDisabled,
1615
EvmAddress,
1716
Address,
1817
isDefined,
@@ -68,9 +67,9 @@ export function generateMarkdownForRootBundle(
6867
let bundleBlockRangePretty = "";
6968
bundleBlockRange.forEach((_blockRange, index) => {
7069
const chainId = chainIdListForBundleEvaluationBlockNumbers[index];
71-
bundleBlockRangePretty += `\n\t\t${chainId}: ${JSON.stringify(bundleBlockRange[index])}${
72-
isChainDisabled(bundleBlockRange[index]) ? " 🥶" : ""
73-
}`;
70+
const [startBlock, endBlock] = bundleBlockRange[index];
71+
const paused = startBlock === endBlock ? " 🥶" : "";
72+
bundleBlockRangePretty += `\n\t\t${chainId}: ${JSON.stringify(bundleBlockRange[index])}${paused}`;
7473
});
7574

7675
const convertTokenListFromWei = (chainId: number, tokenAddresses: Address[], weiVals: string[]) => {

src/utils/SDKUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const {
104104

105105
export const {
106106
getRefundsFromBundle,
107-
isChainDisabled,
107+
isChainDisabledAtBlock,
108108
getWidestPossibleExpectedBlockRange,
109109
getEndBlockBuffers,
110110
buildPoolRebalanceLeafTree,
Lines changed: 2 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
import { BundleDataClient, HubPoolClient, MultiCallerClient, SpokePoolClient } from "../src/clients";
2-
import {
3-
EvmAddress,
4-
buildRelayerRefundTree,
5-
MAX_UINT_VAL,
6-
RelayerRefundLeaf,
7-
toBN,
8-
toBNWei,
9-
toAddressType,
10-
} from "../src/utils";
1+
import { HubPoolClient, MultiCallerClient, SpokePoolClient } from "../src/clients";
2+
import { EvmAddress, buildRelayerRefundTree, MAX_UINT_VAL, RelayerRefundLeaf, toBNWei } from "../src/utils";
113
import {
124
MAX_L1_TOKENS_PER_POOL_REBALANCE_LEAF,
135
MAX_REFUNDS_PER_RELAYER_REFUND_LEAF,
146
amountToDeposit,
157
destinationChainId,
16-
repaymentChainId,
178
} from "./constants";
189
import { setupDataworker } from "./fixtures/Dataworker.Fixture";
1910
import { Contract, SignerWithAddress, depositV3, ethers, expect, fillV3Relay } from "./utils";
@@ -148,11 +139,9 @@ describe("Dataworker: Execute relayer refunds", async function () {
148139
});
149140
describe("Computing refunds for bundles", function () {
150141
let relayer: SignerWithAddress;
151-
let bundleDataClient: BundleDataClient;
152142

153143
beforeEach(async function () {
154144
relayer = depositor;
155-
bundleDataClient = dataworkerInstance.clients.bundleDataClient;
156145
await updateAllClients();
157146

158147
const deposit1 = await depositV3(
@@ -172,169 +161,5 @@ describe("Dataworker: Execute relayer refunds", async function () {
172161

173162
await updateAllClients();
174163
});
175-
it("No validated bundle refunds", async function () {
176-
// Propose a bundle:
177-
await dataworkerInstance.proposeRootBundle(spokePoolClients);
178-
await multiCallerClient.executeTxnQueues();
179-
await updateAllClients();
180-
181-
// No bundle is validated so no refunds.
182-
const refunds = await bundleDataClient.getPendingRefundsFromValidBundles();
183-
expect(
184-
bundleDataClient.getTotalRefund(
185-
refunds,
186-
EvmAddress.from(relayer.address),
187-
destinationChainId,
188-
toAddressType(erc20_2.address, destinationChainId)
189-
)
190-
).to.equal(toBN(0));
191-
});
192-
it("Get refunds from validated bundles", async function () {
193-
await updateAllClients();
194-
// Propose a bundle:
195-
await dataworkerInstance.proposeRootBundle(spokePoolClients);
196-
await multiCallerClient.executeTxnQueues();
197-
198-
// Advance time and execute leaves:
199-
await hubPool.setCurrentTime(Number(await hubPool.getCurrentTime()) + Number(await hubPool.liveness()) + 1);
200-
await updateAllClients();
201-
await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, await getNewBalanceAllocator());
202-
await multiCallerClient.executeTxnQueues();
203-
204-
// Before relayer refund leaves are not executed, should have pending refunds:
205-
await updateAllClients();
206-
const validatedRootBundles = hubPoolClient.getValidatedRootBundles();
207-
expect(validatedRootBundles.length).to.equal(1);
208-
const refunds = await bundleDataClient.getPendingRefundsFromValidBundles();
209-
const totalRefund1 = bundleDataClient.getTotalRefund(
210-
refunds,
211-
toAddressType(relayer.address, destinationChainId),
212-
destinationChainId,
213-
toAddressType(erc20_2.address, destinationChainId)
214-
);
215-
expect(totalRefund1).to.gt(0);
216-
217-
// Test edge cases of `getTotalRefund` that should return BN(0)
218-
expect(
219-
bundleDataClient.getTotalRefund(
220-
refunds,
221-
toAddressType(relayer.address, repaymentChainId),
222-
repaymentChainId,
223-
toAddressType(erc20_2.address, repaymentChainId)
224-
)
225-
).to.equal(toBN(0));
226-
expect(
227-
bundleDataClient.getTotalRefund(
228-
refunds,
229-
toAddressType(relayer.address, destinationChainId),
230-
destinationChainId,
231-
toAddressType(erc20_1.address, destinationChainId)
232-
)
233-
).to.equal(toBN(0));
234-
235-
// Manually relay the roots to spoke pools since adapter is a dummy and won't actually relay messages.
236-
const rootBundle = validatedRootBundles[0];
237-
await spokePool_1.relayRootBundle(rootBundle.relayerRefundRoot, rootBundle.slowRelayRoot);
238-
await spokePool_2.relayRootBundle(rootBundle.relayerRefundRoot, rootBundle.slowRelayRoot);
239-
await updateAllClients();
240-
241-
// Execute relayer refund leaves. Send funds to spoke pools to execute the leaves.
242-
await erc20_2.mint(spokePool_2.address, amountToDeposit);
243-
await dataworkerInstance.executeRelayerRefundLeaves(spokePoolClients, await getNewBalanceAllocator());
244-
await multiCallerClient.executeTxnQueues();
245-
246-
// Should now have zero pending refunds
247-
await updateAllClients();
248-
// If we call `getPendingRefundsFromLatestBundle` multiple times, there should be no error. If there is an error,
249-
// then it means that `getPendingRefundsFromLatestBundle` is mutating the return value of `.loadData` which is
250-
// stored in the bundle data client's cache. `getPendingRefundsFromLatestBundle` should instead be using a
251-
// deep cloned copy of `.loadData`'s output.
252-
await bundleDataClient.getPendingRefundsFromValidBundles();
253-
const postExecutionRefunds = await bundleDataClient.getPendingRefundsFromValidBundles();
254-
expect(
255-
bundleDataClient.getTotalRefund(
256-
postExecutionRefunds,
257-
toAddressType(relayer.address, destinationChainId),
258-
destinationChainId,
259-
toAddressType(erc20_2.address, destinationChainId)
260-
)
261-
).to.equal(toBN(0));
262-
263-
// Submit fill2 and propose another bundle:
264-
const newDepositAmount = amountToDeposit.mul(2);
265-
const deposit2 = await depositV3(
266-
spokePool_1,
267-
destinationChainId,
268-
depositor,
269-
erc20_1.address,
270-
newDepositAmount,
271-
erc20_2.address,
272-
amountToDeposit
273-
);
274-
await updateAllClients();
275-
276-
// Submit a valid fill.
277-
await fillV3Relay(spokePool_2, deposit2, relayer, destinationChainId);
278-
await updateAllClients();
279-
280-
// Validate another bundle:
281-
await dataworkerInstance.proposeRootBundle(spokePoolClients);
282-
await multiCallerClient.executeTxnQueues();
283-
await hubPool.setCurrentTime(Number(await hubPool.getCurrentTime()) + Number(await hubPool.liveness()) + 1);
284-
await updateAllClients();
285-
await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, await getNewBalanceAllocator());
286-
await multiCallerClient.executeTxnQueues();
287-
await updateAllClients();
288-
289-
expect(hubPoolClient.getValidatedRootBundles().length).to.equal(2);
290-
291-
// Should include refunds for most recently validated bundle but not count first one
292-
// since they were already refunded.
293-
const refunds2 = await bundleDataClient.getPendingRefundsFromValidBundles();
294-
expect(
295-
bundleDataClient.getTotalRefund(
296-
refunds2,
297-
toAddressType(relayer.address, destinationChainId),
298-
destinationChainId,
299-
toAddressType(erc20_2.address, destinationChainId)
300-
)
301-
).to.gt(0);
302-
});
303-
it("Refunds in next bundle", async function () {
304-
// Before proposal should show refunds:
305-
expect(
306-
bundleDataClient.getRefundsFor(
307-
(await bundleDataClient.getNextBundleRefunds())[0],
308-
toAddressType(relayer.address, destinationChainId),
309-
destinationChainId,
310-
toAddressType(erc20_2.address, destinationChainId)
311-
)
312-
).to.gt(0);
313-
314-
// Propose a bundle:
315-
await dataworkerInstance.proposeRootBundle(spokePoolClients);
316-
await multiCallerClient.executeTxnQueues();
317-
await updateAllClients();
318-
319-
// After proposal but before execution should show upcoming refund:
320-
expect(
321-
bundleDataClient.getRefundsFor(
322-
(await bundleDataClient.getNextBundleRefunds())[0],
323-
toAddressType(relayer.address, destinationChainId),
324-
destinationChainId,
325-
toAddressType(erc20_2.address, destinationChainId)
326-
)
327-
).to.gt(0);
328-
329-
// Advance time and execute root bundle:
330-
await hubPool.setCurrentTime(Number(await hubPool.getCurrentTime()) + Number(await hubPool.liveness()) + 1);
331-
await updateAllClients();
332-
await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, await getNewBalanceAllocator());
333-
await multiCallerClient.executeTxnQueues();
334-
335-
// Should reset to no refunds in "next bundle", though these will show up in pending bundle.
336-
await updateAllClients();
337-
expect(await bundleDataClient.getNextBundleRefunds()).to.deep.equal([{}]);
338-
});
339164
});
340165
});

test/Dataworker.loadData.deposit.ts

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { BundleDataClient, ConfigStoreClient, HubPoolClient, SpokePoolClient } from "../src/clients";
2-
import { amountToDeposit, destinationChainId, originChainId, repaymentChainId } from "./constants";
2+
import { destinationChainId, originChainId, repaymentChainId } from "./constants";
33
import { DataworkerConfig, setupDataworker } from "./fixtures/Dataworker.Fixture";
44
import {
55
Contract,
66
FakeContract,
77
SignerWithAddress,
88
V3FillFromDeposit,
9-
depositV3,
109
ethers,
1110
expect,
1211
getDefaultBlockRange,
@@ -21,11 +20,11 @@ import { getCurrentTime, toBNWei, ZERO_ADDRESS, BigNumber, bnZero, toAddressType
2120
import { MockHubPoolClient, MockSpokePoolClient } from "./mocks";
2221
import { interfaces, utils as sdkUtils } from "@across-protocol/sdk";
2322

24-
let spokePool_1: Contract, erc20_1: Contract, spokePool_2: Contract, erc20_2: Contract;
23+
let erc20_1: Contract, erc20_2: Contract;
2524
let l1Token_1: Contract;
26-
let depositor: SignerWithAddress, relayer: SignerWithAddress;
25+
let relayer: SignerWithAddress;
2726

28-
let spokePoolClient_1: SpokePoolClient, spokePoolClient_2: SpokePoolClient, bundleDataClient: BundleDataClient;
27+
let spokePoolClient_1: SpokePoolClient, spokePoolClient_2: SpokePoolClient;
2928
let hubPoolClient: HubPoolClient, configStoreClient: ConfigStoreClient;
3029
let dataworkerInstance: Dataworker;
3130
let spokePoolClients: { [chainId: number]: SpokePoolClient };
@@ -38,14 +37,11 @@ let updateAllClients: () => Promise<void>;
3837
describe("Dataworker: Load bundle data", async function () {
3938
beforeEach(async function () {
4039
({
41-
spokePool_1,
4240
erc20_1,
43-
spokePool_2,
4441
erc20_2,
4542
configStoreClient,
4643
hubPoolClient,
4744
l1Token_1,
48-
depositor,
4945
relayer,
5046
dataworkerInstance,
5147
spokePoolClient_1,
@@ -54,7 +50,6 @@ describe("Dataworker: Load bundle data", async function () {
5450
updateAllClients,
5551
spy,
5652
} = await setupDataworker(ethers, 25, 25, 0));
57-
bundleDataClient = dataworkerInstance.clients.bundleDataClient;
5853
});
5954

6055
describe("Computing bundle deposits and expired deposits to refund", function () {
@@ -558,71 +553,4 @@ describe("Dataworker: Load bundle data", async function () {
558553
expect(data1.bundleFillsV3[repaymentChainId][toBytes32(l1Token_1.address)].fills.length).to.equal(1);
559554
});
560555
});
561-
562-
describe("Miscellaneous functions", function () {
563-
it("getUpcomingDepositAmount", async function () {
564-
// Send two deposits on different chains
565-
await depositV3(
566-
spokePool_1,
567-
destinationChainId,
568-
depositor,
569-
erc20_1.address,
570-
amountToDeposit,
571-
ZERO_ADDRESS,
572-
amountToDeposit
573-
);
574-
await depositV3(
575-
spokePool_2,
576-
originChainId,
577-
depositor,
578-
erc20_2.address,
579-
amountToDeposit,
580-
ZERO_ADDRESS,
581-
amountToDeposit
582-
);
583-
await updateAllClients();
584-
expect(
585-
await bundleDataClient.getUpcomingDepositAmount(originChainId, toAddressType(erc20_1.address, originChainId), 0)
586-
).to.equal(amountToDeposit);
587-
expect(
588-
await bundleDataClient.getUpcomingDepositAmount(
589-
destinationChainId,
590-
toAddressType(erc20_2.address, destinationChainId),
591-
0
592-
)
593-
).to.equal(amountToDeposit);
594-
595-
// Removes deposits using block, token, and chain filters.
596-
expect(
597-
await bundleDataClient.getUpcomingDepositAmount(
598-
originChainId,
599-
toAddressType(erc20_1.address, originChainId),
600-
spokePoolClient_1.latestHeightSearched // block higher than the deposit
601-
)
602-
).to.equal(0);
603-
expect(
604-
await bundleDataClient.getUpcomingDepositAmount(
605-
originChainId,
606-
toAddressType(erc20_2.address, originChainId), // diff token
607-
0
608-
)
609-
).to.equal(0);
610-
expect(
611-
await bundleDataClient.getUpcomingDepositAmount(
612-
destinationChainId, // diff chain
613-
toAddressType(erc20_1.address, destinationChainId),
614-
0
615-
)
616-
).to.equal(0);
617-
618-
// spoke pool client for chain not defined
619-
expect(
620-
await bundleDataClient.getUpcomingDepositAmount(
621-
originChainId + destinationChainId + repaymentChainId + 1, // spoke pool client for chain is not defined in BundleDataClient
622-
toAddressType(erc20_1.address, originChainId),
623-
0
624-
)
625-
).to.equal(0);
626-
});
627-
});
628556
});

0 commit comments

Comments
 (0)