Skip to content

Commit

Permalink
Merge branch 'zkevm' into fix-stage-batches-resequence
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Staykov authored Oct 31, 2024
2 parents d90a0fd + 5187e6f commit cfd68a3
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ For a full explanation of the config options, see below:
Sequencer specific config:
- `zkevm.executor-urls`: A csv list of the executor URLs. These will be used in a round robbin fashion by the sequencer
- `zkevm.executor-strict`: Defaulted to true, but can be set to false when running the sequencer without verifications (use with extreme caution)
- `zkevm.witness-full`: Defaulted to true. Controls whether the full or partial witness is used with the executor.
- `zkevm.witness-full`: Defaulted to false. Controls whether the full or partial witness is used with the executor.
- `zkevm.reject-smart-contract-deployments`: Defaulted to false. Controls whether smart contract deployments are rejected by the TxPool.

Resource Utilisation config:
Expand Down
10 changes: 5 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ var (
WitnessFullFlag = cli.BoolFlag{
Name: "zkevm.witness-full",
Usage: "Enable/Diable witness full",
Value: true,
Value: false,
}
SyncLimit = cli.UintFlag{
Name: "zkevm.sync-limit",
Expand Down Expand Up @@ -1433,6 +1433,7 @@ func setNodeUserIdent(ctx *cli.Context, cfg *nodecfg.Config) {
cfg.UserIdent = identity
}
}

func setNodeUserIdentCobra(f *pflag.FlagSet, cfg *nodecfg.Config) {
if identity := f.String(IdentityFlag.Name, IdentityFlag.Value, IdentityFlag.Usage); identity != nil && len(*identity) > 0 {
cfg.UserIdent = *identity
Expand Down Expand Up @@ -1741,7 +1742,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config, nodeName, datadir string, l

if ctx.String(ChainFlag.Name) == networkname.DevChainName {
// --dev mode can't use p2p networking.
//cfg.MaxPeers = 0 // It can have peers otherwise local sync is not possible
// cfg.MaxPeers = 0 // It can have peers otherwise local sync is not possible
if !ctx.IsSet(ListenPortFlag.Name) {
cfg.ListenAddr = ":0"
}
Expand All @@ -1762,7 +1763,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *nodecfg.Config, logger log.Logger) {

func SetNodeConfigCobra(cmd *cobra.Command, cfg *nodecfg.Config) {
flags := cmd.Flags()
//SetP2PConfig(ctx, &cfg.P2P)
// SetP2PConfig(ctx, &cfg.P2P)
setNodeUserIdentCobra(flags, cfg)
setDataDirCobra(flags, cfg)
}
Expand Down Expand Up @@ -2138,7 +2139,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
}

cfg.Sync.UseSnapshots = ethconfig.UseSnapshotsByChainName(chain)
if ctx.IsSet(SnapshotFlag.Name) { //force override default by cli
if ctx.IsSet(SnapshotFlag.Name) { // force override default by cli
cfg.Sync.UseSnapshots = ctx.Bool(SnapshotFlag.Name)
}

Expand Down Expand Up @@ -2169,7 +2170,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
webseedsList = append(webseedsList, known...)
}
cfg.Downloader, err = downloadercfg2.New(cfg.Dirs, version, lvl, downloadRate, uploadRate, ctx.Int(TorrentPortFlag.Name), ctx.Int(TorrentConnsPerFileFlag.Name), ctx.Int(TorrentDownloadSlotsFlag.Name), libcommon.CliString2Array(ctx.String(TorrentStaticPeersFlag.Name)), webseedsList, chain, true)

if err != nil {
panic(err)
}
Expand Down
33 changes: 17 additions & 16 deletions turbo/jsonrpc/zkevm_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,11 @@ func (api *ZkEvmAPIImpl) GetBatchDataByNumbers(ctx context.Context, batchNumbers
bds := make([]*types.BatchDataSlim, 0, len(batchNumbers.Numbers))

for _, batchRpcNumber := range batchNumbers.Numbers {
// looks weird but we're using the rpc.BlockNumber type to represent the batch number, LatestBlockNumber represents latest batch
if batchRpcNumber == rpc.LatestBlockNumber {
batchRpcNumber = rpc.BlockNumber(highestBatchNo)
batchNo, _, err := rpchelper.GetBatchNumber(batchRpcNumber, tx, nil)
if err != nil {
return nil, err
}

batchNo := batchRpcNumber.Uint64()

bd := &types.BatchDataSlim{
Number: types.ArgUint64(batchNo),
Empty: false,
Expand Down Expand Up @@ -419,7 +417,7 @@ func (api *ZkEvmAPIImpl) getBatchBlocksWithSenders(ctx context.Context, tx kv.Tx

// GetBatchByNumber returns a batch from the current canonical chain. If number is nil, the
// latest known batch is returned.
func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.BlockNumber, fullTx *bool) (json.RawMessage, error) {
func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, rpcBatchNumber rpc.BlockNumber, fullTx *bool) (json.RawMessage, error) {
tx, err := api.db.BeginRo(ctx)
if err != nil {
return nil, err
Expand All @@ -435,6 +433,11 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
return nil, err
}

batchNo, _, err := rpchelper.GetBatchNumber(rpcBatchNumber, tx, nil)
if err != nil {
return nil, err
}

// check sync status of node
syncStatus, err := api.ethApi.Syncing(ctx)
if err != nil {
Expand All @@ -447,17 +450,10 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
}

}
if batchNumber.Uint64() > highestBatchNo {
if batchNo > highestBatchNo {
return nil, nil
}

// looks weird but we're using the rpc.BlockNumber type to represent the batch number, LatestBlockNumber represents latest batch
if batchNumber == rpc.LatestBlockNumber {
batchNumber = rpc.BlockNumber(highestBatchNo)
}

batchNo := batchNumber.Uint64()

batch := &types.Batch{
Number: types.ArgUint64(batchNo),
}
Expand Down Expand Up @@ -1797,14 +1793,19 @@ func (api *ZkEvmAPIImpl) GetForkById(ctx context.Context, forkId hexutil.Uint64)
}

// GetForkIdByBatchNumber returns the fork ID given the provided batch number
func (api *ZkEvmAPIImpl) GetForkIdByBatchNumber(ctx context.Context, batchNumber rpc.BlockNumber) (hexutil.Uint64, error) {
func (api *ZkEvmAPIImpl) GetForkIdByBatchNumber(ctx context.Context, rpcBatchNumber rpc.BlockNumber) (hexutil.Uint64, error) {
tx, err := api.db.BeginRo(ctx)
if err != nil {
return hexutil.Uint64(0), err
}
defer tx.Rollback()

currentForkId, err := getForkIdByBatchNo(tx, uint64(batchNumber))
batchNumber, _, err := rpchelper.GetBatchNumber(rpcBatchNumber, tx, nil)
if err != nil {
return 0, err
}

currentForkId, err := getForkIdByBatchNo(tx, batchNumber)
if err != nil {
return 0, err
}
Expand Down
1 change: 0 additions & 1 deletion zk/tests/nightly-l1-recovery/network5-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ zkevm.datastream-version: 2
zkevm.data-stream-host: "127.0.0.1"
zkevm.executor-strict: false
# zkevm.executor-urls: "zkevm2-stateless-executor:50071"
zkevm.witness-full: false
zkevm.sequencer-block-seal-time: "5s"
zkevm.sequencer-batch-seal-time: "15m"
zkevm.allow-pre-eip155-transactions: true
Expand Down
1 change: 0 additions & 1 deletion zk/tests/nightly-l1-recovery/network5-sync-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ zkevm.l1-query-delay: 6000
zkevm.l1-first-block: 6032365
zkevm.executor-strict: false
# zkevm.executor-urls: "zkevm2-stateless-executor:50071"
zkevm.witness-full: false
zkevm.sequencer-block-seal-time: "5s"
zkevm.sequencer-batch-seal-time: "15m"
zkevm.allow-pre-eip155-transactions: true
Expand Down
1 change: 0 additions & 1 deletion zk/tests/nightly-l1-recovery/network8-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ zkevm.datastream-version: 2
zkevm.data-stream-host: "127.0.0.1"
# zkevm.sequencer-initial-fork-id: 9
zkevm.executor-strict: false
zkevm.witness-full: false
zkevm.sequencer-block-seal-time: "5s"
zkevm.sequencer-batch-seal-time: "15m"
zkevm.allow-pre-eip155-transactions: true
Expand Down
1 change: 0 additions & 1 deletion zk/tests/nightly-l1-recovery/network8-sync-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ zkevm.datastream-version: 2
#zkevm.data-stream-host: "127.0.0.1"
# zkevm.sequencer-initial-fork-id: 9
zkevm.executor-strict: false
zkevm.witness-full: false
zkevm.sequencer-block-seal-time: "5s"
zkevm.sequencer-batch-seal-time: "15m"
zkevm.allow-pre-eip155-transactions: true
Expand Down
1 change: 0 additions & 1 deletion zk/tests/unwinds/config/dynamic-integration8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ zkevm.l1-first-block: 6411787
zkevm.datastream-version: 2
# zkevm.data-stream-host: "127.0.0.1"
zkevm.executor-strict: false
zkevm.witness-full: false
zkevm.sequencer-block-seal-time: "5s"
zkevm.sequencer-batch-seal-time: "15m"
zkevm.allow-pre-eip155-transactions: true
Expand Down

0 comments on commit cfd68a3

Please sign in to comment.