Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
sol-242: remove network_name field in subnet and accounts in config
Browse files Browse the repository at this point in the history
  • Loading branch information
adlrocha committed Oct 13, 2023
1 parent fd75ba4 commit 0518d7c
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand All @@ -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"]
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion docs/quickstart-calibration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 0 additions & 30 deletions ipc/provider/src/config/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Address>, D::Error>
where
D: Deserializer<'de>,
{
let addrs: Result<Vec<Address>, _> = <Vec<String>>::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<Vec<Address>, D::Error>
where
D: Deserializer<'de>,
{
let addrs: Result<Vec<Address>, _> = <Vec<String>>::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<Address> {
let addr = EthAddress::from_str(s)?;
Ok(Address::from(addr))
Expand Down
4 changes: 0 additions & 4 deletions ipc/provider/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,11 +44,9 @@ registry_addr = "0xb505eD453138A782b5c51f45952E067798F4777d"
# Subnet template - uncomment and adjust before using
# [[subnets]]
# id = "/r314159/<SUBNET_ID>"
# network_name = "<NAME>"
# [subnets.config]
# gateway_addr = "t064"
# accounts = ["<WORKER_1>", "<WORKER_2>", "<WORKER_3>"]
# jsonrpc_api_http = "http://127.0.0.1:1251/rpc/v1"
# auth_token = "<AUTH_TOKEN_1>"
# network_type = "fvm"
Expand Down
28 changes: 0 additions & 28 deletions ipc/provider/src/config/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,6 @@ where
s.serialize_str(&format!("0x{:?}", addr))
}

pub fn serialize_eth_accounts<S>(addrs: &Vec<Address>, s: S) -> Result<S::Ok, S::Error>
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<S>(addrs: &Vec<Address>, s: S) -> Result<S::Ok, S::Error>
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<EthAddress> {
match addr.payload() {
Payload::Delegated(inner) => {
Expand All @@ -99,21 +76,18 @@ mod tests {
[[subnets]]
id = "/r1234"
network_name = "test2"
[subnets.config]
network_type = "fevm"
provider_http = "http://127.0.0.1:3030/rpc/v1"
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"
Expand Down Expand Up @@ -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),
}),
};
Expand Down
19 changes: 2 additions & 17 deletions ipc/provider/src/config/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}

Expand Down Expand Up @@ -61,12 +58,6 @@ impl Subnet {
SubnetConfig::Fevm(s) => s.gateway_addr,
}
}

pub fn accounts(&self) -> Vec<Address> {
match &self.config {
SubnetConfig::Fevm(s) => s.accounts.clone(),
}
}
}

/// The FVM subnet config parameters
Expand All @@ -77,9 +68,6 @@ pub struct FVMSubnet {
pub gateway_addr: Address,
pub jsonrpc_api_http: Url,
pub auth_token: Option<String>,
#[serde(deserialize_with = "deserialize_accounts", default)]
#[serde(serialize_with = "serialize_accounts")]
pub accounts: Vec<Address>,
}

/// The EVM subnet config parameters
Expand All @@ -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<Address>,
}
12 changes: 0 additions & 12 deletions ipc/provider/src/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -115,15 +107,13 @@ fn config_str() -> String {
[[subnets]]
id = "{CHILD_ID}"
network_name = "child"
[subnets.config]
network_type = "fevm"
auth_token = "{CHILD_AUTH_TOKEN}"
provider_http = "{PROVIDER_HTTP}"
registry_addr = "{ETH_ADDRESS}"
gateway_addr = "{ETH_ADDRESS}"
accounts = ["{ETH_ADDRESS}", "{ETH_ADDRESS}"]
"#
)
}
Expand All @@ -135,15 +125,13 @@ fn config_str_diff_addr() -> String {
[[subnets]]
id = "{CHILD_ID}"
network_name = "child"
[subnets.config]
network_type = "fevm"
auth_token = "{CHILD_AUTH_TOKEN}"
provider_http = "{PROVIDER_HTTP}"
registry_addr = "{ETH_ADDRESS}"
gateway_addr = "{ETH_ADDRESS}"
accounts = ["{ETH_ADDRESS}", "{ETH_ADDRESS}"]
"#
)
}
Expand Down
1 change: 0 additions & 1 deletion ipc/provider/src/manager/evm/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions ipc/testing/e2e/scripts/connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0518d7c

Please sign in to comment.