Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f364999
Benchmark beefy by signatures
yrong Apr 18, 2025
6d17159
More samples
yrong Apr 18, 2025
aeef3a2
Cleanup
yrong Apr 23, 2025
e3734b3
SubmitFiatShamir
yrong Apr 25, 2025
2d55aa0
Add CreateFiatShamirFinalBitfield
yrong Apr 25, 2025
5bea664
Make requiredSignatures bounded
yrong Apr 28, 2025
f2ed8d2
Beefy relayer
yrong Apr 28, 2025
4f978c0
Cleanup
yrong Apr 28, 2025
bb5c9d2
Merge branch 'ron/benchmark-beefy-by-signatures' into ron/submitFiatS…
yrong Apr 30, 2025
a61d4ca
Generate test fixture
yrong Apr 30, 2025
a34b83d
Merge branch 'main' into ron/benchmark-beefy-by-signatures
yrong Apr 30, 2025
1458b8c
Merge branch 'ron/benchmark-beefy-by-signatures' into ron/submitFiatS…
yrong Apr 30, 2025
e48f5c4
testSubmitFiatShamirWithHandOver
yrong May 2, 2025
afc04c1
Fix compile error
yrong May 2, 2025
ec230b8
Use sha256 as hash function
yrong May 6, 2025
9da095f
Update test fixture
yrong May 6, 2025
e277eb7
Update quorum function
yrong May 6, 2025
b94851e
Switch to sha256d
yrong May 11, 2025
dcc7588
Initialize fiatShamirRequiredSignatures via the constructor
yrong May 11, 2025
b844164
Add an environment variable for local setup
yrong May 12, 2025
98b57d1
Merge branch 'main' into ron/submitFiatShamir
yrong Sep 8, 2025
042e546
Update contract binding
yrong Sep 8, 2025
2aeb930
Submit FiatShamir on demand
yrong Sep 8, 2025
b7ffc9e
Check for outdated commitments in the two-phase commit
yrong Sep 9, 2025
adf074a
Add an option to accelerate the transfer
yrong Sep 10, 2025
ee36155
Merge branch 'main' into ron/submitFiatShamir
yrong Sep 10, 2025
3e62355
Merge branch 'ron/submitFiatShamir' into ron/submitFiatShamir-fe
yrong Sep 10, 2025
13c608b
Merge branch 'main' into ron/submitFiatShamir-fe
yrong Mar 26, 2026
a18f6e4
Revert unrelated
yrong Mar 26, 2026
ed1aba2
Fix fee calculation
yrong Mar 26, 2026
6bd2448
Fee default
yrong Mar 26, 2026
63e7551
Cleanup
yrong Mar 26, 2026
1d43bfd
Merge branch 'main' into ron/submitFiatShamir-fe
yrong Apr 1, 2026
f311d11
Revamped fees
yrong Apr 1, 2026
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
28 changes: 20 additions & 8 deletions web/packages/api/src/toEthereumSnowbridgeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,29 @@ export const estimateEthereumExecutionFee = async (
options?: {
contractCall?: ContractCall
fillDeadlineBuffer?: bigint
accelerated?: boolean
},
): Promise<bigint> => {
const ethereum = await context.ethereum()
const { tokenErcMetadata } = resolveInputs(registry, tokenAddress, sourceParaId)

// Calculate execution cost on ethereum
let ethereumChain = registry.ethereumChains[`ethereum_${registry.ethChainId}`]
let feeData = await ethereum.getFeeData()
let ethereumExecutionFee =
(feeData.gasPrice ?? 2_000_000_000n) *
((tokenErcMetadata.deliveryGas ?? 80_000n) +
(ethereumChain.baseDeliveryGas ?? 120_000n) +
(options?.contractCall?.gas ?? 0n))
// Calculate execution cost on ethereum including:
// 1. the consensus update, which is the fiat-shamir submit (if accelerated) or two phase submit if not.
// 2. message verification, token delivery and the optional contract call.
const ethereumChain = registry.ethereumChains[`ethereum_${registry.ethChainId}`]
const feeData = await ethereum.getFeeData()
const gasPrice = feeData.gasPrice ?? 2_000_000_000n
const twoPhaseSubmitGas = ethereumChain.twoPhaseSubmitGas ?? 1_000_000n
const submitFiatShamirGas = options?.accelerated
? (ethereumChain.submitFiatShamirGas ?? 2_200_000n)
: 0n
const consensusUpdateGas = options?.accelerated ? submitFiatShamirGas : twoPhaseSubmitGas
const messageVerificationGas = ethereumChain.baseDeliveryGas ?? 120_000n
const tokenDeliveryGas = tokenErcMetadata.deliveryGas ?? 200_000n
const contractCallGas = options?.contractCall?.gas ?? 0n
const totalGas =
consensusUpdateGas + messageVerificationGas + tokenDeliveryGas + contractCallGas
const ethereumExecutionFee = gasPrice * totalGas
return ethereumExecutionFee
}

