Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Dataworker): Account for total required netSendAmount when executing PoolRebalanceLeaves #1933

Merged
merged 68 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
acc6c2f
fix(Dataworker): Update balanceAllocator properly when executing Pool…
nicholaspai Nov 28, 2024
204a028
fix issue
nicholaspai Nov 28, 2024
23c4429
Update Dataworker.executePoolRebalances.ts
nicholaspai Nov 28, 2024
8b193c0
Add more test cases
nicholaspai Nov 28, 2024
1ce5b37
Update Dataworker.executePoolRebalances.ts
nicholaspai Nov 28, 2024
088b8ac
Update Monitor.ts
nicholaspai Nov 29, 2024
0282f30
comment on tests
nicholaspai Nov 29, 2024
10c401b
make test better
nicholaspai Nov 29, 2024
f7a7e1b
Add orbit-fee handling, remove balance allocator
nicholaspai Nov 30, 2024
b9f4e19
Fix balanceAllocator call in _executePoolRebalanceLeaves
nicholaspai Nov 30, 2024
ffacd57
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Nov 30, 2024
83f2b62
throw error if can't fund the DonationBox or loadEthForL2Calls call
nicholaspai Dec 1, 2024
4d5ba26
add lifecycle test
nicholaspai Dec 1, 2024
870334a
Exit early if aggregate net send amount == 0
nicholaspai Dec 1, 2024
f441505
Update Dataworker.executePoolRebalances.ts
nicholaspai Dec 1, 2024
299b3d0
Update log in _updateExchangeRatesBeforeExecutingNonHubChainLeaves wh…
nicholaspai Dec 1, 2024
bf79501
Update Dataworker.ts
nicholaspai Dec 1, 2024
b6e44de
Fund more AZERO whenever we're short
nicholaspai Dec 2, 2024
29515c8
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 2, 2024
81228ca
remove hardcodes
nicholaspai Dec 3, 2024
0e889a3
Improve logs about lookback window being too short
nicholaspai Dec 3, 2024
df6d9ea
Improve logs on funding orbit chain message
nicholaspai Dec 4, 2024
086d806
Update Dataworker.customSpokePoolClients.ts
nicholaspai Dec 4, 2024
7960fff
Update index.ts
nicholaspai Dec 4, 2024
ea0cb15
Update index.ts
nicholaspai Dec 4, 2024
51dd6c3
Add invariant unit test
nicholaspai Dec 4, 2024
6fd902e
Remove l1 tokens with 0 net send amounts from _updateOldExchangeRates
nicholaspai Dec 4, 2024
42d0144
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 5, 2024
1b6da03
Rename to amountWei
nicholaspai Dec 5, 2024
a638412
Refactor blockRangesAreInvalid to internal helper func
nicholaspai Dec 5, 2024
a22ddf7
Squash feeData
nicholaspai Dec 5, 2024
5c673e0
Update src/dataworker/Dataworker.ts
nicholaspai Dec 5, 2024
d70588d
Update src/dataworker/Dataworker.ts
nicholaspai Dec 5, 2024
2907278
Update src/dataworker/Dataworker.ts
nicholaspai Dec 5, 2024
770738f
result
nicholaspai Dec 5, 2024
6cd1687
Add unit testing about exiting early if leaves are already executed
nicholaspai Dec 5, 2024
41a2aae
Add ability for some nonHubChain leaves to be executed even if they a…
nicholaspai Dec 5, 2024
11b7d95
Skip mainnet leaf execution if we cannot execute instead of throwing
nicholaspai Dec 5, 2024
6c5e5c9
Skip sync in _updateExchangeRatesBeforeExecutingNonHubChainLeaves if …
nicholaspai Dec 5, 2024
1115567
refactor block range pretty printing
nicholaspai Dec 5, 2024
4bbafd8
update comments
nicholaspai Dec 5, 2024
468c26f
Add assert error messages
nicholaspai Dec 6, 2024
e2a4784
Add _getSpokeBalanceForL2Tokens helper and add to logs
nicholaspai Dec 6, 2024
630cafc
Re-add balance allocator
nicholaspai Dec 6, 2024
46d918e
Update Dataworker.executeRelayerRefunds.ts
nicholaspai Dec 6, 2024
7f8b359
Update Dataworker.ts
nicholaspai Dec 6, 2024
9fb8403
Remove canExecute return value from _updateExchangeRatesBeforeExecut…
nicholaspai Dec 6, 2024
7fd746b
Update Dataworker.executePoolRebalances.ts
nicholaspai Dec 6, 2024
7e0badd
Update Dataworker.executePoolRebalances.ts
nicholaspai Dec 6, 2024
0ee996d
Refactor error log
nicholaspai Dec 6, 2024
8ba187d
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 6, 2024
59546dd
Clean up logs
nicholaspai Dec 6, 2024
72812d2
Consider state of liquid reserves following eth pool rebalance leaf e…
nicholaspai Dec 6, 2024
bee015b
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 6, 2024
c993e07
Improve tests
nicholaspai Dec 6, 2024
8555b98
Update name
nicholaspai Dec 6, 2024
0f8ddd2
Add unit test, split executePoolRebalanceLeaf tests in two files to t…
nicholaspai Dec 6, 2024
6821b2d
Remove SIMULATE_L1_EXECUTION
nicholaspai Dec 6, 2024
7605451
Add test for amountToReturn
nicholaspai Dec 7, 2024
2846314
add tests
nicholaspai Dec 7, 2024
b0b59ef
Add test about hub chain slow fill leaves
nicholaspai Dec 8, 2024
34fb02e
Update BalanceAllocator.ts
nicholaspai Dec 9, 2024
6ff2e40
Update Dataworker.ts
nicholaspai Dec 9, 2024
2bf6973
change blockRangesAreInvalidForSpokeClients to return list of chain I…
nicholaspai Dec 9, 2024
3922adb
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 10, 2024
18f7e3f
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 10, 2024
eeef8bf
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 16, 2024
6f3b74c
Merge branch 'master' into dataworker-executor-l1-sync
nicholaspai Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/clients/BalanceAllocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export class BalanceAllocator {
return this.requestBalanceAllocations([{ chainId, tokens, holder, amount }]);
}

