Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tx index #54

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"0.114.0",
"0.115.0",
"0.116.1",
"0.117.0",
] # Replace with your versions

DOWNLOAD_DIR = "download"
Expand Down
55 changes: 55 additions & 0 deletions framework/helper/ckb_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,38 @@ def get_cells(
output_format="json",
api_url="http://127.0.0.1:8114",
):
"""
cmd:export API_URL=http://127.0.0.1:8314 && cd /Users/xueyanli/PycharmProjects/ckb-py-integration-test/source && ./ckb-cli rpc sync_state --output-format json
result:{
"assume_valid_target": "0x0000000000000000000000000000000000000000000000000000000000000000",
"assume_valid_target_reached": true,
"best_known_block_number": 0,
"best_known_block_timestamp": "0 (1970-01-01 08:00:00 +08:00)",
"fast_time": 1000,
"ibd": false,
"inflight_blocks_count": 0,
"low_time": 1500,
"min_chain_work": "0x0",
"min_chain_work_reached": true,
"normal_time": 1250,
"orphan_blocks_count": 0,
"orphan_blocks_size": 0
}

Args:
json_path:
order:
limit:
raw_data:
no_color:
debug:
local_only:
output_format:
api_url:

Returns:

"""
cmd = "rpc get_cells"
if raw_data:
cmd += " --raw-data"
Expand Down Expand Up @@ -990,3 +1022,26 @@ def get_cells_capacity(

cmd = f"export API_URL={api_url} && {cli_path} {cmd}"
return json.loads(run_command(cmd))


def sync_state(
raw_data=False,
no_color=False,
debug=False,
local_only=False,
output_format="json",
api_url="http://127.0.0.1:8114",
):
cmd = "rpc sync_state"
if raw_data:
cmd += " --raw-data"
if no_color:
cmd += " --no-color"
if debug:
cmd += " --debug"
if local_only:
cmd += " --local-only"
cmd += f" --output-format {output_format}"

cmd = f"export API_URL={api_url} && {cli_path} {cmd}"
return json.loads(run_command(cmd))
30 changes: 21 additions & 9 deletions framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,32 @@


class CkbNodeConfigPath(Enum):

CURRENT_TEST = (
"source/template/ckb/v116/ckb.toml.j2",
"source/template/ckb/v116/ckb-miner.toml.j2",
"source/template/ckb/v116/specs/dev.toml",
"download/0.116.1",
"source/template/ckb/v117/ckb.toml.j2",
"source/template/ckb/v117/ckb-miner.toml.j2",
"source/template/ckb/v117/specs/dev.toml",
"download/0.117.0",
)

CURRENT_MAIN = (
"source/template/ckb/v116/ckb.toml.j2",
"source/template/ckb/v116/ckb-miner.toml.j2",
"source/template/ckb/v117/ckb.toml.j2",
"source/template/ckb/v117/ckb-miner.toml.j2",
"source/template/specs/mainnet.toml.j2",
"download/0.116.1",
"download/0.117.0",
)

develop = (
"source/template/ckb/v117/ckb.toml.j2",
"source/template/ckb/v117/ckb-miner.toml.j2",
"source/template/ckb/v117/specs/dev.toml",
"download/develop/ckb/target/prod",
)

v117 = (
"source/template/ckb/v117/ckb.toml.j2",
"source/template/ckb/v117/ckb-miner.toml.j2",
"source/template/ckb/v117/specs/dev.toml",
"download/0.117.0",
)

v116 = (
Expand Down Expand Up @@ -124,7 +137,6 @@ def __str__(self):


class CkbNode:

@classmethod
def init_dev_by_port(
cls, ckb_node_path_enum: CkbNodeConfigPath, dec_dir, rpc_port, p2p_port
Expand Down
9 changes: 2 additions & 7 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
set -e
# git clone https://github.com/nervosnetwork/ckb-cli.git
# cd ckb-cli
# git checkout pkg/v1.7.0
# make prod
# cp target/release/ckb-cli ../source/ckb-cli
# cd ../
cp download/0.110.2/ckb-cli ./source/ckb-cli-old
cp download/0.115.0/ckb-cli ./source/ckb-cli
cp download/0.117.0/ckb-cli ./source/ckb-cli
#cp ckb-cli/target/release/ckb-cli download/develop/ckb/target/prod/
#git clone https://github.com/quake/ckb-light-client.git
#cd ckb-light-client
#git checkout quake/fix-set-scripts-partial-bug
Expand Down
16 changes: 16 additions & 0 deletions prepare_ckb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

BRANCH="develop"
BASE_DIR="download/${BRANCH}/"
REPO_URL="https://github.com/nervosnetwork/ckb.git"

if [ ! -d "$BASE_DIR" ]; then
mkdir -p "$BASE_DIR"
fi

cd "$BASE_DIR"
git clone -b $BRANCH $REPO_URL

cd ckb/
make prod
45 changes: 45 additions & 0 deletions source/template/ckb/v117/ckb-miner.toml.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Loading
Loading