-
Notifications
You must be signed in to change notification settings - Fork 288
Description
Ledger App support
Zondax et al. have developed a Ledger app to support generic substrate networks,1 meaning Bittensor will benefit from this app provided we integrate the required changes to our runtime, giving us Ledger support (and other hardware signers).
The changes required involve providing a verification of the chain metadata to consumers, e.g. hardware signers. This change allows hardware signer devices to verify their decoding of transactions, avoiding approvals of maliciously crafted transactions given some unverified metadata.
Background
- Overview forum post: https://forum.polkadot.network/t/polkadot-generic-ledger-app/4295/3
- RFC for needed runtime changes: Metadata for offline signers polkadot-fellows/RFCs#46
polkadot-sdkUpstream PR: ImplementCheckMetadataHashextension paritytech/polkadot-sdk#4274- Guide for integration
TODO (from above guide)2:
- Runtime integration
From the runtime side only the
frame_metadata_hash_extension::CheckMetadataHashneeds to be added to the list of signed extension[s]Note:
Adding the signed extension changes the encoding of the transaction and adds one extra byte per transaction!
This signed extension will make sure to decode the requested
modeand will add the metadata
hash to the signed data depending on the requestedmode. Themodegives the user/wallet
control over deciding if the metadata hash should be verified or not. The metadata hash itself
is drawn from theRUNTIME_METADATA_HASHenvironment variable. If the environment variable is
not set, any transaction that requires the metadata hash is rejected with the error
CannotLookup. This is a security measurement to prevent including invalid transactions.Warning
The extension does not work with the native runtime, because the
RUNTIME_METADATA_HASHenvironment variable is not set when building the
frame-metadata-hash-extensioncrate.
- Enable metadata hash generation
The metadata hash generation needs to be enabled when building the wasm binary. The
substrate-wasm-buildersupports this out of the boxNote:
The
metadata-hashfeature needs to be enabled for thesubstrate-wasm-builderto enable the
code for being able to generate the metadata hash. It is also recommended to put the metadata
hash generation behind a feature in the runtime as shown above. The reason behind is that it
adds a lot of code which increases the compile time and the generation itself also increases
the compile time. Thus, it is recommended to enable the feature only when the metadata hash is
required (e.g. for an on-chain build).The two parameters to
enable_metadata_hashare the token symbol and the number of decimals of
the primary token of the chain. These information are included for the wallets to show token
related operations in a more user friendly way.