Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chain/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ where

for message in unsigned_box.chain(signed_box) {
let from_address = &message.from();
if applied.contains_key(from_address) {
if !applied.contains_key(from_address) {
let actor_state = state
.get_actor(from_address)?
.ok_or_else(|| Error::Other("Actor state not found".to_string()))?;
Expand Down
25 changes: 23 additions & 2 deletions src/cli_shared/cli/config.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright 2019-2025 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use super::client::Client;
use crate::db::db_engine::DbConfig;
use crate::libp2p::Libp2pConfig;
use crate::shim::clock::ChainEpoch;
use crate::shim::econ::TokenAmount;
use crate::utils::misc::env::is_env_set_and_truthy;
use crate::{chain_sync::SyncConfig, networks::NetworkChain};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

use super::client::Client;
use std::str::FromStr;

const FOREST_CHAIN_INDEXER_ENABLED: &str = "FOREST_CHAIN_INDEXER_ENABLED";

Expand Down Expand Up @@ -92,6 +93,25 @@ impl Default for ChainIndexerConfig {
}
}

#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct FeeConfig {
#[serde(with = "crate::lotus_json")]
pub max_fee: TokenAmount,
}

impl Default for FeeConfig {
fn default() -> Self {
// This indicates the default max fee for a message,
// The code is taken from https://github.com/filecoin-project/lotus/blob/release/v1.34.1/node/config/def.go#L39
Self {
max_fee: TokenAmount::from_atto(
num_bigint::BigInt::from_str("70000000000000000").unwrap(),
), // 0.07 FIL
}
}
}

#[derive(Serialize, Deserialize, PartialEq, Default, Debug, Clone)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
#[serde(default)]
Expand All @@ -104,6 +124,7 @@ pub struct Config {
pub daemon: DaemonConfig,
pub events: EventsConfig,
pub fevm: FevmConfig,
pub fee: FeeConfig,
pub chain_indexer: ChainIndexerConfig,
}

Expand Down
1 change: 1 addition & 0 deletions src/daemon/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn get_chain_config_and_set_network(config: &Config) -> Arc<ChainConfig> {
Arc::new(ChainConfig {
enable_indexer: config.chain_indexer.enable_indexer,
enable_receipt_event_caching: config.client.enable_rpc,
default_max_fee: Some(config.fee.max_fee.clone()),
..chain_config
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/lotus_json/signed_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl HasLotusJson for SignedMessage {
},
}),
SignedMessage {
message: crate::shim::message::Message::default(),
signature: crate::shim::crypto::Signature {
message: Message::default(),
signature: Signature {
sig_type: crate::shim::crypto::SignatureType::Bls,
bytes: Vec::from_iter(*b"hello world!"),
},
Expand Down
5 changes: 5 additions & 0 deletions src/networks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ pub struct ChainConfig {
pub f3_initial_power_table: Option<Cid>,
pub enable_indexer: bool,
pub enable_receipt_event_caching: bool,
pub default_max_fee: Option<TokenAmount>,
}

impl ChainConfig {
Expand Down Expand Up @@ -304,6 +305,7 @@ impl ChainConfig {
),
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: None,
}
}

Expand Down Expand Up @@ -340,6 +342,7 @@ impl ChainConfig {
),
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: None,
}
}

Expand All @@ -366,6 +369,7 @@ impl ChainConfig {
f3_initial_power_table: None,
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: None,
}
}

Expand Down Expand Up @@ -398,6 +402,7 @@ impl ChainConfig {
f3_initial_power_table: None,
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: None,
}
}

Expand Down
21 changes: 18 additions & 3 deletions src/rpc/methods/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl RpcMethod<1> for ChainGetMessage {
const DESCRIPTION: Option<&'static str> = Some("Returns the message with the specified CID.");

type Params = (Cid,);
type Ok = Message;
type Ok = FlattenedApiMessage;

async fn handle(
ctx: Ctx<impl Blockstore>,
Expand All @@ -164,10 +164,13 @@ impl RpcMethod<1> for ChainGetMessage {
.store()
.get_cbor(&message_cid)?
.with_context(|| format!("can't find message with cid {message_cid}"))?;
Ok(match chain_message {
let message = match chain_message {
ChainMessage::Signed(m) => m.into_message(),
ChainMessage::Unsigned(m) => m,
})
};

let cid = message.cid();
Ok(FlattenedApiMessage { message, cid })
}
}

Expand Down Expand Up @@ -1052,6 +1055,18 @@ pub struct ApiMessage {

lotus_json_with_self!(ApiMessage);

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, Eq, PartialEq)]
pub struct FlattenedApiMessage {
#[serde(flatten, with = "crate::lotus_json")]
#[schemars(with = "LotusJson<Message>")]
pub message: Message,
#[serde(rename = "CID", with = "crate::lotus_json")]
#[schemars(with = "LotusJson<Cid>")]
pub cid: Cid,
}

lotus_json_with_self!(FlattenedApiMessage);

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ForestChainExportParams {
pub version: FilecoinSnapshotVersion,
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ impl RpcMethod<0> for EthGasPrice {
let ts = ctx.chain_store().heaviest_tipset();
let block0 = ts.block_headers().first();
let base_fee = block0.parent_base_fee.atto();
let tip = crate::rpc::gas::estimate_gas_premium(&ctx, 0)
let tip = crate::rpc::gas::estimate_gas_premium(&ctx, 0, &ApiTipsetKey(None))
.await
.map(|gas_premium| gas_premium.atto().to_owned())
.unwrap_or_default();
Expand Down Expand Up @@ -2286,7 +2286,7 @@ impl RpcMethod<0> for EthMaxPriorityFeePerGas {
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(): Self::Params,
) -> Result<Self::Ok, ServerError> {
match crate::rpc::gas::estimate_gas_premium(&ctx, 0).await {
match gas::estimate_gas_premium(&ctx, 0, &ApiTipsetKey(None)).await {
Ok(gas_premium) => Ok(EthBigInt(gas_premium.atto().clone())),
Err(_) => Ok(EthBigInt(num_bigint::BigInt::zero())),
}
Expand Down
Loading
Loading