-
Notifications
You must be signed in to change notification settings - Fork 115
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
staking: paranoid writeback changes #4466
base: master
Are you sure you want to change the base?
Conversation
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 "looks" ok, but I would feel better about it if our test cases covered the edge cases that lead to the weirdness in the first place.
@@ -79,15 +79,14 @@ func (app *stakingApplication) transfer(ctx *api.Context, state *stakingState.Mu | |||
return nil, err | |||
} | |||
|
|||
if err = state.SetAccount(ctx, fromAddr, from); err != nil { | |||
return nil, fmt.Errorf("failed to fetch account: %w", err) |
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.
While you're here, probably change this?
// copies of it and overwrite it later. | ||
var from *staking.Account | ||
if toAddr.Equal(reclaim.Account) { | ||
from = to |
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 was deliberate if somewhat wonky, but to
is never mutated, so the removal appears to be ok.
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.
right, to prevent creating multiple in-memory representations of the same record that can get out of sync. in the changed version, we no longer attempt to load the "to"/delegator account. to
is gone altogether, so we thus still avoid that condition
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.
The thinking behind the current setup is that these Set
calls can only fail in case there is state corruption in which case all state updates are rolled back and consensus halts.
You could also use:
ctx = ctx.NewTransaction()
defer ctx.Close()
// ...
ctx.Commit()
oh the transaction way would be nice. this being something that came up while thinking about adding a minimum balance check, it seems more correct to create a transaction and roll back if the minimum balance is not met |
fb277d9
to
a46e0e9
Compare
ok Set* rearrangements removed, NewTransaction + Commit added |
a46e0e9
to
a679055
Compare
no, this is all wrong, we can't just start a transaction and keep using the same |
Codecov Report
@@ Coverage Diff @@
## master #4466 +/- ##
==========================================
+ Coverage 68.83% 69.06% +0.23%
==========================================
Files 415 415
Lines 46799 46816 +17
==========================================
+ Hits 32214 32334 +120
+ Misses 10625 10543 -82
+ Partials 3960 3939 -21
Continue to review full report at Codecov.
|
transfer/withdraw saves from account first, then to account:
reclaim escrow inconsistencies in partial failure, under new ordering:
add escrow seems fine as is:
do we want these changes? I can split these up if we want some and not others