Skip to content

Commit

Permalink
rpc: Use yParity for non-legacy transactions (erigontech#9574)
Browse files Browse the repository at this point in the history
`v` is not used in any transaction types other than legacy transactions.

Before:
```
{
...
		"type": "0x2",
		"accessList": [],
		"chainId": "0x13881",
		"v": "0x1",
		"r": "0x3b8d9ed8ccda5bc4ab0c9ec6165cec0052b2cf2fc77f19dc1daf6b349174080e",
		"s": "0x222f86d644ad797d9dc1be772adff862cfe499c5113ec3c0e14e0a63c75ca158"
	}
}
```

After:
```
...
		"type": "0x2",
		"accessList": [],
		"chainId": "0x13881",
		"yParity": "0x1",
		"v": "0x1",
		"r": "0x3b8d9ed8ccda5bc4ab0c9ec6165cec0052b2cf2fc77f19dc1daf6b349174080e",
		"s": "0x222f86d644ad797d9dc1be772adff862cfe499c5113ec3c0e14e0a63c75ca158"
	}
}
```
  • Loading branch information
shohamc1 authored and mriccobene committed Mar 13, 2024
1 parent 22b330b commit f13c27f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions turbo/adapter/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ package ethapi
import (
"errors"
"fmt"
"github.com/ledgerwatch/erigon-lib/common/hexutil"
"math/big"

"github.com/ledgerwatch/erigon-lib/common/hexutil"

"github.com/holiman/uint256"
"github.com/ledgerwatch/log/v3"

libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
types2 "github.com/ledgerwatch/erigon-lib/types"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon/accounts/abi"
"github.com/ledgerwatch/erigon/common/math"
Expand Down Expand Up @@ -402,6 +404,7 @@ type RPCTransaction struct {
Accesses *types2.AccessList `json:"accessList,omitempty"`
ChainID *hexutil.Big `json:"chainId,omitempty"`
V *hexutil.Big `json:"v"`
YParity *hexutil.Big `json:"yParity,omitempty"`
R *hexutil.Big `json:"r"`
S *hexutil.Big `json:"s"`

Expand Down Expand Up @@ -440,6 +443,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
chainId.Set(t.ChainID)
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand All @@ -449,6 +453,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.Tip = (*hexutil.Big)(t.Tip.ToBig())
result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand All @@ -460,6 +465,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.Tip = (*hexutil.Big)(t.Tip.ToBig())
result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand Down
4 changes: 4 additions & 0 deletions turbo/jsonrpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ type RPCTransaction struct {
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
V *hexutil.Big `json:"v"`
YParity *hexutil.Big `json:"yParity,omitempty"`
R *hexutil.Big `json:"r"`
S *hexutil.Big `json:"s"`
}
Expand Down Expand Up @@ -409,6 +410,7 @@ func NewRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
chainId.Set(t.ChainID)
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.GasPrice = (*hexutil.Big)(t.GasPrice.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand All @@ -418,6 +420,7 @@ func NewRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.Tip = (*hexutil.Big)(t.Tip.ToBig())
result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand All @@ -428,6 +431,7 @@ func NewRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
result.ChainID = (*hexutil.Big)(chainId.ToBig())
result.Tip = (*hexutil.Big)(t.Tip.ToBig())
result.FeeCap = (*hexutil.Big)(t.FeeCap.ToBig())
result.YParity = (*hexutil.Big)(t.V.ToBig())
result.V = (*hexutil.Big)(t.V.ToBig())
result.R = (*hexutil.Big)(t.R.ToBig())
result.S = (*hexutil.Big)(t.S.ToBig())
Expand Down

0 comments on commit f13c27f

Please sign in to comment.