avalanchego
avalanchego copied to clipboard
Drop explicit calls to chain.GetTx from txs execution paths
Why this should be merged
MerkleDB is likely to require dropping the use of Chain.GetTx
in txs execution in favour of smaller, more specific data, whose lifetime is bounded as stakers objects' one. That is to say object that can be deleted once staker is removed, unlike txs which are currently stored indefinitely on disk.
This PR is a step into that direction: without removing Chain.GetTx
, we add a couple of method to state.Chain
interface. What we achieve in this PR is that chain.GetTx
won't be explicitly called in txs execution, outside of the state
package.
What we gain in this way is freedom for a merkleDB based P-chain to avoid storing txs into the merkleDB section, since they won't be needed to verify transactions.
In this PR we still use chain.GetTx
under the hood, so that we avoid storing extra data to db and requiring a db migration.
The increase in LOC is mostly due to mock implementation of the new methods
How this works
This PR adds
-
GetChainSubnet(chainID ids.ID) (ids.ID, error)
-
GetStakerRewardAttributes(stakerID ids.ID) (*StakerRewardAttributes, error)
to state.Chain
.
This PR does not:
- change data layout on db (no extra data added, no data removed)
- introduce a
DeleteStakerRewardAttributes
(similar toDeleteStaker
, to bound cold attribute lifetime), yet, since stakers cold attribute are not store independently from txs. But a P-chain merkleDB could!
How this was tested
CI