async getBalanceSubUsed(chainId: number, token: string, holder: string): Promise<BigNumber> {
const balance = await this.getBalance(chainId, token, holder);
const used = this.getUsed(chainId, token, holder);
return balance.sub(used);
}

async getBalance(chainId: number, token: string, holder: string): Promise<BigNumber> {
if (!this.balances?.[chainId]?.[token]?.[holder]) {
const balance = await this._queryBalance(chainId, token, holder);
Expand All @@ -114,6 +120,12 @@ export class BalanceAllocator {
return this.balances[chainId][token][holder];
}

testSetBalance(chainId: number, token: string, holder: string, balance: BigNumber): void {
this.balances[chainId] ??= {};
this.balances[chainId][token] ??= {};
this.balances[chainId][token][holder] = balance;
}

getUsed(chainId: number, token: string, holder: string): BigNumber {
if (!this.used?.[chainId]?.[token]?.[holder]) {
// Note: cannot use assign because it breaks the BigNumber object.
Expand Down
28 changes: 28 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,31 @@ export const DEFAULT_GAS_MULTIPLIER: { [chainId: number]: number } = {
};

export const CONSERVATIVE_BUNDLE_FREQUENCY_SECONDS = 3 * 60 * 60; // 3 hours is a safe assumption for the time

export const ARBITRUM_ORBIT_L1L2_MESSAGE_FEE_DATA: {
[chainId: number]: {
// Amount of tokens required to send a single message to the L2
amountWei: number;
// Multiple of the required amount above to send to the feePayer in case
// we are short funds. For example, if set to 10, then everytime we need to load more funds
// we'll send 10x the required amount.
amountMultipleToFund: number;
// Account that pays the fees on-chain that we will load more fee tokens into.
feePayer?: string;
// Token that the feePayer will pay the fees in.
feeToken?: string;
};
} = {
// Leave feePayer undefined if feePayer is HubPool.
// Leave feeToken undefined if feeToken is ETH.
[CHAIN_IDs.ARBITRUM]: {
amountWei: 0.02,
amountMultipleToFund: 1,
},
[CHAIN_IDs.ALEPH_ZERO]: {
amountWei: 0.49,
amountMultipleToFund: 20,
feePayer: "0x0d57392895Db5aF3280e9223323e20F3951E81B1", // DonationBox
feeToken: TOKEN_SYMBOLS_MAP.AZERO.addresses[CHAIN_IDs.MAINNET],
},
};
Loading
Loading