Skip to content

Commit

Permalink
Merge pull request #5493 from oasisprotocol/ptrus/stable/23.0.x/backp…
Browse files Browse the repository at this point in the history
…orts

[BACKPORT/23.0.x] 5488 5492
  • Loading branch information
ptrus authored Nov 30, 2023
2 parents 8313374 + a34e8fb commit 8529efd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions .changelog/5488.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rhp: don't prepend 'failed to read response' to runtime module errors
1 change: 1 addition & 0 deletions .changelog/5492.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage/checkpoints: Ignore i/o root in genesis checkpoint
6 changes: 3 additions & 3 deletions go/runtime/host/protocol/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (c *connection) call(ctx context.Context, body *Body) (result *Body, err er
// Await a response.
resp, err := c.readResponse(ctx, respCh)
if err != nil {
return nil, fmt.Errorf("failed to read response: %w", err)
return nil, err
}

return resp, nil
Expand All @@ -349,9 +349,9 @@ func (c *connection) readResponse(ctx context.Context, respCh <-chan *Body) (*Bo

return resp, nil
case <-c.closeCh:
return nil, fmt.Errorf("connection closed")
return nil, fmt.Errorf("failed to read response: %w", fmt.Errorf("connection closed"))
case <-ctx.Done():
return nil, ctx.Err()
return nil, fmt.Errorf("failed to read response: %w", ctx.Err())
}
}

Expand Down
28 changes: 25 additions & 3 deletions go/worker/storage/committee/checkpoint_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,17 @@ func (n *Node) getCheckpointList() ([]*storageSync.Checkpoint, error) {
return list, nil
}

func (n *Node) checkCheckpointUsable(cp *storageSync.Checkpoint, remainingMask outstandingMask) bool {
func (n *Node) checkCheckpointUsable(cp *storageSync.Checkpoint, remainingMask outstandingMask, genesisRound uint64) bool {
namespace := n.commonNode.Runtime.ID()
if !namespace.Equal(&cp.Root.Namespace) {
// Not for the right runtime.
return false
}
if cp.Root.Version == genesisRound && cp.Root.Type == storageApi.RootTypeIO {
// Never fetch i/o root for genesis round.
return false
}

blk, err := n.commonNode.Runtime.History().GetCommittedBlock(n.ctx, cp.Root.Version)
if err != nil {
n.logger.Error("can't get block information for checkpoint, skipping", "err", err, "root", cp.Root)
Expand Down Expand Up @@ -374,13 +379,14 @@ func (n *Node) syncCheckpoints(genesisRound uint64, wantOnlyGenesis bool) (*bloc
}()

for _, check := range cps {
if check.Root.Version < genesisRound || !n.checkCheckpointUsable(check, remainingRoots) {

if check.Root.Version < genesisRound || !n.checkCheckpointUsable(check, remainingRoots, genesisRound) {
continue
}

if check.Root.Version != prevVersion {
// Starting a new round, so we need to clean up all state from
// previous retores. Aborting multipart works with no multipart in
// previous retries. Aborting multipart works with no multipart in
// progress too.
multipartRunning = false
if err := n.localStorage.NodeDB().AbortMultipartInsert(); err != nil {
Expand All @@ -393,6 +399,22 @@ func (n *Node) syncCheckpoints(genesisRound uint64, wantOnlyGenesis bool) (*bloc
remainingRoots = outstandingMaskFull
prevVersion = check.Root.Version
syncState.Roots = nil

if check.Root.Version == genesisRound {
// Genesis round has no i/o root. The remote node could have
// (an invalid) one checkpointed, if its history state was not
// cleared during a dump-restore upgrade. Ignore fetching it and
// use an empty i/o root.
remainingRoots.remove(storageApi.RootTypeIO)

root := storageApi.Root{
Namespace: check.Root.Namespace,
Version: check.Root.Version,
Type: storageApi.RootTypeIO,
}
root.Hash.Empty()
syncState.Roots = append(syncState.Roots, root)
}
}

status, err := n.handleCheckpoint(check, n.checkpointSyncCfg.ChunkFetcherCount)
Expand Down

0 comments on commit 8529efd

Please sign in to comment.