-
Notifications
You must be signed in to change notification settings - Fork 328
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
[action] support pre-EIP155 unprotected transaction #3965
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3965 +/- ##
==========================================
+ Coverage 75.38% 76.14% +0.76%
==========================================
Files 303 330 +27
Lines 25923 28138 +2215
==========================================
+ Hits 19541 21425 +1884
- Misses 5360 5614 +254
- Partials 1022 1099 +77 ☔ View full report in Codecov by Sentry. |
one question: does this pr depend on #3967 ? |
} | ||
|
||
// ExtractTypeSigPubkey extracts tx type, signature, and pubkey | ||
func ExtractTypeSigPubkey(tx *types.Transaction) (iotextypes.Encoding, []byte, crypto.PublicKey, error) { |
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.
split to 2 funcs for clarity
unprotectedTx := "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" | ||
for _, chainID := range []uint32{_evmNetworkID, _evmNetworkID + 1, 0} { | ||
_, _, _, err := DecodeRawTx(unprotectedTx, chainID) | ||
r.Equal(crypto.ErrInvalidKey, err) |
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.
test to verify new unprotected tx will cause error using current code
yes, this PR has now rebased to 3967, pls check again |
err error | ||
) | ||
if g := cs.Genesis(); g.IsSumatra(cs.TipHeight()) { | ||
tx, err = action.DecodeEtherTx(dataStr.String()) |
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.
use new code path after hard-fork
switch txType { | ||
case iotextypes.Encoding_IOTEX_PROTOBUF: | ||
// native tx use same signature format as that of Homestead | ||
return types.HomesteadSigner{}, nil | ||
case iotextypes.Encoding_ETHEREUM_RLP: | ||
case iotextypes.Encoding_ETHEREUM_EIP155: |
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.
iotextypes.Encoding_ETHEREUM_RLP & iotextypes.Encoding_ETHEREUM_PRE_EIP155?
Otherwise, there will be backwards compatibility issue
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.
Encoding_ETHEREUM_UNPROTECTED
is a better name/term, Ethereum call it unprotected tx, and there is Protected() bool
func
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.
there won't be backwards compatibility issue, _EIP155 is an alias of _RLP
Encoding_ETHEREUM_EIP155 == Encoding_ETHEREUM_RLP == 1
the reason to create _EIP155 is because now we have 3 types (all using RLP encoding), so old _RLP is not correct now
"04830579b50e01602c2015c24e72fbc48bca1cca1e601b119ca73abe2e0b5bd61fcb7874567e091030d6b644f927445d80e00b3f9ca0c566c21c30615e94c343da", | ||
"8d38efe45794d7fceea10b2262c23c12245959db", | ||
}, | ||
{ |
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.
what error if integrated with `TestRlpDecodeVerify``
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.
the error is crypto.ErrInvalidKey
, see func TestBackwardComp(t *testing.T)
below (I've added a comment)
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.
ok, could testdata be shared in Var
?
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.
updated in latest commit
@@ -1589,6 +1591,11 @@ func (core *coreService) ActionsInActPool(actHashes []string) ([]action.SealedEn | |||
return ret, nil | |||
} | |||
|
|||
// Genesis returns the genesis of the chain | |||
func (core *coreService) Genesis() genesis.Genesis { | |||
return core.bc.Genesis() |
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.
coreService is the adapter for other services, where Genesis() shouldn't be exposed and tx decoding should be done
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.
tx decoding is for web3 only, gRPC won't use it, so I think tx decoding should be in web3, not coreService
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.
there are some grpc-only interfaces in coreservice as well
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.
ok, but that is not the reason to add another one ... here are my 3 thoughts when adding this to coreService:
- coreService already has existing similar funcs like
ChainID()
,EvmNetworkID()
,TipHeight()
, these actually all belong to theBlockchain()
interface, so I don't see why cannot add a newGenesis()
. We should have another PR to add aBlockchain()
funcs to deprecate these - like you said, we can add a
DecodeTx()
funcs instead ofGenesis()
, but given the facts in 1, doing so does not make our programming better IMO. TheDecodeTx()
is just a wrapper of some calls, it's not simpler or better readable thanGenesis()
- finally, after the hard-fork, we will switch to use the new code path, this
Genesis()
func won't be needed anymore, it will be deleted at that time
Kudos, SonarCloud Quality Gate passed! |
Description
Currently, our chain only supports Ether-compatible tx with EIP-155 signature. This PR adds support for old unprotected tx (before EIP-155)
For more details, see https://iotex.larksuite.com/wiki/QN4RwY6fOilXrWk08VHuj9uGs5d
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: