Skip to content

Commit

Permalink
ETA adjustments (#672)
Browse files Browse the repository at this point in the history
* add 5 sec of padding to ETAs for guardian network

* raise Ethereum finality threshold
  • Loading branch information
artursapek committed Aug 14, 2024
1 parent 45f4376 commit cc33e75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions connect/src/protocols/cctp/cctpTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
import { circle, encoding, finality, toChain } from "@wormhole-foundation/sdk-base";
import { circle, encoding, finality, guardians, toChain } from "@wormhole-foundation/sdk-base";
import type {
Attestation,
AttestationId,
Expand Down Expand Up @@ -592,7 +592,7 @@ export namespace CircleTransfer {

// https://developers.circle.com/stablecoins/docs/required-block-confirmations
const eta =
srcChain.chain === "Polygon" ? 2_000 * 200 : finality.estimateFinalityTime(srcChain.chain);
(srcChain.chain === "Polygon" ? 2_000 * 200 : finality.estimateFinalityTime(srcChain.chain)) + guardians.guardianAttestationEta;
if (!transfer.automatic) {
return {
sourceToken: { token: srcToken, amount: transfer.amount },
Expand Down
4 changes: 2 additions & 2 deletions connect/src/protocols/tokenBridge/tokenTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
import { amount, encoding, finality, toChain as toChainName } from "@wormhole-foundation/sdk-base";
import { amount, encoding, finality, guardians, toChain as toChainName } from "@wormhole-foundation/sdk-base";
import type {
AttestationId,
AutomaticTokenBridge,
Expand Down Expand Up @@ -717,7 +717,7 @@ export namespace TokenTransfer {
const dstDecimals = await dstChain.getDecimals(dstToken.address);
const dstAmountReceivable = amount.scale(srcAmountTruncated, dstDecimals);

const eta = finality.estimateFinalityTime(srcChain.chain);
const eta = finality.estimateFinalityTime(srcChain.chain) + guardians.guardianAttestationEta;
if (!transfer.automatic) {
return {
sourceToken: {
Expand Down
2 changes: 1 addition & 1 deletion core/base/src/constants/finality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const safeThreshold = constMap(safeThresholds);
// Number of blocks before a transaction is considered "final"
const finalityThresholds = [
["Solana", 32],
["Ethereum", 64],
["Ethereum", 96],
["Bsc", 15],
// Checkpointed to L1 after ~512 blocks
["Optimism", 512],
Expand Down
4 changes: 4 additions & 0 deletions core/base/src/constants/guardians.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ export const guardianKeyToName = constMap(guardianKeyAndNameEntries, [1, [0, 2]]

export const devnetGuardianPrivateKey =
"cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0";

// Number of seconds we expect to wait for attestation
// Used for eta calculation in route code
export const guardianAttestationEta = 5;

0 comments on commit cc33e75

Please sign in to comment.