Expand All @@ -270,6 +280,7 @@ export const estimateFeesFromAssetHub = async (
l2PadFeeByPercentage?: bigint
l2TransferGasLimit?: bigint
fillDeadlineBuffer?: bigint
accelerated?: boolean
},
l2ChainId?: number,
tokenAmount?: bigint,
Expand Down Expand Up @@ -391,6 +402,7 @@ export const estimateFeesFromParachains = async (
defaultFee?: bigint
feeTokenLocation?: any
contractCall?: ContractCall
accelerated?: boolean
},
): Promise<DeliveryFee> => {
const sourceParachain = registry.parachains[`polkadot_${sourceParaId}`]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class ERC20FromParachain implements TransferInterface {
feeTokenLocation?: any
claimerLocation?: any
contractCall?: ContractCall
accelerated?: boolean
},
): Promise<DeliveryFee> {
const { assetHub, parachain } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface TransferInterface {
feeTokenLocation?: any
claimerLocation?: any
contractCall?: ContractCall
accelerated?: boolean
},
): Promise<DeliveryFee>

Expand Down
4 changes: 4 additions & 0 deletions web/packages/base-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type EthereumChain = ChainId & {
xcTokenMap?: XC20TokenMap;
// The gas cost of v2_submit excludes command execution, mainly covers the verification.
baseDeliveryGas?: bigint;
// The gas cost of the two phase submit (submitInitial + commitPrevRandao + submitFinal)
twoPhaseSubmitGas?: bigint;
// The gas cost of submitFiatShamir
submitFiatShamirGas?: bigint;
};

export type ChainProperties = {
Expand Down
11 changes: 6 additions & 5 deletions web/packages/registry/scripts/buildRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ const SNOWBRIDGE_ENV: { [env: string]: Environment } = {
assetHubParaId: 1000,
bridgeHubParaId: 1002,
v2_parachains: [1000],
indexerGraphQlUrl:
"https://subsquid.snowbridge.network/graphql",
indexerGraphQlUrl: "https://subsquid.snowbridge.network/graphql",
kusama: {
assetHubParaId: 1000,
bridgeHubParaId: 1002,
Expand Down Expand Up @@ -972,8 +971,8 @@ async function indexEthChain(
? foreignId
: undefined,
// LDO gas from https://etherscan.io/tx/0x4e984250beacf693e7407c6cfdcb51229f6a549aa857d601db868b572ee2364b
// Other ERC20 token transfer on Ethereum typically ranges from 45,000 to 65,000 gas units; use 80_000 to leave a margin
deliveryGas: asset.symbol == "LDO" ? 150_000n : 80_000n,
// Other ERC20 token transfer on Ethereum typically ranges from 45,000 to 65,000 gas units; use 120_000 to leave a margin
deliveryGas: asset.symbol == "LDO" ? 200_000n : 120_000n,
}
}
if (token in metadataOverrides) {
Expand Down Expand Up @@ -1002,6 +1001,8 @@ async function indexEthChain(
assets,
key: `ethereum_${networkChainId}`,
baseDeliveryGas: 120_000n,
twoPhaseSubmitGas: 1_000_000n,
submitFiatShamirGas: 2_200_000n,
}
} else if (networkChainId in l2Chains) {
const assets: ERC20MetadataMap = {}
Expand Down Expand Up @@ -1175,7 +1176,7 @@ async function getRegisteredPnas(
}

;(async () => {
let env = "local_e2e"
let env = "polkadot_mainnet"
if (process.env.NODE_ENV !== undefined) {
env = process.env.NODE_ENV
}
Expand Down
Loading
Loading