Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
947e657
fix gas estimate message gas issue
akaladarshi Sep 22, 2025
f7e232e
add unit tests
akaladarshi Sep 22, 2025
ab7f29f
fix message tipset issue
akaladarshi Sep 23, 2025
e4c32ea
add snapshot tests for the estimate message gas API
akaladarshi Sep 24, 2025
1f87632
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Sep 24, 2025
5ce5eaf
update the failing gas related snapshot and fix message response
akaladarshi Sep 24, 2025
8e73d66
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Sep 24, 2025
d5a8754
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Sep 25, 2025
fa8af08
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Oct 2, 2025
1615714
small refactor
akaladarshi Oct 3, 2025
48c2ea8
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Oct 3, 2025
33be1a5
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Oct 3, 2025
7f3452b
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Dec 4, 2025
291e4fe
fix linter issue
akaladarshi Dec 4, 2025
06ff3fe
address comments
akaladarshi Dec 8, 2025
ea881dc
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Dec 8, 2025
dbb91d0
refactor as per the comments
akaladarshi Dec 10, 2025
ec9c48e
add check for gas limit in cap gas fee
akaladarshi Dec 10, 2025
c9e4246
fix linter issue and test error
akaladarshi Dec 10, 2025
9d9f59b
address comment
akaladarshi Dec 10, 2025
e06aa75
address comment
akaladarshi Dec 11, 2025
eade8f6
fix linter issue
akaladarshi Dec 11, 2025
c42c5ec
address final comments
akaladarshi Dec 15, 2025
e2a5ad3
Merge branch 'main' into akaladarshi/fix-estimate-msg-gas
akaladarshi Dec 15, 2025
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 @@ -661,7 +661,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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

let actor_state = state
.get_actor(from_address)?
.ok_or_else(|| Error::Other("Actor state not found".to_string()))?;
Expand Down
22 changes: 20 additions & 2 deletions src/cli_shared/cli/config.rs
Original file line number Diff line number Diff line change
@@ -1,16 +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;

const FOREST_CHAIN_INDEXER_ENABLED: &str = "FOREST_CHAIN_INDEXER_ENABLED";

/// Structure that defines daemon configuration when process is detached
Expand Down Expand Up @@ -92,6 +92,23 @@ impl Default for ChainIndexerConfig {
}
}

#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct FeeConfig {
/// Indicates the default max fee for a message
#[serde(with = "crate::lotus_json")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[serde(with = "crate::lotus_json")]
/// Indicates the default max fee for a message
#[serde(with = "crate::lotus_json")]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pub max_fee: TokenAmount,
}

impl Default for FeeConfig {
fn default() -> Self {
// 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(70_000_000_000_000_000u64), // 0.07 FIL
}
}
}

#[derive(Serialize, Deserialize, PartialEq, Default, Debug, Clone)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
#[serde(default)]
Expand All @@ -104,6 +121,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: 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
6 changes: 6 additions & 0 deletions src/networks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use fil_actors_shared::v13::runtime::Policy;
use fvm_ipld_blockstore::Blockstore;
use itertools::Itertools;
use libp2p::Multiaddr;
use num_traits::Zero;
use serde::{Deserialize, Serialize};
use strum::IntoEnumIterator;
use strum_macros::Display;
Expand Down Expand Up @@ -283,6 +284,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: TokenAmount,
}

impl ChainConfig {
Expand Down Expand Up @@ -316,6 +318,7 @@ impl ChainConfig {
),
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: TokenAmount::zero(),
}
}

Expand Down Expand Up @@ -352,6 +355,7 @@ impl ChainConfig {
),
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: TokenAmount::zero(),
}
}

Expand All @@ -378,6 +382,7 @@ impl ChainConfig {
f3_initial_power_table: None,
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: TokenAmount::zero(),
}
}

Expand Down Expand Up @@ -410,6 +415,7 @@ impl ChainConfig {
f3_initial_power_table: None,
enable_indexer: false,
enable_receipt_event_caching: true,
default_max_fee: TokenAmount::zero(),
}
}

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 @@ -219,7 +219,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 @@ -229,10 +229,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 @@ -1357,6 +1360,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 @@ -848,7 +848,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 @@ -2321,7 +2321,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