Skip to content

Commit

Permalink
add random ContextId when calling executor.ProcessBatch (#2575)
Browse files Browse the repository at this point in the history
  • Loading branch information
tclemos authored Oct 5, 2023
1 parent bf82f69 commit 2b96683
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 561 deletions.
1 change: 1 addition & 0 deletions proto/src/proto/executor/v1/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ message ProcessBatchRequest {
map<string, string> db = 13;
map<string, string> contracts_bytecode = 14; // For debug/testing purpposes only. Don't fill this on production
TraceConfig trace_config = 15;
string context_id = 16;
}

message ProcessBatchResponse {
Expand Down
6 changes: 6 additions & 0 deletions state/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/google/uuid"
"github.com/jackc/pgx/v4"
)

Expand Down Expand Up @@ -182,6 +183,7 @@ func (s *State) ProcessBatch(ctx context.Context, request ProcessRequest, update
UpdateMerkleTree: updateMT,
ChainId: s.cfg.ChainID,
ForkId: forkID,
ContextId: uuid.NewString(),
}
res, err := s.sendBatchRequestToExecutor(ctx, processBatchRequest, request.Caller)
if err != nil {
Expand Down Expand Up @@ -233,6 +235,7 @@ func (s *State) ExecuteBatch(ctx context.Context, batch Batch, updateMerkleTree
UpdateMerkleTree: updateMT,
ChainId: s.cfg.ChainID,
ForkId: forkId,
ContextId: uuid.NewString(),
}

// Send Batch to the Executor
Expand All @@ -247,6 +250,7 @@ func (s *State) ExecuteBatch(ctx context.Context, batch Batch, updateMerkleTree
log.Debugf("ExecuteBatch[processBatchRequest.UpdateMerkleTree]: %v", processBatchRequest.UpdateMerkleTree)
log.Debugf("ExecuteBatch[processBatchRequest.ChainId]: %v", processBatchRequest.ChainId)
log.Debugf("ExecuteBatch[processBatchRequest.ForkId]: %v", processBatchRequest.ForkId)
log.Debugf("ExecuteBatch[processBatchRequest.ContextId]: %v", processBatchRequest.ContextId)

processBatchResponse, err := s.executorClient.ProcessBatch(ctx, processBatchRequest)
if err != nil {
Expand Down Expand Up @@ -314,6 +318,7 @@ func (s *State) processBatch(ctx context.Context, batchNumber uint64, batchL2Dat
UpdateMerkleTree: cTrue,
ChainId: s.cfg.ChainID,
ForkId: forkID,
ContextId: uuid.NewString(),
}

return s.sendBatchRequestToExecutor(ctx, processBatchRequest, caller)
Expand All @@ -336,6 +341,7 @@ func (s *State) sendBatchRequestToExecutor(ctx context.Context, processBatchRequ
log.Debugf("processBatch[processBatchRequest.UpdateMerkleTree]: %v", processBatchRequest.UpdateMerkleTree)
log.Debugf("processBatch[processBatchRequest.ChainId]: %v", processBatchRequest.ChainId)
log.Debugf("processBatch[processBatchRequest.ForkId]: %v", processBatchRequest.ForkId)
log.Debugf("processBatch[processBatchRequest.ContextId]: %v", processBatchRequest.ContextId)
}
now := time.Now()
res, err := s.executorClient.ProcessBatch(ctx, processBatchRequest)
Expand Down
Loading

0 comments on commit 2b96683

Please sign in to comment.