Conversation
|
@shargon Ready for merge? |
erikzhang
left a comment
There was a problem hiding this comment.
If state_account.VoteTo keeps the original value, then other changes should also be rolled back, otherwise transaction consistency cannot be guaranteed. Maybe Vote() shouldn't return bool, but should throw an exception when something goes wrong.
|
Retesting. |
|
Test passed:
|
|
@erikzhang Could you review it again? |
| validator_new = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_Candidate).Add(voteTo))?.GetInteroperable<CandidateState>(); | ||
| if (validator_new is null) return false; | ||
| if (!validator_new.Registered) return false; | ||
| } |
There was a problem hiding this comment.
why not throw an exception?
There was a problem hiding this comment.
Returning false can give the contract a chance to recover from the exception. Throwing an exception will directly terminate the virtual machine. we should try not to throw exceptions if the consistency can be guaranteed.
|
Retest passed.
|
|
Looks good now. |
|
@erikzhang Shall we merge? |
|
@shargon Need your merge. |
* Classes related to Neo.SmartContract types should not be internal (#1785) * Classes related to Neo.SmartContract types should not be internal Fixes #1782 * public callbacks + protected internal service methods * Add AsReadOnly() Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> Co-authored-by: Shargon <shargon@gmail.com> * Add AppEngine.ValidateCallFlags to be callable by subclasses (#1784) * Update ApplicationEngine.cs separate call flag validation into separate function so it can be called by ApplicationEngine subclasses. This is needed for the debugger, which overrides a few of the standard service implementations * fix whitespace * protected internal addGas Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> * Fix vote (#1792) * fix vote * add ut * throw exception * fix * fix ut Co-authored-by: Tommo-L <luchuan@neo.org> Co-authored-by: erikzhang <erik@neo.org> * preview3 * Update dependency Co-authored-by: Harry Pierson <harrypierson@hotmail.com> Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> Co-authored-by: Tommo-L <luchuan@neo.org>
* Classes related to Neo.SmartContract types should not be internal (neo-project#1785) * Classes related to Neo.SmartContract types should not be internal Fixes neo-project#1782 * public callbacks + protected internal service methods * Add AsReadOnly() Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> Co-authored-by: Shargon <shargon@gmail.com> * Add AppEngine.ValidateCallFlags to be callable by subclasses (neo-project#1784) * Update ApplicationEngine.cs separate call flag validation into separate function so it can be called by ApplicationEngine subclasses. This is needed for the debugger, which overrides a few of the standard service implementations * fix whitespace * protected internal addGas Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> * Fix vote (neo-project#1792) * fix vote * add ut * throw exception * fix * fix ut Co-authored-by: Tommo-L <luchuan@neo.org> Co-authored-by: erikzhang <erik@neo.org> * preview3 * Update dependency Co-authored-by: Harry Pierson <harrypierson@hotmail.com> Co-authored-by: Harry Pierson <harrypierson@ngd.neo.org> Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> Co-authored-by: Tommo-L <luchuan@neo.org>


Close #1790