-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix error from CalculateNonceAndVUB
#3134
Fix error from CalculateNonceAndVUB
#3134
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3134 +/- ##
==========================================
- Coverage 23.04% 23.03% -0.01%
==========================================
Files 756 756
Lines 60202 60212 +10
==========================================
- Hits 13872 13870 -2
- Misses 45334 45345 +11
- Partials 996 997 +1 ☔ View full report in Codecov by Sentry. |
2257c3c
to
8fa1b74
Compare
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.
Can we somehow do this only for this special main chain case? The problem is that in the vast majority of cases the original error is more appropriate, there has to be a transaction. Maybe we can pass zero hash in this case and then fallback to this scheme without transaction height query?
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.
Agree that we need to separate this logic for events from main and FS chains. For FS chains it is a real problem if no TX found while for main it should not be even tried. TBH I even cannot say if we have any non-notary notifications from FS chain but it should not change anything, they may appear at any time, morph
client was meant to be for every chain (at least it is now, without additional chages i would keep this).
3aae148
to
435f64d
Compare
pkg/innerring/state.go
Outdated
@@ -128,7 +128,11 @@ func (s *Server) voteForFSChainValidator(validators keys.PublicKeys, trigger *ut | |||
if trigger != nil { | |||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(*trigger) | |||
if err != nil { | |||
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values: %w", err) | |||
s.log.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err)) | |||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(util.Uint256{}) |
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.
commit states
... an error is returned because there is no hash in the FSchain. Ignore the error and calculate the value in another way
but we switch to zero hash on any failure. Shouldnt we check the exact case?
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.
IIUC we should always call CalculateNonceAndVUB
with util.Uint256{}
in voteForFSChainValidator
if trigger == nil
, because the only user of this method (not counting validator predefined in config) is governance processor reacting to main chain events.
pkg/innerring/state.go
Outdated
@@ -128,7 +128,11 @@ func (s *Server) voteForFSChainValidator(validators keys.PublicKeys, trigger *ut | |||
if trigger != nil { | |||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(*trigger) | |||
if err != nil { | |||
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values: %w", err) | |||
s.log.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(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.
the hash can also be useful
pkg/innerring/state.go
Outdated
s.log.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err)) | ||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(util.Uint256{}) | ||
if err != nil { | ||
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values for zero hash: %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.
how about wrapping both errors?
pkg/innerring/state.go
Outdated
@@ -128,7 +128,11 @@ func (s *Server) voteForFSChainValidator(validators keys.PublicKeys, trigger *ut | |||
if trigger != nil { | |||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(*trigger) | |||
if err != nil { | |||
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values: %w", err) | |||
s.log.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err)) | |||
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(util.Uint256{}) |
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.
IIUC we should always call CalculateNonceAndVUB
with util.Uint256{}
in voteForFSChainValidator
if trigger == nil
, because the only user of this method (not counting validator predefined in config) is governance processor reacting to main chain events.
435f64d
to
b1cfbb4
Compare
The alphabetic key change event comes from the main chain with its hash, and when calculating vub, an error is returned because there is no hash in the FS chain. So for designation event of the mainnet RoleManagement contract transaction hash is set to zero. `CalculateNonceAndVUB` can now handle zero hashes and calculate vub rounded. Signed-off-by: Andrey Butusov <[email protected]>
Signed-off-by: Andrey Butusov <[email protected]>
b1cfbb4
to
0ddb375
Compare
Designation event of the mainnet RoleManagement contract contains a hash from the main chain, so I just made it zero, so that later it calculated |
@@ -40,6 +40,6 @@ func ParseDesignate(e *state.ContainedNotificationEvent) (event.Event, error) { | |||
|
|||
return Designate{ | |||
Role: noderoles.Role(bi.Int64()), | |||
TxHash: e.Container, | |||
TxHash: util.Uint256{}, |
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.
I'm not excited about this one because I'd expect this "real->fake" translation at some other layer dealing with the event. But it should work.
The alphabetic key change event comes from the main chain with its hash, and when calculating vub, an error is returned because there is no hash in the fs chain. Ignore the error and calculate the value in another way.