From 5db26205d61e7a621d6449fb71c7626bccd31a1d Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 18:21:16 +0800 Subject: [PATCH 1/6] del pytest.mark.skip --- test_cases/feature/test_get_transaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_cases/feature/test_get_transaction.py b/test_cases/feature/test_get_transaction.py index 0774780..aa44fd0 100644 --- a/test_cases/feature/test_get_transaction.py +++ b/test_cases/feature/test_get_transaction.py @@ -32,7 +32,7 @@ def teardown_class(cls): cls.node.stop() cls.node.clean() - @pytest.mark.skip("util v118") + # @pytest.mark.skip("util v118") def test_get_transaction_by_tx_index(self): """ 1. new tx in block From dfbc49772ea93be2c5ab75336d55fd5bd22b614f Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Tue, 20 Aug 2024 10:25:25 +0800 Subject: [PATCH 2/6] add source ckb 118 config --- framework/test_node.py | 16 +- source/template/ckb/v118/ckb-miner.toml.j2 | 45 ++++ source/template/ckb/v118/ckb.toml.j2 | 206 ++++++++++++++++++ .../ckb/{ => v118}/default.db-options | 0 .../ckb/v118/specs/benchmark-spec.toml | 0 source/template/ckb/v118/specs/dev.toml | 100 +++++++++ source/template/ckb/v118/specs/mainnet.toml | 69 ++++++ source/template/ckb/v118/specs/testnet.toml | 90 ++++++++ 8 files changed, 518 insertions(+), 8 deletions(-) create mode 100644 source/template/ckb/v118/ckb-miner.toml.j2 create mode 100644 source/template/ckb/v118/ckb.toml.j2 rename source/template/ckb/{ => v118}/default.db-options (100%) create mode 100644 source/template/ckb/v118/specs/benchmark-spec.toml create mode 100644 source/template/ckb/v118/specs/dev.toml create mode 100644 source/template/ckb/v118/specs/mainnet.toml create mode 100644 source/template/ckb/v118/specs/testnet.toml diff --git a/framework/test_node.py b/framework/test_node.py index 5728840..2851b1e 100644 --- a/framework/test_node.py +++ b/framework/test_node.py @@ -15,23 +15,23 @@ class CkbNodeConfigPath(Enum): CURRENT_TEST = ( - "source/template/ckb/v117/ckb.toml.j2", - "source/template/ckb/v117/ckb-miner.toml.j2", - "source/template/ckb/v117/specs/dev.toml", + "source/template/ckb/v118/ckb.toml.j2", + "source/template/ckb/v118/ckb-miner.toml.j2", + "source/template/ckb/v118/specs/dev.toml", "download/0.118.0", ) CURRENT_MAIN = ( - "source/template/ckb/v117/ckb.toml.j2", - "source/template/ckb/v117/ckb-miner.toml.j2", + "source/template/ckb/v118/ckb.toml.j2", + "source/template/ckb/v118/ckb-miner.toml.j2", "source/template/specs/mainnet.toml.j2", "download/0.118.0", ) v118 = ( - "source/template/ckb/v117/ckb.toml.j2", - "source/template/ckb/v117/ckb-miner.toml.j2", - "source/template/ckb/v117/specs/dev.toml", + "source/template/ckb/v118/ckb.toml.j2", + "source/template/ckb/v118/ckb-miner.toml.j2", + "source/template/ckb/v118/specs/dev.toml", "download/0.118.0", ) diff --git a/source/template/ckb/v118/ckb-miner.toml.j2 b/source/template/ckb/v118/ckb-miner.toml.j2 new file mode 100644 index 0000000..6c29b12 --- /dev/null +++ b/source/template/ckb/v118/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/v118/ckb.toml.j2 b/source/template/ckb/v118/ckb.toml.j2 new file mode 100644 index 0000000..968f3ee --- /dev/null +++ b/source/template/ckb/v118/ckb.toml.j2 @@ -0,0 +1,206 @@ +# 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"] + +# [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") }} + + +[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}"] +# +# [indexer_v2] +# # 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/default.db-options b/source/template/ckb/v118/default.db-options similarity index 100% rename from source/template/ckb/default.db-options rename to source/template/ckb/v118/default.db-options diff --git a/source/template/ckb/v118/specs/benchmark-spec.toml b/source/template/ckb/v118/specs/benchmark-spec.toml new file mode 100644 index 0000000..e69de29 diff --git a/source/template/ckb/v118/specs/dev.toml b/source/template/ckb/v118/specs/dev.toml new file mode 100644 index 0000000..f25a259 --- /dev/null +++ b/source/template/ckb/v118/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/v118/specs/mainnet.toml b/source/template/ckb/v118/specs/mainnet.toml new file mode 100644 index 0000000..daf7edf --- /dev/null +++ b/source/template/ckb/v118/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/v118/specs/testnet.toml b/source/template/ckb/v118/specs/testnet.toml new file mode 100644 index 0000000..2461e53 --- /dev/null +++ b/source/template/ckb/v118/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 From b1cfc3c7d86449d14211990d171d338f9295f538 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Tue, 20 Aug 2024 10:28:01 +0800 Subject: [PATCH 3/6] add source ckb 118 config --- test_cases/feature/test_get_transaction.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test_cases/feature/test_get_transaction.py b/test_cases/feature/test_get_transaction.py index aa44fd0..6f0544c 100644 --- a/test_cases/feature/test_get_transaction.py +++ b/test_cases/feature/test_get_transaction.py @@ -32,7 +32,6 @@ def teardown_class(cls): cls.node.stop() cls.node.clean() - # @pytest.mark.skip("util v118") def test_get_transaction_by_tx_index(self): """ 1. new tx in block From 4c1bef3c3be56ef95057be3d023d50db95adaa5f Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Tue, 20 Aug 2024 10:29:02 +0800 Subject: [PATCH 4/6] add source ckb 118 config --- test_cases/feature/test_get_transaction.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test_cases/feature/test_get_transaction.py b/test_cases/feature/test_get_transaction.py index 6f0544c..d2de45d 100644 --- a/test_cases/feature/test_get_transaction.py +++ b/test_cases/feature/test_get_transaction.py @@ -1,5 +1,4 @@ from framework.basic import CkbTest -import pytest class TestGetTransaction(CkbTest): From c895bb7766b49b51ade3788a30594ece9643c2fe Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Tue, 20 Aug 2024 10:35:15 +0800 Subject: [PATCH 5/6] add default.db-options --- source/template/ckb/default.db-options | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 source/template/ckb/default.db-options diff --git a/source/template/ckb/default.db-options b/source/template/ckb/default.db-options new file mode 100644 index 0000000..bffbdc0 --- /dev/null +++ b/source/template/ckb/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 From 7311d64cb66381bd7383558b08c4166ffb3348f1 Mon Sep 17 00:00:00 2001 From: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:03:00 +0800 Subject: [PATCH 6/6] add config test (#61) * add config test * add config test --- Makefile | 3 +- source/template/ckb/v118/ckb.toml.j2 | 16 ++++- test_cases/config/test_request_limit.py | 74 +++++++++++++++++++++++ test_cases/config/test_rpc_batch_limit.py | 69 +++++++++++++++++++++ 4 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 test_cases/config/test_request_limit.py create mode 100644 test_cases/config/test_rpc_batch_limit.py diff --git a/Makefile b/Makefile index c8f1778..cb95e8f 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ test_cases := \ test_cases/soft_fork \ test_cases/issue \ test_cases/tx_pool_refactor \ - test_cases/feature + test_cases/feature \ + test_cases/config test: @failed_cases=; \ diff --git a/source/template/ckb/v118/ckb.toml.j2 b/source/template/ckb/v118/ckb.toml.j2 index 968f3ee..25f6536 100644 --- a/source/template/ckb/v118/ckb.toml.j2 +++ b/source/template/ckb/v118/ckb.toml.j2 @@ -108,6 +108,11 @@ reject_ill_transactions = {{ ckb_rpc_reject_ill_transactions | default("true") } 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") }} @@ -177,8 +182,15 @@ block_uncles_cache_size = {{ ckb_store_block_uncles_cache_size | default(" # notify = ["http://127.0.0.1:8888"] # # Or you may want use more flexible scripts, block template as arg. # notify_scripts = ["{cmd} {blocktemplate}"] -# -# [indexer_v2] + + +{% 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 diff --git a/test_cases/config/test_request_limit.py b/test_cases/config/test_request_limit.py new file mode 100644 index 0000000..fe794e8 --- /dev/null +++ b/test_cases/config/test_request_limit.py @@ -0,0 +1,74 @@ +import pytest + +from framework.basic import CkbTest + + +class TestRequestLimit(CkbTest): + node: CkbTest.CkbNode + + @classmethod + def setup_class(cls): + cls.node = cls.CkbNode.init_dev_by_port( + cls.CkbNodeConfigPath.CURRENT_TEST, "node/node", 8118, 8119 + ) + cls.node.prepare() + cls.node.start() + # miner 100 block + cls.Miner.make_tip_height_number(cls.node, 100) + + @classmethod + def teardown_class(cls): + cls.node.stop() + cls.node.clean() + + def test_request_limit(self): + """ + 1. change ckb_request_limit = 10 in ckb.toml + 2. get_cells(len:0xff) => Invalid params limit must be less than 10 + 3. get_cells(len:10) => cells.length = 10 + Returns: + + """ + + # 1. change ckb_request_limit = 10 in ckb.toml + self.node.stop() + self.node.prepare(other_ckb_config={"ckb_request_limit": 10}) + self.node.start() + + # 2. get_cells(len:0xff) => Invalid params limit must be less than 10 + with pytest.raises(Exception) as exc_info: + self.node.getClient().get_cells( + { + "script": { + "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hash_type": "type", + "args": "0x", + }, + "script_type": "lock", + "script_search_mode": "prefix", + }, + "asc", + "0xff", + None, + ) + expected_error_message = "Invalid params limit must be less than 10" + assert ( + expected_error_message in exc_info.value.args[0] + ), f"Expected substring '{expected_error_message}' not found in actual string '{exc_info.value.args[0]}'" + + # 3. get_cells(len:10) => cells.length = 10 + cells = self.node.getClient().get_cells( + { + "script": { + "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hash_type": "type", + "args": "0x", + }, + "script_type": "lock", + "script_search_mode": "prefix", + }, + "asc", + "0xa", + None, + ) + assert len(cells["objects"]) == 10 diff --git a/test_cases/config/test_rpc_batch_limit.py b/test_cases/config/test_rpc_batch_limit.py new file mode 100644 index 0000000..da55de9 --- /dev/null +++ b/test_cases/config/test_rpc_batch_limit.py @@ -0,0 +1,69 @@ +import pytest + +from framework.basic import CkbTest +from framework.util import run_command + + +class TestRpcBatchLimit(CkbTest): + node: CkbTest.CkbNode + + @classmethod + def setup_class(cls): + cls.node = cls.CkbNode.init_dev_by_port( + cls.CkbNodeConfigPath.CURRENT_TEST, "node/node", 8118, 8119 + ) + cls.node.prepare() + cls.node.start() + + @classmethod + def teardown_class(cls): + cls.node.stop() + cls.node.clean() + pass + + def test_rpc_batch_limit(self): + """ + 1. set ckb_rpc_batch_limit = 10 in ckb.toml + 2. curl batch [11] -> batch size is too large, expect it less than: 10 + 3. curl batch [10] -> successful + Returns: + + """ + # 1. set ckb_rpc_batch_limit = 10 in ckb.toml + self.node.stop() + self.node.prepare(other_ckb_config={"ckb_rpc_batch_limit": 10}) + self.node.start() + + # 2. curl batch [11] -> batch size is too large, expect it less than: 10 + requestBody = "" + for i in range(11): + requestBody = ( + requestBody + + """{"jsonrpc": "2.0", "method": "get_block_by_number", "params": ["0x0"], + "id": "1"},""" + ) + requestBody = requestBody[:-1] + requests = ( + """curl -X POST -H "Content-Type: application/json" -d '[""" + + str(requestBody) + + f"""]' {self.node.rpcUrl} """ + ) + response = run_command(requests) + assert "batch size is too large, expect it less than: 10" in response + + # 3. curl batch [10] -> successful + requestBody = "" + for i in range(10): + requestBody = ( + requestBody + + """{"jsonrpc": "2.0", "method": "get_block_by_number", "params": ["0x0"], + "id": "1"},""" + ) + requestBody = requestBody[:-1] + requests = ( + """curl -X POST -H "Content-Type: application/json" -d '[""" + + str(requestBody) + + f"""]' {self.node.rpcUrl} """ + ) + response = run_command(requests) + assert "batch size is too large, expect it less than: 10" not in response