Skip to content

Commit 91db005

Browse files
committed
feat: rebase
1 parent e2f08b6 commit 91db005

File tree

11 files changed

+79
-54
lines changed

11 files changed

+79
-54
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ tracing-appender = "0.2.3"
184184
text-tables = "0.3.1"
185185
url = { version = "2.4.1", features = ["serde"] }
186186
zeroize = "1.6"
187+
parking_lot = "0.12"
188+
humantime-serde = "1.1"
187189

188190
# Vendored for cross-compilation, see https://github.com/cross-rs/cross/wiki/Recipes#openssl
189191
# Make sure every top level build target actually imports this dependency, and don't end up

fendermint/actors-custom-car/src/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::{anyhow, Context};
44
use cid::Cid;
55
use fendermint_actor_chainmetadata::CHAINMETADATA_ACTOR_NAME;
66
use fendermint_actor_eam::IPC_EAM_ACTOR_NAME;
7-
use fendermint_actor_f3_cert_manager::F3_CERT_MANAGER_ACTOR_NAME;
7+
use fendermint_actor_f3_light_client::F3_LIGHT_CLIENT_ACTOR_NAME;
88
use fendermint_actor_gas_market_eip1559::ACTOR_NAME as GAS_MARKET_EIP1559_ACTOR_NAME;
99
use fvm_ipld_blockstore::Blockstore;
1010
use fvm_ipld_encoding::CborStore;
@@ -13,7 +13,7 @@ use std::collections::HashMap;
1313
// array of required actors
1414
pub const REQUIRED_ACTORS: &[&str] = &[
1515
CHAINMETADATA_ACTOR_NAME,
16-
F3_CERT_MANAGER_ACTOR_NAME,
16+
F3_LIGHT_CLIENT_ACTOR_NAME,
1717
IPC_EAM_ACTOR_NAME,
1818
GAS_MARKET_EIP1559_ACTOR_NAME,
1919
];

fendermint/app/options/src/genesis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ pub struct GenesisFromParentArgs {
227227

228228
/// Filecoin/Lotus RPC endpoint for fetching F3 certificate data (parent finality proofs).
229229
/// This is separate from parent_endpoint which is the EVM/Ethereum API.
230-
/// Optional - if not provided, F3 data will not be fetched (e.g., when parent is not Filecoin).
230+
/// Required for proof-based parent finality.
231231
#[arg(long)]
232-
pub parent_filecoin_rpc: Option<url::Url>,
232+
pub parent_filecoin_rpc: url::Url,
233233

234234
/// Auth token for the Filecoin RPC endpoint.
235235
#[arg(long)]

fendermint/app/src/cmd/genesis.rs

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use anyhow::{anyhow, Context};
55
use fendermint_actor_f3_light_client::types;
66
use fendermint_crypto::PublicKey;
7+
// Temporarily disabled due to [email protected] compatibility issues
8+
// use filecoin_f3_lightclient::F3Client;
79
use fvm_shared::address::Address;
810
use ipc_api::subnet_id::SubnetID;
911
use ipc_provider::config::subnet::{EVMSubnet, SubnetConfig};
@@ -350,13 +352,15 @@ pub async fn seal_genesis(genesis_file: &PathBuf, args: &SealGenesisArgs) -> any
350352
builder.write_to(args.output_path.clone()).await
351353
}
352354

