Open austinabell opened 3 years ago
Thanks for opening the question. There are some inconsistencies here and it would be nice to figure out a single way of doing it.
ConfirmSectorProofsValid
does it in the transaction, for no good reasonMost of the time, I think the rt.StateReadonly(&st)
is unnecessary, and the transaction state could be used.
TerminateSectors
needs it, or would need refactoring to avoid itOnDeferredCronEvent
also needs it with the present structure (due to processing sector termination)I think we can pick a policy that we can use almost everywhere, with the possible exception of the two prior places. So the question is do we want to always load state, redundantly, to be sure it's the correct one? Or trust in our patterns and use the post-transaction state without re-loading it?
Thoughts @Stebalien @ZenGround0 ?
Without investigating too deeply I prefer consistently re-loading state redundantly because
It would be great to prioritize performance of invariant checking if we have the bandwidth at which point we could profile and revisit this question. But I expect working on parallelizing as in the migration to be much higher leverage.
Given that the only two cases where we don't currently reload the state are RepayDebt
and WithdrawBalance
, neither of which are performance critical, I'd just reload the state to be consistent (even though we know that burning funds, changing pledge, etc. are not reentrent).
From sync with other actors implementors the inconsistency here was explicitly called out as burdensome, making this now higher priority to do consistently.
Most checks load state before checking invariants, for example:
https://github.com/filecoin-project/specs-actors/blob/2a6279534fab3e1fe818f9aeeda4ab27efd57af7/actors/builtin/miner/miner_actor.go#L477-L478
Where others do not and use the state from the transaction, such as: https://github.com/filecoin-project/specs-actors/blob/2a6279534fab3e1fe818f9aeeda4ab27efd57af7/actors/builtin/miner/miner_actor.go#L1710 https://github.com/filecoin-project/specs-actors/blob/2a6279534fab3e1fe818f9aeeda4ab27efd57af7/actors/builtin/miner/miner_actor.go#L1731
When it seems like it has the same side effects as the others. Maybe there is a reason for this inconsistency, so feel free to close issue if so, but opening in case there isn't.