Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import cdk-validium-node genesis improvement #3780

Merged
merged 7 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ func forkIDIntervals(ctx context.Context, st *state.State, etherman *etherman.Cl
if err != nil && !errors.Is(err, state.ErrStateNotSynchronized) {
return []state.ForkIDInterval{}, fmt.Errorf("error checking lastL1BlockSynced. Error: %v", err)
}
if lastBlock != nil {
// If there are a lastBlock and is >= to genesisBlock, means that have started the sync process (if not if lastBlock!=nil then is doing pregenesis sync)
if lastBlock != nil && lastBlock.BlockNumber >= genesisBlockNumber {
log.Info("Getting forkIDs intervals. Please wait...")
// Read Fork ID FROM POE SC
forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, lastBlock.BlockNumber)
Expand Down
1 change: 1 addition & 0 deletions config/cardonagenesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const CardonaNetworkConfigJSON = `
"chainId": 11155111
},
"genesisBlockNumber": 4789190,
"rollupManagerCreationBlockNumber": 4789190,
"root": "0x91dfcdeb628dfdc51f3a2ee38cb17c78581e4e7ff91bcc2e327d24a9dfa46982",
"genesis": [
{
Expand Down
1 change: 1 addition & 0 deletions config/mainnetgenesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MainnetNetworkConfigJSON = `
},
"root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9",
"genesisBlockNumber": 16896721,
"rollupManagerCreationBlockNumber": 16896721,
"genesis": [
{
"contractName": "PolygonZkEVMDeployer",
Expand Down
9 changes: 6 additions & 3 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type GenesisFromJSON struct {
Root string `json:"root"`
// L1: block number of the genesis block
GenesisBlockNum uint64 `json:"genesisBlockNumber"`
// rollupManagerCreationBlockNumber is the block number where the RollupManager smc was deployed on L1 (0 auto-discover)
RollupManagerCreationBlockNumber uint64 `json:"rollupManagerCreationBlockNumber"`
// L2: List of states contracts used to populate merkle tree at initial state
Genesis []genesisAccountFromJSON `json:"genesis"`
// L1: configuration of the network
Expand Down Expand Up @@ -122,9 +124,10 @@ func LoadGenesisFromJSONString(jsonStr string) (NetworkConfig, error) {

cfg.L1Config = cfgJSON.L1Config
cfg.Genesis = state.Genesis{
BlockNumber: cfgJSON.GenesisBlockNum,
Root: common.HexToHash(cfgJSON.Root),
Actions: []*state.GenesisAction{},
BlockNumber: cfgJSON.GenesisBlockNum,
Root: common.HexToHash(cfgJSON.Root),
RollupManagerBlockNumber: cfgJSON.RollupManagerCreationBlockNumber,
Actions: []*state.GenesisAction{},
}

for _, account := range cfgJSON.Genesis {
Expand Down
6 changes: 4 additions & 2 deletions config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
inputConfigStr: `{
"root": "0xBEEF",
"genesisBlockNumber": 69,
"rollupManagerCreationBlockNumber": 68,
"l1Config" : {
"chainId": 420,
"polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4",
Expand Down Expand Up @@ -89,8 +90,9 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
},
Genesis: state.Genesis{
Root: common.HexToHash("0xBEEF"),
BlockNumber: 69,
Root: common.HexToHash("0xBEEF"),
BlockNumber: 69,
RollupManagerBlockNumber: 68,
Actions: []*state.GenesisAction{
{
Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4",
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/custom_network-config-doc.html

Large diffs are not rendered by default.

48 changes: 27 additions & 21 deletions docs/config-file/custom_network-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
**Type:** : `object`
**Description:** GenesisFromJSON is the config file for network_custom

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| -------------------------------------------- | ------- | --------------- | ---------- | ---------- | --------------------------------------------------------------------------- |
| - [root](#root ) | No | string | No | - | L1: root hash of the genesis block |
| - [genesisBlockNumber](#genesisBlockNumber ) | No | integer | No | - | L1: block number of the genesis block |
| - [genesis](#genesis ) | No | array of object | No | - | L2: List of states contracts used to populate merkle tree at initial state |
| - [L1Config](#L1Config ) | No | object | No | - | L1: configuration of the network |
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------------------ | ------- | --------------- | ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------- |
| - [root](#root ) | No | string | No | - | L1: root hash of the genesis block |
| - [genesisBlockNumber](#genesisBlockNumber ) | No | integer | No | - | L1: block number of the genesis block |
| - [rollupManagerCreationBlockNumber](#rollupManagerCreationBlockNumber ) | No | integer | No | - | rollupManagerCreationBlockNumber is the block number where the RollupManager smc was deployed on L1 (0 auto-discover) |
| - [genesis](#genesis ) | No | array of object | No | - | L2: List of states contracts used to populate merkle tree at initial state |
| - [L1Config](#L1Config ) | No | object | No | - | L1: configuration of the network |

## <a name="root"></a>1. `root`

Expand All @@ -20,7 +21,12 @@
**Type:** : `integer`
**Description:** L1: block number of the genesis block

## <a name="genesis"></a>3. `genesis`
## <a name="rollupManagerCreationBlockNumber"></a>3. `rollupManagerCreationBlockNumber`

**Type:** : `integer`
**Description:** rollupManagerCreationBlockNumber is the block number where the RollupManager smc was deployed on L1 (0 auto-discover)

## <a name="genesis"></a>4. `genesis`

**Type:** : `array of object`
**Description:** L2: List of states contracts used to populate merkle tree at initial state
Expand All @@ -37,7 +43,7 @@
| ------------------------------- | ----------- |
| [genesis items](#genesis_items) | - |

### <a name="autogenerated_heading_2"></a>3.1. [genesis.genesis items]
### <a name="autogenerated_heading_2"></a>4.1. [genesis.genesis items]

**Type:** : `object`

Expand All @@ -50,39 +56,39 @@
| - [storage](#genesis_items_storage ) | No | object | No | - | - |
| - [contractName](#genesis_items_contractName ) | No | string | No | - | - |

#### <a name="genesis_items_balance"></a>3.1.1. `genesis.genesis items.balance`
#### <a name="genesis_items_balance"></a>4.1.1. `genesis.genesis items.balance`

**Type:** : `string`

#### <a name="genesis_items_nonce"></a>3.1.2. `genesis.genesis items.nonce`
#### <a name="genesis_items_nonce"></a>4.1.2. `genesis.genesis items.nonce`

**Type:** : `string`

#### <a name="genesis_items_address"></a>3.1.3. `genesis.genesis items.address`
#### <a name="genesis_items_address"></a>4.1.3. `genesis.genesis items.address`

**Type:** : `string`

#### <a name="genesis_items_bytecode"></a>3.1.4. `genesis.genesis items.bytecode`
#### <a name="genesis_items_bytecode"></a>4.1.4. `genesis.genesis items.bytecode`

**Type:** : `string`

#### <a name="genesis_items_storage"></a>3.1.5. `[genesis.genesis items.storage]`
#### <a name="genesis_items_storage"></a>4.1.5. `[genesis.genesis items.storage]`

**Type:** : `object`

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| -------------------------------------------------- | ------- | ------ | ---------- | ---------- | ----------------- |
| - [](#genesis_items_storage_additionalProperties ) | No | string | No | - | - |

##### <a name="genesis_items_storage_additionalProperties"></a>3.1.5.1. `genesis.genesis items.storage.additionalProperties`
##### <a name="genesis_items_storage_additionalProperties"></a>4.1.5.1. `genesis.genesis items.storage.additionalProperties`

**Type:** : `string`

#### <a name="genesis_items_contractName"></a>3.1.6. `genesis.genesis items.contractName`
#### <a name="genesis_items_contractName"></a>4.1.6. `genesis.genesis items.contractName`

**Type:** : `string`

## <a name="L1Config"></a>4. `[L1Config]`
## <a name="L1Config"></a>5. `[L1Config]`

**Type:** : `object`
**Description:** L1: configuration of the network
Expand All @@ -95,27 +101,27 @@
| - [polTokenAddress](#L1Config_polTokenAddress ) | No | array of integer | No | - | PolAddr Address of the L1 Pol token Contract |
| - [polygonZkEVMGlobalExitRootAddress](#L1Config_polygonZkEVMGlobalExitRootAddress ) | No | array of integer | No | - | GlobalExitRootManagerAddr Address of the L1 GlobalExitRootManager contract |

### <a name="L1Config_chainId"></a>4.1. `L1Config.chainId`
### <a name="L1Config_chainId"></a>5.1. `L1Config.chainId`

**Type:** : `integer`
**Description:** Chain ID of the L1 network

### <a name="L1Config_polygonZkEVMAddress"></a>4.2. `L1Config.polygonZkEVMAddress`
### <a name="L1Config_polygonZkEVMAddress"></a>5.2. `L1Config.polygonZkEVMAddress`

**Type:** : `array of integer`
**Description:** ZkEVMAddr Address of the L1 contract polygonZkEVMAddress

### <a name="L1Config_polygonRollupManagerAddress"></a>4.3. `L1Config.polygonRollupManagerAddress`
### <a name="L1Config_polygonRollupManagerAddress"></a>5.3. `L1Config.polygonRollupManagerAddress`

**Type:** : `array of integer`
**Description:** RollupManagerAddr Address of the L1 contract

### <a name="L1Config_polTokenAddress"></a>4.4. `L1Config.polTokenAddress`
### <a name="L1Config_polTokenAddress"></a>5.4. `L1Config.polTokenAddress`

**Type:** : `array of integer`
**Description:** PolAddr Address of the L1 Pol token Contract

### <a name="L1Config_polygonZkEVMGlobalExitRootAddress"></a>4.5. `L1Config.polygonZkEVMGlobalExitRootAddress`
### <a name="L1Config_polygonZkEVMGlobalExitRootAddress"></a>5.5. `L1Config.polygonZkEVMGlobalExitRootAddress`

**Type:** : `array of integer`
**Description:** GlobalExitRootManagerAddr Address of the L1 GlobalExitRootManager contract
Expand Down
4 changes: 4 additions & 0 deletions docs/config-file/custom_network-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"type": "integer",
"description": "L1: block number of the genesis block"
},
"rollupManagerCreationBlockNumber": {
"type": "integer",
"description": "rollupManagerCreationBlockNumber is the block number where the RollupManager smc was deployed on L1 (0 auto-discover)"
},
"genesis": {
"items": {
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

43 changes: 29 additions & 14 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3306,11 +3306,12 @@ chainId=0
**Type:** : `object`
**Description:** L1: Genesis of the rollup, first block number and root

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ---------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------------------------------------------------------------------- |
| - [BlockNumber](#NetworkConfig_Genesis_BlockNumber ) | No | integer | No | - | BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 |
| - [Root](#NetworkConfig_Genesis_Root ) | No | array of integer | No | - | Root hash of the genesis block |
| - [Actions](#NetworkConfig_Genesis_Actions ) | No | array of object | No | - | Actions is the data to populate into the state trie |
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------------------------ | ------- | ---------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| - [BlockNumber](#NetworkConfig_Genesis_BlockNumber ) | No | integer | No | - | BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 |
| - [Root](#NetworkConfig_Genesis_Root ) | No | array of integer | No | - | Root hash of the genesis block |
| - [RollupManagerBlockNumber](#NetworkConfig_Genesis_RollupManagerBlockNumber ) | No | integer | No | - | RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1 if if set to AutoDiscoverRollupManagerBlockNumber(0) then is auto-discovered |
| - [Actions](#NetworkConfig_Genesis_Actions ) | No | array of object | No | - | Actions is the data to populate into the state trie |

#### <a name="NetworkConfig_Genesis_BlockNumber"></a>13.2.1. `NetworkConfig.Genesis.BlockNumber`

Expand All @@ -3331,7 +3332,21 @@ BlockNumber=0
**Type:** : `array of integer`
**Description:** Root hash of the genesis block

#### <a name="NetworkConfig_Genesis_Actions"></a>13.2.3. `NetworkConfig.Genesis.Actions`
#### <a name="NetworkConfig_Genesis_RollupManagerBlockNumber"></a>13.2.3. `NetworkConfig.Genesis.RollupManagerBlockNumber`

**Type:** : `integer`

**Default:** `0`

**Description:** RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1 if if set to AutoDiscoverRollupManagerBlockNumber(0) then is auto-discovered

**Example setting the default value** (0):
```
[NetworkConfig.Genesis]
RollupManagerBlockNumber=0
```

#### <a name="NetworkConfig_Genesis_Actions"></a>13.2.4. `NetworkConfig.Genesis.Actions`

**Type:** : `array of object`
**Description:** Actions is the data to populate into the state trie
Expand All @@ -3348,7 +3363,7 @@ BlockNumber=0
| ----------------------------------------------------- | ------------------------------------------------------------------------- |
| [Actions items](#NetworkConfig_Genesis_Actions_items) | GenesisAction represents one of the values set on the SMT during genesis. |

##### <a name="autogenerated_heading_3"></a>13.2.3.1. [NetworkConfig.Genesis.Actions.Actions items]
##### <a name="autogenerated_heading_3"></a>13.2.4.1. [NetworkConfig.Genesis.Actions.Actions items]

**Type:** : `object`
**Description:** GenesisAction represents one of the values set on the SMT during genesis.
Expand All @@ -3363,31 +3378,31 @@ BlockNumber=0
| - [value](#NetworkConfig_Genesis_Actions_items_value ) | No | string | No | - | - |
| - [root](#NetworkConfig_Genesis_Actions_items_root ) | No | string | No | - | - |

##### <a name="NetworkConfig_Genesis_Actions_items_address"></a>13.2.3.1.1. `NetworkConfig.Genesis.Actions.Actions items.address`
##### <a name="NetworkConfig_Genesis_Actions_items_address"></a>13.2.4.1.1. `NetworkConfig.Genesis.Actions.Actions items.address`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_Actions_items_type"></a>13.2.3.1.2. `NetworkConfig.Genesis.Actions.Actions items.type`
##### <a name="NetworkConfig_Genesis_Actions_items_type"></a>13.2.4.1.2. `NetworkConfig.Genesis.Actions.Actions items.type`

**Type:** : `integer`

##### <a name="NetworkConfig_Genesis_Actions_items_storagePosition"></a>13.2.3.1.3. `NetworkConfig.Genesis.Actions.Actions items.storagePosition`
##### <a name="NetworkConfig_Genesis_Actions_items_storagePosition"></a>13.2.4.1.3. `NetworkConfig.Genesis.Actions.Actions items.storagePosition`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_Actions_items_bytecode"></a>13.2.3.1.4. `NetworkConfig.Genesis.Actions.Actions items.bytecode`
##### <a name="NetworkConfig_Genesis_Actions_items_bytecode"></a>13.2.4.1.4. `NetworkConfig.Genesis.Actions.Actions items.bytecode`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_Actions_items_key"></a>13.2.3.1.5. `NetworkConfig.Genesis.Actions.Actions items.key`
##### <a name="NetworkConfig_Genesis_Actions_items_key"></a>13.2.4.1.5. `NetworkConfig.Genesis.Actions.Actions items.key`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_Actions_items_value"></a>13.2.3.1.6. `NetworkConfig.Genesis.Actions.Actions items.value`
##### <a name="NetworkConfig_Genesis_Actions_items_value"></a>13.2.4.1.6. `NetworkConfig.Genesis.Actions.Actions items.value`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_Actions_items_root"></a>13.2.3.1.7. `NetworkConfig.Genesis.Actions.Actions items.root`
##### <a name="NetworkConfig_Genesis_Actions_items_root"></a>13.2.4.1.7. `NetworkConfig.Genesis.Actions.Actions items.root`

**Type:** : `string`

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 @@ -1311,6 +1311,11 @@
"minItems": 32,
"description": "Root hash of the genesis block"
},
"RollupManagerBlockNumber": {
"type": "integer",
"description": "RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1 if if set to AutoDiscoverRollupManagerBlockNumber(0) then is auto-discovered",
"default": 0
},
"Actions": {
"items": {
"properties": {
Expand Down
Loading
Loading