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 pool #25

Merged
merged 5 commits into from
Nov 20, 2023
Merged
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
2 changes: 1 addition & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import requests
from tqdm import tqdm

versions = ['0.109.0', '0.110.2', '0.111.0','0.112.0-rc2'] # Replace with your versions
versions = ['0.109.0', '0.110.2', '0.111.0','0.112.0-rc3'] # Replace with your versions
DOWNLOAD_DIR = "download"
SYSTEMS = {
'Windows': {
Expand Down
31 changes: 30 additions & 1 deletion framework/helper/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def make_tip_height_number(node, number):
assert current_tip_number == number


def miner_until_tx_committed(node, tx_hash):
def miner_until_tx_committed(node, tx_hash, with_unknown=False):
for i in range(100):
tx_response = node.getClient().get_transaction(tx_hash)
if tx_response['tx_status']['status'] == "committed":
Expand All @@ -30,6 +30,10 @@ def miner_until_tx_committed(node, tx_hash):
miner_with_version(node, "0x0")
time.sleep(1)
continue
if with_unknown and tx_response['tx_status']['status'] == "unknown":
miner_with_version(node, "0x0")
time.sleep(1)
continue

if tx_response['tx_status']['status'] == "rejected" or tx_response['tx_status']['status'] == "unknown":
raise Exception(f"status:{tx_response['tx_status']['status']},reason:{tx_response['tx_status']['reason']}")
Expand Down Expand Up @@ -87,3 +91,28 @@ def get_hex_timestamp():
timestamp = int(time.time() * 1000)
hex_timestamp = hex(timestamp)
return hex_timestamp




def compact_to_target(compact):
exponent = compact >> 24
mantissa = compact & 0x00ffffff
rtn = 0
if (exponent <= 3):
mantissa >>= (8 * (3 - exponent))
rtn = mantissa
else:
rtn = mantissa
rtn <<= (8 * (exponent - 3))
overflow = mantissa != 0 and (exponent > 32)
return rtn, overflow


def target_to_compact(target):
bits = (target).bit_length()
exponent = ((bits + 7) // 8)
compact = target << (
8 * (3 - exponent)) if exponent <= 3 else (target >> (8 * (exponent - 3)))
compact = (compact | (exponent << 24))
return compact
4 changes: 3 additions & 1 deletion framework/helper/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def send_transfer_self_tx_with_input(input_tx_hash_list, input_tx_index_list, sign_private, data="0x",
fee=5000, output_count=1,
api_url="http://127.0.0.1:8114"):
api_url="http://127.0.0.1:8114", dep_cells=[]):
# tx file init

tmp_tx_file = f"/tmp/demo{time.time()}-{random.randint(0, 100000000)}.json"
Expand Down Expand Up @@ -34,6 +34,8 @@ def send_transfer_self_tx_with_input(input_tx_hash_list, input_tx_index_list, si
tx_add_type_out_put(input_cell_template["lock"]["code_hash"], input_cell_template["lock"]["hash_type"],
input_cell_template["lock"]["args"],
hex(output_cell_capacity), data, tmp_tx_file, False)
for i in range(len(dep_cells)):
tx_add_cell_dep(dep_cells[i]['tx_hash'],dep_cells[i]['index_hex'],tmp_tx_file)

# sign
sign_data = tx_sign_inputs(sign_private, tmp_tx_file, api_url)
Expand Down
3 changes: 3 additions & 0 deletions framework/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def get_fee_rate_statics(self, target=None):
def generate_epochs(self, epoch):
return self.call("generate_epochs", [epoch])

def generate_block(self):
return self.call("generate_block",[])

def get_deployments_info(self):
return self.call("get_deployments_info", [])

Expand Down
Loading