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

feat(rpc): implement Filecoin.StateMarketParticipants #4302

Merged
merged 1 commit into from
May 9, 2024

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented May 9, 2024

Summary of changes

Part of #4164

Changes introduced in this pull request:

  • implement RPC method Filecoin.StateMarketParticipants
  • API compare tests
     Running `target/quick/forest-tool api compare /home/me/fr/snapshots/calibnet/forest_snapshot_calibnet_2024-05-07_height_1591906.forest.car.zst --filter StateMarketParticipants`
| RPC Method                            | Forest | Lotus |
|---------------------------------------|--------|-------|
| Filecoin.StateMarketParticipants (10) | Valid  | Valid |

Lotus code:

func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketBalance, error) {
	out := map[string]api.MarketBalance{}

	ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
	if err != nil {
		return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
	}

	state, err := a.StateManager.GetMarketState(ctx, ts)
	if err != nil {
		return nil, err
	}
	escrow, err := state.EscrowTable()
	if err != nil {
		return nil, err
	}
	locked, err := state.LockedTable()
	if err != nil {
		return nil, err
	}

	err = escrow.ForEach(func(a address.Address, es abi.TokenAmount) error {

		lk, err := locked.Get(a)
		if err != nil {
			return err
		}

		out[a.String()] = api.MarketBalance{
			Escrow: es,
			Locked: lk,
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return out, nil
}

Reference issue to close (if applicable)

Closes #4303

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • 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 May 9, 2024 07:13
@hanabi1224 hanabi1224 requested a review from a team as a code owner May 9, 2024 07:13
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team May 9, 2024 07:13
@hanabi1224 hanabi1224 added this pull request to the merge queue May 9, 2024
Merged via the queue into main with commit e5066ba May 9, 2024
44 of 47 checks passed
@hanabi1224 hanabi1224 deleted the hm/StateMarketParticipants branch May 9, 2024 10:26
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.

Filecoin.StateMarketParticipants
3 participants