Skip to content

Commit

Permalink
update tx block base fee, tips,fee cap json fields. (eip1559) (#2237)
Browse files Browse the repository at this point in the history
* update tx block base fee, tips,fee cap json fields. (eip1559)

* gofmt core/types/block.go
  • Loading branch information
dubuqingfeng authored Jun 27, 2021
1 parent ef3e5d3 commit 31cd8af
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/commands/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ type RPCTransaction struct {
From common.Address `json:"from"`
Gas hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
Tip *hexutil.Big `json:"tip,omitempty"`
FeeCap *hexutil.Big `json:"feeCap,omitempty"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
Hash common.Hash `json:"hash"`
Input hexutil.Bytes `json:"input"`
Nonce hexutil.Uint64 `json:"nonce"`
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/commands/trace_adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type TraceCallParam struct {
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Tip *hexutil.Big `json:"tip"`
FeeCap *hexutil.Big `json:"feeCap"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas"`
FeeCap *hexutil.Big `json:"maxFeePerGas"`
Value *hexutil.Big `json:"value"`
Data hexutil.Bytes `json:"data"`
AccessList *types.AccessList `json:"accessList"`
Expand Down
4 changes: 2 additions & 2 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Header struct {
Extra []byte `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"`
Nonce BlockNonce `json:"nonce"`
BaseFee *big.Int `json:"baseFee"`
BaseFee *big.Int `json:"baseFeePerGas"`
Eip1559 bool // to avoid relying on BaseFee != nil for that
Seal [][]byte // AuRa POA network field
WithSeal bool // to avoid relying on Seal != nil for that
Expand Down Expand Up @@ -422,7 +422,7 @@ func (h *Header) DecodeRLP(s *rlp.Stream) error {
_, err := s.List()
if err != nil {
return err
//return fmt.Errorf("open header struct: %w", err)
// return fmt.Errorf("open header struct: %w", err)
}
var b []byte
if b, err = s.Bytes(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type txJSON struct {
// Common transaction fields:
Nonce *hexutil.Uint64 `json:"nonce"`
GasPrice *hexutil.Big `json:"gasPrice"`
FeeCap *hexutil.Big `json:"feeCap"`
Tip *hexutil.Big `json:"tip"`
FeeCap *hexutil.Big `json:"maxFeePerGas"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas"`
Gas *hexutil.Uint64 `json:"gas"`
Value *hexutil.Big `json:"value"`
Data *hexutil.Bytes `json:"input"`
Expand Down
15 changes: 10 additions & 5 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ type CallArgs struct {
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Tip *hexutil.Big `json:"tip"`
FeeCap *hexutil.Big `json:"feeCap"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas"`
FeeCap *hexutil.Big `json:"maxFeePerGas"`
Value *hexutil.Big `json:"value"`
Data *hexutil.Bytes `json:"data"`
AccessList *types.AccessList `json:"accessList"`
Expand Down Expand Up @@ -729,7 +729,7 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {

// RPCMarshalHeader converts the given header to the RPC output .
func RPCMarshalHeader(head *types.Header) map[string]interface{} {
return map[string]interface{}{
result := map[string]interface{}{
"number": (*hexutil.Big)(head.Number),
"hash": head.Hash(),
"parentHash": head.ParentHash,
Expand All @@ -748,6 +748,11 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
"transactionsRoot": head.TxHash,
"receiptsRoot": head.ReceiptHash,
}
if head.BaseFee != nil {
result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
}

return result
}

// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
Expand Down Expand Up @@ -817,8 +822,8 @@ type RPCTransaction struct {
From common.Address `json:"from"`
Gas hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
Tip *hexutil.Big `json:"tip,omitempty"`
FeeCap *hexutil.Big `json:"feeCap,omitempty"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
Hash common.Hash `json:"hash"`
Input hexutil.Bytes `json:"input"`
Nonce hexutil.Uint64 `json:"nonce"`
Expand Down

0 comments on commit 31cd8af

Please sign in to comment.