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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

### Fixed

- [#7227](https://github.com/ChainSafe/forest/issues/7227): Fixed invalid `Filecoin.GasEstimateGasPremium` and `Filecoin.GasEstimateFeeCap` responses that were returning a fraction instead of an integer.

## Forest v0.33.7 "Shimmergloom"

### Added
Expand Down
1 change: 1 addition & 0 deletions scripts/tests/api_compare/filter-list-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
!Filecoin.EthGetTransactionByHashLimited
!Filecoin.F3
!Filecoin.GasEstimateGasLimit
!Filecoin.GasEstimateFeeCap
!Filecoin.MinerCreateBlock
!Filecoin.MpoolGetConfig
!Filecoin.MpoolSelect
Expand Down
10 changes: 4 additions & 6 deletions src/rpc/methods/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ impl RpcMethod<3> for GasEstimateFeeCap {
Some("Returns the estimated fee cap for the given parameters.");

type Params = (Message, i64, ApiTipsetKey);
type Ok = String;
type Ok = TokenAmount;

async fn handle(
ctx: Ctx,
(msg, max_queue_blks, tsk): Self::Params,
_: &http::Extensions,
) -> Result<Self::Ok, ServerError> {
estimate_fee_cap(&ctx, &msg, max_queue_blks, &tsk).map(|n| TokenAmount::to_string(&n))
estimate_fee_cap(&ctx, &msg, max_queue_blks, &tsk)
}
}

Expand Down Expand Up @@ -85,16 +85,14 @@ impl RpcMethod<4> for GasEstimateGasPremium {
Some("Returns the estimated gas premium for the given parameters.");

type Params = (u64, Address, i64, ApiTipsetKey);
type Ok = String;
type Ok = TokenAmount;

async fn handle(
ctx: Ctx,
(nblocksincl, _sender, _gas_limit, tsk): Self::Params,
_: &http::Extensions,
) -> Result<Self::Ok, ServerError> {
estimate_gas_premium(&ctx, nblocksincl, &tsk)
.await
.map(|n| TokenAmount::to_string(&n))
estimate_gas_premium(&ctx, nblocksincl, &tsk).await
}
}

Expand Down
4 changes: 2 additions & 2 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.

4 changes: 2 additions & 2 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.

31 changes: 30 additions & 1 deletion src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,7 @@ fn gas_tests_with_tipset(shared_tipset: &Tipset) -> Vec<RpcTest> {
// return reasonable values within expected bounds rather than exact equality.
RpcTest::validate(
GasEstimateMessageGas::request((
message,
message.clone(),
None, // No MessageSendSpec
shared_tipset.key().into(),
))
Expand Down Expand Up @@ -2417,6 +2417,35 @@ fn gas_tests_with_tipset(shared_tipset: &Tipset) -> Vec<RpcTest> {
&& forest_premium.is_within_percent(lotus_premium, 5)
},
),
// Pin to `shared_tipset` so both nodes compute over the same chain history;
// the only remaining difference is each node's ±1% gaussian noise, which the
// 5% tolerance absorbs. The heaviest tipset would compare two independently-
// synced heads and diff arbitrarily.
RpcTest::validate(
GasEstimateGasPremium::request((3, addr, 9, shared_tipset.key().into())).unwrap(),
|forest_premium, lotus_premium| {
// Gas premium should not be negative
if forest_premium.is_negative() || lotus_premium.is_negative() {
return false;
}

forest_premium.is_within_percent(&lotus_premium, 5)
},
),
// The fee cap derives from the noise-perturbed premium, so use the same 5%
// tolerance; pinning to `shared_tipset` fixes the parent base fee both nodes
// read. Deserializing the result as `TokenAmount` is what rejects a FIL-decimal
// serialization regression (such a string fails to parse as an integer).
RpcTest::validate(
GasEstimateFeeCap::request((message, 20, shared_tipset.key().into())).unwrap(),
|forest_fee_cap, lotus_fee_cap| {
if forest_fee_cap.is_negative() || lotus_fee_cap.is_negative() {
return false;
}

forest_fee_cap.is_within_percent(&lotus_fee_cap, 5)
},
),
]
}

Expand Down
Loading