mirror of https://github.com/ethereum/go-ethereum
cmd/evm: add b11r tool (#23843)
evm block-builder (a.k.a b11r) is a utility to help assemble blocks, for use during the test-creation process.pull/23576/head
parent
5d4bcbc14f
commit
441c7f2b0f
@ -0,0 +1,380 @@ |
||||
// Copyright 2021 The go-ethereum Authors
|
||||
// This file is part of go-ethereum.
|
||||
//
|
||||
// go-ethereum is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// go-ethereum is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package t8ntool |
||||
|
||||
import ( |
||||
"crypto/ecdsa" |
||||
"encoding/json" |
||||
"errors" |
||||
"fmt" |
||||
"math/big" |
||||
"os" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
"github.com/ethereum/go-ethereum/common/math" |
||||
"github.com/ethereum/go-ethereum/consensus/clique" |
||||
"github.com/ethereum/go-ethereum/consensus/ethash" |
||||
"github.com/ethereum/go-ethereum/core/types" |
||||
"github.com/ethereum/go-ethereum/crypto" |
||||
"github.com/ethereum/go-ethereum/log" |
||||
"github.com/ethereum/go-ethereum/rlp" |
||||
"gopkg.in/urfave/cli.v1" |
||||
) |
||||
|
||||
//go:generate gencodec -type header -field-override headerMarshaling -out gen_header.go
|
||||
type header struct { |
||||
ParentHash common.Hash `json:"parentHash"` |
||||
OmmerHash *common.Hash `json:"sha3Uncles"` |
||||
Coinbase *common.Address `json:"miner"` |
||||
Root common.Hash `json:"stateRoot" gencodec:"required"` |
||||
TxHash *common.Hash `json:"transactionsRoot"` |
||||
ReceiptHash *common.Hash `json:"receiptsRoot"` |
||||
Bloom types.Bloom `json:"logsBloom"` |
||||
Difficulty *big.Int `json:"difficulty"` |
||||
Number *big.Int `json:"number" gencodec:"required"` |
||||
GasLimit uint64 `json:"gasLimit" gencodec:"required"` |
||||
GasUsed uint64 `json:"gasUsed"` |
||||
Time uint64 `json:"timestamp" gencodec:"required"` |
||||
Extra []byte `json:"extraData"` |
||||
MixDigest common.Hash `json:"mixHash"` |
||||
Nonce *types.BlockNonce `json:"nonce"` |
||||
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` |
||||
} |
||||
|
||||
type headerMarshaling struct { |
||||
Difficulty *math.HexOrDecimal256 |
||||
Number *math.HexOrDecimal256 |
||||
GasLimit math.HexOrDecimal64 |
||||
GasUsed math.HexOrDecimal64 |
||||
Time math.HexOrDecimal64 |
||||
Extra hexutil.Bytes |
||||
BaseFee *math.HexOrDecimal256 |
||||
} |
||||
|
||||
type bbInput struct { |
||||
Header *header `json:"header,omitempty"` |
||||
OmmersRlp []string `json:"ommers,omitempty"` |
||||
TxRlp string `json:"txs,omitempty"` |
||||
Clique *cliqueInput `json:"clique,omitempty"` |
||||
|
||||
Ethash bool `json:"-"` |
||||
EthashDir string `json:"-"` |
||||
PowMode ethash.Mode `json:"-"` |
||||
Txs []*types.Transaction `json:"-"` |
||||
Ommers []*types.Header `json:"-"` |
||||
} |
||||
|
||||
type cliqueInput struct { |
||||
Key *ecdsa.PrivateKey |
||||
Voted *common.Address |
||||
Authorize *bool |
||||
Vanity common.Hash |
||||
} |
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler interface.
|
||||
func (c *cliqueInput) UnmarshalJSON(input []byte) error { |
||||
var x struct { |
||||
Key *common.Hash `json:"secretKey"` |
||||
Voted *common.Address `json:"voted"` |
||||
Authorize *bool `json:"authorize"` |
||||
Vanity common.Hash `json:"vanity"` |
||||
} |
||||
if err := json.Unmarshal(input, &x); err != nil { |
||||
return err |
||||
} |
||||
if x.Key == nil { |
||||
return errors.New("missing required field 'secretKey' for cliqueInput") |
||||
} |
||||
if ecdsaKey, err := crypto.ToECDSA(x.Key[:]); err != nil { |
||||
return err |
||||
} else { |
||||
c.Key = ecdsaKey |
||||
} |
||||
c.Voted = x.Voted |
||||
c.Authorize = x.Authorize |
||||
c.Vanity = x.Vanity |
||||
return nil |
||||
} |
||||
|
||||
// ToBlock converts i into a *types.Block
|
||||
func (i *bbInput) ToBlock() *types.Block { |
||||
header := &types.Header{ |
||||
ParentHash: i.Header.ParentHash, |
||||
UncleHash: types.EmptyUncleHash, |
||||
Coinbase: common.Address{}, |
||||
Root: i.Header.Root, |
||||
TxHash: types.EmptyRootHash, |
||||
ReceiptHash: types.EmptyRootHash, |
||||
Bloom: i.Header.Bloom, |
||||
Difficulty: common.Big0, |
||||
Number: i.Header.Number, |
||||
GasLimit: i.Header.GasLimit, |
||||
GasUsed: i.Header.GasUsed, |
||||
Time: i.Header.Time, |
||||
Extra: i.Header.Extra, |
||||
MixDigest: i.Header.MixDigest, |
||||
BaseFee: i.Header.BaseFee, |
||||
} |
||||
|
||||
// Fill optional values.
|
||||
if i.Header.OmmerHash != nil { |
||||
header.UncleHash = *i.Header.OmmerHash |
||||
} else if len(i.Ommers) != 0 { |
||||
// Calculate the ommer hash if none is provided and there are ommers to hash
|
||||
header.UncleHash = types.CalcUncleHash(i.Ommers) |
||||
} |
||||
if i.Header.Coinbase != nil { |
||||
header.Coinbase = *i.Header.Coinbase |
||||
} |
||||
if i.Header.TxHash != nil { |
||||
header.TxHash = *i.Header.TxHash |
||||
} |
||||
if i.Header.ReceiptHash != nil { |
||||
header.ReceiptHash = *i.Header.ReceiptHash |
||||
} |
||||
if i.Header.Nonce != nil { |
||||
header.Nonce = *i.Header.Nonce |
||||
} |
||||
if header.Difficulty != nil { |
||||
header.Difficulty = i.Header.Difficulty |
||||
} |
||||
return types.NewBlockWithHeader(header).WithBody(i.Txs, i.Ommers) |
||||
} |
||||
|
||||
// SealBlock seals the given block using the configured engine.
|
||||
func (i *bbInput) SealBlock(block *types.Block) (*types.Block, error) { |
||||
switch { |
||||
case i.Ethash: |
||||
return i.sealEthash(block) |
||||
case i.Clique != nil: |
||||
return i.sealClique(block) |
||||
default: |
||||
return block, nil |
||||
} |
||||
} |
||||
|
||||
// sealEthash seals the given block using ethash.
|
||||
func (i *bbInput) sealEthash(block *types.Block) (*types.Block, error) { |
||||
if i.Header.Nonce != nil { |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("sealing with ethash will overwrite provided nonce")) |
||||
} |
||||
ethashConfig := ethash.Config{ |
||||
PowMode: i.PowMode, |
||||
DatasetDir: i.EthashDir, |
||||
CacheDir: i.EthashDir, |
||||
DatasetsInMem: 1, |
||||
DatasetsOnDisk: 2, |
||||
CachesInMem: 2, |
||||
CachesOnDisk: 3, |
||||
} |
||||
engine := ethash.New(ethashConfig, nil, true) |
||||
defer engine.Close() |
||||
// Use a buffered chan for results.
|
||||
// If the testmode is used, the sealer will return quickly, and complain
|
||||
// "Sealing result is not read by miner" if it cannot write the result.
|
||||
results := make(chan *types.Block, 1) |
||||
if err := engine.Seal(nil, block, results, nil); err != nil { |
||||
panic(fmt.Sprintf("failed to seal block: %v", err)) |
||||
} |
||||
found := <-results |
||||
return block.WithSeal(found.Header()), nil |
||||
} |
||||
|
||||
// sealClique seals the given block using clique.
|
||||
func (i *bbInput) sealClique(block *types.Block) (*types.Block, error) { |
||||
// If any clique value overwrites an explicit header value, fail
|
||||
// to avoid silently building a block with unexpected values.
|
||||
if i.Header.Extra != nil { |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("sealing with clique will overwrite provided extra data")) |
||||
} |
||||
header := block.Header() |
||||
if i.Clique.Voted != nil { |
||||
if i.Header.Coinbase != nil { |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("sealing with clique and voting will overwrite provided coinbase")) |
||||
} |
||||
header.Coinbase = *i.Clique.Voted |
||||
} |
||||
if i.Clique.Authorize != nil { |
||||
if i.Header.Nonce != nil { |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("sealing with clique and voting will overwrite provided nonce")) |
||||
} |
||||
if *i.Clique.Authorize { |
||||
header.Nonce = [8]byte{} |
||||
} else { |
||||
header.Nonce = [8]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} |
||||
} |
||||
} |
||||
// Extra is fixed 32 byte vanity and 65 byte signature
|
||||
header.Extra = make([]byte, 32+65) |
||||
copy(header.Extra[0:32], i.Clique.Vanity.Bytes()[:]) |
||||
|
||||
// Sign the seal hash and fill in the rest of the extra data
|
||||
h := clique.SealHash(header) |
||||
sighash, err := crypto.Sign(h[:], i.Clique.Key) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
copy(header.Extra[32:], sighash) |
||||
block = block.WithSeal(header) |
||||
return block, nil |
||||
} |
||||
|
||||
// BuildBlock constructs a block from the given inputs.
|
||||
func BuildBlock(ctx *cli.Context) error { |
||||
// Configure the go-ethereum logger
|
||||
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) |
||||
glogger.Verbosity(log.Lvl(ctx.Int(VerbosityFlag.Name))) |
||||
log.Root().SetHandler(glogger) |
||||
|
||||
baseDir, err := createBasedir(ctx) |
||||
if err != nil { |
||||
return NewError(ErrorIO, fmt.Errorf("failed creating output basedir: %v", err)) |
||||
} |
||||
inputData, err := readInput(ctx) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
block := inputData.ToBlock() |
||||
block, err = inputData.SealBlock(block) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
return dispatchBlock(ctx, baseDir, block) |
||||
} |
||||
|
||||
func readInput(ctx *cli.Context) (*bbInput, error) { |
||||
var ( |
||||
headerStr = ctx.String(InputHeaderFlag.Name) |
||||
ommersStr = ctx.String(InputOmmersFlag.Name) |
||||
txsStr = ctx.String(InputTxsRlpFlag.Name) |
||||
cliqueStr = ctx.String(SealCliqueFlag.Name) |
||||
ethashOn = ctx.Bool(SealEthashFlag.Name) |
||||
ethashDir = ctx.String(SealEthashDirFlag.Name) |
||||
ethashMode = ctx.String(SealEthashModeFlag.Name) |
||||
inputData = &bbInput{} |
||||
) |
||||
if ethashOn && cliqueStr != "" { |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("both ethash and clique sealing specified, only one may be chosen")) |
||||
} |
||||
if ethashOn { |
||||
inputData.Ethash = ethashOn |
||||
inputData.EthashDir = ethashDir |
||||
switch ethashMode { |
||||
case "normal": |
||||
inputData.PowMode = ethash.ModeNormal |
||||
case "test": |
||||
inputData.PowMode = ethash.ModeTest |
||||
case "fake": |
||||
inputData.PowMode = ethash.ModeFake |
||||
default: |
||||
return nil, NewError(ErrorConfig, fmt.Errorf("unknown pow mode: %s, supported modes: test, fake, normal", ethashMode)) |
||||
} |
||||
} |
||||
if headerStr == stdinSelector || ommersStr == stdinSelector || txsStr == stdinSelector || cliqueStr == stdinSelector { |
||||
decoder := json.NewDecoder(os.Stdin) |
||||
if err := decoder.Decode(inputData); err != nil { |
||||
return nil, NewError(ErrorJson, fmt.Errorf("failed unmarshaling stdin: %v", err)) |
||||
} |
||||
} |
||||
if cliqueStr != stdinSelector && cliqueStr != "" { |
||||
var clique cliqueInput |
||||
if err := readFile(cliqueStr, "clique", &clique); err != nil { |
||||
return nil, err |
||||
} |
||||
inputData.Clique = &clique |
||||
} |
||||
if headerStr != stdinSelector { |
||||
var env header |
||||
if err := readFile(headerStr, "header", &env); err != nil { |
||||
return nil, err |
||||
} |
||||
inputData.Header = &env |
||||
} |
||||
if ommersStr != stdinSelector && ommersStr != "" { |
||||
var ommers []string |
||||
if err := readFile(ommersStr, "ommers", &ommers); err != nil { |
||||
return nil, err |
||||
} |
||||
inputData.OmmersRlp = ommers |
||||
} |
||||
if txsStr != stdinSelector { |
||||
var txs string |
||||
if err := readFile(txsStr, "txs", &txs); err != nil { |
||||
return nil, err |
||||
} |
||||
inputData.TxRlp = txs |
||||
} |
||||
// Deserialize rlp txs and ommers
|
||||
var ( |
||||
ommers = []*types.Header{} |
||||
txs = []*types.Transaction{} |
||||
) |
||||
if inputData.TxRlp != "" { |
||||
if err := rlp.DecodeBytes(common.FromHex(inputData.TxRlp), &txs); err != nil { |
||||
return nil, NewError(ErrorRlp, fmt.Errorf("unable to decode transaction from rlp data: %v", err)) |
||||
} |
||||
inputData.Txs = txs |
||||
} |
||||
for _, str := range inputData.OmmersRlp { |
||||
type extblock struct { |
||||
Header *types.Header |
||||
Txs []*types.Transaction |
||||
Ommers []*types.Header |
||||
} |
||||
var ommer *extblock |
||||
if err := rlp.DecodeBytes(common.FromHex(str), &ommer); err != nil { |
||||
return nil, NewError(ErrorRlp, fmt.Errorf("unable to decode ommer from rlp data: %v", err)) |
||||
} |
||||
ommers = append(ommers, ommer.Header) |
||||
} |
||||
inputData.Ommers = ommers |
||||
|
||||
return inputData, nil |
||||
} |
||||
|
||||
// dispatchOutput writes the output data to either stderr or stdout, or to the specified
|
||||
// files
|
||||
func dispatchBlock(ctx *cli.Context, baseDir string, block *types.Block) error { |
||||
raw, _ := rlp.EncodeToBytes(block) |
||||
|
||||
type blockInfo struct { |
||||
Rlp hexutil.Bytes `json:"rlp"` |
||||
Hash common.Hash `json:"hash"` |
||||
} |
||||
var enc blockInfo |
||||
enc.Rlp = raw |
||||
enc.Hash = block.Hash() |
||||
|
||||
b, err := json.MarshalIndent(enc, "", " ") |
||||
if err != nil { |
||||
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err)) |
||||
} |
||||
switch dest := ctx.String(OutputBlockFlag.Name); dest { |
||||
case "stdout": |
||||
os.Stdout.Write(b) |
||||
os.Stdout.WriteString("\n") |
||||
case "stderr": |
||||
os.Stderr.Write(b) |
||||
os.Stderr.WriteString("\n") |
||||
default: |
||||
if err := saveFile(baseDir, dest, enc); err != nil { |
||||
return err |
||||
} |
||||
} |
||||
return nil |
||||
} |
@ -0,0 +1,135 @@ |
||||
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||
|
||||
package t8ntool |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"math/big" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
"github.com/ethereum/go-ethereum/common/math" |
||||
"github.com/ethereum/go-ethereum/core/types" |
||||
) |
||||
|
||||
var _ = (*headerMarshaling)(nil) |
||||
|
||||
// MarshalJSON marshals as JSON.
|
||||
func (h header) MarshalJSON() ([]byte, error) { |
||||
type header struct { |
||||
ParentHash common.Hash `json:"parentHash"` |
||||
OmmerHash *common.Hash `json:"sha3Uncles"` |
||||
Coinbase *common.Address `json:"miner"` |
||||
Root common.Hash `json:"stateRoot" gencodec:"required"` |
||||
TxHash *common.Hash `json:"transactionsRoot"` |
||||
ReceiptHash *common.Hash `json:"receiptsRoot"` |
||||
Bloom types.Bloom `json:"logsBloom"` |
||||
Difficulty *math.HexOrDecimal256 `json:"difficulty"` |
||||
Number *math.HexOrDecimal256 `json:"number" gencodec:"required"` |
||||
GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` |
||||
GasUsed math.HexOrDecimal64 `json:"gasUsed"` |
||||
Time math.HexOrDecimal64 `json:"timestamp" gencodec:"required"` |
||||
Extra hexutil.Bytes `json:"extraData"` |
||||
MixDigest common.Hash `json:"mixHash"` |
||||
Nonce *types.BlockNonce `json:"nonce"` |
||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas" rlp:"optional"` |
||||
} |
||||
var enc header |
||||
enc.ParentHash = h.ParentHash |
||||
enc.OmmerHash = h.OmmerHash |
||||
enc.Coinbase = h.Coinbase |
||||
enc.Root = h.Root |
||||
enc.TxHash = h.TxHash |
||||
enc.ReceiptHash = h.ReceiptHash |
||||
enc.Bloom = h.Bloom |
||||
enc.Difficulty = (*math.HexOrDecimal256)(h.Difficulty) |
||||
enc.Number = (*math.HexOrDecimal256)(h.Number) |
||||
enc.GasLimit = math.HexOrDecimal64(h.GasLimit) |
||||
enc.GasUsed = math.HexOrDecimal64(h.GasUsed) |
||||
enc.Time = math.HexOrDecimal64(h.Time) |
||||
enc.Extra = h.Extra |
||||
enc.MixDigest = h.MixDigest |
||||
enc.Nonce = h.Nonce |
||||
enc.BaseFee = (*math.HexOrDecimal256)(h.BaseFee) |
||||
return json.Marshal(&enc) |
||||
} |
||||
|
||||
// UnmarshalJSON unmarshals from JSON.
|
||||
func (h *header) UnmarshalJSON(input []byte) error { |
||||
type header struct { |
||||
ParentHash *common.Hash `json:"parentHash"` |
||||
OmmerHash *common.Hash `json:"sha3Uncles"` |
||||
Coinbase *common.Address `json:"miner"` |
||||
Root *common.Hash `json:"stateRoot" gencodec:"required"` |
||||
TxHash *common.Hash `json:"transactionsRoot"` |
||||
ReceiptHash *common.Hash `json:"receiptsRoot"` |
||||
Bloom *types.Bloom `json:"logsBloom"` |
||||
Difficulty *math.HexOrDecimal256 `json:"difficulty"` |
||||
Number *math.HexOrDecimal256 `json:"number" gencodec:"required"` |
||||
GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` |
||||
GasUsed *math.HexOrDecimal64 `json:"gasUsed"` |
||||
Time *math.HexOrDecimal64 `json:"timestamp" gencodec:"required"` |
||||
Extra *hexutil.Bytes `json:"extraData"` |
||||
MixDigest *common.Hash `json:"mixHash"` |
||||
Nonce *types.BlockNonce `json:"nonce"` |
||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas" rlp:"optional"` |
||||
} |
||||
var dec header |
||||
if err := json.Unmarshal(input, &dec); err != nil { |
||||
return err |
||||
} |
||||
if dec.ParentHash != nil { |
||||
h.ParentHash = *dec.ParentHash |
||||
} |
||||
if dec.OmmerHash != nil { |
||||
h.OmmerHash = dec.OmmerHash |
||||
} |
||||
if dec.Coinbase != nil { |
||||
h.Coinbase = dec.Coinbase |
||||
} |
||||
if dec.Root == nil { |
||||
return errors.New("missing required field 'stateRoot' for header") |
||||
} |
||||
h.Root = *dec.Root |
||||
if dec.TxHash != nil { |
||||
h.TxHash = dec.TxHash |
||||
} |
||||
if dec.ReceiptHash != nil { |
||||
h.ReceiptHash = dec.ReceiptHash |
||||
} |
||||
if dec.Bloom != nil { |
||||
h.Bloom = *dec.Bloom |
||||
} |
||||
if dec.Difficulty != nil { |
||||
h.Difficulty = (*big.Int)(dec.Difficulty) |
||||
} |
||||
if dec.Number == nil { |
||||
return errors.New("missing required field 'number' for header") |
||||
} |
||||
h.Number = (*big.Int)(dec.Number) |
||||
if dec.GasLimit == nil { |
||||
return errors.New("missing required field 'gasLimit' for header") |
||||
} |
||||
h.GasLimit = uint64(*dec.GasLimit) |
||||
if dec.GasUsed != nil { |
||||
h.GasUsed = uint64(*dec.GasUsed) |
||||
} |
||||
if dec.Time == nil { |
||||
return errors.New("missing required field 'timestamp' for header") |
||||
} |
||||
h.Time = uint64(*dec.Time) |
||||
if dec.Extra != nil { |
||||
h.Extra = *dec.Extra |
||||
} |
||||
if dec.MixDigest != nil { |
||||
h.MixDigest = *dec.MixDigest |
||||
} |
||||
if dec.Nonce != nil { |
||||
h.Nonce = dec.Nonce |
||||
} |
||||
if dec.BaseFee != nil { |
||||
h.BaseFee = (*big.Int)(dec.BaseFee) |
||||
} |
||||
return nil |
||||
} |
@ -0,0 +1,54 @@ |
||||
// Copyright 2021 The go-ethereum Authors
|
||||
// This file is part of go-ethereum.
|
||||
//
|
||||
// go-ethereum is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// go-ethereum is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package t8ntool |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"fmt" |
||||
"os" |
||||
|
||||
"gopkg.in/urfave/cli.v1" |
||||
) |
||||
|
||||
// readFile reads the json-data in the provided path and marshals into dest.
|
||||
func readFile(path, desc string, dest interface{}) error { |
||||
inFile, err := os.Open(path) |
||||
if err != nil { |
||||
return NewError(ErrorIO, fmt.Errorf("failed reading %s file: %v", desc, err)) |
||||
} |
||||
defer inFile.Close() |
||||
decoder := json.NewDecoder(inFile) |
||||
if err := decoder.Decode(dest); err != nil { |
||||
return NewError(ErrorJson, fmt.Errorf("failed unmarshaling %s file: %v", desc, err)) |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
// createBasedir makes sure the basedir exists, if user specified one.
|
||||
func createBasedir(ctx *cli.Context) (string, error) { |
||||
baseDir := "" |
||||
if ctx.IsSet(OutputBasedir.Name) { |
||||
if base := ctx.String(OutputBasedir.Name); len(base) > 0 { |
||||
err := os.MkdirAll(base, 0755) // //rw-r--r--
|
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
baseDir = base |
||||
} |
||||
} |
||||
return baseDir, nil |
||||
} |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"rlp": "0xf902d9f90211a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e997a23b159e2e2a5ce72333262972374b15425ca0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e99476574682f76312e302e312f6c696e75782f676f312e342e32a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf8897435673d874f7c8f8c2f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600c0", |
||||
"hash": "0xaba9a3b6a4e96e9ecffcadaa5a2ae0589359455617535cd86589fe1dd26fe899" |
||||
} |
@ -0,0 +1,14 @@ |
||||
{ |
||||
"parentHash": "0xd6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34e", |
||||
"miner": "0xe997a23b159e2e2a5ce72333262972374b15425c", |
||||
"stateRoot": "0x325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2e", |
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", |
||||
"difficulty": "0x1000", |
||||
"number": "0xc3be", |
||||
"gasLimit": "0x50785", |
||||
"gasUsed": "0x0", |
||||
"timestamp": "0x55c5277e", |
||||
"extraData": "0x476574682f76312e302e312f6c696e75782f676f312e342e32", |
||||
"mixHash": "0x5865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf", |
||||
"nonce": "0x97435673d874f7c8" |
||||
} |
@ -0,0 +1 @@ |
||||
[] |
@ -0,0 +1,11 @@ |
||||
# Block building |
||||
|
||||
This test shows how `b11r` can be used to assemble an unsealed block. |
||||
|
||||
```console |
||||
$ go run . b11r --input.header=testdata/20/header.json --input.txs=testdata/20/txs.rlp --input.ommers=testdata/20/ommers.json --output.block=stdout |
||||
{ |
||||
"rlp": "0xf90216f90211a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e997a23b159e2e2a5ce72333262972374b15425ca0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e99476574682f76312e302e312f6c696e75782f676f312e342e32a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf8897435673d874f7c8c0c0", |
||||
"hash": "0xaba9a3b6a4e96e9ecffcadaa5a2ae0589359455617535cd86589fe1dd26fe899" |
||||
} |
||||
``` |
@ -0,0 +1 @@ |
||||
"0xf8c2f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600" |
@ -0,0 +1,6 @@ |
||||
{ |
||||
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", |
||||
"voted": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", |
||||
"authorize": false, |
||||
"vanity": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
||||
} |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"rlp": "0xf9025ff9025aa0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277eb861aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac540a67aaee364005841da84f488f6b6d0116dfb5103d091402c81a163d5f66666595e37f56f196d8c5c98da714dbfae68d6b7e1790cc734a20ec6ce52213ad800a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf88ffffffffffffffffc0c0", |
||||
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7" |
||||
} |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"rlp": "0xf901fdf901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0c0", |
||||
"hash": "0x801411e9f6609a659825690d13e4f75a3cfe9143952fa2d9573f3b0a5eb9ebbb" |
||||
} |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"parentHash": "0xd6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34e", |
||||
"stateRoot": "0x325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2e", |
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", |
||||
"difficulty": "0x1000", |
||||
"number": "0xc3be", |
||||
"gasLimit": "0x50785", |
||||
"gasUsed": "0x0", |
||||
"timestamp": "0x55c5277e", |
||||
"mixHash": "0x5865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf" |
||||
} |
@ -0,0 +1 @@ |
||||
[] |
@ -0,0 +1,23 @@ |
||||
# Sealed block building |
||||
|
||||
This test shows how `b11r` can be used to assemble a sealed block. |
||||
|
||||
## Ethash |
||||
|
||||
```console |
||||
$ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/txs.rlp --input.ommers=testdata/21/ommers.json --seal.ethash --seal.ethash.mode=test --output.block=stdout |
||||
{ |
||||
"rlp": "0xf901fdf901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0c0", |
||||
"hash": "0x801411e9f6609a659825690d13e4f75a3cfe9143952fa2d9573f3b0a5eb9ebbb" |
||||
} |
||||
``` |
||||
|
||||
## Clique |
||||
|
||||
```console |
||||
$ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/txs.rlp --input.ommers=testdata/21/ommers.json --seal.clique=testdata/21/clique.json --output.block=stdout |
||||
{ |
||||
"rlp": "0xf9025ff9025aa0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277eb861aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac540a67aaee364005841da84f488f6b6d0116dfb5103d091402c81a163d5f66666595e37f56f196d8c5c98da714dbfae68d6b7e1790cc734a20ec6ce52213ad800a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf88ffffffffffffffffc0c0", |
||||
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7" |
||||
} |
||||
``` |
@ -0,0 +1 @@ |
||||
"c0" |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"rlp": "0xf9025ff9025aa0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277eb861aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac540a67aaee364005841da84f488f6b6d0116dfb5103d091402c81a163d5f66666595e37f56f196d8c5c98da714dbfae68d6b7e1790cc734a20ec6ce52213ad800a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf88ffffffffffffffffc0c0", |
||||
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7" |
||||
} |
@ -0,0 +1,4 @@ |
||||
{ |
||||
"rlp": "0xf905f5f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea06eb9f0c3cd68c9e97134e6725d12b1f1d8f0644458da6870a37ff84c908fb1e7940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0f903f6f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000", |
||||
"hash": "0xd9a81c8fcd57a7f2a0d2c375eff6ad192c30c3729a271303f0a9a7e1b357e755" |
||||
} |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"parentHash": "0xd6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34e", |
||||
"stateRoot": "0x325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2e", |
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", |
||||
"difficulty": "0x1000", |
||||
"number": "0xc3be", |
||||
"gasLimit": "0x50785", |
||||
"gasUsed": "0x0", |
||||
"timestamp": "0x55c5277e", |
||||
"mixHash": "0x5865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf" |
||||
} |
@ -0,0 +1 @@ |
||||
["0xf901fdf901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0c0","0xf901fdf901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0c0"] |
@ -0,0 +1,11 @@ |
||||
# Building blocks with ommers |
||||
|
||||
This test shows how `b11r` can chain together ommer assembles into a canonical block. |
||||
|
||||
```console |
||||
$ echo "{ \"ommers\": [`go run . b11r --input.header=testdata/22/header.json --input.txs=testdata/22/txs.rlp --output.block=stdout | jq '.[\"rlp\"]'`,`go run . b11r --input.header=testdata/22/header.json --input.txs=testdata/22/txs.rlp --output.block=stdout | jq '.[\"rlp\"]'`]}" | go run . b11r --input.header=testdata/22/header.json --input.txs=testdata/22/txs.rlp --input.ommers=stdin --output.block=stdout |
||||
{ |
||||
"rlp": "0xf905f5f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea06eb9f0c3cd68c9e97134e6725d12b1f1d8f0644458da6870a37ff84c908fb1e7940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000c0f903f6f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000f901f8a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e80a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf880000000000000000", |
||||
"hash": "0xd9a81c8fcd57a7f2a0d2c375eff6ad192c30c3729a271303f0a9a7e1b357e755" |
||||
} |
||||
``` |
@ -0,0 +1 @@ |
||||
"c0" |
Loading…
Reference in new issue