Skip to content

Commit

Permalink
Merge v0.5.13 into v0.6.0 (#3350)
Browse files Browse the repository at this point in the history
  • Loading branch information
tclemos authored Feb 22, 2024
1 parent a039a0a commit d218fe2
Show file tree
Hide file tree
Showing 23 changed files with 950 additions and 107 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN cd /src/db && packr2
RUN cd /src && make build

# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18.4
FROM alpine:3.18
COPY --from=build /src/dist/zkevm-node /app/zkevm-node
COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
RUN apk update && apk add postgresql15-client
Expand Down
10 changes: 10 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ func runJSONRPCServer(c config.Config, etherman *etherman.Client, chainID uint64
storage := jsonrpc.NewStorage()
c.RPC.MaxCumulativeGasUsed = c.State.Batch.Constraints.MaxCumulativeGasUsed
c.RPC.L2Coinbase = c.SequenceSender.L2Coinbase
c.RPC.ZKCountersLimits = jsonrpc.ZKCountersLimits{
MaxKeccakHashes: c.State.Batch.Constraints.MaxKeccakHashes,
MaxPoseidonHashes: c.State.Batch.Constraints.MaxPoseidonHashes,
MaxPoseidonPaddings: c.State.Batch.Constraints.MaxPoseidonPaddings,
MaxMemAligns: c.State.Batch.Constraints.MaxMemAligns,
MaxArithmetics: c.State.Batch.Constraints.MaxArithmetics,
MaxBinaries: c.State.Batch.Constraints.MaxBinaries,
MaxSteps: c.State.Batch.Constraints.MaxSteps,
MaxSHA256Hashes: c.State.Batch.Constraints.MaxSHA256Hashes,
}
if !c.IsTrustedSequencer {
if c.RPC.SequencerNodeURI == "" {
log.Debug("getting trusted sequencer URL from smc")
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ ForkID=0
| - [MaxLogsBlockRange](#RPC_MaxLogsBlockRange ) | No | integer | No | - | MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs<br />logs in a single call to the state, if zero it means no limit |
| - [MaxNativeBlockHashBlockRange](#RPC_MaxNativeBlockHashBlockRange ) | No | integer | No | - | MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying<br />native block hashes in a single call to the state, if zero it means no limit |
| - [EnableHttpLog](#RPC_EnableHttpLog ) | No | boolean | No | - | EnableHttpLog allows the user to enable or disable the logs related to the HTTP<br />requests to be captured by the server. |
| - [ZKCountersLimits](#RPC_ZKCountersLimits ) | No | object | No | - | ZKCountersLimits defines the ZK Counter limits |

### <a name="RPC_Host"></a>8.1. `RPC.Host`

Expand Down Expand Up @@ -1215,6 +1216,118 @@ requests to be captured by the server.
EnableHttpLog=true
```

### <a name="RPC_ZKCountersLimits"></a>8.17. `[RPC.ZKCountersLimits]`

**Type:** : `object`
**Description:** ZKCountersLimits defines the ZK Counter limits

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- |
| - [MaxKeccakHashes](#RPC_ZKCountersLimits_MaxKeccakHashes ) | No | integer | No | - | - |
| - [MaxPoseidonHashes](#RPC_ZKCountersLimits_MaxPoseidonHashes ) | No | integer | No | - | - |
| - [MaxPoseidonPaddings](#RPC_ZKCountersLimits_MaxPoseidonPaddings ) | No | integer | No | - | - |
| - [MaxMemAligns](#RPC_ZKCountersLimits_MaxMemAligns ) | No | integer | No | - | - |
| - [MaxArithmetics](#RPC_ZKCountersLimits_MaxArithmetics ) | No | integer | No | - | - |
| - [MaxBinaries](#RPC_ZKCountersLimits_MaxBinaries ) | No | integer | No | - | - |
| - [MaxSteps](#RPC_ZKCountersLimits_MaxSteps ) | No | integer | No | - | - |
| - [MaxSHA256Hashes](#RPC_ZKCountersLimits_MaxSHA256Hashes ) | No | integer | No | - | - |

#### <a name="RPC_ZKCountersLimits_MaxKeccakHashes"></a>8.17.1. `RPC.ZKCountersLimits.MaxKeccakHashes`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxKeccakHashes=0
```

#### <a name="RPC_ZKCountersLimits_MaxPoseidonHashes"></a>8.17.2. `RPC.ZKCountersLimits.MaxPoseidonHashes`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxPoseidonHashes=0
```

#### <a name="RPC_ZKCountersLimits_MaxPoseidonPaddings"></a>8.17.3. `RPC.ZKCountersLimits.MaxPoseidonPaddings`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxPoseidonPaddings=0
```

#### <a name="RPC_ZKCountersLimits_MaxMemAligns"></a>8.17.4. `RPC.ZKCountersLimits.MaxMemAligns`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxMemAligns=0
```

#### <a name="RPC_ZKCountersLimits_MaxArithmetics"></a>8.17.5. `RPC.ZKCountersLimits.MaxArithmetics`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxArithmetics=0
```

#### <a name="RPC_ZKCountersLimits_MaxBinaries"></a>8.17.6. `RPC.ZKCountersLimits.MaxBinaries`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxBinaries=0
```

#### <a name="RPC_ZKCountersLimits_MaxSteps"></a>8.17.7. `RPC.ZKCountersLimits.MaxSteps`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxSteps=0
```

#### <a name="RPC_ZKCountersLimits_MaxSHA256Hashes"></a>8.17.8. `RPC.ZKCountersLimits.MaxSHA256Hashes`

**Type:** : `integer`

**Default:** `0`

**Example setting the default value** (0):
```
[RPC.ZKCountersLimits]
MaxSHA256Hashes=0
```

## <a name="Synchronizer"></a>9. `[Synchronizer]`

**Type:** : `object`
Expand Down
39 changes: 39 additions & 0 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,45 @@
"type": "boolean",
"description": "EnableHttpLog allows the user to enable or disable the logs related to the HTTP\nrequests to be captured by the server.",
"default": true
},
"ZKCountersLimits": {
"properties": {
"MaxKeccakHashes": {
"type": "integer",
"default": 0
},
"MaxPoseidonHashes": {
"type": "integer",
"default": 0
},
"MaxPoseidonPaddings": {
"type": "integer",
"default": 0
},
"MaxMemAligns": {
"type": "integer",
"default": 0
},
"MaxArithmetics": {
"type": "integer",
"default": 0
},
"MaxBinaries": {
"type": "integer",
"default": 0
},
"MaxSteps": {
"type": "integer",
"default": 0
},
"MaxSHA256Hashes": {
"type": "integer",
"default": 0
}
},
"additionalProperties": false,
"type": "object",
"description": "ZKCountersLimits defines the ZK Counter limits"
}
},
"additionalProperties": false,
Expand Down
10 changes: 7 additions & 3 deletions docs/json-rpc-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ If the endpoint is not in the list below, it means this specific endpoint is not
- `zkevm_batchNumber`
- `zkevm_batchNumberByBlockNumber`
- `zkevm_consolidatedBlockNumber`
- `zkevm_estimateFee`
- `zkevm_estimateGasPrice`
- `zkevm_estimateCounters`
- `zkevm_getBatchByNumber`
- `zkevm_getExitRootsByGER`
- `zkevm_getFullBlockByHash`
- `zkevm_getFullBlockByNumber`
- `zkevm_getLatestGlobalExitRoot`
- `zkevm_getNativeBlockHashesInRange`
- `zkevm_getTransactionByL2Hash`
- `zkevm_getTransactionReceiptByL2Hash`
- `zkevm_isBlockConsolidated`
- `zkevm_isBlockVirtualized`
- `zkevm_verifiedBatchNumber`
- `zkevm_virtualBatchNumber`
- `zkevm_getTransactionByL2Hash`
- `zkevm_getTransactionReceiptByL2Hash`
- `zkevm_getExitRootsByGER`
15 changes: 15 additions & 0 deletions jsonrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ type Config struct {
// EnableHttpLog allows the user to enable or disable the logs related to the HTTP
// requests to be captured by the server.
EnableHttpLog bool `mapstructure:"EnableHttpLog"`

// ZKCountersLimits defines the ZK Counter limits
ZKCountersLimits ZKCountersLimits
}

// ZKCountersLimits defines the ZK Counter limits
type ZKCountersLimits struct {
MaxKeccakHashes uint32
MaxPoseidonHashes uint32
MaxPoseidonPaddings uint32
MaxMemAligns uint32
MaxArithmetics uint32
MaxBinaries uint32
MaxSteps uint32
MaxSHA256Hashes uint32
}

// WebSocketsConfig has parameters to config the rpc websocket support
Expand Down
6 changes: 6 additions & 0 deletions jsonrpc/endpoints_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ func (e *EthEndpoints) GetBlockByNumber(number types.BlockNumber, fullTx bool, i
return RPCErrorResponse(types.DefaultErrorCode, "couldn't build the pending block response", err, true)
}

// clean fields that are not available for pending block
rpcBlock.Hash = nil
rpcBlock.Miner = nil
rpcBlock.Nonce = nil
rpcBlock.TotalDifficulty = nil

return rpcBlock, nil
}
var err error
Expand Down
37 changes: 24 additions & 13 deletions jsonrpc/endpoints_eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ func TestGetL2BlockByNumber(t *testing.T) {
}

n := big.NewInt(0).SetUint64(l2Block.Nonce())
rpcBlockNonce := common.LeftPadBytes(n.Bytes(), 8) //nolint:gomnd
rpcBlockNonce := types.ArgBytes(common.LeftPadBytes(n.Bytes(), 8)) //nolint:gomnd

difficulty := types.ArgUint64(0)
var totalDifficulty *types.ArgUint64
Expand All @@ -1249,7 +1249,7 @@ func TestGetL2BlockByNumber(t *testing.T) {
Timestamp: types.ArgUint64(l2Block.Time()),
ExtraData: l2Block.Extra(),
MixHash: l2Block.MixDigest(),
Nonce: rpcBlockNonce,
Nonce: &rpcBlockNonce,
Hash: state.Ptr(l2Block.Hash()),
GlobalExitRoot: state.Ptr(l2Block.GlobalExitRoot()),
BlockInfoRoot: state.Ptr(l2Block.BlockInfoRoot()),
Expand Down Expand Up @@ -1422,8 +1422,10 @@ func TestGetL2BlockByNumber(t *testing.T) {
tc.ExpectedResult.ExtraData = []byte{}
tc.ExpectedResult.GlobalExitRoot = state.Ptr(common.Hash{})
tc.ExpectedResult.BlockInfoRoot = state.Ptr(common.Hash{})
rpcBlockNonce := common.LeftPadBytes(big.NewInt(0).Bytes(), 8) //nolint:gomnd
tc.ExpectedResult.Nonce = rpcBlockNonce
tc.ExpectedResult.Hash = nil
tc.ExpectedResult.Miner = nil
tc.ExpectedResult.Nonce = nil
tc.ExpectedResult.TotalDifficulty = nil

m.DbTx.
On("Commit", context.Background()).
Expand Down Expand Up @@ -1480,32 +1482,41 @@ func TestGetL2BlockByNumber(t *testing.T) {
if result != nil || tc.ExpectedResult != nil {
assert.Equal(t, tc.ExpectedResult.ParentHash.String(), result.ParentHash.String())
assert.Equal(t, tc.ExpectedResult.Sha3Uncles.String(), result.Sha3Uncles.String())
if tc.ExpectedResult.Miner != nil {
assert.Equal(t, tc.ExpectedResult.Miner.String(), result.Miner.String())
} else {
assert.Nil(t, result.Miner)
}
assert.Equal(t, tc.ExpectedResult.StateRoot.String(), result.StateRoot.String())
assert.Equal(t, tc.ExpectedResult.TxRoot.String(), result.TxRoot.String())
assert.Equal(t, tc.ExpectedResult.ReceiptsRoot.String(), result.ReceiptsRoot.String())
assert.Equal(t, tc.ExpectedResult.LogsBloom, result.LogsBloom)
assert.Equal(t, tc.ExpectedResult.Difficulty, result.Difficulty)
assert.Equal(t, tc.ExpectedResult.TotalDifficulty, result.TotalDifficulty)
assert.Equal(t, tc.ExpectedResult.Size, result.Size)
assert.Equal(t, tc.ExpectedResult.Number, result.Number)
assert.Equal(t, tc.ExpectedResult.GasLimit, result.GasLimit)
assert.Equal(t, tc.ExpectedResult.GasUsed, result.GasUsed)
assert.Equal(t, tc.ExpectedResult.Timestamp, result.Timestamp)
assert.Equal(t, tc.ExpectedResult.ExtraData, result.ExtraData)
assert.Equal(t, tc.ExpectedResult.MixHash, result.MixHash)
assert.Equal(t, tc.ExpectedResult.Nonce, result.Nonce)
assert.Equal(t, tc.ExpectedResult.GlobalExitRoot, result.GlobalExitRoot)
assert.Equal(t, tc.ExpectedResult.BlockInfoRoot, result.BlockInfoRoot)

if tc.ExpectedResult.Hash != nil {
assert.Equal(t, tc.ExpectedResult.Hash.String(), result.Hash.String())
} else {
assert.Nil(t, result.Hash)
}
assert.Equal(t, tc.ExpectedResult.GlobalExitRoot, result.GlobalExitRoot)
assert.Equal(t, tc.ExpectedResult.BlockInfoRoot, result.BlockInfoRoot)
if tc.ExpectedResult.Miner != nil {
assert.Equal(t, tc.ExpectedResult.Miner.String(), result.Miner.String())
} else {
assert.Nil(t, result.Miner)
}
if tc.ExpectedResult.Nonce != nil {
assert.Equal(t, tc.ExpectedResult.Nonce, result.Nonce)
} else {
assert.Nil(t, result.Nonce)
}
if tc.ExpectedResult.TotalDifficulty != nil {
assert.Equal(t, tc.ExpectedResult.TotalDifficulty, result.TotalDifficulty)
} else {
assert.Nil(t, result.TotalDifficulty)
}

assert.Equal(t, len(tc.ExpectedResult.Transactions), len(result.Transactions))
assert.Equal(t, len(tc.ExpectedResult.Uncles), len(result.Uncles))
Expand Down
Loading

0 comments on commit d218fe2

Please sign in to comment.