Skip to content

Commit

Permalink
Remove whitelist Ethereum events from the ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Jul 15, 2023
1 parent 29cca2f commit c54097f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 91 deletions.
52 changes: 5 additions & 47 deletions apps/src/lib/node/ledger/ethereum_oracle/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ pub mod eth_events {
};
use ethbridge_events::{DynEventCodec, Events as RawEvents};
use ethbridge_governance_events::{
GovernanceEvents, NewContractFilter, UpdateBridgeWhitelistFilter,
UpgradedContractFilter, ValidatorSetUpdateFilter,
GovernanceEvents, NewContractFilter, UpgradedContractFilter,
ValidatorSetUpdateFilter,
};
use namada::core::types::ethereum_structs;
use namada::eth_bridge::ethers::contract::EthEvent;
use namada::types::address::Address;
use namada::types::ethereum_events::{
EthAddress, EthereumEvent, TokenWhitelist, TransferToEthereum,
TransferToEthereumKind, TransferToNamada, Uint,
EthAddress, EthereumEvent, TransferToEthereum, TransferToEthereumKind,
TransferToNamada, Uint,
};
use namada::types::keccak::KeccakHash;
use namada::types::token::Amount;
Expand Down Expand Up @@ -106,31 +106,6 @@ pub mod eth_events {
NewContractFilter::name().into(),
));
}
RawEvents::Governance(
GovernanceEvents::UpdateBridgeWhitelistFilter(
UpdateBridgeWhitelistFilter {
nonce,
tokens,
token_cap,
},
),
) => {
let mut whitelist = vec![];

for (token, cap) in
tokens.into_iter().zip(token_cap.into_iter())
{
whitelist.push(TokenWhitelist {
token: token.parse_eth_address()?,
cap: cap.parse_amount()?,
});
}

EthereumEvent::UpdateBridgeWhitelist {
nonce: nonce.parse_uint256()?,
whitelist,
}
}
RawEvents::Governance(
GovernanceEvents::UpgradedContractFilter(
UpgradedContractFilter { name: _, addr: _ },
Expand Down Expand Up @@ -342,7 +317,7 @@ pub mod eth_events {
use ethabi::ethereum_types::{H160, U256};
use ethbridge_events::{
TRANSFER_TO_ERC_CODEC, TRANSFER_TO_NAMADA_CODEC,
UPDATE_BRIDGE_WHITELIST_CODEC, VALIDATOR_SET_UPDATE_CODEC,
VALIDATOR_SET_UPDATE_CODEC,
};
use namada::eth_bridge::ethers::abi::AbiEncode;

Expand Down Expand Up @@ -553,11 +528,6 @@ pub mod eth_events {
bridge_validator_set_hash: [1; 32],
governance_validator_set_hash: [2; 32],
};
let whitelist = UpdateBridgeWhitelistFilter {
nonce: 0u64.into(),
tokens: vec![H160([0; 20]); 2],
token_cap: vec![0u64.into(); 2],
};
assert_eq!(
{
let decoded: TransferToNamadaFilter =
Expand Down Expand Up @@ -593,18 +563,6 @@ pub mod eth_events {
},
update
);
assert_eq!(
{
let decoded: UpdateBridgeWhitelistFilter =
UPDATE_BRIDGE_WHITELIST_CODEC
.decode(&get_log(whitelist.clone().encode()))
.expect("Test failed")
.try_into()
.expect("Test failed");
decoded
},
whitelist
);
}

/// Return an Ethereum events log, from the given encoded event
Expand Down
5 changes: 0 additions & 5 deletions apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,6 @@ where
return Err(VoteExtensionError::InvalidNamNonce);
}
}
EthereumEvent::UpdateBridgeWhitelist { .. } => {
// TODO: check nonce of whitelist update;
// for this, we need to store the nonce of
// whitelist updates somewhere
}
// consider other ethereum event kinds valid
_ => {}
}
Expand Down
34 changes: 0 additions & 34 deletions core/src/types/ethereum_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,6 @@ pub enum EthereumEvent {
#[allow(dead_code)]
address: EthAddress,
},
/// Event indication a new Ethereum based token has been whitelisted for
/// transfer across the bridge
UpdateBridgeWhitelist {
/// Monotonically increasing nonce
#[allow(dead_code)]
nonce: Uint,
/// Tokens to be allowed to be transferred across the bridge
#[allow(dead_code)]
whitelist: Vec<TokenWhitelist>,
},
}

impl EthereumEvent {
Expand Down Expand Up @@ -462,30 +452,6 @@ pub struct TransferToEthereum {
pub gas_payer: Address,
}

/// struct for whitelisting a token from Ethereum.
/// Includes the address of issuing contract and
/// a cap on the max amount of this token allowed to be
/// held by the bridge.
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
BorshSerialize,
BorshDeserialize,
BorshSchema,
)]
#[allow(dead_code)]
pub struct TokenWhitelist {
/// Address of Ethereum smart contract issuing token
pub token: EthAddress,
/// Maximum amount of token allowed on the bridge
pub cap: Amount,
}

#[cfg(test)]
pub mod tests {
use std::str::FromStr;
Expand Down
1 change: 0 additions & 1 deletion core/src/types/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ pub struct PrefixValue {
pub struct EthEventsQueue {
/// Queue of transfer to Namada events.
pub transfers_to_namada: InnerEthEventsQueue<TransfersToNamada>,
// TODO: add queue of update whitelist events
}

/// A queue of confirmed Ethereum events of type `E`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,6 @@ mod tests {
name: "bridge".to_string(),
address: arbitrary_eth_address(),
},
EthereumEvent::UpdateBridgeWhitelist {
nonce: arbitrary_nonce(),
whitelist: vec![],
},
EthereumEvent::UpgradedContract {
name: "bridge".to_string(),
address: arbitrary_eth_address(),
Expand Down

0 comments on commit c54097f

Please sign in to comment.