Zondax / ledger-oasis

Oasis app for Ledger Nano S and X
Apache License 2.0
3 stars 6 forks source link

Support for Registry Deregister Entity txn type #135

Closed tjanez closed 3 years ago

tjanez commented 3 years ago

Steps to reproduce

cd $(mktemp -d)

OASIS_CORE_VERSION=21.2.7
wget https://github.com/oasisprotocol/oasis-core/releases/download/v${OASIS_CORE_VERSION}/oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz
tar -xf oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz
export OASIS_NODE="$PWD/oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-node"

OASIS_CORE_LEDGER_VERSION=1.2.0
wget https://github.com/oasisprotocol/oasis-core-ledger/releases/download/v${OASIS_CORE_LEDGER_VERSION}/oasis_core_ledger_${OASIS_CORE_LEDGER_VERSION}_linux_amd64.tar.gz
tar -xf oasis_core_ledger_${OASIS_CORE_LEDGER_VERSION}_linux_amd64.tar.gz
export LEDGER_SIGNER_PATH="$PWD/oasis_core_ledger_${OASIS_CORE_LEDGER_VERSION}_linux_amd64/ledger-signer"

wget https://github.com/oasisprotocol/mainnet-artifacts/releases/download/2021-04-28/genesis.json -O genesis.json

ENTITY_DIR=entity0/
LEDGER_SIGNER_FLAGS=(
  --signer.dir $ENTITY_DIR
  --signer.backend plugin
  --signer.plugin.name ledger
  --signer.plugin.path "$LEDGER_SIGNER_PATH"
)
TX_FLAGS=(
  --genesis.file genesis.json
  "${LEDGER_SIGNER_FLAGS[@]}"
)

# Open Oasis app on Ledger.

mkdir $ENTITY_DIR
$OASIS_NODE signer export "${LEDGER_SIGNER_FLAGS[@]}"

$OASIS_NODE registry entity gen_deregister \
  "${TX_FLAGS[@]}" \
  --transaction.file tx_entity_registery.json \
  --transaction.nonce 42 \
  --transaction.fee.gas 1000 \
  --transaction.fee.amount 2000

Results with Version 2.2.0

NOTE: I've compiled the latest commit of PR #129 as of now: 551df7d2d3f7df0ec8fe3099ad6d859bb1dac4e7.

$ $OASIS_NODE registry entity gen_deregister \
>   "${TX_FLAGS[@]}" \
>   --transaction.file tx_entity_registery.json \
>   --transaction.nonce 42 \
>   --transaction.fee.gas 1000 \
>   --transaction.fee.amount 2000
You are about to sign the following transaction:
  Method: registry.DeregisterEntity
  Body:
    <unknown method body: >
  Nonce:  42
  Fee:
    Amount: 0.000002 ROSE
    Gas limit: 1000
    (gas price: 0.000000002 ROSE per gas unit)
Other info:
  Genesis document's hash: 53852332637bacb61b91b6411ab4095168ba02a50be4c3f82448438826f23898

You may need to review the transaction on your device if you use a hardware-based signer plugin...
ts=2021-08-03T19:39:25.384414697Z level=error module=cmd/common/consensus caller=consensus.go:139 msg="failed to sign transaction" err="signature/signer/plugin: failed to sign: ledger: failed to sign message: ledger/oasis: failed to sign: No more data"
tjanez commented 3 years ago

It actually turns out Registry Deregister Entity transaction type signing was never supported yet.

I would suggest the following Ledger confirmation workflow:

  1. Type
  2. Fee
  3. Gas limit
  4. Genesis hash
  5. Approve

This also follows the Oasis Node CLI's confirmation output, e.g.:

You are about to sign the following transaction:
  Method: registry.DeregisterEntity
  Body:
    {}
  Nonce:  25
  Fee:
    Amount: 0.000002 TEST
    Gas limit: 1000
    (gas price: 0.000000002 TEST per gas unit)
Other info:
  Genesis document's hash: 5ba68bc5e01e06f755c4c044dd11ec508e4c17f1faf40c0e67874388437a9e55

You may need to review the transaction on your device if you use a hardware-based signer plugin...
tjanez commented 3 years ago

Implemented in #136.