mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Revert "internal/ethapi: eth API changes needed for 4844 (#27928)"
This reverts commit e93739e06c.
This commit is contained in:
parent
2aa49b926b
commit
691ab8e606
1 changed files with 25 additions and 63 deletions
|
|
@ -1333,18 +1333,15 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1403,28 +1400,26 @@ 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"`
|
||||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
Hash common.Hash `json:"hash"`
|
||||||
Hash common.Hash `json:"hash"`
|
Input hexutil.Bytes `json:"input"`
|
||||||
Input hexutil.Bytes `json:"input"`
|
Nonce hexutil.Uint64 `json:"nonce"`
|
||||||
Nonce hexutil.Uint64 `json:"nonce"`
|
To *common.Address `json:"to"`
|
||||||
To *common.Address `json:"to"`
|
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
||||||
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
Value *hexutil.Big `json:"value"`
|
||||||
Value *hexutil.Big `json:"value"`
|
Type hexutil.Uint64 `json:"type"`
|
||||||
Type hexutil.Uint64 `json:"type"`
|
Accesses *types.AccessList `json:"accessList,omitempty"`
|
||||||
Accesses *types.AccessList `json:"accessList,omitempty"`
|
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
V *hexutil.Big `json:"v"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
R *hexutil.Big `json:"r"`
|
||||||
V *hexutil.Big `json:"v"`
|
S *hexutil.Big `json:"s"`
|
||||||
R *hexutil.Big `json:"r"`
|
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||||
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
|
||||||
|
|
@ -1478,43 +1473,15 @@ 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)
|
||||||
result.GasPrice = (*hexutil.Big)(effectiveGasPrice(tx, baseFee))
|
price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap())
|
||||||
|
result.GasPrice = (*hexutil.Big)(price)
|
||||||
} else {
|
} else {
|
||||||
result.GasPrice = (*hexutil.Big)(tx.GasFeeCap())
|
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 {
|
|
||||||
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 (
|
||||||
|
|
@ -1819,11 +1786,6 @@ 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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue