diff --git a/download.py b/download.py index 5640fc0c..cb453a5e 100644 --- a/download.py +++ b/download.py @@ -25,6 +25,7 @@ "0.119.0", "0.120.0", "0.121.0", + "0.200.0", ] # Replace with your versions DOWNLOAD_DIR = "download" diff --git a/framework/helper/contract.py b/framework/helper/contract.py index fed0df63..5989f1c7 100644 --- a/framework/helper/contract.py +++ b/framework/helper/contract.py @@ -50,8 +50,13 @@ def deploy_ckb_contract( with open(tmp_deploy_toml_path, "w") as f: f.write(deploy_toml_str) account = util_key_info_by_private_key(private_key) + net = ( + "testnet" + if RPCClient(api_url).get_consensus()["id"] != "ckb" + else "mainnet" + ) deploy_gen_txs( - account["address"]["testnet"], + account["address"][net], tmp_deploy_toml_path, tmp_tx_info_path, api_url, @@ -61,7 +66,8 @@ def deploy_ckb_contract( return deploy_tx_result["cell_tx"] # rand ckb address ,provider contract cell cant be used - to_ckb_address = "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqwgx292hnvmn68xf779vmzrshpmm6epn4g6eqkaw" + pre_address = "ckb" if RPCClient(api_url).get_consensus()["id"] == "ckb" else "ckt" + to_ckb_address = f"{pre_address}1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqwgx292hnvmn68xf779vmzrshpmm6epn4g6eqkaw" with open(contract_path, "rb") as f: # +100 provider capacity enough deploy contract capacity = len(f.read()) + 100 @@ -149,7 +155,8 @@ def invoke_ckb_contract( ) # get input_cell account = util_key_info_by_private_key(account_private) - account_address = account["address"]["testnet"] + net = "testnet" if RPCClient(api_url).get_consensus()["id"] != "ckb" else "mainnet" + account_address = account["address"][net] account_live_cells = wallet_get_live_cells(account_address, api_url=api_url) assert len(account_live_cells["live_cells"]) > 0 input_cell_out_points = [] diff --git a/framework/test_node.py b/framework/test_node.py index 14eea340..2c3327b8 100644 --- a/framework/test_node.py +++ b/framework/test_node.py @@ -15,36 +15,43 @@ class CkbNodeConfigPath(Enum): CURRENT_TEST = ( - "source/template/ckb/v120/ckb.toml.j2", - "source/template/ckb/v120/ckb-miner.toml.j2", - "source/template/ckb/v120/specs/dev.toml", - "download/0.121.0", + "source/template/ckb/v200/ckb.toml.j2", + "source/template/ckb/v200/ckb-miner.toml.j2", + "source/template/ckb/v200/specs/dev.toml", + "download/0.200.0", ) TESTNET = ( - "source/template/ckb/v120/ckb.toml.j2", - "source/template/ckb/v120/ckb-miner.toml.j2", + "source/template/ckb/v200/ckb.toml.j2", + "source/template/ckb/v200/ckb-miner.toml.j2", "source/template/specs/testnet.toml.j2", - "download/0.121.0", + "download/0.200.0", ) CURRENT_MAIN = ( - "source/template/ckb/v120/ckb.toml.j2", - "source/template/ckb/v120/ckb-miner.toml.j2", + "source/template/ckb/v200/ckb.toml.j2", + "source/template/ckb/v200/ckb-miner.toml.j2", "source/template/specs/mainnet.toml.j2", - "download/0.121.0", + "download/0.200.0", ) PREVIEW_DUMMY = ( - "source/template/ckb/v120/ckb.toml.j2", - "source/template/ckb/v120/ckb-miner.toml.j2", + "source/template/ckb/v200/ckb.toml.j2", + "source/template/ckb/v200/ckb-miner.toml.j2", "source/template/specs/preview_dev.toml", - "download/0.121.0", + "download/0.200.0", + ) + + v200 = ( + "source/template/ckb/v200/ckb.toml.j2", + "source/template/ckb/v200/ckb-miner.toml.j2", + "source/template/ckb/v200/specs/dev.toml", + "download/0.200.0", ) v121 = ( - "source/template/ckb/v120/ckb.toml.j2", - "source/template/ckb/v120/ckb-miner.toml.j2", - "source/template/ckb/v120/specs/dev.toml", + "source/template/ckb/v121/ckb.toml.j2", + "source/template/ckb/v121/ckb-miner.toml.j2", + "source/template/ckb/v121/specs/dev.toml", "download/0.121.0", ) diff --git a/source/template/ckb/v121/ckb-miner.toml.j2 b/source/template/ckb/v121/ckb-miner.toml.j2 new file mode 100644 index 00000000..6c29b129 --- /dev/null +++ b/source/template/ckb/v121/ckb-miner.toml.j2 @@ -0,0 +1,45 @@ +# Config generated by `ckb init --chain dev` + +data_dir = "{{ ckb_miner_data_dir | default(ckb_data_dir) }}" + +[chain] +{# Choose the kind of chains to run, possible values: #} +{# - { file = "specs/dev.toml" } #} +{# - { bundled = "specs/testnet.toml" } #} +{# - { bundled = "specs/mainnet.toml" } #} +spec = {{ ckb_chain_spec }} + + +[logger] +filter = "{{ ckb_miner_logger_filter | default("info") }}" +color = {{ ckb_miner_logger_color | default("true") }} +log_to_file = {{ ckb_miner_logger_log_to_file | default("true") }} +log_to_stdout = {{ ckb_miner_logger_log_to_stdout | default("true") }} + +[sentry] +# set to blank to disable sentry error collection +dsn = "{{ ckb_miner_sentry_dsn | default("") }}" +# if you are willing to help us to improve, +# please leave a way to contact you when we have troubles to reproduce the errors. +# org_contact = "{{ ckb_miner_sentry_org_contact | default() }}" + +[miner.client] +rpc_url = "http://{{ ckb_miner_rpc_url | default("127.0.0.1:8114") }}" +block_on_submit = {{ ckb_miner_block_on_submit | default("true") }} + +# block template polling interval in milliseconds +poll_interval = {{ ckb_miner_poll_interval | default("1000") }} + +#{% if ckb_miner_workers is defined %} +# {% for worker in ckb_miner_workers %} +# [[miner.workers]] +# worker_type = "{{ worker.worker_type }}" +# delay_type = "{{ worker.delay_type }}" +# value = {{ worker.value }} +# {% endfor %} +#{% else %} +[[miner.workers]] +worker_type = "Dummy" +delay_type = "Constant" +value = 1000 +#{% endif %} diff --git a/source/template/ckb/v121/ckb.toml.j2 b/source/template/ckb/v121/ckb.toml.j2 new file mode 100644 index 00000000..d2c8dfd0 --- /dev/null +++ b/source/template/ckb/v121/ckb.toml.j2 @@ -0,0 +1,220 @@ +# Config generated by `ckb init --chain dev` + +data_dir = "{{ ckb_data_dir | default("data") }}" + + +[chain] +# Choose the kind of chains to run, possible values: +# - { file = "specs/dev.toml" } +# - { bundled = "specs/testnet.toml" } +# - { bundled = "specs/mainnet.toml" } +spec = {{ ckb_chain_spec }} + + +[logger] +filter = "{{ ckb_logger_filter | default("info") }}" +color = {{ ckb_logger_color | default("true") }} +log_to_file = {{ ckb_logger_log_to_file | default("true") }} +log_to_stdout = {{ ckb_logger_log_to_stdout | default("true") }} + + +[sentry] +# set to blank to disable sentry error collection +dsn = "{{ ckb_sentry_dsn | default("") }}" +# if you are willing to help us to improve, +# please leave a way to contact you when we have troubles to reproduce the errors. +org_contact = "{{ ckb_sentry_org_contact | default("") }}" + + +# # **Experimental** Monitor memory changes. +# [memory_tracker] +# # Seconds between checking the process, 0 is disable, default is 0. +# interval = 600 + +[db] +# The capacity of RocksDB cache, which caches uncompressed data blocks, indexes and filters, default is 128MB. +# Rocksdb will automatically create and use an 8MB internal cache if you set this value to 0. +# To turning off cache, you need to set this value to 0 and set `no_block_cache = true` in the options_file, +# however, we strongly discourage this setting, it may lead to severe performance degradation. +cache_size = {{ ckb_db_cache_size | default("134217728") }} + +# Provide an options file to tune RocksDB for your workload and your system configuration. +# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide). +options_file = "{{ ckb_db_options_file | default("default.db-options") }}" + +[network] +listen_addresses = {{ ckb_network_listen_addresses | default(["/ip4/0.0.0.0/tcp/8115"]) | to_json }} +### Specify the public and routable network addresses +public_addresses = {{ ckb_network_public_addresses | default([]) | to_json }} + +# Node connects to nodes listed here to discovery other peers when there's no local stored peers. +# When chain.spec is changed, this usually should also be changed to the bootnodes in the new chain. +bootnodes = {{ ckb_network_bootnodes | default([]) | to_json }} + +### Whitelist-only mode +whitelist_only = {{ ckb_network_whitelist_only | default("false") }} +### Whitelist peers connecting from the given IP addresses +whitelist_peers = {{ ckb_network_whitelist_peers | default([]) | to_json }} +### Enable `SO_REUSEPORT` feature to reuse port on Linux, not supported on other OS yet +# reuse_port_on_linux = true + +max_peers = {{ ckb_network_max_peers | default(125) }} +max_outbound_peers = {{ ckb_network_max_outbound_peers | default(8) }} +# 2 minutes +ping_interval_secs = {{ ckb_network_ping_interval_secs | default(120) }} +# 20 minutes +ping_timeout_secs = {{ ckb_network_ping_timeout_secs | default(1200) }} +connect_outbound_interval_secs = 15 +# If set to true, try to register upnp +upnp = {{ ckb_network_upnp | default("false") }} +# If set to true, network service will add discovered local address to peer store, it's helpful for private net development +discovery_local_address = {{ ckb_network_discovery_local_address | default("true") }} +# If set to true, random cleanup when there are too many inbound nodes +# Ensure that itself can continue to serve as a bootnode node +bootnode_mode = {{ ckb_network_bootnode_mode | default("false") }} + +# Supported protocols list, only "Sync" and "Identify" are mandatory, others are optional +support_protocols = ["Ping", "Discovery", "Identify", "Feeler", "DisconnectMessage", "Sync", "Relay", "Time", "Alert", "LightClient", "Filter"] +# reuse_tcp_with_ws = true +reuse_tcp_with_ws = {{ ckb_network_reuse_tcp_with_ws | default("false") }} +# [network.sync.header_map] +# memory_limit = "600MB" + +[rpc] +# By default RPC only binds to localhost, thus it only allows accessing from the same machine. +# +# Allowing arbitrary machines to access the JSON-RPC port is dangerous and strongly discouraged. +# Please strictly limit the access to only trusted machines. +listen_address = "{{ ckb_rpc_listen_address | default("127.0.0.1:8114") }}" + +# Default is 10MiB = 10 * 1024 * 1024 +max_request_body_size = {{ ckb_rpc_max_request_body_size | default(10485760) }} + +# List of API modules: ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug", "Indexer"] +#modules = ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug"] +modules = {{ ckb_rpc_modules | to_json }} + +# By default RPC only binds to HTTP service, you can bind it to TCP and WebSocket. +#{% if ckb_tcp_listen_address is defined %} +tcp_listen_address = "{{ ckb_tcp_listen_address }}" +#{% endif %} + +#{% if ckb_ws_listen_address is defined %} +ws_listen_address = "{{ ckb_ws_listen_address }}" +#{% endif %} + +reject_ill_transactions = {{ ckb_rpc_reject_ill_transactions | default("true") }} + +# By default deprecated rpc methods are disabled. +enable_deprecated_rpc = {{ ckb_rpc_enable_deprecated_rpc | default("false") }} + + +{% if ckb_rpc_batch_limit is defined %} +rpc_batch_limit = {{ ckb_rpc_batch_limit | default("2000") }} +{% endif %} + + +[tx_pool] +max_tx_pool_size = {{ ckb_tx_pool_max_tx_pool_size | default("180_000_000") }} +min_fee_rate = {{ ckb_tx_pool_min_fee_rate | default("1_000") }} +max_tx_verify_cycles = {{ ckb_tx_pool_max_tx_verify_cycles | default("70_000_000") }} +max_ancestors_count = {{ ckb_tx_pool_max_ancestors_count | default("25") }} +min_rbf_rate = {{ ckb_tx_pool_min_rbf_rate | default("1_500") }} + + +[store] +header_cache_size = {{ ckb_store_header_cache_size | default("4096")}} +cell_data_cache_size = {{ ckb_store_cell_data_cache_size | default("128")}} +block_proposals_cache_size = {{ ckb_store_block_proposals_cache_size | default("30")}} +block_tx_hashes_cache_size = {{ ckb_store_block_tx_hashes_cache_size | default("30")}} +block_uncles_cache_size = {{ ckb_store_block_uncles_cache_size | default("30")}} + + +# [notify] +# # Execute command when the new tip block changes, first arg is block hash. +# new_block_notify_script = "your_new_block_notify_script.sh" +# # Execute command when node received an network alert, first arg is alert message string. +# network_alert_notify_script = "your_network_alert_notify_script.sh" + + +# Set the lock script to protect mined CKB. +# +# CKB uses CS architecture for miner. Miner process (ckb miner) gets block +# template from the Node process (ckb run) via RPC. Thus the lock script is +# configured in ckb.toml instead of ckb-miner.toml, and the config takes effect +# after restarting Node process. +# +# The `code_hash` identifies different cryptography algorithm. Read the manual +# of the lock script provider about how to generate this config. +# +# CKB provides an secp256k1 implementation, it requires a hash on the +# compressed public key. The hash algorithm is blake2b, with personal +# "ckb-default-hash". The first 160 bits (20 bytes) are used as the only arg. +# +# You can use any tool you trust to generate a Bitcoin private key and public +# key pair, which can be used in CKB as well. CKB CLI provides the function for +# you to convert the public key into block assembler configuration parameters. +# +# Here is an example using ckb-cli to generate an account, this command will +# print the block assembler args(lock_arg) to screen: +# +# ckb-cli account new +# +# If you already have a raw secp256k1 private key, you can get the lock_arg by: +# +# ckb-cli util key-info --privkey-path +# +# The command `ckb init` also accepts options to generate the block assembler +# directly. See `ckb init --help` for details. +# +# ckb init +# +# secp256k1_blake160_sighash_all example: +# [block_assembler] +# code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +# args = "ckb-cli util blake2b --prefix-160 " +# hash_type = "type" +# message = "A 0x-prefixed hex string" +# # +# # CKB will prepend the binary version to message, to identify the block miner client. (default true, false to disable it) +# use_binary_version_as_message_prefix = true +# # +# # Block assembler will notify new block template through http post to specified endpoints when update +# notify = ["http://127.0.0.1:8888"] +# # Or you may want use more flexible scripts, block template as arg. +# notify_scripts = ["{cmd} {blocktemplate}"] + + +{% if ckb_request_limit is defined %} +[indexer_v2] +request_limit = {{ ckb_request_limit | default("400") }} +{% endif %} + + + +# # Indexing the pending txs in the ckb tx-pool +# index_tx_pool = false +# # Customize block filtering rules to index only retained blocks +#block_filter = "block.header.number.to_uint() >= \"0x0\".to_uint()" +# # Customize cell filtering rules to index only retained cells +#cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\"" +# # The initial tip can be set higher than the current indexer tip as the starting height for indexing. +# init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44" +# +# # CKB rich-indexer has its unique configuration. + +#[indexer_v2.rich_indexer] +# # By default, it uses an embedded SQLite database. +# # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters. +# db_type = "postgres" +# db_name = "ckb-rich-indexer" +# db_host = "127.0.0.1" +# db_port = 5432 +# db_user = "postgres" +# db_password = "123456" + +[block_assembler] +code_hash = "{{ ckb_block_assembler_code_hash }}" +args = "{{ ckb_block_assembler_args }}" +hash_type = "{{ ckb_block_assembler_hash_type }}" +message = "{{ ckb_block_assembler_message }}" diff --git a/source/template/ckb/v121/default.db-options b/source/template/ckb/v121/default.db-options new file mode 100644 index 00000000..bffbdc09 --- /dev/null +++ b/source/template/ckb/v121/default.db-options @@ -0,0 +1,22 @@ +# This is a RocksDB option file. +# +# For detailed file format spec, please refer to the official documents +# in https://rocksdb.org/docs/ +# + +[DBOptions] +bytes_per_sync=1048576 +max_background_jobs=6 +max_total_wal_size=134217728 +keep_log_file_num=32 + +[CFOptions "default"] +level_compaction_dynamic_level_bytes=true +write_buffer_size=8388608 +min_write_buffer_number_to_merge=1 +max_write_buffer_number=2 +max_write_buffer_size_to_maintain=-1 + +[TableOptions/BlockBasedTable "default"] +cache_index_and_filter_blocks=true +pin_l0_filter_and_index_blocks_in_cache=true diff --git a/source/template/ckb/v121/specs/benchmark-spec.toml b/source/template/ckb/v121/specs/benchmark-spec.toml new file mode 100644 index 00000000..e69de29b diff --git a/source/template/ckb/v121/specs/dev.toml b/source/template/ckb/v121/specs/dev.toml new file mode 100644 index 00000000..f25a259a --- /dev/null +++ b/source/template/ckb/v121/specs/dev.toml @@ -0,0 +1,100 @@ +name = "ckb_dev" + +[genesis] +version = 0 +parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +timestamp = 0 +compact_target = 0x20010000 +uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +nonce = "0x0" + +[genesis.genesis_cell] +message = "1688032132025" + +[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" + +# issue for random generated private key: d00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc +[[genesis.issued_cells]] +capacity = 20_000_000_000_00000000 +lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +lock.args = "0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7" +lock.hash_type = "type" + +# issue for random generated private key: 63d86723e08f0f813a36ce6aa123bb2289d90680ae1e99d4de8cdb334553f24d +[[genesis.issued_cells]] +capacity = 5_198_735_037_00000000 +lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +lock.args = "0x470dcdc5e44064909650113a274b3b36aecb6dc7" +lock.hash_type = "type" + +[params] +initial_primary_epoch_reward = 1_917_808_21917808 +secondary_epoch_reward = 613_698_63013698 +max_block_cycles = 10_000_000_000 +cellbase_maturity = 0 +primary_epoch_reward_halving_interval = 8760 +epoch_duration_target = 14400 +genesis_epoch_length = 1000 +# For development and testing purposes only. +# Keep difficulty be permanent if the pow is Dummy. (default: false) +permanent_difficulty_in_dummy = true + +[params.hardfork] +ckb2023 = 1 + +[pow] +func = "Dummy" diff --git a/source/template/ckb/v121/specs/mainnet.toml b/source/template/ckb/v121/specs/mainnet.toml new file mode 100644 index 00000000..daf7edfb --- /dev/null +++ b/source/template/ckb/v121/specs/mainnet.toml @@ -0,0 +1,69 @@ +name = "ckb" + +[genesis] +version = 0 +parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +timestamp = 1573852190812 +compact_target = 0x1a08a97e +uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +nonce = "0x0" + +[genesis.genesis_cell] +message = "lina 0x18e020f6b1237a3d06b75121f25a7efa0550e4b3f44f974822f471902424c104" + +[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 = "data" + + + +[params] +genesis_epoch_length = 1743 + +[pow] +func = "Eaglesong" \ No newline at end of file diff --git a/source/template/ckb/v121/specs/testnet.toml b/source/template/ckb/v121/specs/testnet.toml new file mode 100644 index 00000000..2461e535 --- /dev/null +++ b/source/template/ckb/v121/specs/testnet.toml @@ -0,0 +1,90 @@ +name = "ckb_testnet" + +[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 = "0x10639e0895502b5688a6be8cf69460d76541bfa4821629d86d62ba0aae3f9606" + +[genesis.genesis_cell] +message = "aggron-v4" + +[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" + +[pow] +func = "EaglesongBlake2b" \ No newline at end of file diff --git a/source/template/ckb/v200/ckb-miner.toml.j2 b/source/template/ckb/v200/ckb-miner.toml.j2 new file mode 100644 index 00000000..6c29b129 --- /dev/null +++ b/source/template/ckb/v200/ckb-miner.toml.j2 @@ -0,0 +1,45 @@ +# Config generated by `ckb init --chain dev` + +data_dir = "{{ ckb_miner_data_dir | default(ckb_data_dir) }}" + +[chain] +{# Choose the kind of chains to run, possible values: #} +{# - { file = "specs/dev.toml" } #} +{# - { bundled = "specs/testnet.toml" } #} +{# - { bundled = "specs/mainnet.toml" } #} +spec = {{ ckb_chain_spec }} + + +[logger] +filter = "{{ ckb_miner_logger_filter | default("info") }}" +color = {{ ckb_miner_logger_color | default("true") }} +log_to_file = {{ ckb_miner_logger_log_to_file | default("true") }} +log_to_stdout = {{ ckb_miner_logger_log_to_stdout | default("true") }} + +[sentry] +# set to blank to disable sentry error collection +dsn = "{{ ckb_miner_sentry_dsn | default("") }}" +# if you are willing to help us to improve, +# please leave a way to contact you when we have troubles to reproduce the errors. +# org_contact = "{{ ckb_miner_sentry_org_contact | default() }}" + +[miner.client] +rpc_url = "http://{{ ckb_miner_rpc_url | default("127.0.0.1:8114") }}" +block_on_submit = {{ ckb_miner_block_on_submit | default("true") }} + +# block template polling interval in milliseconds +poll_interval = {{ ckb_miner_poll_interval | default("1000") }} + +#{% if ckb_miner_workers is defined %} +# {% for worker in ckb_miner_workers %} +# [[miner.workers]] +# worker_type = "{{ worker.worker_type }}" +# delay_type = "{{ worker.delay_type }}" +# value = {{ worker.value }} +# {% endfor %} +#{% else %} +[[miner.workers]] +worker_type = "Dummy" +delay_type = "Constant" +value = 1000 +#{% endif %} diff --git a/source/template/ckb/v200/ckb.toml.j2 b/source/template/ckb/v200/ckb.toml.j2 new file mode 100644 index 00000000..d2c8dfd0 --- /dev/null +++ b/source/template/ckb/v200/ckb.toml.j2 @@ -0,0 +1,220 @@ +# Config generated by `ckb init --chain dev` + +data_dir = "{{ ckb_data_dir | default("data") }}" + + +[chain] +# Choose the kind of chains to run, possible values: +# - { file = "specs/dev.toml" } +# - { bundled = "specs/testnet.toml" } +# - { bundled = "specs/mainnet.toml" } +spec = {{ ckb_chain_spec }} + + +[logger] +filter = "{{ ckb_logger_filter | default("info") }}" +color = {{ ckb_logger_color | default("true") }} +log_to_file = {{ ckb_logger_log_to_file | default("true") }} +log_to_stdout = {{ ckb_logger_log_to_stdout | default("true") }} + + +[sentry] +# set to blank to disable sentry error collection +dsn = "{{ ckb_sentry_dsn | default("") }}" +# if you are willing to help us to improve, +# please leave a way to contact you when we have troubles to reproduce the errors. +org_contact = "{{ ckb_sentry_org_contact | default("") }}" + + +# # **Experimental** Monitor memory changes. +# [memory_tracker] +# # Seconds between checking the process, 0 is disable, default is 0. +# interval = 600 + +[db] +# The capacity of RocksDB cache, which caches uncompressed data blocks, indexes and filters, default is 128MB. +# Rocksdb will automatically create and use an 8MB internal cache if you set this value to 0. +# To turning off cache, you need to set this value to 0 and set `no_block_cache = true` in the options_file, +# however, we strongly discourage this setting, it may lead to severe performance degradation. +cache_size = {{ ckb_db_cache_size | default("134217728") }} + +# Provide an options file to tune RocksDB for your workload and your system configuration. +# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide). +options_file = "{{ ckb_db_options_file | default("default.db-options") }}" + +[network] +listen_addresses = {{ ckb_network_listen_addresses | default(["/ip4/0.0.0.0/tcp/8115"]) | to_json }} +### Specify the public and routable network addresses +public_addresses = {{ ckb_network_public_addresses | default([]) | to_json }} + +# Node connects to nodes listed here to discovery other peers when there's no local stored peers. +# When chain.spec is changed, this usually should also be changed to the bootnodes in the new chain. +bootnodes = {{ ckb_network_bootnodes | default([]) | to_json }} + +### Whitelist-only mode +whitelist_only = {{ ckb_network_whitelist_only | default("false") }} +### Whitelist peers connecting from the given IP addresses +whitelist_peers = {{ ckb_network_whitelist_peers | default([]) | to_json }} +### Enable `SO_REUSEPORT` feature to reuse port on Linux, not supported on other OS yet +# reuse_port_on_linux = true + +max_peers = {{ ckb_network_max_peers | default(125) }} +max_outbound_peers = {{ ckb_network_max_outbound_peers | default(8) }} +# 2 minutes +ping_interval_secs = {{ ckb_network_ping_interval_secs | default(120) }} +# 20 minutes +ping_timeout_secs = {{ ckb_network_ping_timeout_secs | default(1200) }} +connect_outbound_interval_secs = 15 +# If set to true, try to register upnp +upnp = {{ ckb_network_upnp | default("false") }} +# If set to true, network service will add discovered local address to peer store, it's helpful for private net development +discovery_local_address = {{ ckb_network_discovery_local_address | default("true") }} +# If set to true, random cleanup when there are too many inbound nodes +# Ensure that itself can continue to serve as a bootnode node +bootnode_mode = {{ ckb_network_bootnode_mode | default("false") }} + +# Supported protocols list, only "Sync" and "Identify" are mandatory, others are optional +support_protocols = ["Ping", "Discovery", "Identify", "Feeler", "DisconnectMessage", "Sync", "Relay", "Time", "Alert", "LightClient", "Filter"] +# reuse_tcp_with_ws = true +reuse_tcp_with_ws = {{ ckb_network_reuse_tcp_with_ws | default("false") }} +# [network.sync.header_map] +# memory_limit = "600MB" + +[rpc] +# By default RPC only binds to localhost, thus it only allows accessing from the same machine. +# +# Allowing arbitrary machines to access the JSON-RPC port is dangerous and strongly discouraged. +# Please strictly limit the access to only trusted machines. +listen_address = "{{ ckb_rpc_listen_address | default("127.0.0.1:8114") }}" + +# Default is 10MiB = 10 * 1024 * 1024 +max_request_body_size = {{ ckb_rpc_max_request_body_size | default(10485760) }} + +# List of API modules: ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug", "Indexer"] +#modules = ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug"] +modules = {{ ckb_rpc_modules | to_json }} + +# By default RPC only binds to HTTP service, you can bind it to TCP and WebSocket. +#{% if ckb_tcp_listen_address is defined %} +tcp_listen_address = "{{ ckb_tcp_listen_address }}" +#{% endif %} + +#{% if ckb_ws_listen_address is defined %} +ws_listen_address = "{{ ckb_ws_listen_address }}" +#{% endif %} + +reject_ill_transactions = {{ ckb_rpc_reject_ill_transactions | default("true") }} + +# By default deprecated rpc methods are disabled. +enable_deprecated_rpc = {{ ckb_rpc_enable_deprecated_rpc | default("false") }} + + +{% if ckb_rpc_batch_limit is defined %} +rpc_batch_limit = {{ ckb_rpc_batch_limit | default("2000") }} +{% endif %} + + +[tx_pool] +max_tx_pool_size = {{ ckb_tx_pool_max_tx_pool_size | default("180_000_000") }} +min_fee_rate = {{ ckb_tx_pool_min_fee_rate | default("1_000") }} +max_tx_verify_cycles = {{ ckb_tx_pool_max_tx_verify_cycles | default("70_000_000") }} +max_ancestors_count = {{ ckb_tx_pool_max_ancestors_count | default("25") }} +min_rbf_rate = {{ ckb_tx_pool_min_rbf_rate | default("1_500") }} + + +[store] +header_cache_size = {{ ckb_store_header_cache_size | default("4096")}} +cell_data_cache_size = {{ ckb_store_cell_data_cache_size | default("128")}} +block_proposals_cache_size = {{ ckb_store_block_proposals_cache_size | default("30")}} +block_tx_hashes_cache_size = {{ ckb_store_block_tx_hashes_cache_size | default("30")}} +block_uncles_cache_size = {{ ckb_store_block_uncles_cache_size | default("30")}} + + +# [notify] +# # Execute command when the new tip block changes, first arg is block hash. +# new_block_notify_script = "your_new_block_notify_script.sh" +# # Execute command when node received an network alert, first arg is alert message string. +# network_alert_notify_script = "your_network_alert_notify_script.sh" + + +# Set the lock script to protect mined CKB. +# +# CKB uses CS architecture for miner. Miner process (ckb miner) gets block +# template from the Node process (ckb run) via RPC. Thus the lock script is +# configured in ckb.toml instead of ckb-miner.toml, and the config takes effect +# after restarting Node process. +# +# The `code_hash` identifies different cryptography algorithm. Read the manual +# of the lock script provider about how to generate this config. +# +# CKB provides an secp256k1 implementation, it requires a hash on the +# compressed public key. The hash algorithm is blake2b, with personal +# "ckb-default-hash". The first 160 bits (20 bytes) are used as the only arg. +# +# You can use any tool you trust to generate a Bitcoin private key and public +# key pair, which can be used in CKB as well. CKB CLI provides the function for +# you to convert the public key into block assembler configuration parameters. +# +# Here is an example using ckb-cli to generate an account, this command will +# print the block assembler args(lock_arg) to screen: +# +# ckb-cli account new +# +# If you already have a raw secp256k1 private key, you can get the lock_arg by: +# +# ckb-cli util key-info --privkey-path +# +# The command `ckb init` also accepts options to generate the block assembler +# directly. See `ckb init --help` for details. +# +# ckb init +# +# secp256k1_blake160_sighash_all example: +# [block_assembler] +# code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +# args = "ckb-cli util blake2b --prefix-160 " +# hash_type = "type" +# message = "A 0x-prefixed hex string" +# # +# # CKB will prepend the binary version to message, to identify the block miner client. (default true, false to disable it) +# use_binary_version_as_message_prefix = true +# # +# # Block assembler will notify new block template through http post to specified endpoints when update +# notify = ["http://127.0.0.1:8888"] +# # Or you may want use more flexible scripts, block template as arg. +# notify_scripts = ["{cmd} {blocktemplate}"] + + +{% if ckb_request_limit is defined %} +[indexer_v2] +request_limit = {{ ckb_request_limit | default("400") }} +{% endif %} + + + +# # Indexing the pending txs in the ckb tx-pool +# index_tx_pool = false +# # Customize block filtering rules to index only retained blocks +#block_filter = "block.header.number.to_uint() >= \"0x0\".to_uint()" +# # Customize cell filtering rules to index only retained cells +#cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\"" +# # The initial tip can be set higher than the current indexer tip as the starting height for indexing. +# init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44" +# +# # CKB rich-indexer has its unique configuration. + +#[indexer_v2.rich_indexer] +# # By default, it uses an embedded SQLite database. +# # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters. +# db_type = "postgres" +# db_name = "ckb-rich-indexer" +# db_host = "127.0.0.1" +# db_port = 5432 +# db_user = "postgres" +# db_password = "123456" + +[block_assembler] +code_hash = "{{ ckb_block_assembler_code_hash }}" +args = "{{ ckb_block_assembler_args }}" +hash_type = "{{ ckb_block_assembler_hash_type }}" +message = "{{ ckb_block_assembler_message }}" diff --git a/source/template/ckb/v200/default.db-options b/source/template/ckb/v200/default.db-options new file mode 100644 index 00000000..bffbdc09 --- /dev/null +++ b/source/template/ckb/v200/default.db-options @@ -0,0 +1,22 @@ +# This is a RocksDB option file. +# +# For detailed file format spec, please refer to the official documents +# in https://rocksdb.org/docs/ +# + +[DBOptions] +bytes_per_sync=1048576 +max_background_jobs=6 +max_total_wal_size=134217728 +keep_log_file_num=32 + +[CFOptions "default"] +level_compaction_dynamic_level_bytes=true +write_buffer_size=8388608 +min_write_buffer_number_to_merge=1 +max_write_buffer_number=2 +max_write_buffer_size_to_maintain=-1 + +[TableOptions/BlockBasedTable "default"] +cache_index_and_filter_blocks=true +pin_l0_filter_and_index_blocks_in_cache=true diff --git a/source/template/ckb/v200/specs/benchmark-spec.toml b/source/template/ckb/v200/specs/benchmark-spec.toml new file mode 100644 index 00000000..e69de29b diff --git a/source/template/ckb/v200/specs/dev.toml b/source/template/ckb/v200/specs/dev.toml new file mode 100644 index 00000000..f25a259a --- /dev/null +++ b/source/template/ckb/v200/specs/dev.toml @@ -0,0 +1,100 @@ +name = "ckb_dev" + +[genesis] +version = 0 +parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +timestamp = 0 +compact_target = 0x20010000 +uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +nonce = "0x0" + +[genesis.genesis_cell] +message = "1688032132025" + +[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" + +# issue for random generated private key: d00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc +[[genesis.issued_cells]] +capacity = 20_000_000_000_00000000 +lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +lock.args = "0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7" +lock.hash_type = "type" + +# issue for random generated private key: 63d86723e08f0f813a36ce6aa123bb2289d90680ae1e99d4de8cdb334553f24d +[[genesis.issued_cells]] +capacity = 5_198_735_037_00000000 +lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +lock.args = "0x470dcdc5e44064909650113a274b3b36aecb6dc7" +lock.hash_type = "type" + +[params] +initial_primary_epoch_reward = 1_917_808_21917808 +secondary_epoch_reward = 613_698_63013698 +max_block_cycles = 10_000_000_000 +cellbase_maturity = 0 +primary_epoch_reward_halving_interval = 8760 +epoch_duration_target = 14400 +genesis_epoch_length = 1000 +# For development and testing purposes only. +# Keep difficulty be permanent if the pow is Dummy. (default: false) +permanent_difficulty_in_dummy = true + +[params.hardfork] +ckb2023 = 1 + +[pow] +func = "Dummy" diff --git a/source/template/ckb/v200/specs/mainnet.toml b/source/template/ckb/v200/specs/mainnet.toml new file mode 100644 index 00000000..daf7edfb --- /dev/null +++ b/source/template/ckb/v200/specs/mainnet.toml @@ -0,0 +1,69 @@ +name = "ckb" + +[genesis] +version = 0 +parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +timestamp = 1573852190812 +compact_target = 0x1a08a97e +uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000" +nonce = "0x0" + +[genesis.genesis_cell] +message = "lina 0x18e020f6b1237a3d06b75121f25a7efa0550e4b3f44f974822f471902424c104" + +[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 = "data" + + + +[params] +genesis_epoch_length = 1743 + +[pow] +func = "Eaglesong" \ No newline at end of file diff --git a/source/template/ckb/v200/specs/testnet.toml b/source/template/ckb/v200/specs/testnet.toml new file mode 100644 index 00000000..2461e535 --- /dev/null +++ b/source/template/ckb/v200/specs/testnet.toml @@ -0,0 +1,90 @@ +name = "ckb_testnet" + +[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 = "0x10639e0895502b5688a6be8cf69460d76541bfa4821629d86d62ba0aae3f9606" + +[genesis.genesis_cell] +message = "aggron-v4" + +[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" + +[pow] +func = "EaglesongBlake2b" \ No newline at end of file diff --git a/test_cases/ckb2023/test_08_ckb_mainnet.py b/test_cases/ckb2023/test_08_ckb_mainnet.py new file mode 100644 index 00000000..62a6a9aa --- /dev/null +++ b/test_cases/ckb2023/test_08_ckb_mainnet.py @@ -0,0 +1,136 @@ +import time + +from framework.basic import CkbTest +from framework.helper.spawn_contract import SpawnContract + + +# https://github.com/nervosnetwork/ckb/pull/4807 +# pub const CKB2023_START_EPOCH: u64 = 12_293; + + +class CKBTestnet(CkbTest): + + @classmethod + def setup_class(cls): + """ + 1. star 4 node in tmp/cluster/hardFork dir + 2. link ckb node each other + Returns: + + """ + + # 1. star 4 node in tmp/cluster/hardFork dir + nodes = [ + cls.CkbNode.init_dev_by_port( + cls.CkbNodeConfigPath.CURRENT_MAIN, + "cluster/hardFork/node{i}".format(i=i), + 8114 + i, + 8225 + i, + ) + for i in range(1, 5) + ] + cls.cluster = cls.Cluster(nodes) + cls.cluster.prepare_all_nodes( + other_ckb_spec_config={ + "ckb_params_genesis_epoch_length": "1", + "ckb_name": "ckb", + } + ) + cls.cluster.start_all_nodes() + + # 2. link ckb node each other + cls.cluster.connected_all_nodes() + + @classmethod + def teardown_class(cls): + print("\nTeardown TestClass1") + cls.cluster.stop_all_nodes() + cls.cluster.clean_all_nodes() + + def test_02(self): + """ + 1. generate_epochs(hex(12_293)) + 2. get_consensus(0048) == 12_293 + 3. get_consensus(0049) == 12_293 + 4. miner with 0x1 + 5. transfer data2 + 6. invoke spawn + Returns: + + """ + self.cluster.ckb_nodes[0].getClient().get_consensus() + self.Miner.make_tip_height_number(self.cluster.ckb_nodes[0], 12_293) + # generate_epochs will cause HeadersIsInvalid + # self.cluster.ckb_nodes[0].client.generate_epochs(hex(12_293)) + + tip_number = self.cluster.ckb_nodes[0].client.get_tip_block_number() + print("tip number:", tip_number) + consensus = self.cluster.ckb_nodes[0].getClient().get_consensus() + res = get_epoch_number_by_consensus_response(consensus, "0048") + assert res == 12_293 + res = get_epoch_number_by_consensus_response(consensus, "0049") + assert res == 12_293 + time.sleep(5) + # 0048 miner with other version block + for i in range(20): + self.Miner.miner_with_version(self.cluster.ckb_nodes[0], "0x1") + + # transfer data2 + # 2. send tx contains data2 + # send account 1 transfer data2 + # @ckb-lumos/helpers.encodeToAddress( + # { + # hashType:"data2", + # args:"0x", + # codeHash:"0x69c80d6a8104994bddc132bb568c953d60fae0ac928ad887c96de8434ca2a790" + # } + # ) + tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( + self.Config.MINER_PRIVATE_1, + "ckb1qp5usrt2syzfjj7acyetk45vj57kp7hq4jfg4ky8e9k7ss6v52neqpq2cmcdt", + 140, + self.cluster.ckb_nodes[0].client.url, + ) + + # 3. miner until tx committed + self.Miner.miner_with_version(self.cluster.ckb_nodes[0], "0x0") + self.Miner.miner_until_tx_committed(self.cluster.ckb_nodes[0], tx_hash) + # spawn + spawn = SpawnContract() + spawn.deploy(self.Config.MINER_PRIVATE_1, self.cluster.ckb_nodes[0]) + code_tx_hash, code_tx_index = spawn.get_deploy_hash_and_index() + invoke_arg, invoke_data = spawn.get_arg_and_data("demo") + tx_hash = self.Contract.invoke_ckb_contract( + self.Config.MINER_PRIVATE_1, + code_tx_hash, + code_tx_index, + invoke_arg, + "data2", + invoke_data, + api_url=self.cluster.ckb_nodes[0].getClient().url, + ) + self.Miner.miner_until_tx_committed(self.cluster.ckb_nodes[0], tx_hash) + tip_number = self.cluster.ckb_nodes[0].getClient().get_tip_block_number() + self.Node.wait_cluster_height(self.cluster, tip_number, 250) + + +def get_epoch_number_by_consensus_response(consensus_response, rfc_name): + """ + get ckb epoch number + "hardfork_features": [ + { "rfc": "0028", "epoch_number": "0x1526" }, + ] + Example: + get_epoch_number_by_consensus_response(consensus_response,"0028") + return int(0x1526,16) + :param consensus_response: rpc get_consensus response + :param rfc_name: example : 0048 + :return: + """ + hardfork_features = consensus_response["hardfork_features"] + return int( + list(filter(lambda obj: rfc_name in obj["rfc"], hardfork_features))[0][ + "epoch_number" + ].replace("0x", ""), + 16, + )