Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
7dea9c10
Unverified
Commit
7dea9c10
authored
Aug 18, 2023
by
Marius van der Wijden
Committed by
GitHub
Aug 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: eth API changes needed for 4844 (#27928)
Co-authored-by:
Felix Lange
<
fjl@twurst.com
>
parent
950ccddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
25 deletions
+63
-25
api.go
internal/ethapi/api.go
+63
-25
No files found.
internal/ethapi/api.go
View file @
7dea9c10
...
@@ -1333,15 +1333,18 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
...
@@ -1333,15 +1333,18 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
"transactionsRoot"
:
head
.
TxHash
,
"transactionsRoot"
:
head
.
TxHash
,
"receiptsRoot"
:
head
.
ReceiptHash
,
"receiptsRoot"
:
head
.
ReceiptHash
,
}
}
if
head
.
BaseFee
!=
nil
{
if
head
.
BaseFee
!=
nil
{
result
[
"baseFeePerGas"
]
=
(
*
hexutil
.
Big
)(
head
.
BaseFee
)
result
[
"baseFeePerGas"
]
=
(
*
hexutil
.
Big
)(
head
.
BaseFee
)
}
}
if
head
.
WithdrawalsHash
!=
nil
{
if
head
.
WithdrawalsHash
!=
nil
{
result
[
"withdrawalsRoot"
]
=
head
.
WithdrawalsHash
result
[
"withdrawalsRoot"
]
=
head
.
WithdrawalsHash
}
}
if
head
.
BlobGasUsed
!=
nil
{
result
[
"blobGasUsed"
]
=
hexutil
.
Uint64
(
*
head
.
BlobGasUsed
)
}
if
head
.
ExcessBlobGas
!=
nil
{
result
[
"excessBlobGas"
]
=
hexutil
.
Uint64
(
*
head
.
ExcessBlobGas
)
}
return
result
return
result
}
}
...
@@ -1400,26 +1403,28 @@ func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inc
...
@@ -1400,26 +1403,28 @@ func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inc
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
type
RPCTransaction
struct
{
type
RPCTransaction
struct
{
BlockHash
*
common
.
Hash
`json:"blockHash"`
BlockHash
*
common
.
Hash
`json:"blockHash"`
BlockNumber
*
hexutil
.
Big
`json:"blockNumber"`
BlockNumber
*
hexutil
.
Big
`json:"blockNumber"`
From
common
.
Address
`json:"from"`
From
common
.
Address
`json:"from"`
Gas
hexutil
.
Uint64
`json:"gas"`
Gas
hexutil
.
Uint64
`json:"gas"`
GasPrice
*
hexutil
.
Big
`json:"gasPrice"`
GasPrice
*
hexutil
.
Big
`json:"gasPrice"`
GasFeeCap
*
hexutil
.
Big
`json:"maxFeePerGas,omitempty"`
GasFeeCap
*
hexutil
.
Big
`json:"maxFeePerGas,omitempty"`
GasTipCap
*
hexutil
.
Big
`json:"maxPriorityFeePerGas,omitempty"`
GasTipCap
*
hexutil
.
Big
`json:"maxPriorityFeePerGas,omitempty"`
Hash
common
.
Hash
`json:"hash"`
MaxFeePerBlobGas
*
hexutil
.
Big
`json:"maxFeePerBlobGas,omitempty"`
Input
hexutil
.
Bytes
`json:"input"`
Hash
common
.
Hash
`json:"hash"`
Nonce
hexutil
.
Uint64
`json:"nonce"`
Input
hexutil
.
Bytes
`json:"input"`
To
*
common
.
Address
`json:"to"`
Nonce
hexutil
.
Uint64
`json:"nonce"`
TransactionIndex
*
hexutil
.
Uint64
`json:"transactionIndex"`
To
*
common
.
Address
`json:"to"`
Value
*
hexutil
.
Big
`json:"value"`
TransactionIndex
*
hexutil
.
Uint64
`json:"transactionIndex"`
Type
hexutil
.
Uint64
`json:"type"`
Value
*
hexutil
.
Big
`json:"value"`
Accesses
*
types
.
AccessList
`json:"accessList,omitempty"`
Type
hexutil
.
Uint64
`json:"type"`
ChainID
*
hexutil
.
Big
`json:"chainId,omitempty"`
Accesses
*
types
.
AccessList
`json:"accessList,omitempty"`
V
*
hexutil
.
Big
`json:"v"`
ChainID
*
hexutil
.
Big
`json:"chainId,omitempty"`
R
*
hexutil
.
Big
`json:"r"`
BlobVersionedHashes
[]
common
.
Hash
`json:"blobVersionedHashes,omitempty"`
S
*
hexutil
.
Big
`json:"s"`
V
*
hexutil
.
Big
`json:"v"`
YParity
*
hexutil
.
Uint64
`json:"yParity,omitempty"`
R
*
hexutil
.
Big
`json:"r"`
S
*
hexutil
.
Big
`json:"s"`
YParity
*
hexutil
.
Uint64
`json:"yParity,omitempty"`
}
}
// newRPCTransaction returns a transaction that will serialize to the RPC
// newRPCTransaction returns a transaction that will serialize to the RPC
...
@@ -1473,15 +1478,43 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
...
@@ -1473,15 +1478,43 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
// if the transaction has been mined, compute the effective gas price
// if the transaction has been mined, compute the effective gas price
if
baseFee
!=
nil
&&
blockHash
!=
(
common
.
Hash
{})
{
if
baseFee
!=
nil
&&
blockHash
!=
(
common
.
Hash
{})
{
// price = min(gasTipCap + baseFee, gasFeeCap)
// price = min(gasTipCap + baseFee, gasFeeCap)
price
:=
math
.
BigMin
(
new
(
big
.
Int
)
.
Add
(
tx
.
GasTipCap
(),
baseFee
),
tx
.
GasFeeCap
())
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
effectiveGasPrice
(
tx
,
baseFee
))
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
price
)
}
else
{
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
tx
.
GasFeeCap
())
}
case
types
.
BlobTxType
:
al
:=
tx
.
AccessList
()
yparity
:=
hexutil
.
Uint64
(
v
.
Sign
())
result
.
Accesses
=
&
al
result
.
ChainID
=
(
*
hexutil
.
Big
)(
tx
.
ChainId
())
result
.
YParity
=
&
yparity
result
.
GasFeeCap
=
(
*
hexutil
.
Big
)(
tx
.
GasFeeCap
())
result
.
GasTipCap
=
(
*
hexutil
.
Big
)(
tx
.
GasTipCap
())
// if the transaction has been mined, compute the effective gas price
if
baseFee
!=
nil
&&
blockHash
!=
(
common
.
Hash
{})
{
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
effectiveGasPrice
(
tx
,
baseFee
))
}
else
{
}
else
{
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
tx
.
GasFeeCap
())
result
.
GasPrice
=
(
*
hexutil
.
Big
)(
tx
.
GasFeeCap
())
}
}
result
.
MaxFeePerBlobGas
=
(
*
hexutil
.
Big
)(
tx
.
BlobGasFeeCap
())
result
.
BlobVersionedHashes
=
tx
.
BlobHashes
()
}
}
return
result
return
result
}
}
// effectiveGasPrice computes the transaction gas fee, based on the given basefee value.
//
// price = min(gasTipCap + baseFee, gasFeeCap)
func
effectiveGasPrice
(
tx
*
types
.
Transaction
,
baseFee
*
big
.
Int
)
*
big
.
Int
{
fee
:=
tx
.
GasTipCap
()
fee
=
fee
.
Add
(
fee
,
baseFee
)
if
tx
.
GasTipCapIntCmp
(
fee
)
<
0
{
return
tx
.
GasTipCap
()
}
return
fee
}
// NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
// NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
func
NewRPCPendingTransaction
(
tx
*
types
.
Transaction
,
current
*
types
.
Header
,
config
*
params
.
ChainConfig
)
*
RPCTransaction
{
func
NewRPCPendingTransaction
(
tx
*
types
.
Transaction
,
current
*
types
.
Header
,
config
*
params
.
ChainConfig
)
*
RPCTransaction
{
var
(
var
(
...
@@ -1786,6 +1819,11 @@ func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber u
...
@@ -1786,6 +1819,11 @@ func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber u
fields
[
"logs"
]
=
[]
*
types
.
Log
{}
fields
[
"logs"
]
=
[]
*
types
.
Log
{}
}
}
if
tx
.
Type
()
==
types
.
BlobTxType
{
fields
[
"blobGasUsed"
]
=
hexutil
.
Uint64
(
receipt
.
BlobGasUsed
)
fields
[
"blobGasPrice"
]
=
(
*
hexutil
.
Big
)(
receipt
.
BlobGasPrice
)
}
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
if
receipt
.
ContractAddress
!=
(
common
.
Address
{})
{
if
receipt
.
ContractAddress
!=
(
common
.
Address
{})
{
fields
[
"contractAddress"
]
=
receipt
.
ContractAddress
fields
[
"contractAddress"
]
=
receipt
.
ContractAddress
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment