Skip to content

Commit

Permalink
Feature/aggregator update etrog batch (0xPolygonHermez#3117)
Browse files Browse the repository at this point in the history
* wip

* Fix aggregator

* change name to UpgradeEtrogBatchNumber

* doc
  • Loading branch information
ARR552 authored Jan 22, 2024
1 parent 8e0b1f5 commit 05357ab
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 4 deletions.
5 changes: 2 additions & 3 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.

isForcedBatch := false
batchRawData := &state.BatchRawV2{}

if batchToVerify.BatchNumber == 1 || batchToVerify.ForcedBatchNum != nil {
if batchToVerify.BatchNumber == 1 || batchToVerify.ForcedBatchNum != nil || batchToVerify.BatchNumber == a.cfg.UpgradeEtrogBatchNumber {
isForcedBatch = true
} else {
batchRawData, err = state.DecodeBatchV2(batchToVerify.BatchL2Data)
Expand Down Expand Up @@ -1046,7 +1045,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
}
} else {
// Initial batch must be handled differently
if batchToVerify.BatchNumber == 1 {
if batchToVerify.BatchNumber == 1 || batchToVerify.BatchNumber == a.cfg.UpgradeEtrogBatchNumber {
forcedBlockhashL1, err = a.State.GetVirtualBatchParentHash(ctx, batchToVerify.BatchNumber, nil)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@ type Config struct {
// gas offset: 100
// final gas: 1100
GasOffset uint64 `mapstructure:"GasOffset"`

// UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog
UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
}
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ func Test_Defaults(t *testing.T) {
path: "Aggregator.GasOffset",
expectedValue: uint64(0),
},
{
path: "Aggregator.UpgradeEtrogBatchNumber",
expectedValue: uint64(0),
},
{
path: "State.Batch.Constraints.MaxTxsPerBatch",
expectedValue: uint64(300),
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ ProofStatePollingInterval = "5s"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
GasOffset = 0
UpgradeEtrogBatchNumber = 0
[L2GasPriceSuggester]
Type = "follower"
Expand Down
1 change: 1 addition & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ ProofStatePollingInterval = "5s"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
UpgradeEtrogBatchNumber = 0

[EthTxManager]
ForcedGas = 0
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,7 @@ Must be one of:
| - [CleanupLockedProofsInterval](#Aggregator_CleanupLockedProofsInterval ) | No | string | No | - | Duration |
| - [GeneratingProofCleanupThreshold](#Aggregator_GeneratingProofCleanupThreshold ) | No | string | No | - | GeneratingProofCleanupThreshold represents the time interval after<br />which a proof in generating state is considered to be stuck and<br />allowed to be cleared. |
| - [GasOffset](#Aggregator_GasOffset ) | No | integer | No | - | GasOffset is the amount of gas to be added to the gas estimation in order<br />to provide an amount that is higher than the estimated one. This is used<br />to avoid the TX getting reverted in case something has changed in the network<br />state after the estimation which can cause the TX to require more gas to be<br />executed.<br /><br />ex:<br />gas estimation: 1000<br />gas offset: 100<br />final gas: 1100 |
| - [UpgradeEtrogBatchNumber](#Aggregator_UpgradeEtrogBatchNumber ) | No | integer | No | - | UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog |

### <a name="Aggregator_Host"></a>12.1. `Aggregator.Host`

Expand Down Expand Up @@ -2684,6 +2685,20 @@ final gas: 1100
GasOffset=0
```

### <a name="Aggregator_UpgradeEtrogBatchNumber"></a>12.15. `Aggregator.UpgradeEtrogBatchNumber`

**Type:** : `integer`

**Default:** `0`

**Description:** UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog

**Example setting the default value** (0):
```
[Aggregator]
UpgradeEtrogBatchNumber=0
```

## <a name="NetworkConfig"></a>13. `[NetworkConfig]`

**Type:** : `object`
Expand Down
5 changes: 5 additions & 0 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,11 @@
"type": "integer",
"description": "GasOffset is the amount of gas to be added to the gas estimation in order\nto provide an amount that is higher than the estimated one. This is used\nto avoid the TX getting reverted in case something has changed in the network\nstate after the estimation which can cause the TX to require more gas to be\nexecuted.\n\nex:\ngas estimation: 1000\ngas offset: 100\nfinal gas: 1100",
"default": 0
},
"UpgradeEtrogBatchNumber": {
"type": "integer",
"description": "UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog",
"default": 0
}
},
"additionalProperties": false,
Expand Down
1 change: 1 addition & 0 deletions test/config/debug.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ ProofStatePollingInterval = "5s"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
UpgradeEtrogBatchNumber = 0

[EthTxManager]
ForcedGas = 0
Expand Down
1 change: 1 addition & 0 deletions test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ ProofStatePollingInterval = "5s"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
UpgradeEtrogBatchNumber = 0

[EthTxManager]
ForcedGas = 0
Expand Down
1 change: 1 addition & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ services:
- ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db
- ZKEVM_NODE_AGGREGATOR_SENDER_ADDRESS=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
- ZKEVM_NODE_ETHERMAN_URL=http://zkevm-v1tov2-l1-network:8545
- ZKEVM_NODE_AGGREGATOR_UPGRADEETROGBATCHNUMBER=2
volumes:
- ./config/test.node.config.toml:/app/config.toml
- ./config/test.genesis-v1tov2.config.json:/app/genesis.json
Expand Down

0 comments on commit 05357ab

Please sign in to comment.