Files
pezkuwi-subxt/bridges/snowbridge
Vincent Geddes 22d5b80d44 Add a linear fee multiplier (#127) (#3790)
Bridging fees are calculated using a static ETH/DOT exchange rate that
can deviate significantly from the real-world exchange rate. We
therefore need to add a safety margin to the fee so that users almost
aways cover the cost of relaying.

# FAQ

> Why introduce a `multiplier` parameter instead of configuring an
exchange rate which already has a safety factor applied?

When converting from ETH to DOT, we need to _divide_ the multiplier by
the exchange rate, and to convert from DOT to ETH we need to _multiply_
the multiplier by the exchange rate.

> Other input parameters to the fee calculation can also deviate from
real-world values. These include substrate weights, gas prices, and so
on. Why does the multiplier introduced here not adjust those?

A single scalar multiplier won't be able to accommodate the different
volatilities efficiently. For example, gas prices are much more volatile
than exchange rates, and substrate weights hardly ever change.

So the pricing config relating to weights and gas prices should already
have some appropriate safety margin pre-applied.

# Detailed Changes:

* Added `multiplier` field to `PricingParameters`
* Outbound-queue fee is multiplied by `multiplier`
* This `multiplier` is synced to the Ethereum side
* Improved Runtime API for calculating outbound-queue fees. This API
makes it much easier to for configure parts of the system in preparation
for launch.
* Improve and clarify code documentation

Upstreamed from https://github.com/Snowfork/polkadot-sdk/pull/127

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
2024-03-22 11:52:51 +00:00
..

Snowbridge ·

codecov GitHub

Snowbridge is a trustless bridge between Polkadot and Ethereum. For documentation, visit https://docs.snowbridge.network.

Components

The Snowbridge project lives in two repositories:

Parachain

Polkadot parachain and our pallets. See README.md.

Contracts

Ethereum contracts and unit tests. See Snowfork/snowbridge/contracts/README.md

Relayer

Off-chain relayer services for relaying messages between Polkadot and Ethereum. See Snowfork/snowbridge/relayer/README.md

Local Testnet

Scripts to provision a local testnet, running the above services to bridge between local deployments of Polkadot and Ethereum. See Snowfork/snowbridge/web/packages/test/README.md.

Smoke Tests

Integration tests for our local testnet. See Snowfork/snowbridge/smoketest/README.md.

Development

We use the Nix package manager to provide a reproducible and maintainable developer environment.

After installing nix Nix, enable flakes:

mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf

Then activate a developer shell in the root of our repo, where flake.nix is located:

nix develop

Also make sure to run this initialization script once:

scripts/init.sh

Support for code editors

To ensure your code editor (such as VS Code) can execute tools in the nix shell, startup your editor within the interactive shell.

Example for VS Code:

nix develop
code .

Custom shells

The developer shell is bash by default. To preserve your existing shell:

nix develop --command $SHELL

Automatic developer shells

To automatically enter the developer shell whenever you open the project, install direnv and use the template .envrc:

cp .envrc.example .envrc
direnv allow

Upgrading the Rust toolchain

Sometimes we would like to upgrade rust toolchain. First update rust-toolchain.toml as required and then update flake.lock running

nix flake lock --update-input rust-overlay

Troubleshooting

Check the contents of all .envrc files.

Remove untracked files:

git clean -idx

Ensure that the current Rust toolchain is the one selected in scripts/init.sh.

Ensure submodules are up-to-date:

git submodule update

Check untracked files & directories:

git clean -ndx | awk '{print $3}'

After removing node_modules directories (eg. with git clean above), clear the pnpm cache:

pnpm store prune

Check Nix config in ~/.config/nix/nix.conf.

Run a pure developer shell (note that this removes access to your local tools):

nix develop -i --pure-eval

Security

The security policy and procedures can be found in SECURITY.md.