Skip to content

Commit

Permalink
feat: DEVOPS-1774 Whitelist EVM contracts imported from ZQ1 that use …
Browse files Browse the repository at this point in the history
…scilla_call (#2000)

* feat: DEVOPS-1774 Whitelist EVM contracts imported from ZQ1 that use scilla_call #1939

* improve code efficiency
  • Loading branch information
frankmeds authored Dec 11, 2024
1 parent b42028d commit 0ac0226
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 deletions.
20 changes: 20 additions & 0 deletions z2/resources/chain-specs/zq2-protomainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,23 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.scilla_call_gas_exempt_addrs = [
"0x95347b860Bd49818AFAccCA8403C55C23e7BB9ED",
"0xe64cA52EF34FdD7e20C0c7fb2E392cc9b4F6D049",
"0x63B991C17010C21250a0eA58C6697F696a48cdf3",
"0x241c677D9969419800402521ae87C411897A029f",
"0x2274005778063684fbB1BfA96a2b725dC37D75f9",
"0x598FbD8B68a8B7e75b8B7182c750164f348907Bc",
"0x2938fF251Aecc1dfa768D7d0276eB6d073690317",
"0x17D5af5658A24bd964984b36d28e879a8626adC3",
"0xCcF3Ea256d42Aeef0EE0e39Bfc94bAa9Fa14b0Ba",
"0xc6F3dede529Af9D98a11C5B32DbF03Bf34272ED5",
"0x7D2fF48c6b59229d448473D267a714d29F078D3E",
"0xE9D47623bb2B3C497668B34fcf61E101a7ea4058",
"0x03A79429acc808e4261a68b0117aCD43Cb0FdBfa",
"0x097C26F8A93009fd9d98561384b5014D64ae17C2",
"0x01035e423c40a9ad4F6be2E6cC014EB5617c8Bd6",
"0x9C3fE3f471d8380297e4fB222eFb313Ee94DFa0f",
"0x20Dd5D5B5d4C72676514A0eA1052d0200003d69D",
"0xbfDe2156aF75a29d36614bC1F8005DD816Bd9200"
]
14 changes: 14 additions & 0 deletions z2/resources/chain-specs/zq2-prototestnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.scilla_call_gas_exempt_addrs = [
"0x60E6b5b1B8D3E373E1C04dC0b4f5624776bcBB60",
"0x7013Da2653453299Efb867EfcCCcB1A6d5FE1384",
"0x8618d39a8276D931603c6Bc7306af6A53aD2F1F3",
"0xE90Dd366D627aCc5feBEC126211191901A69f8a0",
"0x5900Ac075A67742f5eA4204650FEad9E674c664F",
"0x28e8d39fc68eaa27c88797eb7d324b4b97d5b844",
"0x51b9f3ddb948bcc16b89b48d83b920bc01dbed55",
"0x1fD09F6701a1852132A649fe9D07F2A3b991eCfA",
"0x878c5008A348A60a5B239844436A7b483fAdb7F2",
"0x8895Aa1bEaC254E559A3F91e579CF4a67B70ce02",
"0x453b11386FBd54bC532892c0217BBc316fc7b918",
"0xaD581eC62eA08831c8FE2Cd7A1113473fE40A057"
]
1 change: 1 addition & 0 deletions z2/resources/config.tera.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
consensus.gas_price = "4_761_904_800_000"
consensus.scilla_call_gas_exempt_addrs = {{ whitelisted_evm_contract_addresses }}

{%- if role == "checkpoint" %}
# Checkpoint configuration
Expand Down
40 changes: 40 additions & 0 deletions z2/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,46 @@ impl Chain {
}
}

