mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
output hex values instead of numbers
This commit is contained in:
parent
b07ef33e95
commit
e4a2c82af2
4 changed files with 156 additions and 42 deletions
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/consensus/beacon"
|
"github.com/ethereum/go-ethereum/consensus/beacon"
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
|
@ -43,15 +44,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type supplyInfoIssuance struct {
|
type supplyInfoIssuance struct {
|
||||||
GenesisAlloc *big.Int `json:"genesisAlloc,omitempty"`
|
GenesisAlloc *hexutil.Big `json:"genesisAlloc,omitempty"`
|
||||||
Reward *big.Int `json:"reward"`
|
Reward *hexutil.Big `json:"reward"`
|
||||||
Withdrawals *big.Int `json:"withdrawals"`
|
Withdrawals *hexutil.Big `json:"withdrawals"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type supplyInfoBurn struct {
|
type supplyInfoBurn struct {
|
||||||
EIP1559 *big.Int `json:"1559"`
|
EIP1559 *hexutil.Big `json:"1559"`
|
||||||
Blob *big.Int `json:"blob"`
|
Blob *hexutil.Big `json:"blob"`
|
||||||
Misc *big.Int `json:"misc"`
|
Misc *hexutil.Big `json:"misc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type supplyInfo struct {
|
type supplyInfo struct {
|
||||||
|
|
@ -87,14 +88,14 @@ func TestSupplyGenesisAlloc(t *testing.T) {
|
||||||
|
|
||||||
expected := supplyInfo{
|
expected := supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
GenesisAlloc: new(big.Int).Mul(common.Big2, big.NewInt(params.Ether)),
|
GenesisAlloc: (*hexutil.Big)(new(big.Int).Mul(common.Big2, big.NewInt(params.Ether))),
|
||||||
Reward: common.Big0,
|
Reward: (*hexutil.Big)(common.Big0),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: common.Big0,
|
EIP1559: (*hexutil.Big)(common.Big0),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: common.Big0,
|
Misc: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Number: 0,
|
Number: 0,
|
||||||
Hash: common.HexToHash("0xbcc9466e9fc6a8b56f4b29ca353a421ff8b51a0c1a58ca4743b427605b08f2ca"),
|
Hash: common.HexToHash("0xbcc9466e9fc6a8b56f4b29ca353a421ff8b51a0c1a58ca4743b427605b08f2ca"),
|
||||||
|
|
@ -122,13 +123,13 @@ func TestSupplyRewards(t *testing.T) {
|
||||||
|
|
||||||
expected := supplyInfo{
|
expected := supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: new(big.Int).Mul(common.Big2, big.NewInt(params.Ether)),
|
Reward: (*hexutil.Big)(new(big.Int).Mul(common.Big2, big.NewInt(params.Ether))),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: common.Big0,
|
EIP1559: (*hexutil.Big)(common.Big0),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: common.Big0,
|
Misc: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: common.HexToHash("0xcbb08370505be503dafedc4e96d139ea27aba3cbc580148568b8a307b3f51052"),
|
Hash: common.HexToHash("0xcbb08370505be503dafedc4e96d139ea27aba3cbc580148568b8a307b3f51052"),
|
||||||
|
|
@ -192,13 +193,13 @@ func TestSupplyEip1559Burn(t *testing.T) {
|
||||||
burn = new(big.Int).Mul(big.NewInt(21000), head.BaseFee)
|
burn = new(big.Int).Mul(big.NewInt(21000), head.BaseFee)
|
||||||
expected = supplyInfo{
|
expected = supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: reward,
|
Reward: (*hexutil.Big)(reward),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: burn,
|
EIP1559: (*hexutil.Big)(burn),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: common.Big0,
|
Misc: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: head.Hash(),
|
Hash: head.Hash(),
|
||||||
|
|
@ -237,13 +238,13 @@ func TestSupplyWithdrawals(t *testing.T) {
|
||||||
head = chain.CurrentBlock()
|
head = chain.CurrentBlock()
|
||||||
expected = supplyInfo{
|
expected = supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: common.Big0,
|
Reward: (*hexutil.Big)(common.Big0),
|
||||||
Withdrawals: big.NewInt(1337000000000),
|
Withdrawals: (*hexutil.Big)(big.NewInt(1337000000000)),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: common.Big0,
|
EIP1559: (*hexutil.Big)(common.Big0),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: common.Big0,
|
Misc: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: head.Hash(),
|
Hash: head.Hash(),
|
||||||
|
|
@ -338,13 +339,13 @@ func TestSupplySelfdestruct(t *testing.T) {
|
||||||
// Check live trace output
|
// Check live trace output
|
||||||
expected := supplyInfo{
|
expected := supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: common.Big0,
|
Reward: (*hexutil.Big)(common.Big0),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: big.NewInt(55289500000000),
|
EIP1559: (*hexutil.Big)(big.NewInt(55289500000000)),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: big.NewInt(5000000000),
|
Misc: (*hexutil.Big)(big.NewInt(5000000000)),
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: head.Hash(),
|
Hash: head.Hash(),
|
||||||
|
|
@ -384,13 +385,13 @@ func TestSupplySelfdestruct(t *testing.T) {
|
||||||
head = postCancunChain.CurrentBlock()
|
head = postCancunChain.CurrentBlock()
|
||||||
expected = supplyInfo{
|
expected = supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: common.Big0,
|
Reward: (*hexutil.Big)(common.Big0),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: big.NewInt(55289500000000),
|
EIP1559: (*hexutil.Big)(big.NewInt(55289500000000)),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: common.Big0,
|
Misc: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: head.Hash(),
|
Hash: head.Hash(),
|
||||||
|
|
@ -535,13 +536,13 @@ func TestSupplySelfdestructItselfAndRevert(t *testing.T) {
|
||||||
|
|
||||||
expected := supplyInfo{
|
expected := supplyInfo{
|
||||||
Issuance: &supplyInfoIssuance{
|
Issuance: &supplyInfoIssuance{
|
||||||
Reward: common.Big0,
|
Reward: (*hexutil.Big)(common.Big0),
|
||||||
Withdrawals: common.Big0,
|
Withdrawals: (*hexutil.Big)(common.Big0),
|
||||||
},
|
},
|
||||||
Burn: &supplyInfoBurn{
|
Burn: &supplyInfoBurn{
|
||||||
EIP1559: new(big.Int).Mul(block.BaseFee(), big.NewInt(int64(block.GasUsed()))),
|
EIP1559: (*hexutil.Big)(new(big.Int).Mul(block.BaseFee(), big.NewInt(int64(block.GasUsed())))),
|
||||||
Blob: common.Big0,
|
Blob: (*hexutil.Big)(common.Big0),
|
||||||
Misc: eth5, // 5ETH burned from contract B
|
Misc: (*hexutil.Big)(eth5), // 5ETH burned from contract B
|
||||||
},
|
},
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Hash: block.Hash(),
|
Hash: block.Hash(),
|
||||||
|
|
|
||||||
49
eth/tracers/live/gen_supplyinfoburn.go
Normal file
49
eth/tracers/live/gen_supplyinfoburn.go
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||||
|
|
||||||
|
package live
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = (*supplyInfoBurnMarshaling)(nil)
|
||||||
|
|
||||||
|
// MarshalJSON marshals as JSON.
|
||||||
|
func (s supplyInfoBurn) MarshalJSON() ([]byte, error) {
|
||||||
|
type supplyInfoBurn struct {
|
||||||
|
EIP1559 *hexutil.Big `json:"1559"`
|
||||||
|
Blob *hexutil.Big `json:"blob"`
|
||||||
|
Misc *hexutil.Big `json:"misc"`
|
||||||
|
}
|
||||||
|
var enc supplyInfoBurn
|
||||||
|
enc.EIP1559 = (*hexutil.Big)(s.EIP1559)
|
||||||
|
enc.Blob = (*hexutil.Big)(s.Blob)
|
||||||
|
enc.Misc = (*hexutil.Big)(s.Misc)
|
||||||
|
return json.Marshal(&enc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals from JSON.
|
||||||
|
func (s *supplyInfoBurn) UnmarshalJSON(input []byte) error {
|
||||||
|
type supplyInfoBurn struct {
|
||||||
|
EIP1559 *hexutil.Big `json:"1559"`
|
||||||
|
Blob *hexutil.Big `json:"blob"`
|
||||||
|
Misc *hexutil.Big `json:"misc"`
|
||||||
|
}
|
||||||
|
var dec supplyInfoBurn
|
||||||
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if dec.EIP1559 != nil {
|
||||||
|
s.EIP1559 = (*big.Int)(dec.EIP1559)
|
||||||
|
}
|
||||||
|
if dec.Blob != nil {
|
||||||
|
s.Blob = (*big.Int)(dec.Blob)
|
||||||
|
}
|
||||||
|
if dec.Misc != nil {
|
||||||
|
s.Misc = (*big.Int)(dec.Misc)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
49
eth/tracers/live/gen_supplyinfoissuance.go
Normal file
49
eth/tracers/live/gen_supplyinfoissuance.go
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||||
|
|
||||||
|
package live
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = (*supplyInfoIssuanceMarshaling)(nil)
|
||||||
|
|
||||||
|
// MarshalJSON marshals as JSON.
|
||||||
|
func (s supplyInfoIssuance) MarshalJSON() ([]byte, error) {
|
||||||
|
type supplyInfoIssuance struct {
|
||||||
|
GenesisAlloc *hexutil.Big `json:"genesisAlloc,omitempty"`
|
||||||
|
Reward *hexutil.Big `json:"reward"`
|
||||||
|
Withdrawals *hexutil.Big `json:"withdrawals"`
|
||||||
|
}
|
||||||
|
var enc supplyInfoIssuance
|
||||||
|
enc.GenesisAlloc = (*hexutil.Big)(s.GenesisAlloc)
|
||||||
|
enc.Reward = (*hexutil.Big)(s.Reward)
|
||||||
|
enc.Withdrawals = (*hexutil.Big)(s.Withdrawals)
|
||||||
|
return json.Marshal(&enc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals from JSON.
|
||||||
|
func (s *supplyInfoIssuance) UnmarshalJSON(input []byte) error {
|
||||||
|
type supplyInfoIssuance struct {
|
||||||
|
GenesisAlloc *hexutil.Big `json:"genesisAlloc,omitempty"`
|
||||||
|
Reward *hexutil.Big `json:"reward"`
|
||||||
|
Withdrawals *hexutil.Big `json:"withdrawals"`
|
||||||
|
}
|
||||||
|
var dec supplyInfoIssuance
|
||||||
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if dec.GenesisAlloc != nil {
|
||||||
|
s.GenesisAlloc = (*big.Int)(dec.GenesisAlloc)
|
||||||
|
}
|
||||||
|
if dec.Reward != nil {
|
||||||
|
s.Reward = (*big.Int)(dec.Reward)
|
||||||
|
}
|
||||||
|
if dec.Withdrawals != nil {
|
||||||
|
s.Withdrawals = (*big.Int)(dec.Withdrawals)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
@ -27,12 +28,26 @@ type supplyInfoIssuance struct {
|
||||||
Withdrawals *big.Int `json:"withdrawals"`
|
Withdrawals *big.Int `json:"withdrawals"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:generate go run github.com/fjl/gencodec -type supplyInfoIssuance -field-override supplyInfoIssuanceMarshaling -out gen_supplyinfoissuance.go
|
||||||
|
type supplyInfoIssuanceMarshaling struct {
|
||||||
|
GenesisAlloc *hexutil.Big
|
||||||
|
Reward *hexutil.Big
|
||||||
|
Withdrawals *hexutil.Big
|
||||||
|
}
|
||||||
|
|
||||||
type supplyInfoBurn struct {
|
type supplyInfoBurn struct {
|
||||||
EIP1559 *big.Int `json:"1559"`
|
EIP1559 *big.Int `json:"1559"`
|
||||||
Blob *big.Int `json:"blob"`
|
Blob *big.Int `json:"blob"`
|
||||||
Misc *big.Int `json:"misc"`
|
Misc *big.Int `json:"misc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:generate go run github.com/fjl/gencodec -type supplyInfoBurn -field-override supplyInfoBurnMarshaling -out gen_supplyinfoburn.go
|
||||||
|
type supplyInfoBurnMarshaling struct {
|
||||||
|
EIP1559 *hexutil.Big
|
||||||
|
Blob *hexutil.Big
|
||||||
|
Misc *hexutil.Big
|
||||||
|
}
|
||||||
|
|
||||||
type supplyInfo struct {
|
type supplyInfo struct {
|
||||||
Issuance *supplyInfoIssuance `json:"issuance"`
|
Issuance *supplyInfoIssuance `json:"issuance"`
|
||||||
Burn *supplyInfoBurn `json:"burn"`
|
Burn *supplyInfoBurn `json:"burn"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue