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

Feature/mintlayer pk #1

Open
wants to merge 38 commits into
base: mintlayer-master
Choose a base branch
from
Open

Conversation

OBorce
Copy link
Collaborator

@OBorce OBorce commented May 15, 2024

Add new messages in the proto files for Mintlayer coin support, and handlers.

@OBorce OBorce force-pushed the feature/mintlayer-pk branch from bddbd25 to 967640b Compare July 16, 2024 09:08
@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 5abd648 to 798be63 Compare August 6, 2024 09:54
@azarovh
Copy link
Member

azarovh commented Aug 6, 2024

I wouldn't merge this to master but rather created a separate branch like mintlayer-master and merge features there. This way we can keep it clean and isolated and when we decide to update trezor version we will pull to master and rebase our master. Otherwise it could become a mess very quickly. Makes sense?

One thing to consider is that CI might not work for "our" master.

Copy link

@ImplOfAnImpl ImplOfAnImpl left a comment

Choose a reason for hiding this comment

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

As I can see, there are still many FIXMEs and commented lines, so it seems like this is still work-in-progress.

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h Outdated Show resolved Hide resolved
rust/trezor-client/src/error.rs Outdated Show resolved Hide resolved
rust/trezor-client/src/error.rs Outdated Show resolved Hide resolved
core/src/apps/bitcoin/sign_tx/layout.py Outdated Show resolved Hide resolved
core/src/apps/bitcoin/sign_tx/layout.py Outdated Show resolved Hide resolved
core/src/apps/workflow_handlers.py Outdated Show resolved Hide resolved
core/src/trezor/crypto/bech32.py Outdated Show resolved Hide resolved
core/src/trezor/crypto/bech32.py Outdated Show resolved Hide resolved
core/src/trezor/crypto/bech32.py Outdated Show resolved Hide resolved
@OBorce OBorce force-pushed the feature/mintlayer-pk branch 16 times, most recently from 941d641 to dd3f1e8 Compare September 12, 2024 16:29
@OBorce OBorce changed the base branch from master to main September 12, 2024 16:32
@OBorce OBorce force-pushed the feature/mintlayer-pk branch 9 times, most recently from 08dce8d to 77bb6af Compare September 16, 2024 23:28
Copy link
Member

@azarovh azarovh left a comment

Choose a reason for hiding this comment

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

looks good to me

@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 554dbfd to 0e27aff Compare December 2, 2024 19:01
@OBorce OBorce force-pushed the feature/mintlayer-pk branch 3 times, most recently from 2456d64 to 781eb0d Compare December 4, 2024 13:33
@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 781eb0d to c929c9a Compare December 4, 2024 15:26
@OBorce OBorce force-pushed the feature/mintlayer-pk branch 2 times, most recently from c75c2a2 to 9fb3fc1 Compare December 13, 2024 09:17
Copy link

@ImplOfAnImpl ImplOfAnImpl left a comment

Choose a reason for hiding this comment

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

I guess it makes sense to review it one more time after the comments are applied.

core/src/apps/mintlayer/sign_tx/signer.py Outdated Show resolved Hide resolved
core/src/apps/mintlayer/sign_tx/signer.py Outdated Show resolved Hide resolved
core/src/apps/mintlayer/sign_tx/signer.py Outdated Show resolved Hide resolved
core/src/apps/mintlayer/sign_tx/signer.py Outdated Show resolved Hide resolved
common/protob/messages-mintlayer.proto Outdated Show resolved Hide resolved
rust/trezor-client/src/error.rs Outdated Show resolved Hide resolved
rust/trezor-client/src/error.rs Outdated Show resolved Hide resolved
rust/trezor-client/src/client/mintlayer.rs Outdated Show resolved Hide resolved
@pytest.mark.setup_client(
mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
)
def test_mintlayer_get_public_key(client: Client):

Choose a reason for hiding this comment

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

We need tests for get_address as well (both for testbet and mainnet).

Though I'm still not sure how the network type should be passed to the firmware. The original code seems to use CoinInfo for that.

Choose a reason for hiding this comment

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

Though I'm still not sure how the network type should be passed to the firmware. The original code seems to use CoinInfo for that.

I think we should use CoinInfo too, so that we can call validate_path_against_script_type in get_address/get_public_key/sign_message, which will ensure that the derivation path is correct and show a warning to the user if it's not (as I can see from the code at least)

common/protob/messages-mintlayer.proto Outdated Show resolved Hide resolved
@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 9fb3fc1 to 6e03e86 Compare December 13, 2024 10:39
@ImplOfAnImpl
Copy link

Regarding CoinInfo - I still don't see how having a CoinInfo of our own can interfere with the existing btc-related code. Am I missing something?
Regarding where to put the definitions for ML and TML - we could put it into misc.json. The only problem is that currently it doesn't allow specifying whether the coin is a testnet one and _load_misc in core/vendor/trezor-common/tools/coin_info.py always sets is_testnet to False. I guess we could make is_testnet optional, defaulting to False.

@OBorce OBorce force-pushed the feature/mintlayer-pk branch 3 times, most recently from 15c716f to a6eca9f Compare December 19, 2024 09:33
@OBorce OBorce force-pushed the feature/mintlayer-pk branch from a6eca9f to 40022df Compare December 23, 2024 08:58
Copy link

@ImplOfAnImpl ImplOfAnImpl left a comment

Choose a reason for hiding this comment

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

Btw, trezor-client is outdated, e.g. it references MintlayerRequestType::TXMETA which is no longer there.
And the brach refactor/wallet-generic-signer in the main repo seems to be outdated too. I wonder if you just forgot to push the changes.

Comment on lines +34 to +36
\b
$ trezorctl mintlayer get-address -n m/44h/19788h/0h/0/0
"""

Choose a reason for hiding this comment

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

It's better to have an example for --coin, including its possible values.

if name == REGTEST_COIN.coin_name:
return REGTEST_COIN

raise ValueError(f"unknown coin type {name}")

Choose a reason for hiding this comment

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

This results in a cryptic message in trezorctl: Error: FirmwareError: Firmware error. We should either catch such exceptions later and rethrow something from wire.errors, such as DataError, or throw DataError in the first place.
(I suggest aways throwing DataError or one of its friends from wire.errors unless we actually need to catch the exception in the firmware).

coin_info.prefixes.public_key_hash, data, Encoding.BECH32M
)
else:
raise ValueError(f"Unknown Address type {msg.address_type}")

Choose a reason for hiding this comment

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

DataError?

Comment on lines +113 to +118
raise ValueError("Token Fixed supply without amount")
fixed_amount = int.from_bytes(x.total_supply.fixed_amount, "big")
formated_amount = format_amount(fixed_amount, x.number_of_decimals)
total_supply = f"FIXED {formated_amount}"
else:
raise ValueError("Unhandled Token total supply type")

Choose a reason for hiding this comment

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

DataError?

message MintlayerSignMessage {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required string coin_name = 2; // Coin to use Testnet or Mainnet
required MintlayerAddressType address_type = 3; // destination address in bech32 encoding

Choose a reason for hiding this comment

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

Wrong comment

@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 1768ae8 to 361cb0a Compare January 8, 2025 10:10
@OBorce OBorce force-pushed the feature/mintlayer-pk branch from 877bde1 to 04bd932 Compare January 12, 2025 12:59
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.

3 participants