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
feat(core,legacy): add support for Ethereum 64-bit chain_id #1771
feat(core,legacy): add support for Ethereum 64-bit chain_id #1771
Conversation
This supersedes #1741 |
I think we could use this opportunity to make trezor-firmware/core/src/apps/ethereum/sign_tx.py Lines 153 to 156 in a398704
into this: if msg.chain_id:
req.signature_v += 2 * msg.chain_id + 8 and this: trezor-firmware/legacy/firmware/ethereum.c Lines 211 to 217 in f93a851
into this: msg_tx_request.signature_v = v + 27;
if (chain_id) {
msg_tx_request.signature_v = v + 2 * chain_id + 8;
} What do you think @matejcik? |
My thoughts were in the opposite direction: always require chain_id, and then just send a single bit for I'm not sure if there are any Ethereum networks out there not using EIP-155, but we certainly don't support any, seeing as our Ethereum network database is keyed on chain_id. At that point, perhaps we could go the extra mile and introduce |
I let you decide on this. Either seems fine to me. I just want to decrease the number of source lines in our codebases.
I prefer not to do this, because this would break all existing implementations. OTOH uint32 and uint64 look exactly the same on the wire. |
Would it make sense for me to just remove the check_chain_id function, revert the tests to no longer set chain_id=1, add the two tests for MAX_CHAIN_ID and MAX_CHAIN_ID+1 and then leave all of the other suggestions for another future PR? |
@arbitrarylink yes, that makes sense. Please do that. |
The updates have been made. |
thanks for your work. I'm merging this to a separate Ethereum branch for now, I want to tweak it a little and make it a part of a larger change set (see also #1781) |
@matejcik quick question, are you planning to merge |
yes |
@arbitrarylink could you share more details about Do you know of any reason why that would be a bad idea? |
Currently Trezor One (Legacy) disallows chain_id of 0. It returns an error of "Error: DataError: ChainId out of bounds". This comes from the code ./legacy/firmware/ethereum.c: 444. The code in this PR I had earlier was to disallow chain_id 0 in Trezor T (core) was to make the core behave like the legacy. This code has been reverted as requested. If you want both devices to support a chain_id of 0 you will have to modify the Legacy code. |
i'm well aware. I'm asking if you know something about one or the other behavior being "more correct" in some sense. |
There is an EIP that is not yet accepted that will explicitly make chain_id of 0 invalid. https://eips.ethereum.org/EIPS/eip-3788 |
Thanks for the info! This means that currently transactions with chain_id 0 are valid and actually can be used. |
Adds support for Ethereum 64-bit chain_id This also makes sure that chain_id of 0 is rejected on core the same way it is rejected in legacy.
Test-Results.txt