Skip to content
Merged
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
37 changes: 36 additions & 1 deletion src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use self::trace::types::*;
use self::types::*;
use super::gas;
use crate::blocks::{Tipset, TipsetKey};
use crate::chain::{ChainStore, index::ResolveNullTipset};
use crate::chain::{ChainStore, compute_base_fee, index::ResolveNullTipset};
use crate::chain_sync::NodeSyncStatus;
use crate::cid_collections::CidHashSet;
use crate::eth::{
Expand All @@ -27,6 +27,7 @@ use crate::eth::{
};
use crate::lotus_json::{HasLotusJson, lotus_json_with_self};
use crate::message::{ChainMessage, MessageRead as _, MessageReadWrite as _, SignedMessage};
use crate::networks::Height;
use crate::rpc::{
ApiPaths, Ctx, EthEventHandler, LOOKBACK_NO_LIMIT, Permission, RpcMethod, RpcMethodExt as _,
error::ServerError,
Expand Down Expand Up @@ -805,6 +806,40 @@ impl RpcMethod<0> for EthAccounts {
}
}

pub enum EthBaseFee {}
impl RpcMethod<0> for EthBaseFee {
const NAME: &'static str = "Filecoin.EthBaseFee";
const NAME_ALIAS: Option<&'static str> = Some("eth_baseFee");
const PARAM_NAMES: [&'static str; 0] = [];
const API_PATHS: BitFlags<ApiPaths> = ApiPaths::all_with_v2();
const PERMISSION: Permission = Permission::Read;
Comment thread
LesnyRumcajs marked this conversation as resolved.
const DESCRIPTION: Option<&'static str> =
Some("Returns the calculated base fee of the upcoming tipset in attoFIL");

type Params = ();
type Ok = EthBigInt;

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(): Self::Params,
_: &http::Extensions,
) -> Result<Self::Ok, ServerError> {
let ts = ctx.chain_store().heaviest_tipset();
let heights = &ctx.chain_config().height_infos;
let smoke_height = heights
.get(&Height::Smoke)
.context("Missing Smoke height")?
.epoch;
let firehorse_height = heights
.get(&Height::FireHorse)
.context("Missing FireHorse height")?
.epoch;
let base_fee = compute_base_fee(ctx.store(), &ts, smoke_height, firehorse_height)
.context("failed to compute base fee for eth_baseFee")?;
Ok(EthBigInt(base_fee.atto().clone()))
}
}

pub enum EthBlockNumber {}
impl RpcMethod<0> for EthBlockNumber {
const NAME: &'static str = "Filecoin.EthBlockNumber";
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ macro_rules! for_each_rpc_method {
$callback!($crate::rpc::eth::EthAccounts);
$callback!($crate::rpc::eth::EthAddressToFilecoinAddress);
$callback!($crate::rpc::eth::FilecoinAddressToEthAddress);
$callback!($crate::rpc::eth::EthBaseFee);
$callback!($crate::rpc::eth::EthBlockNumber);
$callback!($crate::rpc::eth::EthCall);
$callback!($crate::rpc::eth::EthChainId);
Expand Down
18 changes: 18 additions & 0 deletions src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap

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

18 changes: 18 additions & 0 deletions src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap

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

18 changes: 18 additions & 0 deletions src/rpc/snapshots/forest__rpc__tests__rpc__v2.snap

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

1 change: 1 addition & 0 deletions src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Filecoin.ChainExport
Filecoin.ChainGetEvents
Filecoin.ChainGetFinalizedTipset
Filecoin.ChainSetHead
Filecoin.EthBaseFee
Filecoin.EthEstimateGas
Filecoin.EthGetFilterChanges
Filecoin.EthGetFilterLogs
Expand Down
Loading