Skip to content

Commit

Permalink
make chainid configurable in genesis (#20)
Browse files Browse the repository at this point in the history
* chore: make chainid configurable in genesis

* Surge chain id added to the bindings/encoding

* testnet chain id

* fix: contract owner configurable

* more seed accounts

* chore: use contract owner in more fields

* Don't check typos in pnpm-lock.yaml"

* Don't check typos in "_typos.toml"

* typos go.sum

* protocol tests ubuntu runner

* Revert "protocol tests ubuntu runner"

This reverts commit 54b67f7.

---------

Co-authored-by: Maciej Skrzypkowski <mskr@gmx.com>
  • Loading branch information
AnshuJalan and mskrzypkows authored Nov 26, 2024
1 parent 22b613d commit b5e4666
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 292 deletions.
3 changes: 3 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ extend-exclude = [
"packages/protocol/deployments/**",
# TODO: fix typos and remove these
"packages/taiko-client/**",
"pnpm-lock.yaml",
"_typos.toml",
"go.sum",
]
438 changes: 218 additions & 220 deletions packages/protocol/test/genesis/data/genesis.json

Large diffs are not rendered by default.

120 changes: 60 additions & 60 deletions packages/protocol/test/genesis/data/genesis_alloc.json

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions packages/protocol/test/genesis/data/genesis_config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
"use strict";
const ADDRESS_LENGTH = 40;

const ownerAddress = process.env.CONTRACT_OWNER;

module.exports = {
// Owner address of the pre-deployed L2 contracts.
contractOwner: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39",
l1ChainId: 1,
contractOwner: ownerAddress,
l1ChainId: parseInt(process.env.L1_CHAINID),
// Chain ID of the Taiko L2 network.
chainId: 167,
chainId: parseInt(process.env.L2_CHAINID),
// Account address and pre-mint ETH amount as key-value pairs.
seedAccounts: [
{ "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39": 1000 },
{ "0x79fcdef22feed20eddacbb2587640e45491b757f": 1000 },
],
// Owner Chain ID, Security Council, and Timelock Controller
l1ChainId: 31337,
ownerSecurityCouncil: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39",
ownerTimelockController: "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39",
seedAccounts: [{ [ownerAddress]: 1000 }],
ownerSecurityCouncil: ownerAddress,
ownerTimelockController: ownerAddress,
get contractAddresses() {
return {
// ============ Implementations ============
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/genesis/data/genesis_config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"contractOwner":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","l1ChainId":31337,"chainId":167,"seedAccounts":[{"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39":1000},{"0x79fcdef22feed20eddacbb2587640e45491b757f":1000}],"ownerSecurityCouncil":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","ownerTimelockController":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","contractAddresses":{"BridgeImpl":"0x0167000000000000000000000000000000000001","ERC20VaultImpl":"0x0167000000000000000000000000000000000002","ERC721VaultImpl":"0x0167000000000000000000000000000000000003","ERC1155VaultImpl":"0x0167000000000000000000000000000000000004","SignalServiceImpl":"0x0167000000000000000000000000000000000005","SharedAddressManagerImpl":"0x0167000000000000000000000000000000000006","BridgedERC20Impl":"0x0167000000000000000000000000000000010096","BridgedERC721Impl":"0x0167000000000000000000000000000000010097","BridgedERC1155Impl":"0x0167000000000000000000000000000000010098","RegularERC20":"0x0167000000000000000000000000000000010099","TaikoL2Impl":"0x0167000000000000000000000000000000010001","RollupAddressManagerImpl":"0x0167000000000000000000000000000000010002","Bridge":"0x1670000000000000000000000000000000000001","ERC20Vault":"0x1670000000000000000000000000000000000002","ERC721Vault":"0x1670000000000000000000000000000000000003","ERC1155Vault":"0x1670000000000000000000000000000000000004","SignalService":"0x1670000000000000000000000000000000000005","SharedAddressManager":"0x1670000000000000000000000000000000000006","TaikoL2":"0x1670000000000000000000000000000000010001","RollupAddressManager":"0x1670000000000000000000000000000000010002"},"param1559":{"gasExcess":1},"predeployERC20":true}
{"contractOwner":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","l1ChainId":1,"chainId":164,"seedAccounts":[{"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39":1000},{"0x79fcdef22feed20eddacbb2587640e45491b757f":1000}],"ownerSecurityCouncil":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","ownerTimelockController":"0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39","contractAddresses":{"BridgeImpl":"0x0164000000000000000000000000000000000001","ERC20VaultImpl":"0x0164000000000000000000000000000000000002","ERC721VaultImpl":"0x0164000000000000000000000000000000000003","ERC1155VaultImpl":"0x0164000000000000000000000000000000000004","SignalServiceImpl":"0x0164000000000000000000000000000000000005","SharedAddressManagerImpl":"0x0164000000000000000000000000000000000006","BridgedERC20Impl":"0x0164000000000000000000000000000000010096","BridgedERC721Impl":"0x0164000000000000000000000000000000010097","BridgedERC1155Impl":"0x0164000000000000000000000000000000010098","RegularERC20":"0x0164000000000000000000000000000000010099","TaikoL2Impl":"0x0164000000000000000000000000000000010001","RollupAddressManagerImpl":"0x0164000000000000000000000000000000010002","Bridge":"0x1640000000000000000000000000000000000001","ERC20Vault":"0x1640000000000000000000000000000000000002","ERC721Vault":"0x1640000000000000000000000000000000000003","ERC1155Vault":"0x1640000000000000000000000000000000000004","SignalService":"0x1640000000000000000000000000000000000005","SharedAddressManager":"0x1640000000000000000000000000000000000006","TaikoL2":"0x1640000000000000000000000000000000010001","RollupAddressManager":"0x1640000000000000000000000000000000010002"},"param1559":{"gasExcess":1},"predeployERC20":true}
34 changes: 34 additions & 0 deletions packages/protocol/test/genesis/generate/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,44 @@ async function main() {
);
fs.writeFileSync(configJsonSavedPath, JSON.stringify(config));

const fullGenesis = {
config: {
chainId: config.chainId,
homesteadBlock: 0,
eip150Block: 0,
eip150Hash:
"0x0000000000000000000000000000000000000000000000000000000000000000",
eip155Block: 0,
eip158Block: 0,
byzantiumBlock: 0,
constantinopleBlock: 0,
petersburgBlock: 0,
istanbulBlock: 0,
muirGlacierBlock: 0,
berlinBlock: 0,
clique: {
period: 0,
epoch: 30000,
},
},
gasLimit: "30000000",
difficulty: "1",
extraData:
"0x0000000000000000000000000000000000000000000000000000000000000000df08f82de32b8d460adbe8d72043e3a7e25a3b390000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
alloc: result.alloc,
};

const genesisJsonSavedPath = path.join(__dirname, "../data/genesis.json");
fs.writeFileSync(
genesisJsonSavedPath,
JSON.stringify(fullGenesis, null, 2),
);

console.log("done");
console.log(`alloc JSON saved to ${allocSavedPath}`);
console.log(`layout JSON saved to ${layoutSavedPath}`);
console.log(`config JSON saved to ${configJsonSavedPath}`);
console.log(`full genesis JSON saved to ${genesisJsonSavedPath}`);
}

main().catch(console.error);
43 changes: 43 additions & 0 deletions packages/taiko-client/bindings/encoding/protocol_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
)

const (
SurgeNetworkID = 763373 // 0xba5ed
SurgeTestNetworkID = 763374 // 0xba5ee
)

var (
livenessBond, _ = new(big.Int).SetString("125000000000000000000", 10)
InternlDevnetProtocolConfig = &bindings.TaikoDataConfig{
Expand Down Expand Up @@ -63,6 +68,40 @@ var (
MaxGasIssuancePerBlock: 600_000_000,
},
}
SurgeProtocolConfig = &bindings.TaikoDataConfig{
ChainId: SurgeNetworkID,
BlockMaxProposals: 324_000,
BlockRingBufferSize: 360_000,
MaxBlocksToVerify: 16,
BlockMaxGasLimit: 240_000_000,
LivenessBond: livenessBond,
StateRootSyncInternal: 16,
MaxAnchorHeightOffset: 64,
OntakeForkHeight: 1,
BaseFeeConfig: bindings.LibSharedDataBaseFeeConfig{
AdjustmentQuotient: 8,
GasIssuancePerSecond: 5_000_000,
MinGasExcess: 1_340_000_000,
MaxGasIssuancePerBlock: 600_000_000,
},
}
SurgeTestnetProtocolConfig = &bindings.TaikoDataConfig{
ChainId: SurgeTestNetworkID,
BlockMaxProposals: 324_000,
BlockRingBufferSize: 360_000,
MaxBlocksToVerify: 16,
BlockMaxGasLimit: 240_000_000,
LivenessBond: livenessBond,
StateRootSyncInternal: 16,
MaxAnchorHeightOffset: 64,
OntakeForkHeight: 1,
BaseFeeConfig: bindings.LibSharedDataBaseFeeConfig{
AdjustmentQuotient: 8,
GasIssuancePerSecond: 5_000_000,
MinGasExcess: 1_340_000_000,
MaxGasIssuancePerBlock: 600_000_000,
},
}
)

// GetProtocolConfig returns the protocol config for the given chain ID.
Expand All @@ -72,6 +111,10 @@ func GetProtocolConfig(chainID uint64) *bindings.TaikoDataConfig {
return HeklaProtocolConfig
case params.TaikoMainnetNetworkID.Uint64():
return MainnetProtocolConfig
case SurgeNetworkID:
return SurgeProtocolConfig
case SurgeTestNetworkID:
return SurgeTestnetProtocolConfig
default:
return InternlDevnetProtocolConfig
}
Expand Down
3 changes: 3 additions & 0 deletions packages/taiko-client/pkg/config/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -37,6 +38,8 @@ var NetworkNames = map[uint64]string{
params.TaikoMainnetNetworkID.Uint64(): "Taiko Mainnet",
params.HeklaNetworkID.Uint64(): "Taiko Hekla Testnet",
params.TaikoInternalL2ANetworkID.Uint64(): "Taiko Internal Devnet",
encoding.SurgeNetworkID: "Surge Mainnet",
encoding.SurgeTestNetworkID: "Surge Testnet",
}

// Description returns a human-readable description of ChainConfig.
Expand Down

0 comments on commit b5e4666

Please sign in to comment.