-
Notifications
You must be signed in to change notification settings - Fork 324
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
[contractstaking] fix invalid delta transfer #3924
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3924 +/- ##
==========================================
+ Coverage 75.38% 76.01% +0.63%
==========================================
Files 303 328 +25
Lines 25923 27859 +1936
==========================================
+ Hits 19541 21176 +1635
- Misses 5360 5590 +230
- Partials 1022 1093 +71
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -27,6 +27,7 @@ var ( | |||
}, | |||
deltaStateAdded: { | |||
deltaActionModify: deltaStateAdded, | |||
deltaActionRemove: deltaStateUnchanged, |
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.
what about deltaStateRemoved
? does it need a state-transition?
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.
as we chatted, also need to check blkHeight == currentHeight + 1
in PutBlock()
?
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.
what about
deltaStateRemoved
? does it need a state-transition?
no valid action could be triggered on deltaStateRemoved
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.
as we chatted, also need to check
blkHeight == currentHeight + 1
inPutBlock()
?
Thx for reminding
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.
add a test to validate, once a bucket is deleted, i.e., deltaStateRemoved
, it cannot transition to any further state (in the same block)
@@ -121,9 +121,16 @@ func (s *Indexer) BucketTypes() ([]*BucketType, error) { | |||
|
|||
// PutBlock puts a block into indexer | |||
func (s *Indexer) PutBlock(ctx context.Context, blk *block.Block) error { | |||
if blk.Height() < s.contractDeployHeight || blk.Height() <= s.cache.Height() { | |||
expectHeight := s.cache.Height() + 1 |
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.
remove empty line
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
Stake
andMerge
in one transaction will cause actiondeltaActionRemove
on statedeltaStateAdded
, which is not allowed currently. But this scenario should be legal, so this transfer should be allowed instead.Fixes #3921
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: