Skip to content

Commit

Permalink
func-test: debug withdrawal op_return
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Jan 17, 2025
1 parent dab5321 commit 2590cd7
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions functional-tests/tests/bridge_withdraw_happy_op_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,23 @@ def __init__(self, ctx: flexitest.InitContext):
testenv.BasicEnvConfig(
pre_generate_blocks=101,
rollup_settings=fast_batch_settings,
# need to manually control the block generations
auto_generate_blocks=False,
)
)

def main(self, ctx: flexitest.RunContext):
btc = ctx.get_service("bitcoin")
seq = ctx.get_service("sequencer")
reth = ctx.get_service("reth")
# create both btc and sequencer RPC
btcrpc: BitcoindClient = btc.create_rpc()
seqrpc = seq.create_rpc()
# generate 5 btc blocks
generate_n_blocks(btcrpc, 5)
rethrpc = reth.create_rpc()

# Wait for seq
wait_until(
lambda: seqrpc.strata_protocolVersion() is not None,
error_with="Sequencer did not start on time",
)
generate_n_blocks(btcrpc, 5)

# Generate addresses
address = ctx.env.gen_ext_btc_address()
Expand Down Expand Up @@ -79,14 +76,41 @@ def main(self, ctx: flexitest.RunContext):
self.deposit(ctx, el_address, bridge_pk)

# Withdraw
self.withdraw_op_return(ctx, el_address, bosd)
l2_tx_hash, _tx_receipt, _total_gas_used = self.withdraw_op_return(ctx, el_address, bosd)
l2_block_hash = rethrpc.eth_getTransactionByHash(l2_tx_hash)["blockHash"]

# Make sure that the OP_RETURN is in the Strata block execution update
# FIXME: I have no idea how to do this
exec_update = seqrpc.strata_getExecUpdateById(l2_block_hash)
self.debug(f"Exec update: {exec_update}")
print(f"Exec update: {exec_update}") # FIXME: REMOVE ME
update_idx = exec_update["update_idx"]
self.debug(f"Exec update index: {update_idx}")
print(f"Exec update index: {update_idx}") # FIXME: REMOVE ME
sync_event = seqrpc.strata_getSyncEvent(update_idx)
self.debug(f"Sync event: {sync_event}")
print(f"Sync event: {sync_event}") # FIXME: REMOVE ME

withdrawals = exec_update["withdrawals"]
self.debug(f"Exec update withdrawals: {withdrawals}")
print(f"Exec update withdrawals: {withdrawals}") # FIXME: REMOVE ME

# Move forward a single block
block = generate_n_blocks(btcrpc, 1)[0] # There's only one
last_block = btcrpc.getblock(block)

# Get all withdraw bridge messages
# VODepositSig(10)
scope = "00"
self.debug(scope)

msgs = seqrpc.strata_getBridgeMsgsByScope(scope)
self.debug(msgs)
print(f"Bridge msgs: {msgs}") # FIXME: REMOVE ME

# Get the output of the tx
# OP_RETURN is the second output
# FIXME: I have no idea how to do this
outputs = last_block["txs"][0].as_dict()["outputs"]
op_return_output = outputs[1]
self.debug(f"OP_RETURN output: {op_return_output}")
Expand Down

0 comments on commit 2590cd7

Please sign in to comment.