Closed pugachAG closed 7 months ago
My summary of necessary changes:
prev_validator_proposals
field goes to BlockInfo::proposals, used in epoch manager, validated in validate_chunk_headers
. It can stay unchanged, but it feels more natural to propagate most recent proposals, available in validator_proposals
in post-state-root world. New name should be validator_proposals
. Edge case: on first block with post-state-root we should add both prev and current proposals.gas_price
- this will not define gas_price in post-state-root world, so I would change it to next_gas_price
to reflect reality. And use newly introduced gas_used and balance_burnt, indeed. Edge case: on first block with post-state-root, aggregate both prev_gas_used and gas_used.Not that necessary changes - we can remove challenges_root and challenges_result, as we don't plan to implement challenges anymore. We could consider the same about block_ordinal and epoch_sync_data_hash.
Full fields description:
After a bit of discussions, I think that there are no necessary fields to change.
Let's stop caring about what's the name of the field. Focus on invariant instead, which is:
Validator proposals must be applied at the same time to EpochManager (during add_validator_proposals) and State (during chunk processing) This is handled by 2-staged processing of proposals: 1) Stake Action is processed during applying chunk. Its result is saved as "validator proposal" and stored to ApplyChunkResult, which then goes to ChunkExtra. 2) On applying next block we take these previously saved proposals and: 2a) apply them to EpochManager 2b) apply them to State during processing of respective chunk
So nothing changes here. With post-state-root, we can just pass proposals using chunk header itself (new validator_proposals
field), not chunk extra. Changing block header contents would be actually a mistake.
I assumed that in pre-state-root, for applying chunk, gas price is taken from the block which contains this chunk, as we already know the block.
But it’s not the case. We take gas price from previous block: https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
I don't know why. But in both pre and post state roots previous block exists anyway, so we can avoid any changes there.
(@pugachAG: we can still just rename this field to next_gas_price
to avoid further confusion)
Extend block production logic to support post-state-root version