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

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Dec 17, 2024

Summary of changes

See #4968

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes #4968

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 marked this pull request as ready for review December 17, 2024 05:53
@hanabi1224 hanabi1224 requested a review from a team as a code owner December 17, 2024 05:53
@hanabi1224 hanabi1224 requested review from lemmih and elmattic and removed request for a team December 17, 2024 05:53
@@ -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!

@@ -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

Choose a reason for hiding this comment

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

Nice catch!

@lemmih lemmih added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit 0c71e52 Dec 17, 2024
39 checks passed
@lemmih lemmih deleted the hm/fix-StateCirculatingSupply branch December 17, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix failing Filecoin.StateCirculatingSupply RPC tests or corresponding endpoint.
3 participants