Skip to content

Commit

Permalink
feat: intro preview chain
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad committed Sep 14, 2024
1 parent 247e1fd commit b0bde9f
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 23 deletions.
42 changes: 42 additions & 0 deletions docs/hashes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,48 @@ included_cells = ["Bundled(specs/cells/secp256k1_data)", "Bundled(specs/cells/se
tx_hash = "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37"
index = 1

[ckb_preview]
spec_hash = "0xce18c4b1c6da3f10ab46bc5dc53aaebe55f03d9643512734d105d7fc86201518"
genesis = "0x9ed819e4bac690c22e97111baf7fbc873811fa053bfa8764db22e138be3f3728"
cellbase = "0xe93c55bea88e10c64d9b218ee2b504bc89b9e5ee912186ff904c1827360a5362"

[[ckb_preview.system_cells]]
path = "Bundled(specs/cells/secp256k1_blake160_sighash_all)"
tx_hash = "0xe93c55bea88e10c64d9b218ee2b504bc89b9e5ee912186ff904c1827360a5362"
index = 1
data_hash = "0x709f3fda12f561cfacf92273c57a98fede188a3f1a59b1f888d113f9cce08649"
type_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"

[[ckb_preview.system_cells]]
path = "Bundled(specs/cells/dao)"
tx_hash = "0xe93c55bea88e10c64d9b218ee2b504bc89b9e5ee912186ff904c1827360a5362"
index = 2
data_hash = "0x32064a14ce10d95d4b7343054cc19d73b25b16ae61a6c681011ca781a60c7923"
type_hash = "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e"

[[ckb_preview.system_cells]]
path = "Bundled(specs/cells/secp256k1_data)"
tx_hash = "0xe93c55bea88e10c64d9b218ee2b504bc89b9e5ee912186ff904c1827360a5362"
index = 3
data_hash = "0x9799bee251b975b82c45a02154ce28cec89c5853ecc14d12b7b8cccfc19e0af4"

[[ckb_preview.system_cells]]
path = "Bundled(specs/cells/secp256k1_blake160_multisig_all)"
tx_hash = "0xe93c55bea88e10c64d9b218ee2b504bc89b9e5ee912186ff904c1827360a5362"
index = 4
data_hash = "0x43400de165f0821abf63dcac299bbdf7fd73898675ee4ddb099b0a0d8db63bfb"
type_hash = "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8"

[[ckb_preview.dep_groups]]
included_cells = ["Bundled(specs/cells/secp256k1_data)", "Bundled(specs/cells/secp256k1_blake160_sighash_all)"]
tx_hash = "0x0fab65924f2784f17ad7f86d6aef4b04ca1ca237102a68961594acebc5c77816"
index = 0

[[ckb_preview.dep_groups]]
included_cells = ["Bundled(specs/cells/secp256k1_data)", "Bundled(specs/cells/secp256k1_blake160_multisig_all)"]
tx_hash = "0x0fab65924f2784f17ad7f86d6aef4b04ca1ca237102a68961594acebc5c77816"
index = 1

[ckb_staging]
spec_hash = "0x7a0ed50e9723e6c41a5c8450225e9f0a639070bb81b87e395fd5f91eef6ce373"
genesis = "0xbc081e6b2e31149c1dc39007f161ed0a0b63d5d30b3b771acc6a3b622133fcc0"
Expand Down
3 changes: 3 additions & 0 deletions resource/ckb-miner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# see => resource/src/template.rs
# mainnet => # Config generated by `ckb init --chain mainnet`
# testnet => # Config generated by `ckb init --chain testnet`
# preview => # Config generated by `ckb init --chain preview`
# staging => # Config generated by `ckb init --chain staging`
# }}

Expand All @@ -16,6 +17,7 @@ spec = { file = "specs/dev.toml" } # {{
# testnet => spec = { {spec_source} = "specs/testnet.toml" }
# mainnet => spec = { {spec_source} = "specs/mainnet.toml" }
# staging => spec = { {spec_source} = "specs/staging.toml" }
# preview => spec = { {spec_source} = "specs/preview.toml" }
# integration => spec = { file = "specs/integration.toml" }
# }}

Expand All @@ -33,6 +35,7 @@ log_to_stdout = true # {{
# set to blank to disable sentry error collection
dsn = "" # {{
# testnet => dsn = "https://[email protected]/4"
# preview => dsn = "https://[email protected]/4"
# staging => dsn = "https://[email protected]/4"
# }}
# if you are willing to help us to improve,
Expand Down
5 changes: 5 additions & 0 deletions resource/ckb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
# mainnet => # Config generated by `ckb init --chain mainnet`
# testnet => # Config generated by `ckb init --chain testnet`
# staging => # Config generated by `ckb init --chain staging`
# preview => # Config generated by `ckb init --chain preview`
# }}

data_dir = "data"

[chain]
# Choose the kind of chains to run, possible values:
# - { file = "specs/dev.toml" }
# - { bundled = "specs/preview.toml" }
# - { bundled = "specs/testnet.toml" }
# - { bundled = "specs/mainnet.toml" }
spec = { file = "specs/dev.toml" } # {{
# preview => spec = { {spec_source} = "specs/preview.toml" }
# testnet => spec = { {spec_source} = "specs/testnet.toml" }
# mainnet => spec = { {spec_source} = "specs/mainnet.toml" }
# staging => spec = { {spec_source} = "specs/staging.toml" }
Expand All @@ -34,6 +37,7 @@ log_to_stdout = true # {{
[sentry]
# set to blank to disable sentry error collection
dsn = "" # {{
# preview => dsn = "https://[email protected]/4"
# testnet => dsn = "https://[email protected]/4"
# staging => dsn = "https://[email protected]/4"
# mainnet => dsn = ""
Expand Down Expand Up @@ -70,6 +74,7 @@ listen_addresses = ["/ip4/0.0.0.0/tcp/8115"] # {{
bootnodes = [] # {{
# mainnet => bootnodes = [\n # Hongkong, Asia\n "/ip4/16.163.82.218/tcp/8114/p2p/QmaZMemLXSsxKUrYNucjEbPxVX3rBKsGhWW2muWtWxUWyh",\n # Tokyo, Asia\n "/ip4/35.79.196.111/tcp/8114/p2p/QmYCRVonLfP18LSoz2WCHaXDorUYxuUMfhtcXK1TuZ1iwF",\n # Mumbai, Asia\n "/ip4/13.234.144.148/tcp/8114/p2p/QmbT7QimcrcD5k2znoJiWpxoESxang6z1Gy9wof1rT1LKR",\n # Seoul, Asia\n "/ip4/34.64.120.143/tcp/8114/p2p/QmejEJEbDcGGMp4D6WtftMMVLkR1ZuBfMgyLFDMJymkDt6",\n # Virginia, North America\n "/ip4/3.218.170.86/tcp/8114/p2p/QmShw2vtVt49wJagc1zGQXGS6LkQTcHxnEV3xs6y8MAmQN",\n # Los Angeles, North America\n "/ip4/35.236.107.161/tcp/8114/p2p/QmSRj57aa9sR2AiTvMyrEea8n1sEM1cDTrfb2VHVJxnGuu",\n # Texas, North America\n "/ip4/23.101.191.12/tcp/8114/p2p/QmexvXVDiRt2FBGptgK4gBJusWyyTEEaHeuCAa35EPNkZS",\n # Toronto, North America\n "/ip4/20.151.143.237/tcp/8114/p2p/QmNsGNQjYA6iP472bNnNE2GR31kCYBifhY1XcaUxRjZ1py",\n # Frankfurt, Europe\n "/ip4/52.59.155.249/tcp/8114/p2p/QmRHqhSGMGm5FtnkW8D6T83X7YwaiMAZXCXJJaKzQEo3rb",\n # London, Europe\n "/ip4/3.10.216.39/tcp/8114/p2p/QmagxSv7GNwKXQE7mi1iDjFHghjUpbqjBgqSot7PmMJqHA",\n # Paris, Europe\n "/ip4/13.37.172.80/tcp/8114/p2p/QmXJg4iKbQzMpLhX75RyDn89Mv7N2H8vLePBR7kgZf6hYk",\n # Warsaw, Europe\n "/ip4/34.118.49.255/tcp/8114/p2p/QmeCzzVmSAU5LNYAeXhdJj8TCq335aJMqUxcvZXERBWdgS",\n # Victoria, Oceania\n "/ip4/40.115.75.216/tcp/8114/p2p/QmW3P1WYtuz9hitqctKnRZua2deHXhNePNjvtc9Qjnwp4q",\n # Santiago, South America\n "/ip4/34.176.239.95/tcp/8114/p2p/QmQoWrmuFauCn3zZ2mYYKAciG9opTbjzC2wVEfWveZNDt8",\n # Capetown, Africa\n "/ip4/13.245.217.98/tcp/8114/p2p/Qmf4t1SzFhRWuGcFcgs7r4pXvkACsz3FcaBMcmMKQMMpn7"\n]
# testnet => bootnodes = [\n # Ohio, North America\n "/ip4/18.217.146.65/tcp/8111/p2p/QmT6DFfm18wtbJz3y4aPNn3ac86N4d4p4xtfQRRPf73frC",\n # Singapore, Asia\n "/ip4/18.136.60.221/tcp/8111/p2p/QmTt6HeNakL8Fpmevrhdna7J4NzEMf9pLchf1CXtmtSrwb",\n # London, Europe\n "/ip4/35.176.207.239/tcp/8111/p2p/QmSJTsMsMGBjzv1oBNwQU36VhQRxc2WQpFoRu1ZifYKrjZ",\n # Singapore, Asia\n "/ip4/13.228.149.113/tcp/8111/p2p/QmQoTR39rBkpZVgLApDGDoFnJ2YDBS9hYeiib1Z6aoAdEf",\n # Bahrain, Asia\n "/ip4/157.241.73.87/tcp/8111/p2p/QmSPkAyXqsWpRiS7HpHLTProVdhQWLKFHCXbRjaLpJj7ZL",\n # Japan, Asia\n "/ip4/4.241.132.26/tcp/8111/p2p/QmX5D6aJiAQ5Fxn4BfVqSn6zrgyuQM1oXVC9yvmzLuHXnx",\n # Korea, Asia\n "/ip4/52.147.120.180/tcp/8111/p2p/QmPcJY2gZLUm66szYA9QaG1P3rzwseWCMgbj6AyNCyW4G2",\n # Hong Kong, Asia\n "/ip4/18.167.196.121/tcp/8111/p2p/QmQMjFrNGaphzfHin3mbYybbJcFMDUihKAcknquYvm9J3W",\n # Oregon, North America\n "/ip4/34.216.103.183/tcp/8111/p2p/Qmd41MaByDprkC5gP1XBKgamZ9DTLNk37zbPgwtiWCzRV6",\n # Canada, North America\n "/ip4/3.98.152.180/tcp/8111/p2p/QmWVuW5KquiWDSqgMJRFW1xRtVqkYJrWz6S9NNk6fFn3wh",\n # Frankfurt, Europe\n "/ip4/18.192.147.65/tcp/8111/p2p/QmWcEhsMNRcfJit62EbKgzpgtAJZX1G3Ur4shXjcvLsYDb",\n # Sydney, Oceania\n "/ip4/13.236.13.195/tcp/8111/p2p/QmfUTZxsse7rFJTJfoUv8bbStoDLETxst5nJEpJozNuAnH"\n]
# preview => bootnodes = [\n "/ip4/43.198.48.141/tcp/8118/p2p/QmQDJWySDgJC8eKmdZBMJuYiin5cJUhbYeBjNWvrXRYYUK",\n "/ip4/13.39.144.196/tcp/8118/p2p/QmZQbkHeN2NP9mze3QZMRBAoFePZ7UHCkaJX3uJzxze48V",\n "/ip4/13.213.203.124/tcp/8118/p2p/QmNiVYpv19KgeP6duwqzJHM6754vc82t4Kq6TUGxKbRb4a",\n "/ip4/18.214.154.228/tcp/8118/p2p/QmaiSHpGDiBVbs6hfM3tuF77GaX14mVhGueRH48ibCyQpL" \n]
# staging => bootnodes = []
# }}

Expand Down
93 changes: 93 additions & 0 deletions resource/specs/preview.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name = "ckb_preview"

[genesis]
version = 0
parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
timestamp = 1589276230000
compact_target = 0x1e015555
uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
nonce = "0x0"
# run `cargo run list-hashes -b` to get the genesis hash
hash = "0x9ed819e4bac690c22e97111baf7fbc873811fa053bfa8764db22e138be3f3728"

[genesis.genesis_cell]
message = "ckb_preview"

[genesis.genesis_cell.lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "data"

# An array list paths to system cell files, which is absolute or relative to
# the directory containing this config file.
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_blake160_sighash_all" }
create_type_id = true
capacity = 100_000_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/dao" }
create_type_id = true
capacity = 16_000_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_data" }
create_type_id = false
capacity = 1_048_617_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_blake160_multisig_all" }
create_type_id = true
capacity = 100_000_0000_0000

[genesis.system_cells_lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "data"

# Dep group cells
[[genesis.dep_groups]]
name = "secp256k1_blake160_sighash_all"
files = [
{ bundled = "specs/cells/secp256k1_data" },
{ bundled = "specs/cells/secp256k1_blake160_sighash_all" },
]
[[genesis.dep_groups]]
name = "secp256k1_blake160_multisig_all"
files = [
{ bundled = "specs/cells/secp256k1_data" },
{ bundled = "specs/cells/secp256k1_blake160_multisig_all" },
]

# For first 11 block
[genesis.bootstrap_lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "type"

# Burn
[[genesis.issued_cells]]
capacity = 8_400_000_000_00000000
lock.code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
lock.args = "0x62e907b15cbf27d5425399ebf6f0fb50ebb88f18"
lock.hash_type = "data"

# Locks for developers to run tests
[[genesis.issued_cells]]
capacity = 8_399_578_345_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x64257f00b6b63e987609fa9be2d0c86d351020fb"
lock.hash_type = "type"
[[genesis.issued_cells]]
capacity = 8_399_578_345_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x3f1573b44218d4c12a91919a58a863be415a2bc3"
lock.hash_type = "type"
[[genesis.issued_cells]]
capacity = 8_399_578_347_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x57ccb07be6875f61d93636b0ee11b675494627d2"
lock.hash_type = "type"

[params.hardfork]
ckb2023 = 0

[pow]
func = "Eaglesong"
2 changes: 1 addition & 1 deletion resource/src/template.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Default chain spec.
pub const DEFAULT_SPEC: &str = "mainnet";
/// The list of bundled chain specs.
pub const AVAILABLE_SPECS: &[&str] = &["mainnet", "testnet", "staging", "dev"];
pub const AVAILABLE_SPECS: &[&str] = &["mainnet", "testnet", "preview", "staging", "dev"];
/// The default RPC listen port *8114*.
pub const DEFAULT_RPC_PORT: &str = "8114";
/// The default P2P listen port *8115*.
Expand Down
10 changes: 8 additions & 2 deletions verification/src/block_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
use ckb_chain_spec::consensus::Consensus;
use ckb_error::Error;
use ckb_types::{
core::BlockView,
core::{BlockView, ScriptHashType},
packed::{CellInput, CellbaseWitness},
prelude::*,
};
Expand Down Expand Up @@ -105,7 +105,13 @@ impl CellbaseVerifier {
if cellbase_transaction
.witnesses()
.get(0)
.and_then(|witness| CellbaseWitness::from_slice(&witness.raw_data()).ok())
.and_then(|witness| {
CellbaseWitness::from_slice(&witness.raw_data())
.ok()
.and_then(|cellbase_witness| {
ScriptHashType::try_from(cellbase_witness.lock().hash_type()).ok()
})
})
.is_none()
{
return Err((CellbaseError::InvalidWitness).into());
Expand Down
Loading

0 comments on commit b0bde9f

Please sign in to comment.