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

Commit

Permalink
sync with latest solidity
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Dec 20, 2023
1 parent 4f34e4b commit 47ba93a
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 271 deletions.
251 changes: 120 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions ipc/cli/src/commands/crossmsg/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ impl CommandLineHandler for Release {
Some(address) => Some(require_fil_addr_from_str(address)?),
None => None,
};
let fee = match &arguments.fee {
Some(f) => Some(f64_to_token_amount(*f)?),
None => None,
};

println!(
"release performed in epoch: {:?}",
Expand All @@ -50,7 +46,6 @@ impl CommandLineHandler for Release {
from,
to,
f64_to_token_amount(arguments.amount)?,
fee,
)
.await?,
);
Expand All @@ -74,8 +69,6 @@ pub(crate) struct ReleaseArgs {
pub to: Option<String>,
#[arg(long, short, help = "The subnet to release funds from")]
pub subnet: String,
#[arg(long, help = "The fee to pay for the cross-net message, in whole FIL")]
pub fee: Option<f64>,
#[arg(help = "The amount to release in FIL, in whole FIL")]
pub amount: f64,
}
Expand Down
29 changes: 26 additions & 3 deletions ipc/cli/src/commands/subnet/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
use async_trait::async_trait;
use clap::Args;
use fvm_shared::address::Address;
use fvm_shared::clock::ChainEpoch;
use ipc_sdk::subnet::{PermissionMode, SupplyKind, SupplySource};
use ipc_sdk::subnet_id::SubnetID;
use std::fmt::Debug;
use std::str::FromStr;
Expand All @@ -30,6 +32,16 @@ impl CreateSubnet {
None => None,
};

let permission_mode = PermissionMode::try_from(arguments.permission_mode)?;
let token_address = if let Some(addr) = &arguments.supply_source_address {
Some(Address::from_str(addr)?)
} else {
None
};
let supply_source = SupplySource {
kind: SupplyKind::try_from(arguments.supply_source_kind)?,
token_address,
};
let addr = provider
.create_subnet(
from,
Expand All @@ -41,7 +53,8 @@ impl CreateSubnet {
.active_validators_limit
.unwrap_or(DEFAULT_ACTIVE_VALIDATORS),
f64_to_token_amount(arguments.min_cross_msg_fee)?,
arguments.permissioned,
permission_mode,
supply_source,
)
.await?;

Expand Down Expand Up @@ -99,7 +112,17 @@ pub struct CreateSubnetArgs {
pub min_cross_msg_fee: f64,
#[arg(
long,
help = "Deploy static network where validators can't join in a permissionless manner"
help = "The permission mode for the subnet, collateral(0), federated(1) and static(2)"
)]
pub permission_mode: u8,
#[arg(
long,
help = "The kind of supply source of a subnet on its parent subnet, native(0), erc20(1)"
)]
pub supply_source_kind: u8,
#[arg(
long,
help = "The address of supply source of a subnet on its parent subnet. None if kind is native"
)]
pub permissioned: bool,
pub supply_source_address: Option<String>,
}
51 changes: 27 additions & 24 deletions ipc/provider/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,24 @@ impl<T: BottomUpCheckpointRelayer + Send + Sync + 'static> BottomUpCheckpointMan
let bundle = self.child_handler.checkpoint_bundle_at(height).await?;
log::debug!("bottom up bundle: {bundle:?}");

let epoch = self
.parent_handler
.submit_checkpoint(submitter, bundle)
.await
.map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?;
log::info!(
"submitted bottom up checkpoint({}) in parent at height {}",
height,
epoch
);

Ok(())
todo!("implement submit checkpoint")

// let epoch = self
// .parent_handler
// .submit_checkpoint(submitter, bundle)
// .await
// .map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?;
// log::info!(
// "submitted bottom up checkpoint({}) in parent at height {}",
// height,
// epoch
// );
//
// Ok(())
}

/// Checks if the relayer has already submitted at the next submission epoch, if not it submits it.
async fn submit_next_epoch(&self, submitter: &Address) -> Result<()> {
async fn submit_next_epoch(&self, _submitter: &Address) -> Result<()> {
let next_submission_height = self.next_submission_height().await?;
let current_height = self.child_handler.current_epoch().await?;
let finalized_height = max(1, current_height - self.finalization_blocks);
Expand Down Expand Up @@ -201,17 +203,18 @@ impl<T: BottomUpCheckpointRelayer + Send + Sync + 'static> BottomUpCheckpointMan
.await?;
log::debug!("bottom up bundle: {bundle:?}");

let epoch = self
.parent_handler
.submit_checkpoint(submitter, bundle)
.await
.map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?;

log::info!(
"submitted bottom up checkpoint({}) in parent at height {}",
event.height,
epoch
);
todo!("implement submiet checkpoint")
// let epoch = self
// .parent_handler
// .submit_checkpoint(submitter, bundle)
// .await
// .map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?;
//
// log::info!(
// "submitted bottom up checkpoint({}) in parent at height {}",
// event.height,
// epoch
// );
}
}

Expand Down
19 changes: 6 additions & 13 deletions ipc/provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use ipc_identity::{
};
use ipc_sdk::checkpoint::{BottomUpCheckpointBundle, QuorumReachedEvent};
use ipc_sdk::staking::{StakingChangeRequest, ValidatorInfo};
use ipc_sdk::subnet::{PermissionMode, SupplySource};
use ipc_sdk::{
cross::CrossMsg,
subnet::{ConsensusType, ConstructParams},
Expand Down Expand Up @@ -239,7 +240,8 @@ impl IpcProvider {
bottomup_check_period: ChainEpoch,
active_validators_limit: u16,
min_cross_msg_fee: TokenAmount,
permissioned: bool,
permission_mode: PermissionMode,
supply_source: SupplySource,
) -> anyhow::Result<Address> {
let conn = match self.connection(&parent) {
None => return Err(anyhow!("target parent subnet not found")),
Expand All @@ -258,7 +260,8 @@ impl IpcProvider {
bottomup_check_period,
active_validators_limit,
min_cross_msg_fee,
permissioned,
permission_mode,
supply_source,
};

conn.manager()
Expand Down Expand Up @@ -485,7 +488,6 @@ impl IpcProvider {
from: Option<Address>,
to: Option<Address>,
amount: TokenAmount,
fee: Option<TokenAmount>,
) -> anyhow::Result<ChainEpoch> {
let conn = match self.connection(&subnet) {
None => return Err(anyhow!("target subnet not found")),
Expand All @@ -501,7 +503,7 @@ impl IpcProvider {
};

conn.manager()
.release(gateway_addr, sender, to.unwrap_or(sender), amount, fee)
.release(gateway_addr, sender, to.unwrap_or(sender), amount)
.await
}

Expand All @@ -518,15 +520,6 @@ impl IpcProvider {
todo!()
}

pub async fn send_cross_message(
&self,
_gateway_addr: Address,
_from: Address,
_cross_msg: CrossMsg,
) -> anyhow::Result<()> {
todo!()
}

/// Send value between two addresses in a subnet
pub async fn send_value(
&mut self,
Expand Down
Loading

0 comments on commit 47ba93a

Please sign in to comment.