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

fix: ethrpc: Add missing fields to EthTx #10223

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
4 changes: 3 additions & 1 deletion chain/types/ethtypes/eth_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type EthTx struct {
Gas EthUint64 `json:"gas"`
MaxFeePerGas EthBigInt `json:"maxFeePerGas"`
MaxPriorityFeePerGas EthBigInt `json:"maxPriorityFeePerGas"`
V EthBigInt `json:"v"`
AccessList []EthHash `json:"accessList"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those come from https://eips.ethereum.org/EIPS/eip-2930, which I don't think are supported in FEVM

Given that those aren't possible to specify (?), and optional, I just add the field and keep it empty, which is enough to keep openrpc happy.

V EthBigInt `json:"yParity"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaict what we put here is in fact YParity according to https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2098.md; V is only used for legacy transactions

This value seems to be set to 0/1; not 27/28 which are V values

Not sure if it makes sense to rename the V field to YParity as well, no strong opinions.

Copy link
Contributor

@ychiaoli18 ychiaoli18 Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to rename it to YParity to keep them consistent.

R EthBigInt `json:"r"`
S EthBigInt `json:"s"`
}
Expand Down Expand Up @@ -86,6 +87,7 @@ func EthTxFromSignedEthMessage(smsg *types.SignedMessage) (EthTx, error) {
Gas: EthUint64(txArgs.GasLimit),
MaxFeePerGas: EthBigInt(txArgs.MaxFeePerGas),
MaxPriorityFeePerGas: EthBigInt(txArgs.MaxPriorityFeePerGas),
AccessList: []EthHash{},
V: v,
R: r,
S: s,
Expand Down
15 changes: 12 additions & 3 deletions documentation/en/api-v1-unstable-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,10 @@ Response:
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"v": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
"yParity": "0x0",
"r": "0x0",
"s": "0x0"
}
Expand Down Expand Up @@ -2680,7 +2683,10 @@ Response:
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"v": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
"yParity": "0x0",
"r": "0x0",
"s": "0x0"
}
Expand Down Expand Up @@ -2715,7 +2721,10 @@ Response:
"gas": "0x5",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"v": "0x0",
"accessList": [
"0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e"
],
"yParity": "0x0",
"r": "0x0",
"s": "0x0"
}
Expand Down
12 changes: 3 additions & 9 deletions itests/eth_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ func TestEthOpenRPCConformance(t *testing.T) {
require.NoError(t, err)
defer closer()

const skipUntilIssue10106 = "Skipped until EthTx is updated, see https://github.com/filecoin-project/lotus/issues/10106"

testCases := []struct {
method string
variant string // suffix applied to the test name to distinguish different variants of a method call
Expand Down Expand Up @@ -227,7 +225,6 @@ func TestEthOpenRPCConformance(t *testing.T) {
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetBlockByHash(context.Background(), blockHashWithMessage, true)
},
skipReason: skipUntilIssue10106,
},

{
Expand All @@ -236,7 +233,7 @@ func TestEthOpenRPCConformance(t *testing.T) {
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetBlockByNumber(context.Background(), "earliest", true)
},
skipReason: skipUntilIssue10106,
skipReason: "earliest block is not supported",
},

{
Expand All @@ -245,15 +242,13 @@ func TestEthOpenRPCConformance(t *testing.T) {
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetBlockByNumber(context.Background(), "pending", true)
},
skipReason: skipUntilIssue10106,
},

{
method: "eth_getBlockByNumber",
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetBlockByNumber(context.Background(), blockNumberWithMessage.Hex(), true)
},
skipReason: skipUntilIssue10106,
},

{
Expand Down Expand Up @@ -329,23 +324,22 @@ func TestEthOpenRPCConformance(t *testing.T) {
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetTransactionByBlockHashAndIndex(context.Background(), blockHashWithMessage, ethtypes.EthUint64(0))
},
skipReason: skipUntilIssue10106,
skipReason: "unimplemented",
},

{
method: "eth_getTransactionByBlockNumberAndIndex",
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetTransactionByBlockNumberAndIndex(context.Background(), blockNumberWithMessage, ethtypes.EthUint64(0))
},
skipReason: skipUntilIssue10106,
skipReason: "unimplemented",
},

{
method: "eth_getTransactionByHash",
call: func(a *ethAPIRaw) (json.RawMessage, error) {
return ethapi.EthGetTransactionByHash(context.Background(), &messageWithEvents)
},
skipReason: skipUntilIssue10106,
},

{
Expand Down
1 change: 1 addition & 0 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,7 @@ func ethTxFromNativeMessage(ctx context.Context, msg *types.Message, sa StateAPI
Gas: ethtypes.EthUint64(msg.GasLimit),
MaxFeePerGas: ethtypes.EthBigInt(msg.GasFeeCap),
MaxPriorityFeePerGas: ethtypes.EthBigInt(msg.GasPremium),
AccessList: []ethtypes.EthHash{},
}
}

Expand Down