Skip to content
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

Include operations from related transactions to match intent #283

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/processor/broadcast_storage_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var _ modules.BroadcastStorageHandler = (*BroadcastStorageHandler)(nil)
// can be sent to other functions (ex: reconciler).
type BroadcastStorageHandler struct {
config *configuration.Configuration
blockStorage *modules.BlockStorage
counterStorage *modules.CounterStorage
coordinator *coordinator.Coordinator
parser *parser.Parser
Expand All @@ -43,12 +44,14 @@ type BroadcastStorageHandler struct {
// NewBroadcastStorageHandler returns a new *BroadcastStorageHandler.
func NewBroadcastStorageHandler(
config *configuration.Configuration,
blockStorage *modules.BlockStorage,
counterStorage *modules.CounterStorage,
coordinator *coordinator.Coordinator,
parser *parser.Parser,
) *BroadcastStorageHandler {
return &BroadcastStorageHandler{
config: config,
blockStorage: blockStorage,
counterStorage: counterStorage,
coordinator: coordinator,
parser: parser,
Expand All @@ -65,7 +68,17 @@ func (h *BroadcastStorageHandler) TransactionConfirmed(
transaction *types.Transaction,
intent []*types.Operation,
) error {
if err := h.parser.ExpectedOperations(intent, transaction.Operations, false, true); err != nil {
_, _, relatedTransactions, err := h.blockStorage.FindRelatedTransactions(ctx, transaction.TransactionIdentifier, dbTx)
if err != nil {
return fmt.Errorf("%w: could not find related transactions", err)
}

observed := transaction.Operations
for _, relatedTransaction := range relatedTransactions {
observed = append(observed, relatedTransaction.Operations...)
}

if err := h.parser.ExpectedOperations(intent, observed, false, true); err != nil {
return fmt.Errorf("%w: confirmed transaction did not match intent", err)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/tester/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func InitializeConstruction(

broadcastHandler := processor.NewBroadcastStorageHandler(
config,
blockStorage,
counterStorage,
coordinator,
parser,
Expand Down