Skip to content

Commit

Permalink
Fix state configuration (0xPolygonHermez#2478)
Browse files Browse the repository at this point in the history
* Fix state configuration

* Remove ResourceWeights unnecessary configuration

* linter
  • Loading branch information
ARR552 authored Aug 30, 2023
1 parent 5bc323d commit eb71392
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 273 deletions.
36 changes: 0 additions & 36 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,42 +450,6 @@ func Test_Defaults(t *testing.T) {
path: "State.Batch.Constraints.MaxSteps",
expectedValue: uint32(7570538),
},
{
path: "State.Batch.ResourceWeights.WeightBatchBytesSize",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightCumulativeGasUsed",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightKeccakHashes",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightPoseidonHashes",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightPoseidonPaddings",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightMemAligns",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightArithmetics",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightBinaries",
expectedValue: 1,
},
{
path: "State.Batch.ResourceWeights.WeightSteps",
expectedValue: 1,
},
}
file, err := os.CreateTemp("", "genesisConfig")
require.NoError(t, err)
Expand Down
10 changes: 0 additions & 10 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ AccountQueue = 64
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538
[State.Batch.ResourceWeights]
WeightBatchBytesSize = 1
WeightCumulativeGasUsed = 1
WeightKeccakHashes = 1
WeightPoseidonHashes = 1
WeightPoseidonPaddings = 1
WeightMemAligns = 1
WeightArithmetics = 1
WeightBinaries = 1
WeightSteps = 1
[Pool]
IntervalToRefreshBlockedAddresses = "5m"
Expand Down
23 changes: 23 additions & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[State]
AccountQueue = 64
[State.DB]
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[State.Batch]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
MaxMemAligns = 236585
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538

[Pool]
IntervalToRefreshBlockedAddresses = "5m"
IntervalToRefreshGasPrices = "5s"
Expand Down
23 changes: 23 additions & 0 deletions config/environments/mainnet/node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ Environment = "development" # "production" or "development"
Level = "info"
Outputs = ["stderr"]

[State]
AccountQueue = 64
[State.DB]
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[State.Batch]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
MaxMemAligns = 236585
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538

[Pool]
MaxTxBytesSize=100132
MaxTxDataBytesSize=100000
Expand Down
23 changes: 23 additions & 0 deletions config/environments/testnet/node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ Environment = "development" # "production" or "development"
Level = "info"
Outputs = ["stderr"]

[State]
AccountQueue = 64
[State.DB]
User = "state_user"
Password = "state_password"
Name = "state_db"
Host = "zkevm-state-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[State.Batch]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 30000000
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
MaxMemAligns = 236585
MaxArithmetics = 236585
MaxBinaries = 473170
MaxSteps = 7570538

[Pool]
IntervalToRefreshBlockedAddresses = "5m"
IntervalToRefreshGasPrices = "5s"
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

