Skip to content

Commit 435f64d

Browse files
committed
morph: fix error from CalculateNonceAndVUB
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. Signed-off-by: Andrey Butusov <[email protected]>
1 parent 653d9f8 commit 435f64d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Changelog for NeoFS Node
2525
- `neofs_node_engine_list_objects_time_bucket` metric (#3120)
2626
- The correct role parameter to invocation (#3127)
2727
- nil pointer error for `storage sanity` command (#3151)
28+
- Calculation of VUB when it is impossible to get the transaction height (#3134)
2829

2930
### Changed
3031
- Number of cuncurrenly handled notifications from the chain was increased from 10 to 300 for IR (#3068)

pkg/innerring/state.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ func (s *Server) voteForFSChainValidator(validators keys.PublicKeys, trigger *ut
128128
if trigger != nil {
129129
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(*trigger)
130130
if err != nil {
131-
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values: %w", err)
131+
s.log.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err))
132+
nonce, vub, err = s.morphClient.CalculateNonceAndVUB(util.Uint256{})
133+
if err != nil {
134+
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values for zero hash: %w", err)
135+
}
132136
}
133137
vubP = &vub
134138
}

pkg/morph/client/notary.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ func (c *Client) UpdateNotaryList(notaries keys.PublicKeys, txHash util.Uint256)
268268

269269
nonce, vub, err := c.CalculateNonceAndVUB(txHash)
270270
if err != nil {
271-
return fmt.Errorf("could not calculate nonce and `valicUntilBlock` values: %w", err)
271+
c.logger.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err))
272+
nonce, vub, err = c.CalculateNonceAndVUB(util.Uint256{})
273+
if err != nil {
274+
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values for zero hash: %w", err)
275+
}
272276
}
273277

274278
return c.notaryInvokeAsCommittee(
@@ -292,7 +296,11 @@ func (c *Client) UpdateNeoFSAlphabetList(alphas keys.PublicKeys, txHash util.Uin
292296

293297
nonce, vub, err := c.CalculateNonceAndVUB(txHash)
294298
if err != nil {
295-
return fmt.Errorf("could not calculate nonce and `valicUntilBlock` values: %w", err)
299+
c.logger.Debug("could not calculate nonce and `validUntilBlock` values", zap.Error(err))
300+
nonce, vub, err = c.CalculateNonceAndVUB(util.Uint256{})
301+
if err != nil {
302+
return fmt.Errorf("could not calculate nonce and `validUntilBlock` values for zero hash: %w", err)
303+
}
296304
}
297305

298306
return c.notaryInvokeAsCommittee(
@@ -767,6 +775,14 @@ func (c *Client) CalculateNonceAndVUB(hash util.Uint256) (nonce uint32, vub uint
767775

768776
nonce = binary.LittleEndian.Uint32(hash.BytesLE())
769777

778+
if hash.Equals(util.Uint256{}) {
779+
c.logger.Debug("get zero hash to calculate nonce and vub")
780+
vub, err = c.notaryTxValidationLimit(conn)
781+
if err != nil {
782+
return 0, 0, fmt.Errorf("could not get vub validation limit: %w", err)
783+
}
784+
return nonce, vub, nil
785+
}
770786
height, err := c.getTransactionHeight(conn, hash)
771787
if err != nil {
772788
return 0, 0, fmt.Errorf("could not get transaction height: %w", err)

0 commit comments

Comments
 (0)