Skip to content

Commit

Permalink
Add Fork9UpgradeBatch params (#176)
Browse files Browse the repository at this point in the history
* update

* fix doc

* update

* update

* update

* update

* update
  • Loading branch information
zjg555543 authored Apr 13, 2024
1 parent aaab4fa commit b5923f1
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,15 @@ func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerS

// XLayer handler
setEthermanDaXLayer(cfg, st, eth, false)
eth.SetFork9UpgradeBatch(cfg.Fork9UpgradeBatch)

etherManForL1 = append(etherManForL1, eth)
}
}

// XLayer handler
setEthermanDaXLayer(cfg, st, etherman, false)
etherman.SetFork9UpgradeBatch(cfg.Fork9UpgradeBatch)

etm := ethtxmanager.New(cfg.EthTxManager, etherman, ethTxManagerStorage, st)
sy, err := synchronizer.NewSynchronizer(
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ type Config struct {
State state.Config
// Apollo configuration
Apollo types.ApolloConfig
// ForceBatchAddress Address of the L1 ForceBatch contract
Fork9UpgradeBatch uint64 `mapstructure:"Fork9UpgradeBatch"`
}

// Default parses the default configuration values.
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const DefaultValues = `
IsTrustedSequencer = false
ForkUpgradeBatchNumber = 0
ForkUpgradeNewForkId = 0
Fork9UpgradeBatch = 0
[Log]
Environment = "development" # "production" or "development"
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| - [HashDB](#HashDB ) | No | object | No | - | Configuration of the hash database connection |
| - [State](#State ) | No | object | No | - | State service configuration |
| - [Apollo](#Apollo ) | No | object | No | - | Apollo configuration |
| - [Fork9UpgradeBatch](#Fork9UpgradeBatch ) | No | integer | No | - | ForceBatchAddress Address of the L1 ForceBatch contract |

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

Expand Down Expand Up @@ -5476,5 +5477,18 @@ AppID=""
NamespaceName=""
```

## <a name="Fork9UpgradeBatch"></a>22. `Fork9UpgradeBatch`

**Type:** : `integer`

**Default:** `0`

**Description:** ForceBatchAddress Address of the L1 ForceBatch contract

**Example setting the default value** (0):
```
Fork9UpgradeBatch=0
```

----------------------------------------------------------------------------------------------------------------------------
Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans)
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 @@ -2164,6 +2164,11 @@
"additionalProperties": false,
"type": "object",
"description": "Apollo configuration"
},
"Fork9UpgradeBatch": {
"type": "integer",
"description": "ForceBatchAddress Address of the L1 ForceBatch contract",
"default": 0
}
},
"additionalProperties": false,
Expand Down
51 changes: 51 additions & 0 deletions docs/upgrade_testnet_rpc_fork9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# upgrade testnet rpc fork.9
XLayer Testnet has been upgraded to Fork9. You can upgrade permission less rpc nodes in two ways.

For more detailed information, please refer to:https://www.okx.com/zh-hans/xlayer/docs/developer/setup-zknode/setup-production-zknode
## 1.Re-download the script and snapshot. It will take about 3 hours. (Recommended)
``` bash
apt install axel # Parallel download tools
apt install pigz # Parallel compression tools
wget https://static.okex.org/cdn/chain/xlayer/snapshot/run_xlayer_testnet.sh && chmod +x run_xlayer_testnet.sh && ./run_xlayer_testnet.sh init && cp ./testnet/example.env ./testnet/.env
vim ./testnet/.env # Modify XLAYER_NODE_ETHERMAN_URL = "http://your.L1node.url"
./run_xlayer_testnet.sh restore
./run_xlayer_testnet.sh start
```

## 2.Manual upgrade
### 2.1 Stop the xlayer-sync and xlayer-rpc services.
### 2.2 Modify the configuration file.
Modify the docker-compose.yml file and replace the image version as follows:
```
xlayer-rpc->image: okexchain/xlayer-node:origin_sync-v0.3.6_20240412160714_76857189
xlayer-sync->image: okexchain/xlayer-node:origin_sync-v0.3.6_20240412160714_76857189
xlayer-prover->image: okexchain/xlayer-prover:origin_release_v0.3.1_20240327040854_458b8d26
```

Modify the config/genesis.config.json file and add the fields rollupCreationBlockNumber and rollupManagerCreationBlockNumber as follows:
```
{
...
"genesisBlockNumber": 4648290,
"rollupCreationBlockNumber": 4648290,
"rollupManagerCreationBlockNumber": 4648290,
"root": "0xb2fbff62137228e52809081a425bfcd30c0fdc8c1213085278c739676a7669b8",
...
}
```

Modify the vim config/node.config.toml file and add the Fork9UpgradeBatch field as follows:
```
...
ForkUpgradeBatchNumber=0
ForkUpgradeNewForkId=0
Fork9UpgradeBatch=476000
...
```

### 2.3 Start the xlayer-sync and xlayer-rpc services.

13 changes: 13 additions & 0 deletions etherman/etherman_xlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ type Client struct {
auth map[common.Address]bind.TransactOpts // empty in case of read-only client

da dataavailability.BatchDataProvider

fork9UpgradeBatch uint64
}

// NewClient creates a new etherman.
Expand Down Expand Up @@ -827,6 +829,11 @@ func (etherMan *Client) updateForkId(ctx context.Context, vLog types.Log, blocks
log.Debug("ignoring this event because it is related to another rollup %d, we are rollupID %d", affectedRollupID, etherMan.RollupID)
return nil
}
if forkID == state.FORKID_9 && etherMan.fork9UpgradeBatch != 0 {
batchNum = etherMan.fork9UpgradeBatch
}
log.Infof("updateForkId: %d, %d, %s", batchNum, forkID, version)

fork := ForkID{
BatchNumber: batchNum,
ForkID: forkID,
Expand Down Expand Up @@ -2071,6 +2078,12 @@ func (etherMan *Client) SetDataProvider(da dataavailability.BatchDataProvider) {
etherMan.da = da
}

// SetFork9UpgradeBatch sets the fork9 upgrade batch
func (etherMan *Client) SetFork9UpgradeBatch(fork9UpgradeBatch uint64) {
log.Infof("SetFork9UpgradeBatch:%v", fork9UpgradeBatch)
etherMan.fork9UpgradeBatch = fork9UpgradeBatch
}

// SetDataAvailabilityProtocol sets the address for the new data availability protocol
func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) {
auth, err := etherMan.getAuthByAddress(from)
Expand Down

0 comments on commit b5923f1

Please sign in to comment.