Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): StateCirculatingSupply #5090

Merged
merged 1 commit into from
Dec 17, 2024
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: 0 additions & 2 deletions scripts/tests/api_compare/filter-list
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
!Filecoin.StateReplay
# TODO(elmattic): https://github.com/ChainSafe/forest/issues/4851
!Filecoin.EthGetLogs
# TODO: https://github.com/ChainSafe/forest/issues/4968
!Filecoin.StateCirculatingSupply
# TODO: https://github.com/ChainSafe/forest/issues/4996
!Filecoin.EthGetTransactionReceipt
!Filecoin.EthGetTransactionReceiptLimited
Expand Down
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list-offline
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
!Filecoin.ChainSetHead
# TODO(elmattic): https://github.com/ChainSafe/forest/issues/4759
!Filecoin.EthGetLogs
# TODO: https://github.com/ChainSafe/forest/issues/4968
!Filecoin.StateCirculatingSupply
# TODO: https://github.com/ChainSafe/forest/issues/4996
!Filecoin.EthGetTransactionReceipt
!Filecoin.EthGetTransactionReceiptLimited
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,8 @@ impl RpcMethod<1> for StateCirculatingSupply {
let height = ts.epoch();
let root = ts.parent_state();
let genesis_info = GenesisInfo::from_chain_config(ctx.chain_config().clone());
let supply = genesis_info.get_state_circulating_supply(height, &ctx.store_owned(), root)?;
let supply =
genesis_info.get_state_circulating_supply(height - 1, &ctx.store_owned(), root)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

func (a *StateAPI) StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) {
	ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
	if err != nil {
		return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
	}

	sTree, err := a.StateManager.ParentState(ts)
	if err != nil {
		return types.EmptyInt, err
	}
	return a.StateManager.GetCirculatingSupply(ctx, ts.Height()-1, sTree)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Ok(supply)
}
}
Expand Down
Loading