From 0518d7c532ef16d4591a9f92523be0673083f6d5 Mon Sep 17 00:00:00 2001 From: Alfonso de la Rocha Date: Fri, 13 Oct 2023 17:00:41 +0200 Subject: [PATCH] sol-242: remove network_name field in subnet and accounts in config --- Cargo.lock | 2 +- Cargo.toml | 7 +++--- README.md | 3 --- docs/quickstart-calibration.md | 1 - ipc/provider/src/config/deserialize.rs | 30 ------------------------- ipc/provider/src/config/mod.rs | 4 ---- ipc/provider/src/config/serialize.rs | 28 ----------------------- ipc/provider/src/config/subnet.rs | 19 ++-------------- ipc/provider/src/config/tests.rs | 12 ---------- ipc/provider/src/manager/evm/manager.rs | 1 - ipc/testing/e2e/scripts/connect.sh | 2 -- 11 files changed, 7 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3276508..23c2853f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2691,7 +2691,7 @@ dependencies = [ [[package]] name = "ipc_actors_abis" version = "0.1.0" -source = "git+https://github.com/consensus-shipyard/ipc-solidity-actors.git?branch=dev#3779e796bbd779dc20218c5685add16c08c56211" +source = "git+https://github.com/consensus-shipyard/ipc-solidity-actors.git?branch=dev#e2624a563072a33b96ede3d3aafe0d78f87ed4ce" dependencies = [ "anyhow", "ethers", diff --git a/Cargo.toml b/Cargo.toml index 6877b543..dbe1ca97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,10 @@ rand = "0.8" hex = "0.4.3" tempfile = "3.4.0" serde_json = { version = "1.0.91", features = ["raw_value"] } +libipld = { version = "0.14", default-features = false, features = ["dag-cbor"] } +ethers = "2.0.8" +ethers-contract = "2.0.8" + ipc_actors_abis = { git = "https://github.com/consensus-shipyard/ipc-solidity-actors.git", branch = "dev" } ipc-sdk = { path = "./ipc/sdk" } @@ -49,10 +53,7 @@ fvm_ipld_encoding = "0.3.3" fvm_ipld_hamt = "0.6" fvm_shared = { version = "=3.2.0", default-features = false, features = ["crypto"] } fil_actors_runtime = { git = "https://github.com/consensus-shipyard/fvm-utils", features = ["fil-actor"] } -libipld = { version = "0.14", default-features = false, features = ["dag-cbor"] } primitives = { git = "https://github.com/consensus-shipyard/fvm-utils" } -ethers = "2.0.8" -ethers-contract = "2.0.8" # Uncomment to point to you local versions # [patch."https://github.com/consensus-shipyard/fvm-utils"] diff --git a/README.md b/README.md index e6f24c2b..be9cdf9f 100644 --- a/README.md +++ b/README.md @@ -93,9 +93,7 @@ In order to use the IPC agent with Calibration we need to have access to a full # Default configuration for Filecoin Calibration [[subnets]] id = "/r314159" -network_name = "calibration" [subnets.config] -accounts = [] gateway_addr = "0x5fBdA31a37E05D8cceF146f7704f4fCe33e2F96F" network_type = "fevm" provider_http = "https://api.calibration.node.glif.io/rpc/v1" @@ -135,7 +133,6 @@ The `/r31415926` section of the agent's `config.toml` must be updated to connect ```toml [[subnets]] id = "/r31415926" -network_name = "root" [subnets.config] network_type = "fvm" diff --git a/docs/quickstart-calibration.md b/docs/quickstart-calibration.md index 7570e516..12ef5e1d 100644 --- a/docs/quickstart-calibration.md +++ b/docs/quickstart-calibration.md @@ -72,7 +72,6 @@ id = "/r314159" network_name = "calibration" [subnets.config] -accounts = [] gateway_addr = "0x5fBdA31a37E05D8cceF146f7704f4fCe33e2F96F" network_type = "fevm" provider_http = "https://api.calibration.node.glif.io/rpc/v1" diff --git a/ipc/provider/src/config/deserialize.rs b/ipc/provider/src/config/deserialize.rs index f0f256c8..1bf1c7bd 100644 --- a/ipc/provider/src/config/deserialize.rs +++ b/ipc/provider/src/config/deserialize.rs @@ -102,36 +102,6 @@ where deserializer.deserialize_str(SubnetIDVisitor) } -/// A serde deserialization method to deserialize a list of account strings into a vector of -/// [`Address`]. -pub(crate) fn deserialize_accounts<'de, D>( - deserializer: D, -) -> anyhow::Result, D::Error> -where - D: Deserializer<'de>, -{ - let addrs: Result, _> = >::deserialize(deserializer)? - .iter() - .map(|raw_addr| Address::from_str(raw_addr)) - .collect(); - addrs.map_err(D::Error::custom) -} - -/// A serde deserialization method to deserialize a list of eth account strings into a vector of -/// [`Address`]. -pub(crate) fn deserialize_eth_accounts<'de, D>( - deserializer: D, -) -> anyhow::Result, D::Error> -where - D: Deserializer<'de>, -{ - let addrs: Result, _> = >::deserialize(deserializer)? - .iter() - .map(|raw_addr| eth_addr_str_to_address(raw_addr)) - .collect(); - addrs.map_err(D::Error::custom) -} - fn eth_addr_str_to_address(s: &str) -> anyhow::Result
{ let addr = EthAddress::from_str(s)?; Ok(Address::from(addr)) diff --git a/ipc/provider/src/config/mod.rs b/ipc/provider/src/config/mod.rs index 7d8b34ac..6e11a2fa 100644 --- a/ipc/provider/src/config/mod.rs +++ b/ipc/provider/src/config/mod.rs @@ -34,10 +34,8 @@ repo_path = "~/.ipc" [[subnets]] id = "/r314159" -network_name = "calibration" [subnets.config] -accounts = [] gateway_addr = "0x5fBdA31a37E05D8cceF146f7704f4fCe33e2F96F" network_type = "fevm" provider_http = "https://api.calibration.node.glif.io/rpc/v1" @@ -46,11 +44,9 @@ registry_addr = "0xb505eD453138A782b5c51f45952E067798F4777d" # Subnet template - uncomment and adjust before using # [[subnets]] # id = "/r314159/" -# network_name = "" # [subnets.config] # gateway_addr = "t064" -# accounts = ["", "", ""] # jsonrpc_api_http = "http://127.0.0.1:1251/rpc/v1" # auth_token = "" # network_type = "fvm" diff --git a/ipc/provider/src/config/serialize.rs b/ipc/provider/src/config/serialize.rs index 1a279ec7..96c8f49b 100644 --- a/ipc/provider/src/config/serialize.rs +++ b/ipc/provider/src/config/serialize.rs @@ -51,29 +51,6 @@ where s.serialize_str(&format!("0x{:?}", addr)) } -pub fn serialize_eth_accounts(addrs: &Vec
, s: S) -> Result -where - S: Serializer, -{ - let mut seq = s.serialize_seq(Some(addrs.len()))?; - for element in addrs { - let addr = address_to_eth_address(element).map_err(S::Error::custom)?; - seq.serialize_element(&format!("0x{:?}", addr))?; - } - seq.end() -} - -pub fn serialize_accounts(addrs: &Vec
, s: S) -> Result -where - S: Serializer, -{ - let mut seq = s.serialize_seq(Some(addrs.len()))?; - for element in addrs { - seq.serialize_element(&element.to_string())?; - } - seq.end() -} - fn address_to_eth_address(addr: &Address) -> anyhow::Result { match addr.payload() { Payload::Delegated(inner) => { @@ -99,7 +76,6 @@ mod tests { [[subnets]] id = "/r1234" - network_name = "test2" [subnets.config] network_type = "fevm" @@ -107,13 +83,11 @@ mod tests { registry_addr = "0x6be1ccf648c74800380d0520d797a170c808b624" gateway_addr = "0x6be1ccf648c74800380d0520d797a170c808b624" private_key = "0x6BE1Ccf648c74800380d0520D797a170c808b624" - accounts = ["0x6be1ccf648c74800380d0520d797a170c808b624", "0x6be1ccf648c74800380d0520d797a170c808b624"] "#; const EMPTY_KEYSTORE: &str = r#" [[subnets]] id = "/r1234" - network_name = "test2" [subnets.config] network_type = "fevm" @@ -152,12 +126,10 @@ mod tests { let eth_addr1 = EthAddress::from_str("0x6BE1Ccf648c74800380d0520D797a170c808b624").unwrap(); let subnet2 = Subnet { id: SubnetID::new_root(1234), - network_name: "test2".to_string(), config: SubnetConfig::Fevm(EVMSubnet { gateway_addr: Address::from(eth_addr1), provider_http: "http://127.0.0.1:3030/rpc/v1".parse().unwrap(), auth_token: None, - accounts: vec![Address::from(eth_addr1), Address::from(eth_addr1)], registry_addr: Address::from(eth_addr1), }), }; diff --git a/ipc/provider/src/config/subnet.rs b/ipc/provider/src/config/subnet.rs index ddebd126..5189eb49 100644 --- a/ipc/provider/src/config/subnet.rs +++ b/ipc/provider/src/config/subnet.rs @@ -6,12 +6,10 @@ use serde::{Deserialize, Serialize}; use url::Url; use crate::config::deserialize::{ - deserialize_accounts, deserialize_address_from_str, deserialize_eth_accounts, - deserialize_eth_address_from_str, deserialize_subnet_id, + deserialize_address_from_str, deserialize_eth_address_from_str, deserialize_subnet_id, }; use crate::config::serialize::{ - serialize_accounts, serialize_address_to_str, serialize_eth_accounts, - serialize_eth_address_to_str, serialize_subnet_id_to_str, + serialize_address_to_str, serialize_eth_address_to_str, serialize_subnet_id_to_str, }; /// Represents a subnet declaration in the config. @@ -20,7 +18,6 @@ pub struct Subnet { #[serde(deserialize_with = "deserialize_subnet_id")] #[serde(serialize_with = "serialize_subnet_id_to_str")] pub id: SubnetID, - pub network_name: String, pub config: SubnetConfig, } @@ -61,12 +58,6 @@ impl Subnet { SubnetConfig::Fevm(s) => s.gateway_addr, } } - - pub fn accounts(&self) -> Vec
{ - match &self.config { - SubnetConfig::Fevm(s) => s.accounts.clone(), - } - } } /// The FVM subnet config parameters @@ -77,9 +68,6 @@ pub struct FVMSubnet { pub gateway_addr: Address, pub jsonrpc_api_http: Url, pub auth_token: Option, - #[serde(deserialize_with = "deserialize_accounts", default)] - #[serde(serialize_with = "serialize_accounts")] - pub accounts: Vec
, } /// The EVM subnet config parameters @@ -93,7 +81,4 @@ pub struct EVMSubnet { #[serde(deserialize_with = "deserialize_eth_address_from_str")] #[serde(serialize_with = "serialize_eth_address_to_str")] pub gateway_addr: Address, - #[serde(deserialize_with = "deserialize_eth_accounts", default)] - #[serde(serialize_with = "serialize_eth_accounts")] - pub accounts: Vec
, } diff --git a/ipc/provider/src/config/tests.rs b/ipc/provider/src/config/tests.rs index 39aba8fa..187fed74 100644 --- a/ipc/provider/src/config/tests.rs +++ b/ipc/provider/src/config/tests.rs @@ -92,20 +92,12 @@ fn check_subnets_config() { let child_id = SubnetID::from_str(CHILD_ID).unwrap(); let child = &config[&child_id]; assert_eq!(child.id, child_id); - assert_eq!(child.network_name, "child"); assert_eq!( child.gateway_addr(), Address::from(EthAddress::from_str(ETH_ADDRESS).unwrap()) ); assert_eq!(*child.rpc_http(), Url::from_str(PROVIDER_HTTP).unwrap(),); assert_eq!(child.auth_token().as_ref().unwrap(), CHILD_AUTH_TOKEN); - assert_eq!( - child.accounts(), - vec![ - Address::from(EthAddress::from_str(ETH_ADDRESS).unwrap()), - Address::from(EthAddress::from_str(ETH_ADDRESS).unwrap()) - ], - ); } fn config_str() -> String { @@ -115,7 +107,6 @@ fn config_str() -> String { [[subnets]] id = "{CHILD_ID}" - network_name = "child" [subnets.config] network_type = "fevm" @@ -123,7 +114,6 @@ fn config_str() -> String { provider_http = "{PROVIDER_HTTP}" registry_addr = "{ETH_ADDRESS}" gateway_addr = "{ETH_ADDRESS}" - accounts = ["{ETH_ADDRESS}", "{ETH_ADDRESS}"] "# ) } @@ -135,7 +125,6 @@ fn config_str_diff_addr() -> String { [[subnets]] id = "{CHILD_ID}" - network_name = "child" [subnets.config] network_type = "fevm" @@ -143,7 +132,6 @@ fn config_str_diff_addr() -> String { provider_http = "{PROVIDER_HTTP}" registry_addr = "{ETH_ADDRESS}" gateway_addr = "{ETH_ADDRESS}" - accounts = ["{ETH_ADDRESS}", "{ETH_ADDRESS}"] "# ) } diff --git a/ipc/provider/src/manager/evm/manager.rs b/ipc/provider/src/manager/evm/manager.rs index 8271a550..c76cdef2 100644 --- a/ipc/provider/src/manager/evm/manager.rs +++ b/ipc/provider/src/manager/evm/manager.rs @@ -225,7 +225,6 @@ impl SubnetManager for EthSubnetManager { root: params.parent.root_id(), route, }, - name, ipc_gateway_addr: self.ipc_contract_info.gateway_addr, consensus: params.consensus as u64 as u8, min_activation_collateral: ethers::types::U256::from(min_validator_stake), diff --git a/ipc/testing/e2e/scripts/connect.sh b/ipc/testing/e2e/scripts/connect.sh index d3c41422..dd131635 100755 --- a/ipc/testing/e2e/scripts/connect.sh +++ b/ipc/testing/e2e/scripts/connect.sh @@ -42,11 +42,9 @@ write_subnet_config() { [[subnets]] id = "${IPC_SUBNET_ID}" gateway_addr = "t064" -network_name = "${IPC_SUBNET_NAME}" # node_type = "${IPC_NODE_TYPE}" jsonrpc_api_http = "http://node-${IPC_NODE_NR}:1234/rpc/v1" auth_token = "${TOKEN}" -accounts = ["${WALLET}"] EOF }