131 changes: 3 additions & 128 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3074,10 +3074,9 @@ MaxConns=200
**Type:** : `object`
**Description:** Configuration for the batch constraints

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| -------------------------------------------------- | ------- | ------ | ---------- | ---------- | ----------------- |
| - [Constraints](#State_Batch_Constraints ) | No | object | No | - | - |
| - [ResourceWeights](#State_Batch_ResourceWeights ) | No | object | No | - | - |
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------ | ------- | ------ | ---------- | ---------- | ----------------- |
| - [Constraints](#State_Batch_Constraints ) | No | object | No | - | - |

#### <a name="State_Batch_Constraints"></a>20.9.1. `[State.Batch.Constraints]`

Expand Down Expand Up @@ -3216,129 +3215,5 @@ MaxBinaries=473170
MaxSteps=7570538
```

#### <a name="State_Batch_ResourceWeights"></a>20.9.2. `[State.Batch.ResourceWeights]`

**Type:** : `object`

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ---------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- |
| - [WeightBatchBytesSize](#State_Batch_ResourceWeights_WeightBatchBytesSize ) | No | integer | No | - | - |
| - [WeightCumulativeGasUsed](#State_Batch_ResourceWeights_WeightCumulativeGasUsed ) | No | integer | No | - | - |
| - [WeightKeccakHashes](#State_Batch_ResourceWeights_WeightKeccakHashes ) | No | integer | No | - | - |
| - [WeightPoseidonHashes](#State_Batch_ResourceWeights_WeightPoseidonHashes ) | No | integer | No | - | - |
| - [WeightPoseidonPaddings](#State_Batch_ResourceWeights_WeightPoseidonPaddings ) | No | integer | No | - | - |
| - [WeightMemAligns](#State_Batch_ResourceWeights_WeightMemAligns ) | No | integer | No | - | - |
| - [WeightArithmetics](#State_Batch_ResourceWeights_WeightArithmetics ) | No | integer | No | - | - |
| - [WeightBinaries](#State_Batch_ResourceWeights_WeightBinaries ) | No | integer | No | - | - |
| - [WeightSteps](#State_Batch_ResourceWeights_WeightSteps ) | No | integer | No | - | - |

##### <a name="State_Batch_ResourceWeights_WeightBatchBytesSize"></a>20.9.2.1. `State.Batch.ResourceWeights.WeightBatchBytesSize`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightBatchBytesSize=1
```

##### <a name="State_Batch_ResourceWeights_WeightCumulativeGasUsed"></a>20.9.2.2. `State.Batch.ResourceWeights.WeightCumulativeGasUsed`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightCumulativeGasUsed=1
```

##### <a name="State_Batch_ResourceWeights_WeightKeccakHashes"></a>20.9.2.3. `State.Batch.ResourceWeights.WeightKeccakHashes`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightKeccakHashes=1
```

##### <a name="State_Batch_ResourceWeights_WeightPoseidonHashes"></a>20.9.2.4. `State.Batch.ResourceWeights.WeightPoseidonHashes`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightPoseidonHashes=1
```

##### <a name="State_Batch_ResourceWeights_WeightPoseidonPaddings"></a>20.9.2.5. `State.Batch.ResourceWeights.WeightPoseidonPaddings`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightPoseidonPaddings=1
```

##### <a name="State_Batch_ResourceWeights_WeightMemAligns"></a>20.9.2.6. `State.Batch.ResourceWeights.WeightMemAligns`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightMemAligns=1
```

##### <a name="State_Batch_ResourceWeights_WeightArithmetics"></a>20.9.2.7. `State.Batch.ResourceWeights.WeightArithmetics`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightArithmetics=1
```

##### <a name="State_Batch_ResourceWeights_WeightBinaries"></a>20.9.2.8. `State.Batch.ResourceWeights.WeightBinaries`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightBinaries=1
```

##### <a name="State_Batch_ResourceWeights_WeightSteps"></a>20.9.2.9. `State.Batch.ResourceWeights.WeightSteps`

**Type:** : `integer`

**Default:** `1`

**Example setting the default value** (1):
```
[State.Batch.ResourceWeights]
WeightSteps=1
```

----------------------------------------------------------------------------------------------------------------------------
Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans)
42 changes: 0 additions & 42 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1293,48 +1293,6 @@
},
"additionalProperties": false,
"type": "object"
},
"ResourceWeights": {
"properties": {
"WeightBatchBytesSize": {
"type": "integer",
"default": 1
},
"WeightCumulativeGasUsed": {
"type": "integer",
"default": 1
},
"WeightKeccakHashes": {
"type": "integer",
"default": 1
},
"WeightPoseidonHashes": {
"type": "integer",
"default": 1
},
"WeightPoseidonPaddings": {
"type": "integer",
"default": 1
},
"WeightMemAligns": {
"type": "integer",
"default": 1
},
"WeightArithmetics": {
"type": "integer",
"default": 1
},
"WeightBinaries": {
"type": "integer",
"default": 1
},
"WeightSteps": {
"type": "integer",
"default": 1
}
},
"additionalProperties": false,
"type": "object"
}
},
"additionalProperties": false,
Expand Down
16 changes: 1 addition & 15 deletions state/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ type Config struct {

// BatchConfig represents the configuration of the batch constraints
type BatchConfig struct {
Constraints BatchConstraintsCfg `mapstructure:"Constraints"`
ResourceWeights BatchResourceWeightsCfg `mapstructure:"ResourceWeights"`
Constraints BatchConstraintsCfg `mapstructure:"Constraints"`
}

// BatchConstraintsCfg represents the configuration of the batch constraints
Expand Down Expand Up @@ -66,16 +65,3 @@ func (c BatchConstraintsCfg) IsWithinConstraints(counters ZKCounters) bool {
counters.UsedBinaries <= c.MaxBinaries &&
counters.UsedSteps <= c.MaxSteps
}

// BatchResourceWeightsCfg represents the configuration of the batch resource weights
type BatchResourceWeightsCfg struct {
WeightBatchBytesSize int `mapstructure:"WeightBatchBytesSize"`
WeightCumulativeGasUsed int `mapstructure:"WeightCumulativeGasUsed"`
WeightKeccakHashes int `mapstructure:"WeightKeccakHashes"`
WeightPoseidonHashes int `mapstructure:"WeightPoseidonHashes"`
WeightPoseidonPaddings int `mapstructure:"WeightPoseidonPaddings"`
WeightMemAligns int `mapstructure:"WeightMemAligns"`
WeightArithmetics int `mapstructure:"WeightArithmetics"`
WeightBinaries int `mapstructure:"WeightBinaries"`
WeightSteps int `mapstructure:"WeightSteps"`
}
Loading

0 comments on commit eb71392

Please sign in to comment.