diff --git a/cmd/run.go b/cmd/run.go index 5a874ccf37..f155593269 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -335,6 +335,7 @@ func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerS // XLayer handler setEthermanDaXLayer(cfg, st, eth, false) + eth.SetFork9UpgradeBatch(cfg.Fork9UpgradeBatch) etherManForL1 = append(etherManForL1, eth) } @@ -342,6 +343,7 @@ func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerS // XLayer handler setEthermanDaXLayer(cfg, st, etherman, false) + etherman.SetFork9UpgradeBatch(cfg.Fork9UpgradeBatch) etm := ethtxmanager.New(cfg.EthTxManager, etherman, ethTxManagerStorage, st) sy, err := synchronizer.NewSynchronizer( diff --git a/config/config.go b/config/config.go index 50337a1e05..4e7fb07b20 100644 --- a/config/config.go +++ b/config/config.go @@ -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. diff --git a/config/default.go b/config/default.go index 9d333cff8b..5f9e0f804a 100644 --- a/config/default.go +++ b/config/default.go @@ -5,6 +5,7 @@ const DefaultValues = ` IsTrustedSequencer = false ForkUpgradeBatchNumber = 0 ForkUpgradeNewForkId = 0 +Fork9UpgradeBatch = 0 [Log] Environment = "development" # "production" or "development" diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 323fbfe5b9..8561f49ee2 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -88,4 +88,4 @@
"300ms"
 

Default: 100000000Type: integer

Configuration of the merkle tree client service. Not use in the node, only for testing
Default: "xlayer-prover:50061"Type: string

URI is the server URI.


Configuration of the metrics service, basically is where is going to publish the metrics
Default: "0.0.0.0"Type: string

Host is the address to bind the metrics server


Default: 9091Type: integer

Port is the port to bind the metrics server


Default: falseType: boolean

Enabled is the flag to enable/disable the metrics server


Default: ""Type: string

ProfilingHost is the address to bind the profiling server


Default: 0Type: integer

ProfilingPort is the port to bind the profiling server


Default: falseType: boolean

ProfilingEnabled is the flag to enable/disable the profiling server


Configuration of the event database connection

DB is the database configuration
Default: ""Type: string

Database name


Default: ""Type: string

Database User name


Default: ""Type: string

Database Password of the user


Default: ""Type: string

Host address of database


Default: ""Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 0Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration of the hash database connection
Default: "prover_db"Type: string

Database name


Default: "prover_user"Type: string

Database User name


Default: "prover_pass"Type: string

Database Password of the user


Default: "xlayer-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


State service configuration
Default: 0Type: integer

MaxCumulativeGasUsed is the max gas allowed per batch


Default: 0Type: integer

ChainID is the L2 ChainID provided by the Network Config


Type: array of object

ForkIdIntervals is the list of fork id intervals

Each item of this array must be:


Default: 0Type: integer

MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion


Default: "0s"Type: string

WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion


Examples:

"1m"
 
"300ms"
-

Default: 0Type: integer

Batch number from which there is a forkid change (fork upgrade)


Default: 0Type: integer

New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade)


DB is the database configuration
Default: "state_db"Type: string

Database name


Default: "state_user"Type: string

Database User name


Default: "state_password"Type: string

Database Password of the user


Default: "xlayer-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration for the batch constraints
Default: 300Type: integer

Default: 120000Type: integer

Default: 1125899906842624Type: integer

Default: 2145Type: integer

Default: 252357Type: integer

Default: 135191Type: integer

Default: 236585Type: integer

Default: 236585Type: integer

Default: 473170Type: integer

Default: 7570538Type: integer

Default: 1596Type: integer

Default: 0Type: integer

MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit


Default: 0Type: integer

MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit


Default: 0Type: integer

MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit


Default: falseType: boolean

AvoidForkIDInMemory is a configuration that forces the ForkID information to be loaded
from the DB every time it's needed


Apollo configuration
Default: falseType: boolean

Default: ""Type: string

Default: ""Type: string

Default: ""Type: string

\ No newline at end of file +
Default: 0Type: integer

Batch number from which there is a forkid change (fork upgrade)


Default: 0Type: integer

New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade)


DB is the database configuration
Default: "state_db"Type: string

Database name


Default: "state_user"Type: string

Database User name


Default: "state_password"Type: string

Database Password of the user


Default: "xlayer-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration for the batch constraints
Default: 300Type: integer

Default: 120000Type: integer

Default: 1125899906842624Type: integer

Default: 2145Type: integer

Default: 252357Type: integer

Default: 135191Type: integer

Default: 236585Type: integer

Default: 236585Type: integer

Default: 473170Type: integer

Default: 7570538Type: integer

Default: 1596Type: integer

Default: 0Type: integer

MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit


Default: 0Type: integer

MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit


Default: 0Type: integer

MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit


Default: falseType: boolean

AvoidForkIDInMemory is a configuration that forces the ForkID information to be loaded
from the DB every time it's needed


Apollo configuration
Default: falseType: boolean

Default: ""Type: string

Default: ""Type: string

Default: ""Type: string

Default: 0Type: integer

ForceBatchAddress Address of the L1 ForceBatch contract


\ No newline at end of file diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md index 2065006ec9..e2df90a6f2 100644 --- a/docs/config-file/node-config-doc.md +++ b/docs/config-file/node-config-doc.md @@ -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 | ## 1. `IsTrustedSequencer` @@ -5476,5 +5477,18 @@ AppID="" NamespaceName="" ``` +## 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) diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index eabbf0eb7a..12d15f76de 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -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, diff --git a/docs/upgrade_testnet_rpc_fork9.md b/docs/upgrade_testnet_rpc_fork9.md new file mode 100644 index 0000000000..83fb2085e6 --- /dev/null +++ b/docs/upgrade_testnet_rpc_fork9.md @@ -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. + diff --git a/etherman/etherman_xlayer.go b/etherman/etherman_xlayer.go index 0714f68310..1e35033824 100644 --- a/etherman/etherman_xlayer.go +++ b/etherman/etherman_xlayer.go @@ -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. @@ -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, @@ -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)