Skip to content

Commit

Permalink
Enso access lists (#2122)
Browse files Browse the repository at this point in the history
# Description
Without this settlements that are sending the native asset to a smart
contract fail simulations, because they run out of gas.

Access lists are supported by temper:
https://github.com/EnsoFinance/temper
  • Loading branch information
fleupold authored Dec 5, 2023
1 parent bf5a400 commit 2a36cf3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/driver/src/domain/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl std::fmt::Debug for Tx {
.field("to", &self.to)
.field("value", &self.value)
.field("input", &self.input)
.field("access_list", &self.access_list)
.finish()
}
}
Expand Down
28 changes: 28 additions & 0 deletions crates/driver/src/infra/simulator/enso/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ pub struct Request {
pub gas_limit: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub block_number: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub access_list: Option<AccessList>,
}

#[derive(Debug, Serialize)]
#[serde(transparent)]
pub struct AccessList(Vec<AccessListItem>);

impl From<eth::AccessList> for AccessList {
fn from(value: eth::AccessList) -> Self {
Self(
web3::types::AccessList::from(value)
.into_iter()
.map(|item| AccessListItem {
address: item.address,
storage_keys: item.storage_keys,
})
.collect(),
)
}
}

#[serde_as]
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AccessListItem {
pub address: eth::H160,
pub storage_keys: Vec<eth::H256>,
}

#[serde_as]
Expand Down
5 changes: 5 additions & 0 deletions crates/driver/src/infra/simulator/enso/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ impl Enso {
value: tx.value.into(),
gas_limit: GAS_LIMIT,
block_number: None,
access_list: if tx.access_list.is_empty() {
None
} else {
Some(tx.access_list.into())
},
})
.send()
.await?
Expand Down

0 comments on commit 2a36cf3

Please sign in to comment.