pub fn get_whitelisted_evm_contracts(&self) -> Vec<&'static str> {
match self {
Self::Zq2ProtoMainnet => vec![
"0x95347b860Bd49818AFAccCA8403C55C23e7BB9ED",
"0xe64cA52EF34FdD7e20C0c7fb2E392cc9b4F6D049",
"0x63B991C17010C21250a0eA58C6697F696a48cdf3",
"0x241c677D9969419800402521ae87C411897A029f",
"0x2274005778063684fbB1BfA96a2b725dC37D75f9",
"0x598FbD8B68a8B7e75b8B7182c750164f348907Bc",
"0x2938fF251Aecc1dfa768D7d0276eB6d073690317",
"0x17D5af5658A24bd964984b36d28e879a8626adC3",
"0xCcF3Ea256d42Aeef0EE0e39Bfc94bAa9Fa14b0Ba",
"0xc6F3dede529Af9D98a11C5B32DbF03Bf34272ED5",
"0x7D2fF48c6b59229d448473D267a714d29F078D3E",
"0xE9D47623bb2B3C497668B34fcf61E101a7ea4058",
"0x03A79429acc808e4261a68b0117aCD43Cb0FdBfa",
"0x097C26F8A93009fd9d98561384b5014D64ae17C2",
"0x01035e423c40a9ad4F6be2E6cC014EB5617c8Bd6",
"0x9C3fE3f471d8380297e4fB222eFb313Ee94DFa0f",
"0x20Dd5D5B5d4C72676514A0eA1052d0200003d69D",
"0xbfDe2156aF75a29d36614bC1F8005DD816Bd9200",
],
Self::Zq2ProtoTestnet => vec![
"0x60E6b5b1B8D3E373E1C04dC0b4f5624776bcBB60",
"0x7013Da2653453299Efb867EfcCCcB1A6d5FE1384",
"0x8618d39a8276D931603c6Bc7306af6A53aD2F1F3",
"0xE90Dd366D627aCc5feBEC126211191901A69f8a0",
"0x5900Ac075A67742f5eA4204650FEad9E674c664F",
"0x28e8d39fc68eaa27c88797eb7d324b4b97d5b844",
"0x51b9f3ddb948bcc16b89b48d83b920bc01dbed55",
"0x1fD09F6701a1852132A649fe9D07F2A3b991eCfA",
"0x878c5008A348A60a5B239844436A7b483fAdb7F2",
"0x8895Aa1bEaC254E559A3F91e579CF4a67B70ce02",
"0x453b11386FBd54bC532892c0217BBc316fc7b918",
"0xaD581eC62eA08831c8FE2Cd7A1113473fE40A057",
],
_ => vec![],
}
}

pub fn get_endpoint(&self) -> Result<&'static str> {
let endpoint = self.get_str("endpoint");

Expand Down
6 changes: 3 additions & 3 deletions z2/src/chain/instance.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::{collections::BTreeMap, str::FromStr};

use anyhow::{anyhow, Ok, Result};
use serde_json::value::Value;
Expand All @@ -18,7 +18,7 @@ pub struct ChainInstance {

impl ChainInstance {
pub async fn new(config: NetworkConfig) -> Result<Self> {
let chain = <Chain as std::str::FromStr>::from_str(&config.name.clone())?;
let chain = Chain::from_str(&config.name.clone())?;
Ok(Self {
config: config.clone(),
machines: Self::import_machines(&config.name, chain.get_project_id()?).await?,
Expand All @@ -31,7 +31,7 @@ impl ChainInstance {
}

pub fn chain(&self) -> Result<Chain> {
Ok(<Chain as std::str::FromStr>::from_str(&self.name())?)
Ok(Chain::from_str(&self.name())?)
}

pub fn persistence_url(&self) -> Option<String> {
Expand Down
6 changes: 6 additions & 0 deletions z2/src/chain/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ impl ChainNode {
let role_name = self.role.to_string();
let eth_chain_id = self.eth_chain_id.to_string();
let bootstrap_public_ip = selected_bootstrap.machine.external_address;
let whitelisted_evm_contract_addresses =
serde_json::to_string_pretty(&self.chain()?.get_whitelisted_evm_contracts())?;

let mut var_map = BTreeMap::<&str, &str>::new();
var_map.insert("role", &role_name);
Expand All @@ -524,6 +526,10 @@ impl ChainNode {
var_map.insert("bootstrap_bls_public_key", &bootstrap_node.bls_public_key);
var_map.insert("set_bootstrap_address", set_bootstrap_address);
var_map.insert("genesis_address", &genesis_account.address);
var_map.insert(
"whitelisted_evm_contract_addresses",
&whitelisted_evm_contract_addresses,
);

let ctx = Context::from_serialize(var_map)?;
Ok(Tera::one_off(spec_config, &ctx, false)?)
Expand Down

0 comments on commit 0ac0226

Please sign in to comment.