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

feat: ETH compatibility in Filecoin : Support legacy Homestead Ethereum transactions and legacy EIP-155 transactions in Filecoin #11930

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c95d4b3
poc for eth legacy tx
aarshkshah1992 Apr 25, 2024
369787f
print statements
aarshkshah1992 Apr 25, 2024
fca57fc
finished
aarshkshah1992 Apr 25, 2024
440040e
tests work
aarshkshah1992 Apr 25, 2024
6695369
remove print statements
aarshkshah1992 Apr 25, 2024
9e63361
Remove all print statements
aarshkshah1992 Apr 25, 2024
266826d
remove extraneous changes
aarshkshah1992 Apr 26, 2024
4d01481
cleaned up code and interface
aarshkshah1992 Apr 26, 2024
18fd140
run make jen
aarshkshah1992 Apr 26, 2024
ad2ec8f
dont duplicate signature
aarshkshah1992 Apr 26, 2024
07d248f
go mod tidy and remove prints
aarshkshah1992 Apr 26, 2024
2e66b80
clean up tests
aarshkshah1992 Apr 26, 2024
4be21ff
test for conversion
aarshkshah1992 Apr 26, 2024
f867359
changes as per review
aarshkshah1992 Apr 29, 2024
9265211
more unit tests for legacy txns
aarshkshah1992 Apr 29, 2024
af4c2cd
Apply suggestions from code review
aarshkshah1992 May 1, 2024
8807aed
address review comments from Rodd
aarshkshah1992 May 1, 2024
c62a67d
changes as per zen's 2nd review
aarshkshah1992 May 1, 2024
cd9d63e
Merge branch 'master' into feat/add-support-legacy-eth-tx
aarshkshah1992 May 1, 2024
a0e1801
go mod tidy
aarshkshah1992 May 1, 2024
2a66114
itests passing for 155 tx
aarshkshah1992 May 3, 2024
770d427
first working version for EIP-155 transactions
aarshkshah1992 May 3, 2024
f1df4ce
green itest
aarshkshah1992 May 6, 2024
fd20cd7
add docs
aarshkshah1992 May 6, 2024
a98727b
tests
aarshkshah1992 May 6, 2024
24d9ece
remove print stmt
aarshkshah1992 May 6, 2024
7f202a4
remove print stmt
aarshkshah1992 May 6, 2024
0dfac4b
validate signature
aarshkshah1992 May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,12 @@ workflows:
- build
suite: itest-eth_hash_lookup
target: "./itests/eth_hash_lookup_test.go"
- test:
name: test-itest-eth_legacy_transactions
requires:
- build
suite: itest-eth_legacy_transactions
target: "./itests/eth_legacy_transactions_test.go"
- test:
name: test-itest-eth_transactions
requires:
Expand Down
20 changes: 20 additions & 0 deletions build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -6543,6 +6543,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -6598,6 +6599,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down Expand Up @@ -6738,6 +6743,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -6793,6 +6799,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down Expand Up @@ -6925,6 +6935,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -6980,6 +6991,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down Expand Up @@ -7129,6 +7144,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -7184,6 +7200,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down
10 changes: 10 additions & 0 deletions build/openrpc/gateway.json
Original file line number Diff line number Diff line change
Expand Up @@ -3077,6 +3077,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
ZenGround0 marked this conversation as resolved.
Show resolved Hide resolved
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -3132,6 +3133,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down Expand Up @@ -3281,6 +3286,7 @@
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"gasPrice": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
Expand Down Expand Up @@ -3336,6 +3342,10 @@
"title": "number",
"type": "number"
},
"gasPrice": {
"additionalProperties": false,
"type": "object"
},
"hash": {
"items": {
"description": "Number is a number",
Expand Down
31 changes: 19 additions & 12 deletions chain/consensus/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,41 @@ import (
// must be recognized by the registered verifier for the signature type.
func AuthenticateMessage(msg *types.SignedMessage, signer address.Address) error {
var digest []byte
signatureType := msg.Signature.Type
signatureCopy := msg.Signature

typ := msg.Signature.Type
switch typ {
switch signatureType {
case crypto.SigTypeDelegated:
txArgs, err := ethtypes.EthTxArgsFromUnsignedEthMessage(&msg.Message)
signatureCopy.Data = make([]byte, len(msg.Signature.Data))
copy(signatureCopy.Data, msg.Signature.Data)
ethTx, err := ethtypes.EthTransactionFromSignedFilecoinMessage(msg)
if err != nil {
return xerrors.Errorf("failed to reconstruct eth transaction: %w", err)
return xerrors.Errorf("failed to reconstruct Ethereum transaction: %w", err)
}
roundTripMsg, err := txArgs.ToUnsignedMessage(msg.Message.From)
filecoinMsg, err := ethTx.ToUnsignedFilecoinMessage(msg.Message.From)
if err != nil {
return xerrors.Errorf("failed to reconstruct filecoin msg: %w", err)
return xerrors.Errorf("failed to reconstruct Filecoin message: %w", err)
}

if !msg.Message.Equals(roundTripMsg) {
return xerrors.New("ethereum tx failed to roundtrip")
if !msg.Message.Equals(filecoinMsg) {
return xerrors.New("Ethereum transaction roundtrip mismatch")
}

rlpEncodedMsg, err := txArgs.ToRlpUnsignedMsg()
rlpEncodedMsg, err := ethTx.ToRlpUnsignedMsg()
if err != nil {
return xerrors.Errorf("failed to repack eth rlp message: %w", err)
return xerrors.Errorf("failed to encode RLP message: %w", err)
}
digest = rlpEncodedMsg
signatureCopy.Data, err = ethTx.ToVerifiableSignature(signatureCopy.Data)
if err != nil {
return xerrors.Errorf("failed to verify signature: %w", err)
}
default:
digest = msg.Message.Cid().Bytes()
}

if err := sigs.Verify(&msg.Signature, signer, digest); err != nil {
return xerrors.Errorf("message %s has invalid signature (type %d): %w", msg.Cid(), typ, err)
if err := sigs.Verify(&signatureCopy, signer, digest); err != nil {
return xerrors.Errorf("invalid signature for message %s (type %d): %w", msg.Cid(), signatureType, err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion chain/messagesigner/messagesigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (ms *MessageSigner) dstoreKey(addr address.Address) datastore.Key {

func SigningBytes(msg *types.Message, sigType address.Protocol) ([]byte, error) {
if sigType == address.Delegated {
txArgs, err := ethtypes.EthTxArgsFromUnsignedEthMessage(msg)
txArgs, err := ethtypes.Eth1559TxArgsFromUnsignedFilecoinMessage(msg)
ZenGround0 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, xerrors.Errorf("failed to reconstruct eth transaction: %w", err)
}
Expand Down
Loading
Loading