Skip to content

Commit

Permalink
execution mode (#3285)
Browse files Browse the repository at this point in the history
* execution mode

* execution mode

* execution mode
  • Loading branch information
ToniRamirezM authored Feb 16, 2024
1 parent f968d8b commit ca5a2c2
Show file tree
Hide file tree
Showing 15 changed files with 806 additions and 763 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 @@ -292,6 +292,7 @@ message ProcessBatchRequestV2 {
// prior to executing the call.
map<string, OverrideAccountV2> state_override = 23;
DebugV2 debug = 24;
uint64 execution_mode = 25;
}

message L1DataV2 {
Expand Down
2 changes: 2 additions & 0 deletions sequencer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/state"
stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics"
"github.com/0xPolygonHermez/zkevm-node/state/runtime"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/ethereum/go-ethereum/common"
)

Expand Down Expand Up @@ -386,6 +387,7 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi
ForkID: f.stateIntf.GetForkIDByBatchNumber(batch.BatchNumber),
SkipVerifyL1InfoRoot_V2: true,
Caller: caller,
ExecutionMode: executor.ExecutionMode0,
}
batchRequest.L1InfoTreeData_V2, _, _, err = f.stateIntf.GetL1InfoTreeDataFromBatchL2Data(ctx, batch.BatchL2Data, nil)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func (f *finalizer) processTransaction(ctx context.Context, tx *TxTracker, first
SkipWriteBlockInfoRoot_V2: true,
SkipVerifyL1InfoRoot_V2: true,
L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
ExecutionMode: executor.ExecutionMode0,
}

txGasPrice := tx.GasPrice
Expand Down
2 changes: 2 additions & 0 deletions sequencer/forcedbatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state"
stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/ethereum/go-ethereum/common"
"github.com/jackc/pgx/v4"
)
Expand Down Expand Up @@ -105,6 +106,7 @@ func (f *finalizer) processForcedBatch(ctx context.Context, forcedBatch state.Fo
ForkID: f.stateIntf.GetForkIDByBatchNumber(lastBatchNumber),
SkipVerifyL1InfoRoot_V2: true,
Caller: stateMetrics.SequencerCallerLabel,
ExecutionMode: executor.ExecutionMode0,
}

batchResponse, err := f.stateIntf.ProcessBatchV2(ctx, batchRequest, true)
Expand Down
3 changes: 3 additions & 0 deletions sequencer/l2block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/state"
stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics"
"github.com/0xPolygonHermez/zkevm-node/state/runtime"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/ethereum/go-ethereum/common"
)

Expand Down Expand Up @@ -262,6 +263,7 @@ func (f *finalizer) executeL2Block(ctx context.Context, initialStateRoot common.
ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
SkipVerifyL1InfoRoot_V2: true,
L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
ExecutionMode: executor.ExecutionMode0,
}
batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
Expand Down Expand Up @@ -545,6 +547,7 @@ func (f *finalizer) executeNewWIPL2Block(ctx context.Context) (*state.ProcessBat
SkipFirstChangeL2Block_V2: false,
Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
ExecutionMode: executor.ExecutionMode0,
}

batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
Expand Down
4 changes: 4 additions & 0 deletions state/batchV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ProcessingContextV2 struct {
ForcedBlockHashL1 *common.Hash
SkipVerifyL1InfoRoot uint32
GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB)
ExecutionMode uint64
}

// ProcessBatchV2 processes a batch for forkID >= ETROG
Expand Down Expand Up @@ -67,6 +68,7 @@ func (s *State) ProcessBatchV2(ctx context.Context, request ProcessRequest, upda
ChainId: s.cfg.ChainID,
ForkId: request.ForkID,
ContextId: uuid.NewString(),
ExecutionMode: request.ExecutionMode,
}

if request.SkipFirstChangeL2Block_V2 {
Expand Down Expand Up @@ -129,6 +131,7 @@ func (s *State) ExecuteBatchV2(ctx context.Context, batch Batch, L1InfoTreeRoot
ForkId: forkId,
ContextId: uuid.NewString(),
SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
ExecutionMode: executor.ExecutionMode1,
}

if forcedBlockHashL1 != nil {
Expand Down Expand Up @@ -229,6 +232,7 @@ func (s *State) processBatchV2(ctx context.Context, processingCtx *ProcessingCon
ContextId: uuid.NewString(),
SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
ExecutionMode: processingCtx.ExecutionMode,
}

if processingCtx.ForcedBlockHashL1 != nil {
Expand Down
7 changes: 7 additions & 0 deletions state/runtime/executor/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

const (
// ExecutionMode0 is the execution mode for the sequencer and RPC, default one
ExecutionMode0 = uint64(0)
// ExecutionMode1 is the execution mode for the synchronizer
ExecutionMode1 = uint64(1)
)

// NewExecutorClient is the executor client constructor.
func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
opts := []grpc.DialOption{
Expand Down
Loading

0 comments on commit ca5a2c2

Please sign in to comment.