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

Arbitrary Bridge pool fee token types #1795

Merged
merged 65 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9ec1833
Add Eth whitelist storage keys
sug0 Jul 11, 2023
ed2afb2
Add Eth whitelist key tests
sug0 Jul 11, 2023
6ca25fd
Add non-usable tokens for Ethereum bridge protocol bookkeeping
sug0 Jul 11, 2023
5208f3d
Add a VP for NUT transfers
sug0 Jul 11, 2023
9c14b65
Test NUT VP
sug0 Jul 12, 2023
4901296
Trigger the NUT native VP
sug0 Jul 12, 2023
9b6df79
Update ethbridge-rs to v0.19.0
sug0 Jul 12, 2023
b932890
Add transfer to Ethereum kinds (ERC20 or NUT)
sug0 Jul 12, 2023
8297842
Mint NUTs upon receiving non-whitelisted assets or exceeding token caps
sug0 Jul 12, 2023
82320aa
Add helper fn to whitelist tokens in tests
sug0 Jul 12, 2023
1a70c4f
Fix unit tests requiring token whitelist checks
sug0 Jul 12, 2023
339e18a
Fix refunding and burning of NUTs
sug0 Jul 12, 2023
d115bb0
Rework DAI minting unit tests to account for NUTs
sug0 Jul 13, 2023
d26e983
Test burning NUTs
sug0 Jul 13, 2023
8de897d
Check NUT escrow in Bridge pool VP
sug0 Jul 14, 2023
a839866
Test NUTs in the Bridge pool
sug0 Jul 14, 2023
180c986
Add NUT cmdline flag for Bridge pool transfers
sug0 Jul 12, 2023
7732e24
Update ethbridge-rs to v0.20.0
sug0 Jul 13, 2023
92bb87f
Remove whitelist Ethereum events from the ledger
sug0 Jul 13, 2023
a1213c7
Add whitelisted ERC20 tokens to the genesis file
sug0 Jul 13, 2023
4777038
Update ethbridge-rs to v0.21.0
sug0 Jul 15, 2023
cde9503
Move ethbridge-rs deps to the workspace
sug0 Jul 31, 2023
20044d0
Add changelog entry for the Ethereum token whitelist
sug0 Jul 31, 2023
2ae23fb
Add helper methods to EthAssetMint
sug0 Aug 1, 2023
f1be3f9
Use EthAssetMint helper methods
sug0 Aug 1, 2023
6ef086f
Refactor redeem_native_token to use update::amount
sug0 Aug 1, 2023
f1bd957
Vet Ethereum bridge config of the native token
sug0 Aug 1, 2023
69037fb
Harden Bridge pool VP against wNAM NUT transfers
sug0 Aug 1, 2023
a26de50
Update wNAM supplies when acting on Ethereum events
sug0 Aug 1, 2023
c67a656
Allow null pre-balances during Bridge pool escrow checks
sug0 Aug 1, 2023
d3a4906
Flow control of NAM transferred to Ethereum
sug0 Aug 2, 2023
99fe477
Replace ERC20 supply RPC query with atomic read of all flow control data
sug0 Aug 2, 2023
2861e46
Refactor get_erc20_flow_control to use EthBridgeQueries
sug0 Aug 2, 2023
14556d7
Add test_wnam_doesnt_mint_nuts() unit test
sug0 Aug 2, 2023
7efe3c2
Fix test_wrapped_nam_not_burned() unit test
sug0 Aug 2, 2023
a714fb3
Fix test_redeem_native_token() unit test
sug0 Aug 2, 2023
0655085
Test that wrapped NAM is never minted
sug0 Aug 3, 2023
7a53732
Fix test_act_on_changes_storage_for_transfers_to_eth() unit test
sug0 Aug 2, 2023
c0b0ed5
Refactor Bridge pool tests to allow modifying pending transfer
sug0 Aug 2, 2023
d704d86
Add `asset` field to Balance
sug0 Aug 3, 2023
d90a5ea
New Bridge pool VP unit tests for wrapped NAM
sug0 Aug 3, 2023
75cf448
Fix wNAM edge cases in Bridge pool VP unit tests
sug0 Aug 3, 2023
fd1bf4d
Add invalidate_wnam_over_cap_tx() unit test
sug0 Aug 8, 2023
161cf43
Add changelog for #1781
sug0 Aug 3, 2023
b30a877
Update ethbridge-rs to v0.22.0
sug0 Aug 3, 2023
1a63f01
Fix compilation errors to support new `ethbridge-rs`
sug0 Aug 3, 2023
91b2fef
Test pending transfers and events have the same ABI encoding
sug0 Aug 7, 2023
5678ee7
Changelog for #1789
sug0 Aug 7, 2023
28dad92
Move `check_balance_changes` to Bridge pool VP module
sug0 Aug 8, 2023
e102aff
Add token addr field to Bridge pool gas fees
sug0 Aug 8, 2023
b30fbeb
Fix compilation errors from prev commit
sug0 Aug 8, 2023
1850b07
Check correct gas fee token in Bridge pool transfers
sug0 Aug 8, 2023
bbff3cc
Validate different gas fee tokens in Bridge pool VP
sug0 Aug 8, 2023
fdf00a8
Fix test_minting_wnam() unit test
sug0 Aug 8, 2023
7ec76d9
Add misc Bridge pool VP tests
sug0 Aug 9, 2023
5c8a030
Fix bug in `determine_escrow_checks` and document corner cases
sug0 Aug 9, 2023
bad6a7c
Arbitrary gas fees in Ethereum events `init_balances`
sug0 Aug 10, 2023
8745546
Test paying Bridge pool gas fees in ERC20 tokens
sug0 Aug 10, 2023
9c3fbcc
Update CLI args for Bridge pool transfers
sug0 Aug 8, 2023
4091b55
Standardize Bridge pool transfer CLI args
sug0 Aug 8, 2023
5342193
Make Bridge pool gas payer CLI arg optional
sug0 Aug 8, 2023
ce21ebd
Fix docstring
sug0 Aug 11, 2023
ba741a5
Add `DenominatedAmount::is_zero`
sug0 Aug 11, 2023
27f07c8
Fix the denomination of Bridge pool gas fees
sug0 Aug 11, 2023
968f1a6
Changelog for #1795
sug0 Aug 9, 2023
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1290-token-whitelist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Implement Ethereum token whitelist.
([\#1290](https://github.com/anoma/namada/issues/1290))
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1781-cap-wnam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Control the flow of NAM over the Ethereum bridge
([\#1781](https://github.com/anoma/namada/pull/1781))
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1789-update-ethbridge-rs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Update ethbridge-rs to v0.22.0
([\#1789](https://github.com/anoma/namada/pull/1789))
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/1795-bridge-pool-fees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Allow Bridge pool transfer fees to be paid in arbitrary token types (except
NUTs) ([\#1795](https://github.com/anoma/namada/pull/1795))
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ directories = "4.0.1"
ed25519-consensus = "1.2.0"
escargot = "0.5.7"
ethabi = "18.0.0"
ethbridge-bridge-contract = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0"}
ethbridge-bridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0"}
ethbridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0"}
ethbridge-governance-contract = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0"}
ethbridge-governance-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0"}
ethbridge-structs = { git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.22.0" }
ethers = "2.0.0"
expectrl = "0.7.0"
eyre = "0.6.5"
Expand Down
6 changes: 3 additions & 3 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ derivative.workspace = true
directories.workspace = true
ed25519-consensus.workspace = true
ethabi.workspace = true
ethbridge-bridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.18.0"}
ethbridge-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.18.0"}
ethbridge-governance-events = {git = "https://github.com/heliaxdev/ethbridge-rs", tag = "v0.18.0"}
ethbridge-bridge-events.workspace = true
ethbridge-events.workspace = true
ethbridge-governance-events.workspace = true
eyre.workspace = true
fd-lock.workspace = true
ferveo-common.workspace = true
Expand Down
71 changes: 46 additions & 25 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,22 @@ pub mod args {
);
pub const BLOCK_HEIGHT: Arg<BlockHeight> = arg("block-height");
// pub const BLOCK_HEIGHT_OPT: ArgOpt<BlockHeight> = arg_opt("height");
pub const BRIDGE_POOL_GAS_AMOUNT: ArgDefault<token::DenominatedAmount> =
sug0 marked this conversation as resolved.
Show resolved Hide resolved
arg_default(
"pool-gas-amount",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
pub const BRIDGE_POOL_GAS_PAYER: ArgOpt<WalletAddress> =
arg_opt("pool-gas-payer");
pub const BRIDGE_POOL_GAS_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx(
"pool-gas-token",
DefaultFn(|| "NAM".parse().unwrap()),
);
pub const BRIDGE_POOL_TARGET: Arg<EthAddress> = arg("target");
pub const BROADCAST_ONLY: ArgFlag = flag("broadcast-only");
pub const CHAIN_ID: Arg<ChainId> = arg("chain-id");
pub const CHAIN_ID_OPT: ArgOpt<ChainId> = CHAIN_ID.opt();
Expand Down Expand Up @@ -2450,7 +2466,7 @@ pub mod args {
pub const ETH_GAS: ArgOpt<u64> = arg_opt("eth-gas");
pub const ETH_GAS_PRICE: ArgOpt<u64> = arg_opt("eth-gas-price");
pub const ETH_ADDRESS: Arg<EthAddress> = arg("ethereum-address");
pub const ETH_ADDRESS_OPT: ArgOpt<EthAddress> = arg_opt("ethereum-address");
pub const ETH_ADDRESS_OPT: ArgOpt<EthAddress> = ETH_ADDRESS.opt();
pub const ETH_RPC_ENDPOINT: ArgDefault<String> = arg_default(
"eth-rpc-endpoint",
DefaultFn(|| "http://localhost:8545".into()),
Expand All @@ -2475,14 +2491,6 @@ pub mod args {
);
pub const GAS_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx("gas-token", DefaultFn(|| "NAM".parse().unwrap()));
pub const FEE_PAYER: Arg<WalletAddress> = arg("fee-payer");
pub const FEE_AMOUNT: ArgDefault<token::DenominatedAmount> = arg_default(
"fee-amount",
DefaultFn(|| token::DenominatedAmount {
amount: token::Amount::default(),
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
pub const GENESIS_PATH: Arg<PathBuf> = arg("genesis-path");
pub const GENESIS_VALIDATOR: ArgOpt<String> =
arg("genesis-validator").opt();
Expand Down Expand Up @@ -2513,6 +2521,7 @@ pub mod args {
pub const NET_ADDRESS: Arg<SocketAddr> = arg("net-address");
pub const NAMADA_START_TIME: ArgOpt<DateTimeUtc> = arg_opt("time");
pub const NO_CONVERSIONS: ArgFlag = flag("no-conversions");
pub const NUT: ArgFlag = flag("nut");
pub const OUT_FILE_PATH_OPT: ArgOpt<PathBuf> = arg_opt("out-file-path");
pub const OUTPUT_FOLDER_PATH: ArgOpt<PathBuf> =
arg_opt("output-folder-path");
Expand Down Expand Up @@ -2787,13 +2796,15 @@ pub mod args {
impl CliToSdk<EthereumBridgePool<SdkTypes>> for EthereumBridgePool<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> EthereumBridgePool<SdkTypes> {
EthereumBridgePool::<SdkTypes> {
nut: self.nut,
tx: self.tx.to_sdk(ctx),
asset: self.asset,
recipient: self.recipient,
sender: ctx.get(&self.sender),
amount: self.amount,
fee_amount: self.fee_amount,
fee_payer: ctx.get(&self.fee_payer),
fee_payer: self.fee_payer.map(|fee_payer| ctx.get(&fee_payer)),
fee_token: ctx.get(&self.fee_token),
code_path: self.code_path,
}
}
Expand All @@ -2803,12 +2814,15 @@ pub mod args {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let asset = ERC20.parse(matches);
let recipient = ETH_ADDRESS.parse(matches);
let sender = ADDRESS.parse(matches);
let recipient = BRIDGE_POOL_TARGET.parse(matches);
let sender = SOURCE.parse(matches);
let amount = InputAmount::Unvalidated(AMOUNT.parse(matches));
let fee_amount = FEE_AMOUNT.parse(matches).amount;
let fee_payer = FEE_PAYER.parse(matches);
let fee_amount =
InputAmount::Unvalidated(BRIDGE_POOL_GAS_AMOUNT.parse(matches));
let fee_payer = BRIDGE_POOL_GAS_PAYER.parse(matches);
let fee_token = BRIDGE_POOL_GAS_TOKEN.parse(matches);
let code_path = PathBuf::from(TX_BRIDGE_POOL_WASM);
let nut = NUT.parse(matches);
Self {
tx,
asset,
Expand All @@ -2817,7 +2831,9 @@ pub mod args {
amount,
fee_amount,
fee_payer,
fee_token,
code_path,
nut,
}
}

Expand All @@ -2829,29 +2845,34 @@ pub mod args {
.help("The Ethereum address of the ERC20 token."),
)
.arg(
ETH_ADDRESS
BRIDGE_POOL_TARGET
.def()
.help("The Ethereum address receiving the tokens."),
)
.arg(
ADDRESS
.def()
.help("The Namada address sending the tokens."),
SOURCE.def().help("The Namada address sending the tokens."),
)
.arg(
AMOUNT.def().help(
"The amount of tokens being sent across the bridge.",
),
)
.arg(FEE_AMOUNT.def().help(
"The amount of NAM you wish to pay to have this transfer \
.arg(BRIDGE_POOL_GAS_AMOUNT.def().help(
"The amount of gas you wish to pay to have this transfer \
relayed to Ethereum.",
))
.arg(
FEE_PAYER.def().help(
"The Namada address of the account paying the fee.",
),
)
.arg(BRIDGE_POOL_GAS_PAYER.def().help(
"The Namada address of the account paying the gas. By \
default, it is the same as the source.",
))
.arg(BRIDGE_POOL_GAS_TOKEN.def().help(
"The token for paying the Bridge pool gas fees. Defaults \
to NAM.",
))
.arg(NUT.def().help(
"Add Non Usable Tokens (NUTs) to the Bridge pool. These \
are usually obtained from invalid transfers to Namada.",
))
}
}

Expand Down
12 changes: 11 additions & 1 deletion apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,10 +909,13 @@ pub fn genesis(
}
#[cfg(any(test, feature = "dev"))]
pub fn genesis(num_validators: u64) -> Genesis {
use namada::ledger::eth_bridge::{Contracts, UpgradeableContract};
use namada::ledger::eth_bridge::{
Contracts, Erc20WhitelistEntry, UpgradeableContract,
};
use namada::types::address::{
self, apfel, btc, dot, eth, kartoffel, nam, schnitzel, wnam,
};
use namada::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS;
use namada::types::ethereum_events::EthAddress;

use crate::wallet;
Expand Down Expand Up @@ -1115,6 +1118,13 @@ pub fn genesis(num_validators: u64) -> Genesis {
gov_params: GovernanceParameters::default(),
pgf_params: PgfParameters::default(),
ethereum_bridge_params: Some(EthereumBridgeConfig {
erc20_whitelist: vec![Erc20WhitelistEntry {
token_address: DAI_ERC20_ETH_ADDRESS,
token_cap: token::DenominatedAmount {
amount: token::Amount::max(),
denom: 18.into(),
},
}],
eth_start_height: Default::default(),
min_confirmations: Default::default(),
contracts: Contracts {
Expand Down
Loading