353-
/// Fetches F3 parameters from the parent Filecoin chain
355+
/// Fetches F3 certificate data from the parent Filecoin chain
354356
async fn fetch_f3_params_from_parent(
355357
parent_endpoint: &url::Url,
356358
parent_auth_token: Option<&String>,
357359
) -> anyhow::Result<Option<ipc::F3Params>> {
360+
use std::convert::TryFrom;
361+
358362
tracing::info!(
359-
"Fetching F3 parameters from parent chain at {}",
363+
"Fetching F3 certificate data from parent chain at {}",
360364
parent_endpoint
361365
);
362366

@@ -368,28 +372,11 @@ async fn fetch_f3_params_from_parent(
368372
// We use a dummy subnet ID here since F3 data is at the chain level, not subnet-specific
369373
let lotus_client = LotusJsonRPCClient::new(jsonrpc_client, SubnetID::default());
370374

371-
// Fetch F3 certificate which contains instance ID and finalized epochs
372-
let certificate = lotus_client.f3_get_certificate().await?;
373-
374-
match certificate {
375-
Some(cert) => {
376-
let instance_id = cert.gpbft_instance;
375+
// Fetch F3 data using the Lotus client
376+
match lotus_client.f3_get_instance_id().await {
377+
Ok(instance_id) => {
377378
tracing::info!("Found F3 instance ID: {}", instance_id);
378379

379-
// Extract finalized epochs from the EC chain
380-
let finalized_epochs: Vec<i64> =
381-
cert.ec_chain.iter().map(|entry| entry.epoch).collect();
382-
383-
if finalized_epochs.is_empty() {
384-
return Err(anyhow::anyhow!("F3 certificate has empty EC chain"));
385-
}
386-
387-
tracing::info!(
388-
"Found {} finalized epochs, latest: {}",
389-
finalized_epochs.len(),
390-
finalized_epochs.iter().max().unwrap_or(&0)
391-
);
392-
393380
// Get power table for this instance
394381
let power_table_response = lotus_client.f3_get_power_table(instance_id).await?;
395382

@@ -412,15 +399,36 @@ async fn fetch_f3_params_from_parent(
412399
.collect();
413400
let power_table = power_table?;
414401

415-
tracing::info!("Successfully fetched F3 parameters from parent chain");
402+
// Get latest certificate to extract finalized epochs
403+
let certificate = lotus_client.f3_get_certificate().await?;
404+
let finalized_epochs = if let Some(cert_response) = certificate {
405+
// Collect all finalized epochs from the EC chain
406+
let epochs: Vec<i64> = cert_response
407+
.ec_chain
408+
.iter()
409+
.map(|entry| entry.epoch)
410+
.collect();
411+
412+
if epochs.is_empty() {
413+
return Err(anyhow::anyhow!("F3 certificate has empty EC chain"));
414+
}
415+
416+
epochs
417+
} else {
418+
// No certificate yet - start with empty finalized chain
419+
Vec::new()
420+
};
421+
422+
tracing::info!("Successfully fetched F3 certificate data from parent chain");
416423
Ok(Some(ipc::F3Params {
417424
instance_id,
418425
power_table,
419426
finalized_epochs,
420427
}))
421428
}
422-
None => Err(anyhow::anyhow!(
423-
"No F3 certificate available - F3 might not be running on the parent chain"
429+
Err(e) => Err(anyhow::anyhow!(
430+
"Failed to fetch F3 certificate data from parent chain: {}",
431+
e
424432
)),
425433
}
426434
}
@@ -450,20 +458,13 @@ pub async fn new_genesis_from_parent(
450458

451459
let genesis_info = parent_provider.get_genesis_info(&args.subnet_id).await?;
452460

453-
// Fetch F3 certificate data from parent chain if Filecoin RPC endpoint is provided.
454-
// If not provided, it means the parent is not Filecoin (e.g., a Fendermint subnet)
455-
// and F3 data is not available.
456-
let f3_params = if let Some(ref parent_filecoin_rpc) = args.parent_filecoin_rpc {
457-
tracing::info!("Fetching F3 data from parent Filecoin chain");
458-
fetch_f3_params_from_parent(
459-
parent_filecoin_rpc,
460-
args.parent_filecoin_auth_token.as_ref(),
461-
)
462-
.await?
463-
} else {
464-
tracing::info!("Skipping F3 data fetch - parent is not Filecoin");
465-
None
466-
};
461+
// Fetch F3 certificate data from parent chain using Lotus client directly
462+
// This requires the Filecoin/Lotus RPC endpoint, not the EVM endpoint
463+
let f3_params = fetch_f3_params_from_parent(
464+
&args.parent_filecoin_rpc,
465+
args.parent_filecoin_auth_token.as_ref(),
466+
)
467+
.await?;
467468

468469
tracing::debug!("F3 params: {:?}", f3_params);
469470

fendermint/vm/interpreter/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ fendermint_vm_genesis = { path = "../genesis" }
1818
fendermint_vm_message = { path = "../message" }
1919
fendermint_vm_resolver = { path = "../resolver" }
2020
fendermint_vm_topdown = { path = "../topdown" }
21-
fendermint_vm_topdown_proof_service = { path = "../topdown/proof-service" }
2221
fendermint_crypto = { path = "../../crypto" }
2322
fendermint_eth_hardhat = { path = "../../eth/hardhat" }
2423
fendermint_eth_deployer = { path = "../../eth/deployer" }

fendermint/vm/interpreter/src/genesis.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,16 @@ struct DeployConfig<'a> {
534534
deployer_addr: ethers::types::Address,
535535
}
536536

537+
/// Get the commit SHA for genesis contract deployment.
538+
/// For genesis, we use a default value as genesis is typically built at compile time.
539+
fn get_genesis_commit_sha() -> [u8; 32] {
540+
// Use default value for genesis (matches test default)
541+
let default_sha = b"c7d8f53f";
542+
let mut result = [0u8; 32];
543+
result[..default_sha.len()].copy_from_slice(default_sha);
544+
result
545+
}
546+
537547
fn deploy_contracts(
538548
ipc_contracts: Vec<ContractSourceAndName>,
539549
top_level_contracts: &EthContractMap,
@@ -564,7 +574,9 @@ fn deploy_contracts(
564574
GatewayParams::new(SubnetID::new(config.chain_id.into(), vec![]))
565575
};
566576

567-
let params = ConstructorParameters::new(ipc_params, validators)
577+
// Get commit SHA for genesis deployment
578+
let commit_sha = get_genesis_commit_sha();
579+
let params = ConstructorParameters::new(ipc_params, validators, commit_sha)
568580
.context("failed to create gateway constructor")?;
569581

570582
let facets = deployer

fendermint/vm/topdown/proof-service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rocksdb = { version = "0.21", features = ["multi-threaded-cf"] }
2424
futures = { workspace = true }
2525

2626
# Fendermint
27-
fendermint_actor_f3_cert_manager = { path = "../../../actors/f3-cert-manager" }
27+
fendermint_actor_f3_light_client = { path = "../../../actors/f3-light-client" }
2828
fendermint_vm_genesis = { path = "../../genesis" }
2929

3030
# IPC

ipc/cli/src/commands/subnet/create_genesis.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,9 @@ pub(crate) async fn create_genesis(
168168
subnet_id: subnet_id.clone(),
169169
parent_endpoint: parent.rpc_http().clone(),
170170
parent_auth_token: parent.auth_token(),
171-
// For F3 data, use the same endpoint as parent_endpoint by default.
172-
// In practice, for Filecoin/Calibration, both EVM and Lotus APIs are on the same endpoint.
173-
// When using ipc-cli, the parent is typically Filecoin, so F3 is available.
174-
parent_filecoin_rpc: Some(parent.rpc_http().clone()),
171+
// For F3 data, use the same endpoint as parent_endpoint by default
172+
// In practice, for Filecoin/Calibration, both EVM and Lotus APIs are on the same endpoint
173+
parent_filecoin_rpc: parent.rpc_http().clone(),
175174
parent_filecoin_auth_token: parent.auth_token(),
176175
parent_gateway: parent.gateway_addr(),
177176
parent_registry: parent.registry_addr(),

ipc/provider/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ tendermint-rpc = { workspace = true }
5858
tendermint = { workspace = true }
5959
fendermint_rpc = { path = "../../fendermint/rpc" }
6060

61-
fendermint_actor_f3_light_client = { path = "../../fendermint/actors/f3-light-client" }
62-
fendermint_vm_genesis = { path = "../../fendermint/vm/genesis" }
63-
64-
6561
fendermint_actor_f3_light_client = { path = "../../fendermint/actors/f3-light-client" }
6662
fendermint_vm_genesis = { path = "../../fendermint/vm/genesis" }
6763

ipc/provider/src/lotus/client.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ impl<T: JsonRpcClient + Send + Sync> LotusClient for LotusJsonRPCClient<T> {
374374
tracing::debug!("received f3_get_power_table_by_instance response: {r:?}");
375375
Ok(r)
376376
}
377+
378+
async fn f3_get_instance_id(&self) -> Result<u64> {
379+
// Get the latest certificate which contains the instance ID
380+
// There's no direct F3GetInstanceID method in Lotus
381+
let cert = self.f3_get_certificate().await?;
382+
match cert {
383+
Some(cert_response) => Ok(cert_response.gpbft_instance),
384+
None => Err(anyhow!(
385+
"No F3 certificate available - F3 might not be running on this chain"
386+
)),
387+
}
388+
}
377389
}
378390

379391
impl<T: JsonRpcClient + Send + Sync> LotusJsonRPCClient<T> {

0 commit comments

Comments
 (0)