Skip to content

Adopting to v0.12#6

Open
dr-orlovsky wants to merge 22 commits intorgb-protocol:v0.11-beta.9from
RGB-WG:v0.12
Open

Adopting to v0.12#6
dr-orlovsky wants to merge 22 commits intorgb-protocol:v0.11-beta.9from
RGB-WG:v0.12

Conversation

@dr-orlovsky
Copy link

No description provided.

@dr-orlovsky dr-orlovsky marked this pull request as ready for review February 2, 2025 14:16
@dr-orlovsky dr-orlovsky changed the base branch from master to v0.11-beta.9 February 2, 2025 14:16
@dr-orlovsky
Copy link
Author

Changed the base to v0.11-beta.9 so it will be easier to review v0.12-specific changes

Comment on lines 20 to +22

# closing method / derivation variables
CLOSING_METHODS=("opret1st" "tapret1st")

# rgb-schemata variables
SCHEMATA_DIR="./rgb-schemata/schemata"
# RGB wallet types
WALLET_TYPES=("wpkh" "tapret-key-only")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have seal types anymore. However, we have wallet types, which work in the following way: if you have a taproot wallet, it will always produce tapret commitments; all other wallet descriptor types will always do opret. Since BP so far supports only one taproot descriptor (key-only), thus, in order to produce tapret commitments you need to create a wallet with tapret-key-only descriptor.

I expect this would be the same with your changes to v0.11x


# maps
declare -A CONTRACT_ID_MAP
declare -A CONTRACT_SCHEMA_MAP
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more schemata; now we have codexes, which are specified right inside the YAML files for contract issuance.

declare -A CONTRACT_SCHEMA_MAP
declare -A CONTRACT_NAME_MAP
declare -A DESC_MAP
declare -A IFACE_MAP
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more interfaces in v0.12; contracts are using so-called APIs, which always ships with them, and since there always a default one, there is no need to specify it neither in rust APIs nor in command-line

