Skip to content

Commit

Permalink
Update smc + sync init tx (0xPolygonHermez#2941)
Browse files Browse the repository at this point in the history
* new smc

* wip sync init tx

* sync init tx

* fix

* linter

* json

* new image and genesis
  • Loading branch information
ARR552 authored Dec 19, 2023
1 parent ec1daa5 commit 4d76030
Show file tree
Hide file tree
Showing 32 changed files with 411 additions and 490 deletions.
23 changes: 8 additions & 15 deletions config/environments/local/local.genesis.config.json

Large diffs are not rendered by default.

33 changes: 14 additions & 19 deletions config/gen_json_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
"github.com/invopop/jsonschema"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -80,10 +79,6 @@ type ConfigWithDurationAndAComplexArray struct {
PrivateKeys []KeystoreFileConfigExample
}

type ConfigWithBatchDataPointer struct {
FirstBatchData *state.BatchData
}

func checkDefaultValue(t *testing.T, schema *jsonschema.Schema, key []string, expectedValue interface{}) {
v, err := getValueFromSchema(schema, key)
require.NoError(t, err)
Expand All @@ -95,20 +90,20 @@ f1_another_name="value_f1"
f2_another_name=5678
`

func TestConfigWithPointer(t *testing.T) {
cli := cli.NewContext(nil, nil, nil)
generator := ConfigJsonSchemaGenerater[ConfigWithBatchDataPointer]{
repoName: "github.com/0xPolygonHermez/zkevm-node/config/",
cleanRequiredField: true,
addCodeCommentsToSchema: true,
pathSourceCode: "./",
repoNameSuffix: "config/",
defaultValues: &ConfigWithBatchDataPointer{},
}
schema, err := generator.GenerateJsonSchema(cli)
require.NoError(t, err)
require.NotNil(t, schema)
}
// func TestConfigWithPointer(t *testing.T) {
// cli := cli.NewContext(nil, nil, nil)
// generator := ConfigJsonSchemaGenerater[ConfigWithBatchDataPointer]{
// repoName: "github.com/0xPolygonHermez/zkevm-node/config/",
// cleanRequiredField: true,
// addCodeCommentsToSchema: true,
// pathSourceCode: "./",
// repoNameSuffix: "config/",
// defaultValues: &ConfigWithBatchDataPointer{},
// }
// schema, err := generator.GenerateJsonSchema(cli)
// require.NoError(t, err)
// require.NotNil(t, schema)
// }

func TestGenerateJsonSchemaWithAEthAddressEmpty(t *testing.T) {
cli := cli.NewContext(nil, nil, nil)
Expand Down
9 changes: 3 additions & 6 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ type GenesisFromJSON struct {
Genesis []genesisAccountFromJSON `json:"genesis"`
// L1: configuration of the network
L1Config etherman.L1Config
// Data of the first batch after the genesis(Batch 1)
FirstBatchData *state.BatchData `json:"firstBatchData"`
}

type genesisAccountFromJSON struct {
Expand Down Expand Up @@ -121,10 +119,9 @@ 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{},
FirstBatchData: cfgJSON.FirstBatchData,
BlockNumber: cfgJSON.GenesisBlockNum,
Root: common.HexToHash(cfgJSON.Root),
Actions: []*state.GenesisAction{},
}

for _, account := range cfgJSON.Genesis {
Expand Down
12 changes: 0 additions & 12 deletions config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
}
}
],
"firstBatchData": {
"transactions": "0xf8c380808401c9c380942a3dd3eb832af982ec71669e178424b10dca2ede80b8a4d3476afe000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005ca1ab1e0000000000000000000000000000000000000000000000000000000005ca1ab1e1bff",
"globalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": 1697640780,
"sequencer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
}
}`,
expectedConfig: NetworkConfig{
L1Config: etherman.L1Config{
Expand All @@ -82,12 +76,6 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
},
Genesis: state.Genesis{
FirstBatchData: &state.BatchData{
Transactions: "0xf8c380808401c9c380942a3dd3eb832af982ec71669e178424b10dca2ede80b8a4d3476afe000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005ca1ab1e0000000000000000000000000000000000000000000000000000000005ca1ab1e1bff",
GlobalExitRoot: common.Hash{},
Timestamp: 1697640780,
Sequencer: common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),
},
Root: common.HexToHash("0xBEEF"),
BlockNumber: 69,
Actions: []*state.GenesisAction{
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/custom_network-config-doc.html

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions docs/config-file/custom_network-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
| - [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 |
| - [firstBatchData](#firstBatchData ) | No | object | No | - | Data of the first batch after the genesis(Batch 1) |

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

Expand Down Expand Up @@ -121,38 +120,5 @@
**Type:** : `array of integer`
**Description:** GlobalExitRootManagerAddr Address of the L1 GlobalExitRootManager contract

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

**Type:** : `object`
**Description:** Data of the first batch after the genesis(Batch 1)

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| --------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------- |
| - [transactions](#firstBatchData_transactions ) | No | string | No | - | - |
| - [globalExitRoot](#firstBatchData_globalExitRoot ) | No | array of integer | No | - | - |
| - [timestamp](#firstBatchData_timestamp ) | No | integer | No | - | - |
| - [sequencer](#firstBatchData_sequencer ) | No | array of integer | No | - | - |
| - [forcedBlockHashL1](#firstBatchData_forcedBlockHashL1 ) | No | array of integer | No | - | - |

### <a name="firstBatchData_transactions"></a>5.1. `firstBatchData.transactions`

**Type:** : `string`

### <a name="firstBatchData_globalExitRoot"></a>5.2. `firstBatchData.globalExitRoot`

**Type:** : `array of integer`

### <a name="firstBatchData_timestamp"></a>5.3. `firstBatchData.timestamp`

**Type:** : `integer`

### <a name="firstBatchData_sequencer"></a>5.4. `firstBatchData.sequencer`

**Type:** : `array of integer`

### <a name="firstBatchData_forcedBlockHashL1"></a>5.5. `firstBatchData.forcedBlockHashL1`

**Type:** : `array of integer`

----------------------------------------------------------------------------------------------------------------------------
Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans)
37 changes: 0 additions & 37 deletions docs/config-file/custom_network-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,43 +87,6 @@
"additionalProperties": false,
"type": "object",
"description": "L1: configuration of the network"
},
"firstBatchData": {
"properties": {
"transactions": {
"type": "string"
},
"globalExitRoot": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 32,
"minItems": 32
},
"timestamp": {
"type": "integer"
},
"sequencer": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 20,
"minItems": 20
},
"forcedBlockHashL1": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 32,
"minItems": 32
}
},
"additionalProperties": false,
"type": "object",
"description": "Data of the first batch after the genesis(Batch 1)"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

44 changes: 5 additions & 39 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2701,12 +2701,11 @@ 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 |
| - [FirstBatchData](#NetworkConfig_Genesis_FirstBatchData ) | No | object | No | - | Data of the first batch after the genesis(Batch 1) |
| 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 |

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

Expand Down Expand Up @@ -2787,39 +2786,6 @@ BlockNumber=0

**Type:** : `string`

#### <a name="NetworkConfig_Genesis_FirstBatchData"></a>13.2.4. `[NetworkConfig.Genesis.FirstBatchData]`

**Type:** : `object`
**Description:** Data of the first batch after the genesis(Batch 1)

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ----------------- |
| - [transactions](#NetworkConfig_Genesis_FirstBatchData_transactions ) | No | string | No | - | - |
| - [globalExitRoot](#NetworkConfig_Genesis_FirstBatchData_globalExitRoot ) | No | array of integer | No | - | - |
| - [timestamp](#NetworkConfig_Genesis_FirstBatchData_timestamp ) | No | integer | No | - | - |
| - [sequencer](#NetworkConfig_Genesis_FirstBatchData_sequencer ) | No | array of integer | No | - | - |
| - [forcedBlockHashL1](#NetworkConfig_Genesis_FirstBatchData_forcedBlockHashL1 ) | No | array of integer | No | - | - |

##### <a name="NetworkConfig_Genesis_FirstBatchData_transactions"></a>13.2.4.1. `NetworkConfig.Genesis.FirstBatchData.transactions`

**Type:** : `string`

##### <a name="NetworkConfig_Genesis_FirstBatchData_globalExitRoot"></a>13.2.4.2. `NetworkConfig.Genesis.FirstBatchData.globalExitRoot`

**Type:** : `array of integer`

##### <a name="NetworkConfig_Genesis_FirstBatchData_timestamp"></a>13.2.4.3. `NetworkConfig.Genesis.FirstBatchData.timestamp`

**Type:** : `integer`

##### <a name="NetworkConfig_Genesis_FirstBatchData_sequencer"></a>13.2.4.4. `NetworkConfig.Genesis.FirstBatchData.sequencer`

**Type:** : `array of integer`

##### <a name="NetworkConfig_Genesis_FirstBatchData_forcedBlockHashL1"></a>13.2.4.5. `NetworkConfig.Genesis.FirstBatchData.forcedBlockHashL1`

**Type:** : `array of integer`

## <a name="L2GasPriceSuggester"></a>14. `[L2GasPriceSuggester]`

**Type:** : `object`
Expand Down
37 changes: 0 additions & 37 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1119,43 +1119,6 @@
},
"type": "array",
"description": "Actions is the data to populate into the state trie"
},
"FirstBatchData": {
"properties": {
"transactions": {
"type": "string"
},
"globalExitRoot": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 32,
"minItems": 32
},
"timestamp": {
"type": "integer"
},
"sequencer": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 20,
"minItems": 20
},
"forcedBlockHashL1": {
"items": {
"type": "integer"
},
"type": "array",
"maxItems": 32,
"minItems": 32
}
},
"additionalProperties": false,
"type": "object",
"description": "Data of the first batch after the genesis(Batch 1)"
}
},
"additionalProperties": false,
Expand Down
Loading

0 comments on commit 4d76030

Please sign in to comment.