-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3049 from oasisprotocol/kostko/fix/compute-p2p-di…
…spatch go/worker: Defer various processing
- Loading branch information
Showing
7 changed files
with
145 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
go/worker/compute/executor: Defer fetching the batch from storage | ||
|
||
There is no need to attempt to fetch the batch immediately, we can defer it to | ||
when we actually need to start processing the batch. This makes fetching not | ||
block P2P dispatch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
go/worker/compute/merge: Defer finalization attempt | ||
|
||
There is no need for the finalization attempt to block handling of an incoming | ||
commitment as any errors from that are not propagated. This avoids blocking | ||
P2P relaying as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package committee | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/opentracing/opentracing-go" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature" | ||
"github.com/oasisprotocol/oasis-core/go/runtime/transaction" | ||
storage "github.com/oasisprotocol/oasis-core/go/storage/api" | ||
) | ||
|
||
// unresolvedBatch is a batch that may still need to be resolved (fetched from storage). | ||
type unresolvedBatch struct { | ||
// ioRoot is the I/O root from the transaction scheduler containing the inputs. | ||
ioRoot storage.Root | ||
// txnSchedSignatures is the transaction scheduler signature of the dispatched batch. | ||
txnSchedSignature signature.Signature | ||
// storageSignatures are the storage node signatures of storage receipts for the I/O root. | ||
storageSignatures []signature.Signature | ||
|
||
batch transaction.RawBatch | ||
spanCtx opentracing.SpanContext | ||
} | ||
|
||
func (ub *unresolvedBatch) String() string { | ||
return fmt.Sprintf("UnresolvedBatch{ioRoot: %s}", ub.ioRoot) | ||
} | ||
|
||
func (ub *unresolvedBatch) resolve(ctx context.Context, storage storage.Backend) (transaction.RawBatch, error) { | ||
if ub.batch != nil { | ||
// In case we already have a resolved batch, just return it. | ||
return ub.batch, nil | ||
} | ||
|
||
txs := transaction.NewTree(storage, ub.ioRoot) | ||
defer txs.Close() | ||
|
||
batch, err := txs.GetInputBatch(ctx) | ||
if err != nil || len(batch) == 0 { | ||
return nil, fmt.Errorf("failed to fetch inputs from storage: %w", err) | ||
} | ||
if len(batch) == 0 { | ||
return nil, fmt.Errorf("failed to fetch inputs from storage: batch is empty") | ||
} | ||
return batch, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.