-
Notifications
You must be signed in to change notification settings - Fork 682
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
Drop explicit calls to chain.GetTx from txs execution paths #2431
Conversation
@@ -96,6 +96,7 @@ func TestApricotProposalBlockTimeVerification(t *testing.T) { | |||
StartTime: utx.StartTime(), | |||
NextTime: chainTime, | |||
EndTime: chainTime, | |||
Priority: utx.CurrentPriority(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed for rewritten RewardStaker to pass
type stakerAttributes struct { | ||
shares uint32 | ||
rewardsOwner fx.Owner | ||
validationRewardsOwner fx.Owner | ||
delegationRewardsOwner fx.Owner | ||
proofOfPossession *signer.ProofOfPossession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR promotes this struct to state
package, renaming it StakerRewardAttributes
"github.com/ava-labs/avalanchego/vms/platformvm/txs" | ||
) | ||
|
||
func getStakerColdAttributes(chain Chain, stakerID ids.ID) (*StakerColdAttributes, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these methods are just to avoid code duplication across state.State
and state.Diff
.
MerkleDB implementation is likely to have different implementation and not require these methods
This PR has become stale because it has been open for 30 days with no activity. Adding the |
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 tostate.Chain
interface. What we achieve in this PR is thatchain.GetTx
won't be explicitly called in txs execution, outside of thestate
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:
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