Skip to content

Commit

Permalink
update executor proto (0xPolygonHermez#2872)
Browse files Browse the repository at this point in the history
* update executor proto

* update doc
  • Loading branch information
ToniRamirezM authored Nov 30, 2023
1 parent 63dc930 commit 0a82217
Show file tree
Hide file tree
Showing 27 changed files with 1,467 additions and 832 deletions.
4 changes: 2 additions & 2 deletions cmd/dumpstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type dumpedState struct {
type genesis state.Genesis

func (g genesis) MarshalJSON() ([]byte, error) {
for _, action := range g.GenesisActions {
for _, action := range g.Actions {
if !strings.HasPrefix(action.Value, "0x") {
action.Value = fmt.Sprintf("0x%s", action.Value)
}
Expand All @@ -66,7 +66,7 @@ func (g genesis) MarshalJSON() ([]byte, error) {
Actions []*state.GenesisAction
}{
Alias: (Alias)(g),
Actions: g.GenesisActions,
Actions: g.Actions,
})
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func start(cliCtx *cli.Context) error {
}

st := newState(cliCtx.Context, c, l2ChainID, []state.ForkIDInterval{}, stateSqlDB, eventLog, needsExecutor, needsStateTree)
forkIDIntervals, err := forkIDIntervals(cliCtx.Context, st, etherman, c.NetworkConfig.Genesis.GenesisBlockNum)
forkIDIntervals, err := forkIDIntervals(cliCtx.Context, st, etherman, c.NetworkConfig.Genesis.BlockNumber)
if err != nil {
log.Fatal("error getting forkIDs. Error: ", err)
}
Expand Down
16 changes: 8 additions & 8 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func LoadGenesisFromJSONString(jsonStr string) (NetworkConfig, error) {

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

for _, account := range cfgJSON.Genesis {
Expand All @@ -134,23 +134,23 @@ func LoadGenesisFromJSONString(jsonStr string) (NetworkConfig, error) {
Type: int(merkletree.LeafTypeBalance),
Value: account.Balance,
}
cfg.Genesis.GenesisActions = append(cfg.Genesis.GenesisActions, action)
cfg.Genesis.Actions = append(cfg.Genesis.Actions, action)
}
if account.Nonce != "" && account.Nonce != "0" {
action := &state.GenesisAction{
Address: account.Address,
Type: int(merkletree.LeafTypeNonce),
Value: account.Nonce,
}
cfg.Genesis.GenesisActions = append(cfg.Genesis.GenesisActions, action)
cfg.Genesis.Actions = append(cfg.Genesis.Actions, action)
}
if account.Bytecode != "" {
action := &state.GenesisAction{
Address: account.Address,
Type: int(merkletree.LeafTypeCode),
Bytecode: account.Bytecode,
}
cfg.Genesis.GenesisActions = append(cfg.Genesis.GenesisActions, action)
cfg.Genesis.Actions = append(cfg.Genesis.Actions, action)
}
if len(account.Storage) > 0 {
for storageKey, storageValue := range account.Storage {
Expand All @@ -160,7 +160,7 @@ func LoadGenesisFromJSONString(jsonStr string) (NetworkConfig, error) {
StoragePosition: storageKey,
Value: storageValue,
}
cfg.Genesis.GenesisActions = append(cfg.Genesis.GenesisActions, action)
cfg.Genesis.Actions = append(cfg.Genesis.Actions, action)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
Timestamp: 1697640780,
Sequencer: common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),
},
Root: common.HexToHash("0xBEEF"),
GenesisBlockNum: 69,
GenesisActions: []*state.GenesisAction{
Root: common.HexToHash("0xBEEF"),
BlockNumber: 69,
Actions: []*state.GenesisAction{
{
Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4",
Type: int(merkletree.LeafTypeNonce),
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestLoadCustomNetworkConfig(t *testing.T) {
}`,
expectedConfig: NetworkConfig{
Genesis: state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Type: int(merkletree.LeafTypeBalance),
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

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

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------ | ------- | ---------------- | ---------- | ---------- | --------------------------------------------------------------------------------- |
| - [GenesisBlockNum](#NetworkConfig_Genesis_GenesisBlockNum ) | No | integer | No | - | GenesisBlockNum 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 |
| - [GenesisActions](#NetworkConfig_Genesis_GenesisActions ) | No | array of object | No | - | Contracts to be deployed to L2 |
| - [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 |
| - [FirstBatchData](#NetworkConfig_Genesis_FirstBatchData ) | No | object | No | - | Data of the first batch after the genesis(Batch 1) |

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

**Type:** : `integer`

**Default:** `0`

**Description:** GenesisBlockNum is the block number where the polygonZKEVM smc was deployed on L1
**Description:** BlockNumber is the block number where the polygonZKEVM smc was deployed on L1

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

#### <a name="NetworkConfig_Genesis_Root"></a>13.2.2. `NetworkConfig.Genesis.Root`

**Type:** : `array of integer`
**Description:** Root hash of the genesis block

#### <a name="NetworkConfig_Genesis_GenesisActions"></a>13.2.3. `NetworkConfig.Genesis.GenesisActions`
#### <a name="NetworkConfig_Genesis_Actions"></a>13.2.3. `NetworkConfig.Genesis.Actions`

**Type:** : `array of object`
**Description:** Contracts to be deployed to L2
**Description:** Actions is the data to populate into the state trie

| | Array restrictions |
| -------------------- | ------------------ |
Expand All @@ -2671,50 +2671,50 @@ GenesisBlockNum=0
| **Additional items** | False |
| **Tuple validation** | See below |

| Each item of this array must be | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [GenesisActions items](#NetworkConfig_Genesis_GenesisActions_items) | GenesisAction represents one of the values set on the SMT during genesis. |
| Each item of this array must be | Description |
| ----------------------------------------------------- | ------------------------------------------------------------------------- |
| [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.GenesisActions.GenesisActions items]
##### <a name="autogenerated_heading_3"></a>13.2.3.1. [NetworkConfig.Genesis.Actions.Actions items]

**Type:** : `object`
**Description:** GenesisAction represents one of the values set on the SMT during genesis.

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| --------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- |
| - [address](#NetworkConfig_Genesis_GenesisActions_items_address ) | No | string | No | - | - |
| - [type](#NetworkConfig_Genesis_GenesisActions_items_type ) | No | integer | No | - | - |
| - [storagePosition](#NetworkConfig_Genesis_GenesisActions_items_storagePosition ) | No | string | No | - | - |
| - [bytecode](#NetworkConfig_Genesis_GenesisActions_items_bytecode ) | No | string | No | - | - |
| - [key](#NetworkConfig_Genesis_GenesisActions_items_key ) | No | string | No | - | - |
| - [value](#NetworkConfig_Genesis_GenesisActions_items_value ) | No | string | No | - | - |
| - [root](#NetworkConfig_Genesis_GenesisActions_items_root ) | No | string | No | - | - |
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| -------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- |
| - [address](#NetworkConfig_Genesis_Actions_items_address ) | No | string | No | - | - |
| - [type](#NetworkConfig_Genesis_Actions_items_type ) | No | integer | No | - | - |
| - [storagePosition](#NetworkConfig_Genesis_Actions_items_storagePosition ) | No | string | No | - | - |
| - [bytecode](#NetworkConfig_Genesis_Actions_items_bytecode ) | No | string | No | - | - |
| - [key](#NetworkConfig_Genesis_Actions_items_key ) | No | string | No | - | - |
| - [value](#NetworkConfig_Genesis_Actions_items_value ) | No | string | No | - | - |
| - [root](#NetworkConfig_Genesis_Actions_items_root ) | No | string | No | - | - |

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

**Type:** : `string`

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

**Type:** : `integer`

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

**Type:** : `string`

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

**Type:** : `string`

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

**Type:** : `string`

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

**Type:** : `string`

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

**Type:** : `string`

Expand Down
8 changes: 4 additions & 4 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,9 @@
},
"Genesis": {
"properties": {
"GenesisBlockNum": {
"BlockNumber": {
"type": "integer",
"description": "GenesisBlockNum is the block number where the polygonZKEVM smc was deployed on L1",
"description": "BlockNumber is the block number where the polygonZKEVM smc was deployed on L1",
"default": 0
},
"Root": {
Expand All @@ -1063,7 +1063,7 @@
"minItems": 32,
"description": "Root hash of the genesis block"
},
"GenesisActions": {
"Actions": {
"items": {
"properties": {
"address": {
Expand Down Expand Up @@ -1093,7 +1093,7 @@
"description": "GenesisAction represents one of the values set on the SMT during genesis."
},
"type": "array",
"description": "Contracts to be deployed to L2"
"description": "Actions is the data to populate into the state trie"
},
"FirstBatchData": {
"properties": {
Expand Down
18 changes: 9 additions & 9 deletions pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
stateDBCfg = dbutils.NewStateConfigFromEnv()
poolDBCfg = dbutils.NewPoolConfigFromEnv()
genesis = state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -290,7 +290,7 @@ func Test_AddTx_OversizedData(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -353,7 +353,7 @@ func Test_AddPreEIP155Tx(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -1012,7 +1012,7 @@ func Test_TryAddIncompatibleTxs(t *testing.T) {
initialBalance, _ := big.NewInt(0).SetString(encoding.MaxUint256StrNumber, encoding.Base10)
initialBalance = initialBalance.Add(initialBalance, initialBalance)
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: operations.DefaultSequencerAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -1334,7 +1334,7 @@ func Test_AddTx_GasPriceErr(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -1475,7 +1475,7 @@ func Test_BlockedAddress(t *testing.T) {
}

genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: auth.From.String(),
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -1691,7 +1691,7 @@ func Test_AddTx_AccountQueueLimit(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down Expand Up @@ -1800,7 +1800,7 @@ func Test_AddTx_GlobalQueueLimit(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: genesisActions,
Actions: genesisActions,
FirstBatchData: genesis.FirstBatchData,
}
ctx := context.Background()
Expand Down Expand Up @@ -1882,7 +1882,7 @@ func Test_AddTx_NonceTooHigh(t *testing.T) {
ReceivedAt: time.Now(),
}
genesis := state.Genesis{
GenesisActions: []*state.GenesisAction{
Actions: []*state.GenesisAction{
{
Address: senderAddress,
Type: int(merkletree.LeafTypeBalance),
Expand Down
20 changes: 12 additions & 8 deletions proto/src/proto/executor/v1/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,20 @@ message ProcessBatchRequestV2 {
uint32 skip_verify_l1_info_root = 14;
// flag to skip the restriction to start a batch with a changeL2Block transaction
uint32 skip_first_change_l2_block = 15;
// flag to skip writing the block info root in the state
uint32 skip_write_block_info_root = 16;
// lInfoTree information
map<uint32, L1DataV2> l1_info_tree_data = 16;
map<uint32, L1DataV2> l1_info_tree_data = 17;
// For testing purposes only
map<string, string> db = 17;
map<string, string> contracts_bytecode = 18; // For debug/testing purpposes only. Don't fill this on production
TraceConfigV2 trace_config = 19;
string context_id = 20;
uint32 get_keys = 21; // if 1, the keys used to read or write storage values will be returned
map<string, string> db = 18;
map<string, string> contracts_bytecode = 19; // For debug/testing purpposes only. Don't fill this on production
TraceConfigV2 trace_config = 20;
string context_id = 21;
uint32 get_keys = 22; // if 1, the keys used to read or write storage values will be returned
// The state override set is an optional address-to-state mapping,
// where each entry specifies some state to be ephemerally overridden
// prior to executing the call.
map<string, OverrideAccountV2> state_override = 22;
map<string, OverrideAccountV2> state_override = 23;
}

message L1DataV2 {
Expand Down Expand Up @@ -817,4 +819,6 @@ enum ExecutorError {
EXECUTOR_ERROR_INVALID_L1_SMT_PROOF = 101;
// EXECUTOR_ERROR_INVALID_BALANCE indicates that the input parameter balance value is invalid
EXECUTOR_ERROR_INVALID_BALANCE = 102;
}
// EXECUTOR_ERROR_SM_MAIN_BINARY_LT4_MISMATCH indicates that the binary instruction less than four opcode failed
EXECUTOR_ERROR_SM_MAIN_BINARY_LT4_MISMATCH = 103;
}
4 changes: 4 additions & 0 deletions state/batchV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (s *State) ProcessBatchV2(ctx context.Context, request ProcessRequest, upda
processBatchRequest.SkipFirstChangeL2Block = cTrue
}

if request.SkipWriteBlockInfoRoot {
processBatchRequest.SkipWriteBlockInfoRoot = cTrue
}

res, err := s.sendBatchRequestToExecutorV2(ctx, processBatchRequest, request.Caller)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 0a82217

Please sign in to comment.