-
Notifications
You must be signed in to change notification settings - Fork 75
[ETCM-1096] eip2930 transaction signature #1095
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
[ETCM-1096] eip2930 transaction signature #1095
Conversation
@@ -0,0 +1,4 @@ | |||
package io.iohk.ethereum.signer | |||
|
|||
trait SignerError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be sealed
Taken from the splitted PR.
at the time of coding, there wasn't , but the signer stuff will remove the need for the hack, since there should be a method to import the signature according to a given ruleset. This behavior is also caused by the fact that, internally, Mantis uses the concept of ECDSASignature for two things:
I'm wondering if we shouldn't introduce a EthererumEncodedSignature to properly differentiate between the two, since the field value is converted between the crypto signature (possible value 0/1) and the rlp encoding (for exemple, before eip-155, it's 27/28, but after eip-155, it's 0/1 + chainId * 2 + 35, and for transaction type 1, it's back to 0/1) Another possibility would be to only keep the unmodified ECDSASignature and doing the computation on the fly when rlp encoding/decoding. However it could possibly lead to the introduction of additional fields (encoding version, chainId, etc) , which would be dependant on the signature ruleset.
The Signer will provide implementation for the different rulesets (homestead, eip-155, eip-2930). Main differences from each of them are:
The main difference between payloadToSign an payloadToCheck is that it's possible to have a choice in the way a client can encode a payload. It's currently only the case for EIP-155, where a transaction can be chainId-protected or not. In our case, the EIP155Signer payloadToSign is alwasy chainId-protecting the transaction, but the payloadToCheck has to guess if the emitter has protected or not the transaction. In this particular case, they can be different. For all the other cases, they are not. Initially, I had a default implementation payloadToCheck = payloadToSign, but it was not working properly when delegating to previous signer, since the call hierarchy would become: But I'm open to proposal to reduce the footprint of the signer. Likewise, I'm contemplating an implementation where we just change the meaning of ECDSASignature, and we restrict it to the pure crypto values. Potential benefits are:
Potential drawbacks (TBD):
The signers should then be plugged in the Mantis client. It add a dependency to two things: the block number and the blockchain config, to know which rulesetto use. The blockchain config could be made available thanks to the implicit pattern already used, but the block number would need some refactor. When receiving a broadcast signed transaction, it seems ok to add this dependency, since this transaction is inserted into a block (but if the block is not emitted, Mantis will have to recheck for every pending transactions if the Signer has changed). When receiving a complet block, there is not ambiguity, the block number is known. Additionally, it may be possible to keep the Signer in the SignedTransaction. It would notably help with the verification part, since the primitive SignedTransaction.getSender would not depend anymore on an external block number. So one possiblity (TBD) could be going from: |
297066a
to
22093b7
Compare
771aa72
to
b511815
Compare
8d84756
to
e486b9b
Compare
b511815
to
971c033
Compare
c569fd7
to
c3d99bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a small unit tests suggestion but other than that OK
@@ -58,7 +58,7 @@ object BaseETH6XMessages { | |||
implicit val accessListItemCodec: RLPCodec[AccessListItem] = | |||
RLPCodec.instance[AccessListItem]( | |||
{ case AccessListItem(address, storageKeys) => | |||
RLPList(address, toRlpList(storageKeys)) | |||
RLPList(address, toRlpList(storageKeys.map(UInt256(_).bytes.toArray))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a test to
- make the round trip and check that the serialization is the same with the padded zeros.
- check that we get the right sender from a given transaction (because it was wrong when we forgot to add the padded zeros)
getLegacyTransactionRawSignature(signedTransaction.signature, chainIdOpt) | ||
case _: TransactionWithAccessList => | ||
getTWALRawSignature(signedTransaction.signature) | ||
case _ => throw new IllegalArgumentException(s"Transaction type not supported for $signedTransaction") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transaction
is only extended by LegacyTransaction
and TransactionWithAccessList
so can this case ever occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current code base, it shouldn't.
New transaction types are expected to be introduced on a regular basis, so this will change.
Currently, Transaction is a sealed trait, so by removing the case _ match, any new transaction not explicitely handled should be caught by the compiler, but since warnings are not generating errors, this won't be visible, until the running client raises a match exception.
The IllegalArgumentException somehow tries to provided a better error.
aac0350
to
6230db0
Compare
Description
Transaction with optional access list (added by EIP 2930) requires a specific rule for signing / validation.
There is currently no framework to handle different rulesets for such a purpose.
This PR is split from #1061
Proposed Solution
Implement the specific ruleset for new transaction type 1
This may need a signature process refactoring. (Signature refactoring has been parked into the branch https://github.com/input-output-hk/mantis/tree/feature/eip2930%2Fsigner_hierarchy)