Questions About block on the endpoint /account/balance

Is it required to record the blocks where the account balance changes? We now have no record of block height where account balance changes.
If this feature is required, it means we need to modify the database to support this feature.

:wave: @Matt.Yue

Is it required to record the blocks where the account balance changes?

I’m assuming you are referring to supporting historical balance lookup (AKA supporting queries where the client populates the PartialBlockIdentifier in an /account/balance request):

It is not required to support historical balance lookup, although it is encouraged. If supporting this feature would require substantial changes to your node runtime (which it sounds like it would), I would only consider supporting it after you have fully completed your Rosetta API implementation (both Data API and Construction API). All validation tooling (i.e. running rosetta-cli check) still works when balances can not be retrieved at specific blocks.

To indicate your implementation does not support historical balance lookup, make sure to specify this in your /network/options response by setting NetworkOptionsResponse.Allow.HistoricalBalanceLookup=false. It will default to false but better to be explicit here!

Nice, block_identifier is not required. tks

If set NetworkOptionsResponse.Allow.HistoricalBalanceLookup=false, what does block_identifier in AccountBalanceResponse return ?

If a block_identifier is not provided in the AccountBalanceRequest, it is assumed that the block_identifier returned in AccountBalanceResponse is the current block.

This is documented on AccountBalanceRequest:

When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. If neither property is specified, it is assumed that the client is making a request at the current block.

If you’d like to improve these docs (calling this behavior out in the response), I’d be happy to review it:

sorry I didn’t see the description. It’s clear.

1 Like