Skip to content

Commit

Permalink
use type prefix when calculating the L2Request hash
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa committed Oct 21, 2024
1 parent 9350c6d commit 0579572
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pallets/rolldown/src/messages/eth_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ sol! {
#[derive(Debug, Eq, PartialEq, Encode, Decode, TypeInfo)]
enum Chain{ Ethereum, Arbitrum }

#[derive(Debug, Eq, PartialEq, Encode, Decode, TypeInfo)]
enum L2RequestType{ Withdrawal, Cancel, FailedDepositResolution }

#[derive(Debug)]
struct L1Update {
Chain chain;
Expand Down
22 changes: 19 additions & 3 deletions pallets/rolldown/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,25 @@ where
impl<AccountId: Clone> EthAbi for L2Request<AccountId> {
fn abi_encode(&self) -> Vec<u8> {
match self {
L2Request::FailedDepositResolution(deposit) => deposit.abi_encode(),
L2Request::Cancel(cancel) => cancel.abi_encode(),
L2Request::Withdrawal(withdrawal) => withdrawal.abi_encode(),
L2Request::FailedDepositResolution(deposit) =>
eth_abi::L2RequestType::FailedDepositResolution
.abi_encode()
.iter()
.chain(deposit.abi_encode().iter())
.cloned()
.collect(),
L2Request::Cancel(cancel) => eth_abi::L2RequestType::Cancel
.abi_encode()
.iter()
.chain(cancel.abi_encode().iter())
.cloned()
.collect(),
L2Request::Withdrawal(withdrawal) => eth_abi::L2RequestType::Withdrawal
.abi_encode()
.iter()
.chain(withdrawal.abi_encode().iter())
.cloned()
.collect(),
}
}
}
Expand Down

0 comments on commit 0579572

Please sign in to comment.