forked from cerc-io/plugeth
Merge pull request #20339 from etclabscore/fix/cmd-puppeth-blocknonce-type
cmd/puppeth: x-spec nonce data type, use types.BlockNonce
This commit is contained in:
commit
7be89a7a01
@ -17,7 +17,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -28,6 +27,7 @@ import (
|
|||||||
math2 "github.com/ethereum/go-ethereum/common/math"
|
math2 "github.com/ethereum/go-ethereum/common/math"
|
||||||
"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"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ type alethGenesisSpec struct {
|
|||||||
} `json:"params"`
|
} `json:"params"`
|
||||||
|
|
||||||
Genesis struct {
|
Genesis struct {
|
||||||
Nonce hexutil.Bytes `json:"nonce"`
|
Nonce types.BlockNonce `json:"nonce"`
|
||||||
Difficulty *hexutil.Big `json:"difficulty"`
|
Difficulty *hexutil.Big `json:"difficulty"`
|
||||||
MixHash common.Hash `json:"mixHash"`
|
MixHash common.Hash `json:"mixHash"`
|
||||||
Author common.Address `json:"author"`
|
Author common.Address `json:"author"`
|
||||||
@ -146,9 +146,7 @@ func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSp
|
|||||||
spec.Params.DurationLimit = (*math2.HexOrDecimal256)(params.DurationLimit)
|
spec.Params.DurationLimit = (*math2.HexOrDecimal256)(params.DurationLimit)
|
||||||
spec.Params.BlockReward = (*hexutil.Big)(ethash.FrontierBlockReward)
|
spec.Params.BlockReward = (*hexutil.Big)(ethash.FrontierBlockReward)
|
||||||
|
|
||||||
spec.Genesis.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
spec.Genesis.Nonce = types.EncodeNonce(genesis.Nonce)
|
||||||
binary.LittleEndian.PutUint64(spec.Genesis.Nonce[:], genesis.Nonce)
|
|
||||||
|
|
||||||
spec.Genesis.MixHash = genesis.Mixhash
|
spec.Genesis.MixHash = genesis.Mixhash
|
||||||
spec.Genesis.Difficulty = (*hexutil.Big)(genesis.Difficulty)
|
spec.Genesis.Difficulty = (*hexutil.Big)(genesis.Difficulty)
|
||||||
spec.Genesis.Author = genesis.Coinbase
|
spec.Genesis.Author = genesis.Coinbase
|
||||||
@ -278,7 +276,7 @@ type parityChainSpec struct {
|
|||||||
Genesis struct {
|
Genesis struct {
|
||||||
Seal struct {
|
Seal struct {
|
||||||
Ethereum struct {
|
Ethereum struct {
|
||||||
Nonce hexutil.Bytes `json:"nonce"`
|
Nonce types.BlockNonce `json:"nonce"`
|
||||||
MixHash hexutil.Bytes `json:"mixHash"`
|
MixHash hexutil.Bytes `json:"mixHash"`
|
||||||
} `json:"ethereum"`
|
} `json:"ethereum"`
|
||||||
} `json:"seal"`
|
} `json:"seal"`
|
||||||
@ -426,10 +424,8 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
|
|||||||
// Disable this one
|
// Disable this one
|
||||||
spec.Params.EIP98Transition = math.MaxInt64
|
spec.Params.EIP98Transition = math.MaxInt64
|
||||||
|
|
||||||
spec.Genesis.Seal.Ethereum.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
spec.Genesis.Seal.Ethereum.Nonce = types.EncodeNonce(genesis.Nonce)
|
||||||
binary.LittleEndian.PutUint64(spec.Genesis.Seal.Ethereum.Nonce[:], genesis.Nonce)
|
spec.Genesis.Seal.Ethereum.MixHash = (genesis.Mixhash[:])
|
||||||
|
|
||||||
spec.Genesis.Seal.Ethereum.MixHash = (hexutil.Bytes)(genesis.Mixhash[:])
|
|
||||||
spec.Genesis.Difficulty = (*hexutil.Big)(genesis.Difficulty)
|
spec.Genesis.Difficulty = (*hexutil.Big)(genesis.Difficulty)
|
||||||
spec.Genesis.Author = genesis.Coinbase
|
spec.Genesis.Author = genesis.Coinbase
|
||||||
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
|
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
|
||||||
@ -597,7 +593,7 @@ func (spec *parityChainSpec) setIstanbul(num *big.Int) {
|
|||||||
// pyEthereumGenesisSpec represents the genesis specification format used by the
|
// pyEthereumGenesisSpec represents the genesis specification format used by the
|
||||||
// Python Ethereum implementation.
|
// Python Ethereum implementation.
|
||||||
type pyEthereumGenesisSpec struct {
|
type pyEthereumGenesisSpec struct {
|
||||||
Nonce hexutil.Bytes `json:"nonce"`
|
Nonce types.BlockNonce `json:"nonce"`
|
||||||
Timestamp hexutil.Uint64 `json:"timestamp"`
|
Timestamp hexutil.Uint64 `json:"timestamp"`
|
||||||
ExtraData hexutil.Bytes `json:"extraData"`
|
ExtraData hexutil.Bytes `json:"extraData"`
|
||||||
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
||||||
@ -616,6 +612,7 @@ func newPyEthereumGenesisSpec(network string, genesis *core.Genesis) (*pyEthereu
|
|||||||
return nil, errors.New("unsupported consensus engine")
|
return nil, errors.New("unsupported consensus engine")
|
||||||
}
|
}
|
||||||
spec := &pyEthereumGenesisSpec{
|
spec := &pyEthereumGenesisSpec{
|
||||||
|
Nonce: types.EncodeNonce(genesis.Nonce),
|
||||||
Timestamp: (hexutil.Uint64)(genesis.Timestamp),
|
Timestamp: (hexutil.Uint64)(genesis.Timestamp),
|
||||||
ExtraData: genesis.ExtraData,
|
ExtraData: genesis.ExtraData,
|
||||||
GasLimit: (hexutil.Uint64)(genesis.GasLimit),
|
GasLimit: (hexutil.Uint64)(genesis.GasLimit),
|
||||||
@ -625,8 +622,5 @@ func newPyEthereumGenesisSpec(network string, genesis *core.Genesis) (*pyEthereu
|
|||||||
Alloc: genesis.Alloc,
|
Alloc: genesis.Alloc,
|
||||||
ParentHash: genesis.ParentHash,
|
ParentHash: genesis.ParentHash,
|
||||||
}
|
}
|
||||||
spec.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
|
||||||
binary.LittleEndian.PutUint64(spec.Nonce[:], genesis.Nonce)
|
|
||||||
|
|
||||||
return spec, nil
|
return spec, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user