Comment on lines +46 to +47
CONTRACT_NAME_MAP["usdt"]=USDT
CONTRACT_NAME_MAP["collectible"]=OtherToken
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v0.12 we have a concept of contract name. Contract directories inside the stash are organized by names (to simplify debugging), and thus, we using this index in order to do import/export with cp (as I explain below, I didn't get time to do import/export commands for rgb cli, and used simple directory cp, since contracts are now reside in independent directories - and not all in one mixed stock file as before)

_subtit "syncing $wallet"
local wallet_id=${WLT_ID_MAP[$wallet]}
_trace "${RGB[@]}" -d "data${wallet_id}" utxos -w "$wallet" --sync
_trace "${RGB[@]}" -d "data${wallet_id}" sync "$INDEXER_CLI" "$wallet"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a dedicated sync command. Also, if a command works with wallet, you provide wallet name as an unnamed argument, instead of using -w

_subtit "(recipient) preparing invoice"
if [ "$witness" = 1 ]; then
address_mode="-a"
address_mode="--wout"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pay-to-address invoices are called "witness output-invoices"

demo.sh Outdated
Comment on lines +538 to +539
_trace "${RGB[@]}" -d "$rcpt_data" invoice "$address_mode" \
-w "$RCPT_WLT" "$contract_id" "$send_amt" >$TRACE_OUT
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invoicing now simpler: no need to provide interface name.

Also, no more "amounts"; invoice includes now arbitrary state, encoded as a strict value. Good news: for numbers, it is just like writing the number. And it is now a positional argument

Both contract_id and state as positional arguments are now optional, allowing creating invoices in form of "pay anything" and "pay any amount under this contract"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the script execution always fails, with

error: invalid value '' for '[CONTRACT]': invalid contract reference ''

For more information, try '--help'.

ERROR: command 'rgb-wallet/bin/rgb -n regtest -d data1 invoice  -w wallet_1 contract:Ko_9~W2J-YXwpN8e-ZTY9X2l-PtqSsUN-g2Wu0ij-onReuzw 100' returned a non-zero exit code (transfer 0)

Spent a lot of time trying to figure why....

Copy link
Author

@dr-orlovsky dr-orlovsky Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, solved this: the reason was that "$address_mode" didn't worked producing an excessive argument in a form of '' when a UTXO payment is used. Spent a day figuring that out... Pity

CONSIGNMENT="consignment_${TRANSFER_NUM}.rgb"
PSBT=tx_${TRANSFER_NUM}.psbt
local sats=(--sats 2000)
local sats=()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a default value in sats for pay-to-address now

Comment on lines +578 to +581
# TODO: Re-enable with `rgbx` tool
# _trace "${RGB[@]}" -d "$send_data" inspect \
# "$send_data/$CONSIGNMENT" "$CONSIGNMENT.yaml"
# _log "consignment exported to file: $CONSIGNMENT.yaml"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspection and other pro debug tasks has moved to a dedicated tool from rgb-std named rgbx. It will be good to install it alongside rgb, but this is too complex for my poor bash knowledge.

The reason is that rgb always has an internal runtime, which relies (and reads) on certain hardcoded directory structure, while rgbx allows to work with individual binary files without any runtime.

_die "accept failed (transfer $TRANSFER_NUM)"
fi

## ending situation
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more consignment verification command; only accept.

The real reason is the fact that consignments now are streams parsed by runtime right into stash - and the stash is an abstract object which can't be cloned in memory. Thus, there is no such thing as a "dumb run": the consignment (if valid) will always get into the stash.

Copy link
Author

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more of explanations

Comment on lines +14 to +15
SATS=800 # TODO: This is required only for witness-out transfers. We need to account for it
FEE=260
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without these changes we had non-deterministic failures since we run out of sats for transfers (at round 7 or 8)


# internal functions
_check_method() {
_check_wallet_type() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now opret and tapret is not a seal closing method but a type of a wallet

local wallet="$1"
local keychain="$2"
if [ -z "$keychain" ]; then
if [ "${WLT_CM_MAP[$wallet]}" = "opret1st" ]; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more RGB-specific keychains

local wallet="$1"
local contract_name="$2"
local sync="$3"
local contract_id iface schema wallet_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iface and schema are now the same and provided in the YAML as codex_id

if [ "$subtit" = 0 ]; then
_tit "checking $contract_name balance for $wallet"
else
elif [ "$subtit" = 1 ]; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with 2 we suppress the printout completely

_subtit "issuing"
_trace "${RGB[@]}" -d "data${wallet_id}" issue -w "$wallet" \
"$schema_id" "ssi:$wallet" "$contract_yaml" >$TRACE_OUT 2>&1
_trace "${RGB[@]}" -d "data${wallet_id}" import issuers/*
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a new concept of issuers which we need to import

_trace "${RGB[@]}" -d "data${wallet_id}" interfaces -w "$wallet"
fi
fi
_trace "${RGB[@]}" -d "data${wallet_id}" init -q
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dedicated command to initialize persistence; -q makes it quiet if the persistence is already initialized

_log "interfaces:"
_trace "${RGB[@]}" -d "data${wallet_id}" interfaces -w "$wallet"
fi
fi
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without schemata the things got much simpler

unset BLNC_RCPT BLNC_SEND RCPT_WLT SEND_WLT
}

transfer_aborted() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to sync wallet in order to abort a transfer, to make wallet see that the tx is not in a mempool anymore.

_trace "${RGB[@]}" -d "$send_data" transfer -w "$SEND_WLT" \
"${sats[@]}" "${fee[@]}" \
_trace "${RGB[@]}" -d "$send_data" pay -w "$SEND_WLT" \
"${sats[@]}" "${fee[@]}" --force \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--force is needed to overwrite consignment if it already exists (like in aborted transfers)

@dr-orlovsky
Copy link
Author

All tests are passing against v0.12.0 beta 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant