Skip to content

Commit

Permalink
improve: adding config params and check for batch requests for enabli…
Browse files Browse the repository at this point in the history
…ng/disabling (disabled by default) and max requests count limit.

Signed-off-by: Nikolay Nedkov <[email protected]>
  • Loading branch information
Psykepro committed Aug 21, 2023
1 parent 3086056 commit 14733fb
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,14 @@ func Test_Defaults(t *testing.T) {
path: "RPC.EnableL2SuggestedGasPricePolling",
expectedValue: true,
},
{
path: "RPC.BatchRequestsEnabled",
expectedValue: false,
},
{
path: "RPC.BatchRequestsLimit",
expectedValue: uint(20),
},
{
path: "RPC.WebSockets.Enabled",
expectedValue: true,
Expand Down
2 changes: 2 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ MaxRequestsPerIPAndSecond = 500
SequencerNodeURI = ""
EnableL2SuggestedGasPricePolling = true
TraceBatchUseHTTPS = true
BatchRequestsEnabled = false
BatchRequestsLimit = 20
[RPC.WebSockets]
Enabled = true
Host = "0.0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</pre></div> </div><div id=RPC_ReadTimeout_ex2 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;300ms&quot;</span>
</pre></div> </div> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.WriteTimeout onclick="anchorLink('RPC.WriteTimeout')">RPC.WriteTimeout=</a> </div> <span class="badge badge-success default-value">Default: "1m0s"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>WriteTimeout is the HTTP server write timeout<br> check net/http.server.WriteTimeout</p> </span> <br> <div class="badge badge-secondary">Examples:</div> <br><div id=RPC_WriteTimeout_ex1 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;1m&quot;</span>
</pre></div> </div><div id=RPC_WriteTimeout_ex2 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;300ms&quot;</span>
</pre></div> </div> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.MaxRequestsPerIPAndSecond onclick="anchorLink('RPC.MaxRequestsPerIPAndSecond')">RPC.MaxRequestsPerIPAndSecond=</a> </div> <span class="badge badge-success default-value">Default: 500</span><span class="badge badge-dark value-type">Type: number</span><br> <span class=description><p>MaxRequestsPerIPAndSecond defines how much requests a single IP can<br> send within a single second</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.SequencerNodeURI onclick="anchorLink('RPC.SequencerNodeURI')">RPC.SequencerNodeURI=</a> </div> <span class="badge badge-success default-value">Default: ""</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>SequencerNodeURI is used allow Non-Sequencer nodes<br> to relay transactions to the Sequencer node</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.MaxCumulativeGasUsed onclick="anchorLink('RPC.MaxCumulativeGasUsed')">RPC.MaxCumulativeGasUsed=</a> </div> <span class="badge badge-success default-value">Default: 0</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>MaxCumulativeGasUsed is the max gas allowed per batch</p> </span> <hr> <div class=accordion id=accordionRPC_WebSockets> <div class=card> <div class=card-header id=headingRPC_WebSockets> <h2 class=mb-0> <button class="btn btn-link property-name-button" type=button data-toggle=collapse data-target=#RPC_WebSockets aria-expanded aria-controls=RPC_WebSockets onclick="setAnchor('#RPC_WebSockets')"><span class=property-name> <div class=breadcrumbs>[<a href=#RPC onclick="anchorLink('RPC')">RPC</a> . <a href=#RPC_WebSockets onclick="anchorLink('RPC_WebSockets')">WebSockets</a>] </div></span></button> </h2> WebSockets configuration </div> <div id=RPC_WebSockets class="collapse property-definition-div" aria-labelledby=headingRPC_WebSockets data-parent=#accordionRPC_WebSockets> <div class="card-body pl-5"> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Enabled onclick="anchorLink('RPC.WebSockets.Enabled')">RPC.WebSockets.Enabled=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>Enabled defines if the WebSocket requests are enabled or disabled</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Host onclick="anchorLink('RPC.WebSockets.Host')">RPC.WebSockets.Host=</a> </div> <span class="badge badge-success default-value">Default: "0.0.0.0"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>Host defines the network adapter that will be used to serve the WS requests</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Port onclick="anchorLink('RPC.WebSockets.Port')">RPC.WebSockets.Port=</a> </div> <span class="badge badge-success default-value">Default: 8546</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>Port defines the port to serve the endpoints via WS</p> </span> <hr> </div> </div> </div> </div> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.EnableL2SuggestedGasPricePolling onclick="anchorLink('RPC.EnableL2SuggestedGasPricePolling')">RPC.EnableL2SuggestedGasPricePolling=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.TraceBatchUseHTTPS onclick="anchorLink('RPC.TraceBatchUseHTTPS')">RPC.TraceBatchUseHTTPS=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>TraceBatchUseHTTPS enables, in the debug<em>traceBatchByNum endpoint, the use of the HTTPS protocol (instead of HTTP)<br> to do the parallel requests to RPC.debug</em>traceTransaction endpoint</p> </span> <hr> </div> </div> </div> </div> <div class=accordion id=accordionSynchronizer> <div class=card> <div class=card-header id=headingSynchronizer> <h2 class=mb-0> <button class="btn btn-link property-name-button" type=button data-toggle=collapse data-target=#Synchronizer aria-expanded aria-controls=Synchronizer onclick="setAnchor('#Synchronizer')"><span class=property-name> <div class=breadcrumbs>[<a href=#Synchronizer onclick="anchorLink('Synchronizer')">Synchronizer</a>] </div></span></button> </h2> Configuration of service `Syncrhonizer`. For this service is also really important the value of `IsTrustedSequencer` because depending of this values is going to ask to a trusted node for trusted transactions or not </div> <div id=Synchronizer class="collapse property-definition-div" aria-labelledby=headingSynchronizer data-parent=#accordionSynchronizer> <div class="card-body pl-5"> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#Synchronizer.SyncInterval onclick="anchorLink('Synchronizer.SyncInterval')">Synchronizer.SyncInterval=</a> </div> <span class="badge badge-success default-value">Default: "1s"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>SyncInterval is the delay interval between reading new rollup information</p> </span> <br> <div class="badge badge-secondary">Examples:</div> <br><div id=Synchronizer_SyncInterval_ex1 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;1m&quot;</span>
</pre></div> </div> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.MaxRequestsPerIPAndSecond onclick="anchorLink('RPC.MaxRequestsPerIPAndSecond')">RPC.MaxRequestsPerIPAndSecond=</a> </div> <span class="badge badge-success default-value">Default: 500</span><span class="badge badge-dark value-type">Type: number</span><br> <span class=description><p>MaxRequestsPerIPAndSecond defines how much requests a single IP can<br> send within a single second</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.SequencerNodeURI onclick="anchorLink('RPC.SequencerNodeURI')">RPC.SequencerNodeURI=</a> </div> <span class="badge badge-success default-value">Default: ""</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>SequencerNodeURI is used allow Non-Sequencer nodes<br> to relay transactions to the Sequencer node</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.MaxCumulativeGasUsed onclick="anchorLink('RPC.MaxCumulativeGasUsed')">RPC.MaxCumulativeGasUsed=</a> </div> <span class="badge badge-success default-value">Default: 0</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>MaxCumulativeGasUsed is the max gas allowed per batch</p> </span> <hr> <div class=accordion id=accordionRPC_WebSockets> <div class=card> <div class=card-header id=headingRPC_WebSockets> <h2 class=mb-0> <button class="btn btn-link property-name-button" type=button data-toggle=collapse data-target=#RPC_WebSockets aria-expanded aria-controls=RPC_WebSockets onclick="setAnchor('#RPC_WebSockets')"><span class=property-name> <div class=breadcrumbs>[<a href=#RPC onclick="anchorLink('RPC')">RPC</a> . <a href=#RPC_WebSockets onclick="anchorLink('RPC_WebSockets')">WebSockets</a>] </div></span></button> </h2> WebSockets configuration </div> <div id=RPC_WebSockets class="collapse property-definition-div" aria-labelledby=headingRPC_WebSockets data-parent=#accordionRPC_WebSockets> <div class="card-body pl-5"> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Enabled onclick="anchorLink('RPC.WebSockets.Enabled')">RPC.WebSockets.Enabled=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>Enabled defines if the WebSocket requests are enabled or disabled</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Host onclick="anchorLink('RPC.WebSockets.Host')">RPC.WebSockets.Host=</a> </div> <span class="badge badge-success default-value">Default: "0.0.0.0"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>Host defines the network adapter that will be used to serve the WS requests</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><!-- None --><a href=#RPC.WebSockets.Port onclick="anchorLink('RPC.WebSockets.Port')">RPC.WebSockets.Port=</a> </div> <span class="badge badge-success default-value">Default: 8546</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>Port defines the port to serve the endpoints via WS</p> </span> <hr> </div> </div> </div> </div> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.EnableL2SuggestedGasPricePolling onclick="anchorLink('RPC.EnableL2SuggestedGasPricePolling')">RPC.EnableL2SuggestedGasPricePolling=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.TraceBatchUseHTTPS onclick="anchorLink('RPC.TraceBatchUseHTTPS')">RPC.TraceBatchUseHTTPS=</a> </div> <span class="badge badge-success default-value">Default: true</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>TraceBatchUseHTTPS enables, in the debug<em>traceBatchByNum endpoint, the use of the HTTPS protocol (instead of HTTP)<br> to do the parallel requests to RPC.debug</em>traceTransaction endpoint</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.BatchRequestsEnabled onclick="anchorLink('RPC.BatchRequestsEnabled')">RPC.BatchRequestsEnabled=</a> </div> <span class="badge badge-success default-value">Default: false</span><span class="badge badge-dark value-type">Type: boolean</span><br> <span class=description><p>BatchRequestsEnabled defines if the Batch requests are enabled or disabled</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#RPC.BatchRequestsLimit onclick="anchorLink('RPC.BatchRequestsLimit')">RPC.BatchRequestsLimit=</a> </div> <span class="badge badge-success default-value">Default: 20</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request</p> </span> <hr> </div> </div> </div> </div> <div class=accordion id=accordionSynchronizer> <div class=card> <div class=card-header id=headingSynchronizer> <h2 class=mb-0> <button class="btn btn-link property-name-button" type=button data-toggle=collapse data-target=#Synchronizer aria-expanded aria-controls=Synchronizer onclick="setAnchor('#Synchronizer')"><span class=property-name> <div class=breadcrumbs>[<a href=#Synchronizer onclick="anchorLink('Synchronizer')">Synchronizer</a>] </div></span></button> </h2> Configuration of service `Syncrhonizer`. For this service is also really important the value of `IsTrustedSequencer` because depending of this values is going to ask to a trusted node for trusted transactions or not </div> <div id=Synchronizer class="collapse property-definition-div" aria-labelledby=headingSynchronizer data-parent=#accordionSynchronizer> <div class="card-body pl-5"> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#Synchronizer.SyncInterval onclick="anchorLink('Synchronizer.SyncInterval')">Synchronizer.SyncInterval=</a> </div> <span class="badge badge-success default-value">Default: "1s"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>SyncInterval is the delay interval between reading new rollup information</p> </span> <br> <div class="badge badge-secondary">Examples:</div> <br><div id=Synchronizer_SyncInterval_ex1 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;1m&quot;</span>
</pre></div> </div><div id=Synchronizer_SyncInterval_ex2 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;300ms&quot;</span>
</pre></div> </div> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#Synchronizer.SyncChunkSize onclick="anchorLink('Synchronizer.SyncChunkSize')">Synchronizer.SyncChunkSize=</a> </div> <span class="badge badge-success default-value">Default: 100</span><span class="badge badge-dark value-type">Type: integer</span><br> <span class=description><p>SyncChunkSize is the number of blocks to sync on each chunk</p> </span> <hr> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#Synchronizer.TrustedSequencerURL onclick="anchorLink('Synchronizer.TrustedSequencerURL')">Synchronizer.TrustedSequencerURL=</a> </div> <span class="badge badge-success default-value">Default: ""</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>TrustedSequencerURL is the rpc url to connect and sync the trusted state</p> </span> <hr> </div> </div> </div> </div> <div class=accordion id=accordionSequencer> <div class=card> <div class=card-header id=headingSequencer> <h2 class=mb-0> <button class="btn btn-link property-name-button" type=button data-toggle=collapse data-target=#Sequencer aria-expanded aria-controls=Sequencer onclick="setAnchor('#Sequencer')"><span class=property-name> <div class=breadcrumbs>[<a href=#Sequencer onclick="anchorLink('Sequencer')">Sequencer</a>] </div></span></button> </h2> Configuration of the sequencer service </div> <div id=Sequencer class="collapse property-definition-div" aria-labelledby=headingSequencer data-parent=#accordionSequencer> <div class="card-body pl-5"> <div class=breadcrumbs> <!-- None --><!-- None --><a href=#Sequencer.WaitPeriodPoolIsEmpty onclick="anchorLink('Sequencer.WaitPeriodPoolIsEmpty')">Sequencer.WaitPeriodPoolIsEmpty=</a> </div> <span class="badge badge-success default-value">Default: "1s"</span><span class="badge badge-dark value-type">Type: string</span><br> <span class=description><p>WaitPeriodPoolIsEmpty is the time the sequencer waits until<br> trying to add new txs to the state</p> </span> <br> <div class="badge badge-secondary">Examples:</div> <br><div id=Sequencer_WaitPeriodPoolIsEmpty_ex1 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;1m&quot;</span>
</pre></div> </div><div id=Sequencer_WaitPeriodPoolIsEmpty_ex2 class="jumbotron examples"><div class=highlight><pre><span></span><span class=s2>&quot;300ms&quot;</span>
Expand Down
30 changes: 30 additions & 0 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ GlobalQueue=1024
| - [WebSockets](#RPC_WebSockets ) | No | object | No | - | WebSockets configuration |
| - [EnableL2SuggestedGasPricePolling](#RPC_EnableL2SuggestedGasPricePolling ) | No | boolean | No | - | EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price. |
| - [TraceBatchUseHTTPS](#RPC_TraceBatchUseHTTPS ) | No | boolean | No | - | TraceBatchUseHTTPS enables, in the debug_traceBatchByNum endpoint, the use of the HTTPS protocol (instead of HTTP)<br />to do the parallel requests to RPC.debug_traceTransaction endpoint |
| - [BatchRequestsEnabled](#RPC_BatchRequestsEnabled ) | No | boolean | No | - | BatchRequestsEnabled defines if the Batch requests are enabled or disabled |
| - [BatchRequestsLimit](#RPC_BatchRequestsLimit ) | No | integer | No | - | BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request |

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

Expand Down Expand Up @@ -924,6 +926,34 @@ to do the parallel requests to RPC.debug_traceTransaction endpoint
TraceBatchUseHTTPS=true
```

### <a name="RPC_BatchRequestsEnabled"></a>8.11. `RPC.BatchRequestsEnabled`

**Type:** : `boolean`

**Default:** `false`

**Description:** BatchRequestsEnabled defines if the Batch requests are enabled or disabled

**Example setting the default value** (false):
```
[RPC]
BatchRequestsEnabled=false
```

### <a name="RPC_BatchRequestsLimit"></a>8.12. `RPC.BatchRequestsLimit`

**Type:** : `integer`

**Default:** `20`

**Description:** BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request

**Example setting the default value** (20):
```
[RPC]
BatchRequestsLimit=20
```

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

**Type:** : `object`
Expand Down
10 changes: 10 additions & 0 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@
"type": "boolean",
"description": "TraceBatchUseHTTPS enables, in the debug_traceBatchByNum endpoint, the use of the HTTPS protocol (instead of HTTP)\nto do the parallel requests to RPC.debug_traceTransaction endpoint",
"default": true
},
"BatchRequestsEnabled": {
"type": "boolean",
"description": "BatchRequestsEnabled defines if the Batch requests are enabled or disabled",
"default": false
},
"BatchRequestsLimit": {
"type": "integer",
"description": "BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request",
"default": 20
}
},
"additionalProperties": false,
Expand Down
Loading

0 comments on commit 14733fb

Please sign in to comment.