Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"deposit": "yarn ts-node ./scripts/spokepool.ts deposit",
"dispute": "yarn ts-node ./scripts/hubpool.ts dispute",
"update": "git pull && yarn reinstall && yarn version --non-interactive && git show --quiet",
"update-addresses": "yarn ts-node ./scripts/fetch-addresses.ts"
"update-addresses": "yarn ts-node ./scripts/fetch-addresses.ts",
"validate-root-bundle": "yarn ts-node src/scripts/validateRootBundle.ts"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",
Expand Down
22 changes: 11 additions & 11 deletions src/adapter/BaseChainAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ export class BaseChainAdapter {

if (unavailableTokens.length > 0) {
this.log("Some tokens do not have a bridge contract for L2 -> L1 bridging", {
unavailableTokens: unavailableTokens.map((token) => token.toNative()),
unavailableTokens,
});
}

if (tokensToApprove.length === 0) {
this.log("No L2 token bridge approvals needed", { l1Tokens: l1Tokens.map((token) => token.toNative()) });
this.log("No L2 token bridge approvals needed", { l1Tokens });
return;
}

Expand Down Expand Up @@ -254,11 +254,11 @@ export class BaseChainAdapter {
.filter(({ bridges }) => bridges.length > 0);
if (unavailableTokens.length > 0) {
this.log("Some tokens do not have a bridge contract", {
unavailableTokens: unavailableTokens.map((token) => token.toNative()),
unavailableTokens,
});
}
if (tokensToApprove.length === 0) {
this.log("No token bridge approvals needed", { l1Tokens: l1Tokens.map((token) => token.toNative()) });
this.log("No token bridge approvals needed", { l1Tokens });
return;
}
const mrkdwn = await approveTokens(tokensToApprove, this.chainId, this.hubChainId, this.logger);
Expand Down Expand Up @@ -288,8 +288,8 @@ export class BaseChainAdapter {
"Failed to constructWithdrawToL1Txns",
{
toAddress: address,
l2Token: l2Token.toNative(),
l1Token: l1Token.toNative(),
l2Token: l2Token,
l1Token: l1Token,
amount: amount.toString(),
srcChainId: this.chainId,
dstChainId: this.hubChainId,
Expand Down Expand Up @@ -351,9 +351,9 @@ export class BaseChainAdapter {
this.log(
"Failed to construct L1 to L2 transaction",
{
address: address.toNative(),
l1Token: l1Token.toNative(),
l2Token: l2Token.toNative(),
address: address,
l1Token: l1Token,
l2Token: l2Token,
amount: amount.toString(),
srcChainId: this.hubChainId,
dstChainId: this.chainId,
Expand Down Expand Up @@ -388,8 +388,8 @@ export class BaseChainAdapter {
this.log(
message,
{
l1Token: l1Token.toNative(),
l2Token: l2Token.toNative(),
l1Token: l1Token,
l2Token: l2Token,
amount,
contract: contract.address,
txnRequestData,
Expand Down
20 changes: 4 additions & 16 deletions src/clients/InventoryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,8 @@ export class InventoryClient {
log({
at: "InventoryClient",
message,
l1Token: l1Token.toNative(),
l2Token: l2Token.toNative(),
l1Token,
l2Token,
l2ChainId: chainId,
balance,
currentBalance,
Expand All @@ -965,20 +965,8 @@ export class InventoryClient {
// Extract unexecutable rebalances for logging.

this.log("Considered inventory rebalances", {
rebalancesRequired: rebalancesRequired.map((rebalance) => {
return {
...rebalance,
l1Token: rebalance.l1Token.toNative(),
l2Token: rebalance.l2Token.toNative(),
};
}),
possibleRebalances: possibleRebalances.map((rebalance) => {
return {
...rebalance,
l1Token: rebalance.l1Token.toNative(),
l2Token: rebalance.l2Token.toNative(),
};
}),
rebalancesRequired,
possibleRebalances,
});

// Finally, execute the rebalances.
Expand Down
6 changes: 3 additions & 3 deletions src/clients/bridges/AdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class AdapterManager {
this.logger.debug({
at: "AdapterManager",
message: `Getting outstandingCrossChainTransfers for ${chainId}`,
adapterSupportedL1Tokens: adapterSupportedL1Tokens.map((l1Token) => l1Token.toNative()),
adapterSupportedL1Tokens,
searchConfigs: adapter.getUpdatedSearchConfigs(),
});
return this.adapters[chainId].getOutstandingCrossChainTransfers(adapterSupportedL1Tokens);
Expand All @@ -173,7 +173,7 @@ export class AdapterManager {
at: "AdapterManager",
message: "Sending token cross-chain",
chainId,
l1Token: l1Token.toNative(),
l1Token,
amount,
});
l2Token ??= this.l2TokenForL1Token(l1Token, chainId);
Expand All @@ -192,7 +192,7 @@ export class AdapterManager {
at: "AdapterManager",
message: "Withdrawing token from L2",
chainId,
l2Token: l2Token.toNative(),
l2Token,
amount,
});
const txnReceipts = this.adapters[chainId].withdrawTokenFromL2(address, l2Token, amount, simMode);
Expand Down
73 changes: 16 additions & 57 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,7 @@ export class Dataworker {
this.logger.debug({
at: "Dataworker#validate",
message: "Found pending proposal",
pendingRootBundle: {
...pendingRootBundle,
proposer: pendingRootBundle.proposer.toNative(),
},
pendingRootBundle,
});

// Exit early if challenge period timestamp has passed:
Expand Down Expand Up @@ -846,10 +843,7 @@ export class Dataworker {
this.logger.debug({
at: "Dataworker#validate",
message: "Empty pool rebalance root, submitting dispute",
rootBundle: {
...rootBundle,
proposer: rootBundle.proposer.toNative(),
},
rootBundle,
});
return {
valid: false,
Expand Down Expand Up @@ -1050,31 +1044,11 @@ export class Dataworker {
at: "Dataworker#validate",
message: "Unexpected pool rebalance root, submitting dispute",
expectedBlockRanges: blockRangesImpliedByBundleEndBlocks,
expectedPoolRebalanceLeaves: expectedPoolRebalanceRoot.leaves.map((leaf) => {
return {
...leaf,
l1Tokens: leaf.l1Tokens.map((l1Token) => l1Token.toNative()),
};
}),
expectedPoolRebalanceLeaves: expectedPoolRebalanceRoot.leaves,
expectedPoolRebalanceRoot: expectedPoolRebalanceRoot.tree.getHexRoot(),
expectedRelayerRefundLeaves: expectedRelayerRefundRoot.leaves.map((leaf) => {
return {
...leaf,
l2TokenAddress: leaf.l2TokenAddress.toNative(),
refundAddresses: leaf.refundAddresses.map((refundAddress) => refundAddress.toNative()),
};
}),
expectedRelayerRefundLeaves: expectedRelayerRefundRoot.leaves,
expectedRelayerRefundRoot: expectedRelayerRefundRoot.tree.getHexRoot(),
expectedSlowRelayLeaves: expectedSlowRelayRoot.leaves.map((leaf) => {
return {
...leaf,
depositor: leaf.relayData.depositor.toNative(),
recipient: leaf.relayData.recipient.toNative(),
inputToken: leaf.relayData.inputToken.toNative(),
outputToken: leaf.relayData.outputToken.toNative(),
exclusiveRelayer: leaf.relayData.exclusiveRelayer.toNative(),
};
}),
expectedSlowRelayLeaves: expectedSlowRelayRoot.leaves,
expectedSlowRelayRoot: expectedSlowRelayRoot.tree.getHexRoot(),
pendingRoot: rootBundle.poolRebalanceRoot,
pendingPoolRebalanceLeafCount: rootBundle.unclaimedPoolRebalanceLeafCount,
Expand Down Expand Up @@ -1323,7 +1297,7 @@ export class Dataworker {
this.logger.warn({
at: "Dataworker#_executeSlowFillLeaf",
message: "Ignoring slow fill.",
leafExecutionArgs: [depositor.toNative(), recipient.toNative()],
leafExecutionArgs: [depositor, recipient],
});
return false;
}
Expand Down Expand Up @@ -1404,7 +1378,7 @@ export class Dataworker {
depositId: slowFill.relayData.depositId,
fromChain: slowFill.relayData.originChainId,
chainId: destinationChainId,
token: outputToken.toNative(),
token: outputToken,
amount: outputAmount,
spokeBalance: await this._getSpokeBalanceForL2Tokens(
balanceAllocator,
Expand Down Expand Up @@ -1534,10 +1508,7 @@ export class Dataworker {
at: "Dataworker#executePoolRebalanceLeaves",
message: "Found pending proposal",
hubPoolCurrentTime: this.clients.hubPoolClient.currentTime,
pendingRootBundle: {
...pendingRootBundle,
proposer: pendingRootBundle.proposer.toNative(),
},
pendingRootBundle,
});

const nextBundleMainnetStartBlock = this.getNextHubChainBundleStartBlock();
Expand Down Expand Up @@ -1782,7 +1753,7 @@ export class Dataworker {
this.logger.error({
at: "Dataworker#_getExecutablePoolRebalanceLeaves",
message: `Not enough funds to execute pool rebalance leaf for chain ${leaf.chainId}`,
l1Tokens: leaf.l1Tokens.map((l1Token) => l1Token.toNative()),
l1Tokens: leaf.l1Tokens,
netSendAmounts: leaf.netSendAmounts,
});
}
Expand Down Expand Up @@ -1831,11 +1802,8 @@ export class Dataworker {
message: `Loading more orbit gas token to pay for L1->L2 message submission fees to ${getNetworkName(
leaf.chainId
)} 📨!`,
leaf: {
...leaf,
l1Tokens: leaf.l1Tokens.map((l1Token) => l1Token.toNative()),
},
feeToken: feeToken.toNative(),
leaf,
feeToken,
requiredAmount,
});
if (submitExecution) {
Expand Down Expand Up @@ -1883,7 +1851,7 @@ export class Dataworker {
message: `feePayer ${holder} has sufficient orbit gas token to pay for L1->L2 message submission fees to ${getNetworkName(
leaf.chainId
)}`,
feeToken: feeToken.toNative(),
feeToken,
requiredAmount,
feePayerBalance: await balanceAllocator.getBalanceSubUsed(hubPoolChainId, feeToken, holder),
});
Expand Down Expand Up @@ -1964,7 +1932,7 @@ export class Dataworker {
message: `Skipping exchange rate update for ${tokenSymbol} because current liquid reserves > netSendAmount for hubChain`,
currentLiquidReserves,
netSendAmount: netSendAmounts[idx],
l1Token: l1Token.toNative(),
l1Token,
});
updatedLiquidReserves[l1Token.toEvmAddress()] = currentLiquidReserves.sub(netSendAmounts[idx]);
return;
Expand Down Expand Up @@ -2206,7 +2174,7 @@ export class Dataworker {
lastUpdateTime: latestFeesCompoundedTime,
currentLiquidReserves,
updatedLiquidReserves,
l1Token: l1Token.toNative(),
l1Token,
});
if (submitExecution) {
this.clients.multiCallerClient.enqueueTransaction({
Expand Down Expand Up @@ -2640,12 +2608,7 @@ export class Dataworker {
key,
root: {
...this.rootCache[key],
leaves: this.rootCache[key].leaves.map((leaf) => {
return {
...leaf,
l1Tokens: leaf.l1Tokens.map((l1Token) => l1Token.toNative()),
};
}),
leaves: this.rootCache[key].leaves,
tree: this.rootCache[key].tree.getHexRoot(),
},
});
Expand Down Expand Up @@ -2899,11 +2862,7 @@ export class Dataworker {
this.logger.debug({
at: "Dataworker#executeRelayerRefundLeafSvm",
message: "Relayer refund leaf accounts",
leaf: {
...leaf,
l2TokenAddress: leaf.l2TokenAddress.toNative(),
refundAddresses: leaf.refundAddresses.map((address) => address.toNative()),
},
leaf,
rootBundleId,
eventAuthority,
statePda,
Expand Down
4 changes: 2 additions & 2 deletions src/dataworker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ export async function runDataworker(_logger: winston.Logger, baseSigner: Signer)
logger[startupLogLevel(config)]({
at: "Dataworker#index",
message: "Dataworker addresses",
evmAddress: tokenClient.relayerEvmAddress.toNative(),
svmAddress: tokenClient.relayerSvmAddress.toNative(),
evmAddress: tokenClient.relayerEvmAddress,
svmAddress: tokenClient.relayerSvmAddress,
});
await tokenClient.update();
// Run approval on hub pool.
Expand Down
4 changes: 2 additions & 2 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export class Relayer {
this.logger.debug({
at: "Relayer::init",
message: "Completed one-time init.",
relayerEvmAddress: this.relayerEvmAddress.toNative(),
relayerSvmAddress: tokenClient.relayerSvmAddress.toNative(),
relayerEvmAddress: this.relayerEvmAddress,
relayerSvmAddress: tokenClient.relayerSvmAddress,
});
}

Expand Down