diff --git a/Makefile b/Makefile index bf9473995b..06f3bbe6cf 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,12 @@ GOBIN = ./build/bin GO ?= latest GORUN = env GO111MODULE=on go run +bor: + mkdir -p $(GOPATH)/bin/ + go build -o $(GOBIN)/bor $(GO_LDFLAGS) ./cmd/cli/main.go + cp $(GOBIN)/bor $(GOPATH)/bin/ + @echo "Done building." + geth: $(GORUN) build/ci.go install ./cmd/geth @echo "Done building." diff --git a/accounts/accounts.go b/accounts/accounts.go index 6c351a9649..93dbd1d20f 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -39,6 +39,7 @@ const ( MimetypeDataWithValidator = "data/validator" MimetypeTypedData = "data/typed" MimetypeClique = "application/x-clique-header" + MimetypeBor = "application/x-bor-header" MimetypeTextPlain = "text/plain" ) diff --git a/cmd/cli/main.go b/cmd/cli/main.go new file mode 100644 index 0000000000..af4b7d8075 --- /dev/null +++ b/cmd/cli/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "os" + + "github.com/ethereum/go-ethereum/internal/cli" +) + +func main() { + os.Exit(cli.Run(os.Args[1:])) +} diff --git a/common/flags/milestone.go b/common/flags/milestone.go new file mode 100644 index 0000000000..d858bc29dd --- /dev/null +++ b/common/flags/milestone.go @@ -0,0 +1,3 @@ +package flags + +const Milestone = true diff --git a/common/gererics/empty.go b/common/gererics/empty.go new file mode 100644 index 0000000000..7a41df3a26 --- /dev/null +++ b/common/gererics/empty.go @@ -0,0 +1,5 @@ +package gererics + +func Empty[T any]() (t T) { + return +} diff --git a/common/network/port.go b/common/network/port.go new file mode 100644 index 0000000000..f92b59ac11 --- /dev/null +++ b/common/network/port.go @@ -0,0 +1,36 @@ +package network + +import ( + "errors" + "fmt" + "net" +) + +const ( + maxPortCheck = 100 + + emptyPort = "127.0.0.1:0" +) + +var ( + ErrCantFindAPort = errors.New("no available port found") +) + +// FindAvailablePort returns the an available port +func FindAvailablePort() (int, net.Listener, error) { + var ( + listener net.Listener + err error + ) + + for i := uint(0); i < maxPortCheck; i++ { + listener, err = net.Listen("tcp", emptyPort) + if err != nil { + continue + } + + return listener.Addr().(*net.TCPAddr).Port, listener, nil + } + + return 0, nil, fmt.Errorf("%w: %s", ErrCantFindAPort, err) +} diff --git a/common/set/slice.go b/common/set/slice.go new file mode 100644 index 0000000000..36f11e67fe --- /dev/null +++ b/common/set/slice.go @@ -0,0 +1,11 @@ +package set + +func New[T comparable](slice []T) map[T]struct{} { + m := make(map[T]struct{}, len(slice)) + + for _, el := range slice { + m[el] = struct{}{} + } + + return m +} diff --git a/common/tracing/context.go b/common/tracing/context.go new file mode 100644 index 0000000000..c3c6342502 --- /dev/null +++ b/common/tracing/context.go @@ -0,0 +1,102 @@ +package tracing + +import ( + "context" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" +) + +type tracerKey struct{} + +type Option func(context.Context, trace.Span) + +func WithTracer(ctx context.Context, tr trace.Tracer) context.Context { + return context.WithValue(ctx, tracerKey{}, tr) +} + +func FromContext(ctx context.Context) trace.Tracer { + tr, _ := ctx.Value(tracerKey{}).(trace.Tracer) + + return tr +} + +func StartSpan(ctx context.Context, snapName string) (context.Context, trace.Span) { + tr := FromContext(ctx) + + if tr == nil { + return ctx, nil + } + + ctx, span := tr.Start(ctx, snapName) + ctx = WithTracer(ctx, tr) + + return ctx, span +} + +func EndSpan(span trace.Span) { + if span != nil { + span.End() + } +} + +func Trace(ctx context.Context, spanName string) (context.Context, trace.Span) { + tr := FromContext(ctx) + + if tr == nil { + return ctx, nil + } + + return tr.Start(ctx, spanName) +} + +func Exec(ctx context.Context, instrumentationName, spanName string, opts ...Option) { + var span trace.Span + + tr := FromContext(ctx) + + if tr == nil && len(instrumentationName) != 0 { + tr = otel.GetTracerProvider().Tracer(instrumentationName) + ctx = WithTracer(ctx, tr) + } + + if tr != nil { + ctx, span = tr.Start(ctx, spanName) + } + + for _, optFn := range opts { + optFn(ctx, span) + } + + if tr != nil { + span.End() + } +} + +func WithTime(fn func(context.Context, trace.Span)) Option { + return func(ctx context.Context, span trace.Span) { + ElapsedTime(ctx, span, "elapsed", fn) + } +} + +func ElapsedTime(ctx context.Context, span trace.Span, msg string, fn func(context.Context, trace.Span)) { + var now time.Time + + if span != nil { + now = time.Now() + } + + fn(ctx, span) + + if span != nil { + span.SetAttributes(attribute.Int(msg, int(time.Since(now).Microseconds()))) + } +} + +func SetAttributes(span trace.Span, kvs ...attribute.KeyValue) { + if span != nil { + span.SetAttributes(kvs...) + } +} diff --git a/consensus/bor/abi/interface.go b/consensus/bor/abi/interface.go new file mode 100644 index 0000000000..bb05bf0b23 --- /dev/null +++ b/consensus/bor/abi/interface.go @@ -0,0 +1,6 @@ +package abi + +type ABI interface { + Pack(name string, args ...interface{}) ([]byte, error) + UnpackIntoInterface(v interface{}, name string, data []byte) error +} diff --git a/consensus/bor/api.go b/consensus/bor/api.go new file mode 100644 index 0000000000..6d72e309e3 --- /dev/null +++ b/consensus/bor/api.go @@ -0,0 +1,355 @@ +package bor + +import ( + "encoding/hex" + "math" + "math/big" + "sort" + "strconv" + "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rpc" + + lru "github.com/hashicorp/golang-lru" + "github.com/xsleonard/go-merkle" + "golang.org/x/crypto/sha3" +) + +var ( + // MaxCheckpointLength is the maximum number of blocks that can be requested for constructing a checkpoint root hash + MaxCheckpointLength = uint64(math.Pow(2, 15)) +) + +// API is a user facing RPC API to allow controlling the signer and voting +// mechanisms of the proof-of-authority scheme. +type API struct { + chain consensus.ChainHeaderReader + bor *Bor + rootHashCache *lru.ARCCache +} + +// GetSnapshot retrieves the state snapshot at a given block. +func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) { + // Retrieve the requested block number (or current if none requested) + var header *types.Header + if number == nil || *number == rpc.LatestBlockNumber { + header = api.chain.CurrentHeader() + } else { + header = api.chain.GetHeaderByNumber(uint64(number.Int64())) + } + // Ensure we have an actually valid block and return its snapshot + if header == nil { + return nil, errUnknownBlock + } + + return api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil) +} + +type BlockSigners struct { + Signers []difficultiesKV + Diff int + Author common.Address +} + +type difficultiesKV struct { + Signer common.Address + Difficulty uint64 +} + +func rankMapDifficulties(values map[common.Address]uint64) []difficultiesKV { + ss := make([]difficultiesKV, 0, len(values)) + for k, v := range values { + ss = append(ss, difficultiesKV{k, v}) + } + + sort.Slice(ss, func(i, j int) bool { + return ss[i].Difficulty > ss[j].Difficulty + }) + + return ss +} + +// GetSnapshotProposerSequence retrieves the in-turn signers of all sprints in a span +func (api *API) GetSnapshotProposerSequence(blockNrOrHash *rpc.BlockNumberOrHash) (BlockSigners, error) { + var header *types.Header + //nolint:nestif + if blockNrOrHash == nil { + header = api.chain.CurrentHeader() + } else { + if blockNr, ok := blockNrOrHash.Number(); ok { + if blockNr == rpc.LatestBlockNumber { + header = api.chain.CurrentHeader() + } else { + header = api.chain.GetHeaderByNumber(uint64(blockNr)) + } + } else { + if blockHash, ok := blockNrOrHash.Hash(); ok { + header = api.chain.GetHeaderByHash(blockHash) + } + } + } + + if header == nil { + return BlockSigners{}, errUnknownBlock + } + + snapNumber := rpc.BlockNumber(header.Number.Int64() - 1) + snap, err := api.GetSnapshot(&snapNumber) + + var difficulties = make(map[common.Address]uint64) + + if err != nil { + return BlockSigners{}, err + } + + proposer := snap.ValidatorSet.GetProposer().Address + proposerIndex, _ := snap.ValidatorSet.GetByAddress(proposer) + + signers := snap.signers() + for i := 0; i < len(signers); i++ { + tempIndex := i + if tempIndex < proposerIndex { + tempIndex = tempIndex + len(signers) + } + + difficulties[signers[i]] = uint64(len(signers) - (tempIndex - proposerIndex)) + } + + rankedDifficulties := rankMapDifficulties(difficulties) + + author, err := api.GetAuthor(blockNrOrHash) + if err != nil { + return BlockSigners{}, err + } + + diff := int(difficulties[*author]) + blockSigners := &BlockSigners{ + Signers: rankedDifficulties, + Diff: diff, + Author: *author, + } + + return *blockSigners, nil +} + +// GetSnapshotProposer retrieves the in-turn signer at a given block. +func (api *API) GetSnapshotProposer(blockNrOrHash *rpc.BlockNumberOrHash) (common.Address, error) { + var header *types.Header + //nolint:nestif + if blockNrOrHash == nil { + header = api.chain.CurrentHeader() + } else { + if blockNr, ok := blockNrOrHash.Number(); ok { + if blockNr == rpc.LatestBlockNumber { + header = api.chain.CurrentHeader() + } else { + header = api.chain.GetHeaderByNumber(uint64(blockNr)) + } + } else { + if blockHash, ok := blockNrOrHash.Hash(); ok { + header = api.chain.GetHeaderByHash(blockHash) + } + } + } + + if header == nil { + return common.Address{}, errUnknownBlock + } + + snapNumber := rpc.BlockNumber(header.Number.Int64() - 1) + snap, err := api.GetSnapshot(&snapNumber) + + if err != nil { + return common.Address{}, err + } + + return snap.ValidatorSet.GetProposer().Address, nil +} + +// GetAuthor retrieves the author a block. +func (api *API) GetAuthor(blockNrOrHash *rpc.BlockNumberOrHash) (*common.Address, error) { + // Retrieve the requested block number (or current if none requested) + var header *types.Header + + //nolint:nestif + if blockNrOrHash == nil { + header = api.chain.CurrentHeader() + } else { + if blockNr, ok := blockNrOrHash.Number(); ok { + header = api.chain.GetHeaderByNumber(uint64(blockNr)) + if blockNr == rpc.LatestBlockNumber { + header = api.chain.CurrentHeader() + } + } else { + if blockHash, ok := blockNrOrHash.Hash(); ok { + header = api.chain.GetHeaderByHash(blockHash) + } + } + } + + // Ensure we have an actually valid block and return its snapshot + if header == nil { + return nil, errUnknownBlock + } + + author, err := api.bor.Author(header) + + return &author, err +} + +// GetSnapshotAtHash retrieves the state snapshot at a given block. +func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) { + header := api.chain.GetHeaderByHash(hash) + if header == nil { + return nil, errUnknownBlock + } + + return api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil) +} + +// GetSigners retrieves the list of authorized signers at the specified block. +func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error) { + // Retrieve the requested block number (or current if none requested) + var header *types.Header + if number == nil || *number == rpc.LatestBlockNumber { + header = api.chain.CurrentHeader() + } else { + header = api.chain.GetHeaderByNumber(uint64(number.Int64())) + } + // Ensure we have an actually valid block and return the signers from its snapshot + if header == nil { + return nil, errUnknownBlock + } + + snap, err := api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil) + + if err != nil { + return nil, err + } + + return snap.signers(), nil +} + +// GetSignersAtHash retrieves the list of authorized signers at the specified block. +func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error) { + header := api.chain.GetHeaderByHash(hash) + if header == nil { + return nil, errUnknownBlock + } + + snap, err := api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil) + + if err != nil { + return nil, err + } + + return snap.signers(), nil +} + +// GetCurrentProposer gets the current proposer +func (api *API) GetCurrentProposer() (common.Address, error) { + snap, err := api.GetSnapshot(nil) + if err != nil { + return common.Address{}, err + } + + return snap.ValidatorSet.GetProposer().Address, nil +} + +// GetCurrentValidators gets the current validators +func (api *API) GetCurrentValidators() ([]*valset.Validator, error) { + snap, err := api.GetSnapshot(nil) + if err != nil { + return make([]*valset.Validator, 0), err + } + + return snap.ValidatorSet.Validators, nil +} + +// GetRootHash returns the merkle root of the start to end block headers +func (api *API) GetRootHash(start uint64, end uint64) (string, error) { + if err := api.initializeRootHashCache(); err != nil { + return "", err + } + + key := getRootHashKey(start, end) + + if root, known := api.rootHashCache.Get(key); known { + return root.(string), nil + } + + length := end - start + 1 + + if length > MaxCheckpointLength { + return "", &MaxCheckpointLengthExceededError{start, end} + } + + currentHeaderNumber := api.chain.CurrentHeader().Number.Uint64() + + if start > end || end > currentHeaderNumber { + return "", &valset.InvalidStartEndBlockError{Start: start, End: end, CurrentHeader: currentHeaderNumber} + } + + blockHeaders := make([]*types.Header, end-start+1) + wg := new(sync.WaitGroup) + concurrent := make(chan bool, 20) + + for i := start; i <= end; i++ { + wg.Add(1) + concurrent <- true + + go func(number uint64) { + blockHeaders[number-start] = api.chain.GetHeaderByNumber(number) + + <-concurrent + wg.Done() + }(i) + } + wg.Wait() + close(concurrent) + + headers := make([][32]byte, nextPowerOfTwo(length)) + + for i := 0; i < len(blockHeaders); i++ { + blockHeader := blockHeaders[i] + header := crypto.Keccak256(appendBytes32( + blockHeader.Number.Bytes(), + new(big.Int).SetUint64(blockHeader.Time).Bytes(), + blockHeader.TxHash.Bytes(), + blockHeader.ReceiptHash.Bytes(), + )) + + var arr [32]byte + + copy(arr[:], header) + headers[i] = arr + } + + tree := merkle.NewTreeWithOpts(merkle.TreeOptions{EnableHashSorting: false, DisableHashLeaves: true}) + if err := tree.Generate(convert(headers), sha3.NewLegacyKeccak256()); err != nil { + return "", err + } + + root := hex.EncodeToString(tree.Root().Hash) + api.rootHashCache.Add(key, root) + + return root, nil +} + +func (api *API) initializeRootHashCache() error { + var err error + if api.rootHashCache == nil { + api.rootHashCache, err = lru.NewARC(10) + } + + return err +} + +func getRootHashKey(start uint64, end uint64) string { + return strconv.FormatUint(start, 10) + "-" + strconv.FormatUint(end, 10) +} diff --git a/consensus/bor/api/caller.go b/consensus/bor/api/caller.go new file mode 100644 index 0000000000..49c06b3f73 --- /dev/null +++ b/consensus/bor/api/caller.go @@ -0,0 +1,16 @@ +package api + +import ( + "context" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/rpc" +) + +//go:generate mockgen -destination=./caller_mock.go -package=api . Caller +type Caller interface { + Call(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi.StateOverride) (hexutil.Bytes, error) + CallWithState(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, state *state.StateDB, overrides *ethapi.StateOverride) (hexutil.Bytes, error) +} diff --git a/consensus/bor/api/caller_mock.go b/consensus/bor/api/caller_mock.go new file mode 100644 index 0000000000..fb8fa3b3c6 --- /dev/null +++ b/consensus/bor/api/caller_mock.go @@ -0,0 +1,72 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/ethereum/go-ethereum/consensus/bor/api (interfaces: Caller) + +// Package api is a generated GoMock package. +package api + +import ( + context "context" + reflect "reflect" + + hexutil "github.com/ethereum/go-ethereum/common/hexutil" + state "github.com/ethereum/go-ethereum/core/state" + ethapi "github.com/ethereum/go-ethereum/internal/ethapi" + rpc "github.com/ethereum/go-ethereum/rpc" + gomock "github.com/golang/mock/gomock" +) + +// MockCaller is a mock of Caller interface. +type MockCaller struct { + ctrl *gomock.Controller + recorder *MockCallerMockRecorder +} + +// MockCallerMockRecorder is the mock recorder for MockCaller. +type MockCallerMockRecorder struct { + mock *MockCaller +} + +// NewMockCaller creates a new mock instance. +func NewMockCaller(ctrl *gomock.Controller) *MockCaller { + mock := &MockCaller{ctrl: ctrl} + mock.recorder = &MockCallerMockRecorder{mock} + + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCaller) EXPECT() *MockCallerMockRecorder { + return m.recorder +} + +// Call mocks base method. +func (m *MockCaller) Call(arg0 context.Context, arg1 ethapi.TransactionArgs, arg2 rpc.BlockNumberOrHash, arg3 *ethapi.StateOverride) (hexutil.Bytes, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Call", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(hexutil.Bytes) + ret1, _ := ret[1].(error) + + return ret0, ret1 +} + +// Call indicates an expected call of Call. +func (mr *MockCallerMockRecorder) Call(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockCaller)(nil).Call), arg0, arg1, arg2, arg3) +} + +// CallWithState mocks base method. +func (m *MockCaller) CallWithState(arg0 context.Context, arg1 ethapi.TransactionArgs, arg2 rpc.BlockNumberOrHash, arg3 *state.StateDB, arg4 *ethapi.StateOverride) (hexutil.Bytes, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CallWithState", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(hexutil.Bytes) + ret1, _ := ret[1].(error) + + return ret0, ret1 +} + +// CallWithState indicates an expected call of CallWithState. +func (mr *MockCallerMockRecorder) CallWithState(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallWithState", reflect.TypeOf((*MockCaller)(nil).CallWithState), arg0, arg1, arg2, arg3, arg4) +} diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go new file mode 100644 index 0000000000..1874e44d74 --- /dev/null +++ b/consensus/bor/bor.go @@ -0,0 +1,1411 @@ +package bor + +import ( + "bytes" + "context" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "io" + "math/big" + "sort" + "strconv" + "sync" + "sync/atomic" + "time" + + lru "github.com/hashicorp/golang-lru" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" + "golang.org/x/crypto/sha3" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/tracing" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/consensus/bor/api" + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/consensus/misc" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/trie" +) + +const ( + checkpointInterval = 1024 // Number of blocks after which to save the vote snapshot to the database + inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory + inmemorySignatures = 4096 // Number of recent block signatures to keep in memory +) + +// Bor protocol constants. +var ( + defaultSprintLength = map[string]uint64{ + "0": 64, + } // Default number of blocks after which to checkpoint and reset the pending votes + + uncleHash = types.CalcUncleHash(nil) // Always Keccak256(RLP([])) as uncles are meaningless outside of PoW. + + validatorHeaderBytesLength = common.AddressLength + 20 // address + power +) + +// Various error messages to mark blocks invalid. These should be private to +// prevent engine specific errors from being referenced in the remainder of the +// codebase, inherently breaking if the engine is swapped out. Please put common +// error types into the consensus package. +var ( + // errUnknownBlock is returned when the list of signers is requested for a block + // that is not part of the local blockchain. + errUnknownBlock = errors.New("unknown block") + + // errMissingVanity is returned if a block's extra-data section is shorter than + // 32 bytes, which is required to store the signer vanity. + errMissingVanity = errors.New("extra-data 32 byte vanity prefix missing") + + // errMissingSignature is returned if a block's extra-data section doesn't seem + // to contain a 65 byte secp256k1 signature. + errMissingSignature = errors.New("extra-data 65 byte signature suffix missing") + + // errExtraValidators is returned if non-sprint-end block contain validator data in + // their extra-data fields. + errExtraValidators = errors.New("non-sprint-end block contains extra validator list") + + // errInvalidSpanValidators is returned if a block contains an + // invalid list of validators (i.e. non divisible by 40 bytes). + errInvalidSpanValidators = errors.New("invalid validator list on sprint end block") + + // errInvalidMixDigest is returned if a block's mix digest is non-zero. + errInvalidMixDigest = errors.New("non-zero mix digest") + + // errInvalidUncleHash is returned if a block contains an non-empty uncle list. + errInvalidUncleHash = errors.New("non empty uncle hash") + + // errInvalidDifficulty is returned if the difficulty of a block neither 1 or 2. + errInvalidDifficulty = errors.New("invalid difficulty") + + // ErrInvalidTimestamp is returned if the timestamp of a block is lower than + // the previous block's timestamp + the minimum block period. + ErrInvalidTimestamp = errors.New("invalid timestamp") + + // errOutOfRangeChain is returned if an authorization list is attempted to + // be modified via out-of-range or non-contiguous headers. + errOutOfRangeChain = errors.New("out of range or non-contiguous chain") + + errUncleDetected = errors.New("uncles not allowed") + errUnknownValidators = errors.New("unknown validators") +) + +// SignerFn is a signer callback function to request a header to be signed by a +// backing account. +type SignerFn func(accounts.Account, string, []byte) ([]byte, error) + +// ecrecover extracts the Ethereum account address from a signed header. +func ecrecover(header *types.Header, sigcache *lru.ARCCache, c *params.BorConfig) (common.Address, error) { + // If the signature's already cached, return that + hash := header.Hash() + if address, known := sigcache.Get(hash); known { + return address.(common.Address), nil + } + // Retrieve the signature from the header extra-data + if len(header.Extra) < types.ExtraSealLength { + return common.Address{}, errMissingSignature + } + + signature := header.Extra[len(header.Extra)-types.ExtraSealLength:] + + // Recover the public key and the Ethereum address + pubkey, err := crypto.Ecrecover(SealHash(header, c).Bytes(), signature) + if err != nil { + return common.Address{}, err + } + + var signer common.Address + + copy(signer[:], crypto.Keccak256(pubkey[1:])[12:]) + + sigcache.Add(hash, signer) + + return signer, nil +} + +// SealHash returns the hash of a block prior to it being sealed. +func SealHash(header *types.Header, c *params.BorConfig) (hash common.Hash) { + hasher := sha3.NewLegacyKeccak256() + encodeSigHeader(hasher, header, c) + hasher.Sum(hash[:0]) + + return hash +} + +func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) { + enc := []interface{}{ + header.ParentHash, + header.UncleHash, + header.Coinbase, + header.Root, + header.TxHash, + header.ReceiptHash, + header.Bloom, + header.Difficulty, + header.Number, + header.GasLimit, + header.GasUsed, + header.Time, + header.Extra[:len(header.Extra)-65], // Yes, this will panic if extra is too short + header.MixDigest, + header.Nonce, + } + + if c.IsJaipur(header.Number) { + if header.BaseFee != nil { + enc = append(enc, header.BaseFee) + } + } + + if err := rlp.Encode(w, enc); err != nil { + panic("can't encode: " + err.Error()) + } +} + +// CalcProducerDelay is the block delay algorithm based on block time, period, producerDelay and turn-ness of a signer +func CalcProducerDelay(number uint64, succession int, c *params.BorConfig) uint64 { + // When the block is the first block of the sprint, it is expected to be delayed by `producerDelay`. + // That is to allow time for block propagation in the last sprint + delay := c.CalculatePeriod(number) + if number%c.CalculateSprint(number) == 0 { + delay = c.CalculateProducerDelay(number) + } + + if succession > 0 { + delay += uint64(succession) * c.CalculateBackupMultiplier(number) + } + + return delay +} + +// BorRLP returns the rlp bytes which needs to be signed for the bor +// sealing. The RLP to sign consists of the entire header apart from the 65 byte signature +// contained at the end of the extra data. +// +// Note, the method requires the extra data to be at least 65 bytes, otherwise it +// panics. This is done to avoid accidentally using both forms (signature present +// or not), which could be abused to produce different hashes for the same header. +func BorRLP(header *types.Header, c *params.BorConfig) []byte { + b := new(bytes.Buffer) + encodeSigHeader(b, header, c) + + return b.Bytes() +} + +// Bor is the matic-bor consensus engine +type Bor struct { + chainConfig *params.ChainConfig // Chain config + config *params.BorConfig // Consensus engine configuration parameters for bor consensus + db ethdb.Database // Database to store and retrieve snapshot checkpoints + + recents *lru.ARCCache // Snapshots for recent block to speed up reorgs + signatures *lru.ARCCache // Signatures of recent blocks to speed up mining + + authorizedSigner atomic.Pointer[signer] // Ethereum address and sign function of the signing key + + ethAPI api.Caller + spanner Spanner + GenesisContractsClient GenesisContract + HeimdallClient IHeimdallClient + + // The fields below are for testing only + fakeDiff bool // Skip difficulty verifications + devFakeAuthor bool + + closeOnce sync.Once +} + +type signer struct { + signer common.Address // Ethereum address of the signing key + signFn SignerFn // Signer function to authorize hashes with +} + +// New creates a Matic Bor consensus engine. +func New( + chainConfig *params.ChainConfig, + db ethdb.Database, + ethAPI api.Caller, + spanner Spanner, + heimdallClient IHeimdallClient, + genesisContracts GenesisContract, + devFakeAuthor bool, +) *Bor { + // get bor config + borConfig := chainConfig.Bor + + // Set any missing consensus parameters to their defaults + if borConfig != nil && borConfig.CalculateSprint(0) == 0 { + borConfig.Sprint = defaultSprintLength + } + // Allocate the snapshot caches and create the engine + recents, _ := lru.NewARC(inmemorySnapshots) + signatures, _ := lru.NewARC(inmemorySignatures) + + c := &Bor{ + chainConfig: chainConfig, + config: borConfig, + db: db, + ethAPI: ethAPI, + recents: recents, + signatures: signatures, + spanner: spanner, + GenesisContractsClient: genesisContracts, + HeimdallClient: heimdallClient, + devFakeAuthor: devFakeAuthor, + } + + c.authorizedSigner.Store(&signer{ + common.Address{}, + func(_ accounts.Account, _ string, i []byte) ([]byte, error) { + // return an error to prevent panics + return nil, &UnauthorizedSignerError{0, common.Address{}.Bytes()} + }, + }) + + // make sure we can decode all the GenesisAlloc in the BorConfig. + for key, genesisAlloc := range c.config.BlockAlloc { + if _, err := decodeGenesisAlloc(genesisAlloc); err != nil { + panic(fmt.Sprintf("BUG: Block alloc '%s' in genesis is not correct: %v", key, err)) + } + } + + return c +} + +// Author implements consensus.Engine, returning the Ethereum address recovered +// from the signature in the header's extra-data section. +func (c *Bor) Author(header *types.Header) (common.Address, error) { + return ecrecover(header, c.signatures, c.config) +} + +// VerifyHeader checks whether a header conforms to the consensus rules. +func (c *Bor) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, _ bool) error { + return c.verifyHeader(chain, header, nil) +} + +func (c *Bor) GetSpanner() Spanner { + return c.spanner +} + +func (c *Bor) SetSpanner(spanner Spanner) { + c.spanner = spanner +} + +// VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The +// method returns a quit channel to abort the operations and a results channel to +// retrieve the async verifications (the order is that of the input slice). +func (c *Bor) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, _ []bool) (chan<- struct{}, <-chan error) { + abort := make(chan struct{}) + results := make(chan error, len(headers)) + + go func() { + for i, header := range headers { + err := c.verifyHeader(chain, header, headers[:i]) + + select { + case <-abort: + return + case results <- err: + } + } + }() + + return abort, results +} + +// verifyHeader checks whether a header conforms to the consensus rules.The +// caller may optionally pass in a batch of parents (ascending order) to avoid +// looking those up from the database. This is useful for concurrently verifying +// a batch of new headers. +func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Header, parents []*types.Header) error { + if header.Number == nil { + return errUnknownBlock + } + + number := header.Number.Uint64() + + // Don't waste time checking blocks from the future + if header.Time > uint64(time.Now().Unix()) { + return consensus.ErrFutureBlock + } + + if err := validateHeaderExtraField(header.Extra); err != nil { + return err + } + + // check extr adata + isSprintEnd := IsSprintStart(number+1, c.config.CalculateSprint(number)) + + // Ensure that the extra-data contains a signer list on checkpoint, but none otherwise + signersBytes := len(header.GetValidatorBytes(c.config)) + + if !isSprintEnd && signersBytes != 0 { + return errExtraValidators + } + + if isSprintEnd && signersBytes%validatorHeaderBytesLength != 0 { + return errInvalidSpanValidators + } + + // Ensure that the mix digest is zero as we don't have fork protection currently + if header.MixDigest != (common.Hash{}) { + return errInvalidMixDigest + } + + // Ensure that the block doesn't contain any uncles which are meaningless in PoA + if header.UncleHash != uncleHash { + return errInvalidUncleHash + } + + // Ensure that the block's difficulty is meaningful (may not be correct at this point) + if number > 0 { + if header.Difficulty == nil { + return errInvalidDifficulty + } + } + + // Verify that the gas limit is <= 2^63-1 + gasCap := uint64(0x7fffffffffffffff) + + if header.GasLimit > gasCap { + return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap) + } + + // All basic checks passed, verify cascading fields + return c.verifyCascadingFields(chain, header, parents) +} + +// validateHeaderExtraField validates that the extra-data contains both the vanity and signature. +// header.Extra = header.Vanity + header.ProducerBytes (optional) + header.Seal +func validateHeaderExtraField(extraBytes []byte) error { + if len(extraBytes) < types.ExtraVanityLength { + return errMissingVanity + } + + if len(extraBytes) < types.ExtraVanityLength+types.ExtraSealLength { + return errMissingSignature + } + + return nil +} + +// verifyCascadingFields verifies all the header fields that are not standalone, +// rather depend on a batch of previous headers. The caller may optionally pass +// in a batch of parents (ascending order) to avoid looking those up from the +// database. This is useful for concurrently verifying a batch of new headers. +func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *types.Header, parents []*types.Header) error { + // The genesis block is the always valid dead-end + number := header.Number.Uint64() + + if number == 0 { + return nil + } + + // Ensure that the block's timestamp isn't too close to it's parent + var parent *types.Header + + if len(parents) > 0 { + parent = parents[len(parents)-1] + } else { + parent = chain.GetHeader(header.ParentHash, number-1) + } + + if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash { + return consensus.ErrUnknownAncestor + } + + // Verify that the gasUsed is <= gasLimit + if header.GasUsed > header.GasLimit { + return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit) + } + + if !chain.Config().IsLondon(header.Number) { + // Verify BaseFee not present before EIP-1559 fork. + if header.BaseFee != nil { + return fmt.Errorf("invalid baseFee before fork: have %d, want ", header.BaseFee) + } + + if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil { + return err + } + } else if err := misc.VerifyEip1559Header(chain.Config(), parent, header); err != nil { + // Verify the header's EIP-1559 attributes. + return err + } + + if parent.Time+c.config.CalculatePeriod(number) > header.Time { + return ErrInvalidTimestamp + } + + // Retrieve the snapshot needed to verify this header and cache it + snap, err := c.snapshot(chain, number-1, header.ParentHash, parents) + if err != nil { + return err + } + + // Verify the validator list match the local contract + if IsSprintStart(number+1, c.config.CalculateSprint(number)) { + newValidators, err := c.spanner.GetCurrentValidatorsByBlockNrOrHash(context.Background(), rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber), number+1) + + if err != nil { + return err + } + + sort.Sort(valset.ValidatorsByAddress(newValidators)) + + headerVals, err := valset.ParseValidators(header.GetValidatorBytes(c.config)) + if err != nil { + return err + } + + if len(newValidators) != len(headerVals) { + return errInvalidSpanValidators + } + + for i, val := range newValidators { + if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) { + return errInvalidSpanValidators + } + } + } + + // verify the validator list in the last sprint block + if IsSprintStart(number, c.config.CalculateSprint(number)) { + parentValidatorBytes := parent.GetValidatorBytes(c.config) + validatorsBytes := make([]byte, len(snap.ValidatorSet.Validators)*validatorHeaderBytesLength) + + currentValidators := snap.ValidatorSet.Copy().Validators + // sort validator by address + sort.Sort(valset.ValidatorsByAddress(currentValidators)) + + for i, validator := range currentValidators { + copy(validatorsBytes[i*validatorHeaderBytesLength:], validator.HeaderBytes()) + } + // len(header.Extra) >= extraVanity+extraSeal has already been validated in validateHeaderExtraField, so this won't result in a panic + if !bytes.Equal(parentValidatorBytes, validatorsBytes) { + return &MismatchingValidatorsError{number - 1, validatorsBytes, parentValidatorBytes} + } + } + + // All basic checks passed, verify the seal and return + return c.verifySeal(chain, header, parents) +} + +// snapshot retrieves the authorization snapshot at a given point in time. +// nolint: gocognit +func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash common.Hash, parents []*types.Header) (*Snapshot, error) { + // Search for a snapshot in memory or on disk for checkpoints + signer := common.BytesToAddress(c.authorizedSigner.Load().signer.Bytes()) + if c.devFakeAuthor && signer.String() != "0x0000000000000000000000000000000000000000" { + log.Info("👨‍💻Using DevFakeAuthor", "signer", signer) + + val := valset.NewValidator(signer, 1000) + validatorset := valset.NewValidatorSet([]*valset.Validator{val}) + + snapshot := newSnapshot(c.config, c.signatures, number, hash, validatorset.Validators) + + return snapshot, nil + } + + var snap *Snapshot + + headers := make([]*types.Header, 0, 16) + + //nolint:govet + for snap == nil { + // If an in-memory snapshot was found, use that + if s, ok := c.recents.Get(hash); ok { + snap = s.(*Snapshot) + + break + } + + // If an on-disk checkpoint snapshot can be found, use that + if number%checkpointInterval == 0 { + if s, err := loadSnapshot(c.config, c.signatures, c.db, hash); err == nil { + log.Trace("Loaded snapshot from disk", "number", number, "hash", hash) + + snap = s + + break + } + } + + // If we're at the genesis, snapshot the initial state. Alternatively if we're + // at a checkpoint block without a parent (light client CHT), or we have piled + // up more headers than allowed to be reorged (chain reinit from a freezer), + // consider the checkpoint trusted and snapshot it. + + // TODO fix this + // nolint:nestif + if number == 0 { + checkpoint := chain.GetHeaderByNumber(number) + if checkpoint != nil { + // get checkpoint data + hash := checkpoint.Hash() + + // get validators and current span + validators, err := c.spanner.GetCurrentValidatorsByHash(context.Background(), hash, number+1) + if err != nil { + return nil, err + } + + // new snap shot + snap = newSnapshot(c.config, c.signatures, number, hash, validators) + if err := snap.store(c.db); err != nil { + return nil, err + } + + log.Info("Stored checkpoint snapshot to disk", "number", number, "hash", hash) + + break + } + } + + // No snapshot for this header, gather the header and move backward + var header *types.Header + if len(parents) > 0 { + // If we have explicit parents, pick from there (enforced) + header = parents[len(parents)-1] + if header.Hash() != hash || header.Number.Uint64() != number { + return nil, consensus.ErrUnknownAncestor + } + + parents = parents[:len(parents)-1] + } else { + // No explicit parents (or no more left), reach out to the database + header = chain.GetHeader(hash, number) + if header == nil { + return nil, consensus.ErrUnknownAncestor + } + } + + headers = append(headers, header) + number, hash = number-1, header.ParentHash + } + + // check if snapshot is nil + if snap == nil { + return nil, fmt.Errorf("unknown error while retrieving snapshot at block number %v", number) + } + + // Previous snapshot found, apply any pending headers on top of it + for i := 0; i < len(headers)/2; i++ { + headers[i], headers[len(headers)-1-i] = headers[len(headers)-1-i], headers[i] + } + + snap, err := snap.apply(headers) + if err != nil { + return nil, err + } + + c.recents.Add(snap.Hash, snap) + + // If we've generated a new checkpoint snapshot, save to disk + if snap.Number%checkpointInterval == 0 && len(headers) > 0 { + if err = snap.store(c.db); err != nil { + return nil, err + } + + log.Trace("Stored snapshot to disk", "number", snap.Number, "hash", snap.Hash) + } + + return snap, err +} + +// VerifyUncles implements consensus.Engine, always returning an error for any +// uncles as this consensus mechanism doesn't permit uncles. +func (c *Bor) VerifyUncles(_ consensus.ChainReader, block *types.Block) error { + if len(block.Uncles()) > 0 { + return errUncleDetected + } + + return nil +} + +// VerifySeal implements consensus.Engine, checking whether the signature contained +// in the header satisfies the consensus protocol requirements. +func (c *Bor) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error { + return c.verifySeal(chain, header, nil) +} + +// verifySeal checks whether the signature contained in the header satisfies the +// consensus protocol requirements. The method accepts an optional list of parent +// headers that aren't yet part of the local blockchain to generate the snapshots +// from. +func (c *Bor) verifySeal(chain consensus.ChainHeaderReader, header *types.Header, parents []*types.Header) error { + // Verifying the genesis block is not supported + number := header.Number.Uint64() + if number == 0 { + return errUnknownBlock + } + // Retrieve the snapshot needed to verify this header and cache it + snap, err := c.snapshot(chain, number-1, header.ParentHash, parents) + if err != nil { + return err + } + + // Resolve the authorization key and check against signers + signer, err := ecrecover(header, c.signatures, c.config) + if err != nil { + return err + } + + if !snap.ValidatorSet.HasAddress(signer) { + // Check the UnauthorizedSignerError.Error() msg to see why we pass number-1 + return &UnauthorizedSignerError{number - 1, signer.Bytes()} + } + + succession, err := snap.GetSignerSuccessionNumber(signer) + if err != nil { + return err + } + + var parent *types.Header + if len(parents) > 0 { // if parents is nil, len(parents) is zero + parent = parents[len(parents)-1] + } else if number > 0 { + parent = chain.GetHeader(header.ParentHash, number-1) + } + + if IsBlockOnTime(parent, header, number, succession, c.config) { + return &BlockTooSoonError{number, succession} + } + + // Ensure that the difficulty corresponds to the turn-ness of the signer + if !c.fakeDiff { + difficulty := Difficulty(snap.ValidatorSet, signer) + if header.Difficulty.Uint64() != difficulty { + return &WrongDifficultyError{number, difficulty, header.Difficulty.Uint64(), signer.Bytes()} + } + } + + return nil +} + +func IsBlockOnTime(parent *types.Header, header *types.Header, number uint64, succession int, cfg *params.BorConfig) bool { + return parent != nil && header.Time < parent.Time+CalcProducerDelay(number, succession, cfg) +} + +// Prepare implements consensus.Engine, preparing all the consensus fields of the +// header for running the transactions on top. +func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { + // If the block isn't a checkpoint, cast a random vote (good enough for now) + header.Coinbase = common.Address{} + header.Nonce = types.BlockNonce{} + + number := header.Number.Uint64() + // Assemble the validator snapshot to check which votes make sense + snap, err := c.snapshot(chain, number-1, header.ParentHash, nil) + if err != nil { + return err + } + + currentSigner := *c.authorizedSigner.Load() + + // Set the correct difficulty + header.Difficulty = new(big.Int).SetUint64(Difficulty(snap.ValidatorSet, currentSigner.signer)) + + // Ensure the extra data has all it's components + if len(header.Extra) < types.ExtraVanityLength { + header.Extra = append(header.Extra, bytes.Repeat([]byte{0x00}, types.ExtraVanityLength-len(header.Extra))...) + } + + header.Extra = header.Extra[:types.ExtraVanityLength] + + // get validator set if number + if IsSprintStart(number+1, c.config.CalculateSprint(number)) { + newValidators, err := c.spanner.GetCurrentValidatorsByHash(context.Background(), header.ParentHash, number+1) + if err != nil { + return errUnknownValidators + } + + // sort validator by address + sort.Sort(valset.ValidatorsByAddress(newValidators)) + + if c.config.IsParallelUniverse(header.Number) { + var tempValidatorBytes []byte + + for _, validator := range newValidators { + tempValidatorBytes = append(tempValidatorBytes, validator.HeaderBytes()...) + } + + blockExtraData := &types.BlockExtraData{ + ValidatorBytes: tempValidatorBytes, + TxDependency: nil, + } + + blockExtraDataBytes, err := rlp.EncodeToBytes(blockExtraData) + if err != nil { + log.Error("error while encoding block extra data: %v", err) + return fmt.Errorf("error while encoding block extra data: %v", err) + } + + header.Extra = append(header.Extra, blockExtraDataBytes...) + } else { + for _, validator := range newValidators { + header.Extra = append(header.Extra, validator.HeaderBytes()...) + } + } + } else if c.config.IsParallelUniverse(header.Number) { + blockExtraData := &types.BlockExtraData{ + ValidatorBytes: nil, + TxDependency: nil, + } + + blockExtraDataBytes, err := rlp.EncodeToBytes(blockExtraData) + if err != nil { + log.Error("error while encoding block extra data: %v", err) + return fmt.Errorf("error while encoding block extra data: %v", err) + } + + header.Extra = append(header.Extra, blockExtraDataBytes...) + } + + // add extra seal space + header.Extra = append(header.Extra, make([]byte, types.ExtraSealLength)...) + + // Mix digest is reserved for now, set to empty + header.MixDigest = common.Hash{} + + // Ensure the timestamp has the correct delay + parent := chain.GetHeader(header.ParentHash, number-1) + if parent == nil { + return consensus.ErrUnknownAncestor + } + + var succession int + // if signer is not empty + if currentSigner.signer != (common.Address{}) { + succession, err = snap.GetSignerSuccessionNumber(currentSigner.signer) + if err != nil { + return err + } + } + + header.Time = parent.Time + CalcProducerDelay(number, succession, c.config) + if header.Time < uint64(time.Now().Unix()) { + header.Time = uint64(time.Now().Unix()) + } + + return nil +} + +// Finalize implements consensus.Engine, ensuring no uncles are set, nor block +// rewards given. +func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, _ []*types.Transaction, _ []*types.Header, withdrawals []*types.Withdrawal) { + var ( + stateSyncData []*types.StateSyncData + err error + ) + + headerNumber := header.Number.Uint64() + + if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) { + ctx := context.Background() + cx := statefull.ChainContext{Chain: chain, Bor: c} + // check and commit span + if err := c.checkAndCommitSpan(ctx, state, header, cx); err != nil { + log.Error("Error while committing span", "error", err) + return + } + + if c.HeimdallClient != nil { + // commit states + stateSyncData, err = c.CommitStates(ctx, state, header, cx) + if err != nil { + log.Error("Error while committing states", "error", err) + return + } + } + } + + if err = c.changeContractCodeIfNeeded(headerNumber, state); err != nil { + log.Error("Error changing contract code", "error", err) + return + } + + // No block rewards in PoA, so the state remains as is and uncles are dropped + header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) + header.UncleHash = types.CalcUncleHash(nil) + + // Set state sync data to blockchain + bc := chain.(*core.BlockChain) + bc.SetStateSync(stateSyncData) +} + +func decodeGenesisAlloc(i interface{}) (core.GenesisAlloc, error) { + var alloc core.GenesisAlloc + + b, err := json.Marshal(i) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(b, &alloc); err != nil { + return nil, err + } + + return alloc, nil +} + +func (c *Bor) changeContractCodeIfNeeded(headerNumber uint64, state *state.StateDB) error { + for blockNumber, genesisAlloc := range c.config.BlockAlloc { + if blockNumber == strconv.FormatUint(headerNumber, 10) { + allocs, err := decodeGenesisAlloc(genesisAlloc) + if err != nil { + return fmt.Errorf("failed to decode genesis alloc: %w", err) + } + + for addr, account := range allocs { + log.Info("change contract code", "address", addr) + state.SetCode(addr, account.Code) + } + } + } + + return nil +} + +// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, +// nor block rewards given, and returns the final block. +func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { + finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble") + defer tracing.EndSpan(finalizeSpan) + + stateSyncData := []*types.StateSyncData{} + + headerNumber := header.Number.Uint64() + + var err error + + if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) { + cx := statefull.ChainContext{Chain: chain, Bor: c} + + tracing.Exec(finalizeCtx, "", "bor.checkAndCommitSpan", func(ctx context.Context, span trace.Span) { + // check and commit span + err = c.checkAndCommitSpan(finalizeCtx, state, header, cx) + }) + + if err != nil { + log.Error("Error while committing span", "error", err) + return nil, err + } + + if c.HeimdallClient != nil { + tracing.Exec(finalizeCtx, "", "bor.checkAndCommitSpan", func(ctx context.Context, span trace.Span) { + // commit states + stateSyncData, err = c.CommitStates(finalizeCtx, state, header, cx) + }) + + if err != nil { + log.Error("Error while committing states", "error", err) + return nil, err + } + } + } + + tracing.Exec(finalizeCtx, "", "bor.changeContractCodeIfNeeded", func(ctx context.Context, span trace.Span) { + err = c.changeContractCodeIfNeeded(headerNumber, state) + }) + + if err != nil { + log.Error("Error changing contract code", "error", err) + return nil, err + } + + // No block rewards in PoA, so the state remains as it is + tracing.Exec(finalizeCtx, "", "bor.IntermediateRoot", func(ctx context.Context, span trace.Span) { + header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) + }) + + // Uncles are dropped + header.UncleHash = types.CalcUncleHash(nil) + + // Assemble block + block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) + + // set state sync + bc := chain.(core.BorStateSyncer) + bc.SetStateSync(stateSyncData) + + tracing.SetAttributes( + finalizeSpan, + attribute.Int("number", int(header.Number.Int64())), + attribute.String("hash", header.Hash().String()), + attribute.Int("number of txs", len(txs)), + attribute.Int("gas used", int(block.GasUsed())), + ) + + // return the final block for sealing + return block, nil +} + +// Authorize injects a private key into the consensus engine to mint new blocks +// with. +func (c *Bor) Authorize(currentSigner common.Address, signFn SignerFn) { + c.authorizedSigner.Store(&signer{ + signer: currentSigner, + signFn: signFn, + }) +} + +// Seal implements consensus.Engine, attempting to create a sealed block using +// the local signing credentials. +func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { + _, sealSpan := tracing.StartSpan(ctx, "bor.Seal") + + var endSpan bool = true + + defer func() { + // Only end span in case of early-returns/errors + if endSpan { + tracing.EndSpan(sealSpan) + } + }() + + header := block.Header() + // Sealing the genesis block is not supported + number := header.Number.Uint64() + if number == 0 { + return errUnknownBlock + } + // For 0-period chains, refuse to seal empty blocks (no reward but would spin sealing) + if c.config.CalculatePeriod(number) == 0 && len(block.Transactions()) == 0 { + log.Info("Sealing paused, waiting for transactions") + return nil + } + + // Don't hold the signer fields for the entire sealing procedure + currentSigner := *c.authorizedSigner.Load() + + snap, err := c.snapshot(chain, number-1, header.ParentHash, nil) + if err != nil { + return err + } + + // Bail out if we're unauthorized to sign a block + if !snap.ValidatorSet.HasAddress(currentSigner.signer) { + // Check the UnauthorizedSignerError.Error() msg to see why we pass number-1 + return &UnauthorizedSignerError{number - 1, currentSigner.signer.Bytes()} + } + + successionNumber, err := snap.GetSignerSuccessionNumber(currentSigner.signer) + if err != nil { + return err + } + + // Sweet, the protocol permits us to sign the block, wait for our time + delay := time.Unix(int64(header.Time), 0).Sub(time.Now()) // nolint: gosimple + // wiggle was already accounted for in header.Time, this is just for logging + wiggle := time.Duration(successionNumber) * time.Duration(c.config.CalculateBackupMultiplier(number)) * time.Second + + // Sign all the things! + err = Sign(currentSigner.signFn, currentSigner.signer, header, c.config) + if err != nil { + return err + } + + // Wait until sealing is terminated or delay timeout. + log.Info("Waiting for slot to sign and propagate", "number", number, "hash", header.Hash, "delay-in-sec", uint(delay), "delay", common.PrettyDuration(delay)) + + go func(sealSpan trace.Span) { + select { + case <-stop: + log.Debug("Discarding sealing operation for block", "number", number) + return + case <-time.After(delay): + if wiggle > 0 { + log.Info( + "Sealing out-of-turn", + "number", number, + "hash", header.Hash, + "wiggle-in-sec", uint(wiggle), + "wiggle", common.PrettyDuration(wiggle), + "in-turn-signer", snap.ValidatorSet.GetProposer().Address.Hex(), + ) + } + + log.Info( + "Sealing successful", + "number", number, + "delay", delay, + "headerDifficulty", header.Difficulty, + ) + + tracing.SetAttributes( + sealSpan, + attribute.Int("number", int(number)), + attribute.String("hash", header.Hash().String()), + attribute.Int("delay", int(delay.Milliseconds())), + attribute.Int("wiggle", int(wiggle.Milliseconds())), + attribute.Bool("out-of-turn", wiggle > 0), + ) + + tracing.EndSpan(sealSpan) + } + select { + case results <- block.WithSeal(header): + default: + log.Warn("Sealing result was not read by miner", "number", number, "sealhash", SealHash(header, c.config)) + } + }(sealSpan) + + // Set the endSpan flag to false, as the go routine will handle it + endSpan = false + + return nil +} + +func Sign(signFn SignerFn, signer common.Address, header *types.Header, c *params.BorConfig) error { + sighash, err := signFn(accounts.Account{Address: signer}, accounts.MimetypeBor, BorRLP(header, c)) + if err != nil { + return err + } + + copy(header.Extra[len(header.Extra)-types.ExtraSealLength:], sighash) + + return nil +} + +// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty +// that a new block should have based on the previous blocks in the chain and the +// current signer. +func (c *Bor) CalcDifficulty(chain consensus.ChainHeaderReader, _ uint64, parent *types.Header) *big.Int { + snap, err := c.snapshot(chain, parent.Number.Uint64(), parent.Hash(), nil) + if err != nil { + return nil + } + + return new(big.Int).SetUint64(Difficulty(snap.ValidatorSet, c.authorizedSigner.Load().signer)) +} + +// SealHash returns the hash of a block prior to it being sealed. +func (c *Bor) SealHash(header *types.Header) common.Hash { + return SealHash(header, c.config) +} + +// APIs implements consensus.Engine, returning the user facing RPC API to allow +// controlling the signer voting. +func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API { + return []rpc.API{{ + Namespace: "bor", + Version: "1.0", + Service: &API{chain: chain, bor: c}, + Public: false, + }} +} + +// Close implements consensus.Engine. It's a noop for bor as there are no background threads. +func (c *Bor) Close() error { + c.closeOnce.Do(func() { + if c.HeimdallClient != nil { + c.HeimdallClient.Close() + } + }) + + return nil +} + +func (c *Bor) checkAndCommitSpan( + ctx context.Context, + state *state.StateDB, + header *types.Header, + chain core.ChainContext, +) error { + headerNumber := header.Number.Uint64() + + span, err := c.spanner.GetCurrentSpan(ctx, header.ParentHash) + if err != nil { + return err + } + + if c.needToCommitSpan(span, headerNumber) { + return c.FetchAndCommitSpan(ctx, span.ID+1, state, header, chain) + } + + return nil +} + +func (c *Bor) needToCommitSpan(currentSpan *span.Span, headerNumber uint64) bool { + // if span is nil + if currentSpan == nil { + return false + } + + // check span is not set initially + if currentSpan.EndBlock == 0 { + return true + } + + // if current block is first block of last sprint in current span + if currentSpan.EndBlock > c.config.CalculateSprint(headerNumber) && currentSpan.EndBlock-c.config.CalculateSprint(headerNumber)+1 == headerNumber { + return true + } + + return false +} + +func (c *Bor) FetchAndCommitSpan( + ctx context.Context, + newSpanID uint64, + state *state.StateDB, + header *types.Header, + chain core.ChainContext, +) error { + var heimdallSpan span.HeimdallSpan + + if c.HeimdallClient == nil { + // fixme: move to a new mock or fake and remove c.HeimdallClient completely + s, err := c.getNextHeimdallSpanForTest(ctx, newSpanID, header, chain) + if err != nil { + return err + } + + heimdallSpan = *s + } else { + response, err := c.HeimdallClient.Span(ctx, newSpanID) + if err != nil { + return err + } + + heimdallSpan = *response + } + + // check if chain id matches with Heimdall span + if heimdallSpan.ChainID != c.chainConfig.ChainID.String() { + return fmt.Errorf( + "chain id proposed span, %s, and bor chain id, %s, doesn't match", + heimdallSpan.ChainID, + c.chainConfig.ChainID, + ) + } + + return c.spanner.CommitSpan(ctx, heimdallSpan, state, header, chain) +} + +// CommitStates commit states +func (c *Bor) CommitStates( + ctx context.Context, + state *state.StateDB, + header *types.Header, + chain statefull.ChainContext, +) ([]*types.StateSyncData, error) { + fetchStart := time.Now() + number := header.Number.Uint64() + + var ( + lastStateIDBig *big.Int + from uint64 + to time.Time + err error + ) + + if c.config.IsIndore(header.Number) { + // Fetch the LastStateId from contract via current state instance + lastStateIDBig, err = c.GenesisContractsClient.LastStateId(state.Copy(), number-1, header.ParentHash) + if err != nil { + return nil, err + } + + stateSyncDelay := c.config.CalculateStateSyncDelay(number) + to = time.Unix(int64(header.Time-stateSyncDelay), 0) + } else { + lastStateIDBig, err = c.GenesisContractsClient.LastStateId(nil, number-1, header.ParentHash) + if err != nil { + return nil, err + } + + to = time.Unix(int64(chain.Chain.GetHeaderByNumber(number-c.config.CalculateSprint(number)).Time), 0) + } + + lastStateID := lastStateIDBig.Uint64() + from = lastStateID + 1 + + log.Info( + "Fetching state updates from Heimdall", + "fromID", from, + "to", to.Format(time.RFC3339)) + + eventRecords, err := c.HeimdallClient.StateSyncEvents(ctx, from, to.Unix()) + if err != nil { + log.Error("Error occurred when fetching state sync events", "fromID", from, "to", to.Unix(), "err", err) + } + + if c.config.OverrideStateSyncRecords != nil { + if val, ok := c.config.OverrideStateSyncRecords[strconv.FormatUint(number, 10)]; ok { + eventRecords = eventRecords[0:val] + } + } + + fetchTime := time.Since(fetchStart) + processStart := time.Now() + totalGas := 0 /// limit on gas for state sync per block + chainID := c.chainConfig.ChainID.String() + stateSyncs := make([]*types.StateSyncData, 0, len(eventRecords)) + + var gasUsed uint64 + + for _, eventRecord := range eventRecords { + if eventRecord.ID <= lastStateID { + continue + } + + if err = validateEventRecord(eventRecord, number, to, lastStateID, chainID); err != nil { + log.Error("while validating event record", "block", number, "to", to, "stateID", lastStateID+1, "error", err.Error()) + break + } + + stateData := types.StateSyncData{ + ID: eventRecord.ID, + Contract: eventRecord.Contract, + Data: hex.EncodeToString(eventRecord.Data), + TxHash: eventRecord.TxHash, + } + + stateSyncs = append(stateSyncs, &stateData) + + // we expect that this call MUST emit an event, otherwise we wouldn't make a receipt + // if the receiver address is not a contract then we'll skip the most of the execution and emitting an event as well + // https://github.com/maticnetwork/genesis-contracts/blob/master/contracts/StateReceiver.sol#L27 + gasUsed, err = c.GenesisContractsClient.CommitState(eventRecord, state, header, chain) + if err != nil { + return nil, err + } + + totalGas += int(gasUsed) + + lastStateID++ + } + + processTime := time.Since(processStart) + + log.Info("StateSyncData", "gas", totalGas, "number", number, "lastStateID", lastStateID, "total records", len(eventRecords), "fetch time", int(fetchTime.Milliseconds()), "process time", int(processTime.Milliseconds())) + + return stateSyncs, nil +} + +func validateEventRecord(eventRecord *clerk.EventRecordWithTime, number uint64, to time.Time, lastStateID uint64, chainID string) error { + // event id should be sequential and event.Time should lie in the range [from, to) + if lastStateID+1 != eventRecord.ID || eventRecord.ChainID != chainID || !eventRecord.Time.Before(to) { + return &InvalidStateReceivedError{number, lastStateID, &to, eventRecord} + } + + return nil +} + +func (c *Bor) SetHeimdallClient(h IHeimdallClient) { + c.HeimdallClient = h +} + +func (c *Bor) GetCurrentValidators(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) { + return c.spanner.GetCurrentValidatorsByHash(ctx, headerHash, blockNumber) +} + +// +// Private methods +// + +func (c *Bor) getNextHeimdallSpanForTest( + ctx context.Context, + newSpanID uint64, + header *types.Header, + chain core.ChainContext, +) (*span.HeimdallSpan, error) { + headerNumber := header.Number.Uint64() + + spanBor, err := c.spanner.GetCurrentSpan(ctx, header.ParentHash) + if err != nil { + return nil, err + } + + // get local chain context object + localContext := chain.(statefull.ChainContext) + // Retrieve the snapshot needed to verify this header and cache it + snap, err := c.snapshot(localContext.Chain, headerNumber-1, header.ParentHash, nil) + if err != nil { + return nil, err + } + + // new span + spanBor.ID = newSpanID + if spanBor.EndBlock == 0 { + spanBor.StartBlock = 256 + } else { + spanBor.StartBlock = spanBor.EndBlock + 1 + } + + spanBor.EndBlock = spanBor.StartBlock + (100 * c.config.CalculateSprint(headerNumber)) - 1 + + selectedProducers := make([]valset.Validator, len(snap.ValidatorSet.Validators)) + for i, v := range snap.ValidatorSet.Validators { + selectedProducers[i] = *v + } + + heimdallSpan := &span.HeimdallSpan{ + Span: *spanBor, + ValidatorSet: *snap.ValidatorSet, + SelectedProducers: selectedProducers, + ChainID: c.chainConfig.ChainID.String(), + } + + return heimdallSpan, nil +} + +func validatorContains(a []*valset.Validator, x *valset.Validator) (*valset.Validator, bool) { + for _, n := range a { + if n.Address == x.Address { + return n, true + } + } + + return nil, false +} + +func getUpdatedValidatorSet(oldValidatorSet *valset.ValidatorSet, newVals []*valset.Validator) *valset.ValidatorSet { + v := oldValidatorSet + oldVals := v.Validators + + changes := make([]*valset.Validator, 0, len(oldVals)) + + for _, ov := range oldVals { + if f, ok := validatorContains(newVals, ov); ok { + ov.VotingPower = f.VotingPower + } else { + ov.VotingPower = 0 + } + + changes = append(changes, ov) + } + + for _, nv := range newVals { + if _, ok := validatorContains(changes, nv); !ok { + changes = append(changes, nv) + } + } + + if err := v.UpdateWithChangeSet(changes); err != nil { + log.Error("Error while updating change set", "error", err) + } + + return v +} + +func IsSprintStart(number, sprint uint64) bool { + return number%sprint == 0 +} diff --git a/consensus/bor/bor_test.go b/consensus/bor/bor_test.go new file mode 100644 index 0000000000..590ddbc3a7 --- /dev/null +++ b/consensus/bor/bor_test.go @@ -0,0 +1,144 @@ +package bor + +import ( + "math/big" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" //nolint:typecheck + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" +) + +func TestGenesisContractChange(t *testing.T) { + t.Parallel() + + addr0 := common.Address{0x1} + + b := &Bor{ + config: ¶ms.BorConfig{ + Sprint: map[string]uint64{ + "0": 10, + }, // skip sprint transactions in sprint + BlockAlloc: map[string]interface{}{ + // write as interface since that is how it is decoded in genesis + "2": map[string]interface{}{ + addr0.Hex(): map[string]interface{}{ + "code": hexutil.Bytes{0x1, 0x2}, + "balance": "0", + }, + }, + "4": map[string]interface{}{ + addr0.Hex(): map[string]interface{}{ + "code": hexutil.Bytes{0x1, 0x3}, + "balance": "0x1000", + }, + }, + }, + }, + } + + genspec := &core.Genesis{ + Alloc: map[common.Address]core.GenesisAccount{ + addr0: { + Balance: big.NewInt(0), + Code: []byte{0x1, 0x1}, + }, + }, + Config: ¶ms.ChainConfig{}, + } + + db := rawdb.NewMemoryDatabase() + genesis := genspec.MustCommit(db) + + statedb, err := state.New(genesis.Root(), state.NewDatabase(db), nil) + require.NoError(t, err) + + chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genspec, nil, b, vm.Config{}, nil, nil, nil) + require.NoError(t, err) + + addBlock := func(root common.Hash, num int64) (common.Hash, *state.StateDB) { + h := &types.Header{ + ParentHash: root, + Number: big.NewInt(num), + } + b.Finalize(chain, h, statedb, nil, nil, nil) + + // write state to database + root, err := statedb.Commit(false) + require.NoError(t, err) + require.NoError(t, statedb.Database().TrieDB().Commit(root, true)) + + statedb, err := state.New(h.Root, state.NewDatabase(db), nil) + require.NoError(t, err) + + return root, statedb + } + + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x1}) + + root := genesis.Root() + + // code does not change + root, statedb = addBlock(root, 1) + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x1}) + + // code changes 1st time + root, statedb = addBlock(root, 2) + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2}) + + // code same as 1st change + root, statedb = addBlock(root, 3) + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2}) + + // code changes 2nd time + _, statedb = addBlock(root, 4) + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x3}) + + // make sure balance change DOES NOT take effect + require.Equal(t, statedb.GetBalance(addr0), big.NewInt(0)) +} + +func TestEncodeSigHeaderJaipur(t *testing.T) { + t.Parallel() + + // As part of the EIP-1559 fork in mumbai, an incorrect seal hash + // was used for Bor that did not included the BaseFee. The Jaipur + // block is a hard fork to fix that. + h := &types.Header{ + Difficulty: new(big.Int), + Number: big.NewInt(1), + Extra: make([]byte, 32+65), + } + + var ( + // hash for the block without the BaseFee + hashWithoutBaseFee = common.HexToHash("0x1be13e83939b3c4701ee57a34e10c9290ce07b0e53af0fe90b812c6881826e36") + // hash for the block with the baseFee + hashWithBaseFee = common.HexToHash("0xc55b0cac99161f71bde1423a091426b1b5b4d7598e5981ad802cce712771965b") + ) + + // Jaipur NOT enabled and BaseFee not set + hash := SealHash(h, ¶ms.BorConfig{JaipurBlock: big.NewInt(10)}) + require.Equal(t, hash, hashWithoutBaseFee) + + // Jaipur enabled (Jaipur=0) and BaseFee not set + hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: common.Big0}) + require.Equal(t, hash, hashWithoutBaseFee) + + h.BaseFee = big.NewInt(2) + + // Jaipur enabled (Jaipur=Header block) and BaseFee set + hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: common.Big1}) + require.Equal(t, hash, hashWithBaseFee) + + // Jaipur NOT enabled and BaseFee set + hash = SealHash(h, ¶ms.BorConfig{JaipurBlock: big.NewInt(10)}) + require.Equal(t, hash, hashWithoutBaseFee) +} diff --git a/consensus/bor/clerk/clerk.go b/consensus/bor/clerk/clerk.go new file mode 100644 index 0000000000..fedca3df16 --- /dev/null +++ b/consensus/bor/clerk/clerk.go @@ -0,0 +1,50 @@ +package clerk + +import ( + "fmt" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" +) + +// EventRecord represents state record +type EventRecord struct { + ID uint64 `json:"id" yaml:"id"` + Contract common.Address `json:"contract" yaml:"contract"` + Data hexutil.Bytes `json:"data" yaml:"data"` + TxHash common.Hash `json:"tx_hash" yaml:"tx_hash"` + LogIndex uint64 `json:"log_index" yaml:"log_index"` + ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"` +} + +type EventRecordWithTime struct { + EventRecord + Time time.Time `json:"record_time" yaml:"record_time"` +} + +// String returns the string representation of EventRecord +func (e *EventRecordWithTime) String(gasUsed uint64) string { + return fmt.Sprintf( + "id %v, contract %v, data: %v, txHash: %v, logIndex: %v, chainId: %v, time %s, gasUsed %d", + e.ID, + e.Contract.String(), + e.Data.String(), + e.TxHash.Hex(), + e.LogIndex, + e.ChainID, + e.Time.Format(time.RFC3339), + gasUsed, + ) +} + +func (e *EventRecordWithTime) BuildEventRecord() *EventRecord { + return &EventRecord{ + ID: e.ID, + Contract: e.Contract, + Data: e.Data, + TxHash: e.TxHash, + LogIndex: e.LogIndex, + ChainID: e.ChainID, + } +} diff --git a/consensus/bor/contract/client.go b/consensus/bor/contract/client.go new file mode 100644 index 0000000000..246939f1ac --- /dev/null +++ b/consensus/bor/contract/client.go @@ -0,0 +1,139 @@ +package contract + +import ( + "context" + "math" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/consensus/bor/api" + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" +) + +var ( + vABI, _ = abi.JSON(strings.NewReader(validatorsetABI)) + sABI, _ = abi.JSON(strings.NewReader(stateReceiverABI)) +) + +func ValidatorSet() abi.ABI { + return vABI +} + +func StateReceiver() abi.ABI { + return sABI +} + +type GenesisContractsClient struct { + validatorSetABI abi.ABI + stateReceiverABI abi.ABI + ValidatorContract string + StateReceiverContract string + chainConfig *params.ChainConfig + ethAPI api.Caller +} + +const ( + validatorsetABI = `[{"constant":true,"inputs":[],"name":"SPRINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SYSTEM_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHAIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"FIRST_END_BLOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"producers","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"power","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ROUND_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"BOR_ID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"spanNumbers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"VOTE_TYPE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"validators","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"power","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"spans","outputs":[{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"endBlock","type":"uint256"}],"name":"NewSpan","type":"event"},{"constant":true,"inputs":[],"name":"currentSprint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"}],"name":"getSpan","outputs":[{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCurrentSpan","outputs":[{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNextSpan","outputs":[{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"number","type":"uint256"}],"name":"getSpanByBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentSpanNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"}],"name":"getValidatorsTotalStakeBySpan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"}],"name":"getProducersTotalStakeBySpan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"name":"getValidatorBySigner","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"power","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"internalType":"struct BorValidatorSet.Validator","name":"result","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"name":"isValidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"},{"internalType":"address","name":"signer","type":"address"}],"name":"isProducer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"isCurrentValidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"isCurrentProducer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"number","type":"uint256"}],"name":"getBorValidators","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInitialValidators","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"newSpan","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"bytes","name":"validatorBytes","type":"bytes"},{"internalType":"bytes","name":"producerBytes","type":"bytes"}],"name":"commitSpan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"span","type":"uint256"},{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"bytes","name":"sigs","type":"bytes"}],"name":"getStakePowerBySigs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"rootHash","type":"bytes32"},{"internalType":"bytes32","name":"leaf","type":"bytes32"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"checkMembership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"d","type":"bytes32"}],"name":"leafNode","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"left","type":"bytes32"},{"internalType":"bytes32","name":"right","type":"bytes32"}],"name":"innerNode","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"}]` + stateReceiverABI = `[{"constant":true,"inputs":[],"name":"SYSTEM_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastStateId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"syncTime","type":"uint256"},{"internalType":"bytes","name":"recordBytes","type":"bytes"}],"name":"commitState","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]` +) + +func NewGenesisContractsClient( + chainConfig *params.ChainConfig, + validatorContract, + stateReceiverContract string, + ethAPI api.Caller, +) *GenesisContractsClient { + return &GenesisContractsClient{ + validatorSetABI: ValidatorSet(), + stateReceiverABI: StateReceiver(), + ValidatorContract: validatorContract, + StateReceiverContract: stateReceiverContract, + chainConfig: chainConfig, + ethAPI: ethAPI, + } +} + +func (gc *GenesisContractsClient) CommitState( + event *clerk.EventRecordWithTime, + state *state.StateDB, + header *types.Header, + chCtx statefull.ChainContext, +) (uint64, error) { + eventRecord := event.BuildEventRecord() + + recordBytes, err := rlp.EncodeToBytes(eventRecord) + if err != nil { + return 0, err + } + + const method = "commitState" + + t := event.Time.Unix() + + data, err := gc.stateReceiverABI.Pack(method, big.NewInt(0).SetInt64(t), recordBytes) + if err != nil { + log.Error("Unable to pack tx for commitState", "error", err) + return 0, err + } + + msg := statefull.GetSystemMessage(common.HexToAddress(gc.StateReceiverContract), data) + + log.Info("→ committing new state", "eventRecord", event.ID) + + gasUsed, err := statefull.ApplyMessage(context.Background(), msg, state, header, gc.chainConfig, chCtx) + + // Logging event log with time and individual gasUsed + log.Info("→ committed new state", "eventRecord", event.String(gasUsed)) + + if err != nil { + return 0, err + } + + return gasUsed, nil +} + +func (gc *GenesisContractsClient) LastStateId(state *state.StateDB, number uint64, hash common.Hash) (*big.Int, error) { + blockNr := rpc.BlockNumber(number) + + const method = "lastStateId" + + data, err := gc.stateReceiverABI.Pack(method) + if err != nil { + log.Error("Unable to pack tx for LastStateId", "error", err) + + return nil, err + } + + msgData := (hexutil.Bytes)(data) + toAddress := common.HexToAddress(gc.StateReceiverContract) + gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2)) + + // Do a call with state so that we can fetch the last state ID from a given (incoming) + // state instead of local(canonical) chain. + result, err := gc.ethAPI.CallWithState(context.Background(), ethapi.TransactionArgs{ + Gas: &gas, + To: &toAddress, + Data: &msgData, + }, rpc.BlockNumberOrHash{BlockNumber: &blockNr, BlockHash: &hash}, state, nil) + if err != nil { + return nil, err + } + + ret := new(*big.Int) + if err := gc.stateReceiverABI.UnpackIntoInterface(ret, method, result); err != nil { + return nil, err + } + + return *ret, nil +} diff --git a/consensus/bor/errors.go b/consensus/bor/errors.go new file mode 100644 index 0000000000..67f7ef53f3 --- /dev/null +++ b/consensus/bor/errors.go @@ -0,0 +1,116 @@ +package bor + +import ( + "fmt" + "time" + + "github.com/ethereum/go-ethereum/consensus/bor/clerk" +) + +type MaxCheckpointLengthExceededError struct { + Start uint64 + End uint64 +} + +func (e *MaxCheckpointLengthExceededError) Error() string { + return fmt.Sprintf( + "Start: %d and end block: %d exceed max allowed checkpoint length: %d", + e.Start, + e.End, + MaxCheckpointLength, + ) +} + +// MismatchingValidatorsError is returned if a last block in sprint contains a +// list of validators different from the one that local node calculated +type MismatchingValidatorsError struct { + Number uint64 + ValidatorSetSnap []byte + ValidatorSetHeader []byte +} + +func (e *MismatchingValidatorsError) Error() string { + return fmt.Sprintf( + "Mismatching validators at block %d\nValidatorBytes from snapshot: 0x%x\nValidatorBytes in Header: 0x%x\n", + e.Number, + e.ValidatorSetSnap, + e.ValidatorSetHeader, + ) +} + +type BlockTooSoonError struct { + Number uint64 + Succession int +} + +func (e *BlockTooSoonError) Error() string { + return fmt.Sprintf( + "Block %d was created too soon. Signer turn-ness number is %d\n", + e.Number, + e.Succession, + ) +} + +// UnauthorizedProposerError is returned if a header is [being] signed by an unauthorized entity. +type UnauthorizedProposerError struct { + Number uint64 + Proposer []byte +} + +func (e *UnauthorizedProposerError) Error() string { + return fmt.Sprintf( + "Proposer 0x%x is not a part of the producer set at block %d", + e.Proposer, + e.Number, + ) +} + +// UnauthorizedSignerError is returned if a header is [being] signed by an unauthorized entity. +type UnauthorizedSignerError struct { + Number uint64 + Signer []byte +} + +func (e *UnauthorizedSignerError) Error() string { + return fmt.Sprintf( + "Signer 0x%x is not a part of the producer set at block %d", + e.Signer, + e.Number, + ) +} + +// WrongDifficultyError is returned if the difficulty of a block doesn't match the +// turn of the signer. +type WrongDifficultyError struct { + Number uint64 + Expected uint64 + Actual uint64 + Signer []byte +} + +func (e *WrongDifficultyError) Error() string { + return fmt.Sprintf( + "Wrong difficulty at block %d, expected: %d, actual %d. Signer was %x\n", + e.Number, + e.Expected, + e.Actual, + e.Signer, + ) +} + +type InvalidStateReceivedError struct { + Number uint64 + LastStateID uint64 + To *time.Time + Event *clerk.EventRecordWithTime +} + +func (e *InvalidStateReceivedError) Error() string { + return fmt.Sprintf( + "Received invalid event %v at block %d. Requested events until %s. Last state id was %d", + e.Event, + e.Number, + e.To.Format(time.RFC3339), + e.LastStateID, + ) +} diff --git a/consensus/bor/genesis.go b/consensus/bor/genesis.go new file mode 100644 index 0000000000..9519b18847 --- /dev/null +++ b/consensus/bor/genesis.go @@ -0,0 +1,17 @@ +package bor + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" +) + +//go:generate mockgen -destination=./genesis_contract_mock.go -package=bor . GenesisContract +type GenesisContract interface { + CommitState(event *clerk.EventRecordWithTime, state *state.StateDB, header *types.Header, chCtx statefull.ChainContext) (uint64, error) + LastStateId(state *state.StateDB, number uint64, hash common.Hash) (*big.Int, error) +} diff --git a/consensus/bor/genesis_contract_mock.go b/consensus/bor/genesis_contract_mock.go new file mode 100644 index 0000000000..0296cbe905 --- /dev/null +++ b/consensus/bor/genesis_contract_mock.go @@ -0,0 +1,70 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/ethereum/go-ethereum/consensus/bor (interfaces: GenesisContract) + +// Package bor is a generated GoMock package. +package bor + +import ( + big "math/big" + reflect "reflect" + + common "github.com/ethereum/go-ethereum/common" + clerk "github.com/ethereum/go-ethereum/consensus/bor/clerk" + statefull "github.com/ethereum/go-ethereum/consensus/bor/statefull" + state "github.com/ethereum/go-ethereum/core/state" + types "github.com/ethereum/go-ethereum/core/types" + gomock "github.com/golang/mock/gomock" +) + +// MockGenesisContract is a mock of GenesisContract interface. +type MockGenesisContract struct { + ctrl *gomock.Controller + recorder *MockGenesisContractMockRecorder +} + +// MockGenesisContractMockRecorder is the mock recorder for MockGenesisContract. +type MockGenesisContractMockRecorder struct { + mock *MockGenesisContract +} + +// NewMockGenesisContract creates a new mock instance. +func NewMockGenesisContract(ctrl *gomock.Controller) *MockGenesisContract { + mock := &MockGenesisContract{ctrl: ctrl} + mock.recorder = &MockGenesisContractMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGenesisContract) EXPECT() *MockGenesisContractMockRecorder { + return m.recorder +} + +// CommitState mocks base method. +func (m *MockGenesisContract) CommitState(arg0 *clerk.EventRecordWithTime, arg1 *state.StateDB, arg2 *types.Header, arg3 statefull.ChainContext) (uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitState", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitState indicates an expected call of CommitState. +func (mr *MockGenesisContractMockRecorder) CommitState(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitState", reflect.TypeOf((*MockGenesisContract)(nil).CommitState), arg0, arg1, arg2, arg3) +} + +// LastStateId mocks base method. +func (m *MockGenesisContract) LastStateId(arg0 *state.StateDB, arg1 uint64, arg2 common.Hash) (*big.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LastStateId", arg0, arg1, arg2) + ret0, _ := ret[0].(*big.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// LastStateId indicates an expected call of LastStateId. +func (mr *MockGenesisContractMockRecorder) LastStateId(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LastStateId", reflect.TypeOf((*MockGenesisContract)(nil).LastStateId), arg0, arg1, arg2) +} diff --git a/consensus/bor/heimdall.go b/consensus/bor/heimdall.go new file mode 100644 index 0000000000..a093cc95da --- /dev/null +++ b/consensus/bor/heimdall.go @@ -0,0 +1,24 @@ +package bor + +import ( + "context" + + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/milestone" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" +) + +//go:generate mockgen -destination=../../tests/bor/mocks/IHeimdallClient.go -package=mocks . IHeimdallClient +type IHeimdallClient interface { + StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) + Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) + FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) + FetchCheckpointCount(ctx context.Context) (int64, error) + FetchMilestone(ctx context.Context) (*milestone.Milestone, error) + FetchMilestoneCount(ctx context.Context) (int64, error) + FetchNoAckMilestone(ctx context.Context, milestoneID string) error //Fetch the bool value whether milestone corresponding to the given id failed in the Heimdall + FetchLastNoAckMilestone(ctx context.Context) (string, error) //Fetch latest failed milestone id + FetchMilestoneID(ctx context.Context, milestoneID string) error //Fetch the bool value whether milestone corresponding to the given id is in process in Heimdall + Close() +} diff --git a/consensus/bor/heimdall/checkpoint/checkpoint.go b/consensus/bor/heimdall/checkpoint/checkpoint.go new file mode 100644 index 0000000000..3f85f2a233 --- /dev/null +++ b/consensus/bor/heimdall/checkpoint/checkpoint.go @@ -0,0 +1,31 @@ +package checkpoint + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" +) + +// Checkpoint defines a response object type of bor checkpoint +type Checkpoint struct { + Proposer common.Address `json:"proposer"` + StartBlock *big.Int `json:"start_block"` + EndBlock *big.Int `json:"end_block"` + RootHash common.Hash `json:"root_hash"` + BorChainID string `json:"bor_chain_id"` + Timestamp uint64 `json:"timestamp"` +} + +type CheckpointResponse struct { + Height string `json:"height"` + Result Checkpoint `json:"result"` +} + +type CheckpointCount struct { + Result int64 `json:"result"` +} + +type CheckpointCountResponse struct { + Height string `json:"height"` + Result CheckpointCount `json:"result"` +} diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go new file mode 100644 index 0000000000..6f696a3ac2 --- /dev/null +++ b/consensus/bor/heimdall/client.go @@ -0,0 +1,460 @@ +package heimdall + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "sort" + "time" + + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/milestone" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" +) + +var ( + // ErrShutdownDetected is returned if a shutdown was detected + ErrShutdownDetected = errors.New("shutdown detected") + ErrNoResponse = errors.New("got a nil response") + ErrNotSuccessfulResponse = errors.New("error while fetching data from Heimdall") + ErrNotInRejectedList = errors.New("milestoneID doesn't exist in rejected list") + ErrNotInMilestoneList = errors.New("milestoneID doesn't exist in Heimdall") +) + +const ( + stateFetchLimit = 50 + apiHeimdallTimeout = 5 * time.Second + retryCall = 5 * time.Second +) + +type StateSyncEventsResponse struct { + Height string `json:"height"` + Result []*clerk.EventRecordWithTime `json:"result"` +} + +type SpanResponse struct { + Height string `json:"height"` + Result span.HeimdallSpan `json:"result"` +} + +type HeimdallClient struct { + urlString string + client http.Client + closeCh chan struct{} +} + +type Request struct { + client http.Client + url *url.URL + start time.Time +} + +func NewHeimdallClient(urlString string) *HeimdallClient { + return &HeimdallClient{ + urlString: urlString, + client: http.Client{ + Timeout: apiHeimdallTimeout, + }, + closeCh: make(chan struct{}), + } +} + +const ( + fetchStateSyncEventsFormat = "from-id=%d&to-time=%d&limit=%d" + fetchStateSyncEventsPath = "clerk/event-record/list" + + fetchCheckpoint = "/checkpoints/%s" + fetchCheckpointCount = "/checkpoints/count" + + fetchMilestone = "/milestone/latest" + fetchMilestoneCount = "/milestone/count" + + fetchLastNoAckMilestone = "/milestone/lastNoAck" + fetchNoAckMilestone = "/milestone/noAck/%s" + fetchMilestoneID = "/milestone/ID/%s" + + fetchSpanFormat = "bor/span/%d" +) + +func (h *HeimdallClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) { + eventRecords := make([]*clerk.EventRecordWithTime, 0) + + for { + url, err := stateSyncURL(h.urlString, fromID, to) + if err != nil { + return nil, err + } + + log.Info("Fetching state sync events", "queryParams", url.RawQuery) + + ctx = withRequestType(ctx, stateSyncRequest) + + response, err := FetchWithRetry[StateSyncEventsResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return nil, err + } + + if response == nil || response.Result == nil { + // status 204 + break + } + + eventRecords = append(eventRecords, response.Result...) + + if len(response.Result) < stateFetchLimit { + break + } + + fromID += uint64(stateFetchLimit) + } + + sort.SliceStable(eventRecords, func(i, j int) bool { + return eventRecords[i].ID < eventRecords[j].ID + }) + + return eventRecords, nil +} + +func (h *HeimdallClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) { + url, err := spanURL(h.urlString, spanID) + if err != nil { + return nil, err + } + + ctx = withRequestType(ctx, spanRequest) + + response, err := FetchWithRetry[SpanResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return nil, err + } + + return &response.Result, nil +} + +// FetchCheckpoint fetches the checkpoint from heimdall +func (h *HeimdallClient) FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) { + url, err := checkpointURL(h.urlString, number) + if err != nil { + return nil, err + } + + ctx = withRequestType(ctx, checkpointRequest) + + response, err := FetchWithRetry[checkpoint.CheckpointResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return nil, err + } + + return &response.Result, nil +} + +// FetchMilestone fetches the checkpoint from heimdall +func (h *HeimdallClient) FetchMilestone(ctx context.Context) (*milestone.Milestone, error) { + url, err := milestoneURL(h.urlString) + if err != nil { + return nil, err + } + + ctx = withRequestType(ctx, milestoneRequest) + + response, err := FetchWithRetry[milestone.MilestoneResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return nil, err + } + + return &response.Result, nil +} + +// FetchCheckpointCount fetches the checkpoint count from heimdall +func (h *HeimdallClient) FetchCheckpointCount(ctx context.Context) (int64, error) { + url, err := checkpointCountURL(h.urlString) + if err != nil { + return 0, err + } + + ctx = withRequestType(ctx, checkpointCountRequest) + + response, err := FetchWithRetry[checkpoint.CheckpointCountResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return 0, err + } + + return response.Result.Result, nil +} + +// FetchMilestoneCount fetches the milestone count from heimdall +func (h *HeimdallClient) FetchMilestoneCount(ctx context.Context) (int64, error) { + url, err := milestoneCountURL(h.urlString) + if err != nil { + return 0, err + } + + ctx = withRequestType(ctx, milestoneCountRequest) + + response, err := FetchWithRetry[milestone.MilestoneCountResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return 0, err + } + + return response.Result.Count, nil +} + +// FetchLastNoAckMilestone fetches the last no-ack-milestone from heimdall +func (h *HeimdallClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) { + url, err := lastNoAckMilestoneURL(h.urlString) + if err != nil { + return "", err + } + + ctx = withRequestType(ctx, milestoneLastNoAckRequest) + + response, err := FetchWithRetry[milestone.MilestoneLastNoAckResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return "", err + } + + return response.Result.Result, nil +} + +// FetchNoAckMilestone fetches the last no-ack-milestone from heimdall +func (h *HeimdallClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error { + url, err := noAckMilestoneURL(h.urlString, milestoneID) + if err != nil { + return err + } + + ctx = withRequestType(ctx, milestoneNoAckRequest) + + response, err := FetchWithRetry[milestone.MilestoneNoAckResponse](ctx, h.client, url, h.closeCh) + if err != nil { + return err + } + + if !response.Result.Result { + return fmt.Errorf("%w: milestoneID %q", ErrNotInRejectedList, milestoneID) + } + + return nil +} + +// FetchMilestoneID fetches the bool result from Heimdal whether the ID corresponding +// to the given milestone is in process in Heimdall +func (h *HeimdallClient) FetchMilestoneID(ctx context.Context, milestoneID string) error { + url, err := milestoneIDURL(h.urlString, milestoneID) + if err != nil { + return err + } + + ctx = withRequestType(ctx, milestoneIDRequest) + + response, err := FetchWithRetry[milestone.MilestoneIDResponse](ctx, h.client, url, h.closeCh) + + if err != nil { + return err + } + + if !response.Result.Result { + return fmt.Errorf("%w: milestoneID %q", ErrNotInMilestoneList, milestoneID) + } + + return nil +} + +// FetchWithRetry returns data from heimdall with retry +func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL, closeCh chan struct{}) (*T, error) { + // request data once + request := &Request{client: client, url: url, start: time.Now()} + result, err := Fetch[T](ctx, request) + + if err == nil { + return result, nil + } + + // attempt counter + attempt := 1 + + log.Warn("an error while trying fetching from Heimdall", "attempt", attempt, "error", err) + + // create a new ticker for retrying the request + ticker := time.NewTicker(retryCall) + defer ticker.Stop() + + const logEach = 5 + +retryLoop: + for { + log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", url.Path, "attempt", attempt) + + attempt++ + + select { + case <-ctx.Done(): + log.Debug("Shutdown detected, terminating request by context.Done") + + return nil, ctx.Err() + case <-closeCh: + log.Debug("Shutdown detected, terminating request by closing") + + return nil, ErrShutdownDetected + case <-ticker.C: + request = &Request{client: client, url: url, start: time.Now()} + result, err = Fetch[T](ctx, request) + + if err != nil { + if attempt%logEach == 0 { + log.Warn("an error while trying fetching from Heimdall", "attempt", attempt, "error", err) + } + + continue retryLoop + } + + return result, nil + } + } +} + +// Fetch returns data from heimdall +func Fetch[T any](ctx context.Context, request *Request) (*T, error) { + isSuccessful := false + + defer func() { + if metrics.EnabledExpensive { + sendMetrics(ctx, request.start, isSuccessful) + } + }() + + result := new(T) + + body, err := internalFetchWithTimeout(ctx, request.client, request.url) + if err != nil { + return nil, err + } + + if body == nil { + return nil, ErrNoResponse + } + + err = json.Unmarshal(body, result) + if err != nil { + return nil, err + } + + isSuccessful = true + + return result, nil +} + +func spanURL(urlString string, spanID uint64) (*url.URL, error) { + return makeURL(urlString, fmt.Sprintf(fetchSpanFormat, spanID), "") +} + +func stateSyncURL(urlString string, fromID uint64, to int64) (*url.URL, error) { + queryParams := fmt.Sprintf(fetchStateSyncEventsFormat, fromID, to, stateFetchLimit) + + return makeURL(urlString, fetchStateSyncEventsPath, queryParams) +} + +func checkpointURL(urlString string, number int64) (*url.URL, error) { + url := "" + if number == -1 { + url = fmt.Sprintf(fetchCheckpoint, "latest") + } else { + url = fmt.Sprintf(fetchCheckpoint, fmt.Sprint(number)) + } + + return makeURL(urlString, url, "") +} + +func milestoneURL(urlString string) (*url.URL, error) { + url := fetchMilestone + + return makeURL(urlString, url, "") +} + +func checkpointCountURL(urlString string) (*url.URL, error) { + return makeURL(urlString, fetchCheckpointCount, "") +} + +func milestoneCountURL(urlString string) (*url.URL, error) { + return makeURL(urlString, fetchMilestoneCount, "") +} + +func lastNoAckMilestoneURL(urlString string) (*url.URL, error) { + return makeURL(urlString, fetchLastNoAckMilestone, "") +} + +func noAckMilestoneURL(urlString string, id string) (*url.URL, error) { + url := fmt.Sprintf(fetchNoAckMilestone, id) + return makeURL(urlString, url, "") +} + +func milestoneIDURL(urlString string, id string) (*url.URL, error) { + url := fmt.Sprintf(fetchMilestoneID, id) + return makeURL(urlString, url, "") +} + +func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) { + u, err := url.Parse(urlString) + if err != nil { + return nil, err + } + + u.Path = rawPath + u.RawQuery = rawQuery + + return u, err +} + +// internal fetch method +func internalFetch(ctx context.Context, client http.Client, u *url.URL) ([]byte, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) + if err != nil { + return nil, err + } + + res, err := client.Do(req) + if err != nil { + return nil, err + } + + defer res.Body.Close() + + // check status code + if res.StatusCode != 200 && res.StatusCode != 204 { + return nil, fmt.Errorf("%w: response code %d", ErrNotSuccessfulResponse, res.StatusCode) + } + + // unmarshall data from buffer + if res.StatusCode == 204 { + return nil, nil + } + + // get response + body, err := io.ReadAll(res.Body) + if err != nil { + return nil, err + } + + return body, nil +} + +func internalFetchWithTimeout(ctx context.Context, client http.Client, url *url.URL) ([]byte, error) { + ctx, cancel := context.WithTimeout(ctx, apiHeimdallTimeout) + defer cancel() + + // request data once + return internalFetch(ctx, client, url) +} + +// Close sends a signal to stop the running process +func (h *HeimdallClient) Close() { + close(h.closeCh) + h.client.CloseIdleConnections() +} diff --git a/consensus/bor/heimdall/client_test.go b/consensus/bor/heimdall/client_test.go new file mode 100644 index 0000000000..5023b847a5 --- /dev/null +++ b/consensus/bor/heimdall/client_test.go @@ -0,0 +1,419 @@ +package heimdall + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "math/big" + "net" + "net/http" + "sync" + "testing" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/network" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/milestone" + + "github.com/stretchr/testify/require" +) + +// HttpHandlerFake defines the handler functions required to serve +// requests to the mock heimdal server for specific functions. Add more handlers +// according to requirements. +type HttpHandlerFake struct { + handleFetchCheckpoint http.HandlerFunc + handleFetchMilestone http.HandlerFunc + handleFetchNoAckMilestone http.HandlerFunc + handleFetchLastNoAckMilestone http.HandlerFunc +} + +func (h *HttpHandlerFake) GetCheckpointHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + h.handleFetchCheckpoint.ServeHTTP(w, r) + } +} + +func (h *HttpHandlerFake) GetMilestoneHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + h.handleFetchMilestone.ServeHTTP(w, r) + } +} + +func (h *HttpHandlerFake) GetNoAckMilestoneHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + h.handleFetchNoAckMilestone.ServeHTTP(w, r) + } +} + +func (h *HttpHandlerFake) GetLastNoAckMilestoneHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + h.handleFetchLastNoAckMilestone.ServeHTTP(w, r) + } +} + +func CreateMockHeimdallServer(wg *sync.WaitGroup, port int, listener net.Listener, handler *HttpHandlerFake) (*http.Server, error) { + // Create a new server mux + mux := http.NewServeMux() + + // Create a route for fetching latest checkpoint + mux.HandleFunc("/checkpoints/latest", func(w http.ResponseWriter, r *http.Request) { + handler.GetCheckpointHandler()(w, r) + }) + + // Create a route for fetching milestone + mux.HandleFunc("/milestone/latest", func(w http.ResponseWriter, r *http.Request) { + handler.GetMilestoneHandler()(w, r) + }) + + // Create a route for fetching milestone + mux.HandleFunc("/milestone/noAck/{id}", func(w http.ResponseWriter, r *http.Request) { + handler.GetNoAckMilestoneHandler()(w, r) + }) + + // Create a route for fetching milestone + mux.HandleFunc("/milestone/lastNoAck", func(w http.ResponseWriter, r *http.Request) { + handler.GetLastNoAckMilestoneHandler()(w, r) + }) + + // Add other routes as per requirement + + // Create the server with given port and mux + srv := &http.Server{ + Addr: fmt.Sprintf("localhost:%d", port), + Handler: mux, + } + + // Close the listener using the port and immediately consume it below + err := listener.Close() + if err != nil { + return nil, err + } + + go func() { + defer wg.Done() + + // always returns error. ErrServerClosed on graceful close + if err := srv.ListenAndServe(); err != http.ErrServerClosed { + fmt.Printf("error in server.ListenAndServe(): %v", err) + } + }() + + return srv, nil +} + +// TestFetchCheckpointFromMockHeimdall tests the heimdall client side logic +// to fetch checkpoints (latest for the scope of test) from a mock heimdall server. +// It can be used for debugging purpose (like response fields, marshalling/unmarshalling, etc). +func TestFetchCheckpointFromMockHeimdall(t *testing.T) { + t.Parallel() + + // Create a wait group for sending across the mock server + wg := &sync.WaitGroup{} + wg.Add(1) + + // Initialize the fake handler and add a fake checkpoint handler function + handler := &HttpHandlerFake{} + handler.handleFetchCheckpoint = func(w http.ResponseWriter, _ *http.Request) { + err := json.NewEncoder(w).Encode(checkpoint.CheckpointResponse{ + Height: "0", + Result: checkpoint.Checkpoint{ + Proposer: common.Address{}, + StartBlock: big.NewInt(0), + EndBlock: big.NewInt(512), + RootHash: common.Hash{}, + BorChainID: "15001", + Timestamp: 0, + }, + }) + + if err != nil { + w.WriteHeader(500) // Return 500 Internal Server Error. + } + } + + // Fetch available port + port, listener, err := network.FindAvailablePort() + require.NoError(t, err, "expect no error in finding available port") + + // Create mock heimdall server and pass handler instance for setting up the routes + srv, err := CreateMockHeimdallServer(wg, port, listener, handler) + require.NoError(t, err, "expect no error in starting mock heimdall server") + + // Create a new heimdall client and use same port for connection + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + _, err = client.FetchCheckpoint(context.Background(), -1) + require.NoError(t, err, "expect no error in fetching checkpoint") + + // Shutdown the server + err = srv.Shutdown(context.TODO()) + require.NoError(t, err, "expect no error in shutting down mock heimdall server") + + // Wait for `wg.Done()` to be called in the mock server's routine. + wg.Wait() +} + +// TestFetchMilestoneFromMockHeimdall tests the heimdall client side logic +// to fetch milestone from a mock heimdall server. +// It can be used for debugging purpose (like response fields, marshalling/unmarshalling, etc). +func TestFetchMilestoneFromMockHeimdall(t *testing.T) { + t.Parallel() + + // Create a wait group for sending across the mock server + wg := &sync.WaitGroup{} + wg.Add(1) + + // Initialize the fake handler and add a fake milestone handler function + handler := &HttpHandlerFake{} + handler.handleFetchMilestone = func(w http.ResponseWriter, _ *http.Request) { + err := json.NewEncoder(w).Encode(milestone.MilestoneResponse{ + Height: "0", + Result: milestone.Milestone{ + Proposer: common.Address{}, + StartBlock: big.NewInt(0), + EndBlock: big.NewInt(512), + Hash: common.Hash{}, + BorChainID: "15001", + Timestamp: 0, + }, + }) + + if err != nil { + w.WriteHeader(500) // Return 500 Internal Server Error. + } + } + + // Fetch available port + port, listener, err := network.FindAvailablePort() + require.NoError(t, err, "expect no error in finding available port") + + // Create mock heimdall server and pass handler instance for setting up the routes + srv, err := CreateMockHeimdallServer(wg, port, listener, handler) + require.NoError(t, err, "expect no error in starting mock heimdall server") + + // Create a new heimdall client and use same port for connection + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + _, err = client.FetchMilestone(context.Background()) + require.NoError(t, err, "expect no error in fetching milestone") + + // Shutdown the server + err = srv.Shutdown(context.TODO()) + require.NoError(t, err, "expect no error in shutting down mock heimdall server") + + // Wait for `wg.Done()` to be called in the mock server's routine. + wg.Wait() +} + +// TestFetchShutdown tests the heimdall client side logic for context timeout and +// interrupt handling while fetching data from a mock heimdall server. +func TestFetchShutdown(t *testing.T) { + t.Parallel() + + // Create a wait group for sending across the mock server + wg := &sync.WaitGroup{} + wg.Add(1) + + // Initialize the fake handler and add a fake checkpoint handler function + handler := &HttpHandlerFake{} + + // Case1 - Testing context timeout: Create delay in serving requests for simulating timeout. Add delay slightly + // greater than `retryDelay`. This should cause the request to timeout and trigger shutdown + // due to `ctx.Done()`. Expect context timeout error. + handler.handleFetchCheckpoint = func(w http.ResponseWriter, _ *http.Request) { + time.Sleep(100 * time.Millisecond) + + err := json.NewEncoder(w).Encode(checkpoint.CheckpointResponse{ + Height: "0", + Result: checkpoint.Checkpoint{ + Proposer: common.Address{}, + StartBlock: big.NewInt(0), + EndBlock: big.NewInt(512), + RootHash: common.Hash{}, + BorChainID: "15001", + Timestamp: 0, + }, + }) + + if err != nil { + w.WriteHeader(500) // Return 500 Internal Server Error. + } + } + + // Fetch available port + port, listener, err := network.FindAvailablePort() + require.NoError(t, err, "expect no error in finding available port") + + // Create mock heimdall server and pass handler instance for setting up the routes + srv, err := CreateMockHeimdallServer(wg, port, listener, handler) + require.NoError(t, err, "expect no error in starting mock heimdall server") + + // Create a new heimdall client and use same port for connection + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + + ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) + + // Expect this to fail due to timeout + _, err = client.FetchCheckpoint(ctx, -1) + require.Equal(t, "context deadline exceeded", err.Error(), "expect the function error to be a context deadline exeeded error") + require.Equal(t, "context deadline exceeded", ctx.Err().Error(), "expect the ctx error to be a context deadline exeeded error") + + cancel() + + // Case2 - Testing context cancellation. Pass a context with timeout to the request and + // cancel it before timeout. This should cause the request to timeout and trigger shutdown + // due to `ctx.Done()`. Expect context cancellation error. + handler.handleFetchCheckpoint = func(w http.ResponseWriter, _ *http.Request) { + time.Sleep(10 * time.Millisecond) + w.WriteHeader(500) // Return 500 Internal Server Error. + } + + ctx, cancel = context.WithTimeout(context.Background(), 50*time.Millisecond) // Use some high value for timeout + + // Cancel the context after a delay until we make request + go func(cancel context.CancelFunc) { + time.Sleep(10 * time.Millisecond) + cancel() + }(cancel) + + // Expect this to fail due to cancellation + _, err = client.FetchCheckpoint(ctx, -1) + require.Equal(t, "context canceled", err.Error(), "expect the function error to be a context cancelled error") + require.Equal(t, "context canceled", ctx.Err().Error(), "expect the ctx error to be a context cancelled error") + + // Case3 - Testing interrupt: Closing the `closeCh` in heimdall client simulating interrupt. This + // should cause the request to fail and throw an error due to `<-closeCh` in fetchWithRetry. + // Expect shutdown detected error. + handler.handleFetchCheckpoint = func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(500) // Return 500 Internal Server Error. + } + + // Close the channel after a delay until we make request + go func() { + time.Sleep(1 * time.Second) + close(client.closeCh) + }() + + // Expect this to fail due to shutdown + _, err = client.FetchCheckpoint(context.Background(), -1) + require.Equal(t, ErrShutdownDetected.Error(), err.Error(), "expect the function error to be a shutdown detected error") + + // Shutdown the server + err = srv.Shutdown(context.TODO()) + require.NoError(t, err, "expect no error in shutting down mock heimdall server") + + // Wait for `wg.Done()` to be called in the mock server's routine. + wg.Wait() +} + +// TestContext includes bunch of simple tests to verify the working of timeout +// based context and cancellation. +func TestContext(t *testing.T) { + t.Parallel() + + ctx, cancel1 := context.WithTimeout(context.Background(), 1*time.Second) + + // Case1: Done is not yet closed, so Err returns nil. + require.NoError(t, ctx.Err(), "expect nil error") + + wg := &sync.WaitGroup{} + + // Case2: Check if timeout is being handled + wg.Add(1) + + go func(ctx context.Context, wg *sync.WaitGroup) { + defer wg.Done() + select { + case <-ctx.Done(): + // Expect context deadline exceeded error + require.Equal(t, "context deadline exceeded", ctx.Err().Error(), "expect the ctx error to be a context deadline exceeded error") + case <-time.After(2 * time.Second): + // Case for safely exiting the tests + return + } + }(ctx, wg) + + // Case3: Check normal case + ctx, cancel2 := context.WithTimeout(context.Background(), 3*time.Second) + + wg.Add(1) + + errCh := make(chan error, 1) + + go func(ctx context.Context, wg *sync.WaitGroup) { + defer wg.Done() + select { + case <-ctx.Done(): + // Expect this to never occur, throw explicit error + errCh <- errors.New("unexpectecd call to `ctx.Done()`") + case <-time.After(2 * time.Second): + // Case for safely exiting the tests + errCh <- nil + return + } + }(ctx, wg) + + if err := <-errCh; err != nil { + t.Fatalf("err: %v", err) + } + + // Case4: Check if cancellation is being handled + ctx, cancel3 := context.WithTimeout(context.Background(), 1*time.Second) + + wg.Add(1) + + go func(cancel context.CancelFunc) { + time.Sleep(500 * time.Millisecond) + cancel() + }(cancel3) + + go func(ctx context.Context, wg *sync.WaitGroup) { + defer wg.Done() + select { + case <-ctx.Done(): + // Expect context canceled error + require.Equal(t, "context canceled", ctx.Err().Error(), "expect the ctx error to be a context canceled error") + case <-time.After(2 * time.Second): + // Case for safely exiting the tests + return + } + }(ctx, wg) + + // Wait for all tests to pass + wg.Wait() + + // Cancel all remaining contexts + cancel1() + cancel2() +} + +func TestSpanURL(t *testing.T) { + t.Parallel() + + url, err := spanURL("http://bor0", 1) + if err != nil { + t.Fatal("got an error", err) + } + + const expected = "http://bor0/bor/span/1" + + if url.String() != expected { + t.Fatalf("expected URL %q, got %q", url.String(), expected) + } +} + +func TestStateSyncURL(t *testing.T) { + t.Parallel() + + url, err := stateSyncURL("http://bor0", 10, 100) + if err != nil { + t.Fatal("got an error", err) + } + + const expected = "http://bor0/clerk/event-record/list?from-id=10&to-time=100&limit=50" + + if url.String() != expected { + t.Fatalf("expected URL %q, got %q", url.String(), expected) + } +} diff --git a/consensus/bor/heimdall/metrics.go b/consensus/bor/heimdall/metrics.go new file mode 100644 index 0000000000..8ad686f373 --- /dev/null +++ b/consensus/bor/heimdall/metrics.go @@ -0,0 +1,122 @@ +package heimdall + +import ( + "context" + "time" + + "github.com/ethereum/go-ethereum/metrics" +) + +type ( + requestTypeKey struct{} + requestType string + + meter struct { + request map[bool]metrics.Meter // map[isSuccessful]metrics.Meter + timer metrics.Timer + } +) + +const ( + stateSyncRequest requestType = "state-sync" + spanRequest requestType = "span" + checkpointRequest requestType = "checkpoint" + checkpointCountRequest requestType = "checkpoint-count" + milestoneRequest requestType = "milestone" + milestoneCountRequest requestType = "milestone-count" + milestoneNoAckRequest requestType = "milestone-no-ack" + milestoneLastNoAckRequest requestType = "milestone-last-no-ack" + milestoneIDRequest requestType = "milestone-id" +) + +func withRequestType(ctx context.Context, reqType requestType) context.Context { + return context.WithValue(ctx, requestTypeKey{}, reqType) +} + +func getRequestType(ctx context.Context) (requestType, bool) { + reqType, ok := ctx.Value(requestTypeKey{}).(requestType) + return reqType, ok +} + +var ( + requestMeters = map[requestType]meter{ + stateSyncRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/statesync/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/statesync/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/statesync/duration", nil), + }, + spanRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/span/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/span/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/span/duration", nil), + }, + checkpointRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/checkpoint/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/checkpoint/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/checkpoint/duration", nil), + }, + checkpointCountRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/checkpointcount/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/checkpointcount/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/checkpointcount/duration", nil), + }, + milestoneRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/milestone/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/milestone/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/milestone/duration", nil), + }, + milestoneCountRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/milestonecount/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/milestonecount/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/milestonecount/duration", nil), + }, + milestoneNoAckRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/milestonenoack/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/milestonenoack/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/milestonenoack/duration", nil), + }, + milestoneLastNoAckRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/milestonelastnoack/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/milestonelastnoack/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/milestonelastnoack/duration", nil), + }, + milestoneIDRequest: { + request: map[bool]metrics.Meter{ + true: metrics.NewRegisteredMeter("client/requests/milestoneid/valid", nil), + false: metrics.NewRegisteredMeter("client/requests/milestoneid/invalid", nil), + }, + timer: metrics.NewRegisteredTimer("client/requests/milestoneid/duration", nil), + }, + } +) + +func sendMetrics(ctx context.Context, start time.Time, isSuccessful bool) { + reqType, ok := getRequestType(ctx) + if !ok { + return + } + + meters, ok := requestMeters[reqType] + if !ok { + return + } + + meters.request[isSuccessful].Mark(1) + meters.timer.Update(time.Since(start)) +} diff --git a/consensus/bor/heimdall/milestone/milestone.go b/consensus/bor/heimdall/milestone/milestone.go new file mode 100644 index 0000000000..a0dd04742a --- /dev/null +++ b/consensus/bor/heimdall/milestone/milestone.go @@ -0,0 +1,58 @@ +package milestone + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" +) + +// milestone defines a response object type of bor milestone +type Milestone struct { + Proposer common.Address `json:"proposer"` + StartBlock *big.Int `json:"start_block"` + EndBlock *big.Int `json:"end_block"` + Hash common.Hash `json:"hash"` + BorChainID string `json:"bor_chain_id"` + Timestamp uint64 `json:"timestamp"` +} + +type MilestoneResponse struct { + Height string `json:"height"` + Result Milestone `json:"result"` +} + +type MilestoneCount struct { + Count int64 `json:"count"` +} + +type MilestoneCountResponse struct { + Height string `json:"height"` + Result MilestoneCount `json:"result"` +} + +type MilestoneLastNoAck struct { + Result string `json:"result"` +} + +type MilestoneLastNoAckResponse struct { + Height string `json:"height"` + Result MilestoneLastNoAck `json:"result"` +} + +type MilestoneNoAck struct { + Result bool `json:"result"` +} + +type MilestoneNoAckResponse struct { + Height string `json:"height"` + Result MilestoneNoAck `json:"result"` +} + +type MilestoneID struct { + Result bool `json:"result"` +} + +type MilestoneIDResponse struct { + Height string `json:"height"` + Result MilestoneID `json:"result"` +} diff --git a/consensus/bor/heimdall/span/span.go b/consensus/bor/heimdall/span/span.go new file mode 100644 index 0000000000..5bf85fb341 --- /dev/null +++ b/consensus/bor/heimdall/span/span.go @@ -0,0 +1,20 @@ +package span + +import ( + "github.com/ethereum/go-ethereum/consensus/bor/valset" +) + +// Span Bor represents a current bor span +type Span struct { + ID uint64 `json:"span_id" yaml:"span_id"` + StartBlock uint64 `json:"start_block" yaml:"start_block"` + EndBlock uint64 `json:"end_block" yaml:"end_block"` +} + +// HeimdallSpan represents span from heimdall APIs +type HeimdallSpan struct { + Span + ValidatorSet valset.ValidatorSet `json:"validator_set" yaml:"validator_set"` + SelectedProducers []valset.Validator `json:"selected_producers" yaml:"selected_producers"` + ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"` +} diff --git a/consensus/bor/heimdall/span/spanner.go b/consensus/bor/heimdall/span/spanner.go new file mode 100644 index 0000000000..9307a0337e --- /dev/null +++ b/consensus/bor/heimdall/span/spanner.go @@ -0,0 +1,203 @@ +package span + +import ( + "context" + "encoding/hex" + "math" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/consensus/bor/abi" + "github.com/ethereum/go-ethereum/consensus/bor/api" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" +) + +type ChainSpanner struct { + ethAPI api.Caller + validatorSet abi.ABI + chainConfig *params.ChainConfig + validatorContractAddress common.Address +} + +func NewChainSpanner(ethAPI api.Caller, validatorSet abi.ABI, chainConfig *params.ChainConfig, validatorContractAddress common.Address) *ChainSpanner { + return &ChainSpanner{ + ethAPI: ethAPI, + validatorSet: validatorSet, + chainConfig: chainConfig, + validatorContractAddress: validatorContractAddress, + } +} + +// GetCurrentSpan get current span from contract +func (c *ChainSpanner) GetCurrentSpan(ctx context.Context, headerHash common.Hash) (*Span, error) { + // block + blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false) + + // method + const method = "getCurrentSpan" + + data, err := c.validatorSet.Pack(method) + if err != nil { + log.Error("Unable to pack tx for getCurrentSpan", "error", err) + + return nil, err + } + + msgData := (hexutil.Bytes)(data) + toAddress := c.validatorContractAddress + gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2)) + + // todo: would we like to have a timeout here? + result, err := c.ethAPI.Call(ctx, ethapi.TransactionArgs{ + Gas: &gas, + To: &toAddress, + Data: &msgData, + }, blockNr, nil) + if err != nil { + return nil, err + } + + // span result + ret := new(struct { + Number *big.Int + StartBlock *big.Int + EndBlock *big.Int + }) + + if err := c.validatorSet.UnpackIntoInterface(ret, method, result); err != nil { + return nil, err + } + + // create new span + span := Span{ + ID: ret.Number.Uint64(), + StartBlock: ret.StartBlock.Uint64(), + EndBlock: ret.EndBlock.Uint64(), + } + + return &span, nil +} + +// GetCurrentValidators get current validators +func (c *ChainSpanner) GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error) { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + // method + const method = "getBorValidators" + + data, err := c.validatorSet.Pack(method, big.NewInt(0).SetUint64(blockNumber)) + if err != nil { + log.Error("Unable to pack tx for getValidator", "error", err) + return nil, err + } + + // call + msgData := (hexutil.Bytes)(data) + toAddress := c.validatorContractAddress + gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2)) + + result, err := c.ethAPI.Call(ctx, ethapi.TransactionArgs{ + Gas: &gas, + To: &toAddress, + Data: &msgData, + }, blockNrOrHash, nil) + if err != nil { + return nil, err + } + + var ( + ret0 = new([]common.Address) + ret1 = new([]*big.Int) + ) + + out := &[]interface{}{ + ret0, + ret1, + } + + if err := c.validatorSet.UnpackIntoInterface(out, method, result); err != nil { + return nil, err + } + + valz := make([]*valset.Validator, len(*ret0)) + for i, a := range *ret0 { + valz[i] = &valset.Validator{ + Address: a, + VotingPower: (*ret1)[i].Int64(), + } + } + + return valz, nil +} + +func (c *ChainSpanner) GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) { + blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false) + + return c.GetCurrentValidatorsByBlockNrOrHash(ctx, blockNr, blockNumber) +} + +const method = "commitSpan" + +func (c *ChainSpanner) CommitSpan(ctx context.Context, heimdallSpan HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error { + // get validators bytes + validators := make([]valset.MinimalVal, 0, len(heimdallSpan.ValidatorSet.Validators)) + for _, val := range heimdallSpan.ValidatorSet.Validators { + validators = append(validators, val.MinimalVal()) + } + + validatorBytes, err := rlp.EncodeToBytes(validators) + if err != nil { + return err + } + + // get producers bytes + producers := make([]valset.MinimalVal, 0, len(heimdallSpan.SelectedProducers)) + for _, val := range heimdallSpan.SelectedProducers { + producers = append(producers, val.MinimalVal()) + } + + producerBytes, err := rlp.EncodeToBytes(producers) + if err != nil { + return err + } + + log.Info("✅ Committing new span", + "id", heimdallSpan.ID, + "startBlock", heimdallSpan.StartBlock, + "endBlock", heimdallSpan.EndBlock, + "validatorBytes", hex.EncodeToString(validatorBytes), + "producerBytes", hex.EncodeToString(producerBytes), + ) + + data, err := c.validatorSet.Pack(method, + big.NewInt(0).SetUint64(heimdallSpan.ID), + big.NewInt(0).SetUint64(heimdallSpan.StartBlock), + big.NewInt(0).SetUint64(heimdallSpan.EndBlock), + validatorBytes, + producerBytes, + ) + if err != nil { + log.Error("Unable to pack tx for commitSpan", "error", err) + + return err + } + + // get system message + msg := statefull.GetSystemMessage(c.validatorContractAddress, data) + + // apply message + _, err = statefull.ApplyMessage(ctx, msg, state, header, c.chainConfig, chainContext) + + return err +} diff --git a/consensus/bor/heimdallapp/checkpoint.go b/consensus/bor/heimdallapp/checkpoint.go new file mode 100644 index 0000000000..288a1a51d1 --- /dev/null +++ b/consensus/bor/heimdallapp/checkpoint.go @@ -0,0 +1,45 @@ +package heimdallapp + +import ( + "context" + "math/big" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint" + "github.com/ethereum/go-ethereum/log" + + hmTypes "github.com/maticnetwork/heimdall/types" +) + +func (h *HeimdallAppClient) FetchCheckpointCount(_ context.Context) (int64, error) { + log.Info("Fetching checkpoint count") + + res := h.hApp.CheckpointKeeper.GetACKCount(h.NewContext()) + + log.Info("Fetched checkpoint count") + + return int64(res), nil +} + +func (h *HeimdallAppClient) FetchCheckpoint(_ context.Context, number int64) (*checkpoint.Checkpoint, error) { + log.Info("Fetching checkpoint", "number", number) + + res, err := h.hApp.CheckpointKeeper.GetCheckpointByNumber(h.NewContext(), uint64(number)) + if err != nil { + return nil, err + } + + log.Info("Fetched checkpoint", "number", number) + + return toBorCheckpoint(res), nil +} + +func toBorCheckpoint(hdCheckpoint hmTypes.Checkpoint) *checkpoint.Checkpoint { + return &checkpoint.Checkpoint{ + Proposer: hdCheckpoint.Proposer.EthAddress(), + StartBlock: big.NewInt(int64(hdCheckpoint.StartBlock)), + EndBlock: big.NewInt(int64(hdCheckpoint.EndBlock)), + RootHash: hdCheckpoint.RootHash.EthHash(), + BorChainID: hdCheckpoint.BorChainID, + Timestamp: hdCheckpoint.TimeStamp, + } +} diff --git a/consensus/bor/heimdallapp/client.go b/consensus/bor/heimdallapp/client.go new file mode 100644 index 0000000000..18a030fcf3 --- /dev/null +++ b/consensus/bor/heimdallapp/client.go @@ -0,0 +1,35 @@ +package heimdallapp + +import ( + "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/log" + + "github.com/maticnetwork/heimdall/app" + "github.com/maticnetwork/heimdall/cmd/heimdalld/service" + + abci "github.com/tendermint/tendermint/abci/types" +) + +const ( + stateFetchLimit = 50 +) + +type HeimdallAppClient struct { + hApp *app.HeimdallApp +} + +func NewHeimdallAppClient() *HeimdallAppClient { + return &HeimdallAppClient{ + hApp: service.GetHeimdallApp(), + } +} + +func (h *HeimdallAppClient) Close() { + // Nothing to close as of now + log.Warn("Shutdown detected, Closing Heimdall App conn") +} + +func (h *HeimdallAppClient) NewContext() types.Context { + return h.hApp.NewContext(true, abci.Header{Height: h.hApp.LastBlockHeight()}) +} diff --git a/consensus/bor/heimdallapp/milestone.go b/consensus/bor/heimdallapp/milestone.go new file mode 100644 index 0000000000..b7183b6498 --- /dev/null +++ b/consensus/bor/heimdallapp/milestone.go @@ -0,0 +1,82 @@ +package heimdallapp + +import ( + "context" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/milestone" + + "github.com/ethereum/go-ethereum/log" + + chTypes "github.com/maticnetwork/heimdall/checkpoint/types" + hmTypes "github.com/maticnetwork/heimdall/types" +) + +func (h *HeimdallAppClient) FetchMilestoneCount(_ context.Context) (int64, error) { + log.Info("Fetching milestone count") + + res := h.hApp.CheckpointKeeper.GetMilestoneCount(h.NewContext()) + + log.Info("Fetched Milestone Count") + + return int64(res), nil +} + +func (h *HeimdallAppClient) FetchMilestone(_ context.Context) (*milestone.Milestone, error) { + log.Info("Fetching Latest Milestone") + + res, err := h.hApp.CheckpointKeeper.GetLastMilestone(h.NewContext()) + if err != nil { + return nil, err + } + + log.Info("Fetched Latest Milestone") + + return toBorMilestone(res), nil +} + +func (h *HeimdallAppClient) FetchNoAckMilestone(_ context.Context, milestoneID string) error { + log.Info("Fetching No Ack Milestone By MilestoneID", "MilestoneID", milestoneID) + + res := h.hApp.CheckpointKeeper.GetNoAckMilestone(h.NewContext(), milestoneID) + if res { + log.Info("Fetched No Ack By MilestoneID", "MilestoneID", milestoneID) + return nil + } + + return fmt.Errorf("Still No Ack Milestone exist corresponding to MilestoneId:%v", milestoneID) +} + +func (h *HeimdallAppClient) FetchLastNoAckMilestone(_ context.Context) (string, error) { + log.Info("Fetching Latest No Ack Milestone ID") + + res := h.hApp.CheckpointKeeper.GetLastNoAckMilestone(h.NewContext()) + + log.Info("Fetched Latest No Ack Milestone ID") + + return res, nil +} + +func (h *HeimdallAppClient) FetchMilestoneID(_ context.Context, milestoneID string) error { + log.Info("Fetching Milestone ID ", "MilestoneID", milestoneID) + + res := chTypes.GetMilestoneID() + + if res == milestoneID { + return nil + } + + return fmt.Errorf("Milestone corresponding to Milestone ID:%v doesn't exist in Heimdall", milestoneID) +} + +func toBorMilestone(hdMilestone *hmTypes.Milestone) *milestone.Milestone { + return &milestone.Milestone{ + Proposer: hdMilestone.Proposer.EthAddress(), + StartBlock: big.NewInt(int64(hdMilestone.StartBlock)), + EndBlock: big.NewInt(int64(hdMilestone.EndBlock)), + Hash: hdMilestone.Hash.EthHash(), + BorChainID: hdMilestone.BorChainID, + Timestamp: hdMilestone.TimeStamp, + } +} diff --git a/consensus/bor/heimdallapp/span.go b/consensus/bor/heimdallapp/span.go new file mode 100644 index 0000000000..4d1c384502 --- /dev/null +++ b/consensus/bor/heimdallapp/span.go @@ -0,0 +1,86 @@ +package heimdallapp + +import ( + "context" + + hmTypes "github.com/maticnetwork/heimdall/types" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/log" +) + +func (h *HeimdallAppClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) { + log.Info("Fetching span", "spanID", spanID) + + res, err := h.hApp.BorKeeper.GetSpan(h.NewContext(), spanID) + if err != nil { + return nil, err + } + + log.Info("Fetched span", "spanID", spanID) + + return toSpan(res), nil +} + +func toSpan(hdSpan *hmTypes.Span) *span.HeimdallSpan { + return &span.HeimdallSpan{ + Span: span.Span{ + ID: hdSpan.ID, + StartBlock: hdSpan.StartBlock, + EndBlock: hdSpan.EndBlock, + }, + ValidatorSet: toValidatorSet(hdSpan.ValidatorSet), + SelectedProducers: toValidators(hdSpan.SelectedProducers), + ChainID: hdSpan.ChainID, + } +} + +func toValidatorSet(vs hmTypes.ValidatorSet) valset.ValidatorSet { + return valset.ValidatorSet{ + Validators: toValidatorsRef(vs.Validators), + Proposer: toValidatorRef(vs.Proposer), + } +} + +func toValidators(vs []hmTypes.Validator) []valset.Validator { + newVS := make([]valset.Validator, len(vs)) + + for i, v := range vs { + newVS[i] = toValidator(v) + } + + return newVS +} + +func toValidatorsRef(vs []*hmTypes.Validator) []*valset.Validator { + newVS := make([]*valset.Validator, len(vs)) + + for i, v := range vs { + if v == nil { + continue + } + + newVS[i] = toValidatorRef(v) + } + + return newVS +} + +func toValidatorRef(v *hmTypes.Validator) *valset.Validator { + return &valset.Validator{ + ID: v.ID.Uint64(), + Address: v.Signer.EthAddress(), + VotingPower: v.VotingPower, + ProposerPriority: v.ProposerPriority, + } +} + +func toValidator(v hmTypes.Validator) valset.Validator { + return valset.Validator{ + ID: v.ID.Uint64(), + Address: v.Signer.EthAddress(), + VotingPower: v.VotingPower, + ProposerPriority: v.ProposerPriority, + } +} diff --git a/consensus/bor/heimdallapp/state_sync.go b/consensus/bor/heimdallapp/state_sync.go new file mode 100644 index 0000000000..b61c886436 --- /dev/null +++ b/consensus/bor/heimdallapp/state_sync.go @@ -0,0 +1,60 @@ +package heimdallapp + +import ( + "context" + "time" + + "github.com/maticnetwork/heimdall/clerk/types" + + "github.com/ethereum/go-ethereum/consensus/bor/clerk" +) + +func (h *HeimdallAppClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) { + totalRecords := make([]*clerk.EventRecordWithTime, 0) + + for { + fromRecord, err := h.hApp.ClerkKeeper.GetEventRecord(h.NewContext(), fromID) + if err != nil { + return nil, err + } + + events, err := h.hApp.ClerkKeeper.GetEventRecordListWithTime(h.NewContext(), fromRecord.RecordTime, time.Unix(to, 0), 1, stateFetchLimit) + if err != nil { + return nil, err + } + + totalRecords = append(totalRecords, toEvents(events)...) + + if len(events) < stateFetchLimit { + break + } + + fromID += uint64(stateFetchLimit) + } + + return totalRecords, nil +} + +func toEvents(hdEvents []types.EventRecord) []*clerk.EventRecordWithTime { + events := make([]*clerk.EventRecordWithTime, len(hdEvents)) + + for i, ev := range hdEvents { + events[i] = toEvent(ev) + } + + return events +} + +func toEvent(hdEvent types.EventRecord) *clerk.EventRecordWithTime { + return &clerk.EventRecordWithTime{ + EventRecord: clerk.EventRecord{ + ID: hdEvent.ID, + Contract: hdEvent.Contract.EthAddress(), + Data: hdEvent.Data.Bytes(), + TxHash: hdEvent.TxHash.EthHash(), + LogIndex: hdEvent.LogIndex, + ChainID: hdEvent.ChainID, + }, + Time: hdEvent.RecordTime, + } +} diff --git a/consensus/bor/heimdallgrpc/checkpoint.go b/consensus/bor/heimdallgrpc/checkpoint.go new file mode 100644 index 0000000000..2c51efe736 --- /dev/null +++ b/consensus/bor/heimdallgrpc/checkpoint.go @@ -0,0 +1,51 @@ +package heimdallgrpc + +import ( + "context" + "math/big" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint" + "github.com/ethereum/go-ethereum/log" + + proto "github.com/maticnetwork/polyproto/heimdall" + protoutils "github.com/maticnetwork/polyproto/utils" +) + +func (h *HeimdallGRPCClient) FetchCheckpointCount(ctx context.Context) (int64, error) { + log.Info("Fetching checkpoint count") + + res, err := h.client.FetchCheckpointCount(ctx, nil) + if err != nil { + return 0, err + } + + log.Info("Fetched checkpoint count") + + return res.Result.Result, nil +} + +func (h *HeimdallGRPCClient) FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) { + req := &proto.FetchCheckpointRequest{ + ID: number, + } + + log.Info("Fetching checkpoint", "number", number) + + res, err := h.client.FetchCheckpoint(ctx, req) + if err != nil { + return nil, err + } + + log.Info("Fetched checkpoint", "number", number) + + checkpoint := &checkpoint.Checkpoint{ + StartBlock: new(big.Int).SetUint64(res.Result.StartBlock), + EndBlock: new(big.Int).SetUint64(res.Result.EndBlock), + RootHash: protoutils.ConvertH256ToHash(res.Result.RootHash), + Proposer: protoutils.ConvertH160toAddress(res.Result.Proposer), + BorChainID: res.Result.BorChainID, + Timestamp: uint64(res.Result.Timestamp.GetSeconds()), + } + + return checkpoint, nil +} diff --git a/consensus/bor/heimdallgrpc/client.go b/consensus/bor/heimdallgrpc/client.go new file mode 100644 index 0000000000..7687b7f1c7 --- /dev/null +++ b/consensus/bor/heimdallgrpc/client.go @@ -0,0 +1,52 @@ +package heimdallgrpc + +import ( + "time" + + "github.com/ethereum/go-ethereum/log" + + grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" + proto "github.com/maticnetwork/polyproto/heimdall" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" +) + +const ( + stateFetchLimit = 50 +) + +type HeimdallGRPCClient struct { + conn *grpc.ClientConn + client proto.HeimdallClient +} + +func NewHeimdallGRPCClient(address string) *HeimdallGRPCClient { + opts := []grpc_retry.CallOption{ + grpc_retry.WithMax(10000), + grpc_retry.WithBackoff(grpc_retry.BackoffLinear(5 * time.Second)), + grpc_retry.WithCodes(codes.Internal, codes.Unavailable, codes.Aborted, codes.NotFound), + } + + conn, err := grpc.Dial(address, + grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(opts...)), + grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + if err != nil { + log.Crit("Failed to connect to Heimdall gRPC", "error", err) + } + + log.Info("Connected to Heimdall gRPC server", "address", address) + + return &HeimdallGRPCClient{ + conn: conn, + client: proto.NewHeimdallClient(conn), + } +} + +func (h *HeimdallGRPCClient) Close() { + log.Debug("Shutdown detected, Closing Heimdall gRPC client") + h.conn.Close() +} diff --git a/consensus/bor/heimdallgrpc/milestone.go b/consensus/bor/heimdallgrpc/milestone.go new file mode 100644 index 0000000000..917e33771a --- /dev/null +++ b/consensus/bor/heimdallgrpc/milestone.go @@ -0,0 +1,103 @@ +package heimdallgrpc + +import ( + "context" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/milestone" + "github.com/ethereum/go-ethereum/log" + + proto "github.com/maticnetwork/polyproto/heimdall" + protoutils "github.com/maticnetwork/polyproto/utils" +) + +func (h *HeimdallGRPCClient) FetchMilestoneCount(ctx context.Context) (int64, error) { + log.Info("Fetching milestone count") + + res, err := h.client.FetchMilestoneCount(ctx, nil) + if err != nil { + return 0, err + } + + log.Info("Fetched milestone count") + + return res.Result.Count, nil +} + +func (h *HeimdallGRPCClient) FetchMilestone(ctx context.Context) (*milestone.Milestone, error) { + log.Info("Fetching milestone") + + res, err := h.client.FetchMilestone(ctx, nil) + if err != nil { + return nil, err + } + + log.Info("Fetched milestone") + + milestone := &milestone.Milestone{ + StartBlock: new(big.Int).SetUint64(res.Result.StartBlock), + EndBlock: new(big.Int).SetUint64(res.Result.EndBlock), + Hash: protoutils.ConvertH256ToHash(res.Result.RootHash), + Proposer: protoutils.ConvertH160toAddress(res.Result.Proposer), + BorChainID: res.Result.BorChainID, + Timestamp: uint64(res.Result.Timestamp.GetSeconds()), + } + + return milestone, nil +} + +func (h *HeimdallGRPCClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) { + log.Info("Fetching latest no ack milestone Id") + + res, err := h.client.FetchLastNoAckMilestone(ctx, nil) + if err != nil { + return "", err + } + + log.Info("Fetched last no-ack milestone") + + return res.Result.Result, nil +} + +func (h *HeimdallGRPCClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error { + req := &proto.FetchMilestoneNoAckRequest{ + MilestoneID: milestoneID, + } + + log.Info("Fetching no ack milestone", "milestoneaID", milestoneID) + + res, err := h.client.FetchNoAckMilestone(ctx, req) + if err != nil { + return err + } + + if !res.Result.Result { + return fmt.Errorf("Not in rejected list: milestoneID %q", milestoneID) + } + + log.Info("Fetched no ack milestone", "milestoneaID", milestoneID) + + return nil +} + +func (h *HeimdallGRPCClient) FetchMilestoneID(ctx context.Context, milestoneID string) error { + req := &proto.FetchMilestoneIDRequest{ + MilestoneID: milestoneID, + } + + log.Info("Fetching milestone id", "milestoneID", milestoneID) + + res, err := h.client.FetchMilestoneID(ctx, req) + if err != nil { + return err + } + + if !res.Result.Result { + return fmt.Errorf("This milestoneID %q does not exist", milestoneID) + } + + log.Info("Fetched milestone id", "milestoneID", milestoneID) + + return nil +} diff --git a/consensus/bor/heimdallgrpc/span.go b/consensus/bor/heimdallgrpc/span.go new file mode 100644 index 0000000000..b5c9ddf695 --- /dev/null +++ b/consensus/bor/heimdallgrpc/span.go @@ -0,0 +1,63 @@ +package heimdallgrpc + +import ( + "context" + + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/log" + + proto "github.com/maticnetwork/polyproto/heimdall" + protoutils "github.com/maticnetwork/polyproto/utils" +) + +func (h *HeimdallGRPCClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) { + req := &proto.SpanRequest{ + ID: spanID, + } + + log.Info("Fetching span", "spanID", spanID) + + res, err := h.client.Span(ctx, req) + if err != nil { + return nil, err + } + + log.Info("Fetched span", "spanID", spanID) + + return parseSpan(res.Result), nil +} + +func parseSpan(protoSpan *proto.Span) *span.HeimdallSpan { + resp := &span.HeimdallSpan{ + Span: span.Span{ + ID: protoSpan.ID, + StartBlock: protoSpan.StartBlock, + EndBlock: protoSpan.EndBlock, + }, + ValidatorSet: valset.ValidatorSet{}, + SelectedProducers: []valset.Validator{}, + ChainID: protoSpan.ChainID, + } + + for _, validator := range protoSpan.ValidatorSet.Validators { + resp.ValidatorSet.Validators = append(resp.ValidatorSet.Validators, parseValidator(validator)) + } + + resp.ValidatorSet.Proposer = parseValidator(protoSpan.ValidatorSet.Proposer) + + for _, validator := range protoSpan.SelectedProducers { + resp.SelectedProducers = append(resp.SelectedProducers, *parseValidator(validator)) + } + + return resp +} + +func parseValidator(validator *proto.Validator) *valset.Validator { + return &valset.Validator{ + ID: validator.ID, + Address: protoutils.ConvertH160toAddress(validator.Address), + VotingPower: validator.VotingPower, + ProposerPriority: validator.ProposerPriority, + } +} diff --git a/consensus/bor/heimdallgrpc/state_sync.go b/consensus/bor/heimdallgrpc/state_sync.go new file mode 100644 index 0000000000..a3bbb80aae --- /dev/null +++ b/consensus/bor/heimdallgrpc/state_sync.go @@ -0,0 +1,59 @@ +package heimdallgrpc + +import ( + "context" + "errors" + "io" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/bor/clerk" + + proto "github.com/maticnetwork/polyproto/heimdall" +) + +func (h *HeimdallGRPCClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) { + eventRecords := make([]*clerk.EventRecordWithTime, 0) + + req := &proto.StateSyncEventsRequest{ + FromID: fromID, + ToTime: uint64(to), + Limit: uint64(stateFetchLimit), + } + + var ( + res proto.Heimdall_StateSyncEventsClient + events *proto.StateSyncEventsResponse + err error + ) + + res, err = h.client.StateSyncEvents(ctx, req) + if err != nil { + return nil, err + } + + for { + events, err = res.Recv() + if errors.Is(err, io.EOF) { + return eventRecords, nil + } + + if err != nil { + return nil, err + } + + for _, event := range events.Result { + eventRecord := &clerk.EventRecordWithTime{ + EventRecord: clerk.EventRecord{ + ID: event.ID, + Contract: common.HexToAddress(event.Contract), + Data: common.Hex2Bytes(event.Data[2:]), + TxHash: common.HexToHash(event.TxHash), + LogIndex: event.LogIndex, + ChainID: event.ChainID, + }, + Time: event.Time.AsTime(), + } + eventRecords = append(eventRecords, eventRecord) + } + } +} diff --git a/consensus/bor/merkle.go b/consensus/bor/merkle.go new file mode 100644 index 0000000000..a2ce1d4023 --- /dev/null +++ b/consensus/bor/merkle.go @@ -0,0 +1,52 @@ +package bor + +func appendBytes32(data ...[]byte) []byte { + var result []byte + + for _, v := range data { + paddedV := convertTo32(v) + result = append(result, paddedV[:]...) + } + + return result +} + +func nextPowerOfTwo(n uint64) uint64 { + if n == 0 { + return 1 + } + // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 + n-- + n |= n >> 1 + n |= n >> 2 + n |= n >> 4 + n |= n >> 8 + n |= n >> 16 + n |= n >> 32 + n++ + + return n +} + +func convertTo32(input []byte) (output [32]byte) { + l := len(input) + if l > 32 || l == 0 { + return + } + + copy(output[32-l:], input[:]) + + return +} + +func convert(input [][32]byte) [][]byte { + output := make([][]byte, 0, len(input)) + + for _, in := range input { + newInput := make([]byte, len(in[:])) + copy(newInput, in[:]) + output = append(output, newInput) + } + + return output +} diff --git a/consensus/bor/snapshot.go b/consensus/bor/snapshot.go new file mode 100644 index 0000000000..7ced09c3b8 --- /dev/null +++ b/consensus/bor/snapshot.go @@ -0,0 +1,226 @@ +package bor + +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/consensus/bor/valset" + + lru "github.com/hashicorp/golang-lru" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/params" +) + +// Snapshot is the state of the authorization voting at a given point in time. +type Snapshot struct { + config *params.BorConfig // Consensus engine parameters to fine tune behavior + sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover + + Number uint64 `json:"number"` // Block number where the snapshot was created + Hash common.Hash `json:"hash"` // Block hash where the snapshot was created + ValidatorSet *valset.ValidatorSet `json:"validatorSet"` // Validator set at this moment + Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections +} + +// newSnapshot creates a new snapshot with the specified startup parameters. This +// method does not initialize the set of recent signers, so only ever use if for +// the genesis block. +func newSnapshot( + config *params.BorConfig, + sigcache *lru.ARCCache, + number uint64, + hash common.Hash, + validators []*valset.Validator, +) *Snapshot { + snap := &Snapshot{ + config: config, + sigcache: sigcache, + Number: number, + Hash: hash, + ValidatorSet: valset.NewValidatorSet(validators), + Recents: make(map[uint64]common.Address), + } + + return snap +} + +// loadSnapshot loads an existing snapshot from the database. +func loadSnapshot(config *params.BorConfig, sigcache *lru.ARCCache, db ethdb.Database, hash common.Hash) (*Snapshot, error) { + blob, err := db.Get(append([]byte("bor-"), hash[:]...)) + if err != nil { + return nil, err + } + + snap := new(Snapshot) + + if err := json.Unmarshal(blob, snap); err != nil { + return nil, err + } + + snap.ValidatorSet.UpdateValidatorMap() + + snap.config = config + snap.sigcache = sigcache + + // update total voting power + if err := snap.ValidatorSet.UpdateTotalVotingPower(); err != nil { + return nil, err + } + + return snap, nil +} + +// store inserts the snapshot into the database. +func (s *Snapshot) store(db ethdb.Database) error { + blob, err := json.Marshal(s) + if err != nil { + return err + } + + return db.Put(append([]byte("bor-"), s.Hash[:]...), blob) +} + +// copy creates a deep copy of the snapshot, though not the individual votes. +func (s *Snapshot) copy() *Snapshot { + cpy := &Snapshot{ + config: s.config, + sigcache: s.sigcache, + Number: s.Number, + Hash: s.Hash, + ValidatorSet: s.ValidatorSet.Copy(), + Recents: make(map[uint64]common.Address), + } + for block, signer := range s.Recents { + cpy.Recents[block] = signer + } + + return cpy +} + +func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) { + // Allow passing in no headers for cleaner code + if len(headers) == 0 { + return s, nil + } + // Sanity check that the headers can be applied + for i := 0; i < len(headers)-1; i++ { + if headers[i+1].Number.Uint64() != headers[i].Number.Uint64()+1 { + return nil, errOutOfRangeChain + } + } + + if headers[0].Number.Uint64() != s.Number+1 { + return nil, errOutOfRangeChain + } + // Iterate through the headers and create a new snapshot + snap := s.copy() + + for _, header := range headers { + // Remove any votes on checkpoint blocks + number := header.Number.Uint64() + + // Delete the oldest signer from the recent list to allow it signing again + if number >= s.config.CalculateSprint(number) { + delete(snap.Recents, number-s.config.CalculateSprint(number)) + } + + // Resolve the authorization key and check against signers + signer, err := ecrecover(header, s.sigcache, s.config) + if err != nil { + return nil, err + } + + // check if signer is in validator set + if !snap.ValidatorSet.HasAddress(signer) { + return nil, &UnauthorizedSignerError{number, signer.Bytes()} + } + + if _, err = snap.GetSignerSuccessionNumber(signer); err != nil { + return nil, err + } + + // add recents + snap.Recents[number] = signer + + // change validator set and change proposer + if number > 0 && (number+1)%s.config.CalculateSprint(number) == 0 { + if err := validateHeaderExtraField(header.Extra); err != nil { + return nil, err + } + + validatorBytes := header.GetValidatorBytes(s.config) + + // get validators from headers and use that for new validator set + newVals, _ := valset.ParseValidators(validatorBytes) + v := getUpdatedValidatorSet(snap.ValidatorSet.Copy(), newVals) + v.IncrementProposerPriority(1) + snap.ValidatorSet = v + } + } + + snap.Number += uint64(len(headers)) + snap.Hash = headers[len(headers)-1].Hash() + + return snap, nil +} + +// GetSignerSuccessionNumber returns the relative position of signer in terms of the in-turn proposer +func (s *Snapshot) GetSignerSuccessionNumber(signer common.Address) (int, error) { + validators := s.ValidatorSet.Validators + proposer := s.ValidatorSet.GetProposer().Address + proposerIndex, _ := s.ValidatorSet.GetByAddress(proposer) + + if proposerIndex == -1 { + return -1, &UnauthorizedProposerError{s.Number, proposer.Bytes()} + } + + signerIndex, _ := s.ValidatorSet.GetByAddress(signer) + + if signerIndex == -1 { + return -1, &UnauthorizedSignerError{s.Number, signer.Bytes()} + } + + tempIndex := signerIndex + if proposerIndex != tempIndex { + if tempIndex < proposerIndex { + tempIndex = tempIndex + len(validators) + } + } + + return tempIndex - proposerIndex, nil +} + +// signers retrieves the list of authorized signers in ascending order. +func (s *Snapshot) signers() []common.Address { + sigs := make([]common.Address, 0, len(s.ValidatorSet.Validators)) + for _, sig := range s.ValidatorSet.Validators { + sigs = append(sigs, sig.Address) + } + + return sigs +} + +// Difficulty returns the difficulty for a particular signer at the current snapshot number +func Difficulty(validatorSet *valset.ValidatorSet, signer common.Address) uint64 { + // if signer is empty + if signer == (common.Address{}) { + return 1 + } + + validators := validatorSet.Validators + proposer := validatorSet.GetProposer().Address + totalValidators := len(validators) + + proposerIndex, _ := validatorSet.GetByAddress(proposer) + signerIndex, _ := validatorSet.GetByAddress(signer) + + // temp index + tempIndex := signerIndex + if tempIndex < proposerIndex { + tempIndex = tempIndex + totalValidators + } + + return uint64(totalValidators - (tempIndex - proposerIndex)) +} diff --git a/consensus/bor/snapshot_test.go b/consensus/bor/snapshot_test.go new file mode 100644 index 0000000000..d7c1a7f498 --- /dev/null +++ b/consensus/bor/snapshot_test.go @@ -0,0 +1,225 @@ +package bor + +import ( + "math/big" + "sort" + "testing" + + "github.com/maticnetwork/crand" + "github.com/stretchr/testify/require" + "pgregory.net/rapid" + + "github.com/ethereum/go-ethereum/common" + unique "github.com/ethereum/go-ethereum/common/set" + "github.com/ethereum/go-ethereum/consensus/bor/valset" +) + +const ( + numVals = 100 +) + +func TestGetSignerSuccessionNumber_ProposerIsSigner(t *testing.T) { + t.Parallel() + + validators := buildRandomValidatorSet(numVals) + validatorSet := valset.NewValidatorSet(validators) + snap := Snapshot{ + ValidatorSet: validatorSet, + } + + // proposer is signer + signerTest := validatorSet.Proposer.Address + + successionNumber, err := snap.GetSignerSuccessionNumber(signerTest) + if err != nil { + t.Fatalf("%s", err) + } + + require.Equal(t, 0, successionNumber) +} + +func TestGetSignerSuccessionNumber_SignerIndexIsLarger(t *testing.T) { + t.Parallel() + + validators := buildRandomValidatorSet(numVals) + + // sort validators by address, which is what NewValidatorSet also does + sort.Sort(valset.ValidatorsByAddress(validators)) + + proposerIndex := 32 + signerIndex := 56 + // give highest ProposerPriority to a particular val, so that they become the proposer + validators[proposerIndex].VotingPower = 200 + snap := Snapshot{ + ValidatorSet: valset.NewValidatorSet(validators), + } + + // choose a signer at an index greater than proposer index + signerTest := snap.ValidatorSet.Validators[signerIndex].Address + + successionNumber, err := snap.GetSignerSuccessionNumber(signerTest) + if err != nil { + t.Fatalf("%s", err) + } + + require.Equal(t, signerIndex-proposerIndex, successionNumber) +} + +func TestGetSignerSuccessionNumber_SignerIndexIsSmaller(t *testing.T) { + t.Parallel() + + validators := buildRandomValidatorSet(numVals) + proposerIndex := 98 + signerIndex := 11 + // give highest ProposerPriority to a particular val, so that they become the proposer + validators[proposerIndex].VotingPower = 200 + snap := Snapshot{ + ValidatorSet: valset.NewValidatorSet(validators), + } + + // choose a signer at an index greater than proposer index + signerTest := snap.ValidatorSet.Validators[signerIndex].Address + + successionNumber, err := snap.GetSignerSuccessionNumber(signerTest) + if err != nil { + t.Fatalf("%s", err) + } + + require.Equal(t, signerIndex+numVals-proposerIndex, successionNumber) +} + +func TestGetSignerSuccessionNumber_ProposerNotFound(t *testing.T) { + t.Parallel() + + validators := buildRandomValidatorSet(numVals) + snap := Snapshot{ + ValidatorSet: valset.NewValidatorSet(validators), + } + + require.Len(t, snap.ValidatorSet.Validators, numVals) + + dummyProposerAddress := randomAddress(toAddresses(validators)...) + snap.ValidatorSet.Proposer = &valset.Validator{Address: dummyProposerAddress} + + // choose any signer + signerTest := snap.ValidatorSet.Validators[3].Address + + _, err := snap.GetSignerSuccessionNumber(signerTest) + require.NotNil(t, err) + + e, ok := err.(*UnauthorizedProposerError) + require.True(t, ok) + require.Equal(t, dummyProposerAddress.Bytes(), e.Proposer) +} + +func TestGetSignerSuccessionNumber_SignerNotFound(t *testing.T) { + t.Parallel() + + validators := buildRandomValidatorSet(numVals) + snap := Snapshot{ + ValidatorSet: valset.NewValidatorSet(validators), + } + + dummySignerAddress := randomAddress(toAddresses(validators)...) + _, err := snap.GetSignerSuccessionNumber(dummySignerAddress) + require.NotNil(t, err) + + e, ok := err.(*UnauthorizedSignerError) + require.True(t, ok) + + require.Equal(t, dummySignerAddress.Bytes(), e.Signer) +} + +// nolint: unparam +func buildRandomValidatorSet(numVals int) []*valset.Validator { + validators := make([]*valset.Validator, numVals) + valAddrs := randomAddresses(numVals) + + for i := 0; i < numVals; i++ { + power := crand.BigInt(big.NewInt(99)) + powerN := power.Int64() + 1 + + validators[i] = &valset.Validator{ + Address: valAddrs[i], + // cannot process validators with voting power 0, hence +1 + VotingPower: powerN, + } + } + + // sort validators by address, which is what NewValidatorSet also does + sort.Sort(valset.ValidatorsByAddress(validators)) + + return validators +} + +func randomAddress(exclude ...common.Address) common.Address { + excl := make(map[common.Address]struct{}, len(exclude)) + + for _, addr := range exclude { + excl[addr] = struct{}{} + } + + r := crand.NewRand() + + for { + addr := r.Address() + if _, ok := excl[addr]; ok { + continue + } + + return addr + } +} + +func randomAddresses(n int) []common.Address { + if n <= 0 { + return []common.Address{} + } + + addrs := make([]common.Address, 0, n) + addrsSet := make(map[common.Address]struct{}, n) + + var exist bool + + r := crand.NewRand() + + for { + addr := r.Address() + + _, exist = addrsSet[addr] + if !exist { + addrs = append(addrs, addr) + + addrsSet[addr] = struct{}{} + } + + if len(addrs) == n { + return addrs + } + } +} + +func TestRandomAddresses(t *testing.T) { + t.Parallel() + + rapid.Check(t, func(t *rapid.T) { + length := rapid.IntMax(300).Draw(t, "length").(int) + + addrs := randomAddresses(length) + addressSet := unique.New(addrs) + + if len(addrs) != len(addressSet) { + t.Fatalf("length of unique addresses %d, expected %d", len(addressSet), len(addrs)) + } + }) +} + +func toAddresses(vals []*valset.Validator) []common.Address { + addrs := make([]common.Address, len(vals)) + + for i, val := range vals { + addrs[i] = val.Address + } + + return addrs +} diff --git a/consensus/bor/span.go b/consensus/bor/span.go new file mode 100644 index 0000000000..179f92c79c --- /dev/null +++ b/consensus/bor/span.go @@ -0,0 +1,21 @@ +package bor + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + "github.com/ethereum/go-ethereum/consensus/bor/valset" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" +) + +//go:generate mockgen -destination=./span_mock.go -package=bor . Spanner +type Spanner interface { + GetCurrentSpan(ctx context.Context, headerHash common.Hash) (*span.Span, error) + GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) + GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error) + CommitSpan(ctx context.Context, heimdallSpan span.HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error +} diff --git a/consensus/bor/span_mock.go b/consensus/bor/span_mock.go new file mode 100644 index 0000000000..099807161c --- /dev/null +++ b/consensus/bor/span_mock.go @@ -0,0 +1,101 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/ethereum/go-ethereum/consensus/bor (interfaces: Spanner) + +// Package bor is a generated GoMock package. +package bor + +import ( + context "context" + reflect "reflect" + + common "github.com/ethereum/go-ethereum/common" + span "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" + valset "github.com/ethereum/go-ethereum/consensus/bor/valset" + core "github.com/ethereum/go-ethereum/core" + state "github.com/ethereum/go-ethereum/core/state" + types "github.com/ethereum/go-ethereum/core/types" + rpc "github.com/ethereum/go-ethereum/rpc" + gomock "github.com/golang/mock/gomock" +) + +// MockSpanner is a mock of Spanner interface. +type MockSpanner struct { + ctrl *gomock.Controller + recorder *MockSpannerMockRecorder +} + +// MockSpannerMockRecorder is the mock recorder for MockSpanner. +type MockSpannerMockRecorder struct { + mock *MockSpanner +} + +// NewMockSpanner creates a new mock instance. +func NewMockSpanner(ctrl *gomock.Controller) *MockSpanner { + mock := &MockSpanner{ctrl: ctrl} + mock.recorder = &MockSpannerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSpanner) EXPECT() *MockSpannerMockRecorder { + return m.recorder +} + +// CommitSpan mocks base method. +func (m *MockSpanner) CommitSpan(arg0 context.Context, arg1 span.HeimdallSpan, arg2 *state.StateDB, arg3 *types.Header, arg4 core.ChainContext) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitSpan", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(error) + return ret0 +} + +// CommitSpan indicates an expected call of CommitSpan. +func (mr *MockSpannerMockRecorder) CommitSpan(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitSpan", reflect.TypeOf((*MockSpanner)(nil).CommitSpan), arg0, arg1, arg2, arg3, arg4) +} + +// GetCurrentSpan mocks base method. +func (m *MockSpanner) GetCurrentSpan(arg0 context.Context, arg1 common.Hash) (*span.Span, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentSpan", arg0, arg1) + ret0, _ := ret[0].(*span.Span) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCurrentSpan indicates an expected call of GetCurrentSpan. +func (mr *MockSpannerMockRecorder) GetCurrentSpan(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentSpan", reflect.TypeOf((*MockSpanner)(nil).GetCurrentSpan), arg0, arg1) +} + +// GetCurrentValidatorsByBlockNrOrHash mocks base method. +func (m *MockSpanner) GetCurrentValidatorsByBlockNrOrHash(arg0 context.Context, arg1 rpc.BlockNumberOrHash, arg2 uint64) ([]*valset.Validator, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentValidatorsByBlockNrOrHash", arg0, arg1, arg2) + ret0, _ := ret[0].([]*valset.Validator) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCurrentValidatorsByBlockNrOrHash indicates an expected call of GetCurrentValidatorsByBlockNrOrHash. +func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByBlockNrOrHash(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorsByBlockNrOrHash", reflect.TypeOf((*MockSpanner)(nil).GetCurrentValidatorsByBlockNrOrHash), arg0, arg1, arg2) +} + +// GetCurrentValidatorsByHash mocks base method. +func (m *MockSpanner) GetCurrentValidatorsByHash(arg0 context.Context, arg1 common.Hash, arg2 uint64) ([]*valset.Validator, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentValidatorsByHash", arg0, arg1, arg2) + ret0, _ := ret[0].([]*valset.Validator) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCurrentValidatorsByHash indicates an expected call of GetCurrentValidatorsByHash. +func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByHash(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorsByHash", reflect.TypeOf((*MockSpanner)(nil).GetCurrentValidatorsByHash), arg0, arg1, arg2) +} diff --git a/consensus/bor/statefull/processor.go b/consensus/bor/statefull/processor.go new file mode 100644 index 0000000000..42f53f2d99 --- /dev/null +++ b/consensus/bor/statefull/processor.go @@ -0,0 +1,129 @@ +package statefull + +import ( + "context" + "math" + "math/big" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" +) + +var systemAddress = common.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE") + +type ChainContext struct { + Chain consensus.ChainHeaderReader + Bor consensus.Engine +} + +func (c ChainContext) Engine() consensus.Engine { + return c.Bor +} + +func (c ChainContext) GetHeader(hash common.Hash, number uint64) *types.Header { + return c.Chain.GetHeader(hash, number) +} + +// callmsg implements core.Message to allow passing it as a transaction simulator. +type Callmsg struct { + ethereum.CallMsg +} + +func (m Callmsg) From() common.Address { return m.CallMsg.From } +func (m Callmsg) Nonce() uint64 { return 0 } +func (m Callmsg) CheckNonce() bool { return false } +func (m Callmsg) To() *common.Address { return m.CallMsg.To } +func (m Callmsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } +func (m Callmsg) Gas() uint64 { return m.CallMsg.Gas } +func (m Callmsg) Value() *big.Int { return m.CallMsg.Value } +func (m Callmsg) Data() []byte { return m.CallMsg.Data } + +// get system message +func GetSystemMessage(toAddress common.Address, data []byte) Callmsg { + return Callmsg{ + ethereum.CallMsg{ + From: systemAddress, + Gas: math.MaxUint64 / 2, + GasPrice: big.NewInt(0), + Value: big.NewInt(0), + To: &toAddress, + Data: data, + }, + } +} + +// apply message +func ApplyMessage( + _ context.Context, + msg Callmsg, + state *state.StateDB, + header *types.Header, + chainConfig *params.ChainConfig, + chainContext core.ChainContext, +) (uint64, error) { + initialGas := msg.Gas() + + // Create a new context to be used in the EVM environment + blockContext := core.NewEVMBlockContext(header, chainContext, &header.Coinbase) + + // Create a new environment which holds all relevant information + // about the transaction and calling mechanisms. + vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{}) + + // nolint : contextcheck + // Apply the transaction to the current state (included in the env) + ret, gasLeft, err := vmenv.Call( + vm.AccountRef(msg.From()), + *msg.To(), + msg.Data(), + msg.Gas(), + msg.Value(), + ) + + success := big.NewInt(5).SetBytes(ret) + + if success.Cmp(big.NewInt(0)) == 0 { + log.Error("message execution failed on contract", "msgData", msg.Data) + } + + // Update the state with pending changes + if err != nil { + state.Finalise(true) + } + + gasUsed := initialGas - gasLeft + + return gasUsed, nil +} + +func ApplyBorMessage(vmenv vm.EVM, msg Callmsg) (*core.ExecutionResult, error) { + initialGas := msg.Gas() + + // Apply the transaction to the current state (included in the env) + ret, gasLeft, err := vmenv.Call( + vm.AccountRef(msg.From()), + *msg.To(), + msg.Data(), + msg.Gas(), + msg.Value(), + ) + // Update the state with pending changes + if err != nil { + vmenv.StateDB.Finalise(true) + } + + gasUsed := initialGas - gasLeft + + return &core.ExecutionResult{ + UsedGas: gasUsed, + Err: err, + ReturnData: ret, + }, nil +} diff --git a/consensus/bor/valset/error.go b/consensus/bor/valset/error.go new file mode 100644 index 0000000000..37add21683 --- /dev/null +++ b/consensus/bor/valset/error.go @@ -0,0 +1,32 @@ +package valset + +import "fmt" + +// TotalVotingPowerExceededError is returned when the maximum allowed total voting power is exceeded +type TotalVotingPowerExceededError struct { + Sum int64 + Validators []*Validator +} + +func (e *TotalVotingPowerExceededError) Error() string { + return fmt.Sprintf( + "Total voting power should be guarded to not exceed %v; got: %v; for validator set: %v", + MaxTotalVotingPower, + e.Sum, + e.Validators, + ) +} + +type InvalidStartEndBlockError struct { + Start uint64 + End uint64 + CurrentHeader uint64 +} + +func (e *InvalidStartEndBlockError) Error() string { + return fmt.Sprintf( + "Invalid parameters start: %d and end block: %d params", + e.Start, + e.End, + ) +} diff --git a/consensus/bor/valset/validator.go b/consensus/bor/valset/validator.go new file mode 100644 index 0000000000..f89ae0fe2c --- /dev/null +++ b/consensus/bor/valset/validator.go @@ -0,0 +1,167 @@ +package valset + +import ( + "bytes" + "errors" + "fmt" + "math/big" + "sort" + "strings" + + "github.com/ethereum/go-ethereum/common" +) + +// Validator represents Volatile state for each Validator +type Validator struct { + ID uint64 `json:"ID"` + Address common.Address `json:"signer"` + VotingPower int64 `json:"power"` + ProposerPriority int64 `json:"accum"` +} + +// NewValidator creates new validator +func NewValidator(address common.Address, votingPower int64) *Validator { + return &Validator{ + Address: address, + VotingPower: votingPower, + ProposerPriority: 0, + } +} + +// Copy creates a new copy of the validator so we can mutate ProposerPriority. +// Panics if the validator is nil. +func (v *Validator) Copy() *Validator { + vCopy := *v + return &vCopy +} + +// Cmp returns the one validator with a higher ProposerPriority. +// If ProposerPriority is same, it returns the validator with lexicographically smaller address +func (v *Validator) Cmp(other *Validator) *Validator { + // if both of v and other are nil, nil will be returned and that could possibly lead to nil pointer dereference bubbling up the stack + if v == nil { + return other + } + + if other == nil { + return v + } + + if v.ProposerPriority > other.ProposerPriority { + return v + } + + if v.ProposerPriority < other.ProposerPriority { + return other + } + + result := bytes.Compare(v.Address.Bytes(), other.Address.Bytes()) + + if result == 0 { + panic("Cannot compare identical validators") + } + + if result < 0 { + return v + } + + // result > 0 + return other +} + +func (v *Validator) String() string { + if v == nil { + return "nil-Validator" + } + + return fmt.Sprintf("Validator{%v Power:%v Priority:%v}", + v.Address.Hex(), + v.VotingPower, + v.ProposerPriority) +} + +// ValidatorListString returns a prettified validator list for logging purposes. +func ValidatorListString(vals []*Validator) string { + chunks := make([]string, len(vals)) + for i, val := range vals { + chunks[i] = fmt.Sprintf("%s:%d", val.Address, val.VotingPower) + } + + return strings.Join(chunks, ",") +} + +// HeaderBytes return header bytes +func (v *Validator) HeaderBytes() []byte { + result := make([]byte, 40) + copy(result[:20], v.Address.Bytes()) + copy(result[20:], v.PowerBytes()) + + return result +} + +// PowerBytes return power bytes +func (v *Validator) PowerBytes() []byte { + powerBytes := big.NewInt(0).SetInt64(v.VotingPower).Bytes() + result := make([]byte, 20) + copy(result[20-len(powerBytes):], powerBytes) + + return result +} + +// MinimalVal returns block number of last validator update +func (v *Validator) MinimalVal() MinimalVal { + return MinimalVal{ + ID: v.ID, + VotingPower: uint64(v.VotingPower), + Signer: v.Address, + } +} + +// ParseValidators returns validator set bytes +func ParseValidators(validatorsBytes []byte) ([]*Validator, error) { + if len(validatorsBytes)%40 != 0 { + return nil, errors.New("Invalid validators bytes") + } + + result := make([]*Validator, len(validatorsBytes)/40) + + for i := 0; i < len(validatorsBytes); i += 40 { + address := make([]byte, 20) + power := make([]byte, 20) + + copy(address, validatorsBytes[i:i+20]) + copy(power, validatorsBytes[i+20:i+40]) + + result[i/40] = NewValidator(common.BytesToAddress(address), big.NewInt(0).SetBytes(power).Int64()) + } + + return result, nil +} + +// --- + +// MinimalVal is the minimal validator representation +// Used to send validator information to bor validator contract +type MinimalVal struct { + ID uint64 `json:"ID"` + VotingPower uint64 `json:"power"` // TODO add 10^-18 here so that we dont overflow easily + Signer common.Address `json:"signer"` +} + +// SortMinimalValByAddress sorts validators +func SortMinimalValByAddress(a []MinimalVal) []MinimalVal { + sort.Slice(a, func(i, j int) bool { + return bytes.Compare(a[i].Signer.Bytes(), a[j].Signer.Bytes()) < 0 + }) + + return a +} + +// ValidatorsToMinimalValidators converts array of validators to minimal validators +func ValidatorsToMinimalValidators(vals []Validator) (minVals []MinimalVal) { + for _, val := range vals { + minVals = append(minVals, val.MinimalVal()) + } + + return +} diff --git a/consensus/bor/valset/validator_set.go b/consensus/bor/valset/validator_set.go new file mode 100644 index 0000000000..da187ddf9d --- /dev/null +++ b/consensus/bor/valset/validator_set.go @@ -0,0 +1,786 @@ +package valset + +// Tendermint leader selection algorithm + +import ( + "bytes" + "fmt" + "math" + "math/big" + "sort" + "strings" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" +) + +// MaxTotalVotingPower - the maximum allowed total voting power. +// It needs to be sufficiently small to, in all cases: +// 1. prevent clipping in incrementProposerPriority() +// 2. let (diff+diffMax-1) not overflow in IncrementProposerPriority() +// (Proof of 1 is tricky, left to the reader). +// It could be higher, but this is sufficiently large for our purposes, +// and leaves room for defensive purposes. +// PriorityWindowSizeFactor - is a constant that when multiplied with the total voting power gives +// the maximum allowed distance between validator priorities. + +const ( + MaxTotalVotingPower = int64(math.MaxInt64) / 8 + PriorityWindowSizeFactor = 2 +) + +// ValidatorSet represent a set of *Validator at a given height. +// The validators can be fetched by address or index. +// The index is in order of .Address, so the indices are fixed +// for all rounds of a given blockchain height - ie. the validators +// are sorted by their address. +// On the other hand, the .ProposerPriority of each validator and +// the designated .GetProposer() of a set changes every round, +// upon calling .IncrementProposerPriority(). +// NOTE: Not goroutine-safe. +// NOTE: All get/set to validators should copy the value for safety. +type ValidatorSet struct { + // NOTE: persisted via reflect, must be exported. + Validators []*Validator `json:"validators"` + Proposer *Validator `json:"proposer"` + + // cached (unexported) + totalVotingPower int64 + validatorsMap map[common.Address]int // address -> index +} + +// NewValidatorSet initializes a ValidatorSet by copying over the +// values from `valz`, a list of Validators. If valz is nil or empty, +// the new ValidatorSet will have an empty list of Validators. +// The addresses of validators in `valz` must be unique otherwise the +// function panics. +func NewValidatorSet(valz []*Validator) *ValidatorSet { + vals := &ValidatorSet{validatorsMap: make(map[common.Address]int)} + + err := vals.updateWithChangeSet(valz, false) + if err != nil { + panic(fmt.Sprintf("cannot create validator set: %s", err)) + } + + if len(valz) > 0 { + vals.IncrementProposerPriority(1) + } + + return vals +} + +// Nil or empty validator sets are invalid. +func (vals *ValidatorSet) IsNilOrEmpty() bool { + return vals == nil || len(vals.Validators) == 0 +} + +// Increment ProposerPriority and update the proposer on a copy, and return it. +func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet { + validatorCopy := vals.Copy() + validatorCopy.IncrementProposerPriority(times) + + return validatorCopy +} + +// IncrementProposerPriority increments ProposerPriority of each validator and updates the +// proposer. Panics if validator set is empty. +// `times` must be positive. +func (vals *ValidatorSet) IncrementProposerPriority(times int) { + if vals.IsNilOrEmpty() { + panic("empty validator set") + } + + if times <= 0 { + panic("Cannot call IncrementProposerPriority with non-positive times") + } + + // Cap the difference between priorities to be proportional to 2*totalPower by + // re-normalizing priorities, i.e., rescale all priorities by multiplying with: + // 2*totalVotingPower/(maxPriority - minPriority) + diffMax := PriorityWindowSizeFactor * vals.TotalVotingPower() + vals.RescalePriorities(diffMax) + vals.shiftByAvgProposerPriority() + + var proposer *Validator + // Call IncrementProposerPriority(1) times times. + for i := 0; i < times; i++ { + proposer = vals.incrementProposerPriority() + } + + vals.Proposer = proposer +} + +func (vals *ValidatorSet) RescalePriorities(diffMax int64) { + if vals.IsNilOrEmpty() { + panic("empty validator set") + } + // NOTE: This check is merely a sanity check which could be + // removed if all tests would init. voting power appropriately; + // i.e. diffMax should always be > 0 + if diffMax <= 0 { + return + } + + // Calculating ceil(diff/diffMax): + // Re-normalization is performed by dividing by an integer for simplicity. + // NOTE: This may make debugging priority issues easier as well. + diff := computeMaxMinPriorityDiff(vals) + ratio := (diff + diffMax - 1) / diffMax + + if diff > diffMax { + for _, val := range vals.Validators { + val.ProposerPriority = val.ProposerPriority / ratio + } + } +} + +func (vals *ValidatorSet) incrementProposerPriority() *Validator { + for _, val := range vals.Validators { + // Check for overflow for sum. + newPrio := safeAddClip(val.ProposerPriority, val.VotingPower) + val.ProposerPriority = newPrio + } + // Decrement the validator with most ProposerPriority. + mostest := vals.getValWithMostPriority() + // Mind the underflow. + mostest.ProposerPriority = safeSubClip(mostest.ProposerPriority, vals.TotalVotingPower()) + + return mostest +} + +// Should not be called on an empty validator set. +func (vals *ValidatorSet) computeAvgProposerPriority() int64 { + n := int64(len(vals.Validators)) + sum := big.NewInt(0) + + for _, val := range vals.Validators { + sum.Add(sum, big.NewInt(val.ProposerPriority)) + } + + avg := sum.Div(sum, big.NewInt(n)) + + if avg.IsInt64() { + return avg.Int64() + } + + // This should never happen: each val.ProposerPriority is in bounds of int64. + panic(fmt.Sprintf("Cannot represent avg ProposerPriority as an int64 %v", avg)) +} + +// Compute the difference between the max and min ProposerPriority of that set. +func computeMaxMinPriorityDiff(vals *ValidatorSet) int64 { + if vals.IsNilOrEmpty() { + panic("empty validator set") + } + + max := int64(math.MinInt64) + min := int64(math.MaxInt64) + + for _, v := range vals.Validators { + if v.ProposerPriority < min { + min = v.ProposerPriority + } + + if v.ProposerPriority > max { + max = v.ProposerPriority + } + } + + diff := max - min + + if diff < 0 { + return -1 * diff + } else { + return diff + } +} + +func (vals *ValidatorSet) getValWithMostPriority() *Validator { + var res *Validator + for _, val := range vals.Validators { + res = res.Cmp(val) + } + + return res +} + +func (vals *ValidatorSet) shiftByAvgProposerPriority() { + if vals.IsNilOrEmpty() { + panic("empty validator set") + } + + avgProposerPriority := vals.computeAvgProposerPriority() + + for _, val := range vals.Validators { + val.ProposerPriority = safeSubClip(val.ProposerPriority, avgProposerPriority) + } +} + +// Makes a copy of the validator list. +func validatorListCopy(valsList []*Validator) []*Validator { + if valsList == nil { + return nil + } + + valsCopy := make([]*Validator, len(valsList)) + + for i, val := range valsList { + valsCopy[i] = val.Copy() + } + + return valsCopy +} + +// Copy each validator into a new ValidatorSet. +func (vals *ValidatorSet) Copy() *ValidatorSet { + valCopy := validatorListCopy(vals.Validators) + validatorsMap := make(map[common.Address]int, len(vals.Validators)) + + for i, val := range valCopy { + validatorsMap[val.Address] = i + } + + return &ValidatorSet{ + Validators: validatorListCopy(vals.Validators), + Proposer: vals.Proposer, + totalVotingPower: vals.totalVotingPower, + validatorsMap: validatorsMap, + } +} + +// HasAddress returns true if address given is in the validator set, false - +// otherwise. +func (vals *ValidatorSet) HasAddress(address common.Address) bool { + _, ok := vals.validatorsMap[address] + + return ok +} + +// GetByAddress returns an index of the validator with address and validator +// itself if found. Otherwise, -1 and nil are returned. +func (vals *ValidatorSet) GetByAddress(address common.Address) (index int, val *Validator) { + idx, ok := vals.validatorsMap[address] + if ok { + return idx, vals.Validators[idx].Copy() + } + + return -1, nil +} + +// GetByIndex returns the validator's address and validator itself by index. +// It returns nil values if index is less than 0 or greater or equal to +// len(ValidatorSet.Validators). +func (vals *ValidatorSet) GetByIndex(index int) (address common.Address, val *Validator) { + if index < 0 || index >= len(vals.Validators) { + return common.Address{}, nil + } + + val = vals.Validators[index] + + return val.Address, val.Copy() +} + +// Size returns the length of the validator set. +func (vals *ValidatorSet) Size() int { + return len(vals.Validators) +} + +// Force recalculation of the set's total voting power. +func (vals *ValidatorSet) UpdateTotalVotingPower() error { + sum := int64(0) + for _, val := range vals.Validators { + // mind overflow + sum = safeAddClip(sum, val.VotingPower) + if sum > MaxTotalVotingPower { + return &TotalVotingPowerExceededError{sum, vals.Validators} + } + } + + vals.totalVotingPower = sum + + return nil +} + +// TotalVotingPower returns the sum of the voting powers of all validators. +// It recomputes the total voting power if required. +func (vals *ValidatorSet) TotalVotingPower() int64 { + if vals.totalVotingPower == 0 { + log.Debug("invoking updateTotalVotingPower before returning it") + + if err := vals.UpdateTotalVotingPower(); err != nil { + // Can/should we do better? + panic(err) + } + } + + return vals.totalVotingPower +} + +// GetProposer returns the current proposer. If the validator set is empty, nil +// is returned. +func (vals *ValidatorSet) GetProposer() (proposer *Validator) { + if len(vals.Validators) == 0 { + return nil + } + + if vals.Proposer == nil { + vals.Proposer = vals.findProposer() + } + + return vals.Proposer.Copy() +} + +func (vals *ValidatorSet) findProposer() *Validator { + var proposer *Validator + for _, val := range vals.Validators { + if proposer == nil || val.Address != proposer.Address { + proposer = proposer.Cmp(val) + } + } + + return proposer +} + +// Hash returns the Merkle root hash build using validators (as leaves) in the +// set. +// func (vals *ValidatorSet) Hash() []byte { +// if len(vals.Validators) == 0 { +// return nil +// } +// bzs := make([][]byte, len(vals.Validators)) +// for i, val := range vals.Validators { +// bzs[i] = val.Bytes() +// } +// return merkle.SimpleHashFromByteSlices(bzs) +// } + +// Iterate will run the given function over the set. +func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool) { + for i, val := range vals.Validators { + stop := fn(i, val.Copy()) + if stop { + break + } + } +} + +// Checks changes against duplicates, splits the changes in updates and removals, sorts them by address. +// +// Returns: +// updates, removals - the sorted lists of updates and removals +// err - non-nil if duplicate entries or entries with negative voting power are seen +// +// No changes are made to 'origChanges'. +func processChanges(origChanges []*Validator) (updates, removals []*Validator, err error) { + // Make a deep copy of the changes and sort by address. + changes := validatorListCopy(origChanges) + sort.Sort(ValidatorsByAddress(changes)) + + sliceCap := len(changes) / 2 + if sliceCap == 0 { + sliceCap = 1 + } + + removals = make([]*Validator, 0, sliceCap) + updates = make([]*Validator, 0, sliceCap) + + var prevAddr common.Address + + // Scan changes by address and append valid validators to updates or removals lists. + for _, valUpdate := range changes { + if valUpdate.Address == prevAddr { + err = fmt.Errorf("duplicate entry %v in %v", valUpdate, changes) + return nil, nil, err + } + + if valUpdate.VotingPower < 0 { + err = fmt.Errorf("voting power can't be negative: %v", valUpdate) + return nil, nil, err + } + + if valUpdate.VotingPower > MaxTotalVotingPower { + err = fmt.Errorf("to prevent clipping/ overflow, voting power can't be higher than %v: %v ", + MaxTotalVotingPower, valUpdate) + return nil, nil, err + } + + if valUpdate.VotingPower == 0 { + removals = append(removals, valUpdate) + } else { + updates = append(updates, valUpdate) + } + + prevAddr = valUpdate.Address + } + + return updates, removals, err +} + +// Verifies a list of updates against a validator set, making sure the allowed +// total voting power would not be exceeded if these updates would be applied to the set. +// +// Returns: +// updatedTotalVotingPower - the new total voting power if these updates would be applied +// numNewValidators - number of new validators +// err - non-nil if the maximum allowed total voting power would be exceeded +// +// 'updates' should be a list of proper validator changes, i.e. they have been verified +// by processChanges for duplicates and invalid values. +// No changes are made to the validator set 'vals'. +func verifyUpdates(updates []*Validator, vals *ValidatorSet) (updatedTotalVotingPower int64, numNewValidators int, err error) { + updatedTotalVotingPower = vals.TotalVotingPower() + + for _, valUpdate := range updates { + address := valUpdate.Address + _, val := vals.GetByAddress(address) + + if val == nil { + // New validator, add its voting power the the total. + updatedTotalVotingPower += valUpdate.VotingPower + numNewValidators++ + } else { + // Updated validator, add the difference in power to the total. + updatedTotalVotingPower += valUpdate.VotingPower - val.VotingPower + } + + overflow := updatedTotalVotingPower > MaxTotalVotingPower + + if overflow { + err = fmt.Errorf( + "failed to add/update validator %v, total voting power would exceed the max allowed %v", + valUpdate, MaxTotalVotingPower) + + return 0, 0, err + } + } + + return updatedTotalVotingPower, numNewValidators, nil +} + +// Computes the proposer priority for the validators not present in the set based on 'updatedTotalVotingPower'. +// Leaves unchanged the priorities of validators that are changed. +// +// 'updates' parameter must be a list of unique validators to be added or updated. +// No changes are made to the validator set 'vals'. +func computeNewPriorities(updates []*Validator, vals *ValidatorSet, updatedTotalVotingPower int64) { + for _, valUpdate := range updates { + address := valUpdate.Address + _, val := vals.GetByAddress(address) + + if val == nil { + // add val + // Set ProposerPriority to -C*totalVotingPower (with C ~= 1.125) to make sure validators can't + // un-bond and then re-bond to reset their (potentially previously negative) ProposerPriority to zero. + // + // Contract: updatedVotingPower < MaxTotalVotingPower to ensure ProposerPriority does + // not exceed the bounds of int64. + // + // Compute ProposerPriority = -1.125*totalVotingPower == -(updatedVotingPower + (updatedVotingPower >> 3)). + valUpdate.ProposerPriority = -(updatedTotalVotingPower + (updatedTotalVotingPower >> 3)) + } else { + valUpdate.ProposerPriority = val.ProposerPriority + } + } +} + +// Merges the vals' validator list with the updates list. +// When two elements with same address are seen, the one from updates is selected. +// Expects updates to be a list of updates sorted by address with no duplicates or errors, +// must have been validated with verifyUpdates() and priorities computed with computeNewPriorities(). +func (vals *ValidatorSet) applyUpdates(updates []*Validator) { + existing := vals.Validators + merged := make([]*Validator, len(existing)+len(updates)) + i := 0 + + for len(existing) > 0 && len(updates) > 0 { + if bytes.Compare(existing[0].Address.Bytes(), updates[0].Address.Bytes()) < 0 { // unchanged validator + merged[i] = existing[0] + existing = existing[1:] + } else { + // Apply add or update. + merged[i] = updates[0] + + if existing[0].Address == updates[0].Address { + // Validator is present in both, advance existing. + existing = existing[1:] + } + + updates = updates[1:] + } + + i++ + } + + // Add the elements which are left. + for j := 0; j < len(existing); j++ { + merged[i] = existing[j] + i++ + } + + // OR add updates which are left. + for j := 0; j < len(updates); j++ { + merged[i] = updates[j] + i++ + } + + vals.Validators = merged[:i] +} + +// Checks that the validators to be removed are part of the validator set. +// No changes are made to the validator set 'vals'. +func verifyRemovals(deletes []*Validator, vals *ValidatorSet) error { + for _, valUpdate := range deletes { + address := valUpdate.Address + _, val := vals.GetByAddress(address) + + if val == nil { + return fmt.Errorf("failed to find validator %X to remove", address) + } + } + + if len(deletes) > len(vals.Validators) { + panic("more deletes than validators") + } + + return nil +} + +// Removes the validators specified in 'deletes' from validator set 'vals'. +// Should not fail as verification has been done before. +func (vals *ValidatorSet) applyRemovals(deletes []*Validator) { + existing := vals.Validators + + merged := make([]*Validator, len(existing)-len(deletes)) + i := 0 + + // Loop over deletes until we removed all of them. + for len(deletes) > 0 { + if existing[0].Address == deletes[0].Address { + deletes = deletes[1:] + } else { // Leave it in the resulting slice. + merged[i] = existing[0] + i++ + } + + existing = existing[1:] + } + + // Add the elements which are left. + for j := 0; j < len(existing); j++ { + merged[i] = existing[j] + i++ + } + + vals.Validators = merged[:i] +} + +// Main function used by UpdateWithChangeSet() and NewValidatorSet(). +// If 'allowDeletes' is false then delete operations (identified by validators with voting power 0) +// are not allowed and will trigger an error if present in 'changes'. +// The 'allowDeletes' flag is set to false by NewValidatorSet() and to true by UpdateWithChangeSet(). +func (vals *ValidatorSet) updateWithChangeSet(changes []*Validator, allowDeletes bool) error { + if len(changes) <= 0 { + return nil + } + + // Check for duplicates within changes, split in 'updates' and 'deletes' lists (sorted). + updates, deletes, err := processChanges(changes) + if err != nil { + return err + } + + if !allowDeletes && len(deletes) != 0 { + return fmt.Errorf("cannot process validators with voting power 0: %v", deletes) + } + + // Verify that applying the 'deletes' against 'vals' will not result in error. + if err := verifyRemovals(deletes, vals); err != nil { + return err + } + + // Verify that applying the 'updates' against 'vals' will not result in error. + updatedTotalVotingPower, numNewValidators, err := verifyUpdates(updates, vals) + if err != nil { + return err + } + + // Check that the resulting set will not be empty. + if numNewValidators == 0 && len(vals.Validators) == len(deletes) { + return fmt.Errorf("applying the validator changes would result in empty set") + } + + // Compute the priorities for updates. + computeNewPriorities(updates, vals, updatedTotalVotingPower) + + // Apply updates and removals. + vals.updateValidators(updates, deletes) + + if err := vals.UpdateTotalVotingPower(); err != nil { + return err + } + + // Scale and center. + vals.RescalePriorities(PriorityWindowSizeFactor * vals.TotalVotingPower()) + vals.shiftByAvgProposerPriority() + + return nil +} + +func (vals *ValidatorSet) updateValidators(updates []*Validator, deletes []*Validator) { + vals.applyUpdates(updates) + vals.applyRemovals(deletes) + + vals.UpdateValidatorMap() +} + +func (vals *ValidatorSet) UpdateValidatorMap() { + vals.validatorsMap = make(map[common.Address]int, len(vals.Validators)) + + for i, val := range vals.Validators { + vals.validatorsMap[val.Address] = i + } +} + +// UpdateWithChangeSet attempts to update the validator set with 'changes'. +// It performs the following steps: +// - validates the changes making sure there are no duplicates and splits them in updates and deletes +// - verifies that applying the changes will not result in errors +// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities +// across old and newly added validators are fair +// - computes the priorities of new validators against the final set +// - applies the updates against the validator set +// - applies the removals against the validator set +// - performs scaling and centering of priority values +// +// If an error is detected during verification steps, it is returned and the validator set +// is not changed. +func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error { + return vals.updateWithChangeSet(changes, true) +} + +//----------------- +// ErrTooMuchChange + +func IsErrTooMuchChange(err error) bool { + switch err.(type) { + case tooMuchChangeError: + return true + default: + return false + } +} + +type tooMuchChangeError struct { + got int64 + needed int64 +} + +func (e tooMuchChangeError) Error() string { + return fmt.Sprintf("Invalid commit -- insufficient old voting power: got %v, needed %v", e.got, e.needed) +} + +//---------------- + +func (vals *ValidatorSet) String() string { + return vals.StringIndented("") +} + +func (vals *ValidatorSet) StringIndented(indent string) string { + if vals == nil { + return "nil-ValidatorSet" + } + + valStrings := make([]string, 0, len(vals.Validators)) + + vals.Iterate(func(index int, val *Validator) bool { + valStrings = append(valStrings, val.String()) + return false + }) + + return fmt.Sprintf(`ValidatorSet{ +%s Proposer: %v +%s Validators: +%s %v +%s}`, + indent, vals.GetProposer().String(), + indent, + indent, strings.Join(valStrings, "\n"+indent+" "), + indent) +} + +func (vals *ValidatorSet) SetTotalVotingPower(totalVotingPower int64) { + vals.totalVotingPower = totalVotingPower +} + +func (vals *ValidatorSet) SetMap(validatorsMap map[common.Address]int) { + vals.validatorsMap = validatorsMap +} + +//------------------------------------- +// Implements sort for sorting validators by address. + +// Sort validators by address. +type ValidatorsByAddress []*Validator + +func (valz ValidatorsByAddress) Len() int { + return len(valz) +} + +func (valz ValidatorsByAddress) Less(i, j int) bool { + return bytes.Compare(valz[i].Address.Bytes(), valz[j].Address.Bytes()) == -1 +} + +func (valz ValidatorsByAddress) Swap(i, j int) { + it := valz[i] + valz[i] = valz[j] + valz[j] = it +} + +/////////////////////////////////////////////////////////////////////////////// +// safe addition/subtraction + +func safeAdd(a, b int64) (int64, bool) { + if b > 0 && a > math.MaxInt64-b { + return -1, true + } else if b < 0 && a < math.MinInt64-b { + return -1, true + } + + return a + b, false +} + +func safeSub(a, b int64) (int64, bool) { + if b > 0 && a < math.MinInt64+b { + return -1, true + } else if b < 0 && a > math.MaxInt64+b { + return -1, true + } + + return a - b, false +} + +func safeAddClip(a, b int64) int64 { + c, overflow := safeAdd(a, b) + if overflow { + if b < 0 { + return math.MinInt64 + } + + return math.MaxInt64 + } + + return c +} + +func safeSubClip(a, b int64) int64 { + c, overflow := safeSub(a, b) + if overflow { + if b > 0 { + return math.MinInt64 + } + + return math.MaxInt64 + } + + return c +} diff --git a/consensus/bor/valset/validator_set_test.go b/consensus/bor/valset/validator_set_test.go new file mode 100644 index 0000000000..9397ca3e92 --- /dev/null +++ b/consensus/bor/valset/validator_set_test.go @@ -0,0 +1,199 @@ +package valset + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gotest.tools/assert" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" +) + +func NewValidatorFromKey(key string, votingPower int64) *Validator { + privKey, _ := crypto.HexToECDSA(key) + + return NewValidator(crypto.PubkeyToAddress(privKey.PublicKey), votingPower) +} + +func GetValidators() [4]*Validator { + const ( + // addr0 = 0x96C42C56fdb78294F96B0cFa33c92bed7D75F96a + signer0 = "c8deb0bea5c41afe8e37b4d1bd84e31adff11b09c8c96ff4b605003cce067cd9" + + // addr1 = 0x98925BE497f6dFF6A5a33dDA8B5933cA35262d69 + signer1 = "c8deb0bea5c41afe8e37b4d1bd84e31adff11b09c8c96ff4b605003cce067cd8" + + //addr2 = 0x648Cf2A5b119E2c04061021834F8f75735B1D36b + signer2 = "c8deb0bea5c41afe8e37b4d1bd84e31adff11b09c8c96ff4b605003cce067cd7" + + //addr3 = 0x168f220B3b313D456eD4797520eFdFA9c57E6C45 + signer3 = "c8deb0bea5c41afe8e37b4d1bd84e31adff11b09c8c96ff4b605003cce067cd6" + ) + + return [4]*Validator{ + NewValidatorFromKey(signer0, 100), + NewValidatorFromKey(signer1, 200), + NewValidatorFromKey(signer2, 300), + NewValidatorFromKey(signer3, 400), + } +} + +func TestIncrementProposerPriority(t *testing.T) { + t.Parallel() + + vals := GetValidators() + + // Validator set length = 1 + valSet := NewValidatorSet(vals[:1]) + + expectedPropsers := []*Validator{vals[0], vals[0], vals[0], vals[0], vals[0], vals[0], vals[0], vals[0], vals[0], vals[0]} + + for i := 0; i < 10; i++ { + valSet.IncrementProposerPriority(1) + + require.Equal(t, expectedPropsers[i].Address, valSet.GetProposer().Address) + } + + // Validator set length = 2 + valSet = NewValidatorSet(vals[:2]) + + expectedPropsers = []*Validator{vals[0], vals[1], vals[1], vals[0], vals[1], vals[1], vals[0], vals[1], vals[1], vals[0]} + + for i := 0; i < 10; i++ { + valSet.IncrementProposerPriority(1) + + require.Equal(t, expectedPropsers[i].Address, valSet.GetProposer().Address) + } + + // Validator set length = 3 + valSet = NewValidatorSet(vals[:3]) + + expectedPropsers = []*Validator{vals[1], vals[2], vals[0], vals[1], vals[2], vals[2], vals[1], vals[2], vals[0], vals[1]} + + for i := 0; i < 10; i++ { + valSet.IncrementProposerPriority(1) + + require.Equal(t, expectedPropsers[i].Address, valSet.GetProposer().Address) + } + + // Validator set length = 4 + valSet = NewValidatorSet(vals[:4]) + + expectedPropsers = []*Validator{vals[2], vals[1], vals[3], vals[2], vals[0], vals[3], vals[1], vals[2], vals[3], vals[3]} + + for i := 0; i < 10; i++ { + valSet.IncrementProposerPriority(1) + + require.Equal(t, expectedPropsers[i].Address, valSet.GetProposer().Address) + } +} + +func TestRescalePriorities(t *testing.T) { + t.Parallel() + + vals := GetValidators() + + // Validator set length = 1 + valSet := NewValidatorSet(vals[:1]) + + valSet.RescalePriorities(10) + + expectedPriorities := []int64{0} + for i, val := range valSet.Validators { + require.Equal(t, expectedPriorities[i], val.ProposerPriority) + } + + // Validator set length = 2 + + valSet = NewValidatorSet(vals[:2]) + + valSet.RescalePriorities(100) + + expectedPriorities = []int64{50, -50} + for i, val := range valSet.Validators { + require.Equal(t, expectedPriorities[i], val.ProposerPriority) + } + + // Validator set length = 3 + + valSet = NewValidatorSet(vals[:3]) + + valSet.RescalePriorities(30) + + expectedPriorities = []int64{-17, 5, 11} + for i, val := range valSet.Validators { + require.Equal(t, expectedPriorities[i], val.ProposerPriority) + } + + // Validator set length = 4 + + valSet = NewValidatorSet(vals[:4]) + + valSet.RescalePriorities(10) + + expectedPriorities = []int64{-6, 3, 1, 2} + for i, val := range valSet.Validators { + require.Equal(t, expectedPriorities[i], val.ProposerPriority) + } +} + +func TestGetValidatorByAddressAndIndex(t *testing.T) { + t.Parallel() + + vals := GetValidators() + valSet := NewValidatorSet(vals[:4]) + + for _, val := range valSet.Validators { + idx, valByAddress := valSet.GetByAddress(val.Address) + addr, valByIndex := valSet.GetByIndex(idx) + + assert.DeepEqual(t, val, valByIndex) + assert.DeepEqual(t, val, valByAddress) + assert.DeepEqual(t, val.Address, addr) + } + + tempAddress := common.HexToAddress("0x12345") + + // Negative Testcase + idx, _ := valSet.GetByAddress(tempAddress) + require.Equal(t, idx, -1) + + // checking for validator index out of range + addr, _ := valSet.GetByIndex(100) + require.Equal(t, addr, common.Address{}) +} + +func TestUpdateWithChangeSet(t *testing.T) { + t.Parallel() + + vals := GetValidators() + valSet := NewValidatorSet(vals[:4]) + + // halved the power of vals[2] and doubled the power of vals[3] + vals[2].VotingPower = 150 + vals[3].VotingPower = 800 + + // Adding new temp validator in the set + const tempSigner = "c8deb0bea5c41afe8e37b4d1bd84e31adff11b09c8c96ff4b605003cce067cd5" + + tempVal := NewValidatorFromKey(tempSigner, 250) + + // check totalVotingPower before updating validator set + require.Equal(t, int64(1000), valSet.TotalVotingPower()) + + err := valSet.UpdateWithChangeSet([]*Validator{vals[2], vals[3], tempVal}) + require.NoError(t, err) + + // check totalVotingPower after updating validator set + require.Equal(t, int64(1500), valSet.TotalVotingPower()) + + _, updatedVal2 := valSet.GetByAddress(vals[2].Address) + require.Equal(t, int64(150), updatedVal2.VotingPower) + + _, updatedVal3 := valSet.GetByAddress(vals[3].Address) + require.Equal(t, int64(800), updatedVal3.VotingPower) + + _, updatedTempVal := valSet.GetByAddress(tempVal.Address) + require.Equal(t, int64(250), updatedTempVal.VotingPower) +} diff --git a/core/blockchain.go b/core/blockchain.go index 8e5372c905..f4416ed15d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -18,10 +18,14 @@ package core import ( + "compress/gzip" + "context" "errors" "fmt" "io" "math/big" + "os" + "path/filepath" "runtime" "sort" "strings" @@ -29,17 +33,23 @@ import ( "sync/atomic" "time" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" + + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/common/prque" + "github.com/ethereum/go-ethereum/common/tracing" "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core/blockstm" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/utils" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/eth/downloader/whitelist" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/syncx" @@ -72,12 +82,15 @@ var ( snapshotStorageReadTimer = metrics.NewRegisteredTimer("chain/snapshot/storage/reads", nil) snapshotCommitTimer = metrics.NewRegisteredTimer("chain/snapshot/commits", nil) + blockImportTimer = metrics.NewRegisteredMeter("chain/imports", nil) triedbCommitTimer = metrics.NewRegisteredTimer("chain/triedb/commits", nil) - blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil) - blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil) - blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil) - blockWriteTimer = metrics.NewRegisteredTimer("chain/write", nil) + blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil) + blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil) + blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil) + blockWriteTimer = metrics.NewRegisteredTimer("chain/write", nil) + blockExecutionParallelCounter = metrics.NewRegisteredCounter("chain/execution/parallel", nil) + blockExecutionSerialCounter = metrics.NewRegisteredCounter("chain/execution/serial", nil) blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil) blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) @@ -93,7 +106,7 @@ var ( const ( bodyCacheLimit = 256 blockCacheLimit = 256 - receiptsCacheLimit = 32 + receiptsCacheLimit = 1024 txLookupCacheLimit = 1024 maxFutureBlocks = 256 maxTimeFutureBlocks = 30 @@ -137,19 +150,21 @@ type CacheConfig struct { TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory Preimages bool // Whether to store preimage of trie key to the disk + TriesInMemory uint64 // Number of recent tries to keep in memory SnapshotNoBuild bool // Whether the background generation is allowed SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it } -// defaultCacheConfig are the default caching values if none are specified by the +// DefaultCacheConfig are the default caching values if none are specified by the // user (also used during testing). -var defaultCacheConfig = &CacheConfig{ +var DefaultCacheConfig = &CacheConfig{ TrieCleanLimit: 256, TrieDirtyLimit: 256, TrieTimeLimit: 5 * time.Minute, SnapshotLimit: 256, SnapshotWait: true, + TriesInMemory: 1024, } // BlockChain represents the canonical chain given a database with a genesis @@ -175,7 +190,7 @@ type BlockChain struct { triegc *prque.Prque[int64, common.Hash] // Priority queue mapping block numbers to tries to gc gcproc time.Duration // Accumulates canonical block processing for trie dumping lastWrite uint64 // Last block when the state was flushed - flushInterval int64 // Time interval (processing time) after which to flush a state + flushInterval atomic.Int64 // Time interval (processing time) after which to flush a state triedb *trie.Database // The database handler for maintaining trie nodes. stateCache state.Database // State database to reuse between imports (contains state cache) @@ -216,25 +231,37 @@ type BlockChain struct { wg sync.WaitGroup // quit chan struct{} // shutdown signal, closed in Stop. - running int32 // 0 if chain is running, 1 when stopped - procInterrupt int32 // interrupt signaler for block processing - - engine consensus.Engine - validator Validator // Block and state validator interface - prefetcher Prefetcher - processor Processor // Block transaction processor interface - forker *ForkChoice - vmConfig vm.Config + stopping atomic.Bool // false if chain is running, true when stopped + procInterrupt atomic.Bool // interrupt signaler for block processing + + engine consensus.Engine + validator Validator // Block and state validator interface + prefetcher Prefetcher + processor Processor // Block transaction processor interface + parallelProcessor Processor // Parallel block transaction processor interface + forker *ForkChoice + vmConfig vm.Config + + // Bor related changes + borReceiptsCache *lru.Cache[common.Hash, *types.Receipt] // Cache for the most recent bor receipt receipts per block + stateSyncData []*types.StateSyncData // State sync data + stateSyncFeed event.Feed // State sync feed + chain2HeadFeed event.Feed // Reorg/NewHead/Fork data feed } // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialises the default Ethereum Validator // and Processor. -func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64) (*BlockChain, error) { +// +//nolint:gocognit +func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) { if cacheConfig == nil { - cacheConfig = defaultCacheConfig + cacheConfig = DefaultCacheConfig } + if cacheConfig.TriesInMemory <= 0 { + cacheConfig.TriesInMemory = DefaultCacheConfig.TriesInMemory + } // Open trie database with provided config triedb := trie.NewDatabaseWithConfig(db, &trie.Config{ Cache: cacheConfig.TrieCleanLimit, @@ -261,7 +288,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis cacheConfig: cacheConfig, db: db, triedb: triedb, - flushInterval: int64(cacheConfig.TrieTimeLimit), triegc: prque.New[int64, common.Hash](nil), quit: make(chan struct{}), chainmu: syncx.NewClosableMutex(), @@ -273,8 +299,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis futureBlocks: lru.NewCache[common.Hash, *types.Block](maxFutureBlocks), engine: engine, vmConfig: vmConfig, + + borReceiptsCache: lru.NewCache[common.Hash, *types.Receipt](receiptsCacheLimit), } - bc.forker = NewForkChoice(bc, shouldPreserve) + bc.flushInterval.Store(int64(cacheConfig.TrieTimeLimit)) + bc.forker = NewForkChoice(bc, shouldPreserve, checker) bc.stateCache = state.NewDatabaseWithNodeDB(bc.db, bc.triedb) bc.validator = NewBlockValidator(chainConfig, bc, engine) bc.prefetcher = newStatePrefetcher(chainConfig, bc, engine) @@ -307,6 +336,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } // Make sure the state associated with the block is available head := bc.CurrentBlock() + // nolint:nestif if !bc.HasState(head.Root) { // Head state is missing, before the state recovery, find out the // disk layer point of snapshot(if it's enabled). Make sure the @@ -367,7 +397,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis // The first thing the node will do is reconstruct the verification data for // the head block (ethash cache or clique voting snapshot). Might as well do // it in advance. - bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true) + // bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true) // Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain for hash := range BadHashes { @@ -427,9 +457,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis if compat, ok := genesisErr.(*params.ConfigCompatError); ok { log.Warn("Rewinding chain to upgrade configuration", "err", compat) if compat.RewindToTime > 0 { - bc.SetHeadWithTimestamp(compat.RewindToTime) + _ = bc.SetHeadWithTimestamp(compat.RewindToTime) } else { - bc.SetHead(compat.RewindToBlock) + _ = bc.SetHead(compat.RewindToBlock) } rawdb.WriteChainConfig(db, genesisHash, chainConfig) } @@ -443,6 +473,105 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis return bc, nil } +// NewParallelBlockChain , similar to NewBlockChain, creates a new blockchain object, but with a parallel state processor +func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) { + bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker) + + if err != nil { + return nil, err + } + + // Open trie database with provided config + triedb := trie.NewDatabaseWithConfig(db, &trie.Config{ + Cache: cacheConfig.TrieCleanLimit, + Journal: cacheConfig.TrieCleanJournal, + Preimages: cacheConfig.Preimages, + }) + chainConfig, _, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides) + + if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { + return nil, genesisErr + } + + bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine) + + return bc, nil +} + +func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (types.Receipts, []*types.Log, uint64, *state.StateDB, error) { + // Process the block using processor and parallelProcessor at the same time, take the one which finishes first, cancel the other, and return the result + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + type Result struct { + receipts types.Receipts + logs []*types.Log + usedGas uint64 + err error + statedb *state.StateDB + counter metrics.Counter + } + + resultChan := make(chan Result, 2) + + processorCount := 0 + + if bc.parallelProcessor != nil { + parallelStatedb, err := state.New(parent.Root, bc.stateCache, bc.snaps) + if err != nil { + return nil, nil, 0, nil, err + } + + processorCount++ + + go func() { + parallelStatedb.StartPrefetcher("chain") + receipts, logs, usedGas, err := bc.parallelProcessor.Process(block, parallelStatedb, bc.vmConfig, ctx) + resultChan <- Result{receipts, logs, usedGas, err, parallelStatedb, blockExecutionParallelCounter} + }() + } + + if bc.processor != nil { + statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps) + if err != nil { + return nil, nil, 0, nil, err + } + + processorCount++ + + go func() { + statedb.StartPrefetcher("chain") + receipts, logs, usedGas, err := bc.processor.Process(block, statedb, bc.vmConfig, ctx) + resultChan <- Result{receipts, logs, usedGas, err, statedb, blockExecutionSerialCounter} + }() + } + + result := <-resultChan + + if _, ok := result.err.(blockstm.ParallelExecFailedError); ok { + log.Warn("Parallel state processor failed", "err", result.err) + + // If the parallel processor failed, we will fallback to the serial processor if enabled + if processorCount == 2 { + result.statedb.StopPrefetcher() + result = <-resultChan + processorCount-- + } + } + + result.counter.Inc(1) + + // Make sure we are not leaking any prefetchers + if processorCount == 2 { + go func() { + second_result := <-resultChan + second_result.statedb.StopPrefetcher() + }() + } + + return result.receipts, result.logs, result.usedGas, result.statedb, result.err +} + // empty returns an indicator whether the blockchain is empty. // Note, it's a special case that we connect a non-empty ancient // database with an empty node, so that we can plugin the ancient @@ -701,7 +830,7 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha rawdb.WriteHeadFastBlockHash(db, newHeadSnapBlock.Hash()) // Degrade the chain markers if they are explicitly reverted. - // In theory we should update all in-memory markers in the + // In theory, we should update all in-memory markers in the // last step, however the direction of SetHead is from high // to low, so it's safe the update in-memory markers directly. bc.currentSnapBlock.Store(newHeadSnapBlock.Header()) @@ -738,6 +867,8 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha // removed in the hc.SetHead function. rawdb.DeleteBody(db, hash, num) rawdb.DeleteReceipts(db, hash, num) + rawdb.DeleteBorReceipt(db, hash, num) + rawdb.DeleteBorTxLookupEntry(db, hash, num) } // Todo(rjl493456442) txlookup, bloombits, etc } @@ -765,6 +896,7 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha bc.blockCache.Purge() bc.txLookupCache.Purge() bc.futureBlocks.Purge() + bc.borReceiptsCache.Purge() // Clear safe block, finalized block if needed if safe := bc.CurrentSafeBlock(); safe != nil && head < safe.Number.Uint64() { @@ -910,14 +1042,14 @@ func (bc *BlockChain) writeHeadBlock(block *types.Block) { headBlockGauge.Update(int64(block.NumberU64())) } -// stop stops the blockchain service. If any imports are currently in progress +// stopWithoutSaving stops the blockchain service. If any imports are currently in progress // it will abort them using the procInterrupt. This method stops all running // goroutines, but does not do all the post-stop work of persisting data. // OBS! It is generally recommended to use the Stop method! // This method has been exposed to allow tests to stop the blockchain while simulating // a crash. func (bc *BlockChain) stopWithoutSaving() { - if !atomic.CompareAndSwapInt32(&bc.running, 0, 1) { + if !bc.stopping.CompareAndSwap(false, true) { return } @@ -960,7 +1092,7 @@ func (bc *BlockChain) Stop() { if !bc.cacheConfig.TrieDirtyDisabled { triedb := bc.triedb - for _, offset := range []uint64{0, 1, TriesInMemory - 1} { + for _, offset := range []uint64{0, 1, bc.cacheConfig.TriesInMemory - 1} { if number := bc.CurrentBlock().Number.Uint64(); number > offset { recent := bc.GetBlockByNumber(number - offset) @@ -990,7 +1122,7 @@ func (bc *BlockChain) Stop() { // Ensure all live cached entries be saved into disk, so that we can skip // cache warmup when node restarts. if bc.cacheConfig.TrieCleanJournal != "" { - bc.triedb.SaveCache(bc.cacheConfig.TrieCleanJournal) + _ = bc.triedb.SaveCache(bc.cacheConfig.TrieCleanJournal) } log.Info("Blockchain stopped") } @@ -999,12 +1131,12 @@ func (bc *BlockChain) Stop() { // errInsertionInterrupted as soon as possible. Insertion is permanently disabled after // calling this method. func (bc *BlockChain) StopInsert() { - atomic.StoreInt32(&bc.procInterrupt, 1) + bc.procInterrupt.Store(true) } // insertStopped returns true after StopInsert has been called. func (bc *BlockChain) insertStopped() bool { - return atomic.LoadInt32(&bc.procInterrupt) == 1 + return bc.procInterrupt.Load() } func (bc *BlockChain) procFutureBlocks() { @@ -1071,7 +1203,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ // updateHead updates the head fast sync block if the inserted blocks are better // and returns an indicator whether the inserted blocks are canonical. - updateHead := func(head *types.Block) bool { + updateHead := func(head *types.Block, headers []*types.Header) bool { if !bc.chainmu.TryLock() { return false } @@ -1086,6 +1218,15 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ } else if !reorg { return false } + + isValid, err := bc.forker.ValidateReorg(bc.CurrentSnapBlock(), headers) + if err != nil { + log.Warn("Reorg failed", "err", err) + return false + } else if !isValid { + return false + } + rawdb.WriteHeadFastBlockHash(bc.db, head.Hash()) bc.currentSnapBlock.Store(head.Header()) headFastBlockGauge.Update(int64(head.NumberU64())) @@ -1106,7 +1247,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ if frozen, _ := bc.db.Ancients(); frozen == 0 { b := bc.genesisBlock td := bc.genesisBlock.Difficulty() - writeSize, err := rawdb.WriteAncientBlocks(bc.db, []*types.Block{b}, []types.Receipts{nil}, td) + writeSize, err := rawdb.WriteAncientBlocks(bc.db, []*types.Block{b}, []types.Receipts{nil}, []types.Receipts{nil}, td) size += writeSize if err != nil { log.Error("Error writing genesis to ancients", "err", err) @@ -1122,9 +1263,20 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ return 0, fmt.Errorf("containing header #%d [%x..] unknown", last.Number(), last.Hash().Bytes()[:4]) } + // BOR: Retrieve all the bor receipts and also maintain the array of headers + // for bor specific reorg check. + borReceipts := []types.Receipts{} + + var headers []*types.Header + + for _, block := range blockChain { + borReceipts = append(borReceipts, []*types.Receipt{bc.GetBorReceiptByHash(block.Hash())}) + headers = append(headers, block.Header()) + } + // Write all chain data to ancients. td := bc.GetTd(first.Hash(), first.NumberU64()) - writeSize, err := rawdb.WriteAncientBlocks(bc.db, blockChain, receiptChain, td) + writeSize, err := rawdb.WriteAncientBlocks(bc.db, blockChain, receiptChain, borReceipts, td) size += writeSize if err != nil { log.Error("Error importing chain data to ancients", "err", err) @@ -1170,7 +1322,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ } // Update the current fast block because all block data is now present in DB. previousSnapBlock := bc.CurrentSnapBlock().Number.Uint64() - if !updateHead(blockChain[len(blockChain)-1]) { + if !updateHead(blockChain[len(blockChain)-1], headers) { // We end up here if the header chain has reorg'ed, and the blocks/receipts // don't match the canonical chain. if err := bc.db.TruncateHead(previousSnapBlock + 1); err != nil { @@ -1206,7 +1358,12 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ writeLive := func(blockChain types.Blocks, receiptChain []types.Receipts) (int, error) { skipPresenceCheck := false batch := bc.db.NewBatch() + + headers := make([]*types.Header, 0, len(blockChain)) for i, block := range blockChain { + // Update the headers for bor specific reorg check + headers = append(headers, block.Header()) + // Short circuit insertion if shutting down or processing failed if bc.insertStopped() { return 0, errInsertionInterrupted @@ -1253,7 +1410,9 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ return 0, err } } - updateHead(blockChain[len(blockChain)-1]) + + updateHead(blockChain[len(blockChain)-1], headers) + return 0, nil } @@ -1334,11 +1493,11 @@ func (bc *BlockChain) writeKnownBlock(block *types.Block) error { // writeBlockWithState writes block, metadata and corresponding state data to the // database. -func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, state *state.StateDB) error { +func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB) ([]*types.Log, error) { // Calculate the total difficulty of the block ptd := bc.GetTd(block.ParentHash(), block.NumberU64()-1) if ptd == nil { - return consensus.ErrUnknownAncestor + return []*types.Log{}, consensus.ErrUnknownAncestor } // Make sure no inconsistent state is leaked during insertion externTd := new(big.Int).Add(block.Difficulty(), ptd) @@ -1351,6 +1510,42 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. rawdb.WriteTd(blockBatch, block.Hash(), block.NumberU64(), externTd) rawdb.WriteBlock(blockBatch, block) rawdb.WriteReceipts(blockBatch, block.Hash(), block.NumberU64(), receipts) + + // System call appends state-sync logs into state. So, `state.Logs()` contains + // all logs including system-call logs (state sync logs) while `logs` contains + // only logs generated by transactions (receipts). + // + // That means that state.Logs() can have more logs than receipt logs. + // In that case, we can safely assume that extra logs are from state sync logs. + // + // block logs = receipt logs + state sync logs = `state.Logs()` + blockLogs := state.Logs() + + var stateSyncLogs []*types.Log + + if len(blockLogs) > 0 { + sort.SliceStable(blockLogs, func(i, j int) bool { + return blockLogs[i].Index < blockLogs[j].Index + }) + + if len(blockLogs) > len(logs) { + stateSyncLogs = blockLogs[len(logs):] // get state-sync logs from `state.Logs()` + + // State sync logs don't have tx index, tx hash and other necessary fields + // DeriveFieldsForBorLogs will fill those fields for websocket subscriptions + types.DeriveFieldsForBorLogs(stateSyncLogs, block.Hash(), block.NumberU64(), uint(len(receipts)), uint(len(logs))) + + // Write bor receipt + rawdb.WriteBorReceipt(blockBatch, block.Hash(), block.NumberU64(), &types.ReceiptForStorage{ + Status: types.ReceiptStatusSuccessful, // make receipt status successful + Logs: stateSyncLogs, + }) + + // Write bor tx reverse lookup + rawdb.WriteBorTxLookupEntry(blockBatch, block.Hash(), block.NumberU64()) + } + } + rawdb.WritePreimages(blockBatch, state.Preimages()) if err := blockBatch.Write(); err != nil { log.Crit("Failed to write block into disk", "err", err) @@ -1358,11 +1553,11 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. // Commit all cached state changes into underlying memory database. root, err := state.Commit(bc.chainConfig.IsEIP158(block.Number())) if err != nil { - return err + return []*types.Log{}, err } // If we're running an archive node, always flush if bc.cacheConfig.TrieDirtyDisabled { - return bc.triedb.Commit(root, false) + return []*types.Log{}, bc.triedb.Commit(root, false) } // Full but not archive node, do proper garbage collection bc.triedb.Reference(root, common.Hash{}) // metadata reference to keep trie alive @@ -1370,8 +1565,8 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. current := block.NumberU64() // Flush limits are not considered for the first TriesInMemory blocks. - if current <= TriesInMemory { - return nil + if current <= bc.cacheConfig.TriesInMemory { + return []*types.Log{}, nil } // If we exceeded our memory allowance, flush matured singleton nodes to disk var ( @@ -1379,11 +1574,11 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. limit = common.StorageSize(bc.cacheConfig.TrieDirtyLimit) * 1024 * 1024 ) if nodes > limit || imgs > 4*1024*1024 { - bc.triedb.Cap(limit - ethdb.IdealBatchSize) + _ = bc.triedb.Cap(limit - ethdb.IdealBatchSize) } // Find the next state trie we need to commit - chosen := current - TriesInMemory - flushInterval := time.Duration(atomic.LoadInt64(&bc.flushInterval)) + chosen := current - bc.cacheConfig.TriesInMemory + flushInterval := time.Duration(bc.flushInterval.Load()) // If we exceeded time allowance, flush an entire trie to disk if bc.gcproc > flushInterval { // If the header is missing (canonical chain behind), we're reorging a low @@ -1394,11 +1589,11 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. } else { // If we're exceeding limits but haven't reached a large enough memory gap, // warn the user that the system is becoming unstable. - if chosen < bc.lastWrite+TriesInMemory && bc.gcproc >= 2*flushInterval { - log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", flushInterval, "optimum", float64(chosen-bc.lastWrite)/TriesInMemory) + if chosen < bc.lastWrite+bc.cacheConfig.TriesInMemory && bc.gcproc >= 2*flushInterval { + log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", flushInterval, "optimum", float64(chosen-bc.lastWrite)/float64(bc.cacheConfig.TriesInMemory)) } // Flush an entire trie and restart the counters - bc.triedb.Commit(header.Root, true) + _ = bc.triedb.Commit(header.Root, true) bc.lastWrite = chosen bc.gcproc = 0 } @@ -1412,45 +1607,92 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. } bc.triedb.Dereference(root) } - return nil + + return stateSyncLogs, nil } // WriteBlockAndSetHead writes the given block and all associated state to the database, // and applies the block as the new chain head. -func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) { +func (bc *BlockChain) WriteBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) { if !bc.chainmu.TryLock() { return NonStatTy, errChainStopped } defer bc.chainmu.Unlock() - return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent) + return bc.writeBlockAndSetHead(ctx, block, receipts, logs, state, emitHeadEvent) } // writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead. // This function expects the chain mutex to be held. -func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) { - if err := bc.writeBlockWithState(block, receipts, state); err != nil { +func (bc *BlockChain) writeBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) { + writeBlockAndSetHeadCtx, span := tracing.StartSpan(ctx, "blockchain.writeBlockAndSetHead") + defer tracing.EndSpan(span) + + var stateSyncLogs []*types.Log + + tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.writeBlockWithState", func(_ context.Context, span trace.Span) { + stateSyncLogs, err = bc.writeBlockWithState(block, receipts, logs, state) + tracing.SetAttributes( + span, + attribute.Int("number", int(block.Number().Uint64())), + attribute.Bool("error", err != nil), + ) + }) + + if err != nil { return NonStatTy, err } currentBlock := bc.CurrentBlock() - reorg, err := bc.forker.ReorgNeeded(currentBlock, block.Header()) + + var reorg bool + + tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.ReorgNeeded", func(_ context.Context, span trace.Span) { + reorg, err = bc.forker.ReorgNeeded(currentBlock, block.Header()) + tracing.SetAttributes( + span, + attribute.Int("number", int(block.Number().Uint64())), + attribute.Int("current block", int(currentBlock.Number.Uint64())), + attribute.Bool("reorg needed", reorg), + attribute.Bool("error", err != nil), + ) + }) + if err != nil { return NonStatTy, err } - if reorg { - // Reorganise the chain if the parent is not the head block - if block.ParentHash() != currentBlock.Hash() { - if err := bc.reorg(currentBlock, block); err != nil { - return NonStatTy, err + + tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.reorg", func(_ context.Context, span trace.Span) { + if reorg { + // Reorganise the chain if the parent is not the head block + if block.ParentHash() != currentBlock.Hash() { + if err = bc.reorg(currentBlock, block); err != nil { + status = NonStatTy + } } + + status = CanonStatTy + } else { + status = SideStatTy } - status = CanonStatTy - } else { - status = SideStatTy + + tracing.SetAttributes( + span, + attribute.Int("number", int(block.Number().Uint64())), + attribute.Int("current block", int(currentBlock.Number.Uint64())), + attribute.Bool("reorg needed", reorg), + attribute.Bool("error", err != nil), + attribute.String("status", string(status)), + ) + }) + + if status == NonStatTy { + return } // Set new head. if status == CanonStatTy { - bc.writeHeadBlock(block) + tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.writeHeadBlock", func(_ context.Context, _ trace.Span) { + bc.writeHeadBlock(block) + }) } bc.futureBlocks.Remove(block.Hash()) @@ -1459,6 +1701,12 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types if len(logs) > 0 { bc.logsFeed.Send(logs) } + + // send state sync logs into logs feed + if len(stateSyncLogs) > 0 { + bc.logsFeed.Send(stateSyncLogs) + } + // In theory, we should fire a ChainHeadEvent when we inject // a canonical block, but sometimes we can insert a batch of // canonical blocks. Avoid firing too many ChainHeadEvents, @@ -1466,9 +1714,19 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types // event here. if emitHeadEvent { bc.chainHeadFeed.Send(ChainHeadEvent{Block: block}) + // BOR state sync feed related changes + for _, data := range bc.stateSyncData { + bc.stateSyncFeed.Send(StateSyncEvent{Data: data}) + } + // BOR } } else { bc.chainSideFeed.Send(ChainSideEvent{Block: block}) + + bc.chain2HeadFeed.Send(Chain2HeadEvent{ + Type: Chain2HeadForkEvent, + NewChain: []*types.Block{block}, + }) } return status, nil } @@ -1569,6 +1827,23 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) it := newInsertIterator(chain, results, bc.validator) block, err := it.next() + // Update the block import meter; it will just record chains we've received + // from other peers. (Note that the actual chain which gets imported would be + // quite low). + blockImportTimer.Mark(int64(len(headers))) + + // Check the validity of incoming chain + isValid, err1 := bc.forker.ValidateReorg(bc.CurrentBlock(), headers) + if err1 != nil { + return it.index, err1 + } + + if !isValid { + // The chain to be imported is invalid as the blocks doesn't match with + // the whitelisted block number. + return it.index, whitelist.ErrMismatch + } + // Left-trim all the known blocks that don't need to build snapshot if bc.skipBlock(err, it) { // First block (and state) is known @@ -1668,6 +1943,24 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) } }() + // accumulator for canonical blocks + var canonAccum []*types.Block + + emitAccum := func() { + size := len(canonAccum) + if size == 0 || size > 5 { + // avoid reporting events for large sync events + return + } + + bc.chain2HeadFeed.Send(Chain2HeadEvent{ + Type: Chain2HeadCanonicalEvent, + NewChain: canonAccum, + }) + + canonAccum = canonAccum[:0] + } + for ; block != nil && err == nil || errors.Is(err, ErrKnownBlock); block, err = it.next() { // If the chain is terminating, stop processing blocks if bc.insertStopped() { @@ -1736,7 +2029,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) // If we have a followup block, run that against the current state to pre-cache // transactions and probabilistically some of the account/storage trie nodes. - var followupInterrupt uint32 + var followupInterrupt atomic.Bool + if !bc.cacheConfig.TrieCleanNoPrefetch { if followup, err := it.peek(); followup != nil && err == nil { throwaway, _ := state.New(parent.Root, bc.stateCache, bc.snaps) @@ -1745,7 +2039,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, &followupInterrupt) blockPrefetchExecuteTimer.Update(time.Since(start)) - if atomic.LoadUint32(&followupInterrupt) == 1 { + + if followupInterrupt.Load() { blockPrefetchInterruptMeter.Mark(1) } }(time.Now(), followup, throwaway) @@ -1754,18 +2049,28 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) // Process block using the parent state as reference point pstart := time.Now() - receipts, logs, usedGas, err := bc.processor.Process(block, statedb, bc.vmConfig) + receipts, logs, usedGas, statedb, err := bc.ProcessBlock(block, parent) + activeState = statedb + if err != nil { bc.reportBlock(block, receipts, err) - atomic.StoreUint32(&followupInterrupt, 1) + followupInterrupt.Store(true) + return it.index, err } + + // BOR state sync feed related changes + for _, data := range bc.stateSyncData { + bc.stateSyncFeed.Send(StateSyncEvent{Data: data}) + } + // BOR ptime := time.Since(pstart) vstart := time.Now() if err := bc.validator.ValidateState(block, statedb, receipts, usedGas); err != nil { bc.reportBlock(block, receipts, err) - atomic.StoreUint32(&followupInterrupt, 1) + followupInterrupt.Store(true) + return it.index, err } vtime := time.Since(vstart) @@ -1794,11 +2099,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) ) if !setHead { // Don't set the head, only insert the block - err = bc.writeBlockWithState(block, receipts, statedb) + _, err = bc.writeBlockWithState(block, receipts, logs, statedb) } else { - status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false) + status, err = bc.writeBlockAndSetHead(context.Background(), block, receipts, logs, statedb, false) } - atomic.StoreUint32(&followupInterrupt, 1) + + followupInterrupt.Store(true) + if err != nil { return it.index, err } @@ -1825,6 +2132,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) return it.index, nil // Direct block insertion of a single block } + + // BOR + if status == CanonStatTy { + canonAccum = append(canonAccum, block) + } else { + emitAccum() + } + // BOR + switch status { case CanonStatTy: log.Debug("Inserted new block", "number", block.Number(), "hash", block.Hash(), @@ -1853,6 +2169,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) } } + // BOR + emitAccum() + // BOR + // Any blocks remaining here? The only ones we care about are the future ones if block != nil && errors.Is(err, consensus.ErrFutureBlock) { if err := bc.addFutureBlock(block); err != nil { @@ -1884,6 +2204,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i externTd *big.Int lastBlock = block current = bc.CurrentBlock() + headers []*types.Header ) // The first sidechain block error is already verified to be ErrPrunedAncestor. // Since we don't import them here, we expect ErrUnknownAncestor for the remaining @@ -1891,6 +2212,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i // to disk. err := consensus.ErrPrunedAncestor for ; block != nil && errors.Is(err, consensus.ErrPrunedAncestor); block, err = it.next() { + headers = append(headers, block.Header()) // Check the canonical state root for that number if number := block.NumberU64(); current.Number.Uint64() >= number { canonical := bc.GetBlockByNumber(number) @@ -1946,7 +2268,13 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i if err != nil { return it.index, err } - if !reorg { + + isValid, err := bc.forker.ValidateReorg(current, headers) + if err != nil { + return it.index, err + } + + if !reorg || !isValid { localTd := bc.GetTd(current.Hash(), current.Number.Uint64()) log.Info("Sidechain written to disk", "start", it.first().NumberU64(), "end", it.previous().Number, "sidetd", externTd, "localtd", localTd) return it.index, err @@ -2051,7 +2379,14 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error) // the processing of a block. These logs are later announced as deleted or reborn. func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log { receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64()) - receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.BaseFee(), b.Transactions()) + + // Append bor receipt + borReceipt := rawdb.ReadBorReceipt(bc.db, b.Hash(), b.NumberU64(), bc.chainConfig) + if borReceipt != nil { + receipts = append(receipts, borReceipt) + } + + _ = receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.BaseFee(), b.Transactions()) var logs []*types.Log for _, receipt := range receipts { @@ -2071,6 +2406,7 @@ func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log { // potential missing transactions and post an event about them. // Note the new head block won't be processed here, callers need to handle it // externally. +// nolint:gocognit func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { var ( newChain types.Blocks @@ -2135,6 +2471,12 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { // Ensure the user sees large reorgs if len(oldChain) > 0 && len(newChain) > 0 { + bc.chain2HeadFeed.Send(Chain2HeadEvent{ + Type: Chain2HeadReorgEvent, + NewChain: newChain, + OldChain: oldChain, + }) + logFn := log.Info msg := "Chain reorg detected" if len(oldChain) > 63 { @@ -2154,6 +2496,35 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { } else { // len(newChain) == 0 && len(oldChain) > 0 // rewind the canonical chain to a lower point. + home, err := os.UserHomeDir() + if err != nil { + fmt.Println("Impossible reorg : Unable to get user home dir", "Error", err) + } + + outPath := filepath.Join(home, "impossible-reorgs", fmt.Sprintf("%v-impossibleReorg", time.Now().Format(time.RFC3339))) + + if _, err := os.Stat(outPath); errors.Is(err, os.ErrNotExist) { + err := os.MkdirAll(outPath, os.ModePerm) + if err != nil { + log.Error("Impossible reorg : Unable to create Dir", "Error", err) + } + } else { + err = ExportBlocks(oldChain, filepath.Join(outPath, "oldChain.gz")) + if err != nil { + log.Error("Impossible reorg : Unable to export oldChain", "Error", err) + } + + err = ExportBlocks([]*types.Block{oldBlock}, filepath.Join(outPath, "oldBlock.gz")) + if err != nil { + log.Error("Impossible reorg : Unable to export oldBlock", "Error", err) + } + + err = ExportBlocks([]*types.Block{newBlock}, filepath.Join(outPath, "newBlock.gz")) + if err != nil { + log.Error("Impossible reorg : Unable to export newBlock", "Error", err) + } + } + log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "oldblocks", len(oldChain), "newnum", newBlock.Number(), "newhash", newBlock.Hash(), "newblocks", len(newChain)) } // Insert the new chain(except the head block(reverse order)), @@ -2230,6 +2601,45 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { if len(rebirthLogs) > 0 { bc.logsFeed.Send(rebirthLogs) } + + return nil +} + +// ExportBlocks exports blocks into the specified file, truncating any data +// already present in the file. +func ExportBlocks(blocks []*types.Block, fn string) error { + log.Info("Exporting blockchain", "file", fn) + + // Open the file handle and potentially wrap with a gzip stream + fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) + if err != nil { + return err + } + defer fh.Close() + + var writer io.Writer = fh + if strings.HasSuffix(fn, ".gz") { + writer = gzip.NewWriter(writer) + defer writer.(*gzip.Writer).Close() + } + // Iterate over the blocks and export them + if err := ExportN(writer, blocks); err != nil { + return err + } + + log.Info("Exported blocks", "file", fn) + + return nil +} + +// ExportBlock writes a block to the given writer. +func ExportN(w io.Writer, blocks []*types.Block) error { + for _, block := range blocks { + if err := block.EncodeRLP(w); err != nil { + return err + } + } + return nil } @@ -2486,6 +2896,10 @@ func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (i return 0, err } +func (bc *BlockChain) GetChainConfig() *params.ChainConfig { + return bc.chainConfig +} + // SetBlockValidatorAndProcessorForTesting sets the current validator and processor. // This method can be used to force an invalid blockchain to be verified for tests. // This method is unsafe and should only be used before block import starts. @@ -2498,132 +2912,136 @@ func (bc *BlockChain) SetBlockValidatorAndProcessorForTesting(v Validator, p Pro // It returns nil if the payload is valid, otherwise it returns an error. // - `useBalanceDiffProfit` if set to false, proposer payment is assumed to be in the last transaction of the block // otherwise we use proposer balance changes after the block to calculate proposer payment (see details in the code) -func (bc *BlockChain) ValidatePayload(block *types.Block, feeRecipient common.Address, expectedProfit *big.Int, registeredGasLimit uint64, vmConfig vm.Config, useBalanceDiffProfit bool) error { - header := block.Header() - if err := bc.engine.VerifyHeader(bc, header, true); err != nil { - return err - } - - current := bc.CurrentBlock() - reorg, err := bc.forker.ReorgNeeded(current, header) - if err == nil && reorg { - return errors.New("block requires a reorg") - } - - parent := bc.GetHeader(block.ParentHash(), block.NumberU64()-1) - if parent == nil { - return errors.New("parent not found") - } - - calculatedGasLimit := utils.CalcGasLimit(parent.GasLimit, registeredGasLimit) - if calculatedGasLimit != header.GasLimit { - return errors.New("incorrect gas limit set") - } - - statedb, err := bc.StateAt(parent.Root) - if err != nil { - return err - } - - // The chain importer is starting and stopping trie prefetchers. If a bad - // block or other error is hit however, an early return may not properly - // terminate the background threads. This defer ensures that we clean up - // and dangling prefetcher, without defering each and holding on live refs. - defer statedb.StopPrefetcher() - - feeRecipientBalanceBefore := new(big.Int).Set(statedb.GetBalance(feeRecipient)) - - receipts, _, usedGas, err := bc.processor.Process(block, statedb, vmConfig) - if err != nil { - return err - } - - feeRecipientBalanceDelta := new(big.Int).Set(statedb.GetBalance(feeRecipient)) - feeRecipientBalanceDelta.Sub(feeRecipientBalanceDelta, feeRecipientBalanceBefore) - - if bc.Config().IsShanghai(header.Time) { - if header.WithdrawalsHash == nil { - return fmt.Errorf("withdrawals hash is missing") - } - // withdrawals hash and withdrawals validated later in ValidateBody - } else { - if header.WithdrawalsHash != nil { - return fmt.Errorf("withdrawals hash present before shanghai") - } - if block.Withdrawals() != nil { - return fmt.Errorf("withdrawals list present in block body before shanghai") - } - } - - if err := bc.validator.ValidateBody(block); err != nil { - return err - } - - if err := bc.validator.ValidateState(block, statedb, receipts, usedGas); err != nil { - return err - } - - // Validate proposer payment - - if useBalanceDiffProfit { - if feeRecipientBalanceDelta.Cmp(expectedProfit) >= 0 { - if feeRecipientBalanceDelta.Cmp(expectedProfit) > 0 { - log.Warn("builder claimed profit is lower than calculated profit", "expected", expectedProfit, "actual", feeRecipientBalanceDelta) - } - return nil - } - log.Warn("proposer payment not enough, trying last tx payment validation", "expected", expectedProfit, "actual", feeRecipientBalanceDelta) - } - - if len(receipts) == 0 { - return errors.New("no proposer payment receipt") - } - - lastReceipt := receipts[len(receipts)-1] - if lastReceipt.Status != types.ReceiptStatusSuccessful { - return errors.New("proposer payment not successful") - } - txIndex := lastReceipt.TransactionIndex - if txIndex+1 != uint(len(block.Transactions())) { - return fmt.Errorf("proposer payment index not last transaction in the block (%d of %d)", txIndex, len(block.Transactions())-1) - } - - paymentTx := block.Transaction(lastReceipt.TxHash) - if paymentTx == nil { - return errors.New("payment tx not in the block") - } - - paymentTo := paymentTx.To() - if paymentTo == nil || *paymentTo != feeRecipient { - return fmt.Errorf("payment tx not to the proposers fee recipient (%v)", paymentTo) - } - - if paymentTx.Value().Cmp(expectedProfit) != 0 { - return fmt.Errorf("inaccurate payment %s, expected %s", paymentTx.Value().String(), expectedProfit.String()) - } - - if len(paymentTx.Data()) != 0 { - return fmt.Errorf("malformed proposer payment, contains calldata") - } - - if paymentTx.GasPrice().Cmp(block.BaseFee()) != 0 { - return fmt.Errorf("malformed proposer payment, gas price not equal to base fee") - } - - if paymentTx.GasTipCap().Cmp(block.BaseFee()) != 0 && paymentTx.GasTipCap().Sign() != 0 { - return fmt.Errorf("malformed proposer payment, unexpected gas tip cap") - } - - if paymentTx.GasFeeCap().Cmp(block.BaseFee()) != 0 { - return fmt.Errorf("malformed proposer payment, unexpected gas fee cap") - } - - return nil -} +//func (bc *BlockChain) ValidatePayload(block *types.Block, feeRecipient common.Address, expectedProfit *big.Int, registeredGasLimit uint64, vmConfig vm.Config, useBalanceDiffProfit bool) error { +// header := block.Header() +// if err := bc.engine.VerifyHeader(bc, header, true); err != nil { +// return err +// } +// +// current := bc.CurrentBlock() +// reorg, err := bc.forker.ReorgNeeded(current, header) +// if err == nil && reorg { +// return errors.New("block requires a reorg") +// } +// +// parent := bc.GetHeader(block.ParentHash(), block.NumberU64()-1) +// if parent == nil { +// return errors.New("parent not found") +// } +// +// calculatedGasLimit := utils.CalcGasLimit(parent.GasLimit, registeredGasLimit) +// if calculatedGasLimit != header.GasLimit { +// return errors.New("incorrect gas limit set") +// } +// +// statedb, err := bc.StateAt(parent.Root) +// if err != nil { +// return err +// } +// +// // The chain importer is starting and stopping trie prefetchers. If a bad +// // block or other error is hit however, an early return may not properly +// // terminate the background threads. This defer ensures that we clean up +// // and dangling prefetcher, without defering each and holding on live refs. +// defer statedb.StopPrefetcher() +// +// feeRecipientBalanceBefore := new(big.Int).Set(statedb.GetBalance(feeRecipient)) +// +// receipts, _, usedGas, err := bc.processor.Process(block, statedb, vmConfig) +// if err != nil { +// return err +// } +// +// feeRecipientBalanceDelta := new(big.Int).Set(statedb.GetBalance(feeRecipient)) +// feeRecipientBalanceDelta.Sub(feeRecipientBalanceDelta, feeRecipientBalanceBefore) +// +// if bc.Config().IsShanghai(header.Time) { +// if header.WithdrawalsHash == nil { +// return fmt.Errorf("withdrawals hash is missing") +// } +// // withdrawals hash and withdrawals validated later in ValidateBody +// } else { +// if header.WithdrawalsHash != nil { +// return fmt.Errorf("withdrawals hash present before shanghai") +// } +// if block.Withdrawals() != nil { +// return fmt.Errorf("withdrawals list present in block body before shanghai") +// } +// } +// +// if err := bc.validator.ValidateBody(block); err != nil { +// return err +// } +// +// if err := bc.validator.ValidateState(block, statedb, receipts, usedGas); err != nil { +// return err +// } +// +// // Validate proposer payment +// +// if useBalanceDiffProfit { +// if feeRecipientBalanceDelta.Cmp(expectedProfit) >= 0 { +// if feeRecipientBalanceDelta.Cmp(expectedProfit) > 0 { +// log.Warn("builder claimed profit is lower than calculated profit", "expected", expectedProfit, "actual", feeRecipientBalanceDelta) +// } +// return nil +// } +// log.Warn("proposer payment not enough, trying last tx payment validation", "expected", expectedProfit, "actual", feeRecipientBalanceDelta) +// } +// +// if len(receipts) == 0 { +// return errors.New("no proposer payment receipt") +// } +// +// lastReceipt := receipts[len(receipts)-1] +// if lastReceipt.Status != types.ReceiptStatusSuccessful { +// return errors.New("proposer payment not successful") +// } +// txIndex := lastReceipt.TransactionIndex +// if txIndex+1 != uint(len(block.Transactions())) { +// return fmt.Errorf("proposer payment index not last transaction in the block (%d of %d)", txIndex, len(block.Transactions())-1) +// } +// +// paymentTx := block.Transaction(lastReceipt.TxHash) +// if paymentTx == nil { +// return errors.New("payment tx not in the block") +// } +// +// paymentTo := paymentTx.To() +// if paymentTo == nil || *paymentTo != feeRecipient { +// return fmt.Errorf("payment tx not to the proposers fee recipient (%v)", paymentTo) +// } +// +// if paymentTx.Value().Cmp(expectedProfit) != 0 { +// return fmt.Errorf("inaccurate payment %s, expected %s", paymentTx.Value().String(), expectedProfit.String()) +// } +// +// if len(paymentTx.Data()) != 0 { +// return fmt.Errorf("malformed proposer payment, contains calldata") +// } +// +// if paymentTx.GasPrice().Cmp(block.BaseFee()) != 0 { +// return fmt.Errorf("malformed proposer payment, gas price not equal to base fee") +// } +// +// if paymentTx.GasTipCap().Cmp(block.BaseFee()) != 0 && paymentTx.GasTipCap().Sign() != 0 { +// return fmt.Errorf("malformed proposer payment, unexpected gas tip cap") +// } +// +// if paymentTx.GasFeeCap().Cmp(block.BaseFee()) != 0 { +// return fmt.Errorf("malformed proposer payment, unexpected gas fee cap") +// } +// +// return nil +//} // SetTrieFlushInterval configures how often in-memory tries are persisted to disk. // The interval is in terms of block processing time, not wall clock. // It is thread-safe and can be called repeatedly without side effects. func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) { - atomic.StoreInt64(&bc.flushInterval, int64(interval)) + bc.flushInterval.Store(int64(interval)) +} + +func (bc *BlockChain) SubscribeChain2HeadEvent(ch chan<- Chain2HeadEvent) event.Subscription { + return bc.scope.Track(bc.chain2HeadFeed.Subscribe(ch)) } diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 21a9c6676b..6366ad49e9 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" @@ -62,6 +63,17 @@ func (bc *BlockChain) CurrentSafeBlock() *types.Header { return bc.currentSafeBlock.Load() } +// CurrentFinalizedBlock retrieves the current finalized block of the canonical +// chain. The block is retrieved from the blockchain's internal cache. +func (bc *BlockChain) CurrentFinalizedBlock(number uint64) *types.Block { + hash := rawdb.ReadCanonicalHash(bc.db, number) + if hash == (common.Hash{}) { + return nil + } + + return bc.GetBlock(hash, number) +} + // HasHeader checks if a block header is present in the database or not, caching // it if present. func (bc *BlockChain) HasHeader(hash common.Hash, number uint64) bool { @@ -411,3 +423,36 @@ func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscript func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription { return bc.scope.Track(bc.blockProcFeed.Subscribe(ch)) } + +// Snaps retrieves the snapshot tree. +func (bc *BlockChain) Snaps() *snapshot.Tree { + return bc.snaps +} + +// DB retrieves the blockchain database. +func (bc *BlockChain) DB() ethdb.Database { + return bc.db +} + +// +// Bor related changes +// + +type BorStateSyncer interface { + SetStateSync(stateData []*types.StateSyncData) + SubscribeStateSyncEvent(ch chan<- StateSyncEvent) event.Subscription +} + +// SetStateSync set sync data in state_data +func (bc *BlockChain) SetStateSync(stateData []*types.StateSyncData) { + bc.stateSyncData = stateData +} + +func (bc *BlockChain) GetStateSync() []*types.StateSyncData { + return bc.stateSyncData +} + +// SubscribeStateSyncEvent registers a subscription of StateSyncEvent. +func (bc *BlockChain) SubscribeStateSyncEvent(ch chan<- StateSyncEvent) event.Subscription { + return bc.scope.Track(bc.stateSyncFeed.Subscribe(ch)) +} diff --git a/core/blockstm/dag.go b/core/blockstm/dag.go new file mode 100644 index 0000000000..47bd0685a3 --- /dev/null +++ b/core/blockstm/dag.go @@ -0,0 +1,201 @@ +package blockstm + +import ( + "fmt" + "strings" + "time" + + "github.com/heimdalr/dag" + + "github.com/ethereum/go-ethereum/log" +) + +type DAG struct { + *dag.DAG +} + +type TxDep struct { + Index int + ReadList []ReadDescriptor + FullWriteList [][]WriteDescriptor +} + +func HasReadDep(txFrom TxnOutput, txTo TxnInput) bool { + reads := make(map[Key]bool) + + for _, v := range txTo { + reads[v.Path] = true + } + + for _, rd := range txFrom { + if _, ok := reads[rd.Path]; ok { + return true + } + } + + return false +} + +func BuildDAG(deps TxnInputOutput) (d DAG) { + d = DAG{dag.NewDAG()} + ids := make(map[int]string) + + for i := len(deps.inputs) - 1; i > 0; i-- { + txTo := deps.inputs[i] + + var txToId string + + if _, ok := ids[i]; ok { + txToId = ids[i] + } else { + txToId, _ = d.AddVertex(i) + ids[i] = txToId + } + + for j := i - 1; j >= 0; j-- { + txFrom := deps.allOutputs[j] + + if HasReadDep(txFrom, txTo) { + var txFromId string + if _, ok := ids[j]; ok { + txFromId = ids[j] + } else { + txFromId, _ = d.AddVertex(j) + ids[j] = txFromId + } + + err := d.AddEdge(txFromId, txToId) + if err != nil { + log.Warn("Failed to add edge", "from", txFromId, "to", txToId, "err", err) + } + } + } + } + + return +} + +func depsHelper(dependencies map[int]map[int]bool, txFrom TxnOutput, txTo TxnInput, i int, j int) map[int]map[int]bool { + if HasReadDep(txFrom, txTo) { + dependencies[i][j] = true + + for k := range dependencies[i] { + _, foundDep := dependencies[j][k] + + if foundDep { + delete(dependencies[i], k) + } + } + } + + return dependencies +} + +func UpdateDeps(deps map[int]map[int]bool, t TxDep) map[int]map[int]bool { + txTo := t.ReadList + + deps[t.Index] = map[int]bool{} + + for j := 0; j <= t.Index-1; j++ { + txFrom := t.FullWriteList[j] + + deps = depsHelper(deps, txFrom, txTo, t.Index, j) + } + + return deps +} + +func GetDep(deps TxnInputOutput) map[int]map[int]bool { + newDependencies := map[int]map[int]bool{} + + for i := 1; i < len(deps.inputs); i++ { + txTo := deps.inputs[i] + + newDependencies[i] = map[int]bool{} + + for j := 0; j <= i-1; j++ { + txFrom := deps.allOutputs[j] + + newDependencies = depsHelper(newDependencies, txFrom, txTo, i, j) + } + } + + return newDependencies +} + +// Find the longest execution path in the DAG +func (d DAG) LongestPath(stats map[int]ExecutionStat) ([]int, uint64) { + prev := make(map[int]int, len(d.GetVertices())) + + for i := 0; i < len(d.GetVertices()); i++ { + prev[i] = -1 + } + + pathWeights := make(map[int]uint64, len(d.GetVertices())) + + maxPath := 0 + maxPathWeight := uint64(0) + + idxToId := make(map[int]string, len(d.GetVertices())) + + for k, i := range d.GetVertices() { + idxToId[i.(int)] = k + } + + for i := 0; i < len(idxToId); i++ { + parents, _ := d.GetParents(idxToId[i]) + + if len(parents) > 0 { + for _, p := range parents { + weight := pathWeights[p.(int)] + stats[i].End - stats[i].Start + if weight > pathWeights[i] { + pathWeights[i] = weight + prev[i] = p.(int) + } + } + } else { + pathWeights[i] = stats[i].End - stats[i].Start + } + + if pathWeights[i] > maxPathWeight { + maxPath = i + maxPathWeight = pathWeights[i] + } + } + + path := make([]int, 0) + for i := maxPath; i != -1; i = prev[i] { + path = append(path, i) + } + + // Reverse the path so the transactions are in the ascending order + for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 { + path[i], path[j] = path[j], path[i] + } + + return path, maxPathWeight +} + +func (d DAG) Report(stats map[int]ExecutionStat, out func(string)) { + longestPath, weight := d.LongestPath(stats) + + serialWeight := uint64(0) + + for i := 0; i < len(d.GetVertices()); i++ { + serialWeight += stats[i].End - stats[i].Start + } + + makeStrs := func(ints []int) (ret []string) { + for _, v := range ints { + ret = append(ret, fmt.Sprint(v)) + } + + return + } + + out("Longest execution path:") + out(fmt.Sprintf("(%v) %v", len(longestPath), strings.Join(makeStrs(longestPath), "->"))) + + out(fmt.Sprintf("Longest path ideal execution time: %v of %v (serial total), %v%%", time.Duration(weight), + time.Duration(serialWeight), fmt.Sprintf("%.1f", float64(weight)*100.0/float64(serialWeight)))) +} diff --git a/core/blockstm/executor.go b/core/blockstm/executor.go new file mode 100644 index 0000000000..d142728c19 --- /dev/null +++ b/core/blockstm/executor.go @@ -0,0 +1,645 @@ +package blockstm + +import ( + "container/heap" + "context" + "fmt" + "sync" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" +) + +type ExecResult struct { + err error + ver Version + txIn TxnInput + txOut TxnOutput + txAllOut TxnOutput +} + +type ExecTask interface { + Execute(mvh *MVHashMap, incarnation int) error + MVReadList() []ReadDescriptor + MVWriteList() []WriteDescriptor + MVFullWriteList() []WriteDescriptor + Hash() common.Hash + Sender() common.Address + Settle() + Dependencies() []int +} + +type ExecVersionView struct { + ver Version + et ExecTask + mvh *MVHashMap + sender common.Address +} + +func (ev *ExecVersionView) Execute() (er ExecResult) { + er.ver = ev.ver + if er.err = ev.et.Execute(ev.mvh, ev.ver.Incarnation); er.err != nil { + return + } + + er.txIn = ev.et.MVReadList() + er.txOut = ev.et.MVWriteList() + er.txAllOut = ev.et.MVFullWriteList() + + return +} + +type ErrExecAbortError struct { + Dependency int + OriginError error +} + +func (e ErrExecAbortError) Error() string { + if e.Dependency >= 0 { + return fmt.Sprintf("Execution aborted due to dependency %d", e.Dependency) + } else { + return "Execution aborted" + } +} + +type ParallelExecFailedError struct { + Msg string +} + +func (e ParallelExecFailedError) Error() string { + return e.Msg +} + +type IntHeap []int + +func (h IntHeap) Len() int { return len(h) } +func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] } +func (h IntHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } + +func (h *IntHeap) Push(x any) { + // Push and Pop use pointer receivers because they modify the slice's length, + // not just its contents. + *h = append(*h, x.(int)) +} + +func (h *IntHeap) Pop() any { + old := *h + n := len(old) + x := old[n-1] + *h = old[0 : n-1] + + return x +} + +type SafeQueue interface { + Push(v int, d interface{}) + Pop() interface{} + Len() int +} + +type SafeFIFOQueue struct { + c chan interface{} +} + +func NewSafeFIFOQueue(capacity int) *SafeFIFOQueue { + return &SafeFIFOQueue{ + c: make(chan interface{}, capacity), + } +} + +func (q *SafeFIFOQueue) Push(v int, d interface{}) { + q.c <- d +} + +func (q *SafeFIFOQueue) Pop() interface{} { + return <-q.c +} + +func (q *SafeFIFOQueue) Len() int { + return len(q.c) +} + +// A thread safe priority queue +type SafePriorityQueue struct { + m sync.Mutex + queue *IntHeap + data map[int]interface{} +} + +func NewSafePriorityQueue(capacity int) *SafePriorityQueue { + q := make(IntHeap, 0, capacity) + + return &SafePriorityQueue{ + m: sync.Mutex{}, + queue: &q, + data: make(map[int]interface{}, capacity), + } +} + +func (pq *SafePriorityQueue) Push(v int, d interface{}) { + pq.m.Lock() + + heap.Push(pq.queue, v) + pq.data[v] = d + + pq.m.Unlock() +} + +func (pq *SafePriorityQueue) Pop() interface{} { + pq.m.Lock() + defer pq.m.Unlock() + + v := heap.Pop(pq.queue).(int) + + return pq.data[v] +} + +func (pq *SafePriorityQueue) Len() int { + return pq.queue.Len() +} + +type ParallelExecutionResult struct { + TxIO *TxnInputOutput + Stats *map[int]ExecutionStat + Deps *DAG + AllDeps map[int]map[int]bool +} + +const numGoProcs = 1 + +type ParallelExecutor struct { + tasks []ExecTask + + // Stores the execution statistics for the last incarnation of each task + stats map[int]ExecutionStat + + // Number of workers that execute transactions speculatively + numSpeculativeProcs int + + statsMutex sync.Mutex + + // Channel for tasks that should be prioritized + chTasks chan ExecVersionView + + // Channel for speculative tasks + chSpeculativeTasks chan struct{} + + // Channel to signal that the result of a transaction could be written to storage + specTaskQueue SafeQueue + + // A priority queue that stores speculative tasks + chSettle chan int + + // Channel to signal that a transaction has finished executing + chResults chan struct{} + + // A priority queue that stores the transaction index of results, so we can validate the results in order + resultQueue SafeQueue + + // A wait group to wait for all settling tasks to finish + settleWg sync.WaitGroup + + // An integer that tracks the index of last settled transaction + lastSettled int + + // For a task that runs only after all of its preceding tasks have finished and passed validation, + // its result will be absolutely valid and therefore its validation could be skipped. + // This map stores the boolean value indicating whether a task satisfy this condition ( absolutely valid). + skipCheck map[int]bool + + // Execution tasks stores the state of each execution task + execTasks taskStatusManager + + // Validate tasks stores the state of each validation task + validateTasks taskStatusManager + + // Stats for debugging purposes + cntExec, cntSuccess, cntAbort, cntTotalValidations, cntValidationFail int + + diagExecSuccess, diagExecAbort []int + + // Multi-version hash map + mvh *MVHashMap + + // Stores the inputs and outputs of the last incardanotion of all transactions + lastTxIO *TxnInputOutput + + // Tracks the incarnation number of each transaction + txIncarnations []int + + // A map that stores the estimated dependency of a transaction if it is aborted without any known dependency + estimateDeps map[int][]int + + // A map that records whether a transaction result has been speculatively validated + preValidated map[int]bool + + // Time records when the parallel execution starts + begin time.Time + + // Enable profiling + profile bool + + // Worker wait group + workerWg sync.WaitGroup +} + +type ExecutionStat struct { + TxIdx int + Incarnation int + Start uint64 + End uint64 + Worker int +} + +func NewParallelExecutor(tasks []ExecTask, profile bool, metadata bool, numProcs int) *ParallelExecutor { + numTasks := len(tasks) + + var resultQueue SafeQueue + + var specTaskQueue SafeQueue + + if metadata { + resultQueue = NewSafeFIFOQueue(numTasks) + specTaskQueue = NewSafeFIFOQueue(numTasks) + } else { + resultQueue = NewSafePriorityQueue(numTasks) + specTaskQueue = NewSafePriorityQueue(numTasks) + } + + pe := &ParallelExecutor{ + tasks: tasks, + numSpeculativeProcs: numProcs, + stats: make(map[int]ExecutionStat, numTasks), + chTasks: make(chan ExecVersionView, numTasks), + chSpeculativeTasks: make(chan struct{}, numTasks), + chSettle: make(chan int, numTasks), + chResults: make(chan struct{}, numTasks), + specTaskQueue: specTaskQueue, + resultQueue: resultQueue, + lastSettled: -1, + skipCheck: make(map[int]bool), + execTasks: makeStatusManager(numTasks), + validateTasks: makeStatusManager(0), + diagExecSuccess: make([]int, numTasks), + diagExecAbort: make([]int, numTasks), + mvh: MakeMVHashMap(), + lastTxIO: MakeTxnInputOutput(numTasks), + txIncarnations: make([]int, numTasks), + estimateDeps: make(map[int][]int), + preValidated: make(map[int]bool), + begin: time.Now(), + profile: profile, + } + + return pe +} + +// nolint: gocognit +func (pe *ParallelExecutor) Prepare() error { + prevSenderTx := make(map[common.Address]int) + + for i, t := range pe.tasks { + clearPendingFlag := false + + pe.skipCheck[i] = false + pe.estimateDeps[i] = make([]int, 0) + + if len(t.Dependencies()) > 0 { + for _, val := range t.Dependencies() { + clearPendingFlag = true + + pe.execTasks.addDependencies(val, i) + } + + if clearPendingFlag { + pe.execTasks.clearPending(i) + + clearPendingFlag = false + } + } else { + if tx, ok := prevSenderTx[t.Sender()]; ok { + pe.execTasks.addDependencies(tx, i) + pe.execTasks.clearPending(i) + } + + prevSenderTx[t.Sender()] = i + } + } + + pe.workerWg.Add(pe.numSpeculativeProcs + numGoProcs) + + // Launch workers that execute transactions + for i := 0; i < pe.numSpeculativeProcs+numGoProcs; i++ { + go func(procNum int) { + defer pe.workerWg.Done() + + doWork := func(task ExecVersionView) { + start := time.Duration(0) + if pe.profile { + start = time.Since(pe.begin) + } + + res := task.Execute() + + if res.err == nil { + pe.mvh.FlushMVWriteSet(res.txAllOut) + } + + pe.resultQueue.Push(res.ver.TxnIndex, res) + pe.chResults <- struct{}{} + + if pe.profile { + end := time.Since(pe.begin) + + pe.statsMutex.Lock() + pe.stats[res.ver.TxnIndex] = ExecutionStat{ + TxIdx: res.ver.TxnIndex, + Incarnation: res.ver.Incarnation, + Start: uint64(start), + End: uint64(end), + Worker: procNum, + } + pe.statsMutex.Unlock() + } + } + + if procNum < pe.numSpeculativeProcs { + for range pe.chSpeculativeTasks { + doWork(pe.specTaskQueue.Pop().(ExecVersionView)) + } + } else { + for task := range pe.chTasks { + doWork(task) + } + } + }(i) + } + + pe.settleWg.Add(1) + + go func() { + for t := range pe.chSettle { + pe.tasks[t].Settle() + } + + pe.settleWg.Done() + }() + + // bootstrap first execution + tx := pe.execTasks.takeNextPending() + + if tx == -1 { + return ParallelExecFailedError{"no executable transactions due to bad dependency"} + } + + pe.cntExec++ + + pe.chTasks <- ExecVersionView{ver: Version{tx, 0}, et: pe.tasks[tx], mvh: pe.mvh, sender: pe.tasks[tx].Sender()} + + return nil +} + +func (pe *ParallelExecutor) Close(wait bool) { + close(pe.chTasks) + close(pe.chSpeculativeTasks) + close(pe.chSettle) + + if wait { + pe.workerWg.Wait() + } + + if wait { + pe.settleWg.Wait() + } +} + +// nolint: gocognit +func (pe *ParallelExecutor) Step(res *ExecResult) (result ParallelExecutionResult, err error) { + tx := res.ver.TxnIndex + + if abortErr, ok := res.err.(ErrExecAbortError); ok && abortErr.OriginError != nil && pe.skipCheck[tx] { + // If the transaction failed when we know it should not fail, this means the transaction itself is + // bad (e.g. wrong nonce), and we should exit the execution immediately + err = fmt.Errorf("could not apply tx %d [%v]: %w", tx, pe.tasks[tx].Hash(), abortErr.OriginError) + pe.Close(true) + + return + } + + // nolint: nestif + if execErr, ok := res.err.(ErrExecAbortError); ok { + addedDependencies := false + + if execErr.Dependency >= 0 { + l := len(pe.estimateDeps[tx]) + for l > 0 && pe.estimateDeps[tx][l-1] > execErr.Dependency { + pe.execTasks.removeDependency(pe.estimateDeps[tx][l-1]) + pe.estimateDeps[tx] = pe.estimateDeps[tx][:l-1] + l-- + } + + addedDependencies = pe.execTasks.addDependencies(execErr.Dependency, tx) + } else { + estimate := 0 + + if len(pe.estimateDeps[tx]) > 0 { + estimate = pe.estimateDeps[tx][len(pe.estimateDeps[tx])-1] + } + + addedDependencies = pe.execTasks.addDependencies(estimate, tx) + + newEstimate := estimate + (estimate+tx)/2 + if newEstimate >= tx { + newEstimate = tx - 1 + } + + pe.estimateDeps[tx] = append(pe.estimateDeps[tx], newEstimate) + } + + pe.execTasks.clearInProgress(tx) + + if !addedDependencies { + pe.execTasks.pushPending(tx) + } + + pe.txIncarnations[tx]++ + pe.diagExecAbort[tx]++ + pe.cntAbort++ + } else { + pe.lastTxIO.recordRead(tx, res.txIn) + + if res.ver.Incarnation == 0 { + pe.lastTxIO.recordWrite(tx, res.txOut) + pe.lastTxIO.recordAllWrite(tx, res.txAllOut) + } else { + if res.txAllOut.hasNewWrite(pe.lastTxIO.AllWriteSet(tx)) { + pe.validateTasks.pushPendingSet(pe.execTasks.getRevalidationRange(tx + 1)) + } + + prevWrite := pe.lastTxIO.AllWriteSet(tx) + + // Remove entries that were previously written but are no longer written + + cmpMap := make(map[Key]bool) + + for _, w := range res.txAllOut { + cmpMap[w.Path] = true + } + + for _, v := range prevWrite { + if _, ok := cmpMap[v.Path]; !ok { + pe.mvh.Delete(v.Path, tx) + } + } + + pe.lastTxIO.recordWrite(tx, res.txOut) + pe.lastTxIO.recordAllWrite(tx, res.txAllOut) + } + + pe.validateTasks.pushPending(tx) + pe.execTasks.markComplete(tx) + + pe.diagExecSuccess[tx]++ + pe.cntSuccess++ + + pe.execTasks.removeDependency(tx) + } + + // do validations ... + maxComplete := pe.execTasks.maxAllComplete() + + toValidate := make([]int, 0, 2) + + for pe.validateTasks.minPending() <= maxComplete && pe.validateTasks.minPending() >= 0 { + toValidate = append(toValidate, pe.validateTasks.takeNextPending()) + } + + for i := 0; i < len(toValidate); i++ { + pe.cntTotalValidations++ + + tx := toValidate[i] + + if pe.skipCheck[tx] || ValidateVersion(tx, pe.lastTxIO, pe.mvh) { + pe.validateTasks.markComplete(tx) + } else { + pe.cntValidationFail++ + + pe.diagExecAbort[tx]++ + for _, v := range pe.lastTxIO.AllWriteSet(tx) { + pe.mvh.MarkEstimate(v.Path, tx) + } + // 'create validation tasks for all transactions > tx ...' + pe.validateTasks.pushPendingSet(pe.execTasks.getRevalidationRange(tx + 1)) + pe.validateTasks.clearInProgress(tx) // clear in progress - pending will be added again once new incarnation executes + + pe.execTasks.clearComplete(tx) + pe.execTasks.pushPending(tx) + + pe.preValidated[tx] = false + pe.txIncarnations[tx]++ + } + } + + // Settle transactions that have been validated to be correct and that won't be re-executed again + maxValidated := pe.validateTasks.maxAllComplete() + + for pe.lastSettled < maxValidated { + pe.lastSettled++ + if pe.execTasks.checkInProgress(pe.lastSettled) || pe.execTasks.checkPending(pe.lastSettled) || pe.execTasks.isBlocked(pe.lastSettled) { + pe.lastSettled-- + break + } + pe.chSettle <- pe.lastSettled + } + + if pe.validateTasks.countComplete() == len(pe.tasks) && pe.execTasks.countComplete() == len(pe.tasks) { + log.Debug("blockstm exec summary", "execs", pe.cntExec, "success", pe.cntSuccess, "aborts", pe.cntAbort, "validations", pe.cntTotalValidations, "failures", pe.cntValidationFail, "#tasks/#execs", fmt.Sprintf("%.2f%%", float64(len(pe.tasks))/float64(pe.cntExec)*100)) + + pe.Close(true) + + var allDeps map[int]map[int]bool + + var deps DAG + + if pe.profile { + allDeps = GetDep(*pe.lastTxIO) + deps = BuildDAG(*pe.lastTxIO) + } + + return ParallelExecutionResult{pe.lastTxIO, &pe.stats, &deps, allDeps}, err + } + + // Send the next immediate pending transaction to be executed + if pe.execTasks.minPending() != -1 && pe.execTasks.minPending() == maxValidated+1 { + nextTx := pe.execTasks.takeNextPending() + if nextTx != -1 { + pe.cntExec++ + + pe.skipCheck[nextTx] = true + + pe.chTasks <- ExecVersionView{ver: Version{nextTx, pe.txIncarnations[nextTx]}, et: pe.tasks[nextTx], mvh: pe.mvh, sender: pe.tasks[nextTx].Sender()} + } + } + + // Send speculative tasks + for pe.execTasks.minPending() != -1 { + nextTx := pe.execTasks.takeNextPending() + + if nextTx != -1 { + pe.cntExec++ + + task := ExecVersionView{ver: Version{nextTx, pe.txIncarnations[nextTx]}, et: pe.tasks[nextTx], mvh: pe.mvh, sender: pe.tasks[nextTx].Sender()} + + pe.specTaskQueue.Push(nextTx, task) + pe.chSpeculativeTasks <- struct{}{} + } + } + + return +} + +type PropertyCheck func(*ParallelExecutor) error + +func executeParallelWithCheck(tasks []ExecTask, profile bool, check PropertyCheck, metadata bool, numProcs int, interruptCtx context.Context) (result ParallelExecutionResult, err error) { + if len(tasks) == 0 { + return ParallelExecutionResult{MakeTxnInputOutput(len(tasks)), nil, nil, nil}, nil + } + + pe := NewParallelExecutor(tasks, profile, metadata, numProcs) + err = pe.Prepare() + + if err != nil { + pe.Close(true) + return + } + + for range pe.chResults { + if interruptCtx != nil && interruptCtx.Err() != nil { + pe.Close(true) + return result, interruptCtx.Err() + } + + res := pe.resultQueue.Pop().(ExecResult) + + result, err = pe.Step(&res) + + if err != nil { + return result, err + } + + if check != nil { + err = check(pe) + } + + if result.TxIO != nil || err != nil { + return result, err + } + } + + return +} + +func ExecuteParallel(tasks []ExecTask, profile bool, metadata bool, numProcs int, interruptCtx context.Context) (result ParallelExecutionResult, err error) { + return executeParallelWithCheck(tasks, profile, nil, metadata, numProcs, interruptCtx) +} diff --git a/core/blockstm/executor_test.go b/core/blockstm/executor_test.go new file mode 100644 index 0000000000..8a16e0652f --- /dev/null +++ b/core/blockstm/executor_test.go @@ -0,0 +1,988 @@ +package blockstm + +import ( + "context" + "fmt" + "math/big" + "math/rand" + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" +) + +type OpType int + +var numProcs = 8 + +const readType = 0 +const writeType = 1 +const otherType = 2 +const greenTick = "✅" +const redCross = "❌" + +const threeRockets = "🚀🚀🚀" + +type Op struct { + key Key + duration time.Duration + opType OpType + val int +} + +type testExecTask struct { + txIdx int + ops []Op + readMap map[Key]ReadDescriptor + writeMap map[Key]WriteDescriptor + sender common.Address + nonce int + dependencies []int +} + +type PathGenerator func(addr common.Address, i int, j int, total int) Key + +type TaskRunner func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) + +type TaskRunnerWithMetadata func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) + +type Timer func(txIdx int, opIdx int) time.Duration + +type Sender func(int) common.Address + +func NewTestExecTask(txIdx int, ops []Op, sender common.Address, nonce int) *testExecTask { + return &testExecTask{ + txIdx: txIdx, + ops: ops, + readMap: make(map[Key]ReadDescriptor), + writeMap: make(map[Key]WriteDescriptor), + sender: sender, + nonce: nonce, + dependencies: []int{}, + } +} + +func sleep(i time.Duration) { + start := time.Now() + for time.Since(start) < i { + } +} + +func (t *testExecTask) Execute(mvh *MVHashMap, incarnation int) error { + // Sleep for 50 microsecond to simulate setup time + sleep(time.Microsecond * 50) + + version := Version{TxnIndex: t.txIdx, Incarnation: incarnation} + + t.readMap = make(map[Key]ReadDescriptor) + t.writeMap = make(map[Key]WriteDescriptor) + + deps := -1 + + for i, op := range t.ops { + k := op.key + + switch op.opType { + case readType: + if _, ok := t.writeMap[k]; ok { + sleep(op.duration) + continue + } + + result := mvh.Read(k, t.txIdx) + + val := result.Value() + + if i == 0 && val != nil && (val.(int) != t.nonce) { + return ErrExecAbortError{} + } + + if result.Status() == MVReadResultDependency { + if result.depIdx > deps { + deps = result.depIdx + } + } + + var readKind int + + if result.Status() == MVReadResultDone { + readKind = ReadKindMap + } else if result.Status() == MVReadResultNone { + readKind = ReadKindStorage + } + + sleep(op.duration) + + t.readMap[k] = ReadDescriptor{k, readKind, Version{TxnIndex: result.depIdx, Incarnation: result.incarnation}} + case writeType: + t.writeMap[k] = WriteDescriptor{k, version, op.val} + case otherType: + sleep(op.duration) + default: + panic(fmt.Sprintf("Unknown op type: %d", op.opType)) + } + } + + if deps != -1 { + return ErrExecAbortError{deps, fmt.Errorf("Dependency error")} + } + + return nil +} + +func (t *testExecTask) MVWriteList() []WriteDescriptor { + return t.MVFullWriteList() +} + +func (t *testExecTask) MVFullWriteList() []WriteDescriptor { + writes := make([]WriteDescriptor, 0, len(t.writeMap)) + + for _, v := range t.writeMap { + writes = append(writes, v) + } + + return writes +} + +func (t *testExecTask) MVReadList() []ReadDescriptor { + reads := make([]ReadDescriptor, 0, len(t.readMap)) + + for _, v := range t.readMap { + reads = append(reads, v) + } + + return reads +} + +func (t *testExecTask) Settle() {} + +func (t *testExecTask) Sender() common.Address { + return t.sender +} + +func (t *testExecTask) Hash() common.Hash { + return common.BytesToHash([]byte(fmt.Sprintf("%d", t.txIdx))) +} + +func (t *testExecTask) Dependencies() []int { + return t.dependencies +} + +func randTimeGenerator(min time.Duration, max time.Duration) func(txIdx int, opIdx int) time.Duration { + return func(txIdx int, opIdx int) time.Duration { + return time.Duration(rand.Int63n(int64(max-min))) + min + } +} + +func longTailTimeGenerator(min time.Duration, max time.Duration, i int, j int) func(txIdx int, opIdx int) time.Duration { + return func(txIdx int, opIdx int) time.Duration { + if txIdx%i == 0 && opIdx == j { + return max * 100 + } else { + return time.Duration(rand.Int63n(int64(max-min))) + min + } + } +} + +var randomPathGenerator = func(sender common.Address, i int, j int, total int) Key { + return NewStateKey(common.BigToAddress((big.NewInt(int64(i % 10)))), common.BigToHash((big.NewInt(int64(total))))) +} + +var dexPathGenerator = func(sender common.Address, i int, j int, total int) Key { + if j == total-1 || j == 2 { + return NewSubpathKey(common.BigToAddress(big.NewInt(int64(0))), 1) + } else { + return NewSubpathKey(common.BigToAddress(big.NewInt(int64(j))), 1) + } +} + +var readTime = randTimeGenerator(4*time.Microsecond, 12*time.Microsecond) +var writeTime = randTimeGenerator(2*time.Microsecond, 6*time.Microsecond) +var nonIOTime = randTimeGenerator(1*time.Microsecond, 2*time.Microsecond) + +func taskFactory(numTask int, sender Sender, readsPerT int, writesPerT int, nonIOPerT int, pathGenerator PathGenerator, readTime Timer, writeTime Timer, nonIOTime Timer) ([]ExecTask, time.Duration) { + exec := make([]ExecTask, 0, numTask) + + var serialDuration time.Duration + + senderNonces := make(map[common.Address]int) + + for i := 0; i < numTask; i++ { + s := sender(i) + + // Set first two ops to always read and write nonce + ops := make([]Op, 0, readsPerT+writesPerT+nonIOPerT) + + ops = append(ops, Op{opType: readType, key: NewSubpathKey(s, 2), duration: readTime(i, 0), val: senderNonces[s]}) + + senderNonces[s]++ + + ops = append(ops, Op{opType: writeType, key: NewSubpathKey(s, 2), duration: writeTime(i, 1), val: senderNonces[s]}) + + for j := 0; j < readsPerT-1; j++ { + ops = append(ops, Op{opType: readType}) + } + + for j := 0; j < nonIOPerT; j++ { + ops = append(ops, Op{opType: otherType}) + } + + for j := 0; j < writesPerT-1; j++ { + ops = append(ops, Op{opType: writeType}) + } + + // shuffle ops except for the first three (read nonce, write nonce, another read) ops and last write op. + // This enables random path generator to generate deterministic paths for these "special" ops. + for j := 3; j < len(ops)-1; j++ { + k := rand.Intn(len(ops)-j-1) + j + ops[j], ops[k] = ops[k], ops[j] + } + + // Generate time and key path for each op except first two that are always read and write nonce + for j := 2; j < len(ops); j++ { + if ops[j].opType == readType { + ops[j].key = pathGenerator(s, i, j, len(ops)) + ops[j].duration = readTime(i, j) + } else if ops[j].opType == writeType { + ops[j].key = pathGenerator(s, i, j, len(ops)) + ops[j].duration = writeTime(i, j) + } else { + ops[j].duration = nonIOTime(i, j) + } + + serialDuration += ops[j].duration + } + + if ops[len(ops)-1].opType != writeType { + panic("Last op must be a write") + } + + t := NewTestExecTask(i, ops, s, senderNonces[s]-1) + exec = append(exec, t) + } + + return exec, serialDuration +} + +func testExecutorComb(t *testing.T, totalTxs []int, numReads []int, numWrites []int, numNonIO []int, taskRunner TaskRunner) { + t.Helper() + log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StreamHandler(os.Stderr, log.TerminalFormat(false)))) + + improved := 0 + total := 0 + + totalExecDuration := time.Duration(0) + totalSerialDuration := time.Duration(0) + + for _, numTx := range totalTxs { + for _, numRead := range numReads { + for _, numWrite := range numWrites { + for _, numNonIO := range numNonIO { + log.Info("Executing block", "numTx", numTx, "numRead", numRead, "numWrite", numWrite, "numNonIO", numNonIO) + execDuration, expectedSerialDuration := taskRunner(numTx, numRead, numWrite, numNonIO) + + if execDuration < expectedSerialDuration { + improved++ + } + + total++ + + performance := greenTick + + if execDuration >= expectedSerialDuration { + performance = redCross + } + + fmt.Printf("exec duration %v, serial duration %v, time reduced %v %.2f%%, %v \n", execDuration, expectedSerialDuration, expectedSerialDuration-execDuration, float64(expectedSerialDuration-execDuration)/float64(expectedSerialDuration)*100, performance) + + totalExecDuration += execDuration + totalSerialDuration += expectedSerialDuration + } + } + } + } + + fmt.Println("Improved: ", improved, "Total: ", total, "success rate: ", float64(improved)/float64(total)*100) + fmt.Printf("Total exec duration: %v, total serial duration: %v, time reduced: %v, time reduced percent: %.2f%%\n", totalExecDuration, totalSerialDuration, totalSerialDuration-totalExecDuration, float64(totalSerialDuration-totalExecDuration)/float64(totalSerialDuration)*100) +} + +// nolint: gocognit +func testExecutorCombWithMetadata(t *testing.T, totalTxs []int, numReads []int, numWrites []int, numNonIOs []int, taskRunner TaskRunnerWithMetadata) { + t.Helper() + log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StreamHandler(os.Stderr, log.TerminalFormat(false)))) + + improved := 0 + improvedMetadata := 0 + rocket := 0 + total := 0 + + totalExecDuration := time.Duration(0) + totalExecDurationMetadata := time.Duration(0) + totalSerialDuration := time.Duration(0) + + for _, numTx := range totalTxs { + for _, numRead := range numReads { + for _, numWrite := range numWrites { + for _, numNonIO := range numNonIOs { + log.Info("Executing block", "numTx", numTx, "numRead", numRead, "numWrite", numWrite, "numNonIO", numNonIO) + execDuration, execDurationMetadata, expectedSerialDuration := taskRunner(numTx, numRead, numWrite, numNonIO) + + if execDuration < expectedSerialDuration { + improved++ + } + + total++ + + performance := greenTick + + if execDuration >= expectedSerialDuration { + performance = redCross + + if execDurationMetadata <= expectedSerialDuration { + performance = threeRockets + rocket++ + } + } + + if execDuration >= execDurationMetadata { + improvedMetadata++ + } + + fmt.Printf("WITHOUT METADATA: exec duration %v, serial duration %v, time reduced %v %.2f%%, %v \n", execDuration, expectedSerialDuration, expectedSerialDuration-execDuration, float64(expectedSerialDuration-execDuration)/float64(expectedSerialDuration)*100, performance) + fmt.Printf("WITH METADATA: exec duration %v, exec duration with metadata %v, time reduced %v %.2f%%\n", execDuration, execDurationMetadata, execDuration-execDurationMetadata, float64(execDuration-execDurationMetadata)/float64(execDuration)*100) + + totalExecDuration += execDuration + totalExecDurationMetadata += execDurationMetadata + totalSerialDuration += expectedSerialDuration + } + } + } + } + + fmt.Println("\nImproved: ", improved, "Total: ", total, "success rate: ", float64(improved)/float64(total)*100) + fmt.Println("Metadata Better: ", improvedMetadata, "out of: ", total, "success rate: ", float64(improvedMetadata)/float64(total)*100) + fmt.Println("Rockets (Time of: metadata < serial < without metadata): ", rocket) + fmt.Printf("\nWithout metadata <> serial: Total exec duration: %v, total serial duration : %v, time reduced: %v, time reduced percent: %.2f%%\n", totalExecDuration, totalSerialDuration, totalSerialDuration-totalExecDuration, float64(totalSerialDuration-totalExecDuration)/float64(totalSerialDuration)*100) + fmt.Printf("With metadata <> serial: Total exec duration metadata: %v, total serial duration : %v, time reduced: %v, time reduced percent: %.2f%%\n", totalExecDurationMetadata, totalSerialDuration, totalSerialDuration-totalExecDurationMetadata, float64(totalSerialDuration-totalExecDurationMetadata)/float64(totalSerialDuration)*100) + fmt.Printf("Without metadata <> with metadata: Total exec duration: %v, total exec duration metadata: %v, time reduced: %v, time reduced percent: %.2f%%\n", totalExecDuration, totalExecDurationMetadata, totalExecDuration-totalExecDurationMetadata, float64(totalExecDuration-totalExecDurationMetadata)/float64(totalExecDuration)*100) +} + +func composeValidations(checks []PropertyCheck) PropertyCheck { + return func(pe *ParallelExecutor) error { + for _, check := range checks { + err := check(pe) + if err != nil { + return err + } + } + + return nil + } +} + +func checkNoStatusOverlap(pe *ParallelExecutor) error { + seen := make(map[int]string) + + for _, tx := range pe.execTasks.complete { + seen[tx] = "complete" + } + + for _, tx := range pe.execTasks.inProgress { + if v, ok := seen[tx]; ok { + return fmt.Errorf("tx %v is in both %v and inProgress", v, tx) + } + + seen[tx] = "inProgress" + } + + for _, tx := range pe.execTasks.pending { + if v, ok := seen[tx]; ok { + return fmt.Errorf("tx %v is in both %v complete and pending", v, tx) + } + + seen[tx] = "pending" + } + + return nil +} + +func checkNoDroppedTx(pe *ParallelExecutor) error { + for i := 0; i < len(pe.tasks); i++ { + if !pe.execTasks.checkComplete(i) && !pe.execTasks.checkInProgress(i) && !pe.execTasks.checkPending(i) { + if !pe.execTasks.isBlocked(i) { + return fmt.Errorf("tx %v is not in any status and is not blocked by any other tx", i) + } + } + } + + return nil +} + +// nolint: unparam +func runParallel(t *testing.T, tasks []ExecTask, validation PropertyCheck, metadata bool) time.Duration { + t.Helper() + + profile := false + + start := time.Now() + result, err := executeParallelWithCheck(tasks, false, validation, metadata, numProcs, nil) + + if result.Deps != nil && profile { + result.Deps.Report(*result.Stats, func(str string) { fmt.Println(str) }) + } + + assert.NoError(t, err, "error occur during parallel execution") + + // Need to apply the final write set to storage + + finalWriteSet := make(map[Key]time.Duration) + + for _, task := range tasks { + task := task.(*testExecTask) + for _, op := range task.ops { + if op.opType == writeType { + finalWriteSet[op.key] = op.duration + } + } + } + + for _, v := range finalWriteSet { + sleep(v) + } + + duration := time.Since(start) + + return duration +} + +func runParallelGetMetadata(t *testing.T, tasks []ExecTask, validation PropertyCheck) map[int]map[int]bool { + t.Helper() + + res, err := executeParallelWithCheck(tasks, true, validation, false, numProcs, nil) + + assert.NoError(t, err, "error occur during parallel execution") + + return res.AllDeps +} + +func TestLessConflicts(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{10, 50, 100, 200, 300} + numReads := []int{20, 100, 200} + numWrites := []int{20, 100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i % randomness))) + } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestLessConflictsWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{300} + numReads := []int{100, 200} + numWrites := []int{100, 200} + numNonIOs := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i % randomness))) + } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIOs, taskRunner) +} + +func TestZeroTx(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{0} + numReads := []int{20} + numWrites := []int{20} + numNonIO := []int{100} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(1))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestAlternatingTx(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{200} + numReads := []int{20} + numWrites := []int{20} + numNonIO := []int{100} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(i % 2))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestAlternatingTxWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{200} + numReads := []int{20} + numWrites := []int{20} + numNonIO := []int{100} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(i % 2))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestMoreConflicts(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{10, 50, 100, 200, 300} + numReads := []int{20, 100, 200} + numWrites := []int{20, 100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i / randomness))) + } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestMoreConflictsWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{300} + numReads := []int{100, 200} + numWrites := []int{100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i / randomness))) + } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestRandomTx(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{10, 50, 100, 200, 300} + numReads := []int{20, 100, 200} + numWrites := []int{20, 100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + // Randomly assign this tx to one of 10 senders + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(rand.Intn(10)))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestRandomTxWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{300} + numReads := []int{100, 200} + numWrites := []int{100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + // Randomly assign this tx to one of 10 senders + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(rand.Intn(10)))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, readTime, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestTxWithLongTailRead(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{10, 50, 100, 200, 300} + numReads := []int{20, 100, 200} + numWrites := []int{20, 100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i / randomness))) + } + + longTailReadTimer := longTailTimeGenerator(4*time.Microsecond, 12*time.Microsecond, 7, 10) + + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, longTailReadTimer, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestTxWithLongTailReadWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{300} + numReads := []int{100, 200} + numWrites := []int{100, 200} + numNonIO := []int{100, 500} + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + sender := func(i int) common.Address { + randomness := rand.Intn(10) + 10 + return common.BigToAddress(big.NewInt(int64(i / randomness))) + } + + longTailReadTimer := longTailTimeGenerator(4*time.Microsecond, 12*time.Microsecond, 7, 10) + + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, randomPathGenerator, longTailReadTimer, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestDexScenario(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{10, 50, 100, 200, 300} + numReads := []int{20, 100, 200} + numWrites := []int{20, 100, 200} + numNonIO := []int{100, 500} + + postValidation := func(pe *ParallelExecutor) error { + if pe.lastSettled == len(pe.tasks) { + for i, inputs := range pe.lastTxIO.inputs { + for _, input := range inputs { + if input.V.TxnIndex != i-1 { + return fmt.Errorf("Tx %d should depend on tx %d, but it actually depends on %d", i, i-1, input.V.TxnIndex) + } + } + } + } + + return nil + } + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, postValidation, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration) { + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(i))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, dexPathGenerator, readTime, writeTime, nonIOTime) + + return runParallel(t, tasks, checks, false), serialDuration + } + + testExecutorComb(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestDexScenarioWithMetadata(t *testing.T) { + t.Parallel() + rand.Seed(0) + + totalTxs := []int{300} + numReads := []int{100, 200} + numWrites := []int{100, 200} + numNonIO := []int{100, 500} + + postValidation := func(pe *ParallelExecutor) error { + if pe.lastSettled == len(pe.tasks) { + for i, inputs := range pe.lastTxIO.inputs { + for _, input := range inputs { + if input.V.TxnIndex != i-1 { + return fmt.Errorf("Tx %d should depend on tx %d, but it actually depends on %d", i, i-1, input.V.TxnIndex) + } + } + } + } + + return nil + } + + checks := composeValidations([]PropertyCheck{checkNoStatusOverlap, postValidation, checkNoDroppedTx}) + + taskRunner := func(numTx int, numRead int, numWrite int, numNonIO int) (time.Duration, time.Duration, time.Duration) { + sender := func(i int) common.Address { return common.BigToAddress(big.NewInt(int64(i))) } + tasks, serialDuration := taskFactory(numTx, sender, numRead, numWrite, numNonIO, dexPathGenerator, readTime, writeTime, nonIOTime) + + parallelDuration := runParallel(t, tasks, checks, false) + + allDeps := runParallelGetMetadata(t, tasks, checks) + + newTasks := make([]ExecTask, 0, len(tasks)) + + for _, t := range tasks { + temp := t.(*testExecTask) + + keys := make([]int, len(allDeps[temp.txIdx])) + + i := 0 + + for k := range allDeps[temp.txIdx] { + keys[i] = k + i++ + } + + temp.dependencies = keys + newTasks = append(newTasks, temp) + } + + return parallelDuration, runParallel(t, newTasks, checks, true), serialDuration + } + + testExecutorCombWithMetadata(t, totalTxs, numReads, numWrites, numNonIO, taskRunner) +} + +func TestBreakFromCircularDependency(t *testing.T) { + t.Parallel() + rand.Seed(0) + + tasks := make([]ExecTask, 5) + + for i := range tasks { + tasks[i] = &testExecTask{ + txIdx: i, + dependencies: []int{ + (i + len(tasks) - 1) % len(tasks), + }, + } + } + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + // This should not hang + _, err := ExecuteParallel(tasks, false, true, numProcs, ctx) + + if err == nil { + t.Error("Expected cancel error") + } +} + +func TestBreakFromPartialCircularDependency(t *testing.T) { + t.Parallel() + rand.Seed(0) + + tasks := make([]ExecTask, 5) + + for i := range tasks { + if i < 3 { + tasks[i] = &testExecTask{ + txIdx: i, + dependencies: []int{ + (i + 2) % 3, + }, + } + } else { + tasks[i] = &testExecTask{ + txIdx: i, + dependencies: []int{}, + } + } + } + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + // This should not hang + _, err := ExecuteParallel(tasks, false, true, numProcs, ctx) + + if err == nil { + t.Error("Expected cancel error") + } +} diff --git a/core/blockstm/mvhashmap.go b/core/blockstm/mvhashmap.go new file mode 100644 index 0000000000..3739609304 --- /dev/null +++ b/core/blockstm/mvhashmap.go @@ -0,0 +1,291 @@ +package blockstm + +import ( + "fmt" + "sync" + + "github.com/emirpasic/gods/maps/treemap" + + "github.com/ethereum/go-ethereum/common" +) + +const FlagDone = 0 +const FlagEstimate = 1 + +const addressType = 1 +const stateType = 2 +const subpathType = 3 + +const KeyLength = common.AddressLength + common.HashLength + 2 + +type Key [KeyLength]byte + +func (k Key) IsAddress() bool { + return k[KeyLength-1] == addressType +} + +func (k Key) IsState() bool { + return k[KeyLength-1] == stateType +} + +func (k Key) IsSubpath() bool { + return k[KeyLength-1] == subpathType +} + +func (k Key) GetAddress() common.Address { + return common.BytesToAddress(k[:common.AddressLength]) +} + +func (k Key) GetStateKey() common.Hash { + return common.BytesToHash(k[common.AddressLength : KeyLength-2]) +} + +func (k Key) GetSubpath() byte { + return k[KeyLength-2] +} + +func newKey(addr common.Address, hash common.Hash, subpath byte, keyType byte) Key { + var k Key + + copy(k[:common.AddressLength], addr.Bytes()) + copy(k[common.AddressLength:KeyLength-2], hash.Bytes()) + k[KeyLength-2] = subpath + k[KeyLength-1] = keyType + + return k +} + +func NewAddressKey(addr common.Address) Key { + return newKey(addr, common.Hash{}, 0, addressType) +} + +func NewStateKey(addr common.Address, hash common.Hash) Key { + k := newKey(addr, hash, 0, stateType) + if !k.IsState() { + panic(fmt.Errorf("key is not a state key")) + } + + return k +} + +func NewSubpathKey(addr common.Address, subpath byte) Key { + return newKey(addr, common.Hash{}, subpath, subpathType) +} + +type MVHashMap struct { + m sync.Map + s sync.Map +} + +func MakeMVHashMap() *MVHashMap { + return &MVHashMap{} +} + +type WriteCell struct { + flag uint + incarnation int + data interface{} +} + +type TxnIndexCells struct { + rw sync.RWMutex + tm *treemap.Map +} + +type Version struct { + TxnIndex int + Incarnation int +} + +func (mv *MVHashMap) getKeyCells(k Key, fNoKey func(kenc Key) *TxnIndexCells) (cells *TxnIndexCells) { + val, ok := mv.m.Load(k) + + if !ok { + cells = fNoKey(k) + } else { + cells = val.(*TxnIndexCells) + } + + return +} + +func (mv *MVHashMap) Write(k Key, v Version, data interface{}) { + cells := mv.getKeyCells(k, func(kenc Key) (cells *TxnIndexCells) { + n := &TxnIndexCells{ + rw: sync.RWMutex{}, + tm: treemap.NewWithIntComparator(), + } + cells = n + val, _ := mv.m.LoadOrStore(kenc, n) + cells = val.(*TxnIndexCells) + + return + }) + + cells.rw.RLock() + ci, ok := cells.tm.Get(v.TxnIndex) + cells.rw.RUnlock() + + if ok { + if ci.(*WriteCell).incarnation > v.Incarnation { + panic(fmt.Errorf("existing transaction value does not have lower incarnation: %v, %v", + k, v.TxnIndex)) + } + + ci.(*WriteCell).flag = FlagDone + ci.(*WriteCell).incarnation = v.Incarnation + ci.(*WriteCell).data = data + } else { + cells.rw.Lock() + if ci, ok = cells.tm.Get(v.TxnIndex); !ok { + cells.tm.Put(v.TxnIndex, &WriteCell{ + flag: FlagDone, + incarnation: v.Incarnation, + data: data, + }) + } else { + ci.(*WriteCell).flag = FlagDone + ci.(*WriteCell).incarnation = v.Incarnation + ci.(*WriteCell).data = data + } + cells.rw.Unlock() + } +} + +func (mv *MVHashMap) ReadStorage(k Key, fallBack func() any) any { + data, ok := mv.s.Load(string(k[:])) + if !ok { + data = fallBack() + data, _ = mv.s.LoadOrStore(string(k[:]), data) + } + + return data +} + +func (mv *MVHashMap) MarkEstimate(k Key, txIdx int) { + cells := mv.getKeyCells(k, func(_ Key) *TxnIndexCells { + panic(fmt.Errorf("path must already exist")) + }) + + cells.rw.RLock() + if ci, ok := cells.tm.Get(txIdx); !ok { + panic(fmt.Sprintf("should not happen - cell should be present for path. TxIdx: %v, path, %x, cells keys: %v", txIdx, k, cells.tm.Keys())) + } else { + ci.(*WriteCell).flag = FlagEstimate + } + cells.rw.RUnlock() +} + +func (mv *MVHashMap) Delete(k Key, txIdx int) { + cells := mv.getKeyCells(k, func(_ Key) *TxnIndexCells { + panic(fmt.Errorf("path must already exist")) + }) + + cells.rw.Lock() + defer cells.rw.Unlock() + cells.tm.Remove(txIdx) +} + +const ( + MVReadResultDone = 0 + MVReadResultDependency = 1 + MVReadResultNone = 2 +) + +type MVReadResult struct { + depIdx int + incarnation int + value interface{} +} + +func (res *MVReadResult) DepIdx() int { + return res.depIdx +} + +func (res *MVReadResult) Incarnation() int { + return res.incarnation +} + +func (res *MVReadResult) Value() interface{} { + return res.value +} + +func (mvr MVReadResult) Status() int { + if mvr.depIdx != -1 { + if mvr.incarnation == -1 { + return MVReadResultDependency + } else { + return MVReadResultDone + } + } + + return MVReadResultNone +} + +func (mv *MVHashMap) Read(k Key, txIdx int) (res MVReadResult) { + res.depIdx = -1 + res.incarnation = -1 + + cells := mv.getKeyCells(k, func(_ Key) *TxnIndexCells { + return nil + }) + if cells == nil { + return + } + + cells.rw.RLock() + fk, fv := cells.tm.Floor(txIdx - 1) + cells.rw.RUnlock() + + if fk != nil && fv != nil { + c := fv.(*WriteCell) + switch c.flag { + case FlagEstimate: + res.depIdx = fk.(int) + res.value = c.data + case FlagDone: + { + res.depIdx = fk.(int) + res.incarnation = c.incarnation + res.value = c.data + } + default: + panic(fmt.Errorf("should not happen - unknown flag value")) + } + } + + return +} + +func (mv *MVHashMap) FlushMVWriteSet(writes []WriteDescriptor) { + for _, v := range writes { + mv.Write(v.Path, v.V, v.Val) + } +} + +func ValidateVersion(txIdx int, lastInputOutput *TxnInputOutput, versionedData *MVHashMap) (valid bool) { + valid = true + + for _, rd := range lastInputOutput.ReadSet(txIdx) { + mvResult := versionedData.Read(rd.Path, txIdx) + switch mvResult.Status() { + case MVReadResultDone: + valid = rd.Kind == ReadKindMap && rd.V == Version{ + TxnIndex: mvResult.depIdx, + Incarnation: mvResult.incarnation, + } + case MVReadResultDependency: + valid = false + case MVReadResultNone: + valid = rd.Kind == ReadKindStorage // feels like an assertion? + default: + panic(fmt.Errorf("should not happen - undefined mv read status: %ver", mvResult.Status())) + } + + if !valid { + break + } + } + + return +} diff --git a/core/blockstm/mvhashmap_test.go b/core/blockstm/mvhashmap_test.go new file mode 100644 index 0000000000..7ed728426c --- /dev/null +++ b/core/blockstm/mvhashmap_test.go @@ -0,0 +1,344 @@ +package blockstm + +import ( + "fmt" + "math/big" + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/common" +) + +var randomness = rand.Intn(10) + 10 + +// create test data for a given txIdx and incarnation +func valueFor(txIdx, inc int) []byte { + return []byte(fmt.Sprintf("%ver:%ver:%ver", txIdx*5, txIdx+inc, inc*5)) +} + +func getCommonAddress(i int) common.Address { + return common.BigToAddress(big.NewInt(int64(i % randomness))) +} + +func TestHelperFunctions(t *testing.T) { + t.Parallel() + + ap1 := NewAddressKey(getCommonAddress(1)) + ap2 := NewAddressKey(getCommonAddress(2)) + + mvh := MakeMVHashMap() + + mvh.Write(ap1, Version{0, 1}, valueFor(0, 1)) + mvh.Write(ap1, Version{0, 2}, valueFor(0, 2)) + res := mvh.Read(ap1, 0) + require.Equal(t, -1, res.DepIdx()) + require.Equal(t, -1, res.Incarnation()) + require.Equal(t, 2, res.Status()) + + mvh.Write(ap2, Version{1, 1}, valueFor(1, 1)) + mvh.Write(ap2, Version{1, 2}, valueFor(1, 2)) + res = mvh.Read(ap2, 1) + require.Equal(t, -1, res.DepIdx()) + require.Equal(t, -1, res.Incarnation()) + require.Equal(t, 2, res.Status()) + + mvh.Write(ap1, Version{2, 1}, valueFor(2, 1)) + mvh.Write(ap1, Version{2, 2}, valueFor(2, 2)) + res = mvh.Read(ap1, 2) + require.Equal(t, 0, res.DepIdx()) + require.Equal(t, 2, res.Incarnation()) + require.Equal(t, valueFor(0, 2), res.Value().([]byte)) + require.Equal(t, 0, res.Status()) +} + +func TestFlushMVWrite(t *testing.T) { + t.Parallel() + + ap1 := NewAddressKey(getCommonAddress(1)) + ap2 := NewAddressKey(getCommonAddress(2)) + + mvh := MakeMVHashMap() + + var res MVReadResult + + wd := []WriteDescriptor{} + + wd = append(wd, WriteDescriptor{ + Path: ap1, + V: Version{0, 1}, + Val: valueFor(0, 1), + }) + wd = append(wd, WriteDescriptor{ + Path: ap1, + V: Version{0, 2}, + Val: valueFor(0, 2), + }) + wd = append(wd, WriteDescriptor{ + Path: ap2, + V: Version{1, 1}, + Val: valueFor(1, 1), + }) + wd = append(wd, WriteDescriptor{ + Path: ap2, + V: Version{1, 2}, + Val: valueFor(1, 2), + }) + wd = append(wd, WriteDescriptor{ + Path: ap1, + V: Version{2, 1}, + Val: valueFor(2, 1), + }) + wd = append(wd, WriteDescriptor{ + Path: ap1, + V: Version{2, 2}, + Val: valueFor(2, 2), + }) + + mvh.FlushMVWriteSet(wd) + + res = mvh.Read(ap1, 0) + require.Equal(t, -1, res.DepIdx()) + require.Equal(t, -1, res.Incarnation()) + require.Equal(t, 2, res.Status()) + + res = mvh.Read(ap2, 1) + require.Equal(t, -1, res.DepIdx()) + require.Equal(t, -1, res.Incarnation()) + require.Equal(t, 2, res.Status()) + + res = mvh.Read(ap1, 2) + require.Equal(t, 0, res.DepIdx()) + require.Equal(t, 2, res.Incarnation()) + require.Equal(t, valueFor(0, 2), res.Value().([]byte)) + require.Equal(t, 0, res.Status()) +} + +// TODO - handle panic +func TestLowerIncarnation(t *testing.T) { + t.Parallel() + + ap1 := NewAddressKey(getCommonAddress(1)) + + mvh := MakeMVHashMap() + + mvh.Write(ap1, Version{0, 2}, valueFor(0, 2)) + mvh.Read(ap1, 0) + mvh.Write(ap1, Version{1, 2}, valueFor(1, 2)) + mvh.Write(ap1, Version{0, 5}, valueFor(0, 5)) + mvh.Write(ap1, Version{1, 5}, valueFor(1, 5)) +} + +func TestMarkEstimate(t *testing.T) { + t.Parallel() + + ap1 := NewAddressKey(getCommonAddress(1)) + + mvh := MakeMVHashMap() + + mvh.Write(ap1, Version{7, 2}, valueFor(7, 2)) + mvh.MarkEstimate(ap1, 7) + mvh.Write(ap1, Version{7, 4}, valueFor(7, 4)) +} + +func TestMVHashMapBasics(t *testing.T) { + t.Parallel() + + // memory locations + ap1 := NewAddressKey(getCommonAddress(1)) + ap2 := NewAddressKey(getCommonAddress(2)) + ap3 := NewAddressKey(getCommonAddress(3)) + + mvh := MakeMVHashMap() + + res := mvh.Read(ap1, 5) + require.Equal(t, -1, res.depIdx) + + mvh.Write(ap1, Version{10, 1}, valueFor(10, 1)) + + res = mvh.Read(ap1, 9) + require.Equal(t, -1, res.depIdx, "reads that should go the the DB return dependency -1") + res = mvh.Read(ap1, 10) + require.Equal(t, -1, res.depIdx, "Read returns entries from smaller txns, not txn 10") + + // Reads for a higher txn return the entry written by txn 10. + res = mvh.Read(ap1, 15) + require.Equal(t, 10, res.depIdx, "reads for a higher txn return the entry written by txn 10.") + require.Equal(t, 1, res.incarnation) + require.Equal(t, valueFor(10, 1), res.value) + + // More writes. + mvh.Write(ap1, Version{12, 0}, valueFor(12, 0)) + mvh.Write(ap1, Version{8, 3}, valueFor(8, 3)) + + // Verify reads. + res = mvh.Read(ap1, 15) + require.Equal(t, 12, res.depIdx) + require.Equal(t, 0, res.incarnation) + require.Equal(t, valueFor(12, 0), res.value) + + res = mvh.Read(ap1, 11) + require.Equal(t, 10, res.depIdx) + require.Equal(t, 1, res.incarnation) + require.Equal(t, valueFor(10, 1), res.value) + + res = mvh.Read(ap1, 10) + require.Equal(t, 8, res.depIdx) + require.Equal(t, 3, res.incarnation) + require.Equal(t, valueFor(8, 3), res.value) + + // Mark the entry written by 10 as an estimate. + mvh.MarkEstimate(ap1, 10) + + res = mvh.Read(ap1, 11) + require.Equal(t, 10, res.depIdx) + require.Equal(t, -1, res.incarnation, "dep at tx 10 is now an estimate") + + // Delete the entry written by 10, write to a different ap. + mvh.Delete(ap1, 10) + mvh.Write(ap2, Version{10, 2}, valueFor(10, 2)) + + // Read by txn 11 no longer observes entry from txn 10. + res = mvh.Read(ap1, 11) + require.Equal(t, 8, res.depIdx) + require.Equal(t, 3, res.incarnation) + require.Equal(t, valueFor(8, 3), res.value) + + // Reads, writes for ap2 and ap3. + mvh.Write(ap2, Version{5, 0}, valueFor(5, 0)) + mvh.Write(ap3, Version{20, 4}, valueFor(20, 4)) + + res = mvh.Read(ap2, 10) + require.Equal(t, 5, res.depIdx) + require.Equal(t, 0, res.incarnation) + require.Equal(t, valueFor(5, 0), res.value) + + res = mvh.Read(ap3, 21) + require.Equal(t, 20, res.depIdx) + require.Equal(t, 4, res.incarnation) + require.Equal(t, valueFor(20, 4), res.value) + + // Clear ap1 and ap3. + mvh.Delete(ap1, 12) + mvh.Delete(ap1, 8) + mvh.Delete(ap3, 20) + + // Reads from ap1 and ap3 go to db. + res = mvh.Read(ap1, 30) + require.Equal(t, -1, res.depIdx) + + res = mvh.Read(ap3, 30) + require.Equal(t, -1, res.depIdx) + + // No-op delete at ap2 - doesn't panic because ap2 does exist + mvh.Delete(ap2, 11) + + // Read entry by txn 10 at ap2. + res = mvh.Read(ap2, 15) + require.Equal(t, 10, res.depIdx) + require.Equal(t, 2, res.incarnation) + require.Equal(t, valueFor(10, 2), res.value) +} + +func BenchmarkWriteTimeSameLocationDifferentTxIdx(b *testing.B) { + mvh2 := MakeMVHashMap() + ap2 := NewAddressKey(getCommonAddress(2)) + + randInts := []int{} + for i := 0; i < b.N; i++ { + randInts = append(randInts, rand.Intn(1000000000000000)) + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + mvh2.Write(ap2, Version{randInts[i], 1}, valueFor(randInts[i], 1)) + } +} + +func BenchmarkReadTimeSameLocationDifferentTxIdx(b *testing.B) { + mvh2 := MakeMVHashMap() + ap2 := NewAddressKey(getCommonAddress(2)) + txIdxSlice := []int{} + + for i := 0; i < b.N; i++ { + txIdx := rand.Intn(1000000000000000) + txIdxSlice = append(txIdxSlice, txIdx) + mvh2.Write(ap2, Version{txIdx, 1}, valueFor(txIdx, 1)) + } + + b.ResetTimer() + + for _, value := range txIdxSlice { + mvh2.Read(ap2, value) + } +} + +func TestTimeComplexity(t *testing.T) { + t.Parallel() + + // for 1000000 read and write with no dependency at different memory location + mvh1 := MakeMVHashMap() + + for i := 0; i < 1000000; i++ { + ap1 := NewAddressKey(getCommonAddress(i)) + mvh1.Write(ap1, Version{i, 1}, valueFor(i, 1)) + mvh1.Read(ap1, i) + } + + // for 1000000 read and write with dependency at same memory location + mvh2 := MakeMVHashMap() + ap2 := NewAddressKey(getCommonAddress(2)) + + for i := 0; i < 1000000; i++ { + mvh2.Write(ap2, Version{i, 1}, valueFor(i, 1)) + mvh2.Read(ap2, i) + } +} + +func TestWriteTimeSameLocationDifferentTxnIdx(t *testing.T) { + t.Parallel() + + mvh1 := MakeMVHashMap() + ap1 := NewAddressKey(getCommonAddress(1)) + + for i := 0; i < 1000000; i++ { + mvh1.Write(ap1, Version{i, 1}, valueFor(i, 1)) + } +} + +func TestWriteTimeSameLocationSameTxnIdx(t *testing.T) { + t.Parallel() + + mvh1 := MakeMVHashMap() + ap1 := NewAddressKey(getCommonAddress(1)) + + for i := 0; i < 1000000; i++ { + mvh1.Write(ap1, Version{1, i}, valueFor(i, 1)) + } +} + +func TestWriteTimeDifferentLocation(t *testing.T) { + t.Parallel() + + mvh1 := MakeMVHashMap() + + for i := 0; i < 1000000; i++ { + ap1 := NewAddressKey(getCommonAddress(i)) + mvh1.Write(ap1, Version{i, 1}, valueFor(i, 1)) + } +} + +func TestReadTimeSameLocation(t *testing.T) { + t.Parallel() + + mvh1 := MakeMVHashMap() + ap1 := NewAddressKey(getCommonAddress(1)) + + mvh1.Write(ap1, Version{1, 1}, valueFor(1, 1)) + + for i := 0; i < 1000000; i++ { + mvh1.Read(ap1, 2) + } +} diff --git a/core/blockstm/status.go b/core/blockstm/status.go new file mode 100644 index 0000000000..29bb1461bb --- /dev/null +++ b/core/blockstm/status.go @@ -0,0 +1,227 @@ +package blockstm + +import ( + "fmt" + "sort" +) + +func makeStatusManager(numTasks int) (t taskStatusManager) { + t.pending = make([]int, numTasks) + for i := 0; i < numTasks; i++ { + t.pending[i] = i + } + + t.dependency = make(map[int]map[int]bool, numTasks) + t.blocker = make(map[int]map[int]bool, numTasks) + + for i := 0; i < numTasks; i++ { + t.blocker[i] = make(map[int]bool) + } + + return +} + +type taskStatusManager struct { + pending []int + inProgress []int + complete []int + dependency map[int]map[int]bool + blocker map[int]map[int]bool +} + +func insertInList(l []int, v int) []int { + if len(l) == 0 || v > l[len(l)-1] { + return append(l, v) + } else { + x := sort.SearchInts(l, v) + if x < len(l) && l[x] == v { + // already in list + return l + } + + a := append(l[:x+1], l[x:]...) + a[x] = v + + return a + } +} + +func (m *taskStatusManager) takeNextPending() int { + if len(m.pending) == 0 { + return -1 + } + + x := m.pending[0] + m.pending = m.pending[1:] + m.inProgress = insertInList(m.inProgress, x) + + return x +} + +func hasNoGap(l []int) bool { + return l[0]+len(l) == l[len(l)-1]+1 +} + +func (m taskStatusManager) maxAllComplete() int { + if len(m.complete) == 0 || m.complete[0] != 0 { + return -1 + } else if m.complete[len(m.complete)-1] == len(m.complete)-1 { + return m.complete[len(m.complete)-1] + } else { + for i := len(m.complete) - 2; i >= 0; i-- { + if hasNoGap(m.complete[:i+1]) { + return m.complete[i] + } + } + } + + return -1 +} + +func (m *taskStatusManager) pushPending(tx int) { + m.pending = insertInList(m.pending, tx) +} + +func removeFromList(l []int, v int, expect bool) []int { + x := sort.SearchInts(l, v) + if x == -1 || l[x] != v { + if expect { + panic(fmt.Errorf("should not happen - element expected in list")) + } + + return l + } + + switch x { + case 0: + return l[1:] + case len(l) - 1: + return l[:len(l)-1] + default: + return append(l[:x], l[x+1:]...) + } +} + +func (m *taskStatusManager) markComplete(tx int) { + m.inProgress = removeFromList(m.inProgress, tx, true) + m.complete = insertInList(m.complete, tx) +} + +func (m *taskStatusManager) minPending() int { + if len(m.pending) == 0 { + return -1 + } else { + return m.pending[0] + } +} + +func (m *taskStatusManager) countComplete() int { + return len(m.complete) +} + +func (m *taskStatusManager) addDependencies(blocker int, dependent int) bool { + if blocker < 0 || blocker >= dependent { + return false + } + + curblockers := m.blocker[dependent] + + if m.checkComplete(blocker) { + // Blocker has already completed + delete(curblockers, blocker) + + return len(curblockers) > 0 + } + + if _, ok := m.dependency[blocker]; !ok { + m.dependency[blocker] = make(map[int]bool) + } + + m.dependency[blocker][dependent] = true + curblockers[blocker] = true + + return true +} + +func (m *taskStatusManager) isBlocked(tx int) bool { + return len(m.blocker[tx]) > 0 +} + +func (m *taskStatusManager) removeDependency(tx int) { + if deps, ok := m.dependency[tx]; ok && len(deps) > 0 { + for k := range deps { + delete(m.blocker[k], tx) + + if len(m.blocker[k]) == 0 { + if !m.checkComplete(k) && !m.checkPending(k) && !m.checkInProgress(k) { + m.pushPending(k) + } + } + } + + delete(m.dependency, tx) + } +} + +func (m *taskStatusManager) clearInProgress(tx int) { + m.inProgress = removeFromList(m.inProgress, tx, true) +} + +func (m *taskStatusManager) checkInProgress(tx int) bool { + x := sort.SearchInts(m.inProgress, tx) + if x < len(m.inProgress) && m.inProgress[x] == tx { + return true + } + + return false +} + +func (m *taskStatusManager) checkPending(tx int) bool { + x := sort.SearchInts(m.pending, tx) + if x < len(m.pending) && m.pending[x] == tx { + return true + } + + return false +} + +func (m *taskStatusManager) checkComplete(tx int) bool { + x := sort.SearchInts(m.complete, tx) + if x < len(m.complete) && m.complete[x] == tx { + return true + } + + return false +} + +// getRevalidationRange: this range will be all tasks from tx (inclusive) that are not currently in progress up to the +// +// 'all complete' limit +func (m *taskStatusManager) getRevalidationRange(txFrom int) (ret []int) { + max := m.maxAllComplete() // haven't learned to trust compilers :) + for x := txFrom; x <= max; x++ { + if !m.checkInProgress(x) { + ret = append(ret, x) + } + } + + return +} + +func (m *taskStatusManager) pushPendingSet(set []int) { + for _, v := range set { + if m.checkComplete(v) { + m.clearComplete(v) + } + + m.pushPending(v) + } +} + +func (m *taskStatusManager) clearComplete(tx int) { + m.complete = removeFromList(m.complete, tx, false) +} + +func (m *taskStatusManager) clearPending(tx int) { + m.pending = removeFromList(m.pending, tx, false) +} diff --git a/core/blockstm/status_test.go b/core/blockstm/status_test.go new file mode 100644 index 0000000000..aff00d9a2f --- /dev/null +++ b/core/blockstm/status_test.go @@ -0,0 +1,82 @@ +package blockstm + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestStatusBasics(t *testing.T) { + t.Parallel() + + s := makeStatusManager(10) + + x := s.takeNextPending() + require.Equal(t, 0, x) + require.True(t, s.checkInProgress(x)) + + x = s.takeNextPending() + require.Equal(t, 1, x) + require.True(t, s.checkInProgress(x)) + + x = s.takeNextPending() + require.Equal(t, 2, x) + require.True(t, s.checkInProgress(x)) + + s.markComplete(0) + require.False(t, s.checkInProgress(0)) + s.markComplete(1) + s.markComplete(2) + require.False(t, s.checkInProgress(1)) + require.False(t, s.checkInProgress(2)) + require.Equal(t, 2, s.maxAllComplete()) + + x = s.takeNextPending() + require.Equal(t, 3, x) + + x = s.takeNextPending() + require.Equal(t, 4, x) + + s.markComplete(x) + require.False(t, s.checkInProgress(4)) + require.Equal(t, 2, s.maxAllComplete(), "zero should still be min complete") + + exp := []int{1, 2} + require.Equal(t, exp, s.getRevalidationRange(1)) +} + +func TestMaxComplete(t *testing.T) { + t.Parallel() + + s := makeStatusManager(10) + + for { + tx := s.takeNextPending() + + if tx == -1 { + break + } + + if tx != 7 { + s.markComplete(tx) + } + } + + require.Equal(t, 6, s.maxAllComplete()) + + s2 := makeStatusManager(10) + + for { + tx := s2.takeNextPending() + + if tx == -1 { + break + } + } + s2.markComplete(2) + s2.markComplete(4) + require.Equal(t, -1, s2.maxAllComplete()) + + s2.complete = insertInList(s2.complete, 4) + require.Equal(t, 2, s2.countComplete()) +} diff --git a/core/blockstm/txio.go b/core/blockstm/txio.go new file mode 100644 index 0000000000..19955fb152 --- /dev/null +++ b/core/blockstm/txio.go @@ -0,0 +1,106 @@ +package blockstm + +const ( + ReadKindMap = 0 + ReadKindStorage = 1 +) + +type ReadDescriptor struct { + Path Key + Kind int + V Version +} + +type WriteDescriptor struct { + Path Key + V Version + Val interface{} +} + +type TxnInput []ReadDescriptor +type TxnOutput []WriteDescriptor + +// hasNewWrite: returns true if the current set has a new write compared to the input +func (txo TxnOutput) hasNewWrite(cmpSet []WriteDescriptor) bool { + if len(txo) == 0 { + return false + } else if len(cmpSet) == 0 || len(txo) > len(cmpSet) { + return true + } + + cmpMap := map[Key]bool{cmpSet[0].Path: true} + + for i := 1; i < len(cmpSet); i++ { + cmpMap[cmpSet[i].Path] = true + } + + for _, v := range txo { + if !cmpMap[v.Path] { + return true + } + } + + return false +} + +type TxnInputOutput struct { + inputs []TxnInput + outputs []TxnOutput // write sets that should be checked during validation + outputsSet []map[Key]struct{} + allOutputs []TxnOutput // entire write sets in MVHashMap. allOutputs should always be a parent set of outputs +} + +func (io *TxnInputOutput) ReadSet(txnIdx int) []ReadDescriptor { + return io.inputs[txnIdx] +} + +func (io *TxnInputOutput) WriteSet(txnIdx int) []WriteDescriptor { + return io.outputs[txnIdx] +} + +func (io *TxnInputOutput) AllWriteSet(txnIdx int) []WriteDescriptor { + return io.allOutputs[txnIdx] +} + +func (io *TxnInputOutput) HasWritten(txnIdx int, k Key) bool { + _, ok := io.outputsSet[txnIdx][k] + return ok +} + +func MakeTxnInputOutput(numTx int) *TxnInputOutput { + return &TxnInputOutput{ + inputs: make([]TxnInput, numTx), + outputs: make([]TxnOutput, numTx), + outputsSet: make([]map[Key]struct{}, numTx), + allOutputs: make([]TxnOutput, numTx), + } +} + +func (io *TxnInputOutput) recordRead(txId int, input []ReadDescriptor) { + io.inputs[txId] = input +} + +func (io *TxnInputOutput) recordWrite(txId int, output []WriteDescriptor) { + io.outputs[txId] = output + io.outputsSet[txId] = make(map[Key]struct{}, len(output)) + + for _, v := range output { + io.outputsSet[txId][v.Path] = struct{}{} + } +} + +func (io *TxnInputOutput) recordAllWrite(txId int, output []WriteDescriptor) { + io.allOutputs[txId] = output +} + +func (io *TxnInputOutput) RecordReadAtOnce(inputs [][]ReadDescriptor) { + for ind, val := range inputs { + io.inputs[ind] = val + } +} + +func (io *TxnInputOutput) RecordAllWriteAtOnce(outputs [][]WriteDescriptor) { + for ind, val := range outputs { + io.allOutputs[ind] = val + } +} diff --git a/core/bor_blockchain.go b/core/bor_blockchain.go new file mode 100644 index 0000000000..d6a0226b02 --- /dev/null +++ b/core/bor_blockchain.go @@ -0,0 +1,31 @@ +package core + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" +) + +// GetBorReceiptByHash retrieves the bor block receipt in a given block. +func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt { + if receipt, ok := bc.borReceiptsCache.Get(hash); ok { + return receipt + } + + // read header from hash + number := rawdb.ReadHeaderNumber(bc.db, hash) + if number == nil { + return nil + } + + // read bor reciept by hash and number + receipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig) + if receipt == nil { + return nil + } + + // add into bor receipt cache + bc.borReceiptsCache.Add(hash, receipt) + + return receipt +} diff --git a/core/bor_events.go b/core/bor_events.go new file mode 100644 index 0000000000..68f916fe79 --- /dev/null +++ b/core/bor_events.go @@ -0,0 +1,23 @@ +package core + +import ( + "github.com/ethereum/go-ethereum/core/types" +) + +// StateSyncEvent represents state sync events +type StateSyncEvent struct { + Data *types.StateSyncData +} + +var ( + Chain2HeadReorgEvent = "reorg" + Chain2HeadCanonicalEvent = "head" + Chain2HeadForkEvent = "fork" +) + +// For tracking reorgs related information +type Chain2HeadEvent struct { + NewChain []*types.Block + OldChain []*types.Block + Type string +} diff --git a/core/bor_fee_log.go b/core/bor_fee_log.go new file mode 100644 index 0000000000..50119644ca --- /dev/null +++ b/core/bor_fee_log.go @@ -0,0 +1,120 @@ +package core + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" +) + +var transferLogSig = common.HexToHash("0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4") +var transferFeeLogSig = common.HexToHash("0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63") +var feeAddress = common.HexToAddress("0x0000000000000000000000000000000000001010") +var bigZero = big.NewInt(0) + +func GetFeeAddress() common.Address { + return feeAddress +} + +// AddTransferLog adds transfer log into state +func AddTransferLog( + state vm.StateDB, + + sender, + recipient common.Address, + + amount, + input1, + input2, + output1, + output2 *big.Int, +) { + addTransferLog( + state, + transferLogSig, + + sender, + recipient, + + amount, + input1, + input2, + output1, + output2, + ) +} + +// AddFeeTransferLog adds transfer log into state +// Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 +func AddFeeTransferLog( + state vm.StateDB, + + sender, + recipient common.Address, + + amount, + input1, + input2, + output1, + output2 *big.Int, +) { + addTransferLog( + state, + transferFeeLogSig, + + sender, + recipient, + + amount, + input1, + input2, + output1, + output2, + ) +} + +// addTransferLog adds transfer log into state +func addTransferLog( + state vm.StateDB, + eventSig common.Hash, + + sender, + recipient common.Address, + + amount, + input1, + input2, + output1, + output2 *big.Int, +) { + // ignore if amount is 0 + if amount.Cmp(bigZero) <= 0 { + return + } + + dataInputs := []*big.Int{ + amount, + input1, + input2, + output1, + output2, + } + + var data []byte + for _, v := range dataInputs { + data = append(data, common.LeftPadBytes(v.Bytes(), 32)...) + } + + // add transfer log + state.AddLog(&types.Log{ + Address: feeAddress, + Topics: []common.Hash{ + eventSig, + feeAddress.Hash(), + sender.Hash(), + recipient.Hash(), + }, + Data: data, + }) +} diff --git a/core/forkchoice.go b/core/forkchoice.go index b293c851bf..edf0e1f403 100644 --- a/core/forkchoice.go +++ b/core/forkchoice.go @@ -17,15 +17,13 @@ package core import ( - crand "crypto/rand" "errors" + "github.com/maticnetwork/crand" "math/big" - mrand "math/rand" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" ) @@ -47,25 +45,30 @@ type ChainReader interface { // for all other proof-of-work networks. type ForkChoice struct { chain ChainReader - rand *mrand.Rand + rand Floater // preserve is a helper function used in td fork choice. // Miners will prefer to choose the local mined block if the // local td is equal to the extern one. It can be nil for light // client preserve func(header *types.Header) bool + + validator ethereum.ChainValidator +} + +type Floater interface { + Float64() float64 } -func NewForkChoice(chainReader ChainReader, preserve func(header *types.Header) bool) *ForkChoice { +func NewForkChoice(chainReader ChainReader, preserve func(header *types.Header) bool, validator ethereum.ChainValidator) *ForkChoice { // Seed a fast but crypto originating random generator - seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) - if err != nil { - log.Crit("Failed to initialize random seed", "err", err) - } + r := crand.NewRand() + return &ForkChoice{ - chain: chainReader, - rand: mrand.New(mrand.NewSource(seed.Int64())), - preserve: preserve, + chain: chainReader, + rand: r, + preserve: preserve, + validator: validator, } } @@ -111,3 +114,13 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, extern *types.Header) (b } return reorg, nil } + +// ValidateReorg calls the chain validator service to check if the reorg is valid or not +func (f *ForkChoice) ValidateReorg(current *types.Header, chain []*types.Header) (bool, error) { + // Call the bor chain validator service + if f.validator != nil { + return f.validator.IsValidChain(current, chain) + } + + return true, nil +} diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go new file mode 100644 index 0000000000..831890071a --- /dev/null +++ b/core/parallel_state_processor.go @@ -0,0 +1,429 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package core + +import ( + "context" + "fmt" + "math/big" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/consensus/misc" + "github.com/ethereum/go-ethereum/core/blockstm" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" +) + +type ParallelEVMConfig struct { + Enable bool + SpeculativeProcesses int +} + +// StateProcessor is a basic Processor, which takes care of transitioning +// state from one point to another. +// +// StateProcessor implements Processor. +type ParallelStateProcessor struct { + config *params.ChainConfig // Chain configuration options + bc *BlockChain // Canonical block chain + engine consensus.Engine // Consensus engine used for block rewards +} + +// NewParallelStateProcessor initialises a new StateProcessor. +func NewParallelStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *ParallelStateProcessor { + return &ParallelStateProcessor{ + config: config, + bc: bc, + engine: engine, + } +} + +type ExecutionTask struct { + msg Message + config *params.ChainConfig + + gasLimit uint64 + blockNumber *big.Int + blockHash common.Hash + tx *types.Transaction + index int + statedb *state.StateDB // State database that stores the modified values after tx execution. + cleanStateDB *state.StateDB // A clean copy of the initial statedb. It should not be modified. + finalStateDB *state.StateDB // The final statedb. + header *types.Header + blockChain *BlockChain + evmConfig vm.Config + result *ExecutionResult + shouldDelayFeeCal *bool + shouldRerunWithoutFeeDelay bool + sender common.Address + totalUsedGas *uint64 + receipts *types.Receipts + allLogs *[]*types.Log + + // length of dependencies -> 2 + k (k = a whole number) + // first 2 element in dependencies -> transaction index, and flag representing if delay is allowed or not + // (0 -> delay is not allowed, 1 -> delay is allowed) + // next k elements in dependencies -> transaction indexes on which transaction i is dependent on + dependencies []int + coinbase common.Address + blockContext vm.BlockContext +} + +func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (err error) { + task.statedb = task.cleanStateDB.Copy() + task.statedb.SetTxContext(task.tx.Hash(), task.index) + task.statedb.SetMVHashmap(mvh) + task.statedb.SetIncarnation(incarnation) + + evm := vm.NewEVM(task.blockContext, vm.TxContext{}, task.statedb, task.config, task.evmConfig) + + // Create a new context to be used in the EVM environment. + txContext := NewEVMTxContext(&task.msg) + evm.Reset(txContext, task.statedb) + + defer func() { + if r := recover(); r != nil { + // In some pre-matured executions, EVM will panic. Recover from panic and retry the execution. + log.Debug("Recovered from EVM failure.", "Error:", r) + + err = blockstm.ErrExecAbortError{Dependency: task.statedb.DepTxIndex()} + + return + } + }() + + // Apply the transaction to the current state (included in the env). + if *task.shouldDelayFeeCal { + task.result, err = ApplyMessageNoFeeBurnOrTip(evm, task.msg, new(GasPool).AddGas(task.gasLimit), nil) + + if task.result == nil || err != nil { + return blockstm.ErrExecAbortError{Dependency: task.statedb.DepTxIndex(), OriginError: err} + } + + reads := task.statedb.MVReadMap() + + if _, ok := reads[blockstm.NewSubpathKey(task.blockContext.Coinbase, state.BalancePath)]; ok { + log.Info("Coinbase is in MVReadMap", "address", task.blockContext.Coinbase) + + task.shouldRerunWithoutFeeDelay = true + } + + if _, ok := reads[blockstm.NewSubpathKey(task.result.BurntContractAddress, state.BalancePath)]; ok { + log.Info("BurntContractAddress is in MVReadMap", "address", task.result.BurntContractAddress) + + task.shouldRerunWithoutFeeDelay = true + } + } else { + task.result, err = ApplyMessage(evm, &task.msg, new(GasPool).AddGas(task.gasLimit), nil) + } + + if task.statedb.HadInvalidRead() || err != nil { + err = blockstm.ErrExecAbortError{Dependency: task.statedb.DepTxIndex(), OriginError: err} + return + } + + task.statedb.Finalise(task.config.IsEIP158(task.blockNumber)) + + return +} + +func (task *ExecutionTask) MVReadList() []blockstm.ReadDescriptor { + return task.statedb.MVReadList() +} + +func (task *ExecutionTask) MVWriteList() []blockstm.WriteDescriptor { + return task.statedb.MVWriteList() +} + +func (task *ExecutionTask) MVFullWriteList() []blockstm.WriteDescriptor { + return task.statedb.MVFullWriteList() +} + +func (task *ExecutionTask) Sender() common.Address { + return task.sender +} + +func (task *ExecutionTask) Hash() common.Hash { + return task.tx.Hash() +} + +func (task *ExecutionTask) Dependencies() []int { + return task.dependencies +} + +func (task *ExecutionTask) Settle() { + task.finalStateDB.SetTxContext(task.tx.Hash(), task.index) + + coinbaseBalance := task.finalStateDB.GetBalance(task.coinbase) + + task.finalStateDB.ApplyMVWriteSet(task.statedb.MVFullWriteList()) + + for _, l := range task.statedb.GetLogs(task.tx.Hash(), task.blockNumber.Uint64(), task.blockHash) { + task.finalStateDB.AddLog(l) + } + + if *task.shouldDelayFeeCal { + if task.config.IsLondon(task.blockNumber) { + task.finalStateDB.AddBalance(task.result.BurntContractAddress, task.result.FeeBurnt) + } + + task.finalStateDB.AddBalance(task.coinbase, task.result.FeeTipped) + output1 := new(big.Int).SetBytes(task.result.SenderInitBalance.Bytes()) + output2 := new(big.Int).SetBytes(coinbaseBalance.Bytes()) + + // Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 + // add transfer log + AddFeeTransferLog( + task.finalStateDB, + + task.msg.From, + task.coinbase, + + task.result.FeeTipped, + task.result.SenderInitBalance, + coinbaseBalance, + output1.Sub(output1, task.result.FeeTipped), + output2.Add(output2, task.result.FeeTipped), + ) + } + + for k, v := range task.statedb.Preimages() { + task.finalStateDB.AddPreimage(k, v) + } + + // Update the state with pending changes. + var root []byte + + if task.config.IsByzantium(task.blockNumber) { + task.finalStateDB.Finalise(true) + } else { + root = task.finalStateDB.IntermediateRoot(task.config.IsEIP158(task.blockNumber)).Bytes() + } + + *task.totalUsedGas += task.result.UsedGas + + // Create a new receipt for the transaction, storing the intermediate root and gas used + // by the tx. + receipt := &types.Receipt{Type: task.tx.Type(), PostState: root, CumulativeGasUsed: *task.totalUsedGas} + if task.result.Failed() { + receipt.Status = types.ReceiptStatusFailed + } else { + receipt.Status = types.ReceiptStatusSuccessful + } + + receipt.TxHash = task.tx.Hash() + receipt.GasUsed = task.result.UsedGas + + // If the transaction created a contract, store the creation address in the receipt. + if task.msg.To == nil { + receipt.ContractAddress = crypto.CreateAddress(task.msg.From, task.tx.Nonce()) + } + + // Set the receipt logs and create the bloom filter. + receipt.Logs = task.finalStateDB.GetLogs(task.tx.Hash(), task.blockNumber.Uint64(), task.blockHash) + receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) + receipt.BlockHash = task.blockHash + receipt.BlockNumber = task.blockNumber + receipt.TransactionIndex = uint(task.finalStateDB.TxIndex()) + + *task.receipts = append(*task.receipts, receipt) + *task.allLogs = append(*task.allLogs, receipt.Logs...) +} + +var parallelizabilityTimer = metrics.NewRegisteredTimer("block/parallelizability", nil) + +// Process processes the state changes according to the Ethereum rules by running +// the transaction messages using the statedb and applying any rewards to both +// the processor (coinbase) and any included uncles. +// +// Process returns the receipts and logs accumulated during the process and +// returns the amount of gas that was used in the process. If any of the +// transactions failed to execute due to insufficient gas it will return an error. +// nolint:gocognit +func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config, interruptCtx context.Context) (types.Receipts, []*types.Log, uint64, error) { + var ( + receipts types.Receipts + header = block.Header() + blockHash = block.Hash() + blockNumber = block.Number() + allLogs []*types.Log + usedGas = new(uint64) + metadata bool + ) + + // Mutate the block and state according to any hard-fork specs + if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 { + misc.ApplyDAOHardFork(statedb) + } + + tasks := make([]blockstm.ExecTask, 0, len(block.Transactions())) + + shouldDelayFeeCal := true + + coinbase, _ := p.bc.Engine().Author(header) + + blockTxDependency := block.GetTxDependency() + + deps := GetDeps(blockTxDependency) + + if blockTxDependency != nil { + metadata = true + } + + blockContext := NewEVMBlockContext(header, p.bc, nil) + + // Iterate over and process the individual transactions + for i, tx := range block.Transactions() { + msg, err := TransactionToMessage(tx, types.MakeSigner(p.config, header.Number), header.BaseFee) + if err != nil { + log.Error("error creating message", "err", err) + return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) + } + + cleansdb := statedb.Copy() + + if msg.From == coinbase { + shouldDelayFeeCal = false + } + + if len(blockTxDependency) != len(block.Transactions()) { + task := &ExecutionTask{ + msg: *msg, + config: p.config, + gasLimit: block.GasLimit(), + blockNumber: blockNumber, + blockHash: blockHash, + tx: tx, + index: i, + cleanStateDB: cleansdb, + finalStateDB: statedb, + blockChain: p.bc, + header: header, + evmConfig: cfg, + shouldDelayFeeCal: &shouldDelayFeeCal, + sender: msg.From, + totalUsedGas: usedGas, + receipts: &receipts, + allLogs: &allLogs, + dependencies: deps[i], + coinbase: coinbase, + blockContext: blockContext, + } + + tasks = append(tasks, task) + } else { + task := &ExecutionTask{ + msg: *msg, + config: p.config, + gasLimit: block.GasLimit(), + blockNumber: blockNumber, + blockHash: blockHash, + tx: tx, + index: i, + cleanStateDB: cleansdb, + finalStateDB: statedb, + blockChain: p.bc, + header: header, + evmConfig: cfg, + shouldDelayFeeCal: &shouldDelayFeeCal, + sender: msg.From, + totalUsedGas: usedGas, + receipts: &receipts, + allLogs: &allLogs, + dependencies: nil, + coinbase: coinbase, + blockContext: blockContext, + } + + tasks = append(tasks, task) + } + } + + backupStateDB := statedb.Copy() + + profile := false + result, err := blockstm.ExecuteParallel(tasks, profile, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx) + + if err == nil && profile && result.Deps != nil { + _, weight := result.Deps.LongestPath(*result.Stats) + + serialWeight := uint64(0) + + for i := 0; i < len(result.Deps.GetVertices()); i++ { + serialWeight += (*result.Stats)[i].End - (*result.Stats)[i].Start + } + + parallelizabilityTimer.Update(time.Duration(serialWeight * 100 / weight)) + } + + for _, task := range tasks { + task := task.(*ExecutionTask) + if task.shouldRerunWithoutFeeDelay { + shouldDelayFeeCal = false + + statedb.StopPrefetcher() + *statedb = *backupStateDB + + allLogs = []*types.Log{} + receipts = types.Receipts{} + usedGas = new(uint64) + + for _, t := range tasks { + t := t.(*ExecutionTask) + t.finalStateDB = backupStateDB + t.allLogs = &allLogs + t.receipts = &receipts + t.totalUsedGas = usedGas + } + + _, err = blockstm.ExecuteParallel(tasks, false, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx) + + break + } + } + + if err != nil { + return nil, nil, 0, err + } + + // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) + p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), nil) + + return receipts, allLogs, *usedGas, nil +} + +func GetDeps(txDependency [][]uint64) map[int][]int { + deps := make(map[int][]int) + + for i := 0; i <= len(txDependency)-1; i++ { + deps[i] = []int{} + + for j := 0; j <= len(txDependency[i])-1; j++ { + deps[i] = append(deps[i], int(txDependency[i][j])) + } + } + + return deps +} diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 3d0f36ba76..ae31e34e39 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -36,7 +36,8 @@ import ( // ReadCanonicalHash retrieves the hash assigned to a canonical block number. func ReadCanonicalHash(db ethdb.Reader, number uint64) common.Hash { var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { data, _ = reader.Ancient(ChainFreezerHashTable, number) if len(data) == 0 { // Get it by hash from leveldb @@ -347,7 +348,8 @@ func ReadHeaderRange(db ethdb.Reader, number uint64, count uint64) []rlp.RawValu // ReadHeaderRLP retrieves a block header in its raw RLP database encoding. func ReadHeaderRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { // First try to look up the data in ancient database. Extra hash // comparison is necessary since ancient database only maintains // the canonical data. @@ -440,7 +442,8 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue // comparison is necessary since ancient database only maintains // the canonical data. var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { // Check if the data is in ancients if isCanon(reader, number, hash) { data, _ = reader.Ancient(ChainFreezerBodiesTable, number) @@ -457,7 +460,8 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue // block at number, in RLP encoding. func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue { var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { data, _ = reader.Ancient(ChainFreezerBodiesTable, number) if len(data) > 0 { return nil @@ -523,7 +527,8 @@ func DeleteBody(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { // ReadTdRLP retrieves a block's total difficulty corresponding to the hash in RLP encoding. func ReadTdRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { // Check if the data is in ancients if isCanon(reader, number, hash) { data, _ = reader.Ancient(ChainFreezerDifficultyTable, number) @@ -583,7 +588,8 @@ func HasReceipts(db ethdb.Reader, hash common.Hash, number uint64) bool { // ReadReceiptsRLP retrieves all the transaction receipts belonging to a block in RLP encoding. func ReadReceiptsRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { var data []byte - db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + + _ = db.ReadAncients(func(reader ethdb.AncientReaderOp) error { // Check if the data is in ancients if isCanon(reader, number, hash) { data, _ = reader.Ancient(ChainFreezerReceiptTable, number) @@ -732,6 +738,12 @@ func ReadLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.C } receipts := []*receiptLogs{} if err := rlp.DecodeBytes(data, &receipts); err != nil { + // Receipts might be in the legacy format, try decoding that. + // TODO: to be removed after users migrated + if logs := readLegacyLogs(db, hash, number, config); logs != nil { + return logs + } + log.Error("Invalid receipt array RLP", "hash", hash, "err", err) return nil } @@ -740,6 +752,24 @@ func ReadLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.C for i, receipt := range receipts { logs[i] = receipt.Logs } + + return logs +} + +// readLegacyLogs is a temporary workaround for when trying to read logs +// from a block which has its receipt stored in the legacy format. It'll +// be removed after users have migrated their freezer databases. +func readLegacyLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) [][]*types.Log { + receipts := ReadReceipts(db, hash, number, config) + if receipts == nil { + return nil + } + + logs := make([][]*types.Log, len(receipts)) + for i, receipt := range receipts { + logs[i] = receipt.Logs + } + return logs } @@ -768,10 +798,11 @@ func WriteBlock(db ethdb.KeyValueWriter, block *types.Block) { } // WriteAncientBlocks writes entire block data into ancient store and returns the total written size. -func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts []types.Receipts, td *big.Int) (int64, error) { +func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts []types.Receipts, borReceipts []types.Receipts, td *big.Int) (int64, error) { var ( - tdSum = new(big.Int).Set(td) - stReceipts []*types.ReceiptForStorage + tdSum = new(big.Int).Set(td) + stReceipts []*types.ReceiptForStorage + borStReceipts []*types.ReceiptForStorage ) return db.ModifyAncients(func(op ethdb.AncientWriteOp) error { for i, block := range blocks { @@ -780,11 +811,19 @@ func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts for _, receipt := range receipts[i] { stReceipts = append(stReceipts, (*types.ReceiptForStorage)(receipt)) } + + // Convert bor receipts to storage format and sum up total difficulty. + borStReceipts = borStReceipts[:0] + for _, borReceipt := range borReceipts[i] { + borStReceipts = append(borStReceipts, (*types.ReceiptForStorage)(borReceipt)) + } + header := block.Header() if i > 0 { tdSum.Add(tdSum, header.Difficulty) } - if err := writeAncientBlock(op, block, header, stReceipts, tdSum); err != nil { + + if err := writeAncientBlock(op, block, header, stReceipts, borStReceipts, tdSum); err != nil { return err } } @@ -792,7 +831,7 @@ func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts }) } -func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *types.Header, receipts []*types.ReceiptForStorage, td *big.Int) error { +func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *types.Header, receipts []*types.ReceiptForStorage, borReceipts []*types.ReceiptForStorage, td *big.Int) error { num := block.NumberU64() if err := op.AppendRaw(ChainFreezerHashTable, num, block.Hash().Bytes()); err != nil { return fmt.Errorf("can't add block %d hash: %v", num, err) @@ -809,6 +848,11 @@ func writeAncientBlock(op ethdb.AncientWriteOp, block *types.Block, header *type if err := op.Append(ChainFreezerDifficultyTable, num, td); err != nil { return fmt.Errorf("can't append block %d total difficulty: %v", num, err) } + + if err := op.Append(freezerBorReceiptTable, num, borReceipts); err != nil { + return fmt.Errorf("can't append block %d borReceipts: %v", num, err) + } + return nil } @@ -818,6 +862,9 @@ func DeleteBlock(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { DeleteHeader(db, hash, number) DeleteBody(db, hash, number) DeleteTd(db, hash, number) + + // delete bor receipt + DeleteBorReceipt(db, hash, number) } // DeleteBlockWithoutNumber removes all block data associated with a hash, except @@ -827,6 +874,9 @@ func DeleteBlockWithoutNumber(db ethdb.KeyValueWriter, hash common.Hash, number deleteHeaderWithoutNumber(db, hash, number) DeleteBody(db, hash, number) DeleteTd(db, hash, number) + + // delete bor receipt + DeleteBorReceipt(db, hash, number) } const badBlockToKeep = 10 diff --git a/core/rawdb/bor_receipt.go b/core/rawdb/bor_receipt.go new file mode 100644 index 0000000000..f3242b51ce --- /dev/null +++ b/core/rawdb/bor_receipt.go @@ -0,0 +1,212 @@ +package rawdb + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" +) + +var ( + // bor receipt key + borReceiptKey = types.BorReceiptKey + + // borTxLookupPrefix + hash -> transaction/receipt lookup metadata + borTxLookupPrefix = []byte(borTxLookupPrefixStr) +) + +const ( + borTxLookupPrefixStr = "matic-bor-tx-lookup-" + + // freezerBorReceiptTable indicates the name of the freezer bor receipts table. + freezerBorReceiptTable = "matic-bor-receipts" +) + +// borTxLookupKey = borTxLookupPrefix + bor tx hash +func borTxLookupKey(hash common.Hash) []byte { + return append(borTxLookupPrefix, hash.Bytes()...) +} + +func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue { + var data []byte + + err := db.ReadAncients(func(reader ethdb.AncientReaderOp) error { + // Check if the data is in ancients + if isCanon(reader, number, hash) { + data, _ = reader.Ancient(freezerBorReceiptTable, number) + + return nil + } + + // If not, try reading from leveldb + data, _ = db.Get(borReceiptKey(number, hash)) + + return nil + }) + + if err != nil { + log.Warn("during ReadBorReceiptRLP", "number", number, "hash", hash, "err", err) + } + + return data +} + +// ReadRawBorReceipt retrieves the block receipt belonging to a block. +// The receipt metadata fields are not guaranteed to be populated, so they +// should not be used. Use ReadBorReceipt instead if the metadata is needed. +func ReadRawBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types.Receipt { + // Retrieve the flattened receipt slice + data := ReadBorReceiptRLP(db, hash, number) + if data == nil || len(data) == 0 { + return nil + } + + // Convert the receipts from their storage form to their internal representation + var storageReceipt types.ReceiptForStorage + if err := rlp.DecodeBytes(data, &storageReceipt); err != nil { + log.Error("Invalid receipt array RLP", "hash", hash, "err", err) + return nil + } + + return (*types.Receipt)(&storageReceipt) +} + +// ReadBorReceipt retrieves all the bor block receipts belonging to a block, including +// its correspoinding metadata fields. If it is unable to populate these metadata +// fields then nil is returned. +func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) *types.Receipt { + if config != nil && config.Bor != nil && config.Bor.Sprint != nil && !config.Bor.IsSprintStart(number) { + return nil + } + + // We're deriving many fields from the block body, retrieve beside the receipt + borReceipt := ReadRawBorReceipt(db, hash, number) + if borReceipt == nil { + return nil + } + + // We're deriving many fields from the block body, retrieve beside the receipt + receipts := ReadRawReceipts(db, hash, number) + if receipts == nil { + return nil + } + + body := ReadBody(db, hash, number) + if body == nil { + log.Error("Missing body but have bor receipt", "hash", hash, "number", number) + return nil + } + + if err := types.DeriveFieldsForBorReceipt(borReceipt, hash, number, receipts); err != nil { + log.Error("Failed to derive bor receipt fields", "hash", hash, "number", number, "err", err) + return nil + } + + return borReceipt +} + +// WriteBorReceipt stores all the bor receipt belonging to a block. +func WriteBorReceipt(db ethdb.KeyValueWriter, hash common.Hash, number uint64, borReceipt *types.ReceiptForStorage) { + // Convert the bor receipt into their storage form and serialize them + bytes, err := rlp.EncodeToBytes(borReceipt) + if err != nil { + log.Crit("Failed to encode bor receipt", "err", err) + } + + // Store the flattened receipt slice + if err := db.Put(borReceiptKey(number, hash), bytes); err != nil { + log.Crit("Failed to store bor receipt", "err", err) + } +} + +// DeleteBorReceipt removes receipt data associated with a block hash. +func DeleteBorReceipt(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { + key := borReceiptKey(number, hash) + + if err := db.Delete(key); err != nil { + log.Crit("Failed to delete bor receipt", "err", err) + } +} + +// ReadBorTransactionWithBlockHash retrieves a specific bor (fake) transaction by tx hash and block hash, along with +// its added positional metadata. +func ReadBorTransactionWithBlockHash(db ethdb.Reader, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) { + blockNumber := ReadBorTxLookupEntry(db, txHash) + if blockNumber == nil { + return nil, common.Hash{}, 0, 0 + } + + body := ReadBody(db, blockHash, *blockNumber) + if body == nil { + log.Error("Transaction referenced missing", "number", blockNumber, "hash", blockHash) + return nil, common.Hash{}, 0, 0 + } + + // fetch receipt and return it + return types.NewBorTransaction(), blockHash, *blockNumber, uint64(len(body.Transactions)) +} + +// ReadBorTransaction retrieves a specific bor (fake) transaction by hash, along with +// its added positional metadata. +func ReadBorTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) { + blockNumber := ReadBorTxLookupEntry(db, hash) + if blockNumber == nil { + return nil, common.Hash{}, 0, 0 + } + + blockHash := ReadCanonicalHash(db, *blockNumber) + if blockHash == (common.Hash{}) { + return nil, common.Hash{}, 0, 0 + } + + body := ReadBody(db, blockHash, *blockNumber) + if body == nil { + log.Error("Transaction referenced missing", "number", blockNumber, "hash", blockHash) + return nil, common.Hash{}, 0, 0 + } + + // fetch receipt and return it + return types.NewBorTransaction(), blockHash, *blockNumber, uint64(len(body.Transactions)) +} + +// +// Indexes for reverse lookup +// + +// ReadBorTxLookupEntry retrieves the positional metadata associated with a transaction +// hash to allow retrieving the bor transaction or bor receipt using tx hash. +func ReadBorTxLookupEntry(db ethdb.Reader, txHash common.Hash) *uint64 { + data, _ := db.Get(borTxLookupKey(txHash)) + if len(data) == 0 { + return nil + } + + number := new(big.Int).SetBytes(data).Uint64() + + return &number +} + +// WriteBorTxLookupEntry stores a positional metadata for bor transaction using block hash and block number +func WriteBorTxLookupEntry(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { + txHash := types.GetDerivedBorTxHash(borReceiptKey(number, hash)) + if err := db.Put(borTxLookupKey(txHash), big.NewInt(0).SetUint64(number).Bytes()); err != nil { + log.Crit("Failed to store bor transaction lookup entry", "err", err) + } +} + +// DeleteBorTxLookupEntry removes bor transaction data associated with block hash and block number +func DeleteBorTxLookupEntry(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { + txHash := types.GetDerivedBorTxHash(borReceiptKey(number, hash)) + DeleteBorTxLookupEntryByTxHash(db, txHash) +} + +// DeleteBorTxLookupEntryByTxHash removes bor transaction data associated with a bor tx hash. +func DeleteBorTxLookupEntryByTxHash(db ethdb.KeyValueWriter, txHash common.Hash) { + if err := db.Delete(borTxLookupKey(txHash)); err != nil { + log.Crit("Failed to delete bor transaction lookup entry", "err", err) + } +} diff --git a/core/rawdb/checkpoint.go b/core/rawdb/checkpoint.go new file mode 100644 index 0000000000..af1658b4fc --- /dev/null +++ b/core/rawdb/checkpoint.go @@ -0,0 +1,33 @@ +// nolint +package rawdb + +import ( + "errors" + + "github.com/ethereum/go-ethereum/common" +) + +var ( + lastCheckpoint = []byte("LastCheckpoint") + + ErrEmptyLastFinality = errors.New("empty response while getting last finality") + ErrIncorrectFinality = errors.New("last checkpoint in the DB is incorrect") + ErrIncorrectFinalityToStore = errors.New("failed to marshal the last finality struct") + ErrDBNotResponding = errors.New("failed to store the last finality struct") + ErrIncorrectLockFieldToStore = errors.New("failed to marshal the lockField struct ") + ErrIncorrectLockField = errors.New("lock field in the DB is incorrect") + ErrIncorrectFutureMilestoneFieldToStore = errors.New("failed to marshal the future milestone field struct ") + ErrIncorrectFutureMilestoneField = errors.New("future milestone field in the DB is incorrect") +) + +type Checkpoint struct { + Finality +} + +func (c *Checkpoint) clone() *Checkpoint { + return &Checkpoint{} +} + +func (c *Checkpoint) block() (uint64, common.Hash) { + return c.Block, c.Hash +} diff --git a/core/rawdb/milestone.go b/core/rawdb/milestone.go new file mode 100644 index 0000000000..ca3064050e --- /dev/null +++ b/core/rawdb/milestone.go @@ -0,0 +1,221 @@ +// nolint +package rawdb + +import ( + "fmt" + + json "github.com/json-iterator/go" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/gererics" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" +) + +var ( + lastMilestone = []byte("LastMilestone") + lockFieldKey = []byte("LockField") + futureMilestoneKey = []byte("FutureMilestoneField") +) + +type Finality struct { + Block uint64 + Hash common.Hash +} + +type LockField struct { + Val bool + Block uint64 + Hash common.Hash + IdList map[string]struct{} +} + +type FutureMilestoneField struct { + Order []uint64 + List map[uint64]common.Hash +} + +func (f *Finality) set(block uint64, hash common.Hash) { + f.Block = block + f.Hash = hash +} + +type Milestone struct { + Finality +} + +func (m *Milestone) clone() *Milestone { + return &Milestone{} +} + +func (m *Milestone) block() (uint64, common.Hash) { + return m.Block, m.Hash +} + +func ReadFinality[T BlockFinality[T]](db ethdb.KeyValueReader) (uint64, common.Hash, error) { + lastTV, key := getKey[T]() + + data, err := db.Get(key) + if err != nil { + return 0, common.Hash{}, fmt.Errorf("%w: empty response for %s", err, string(key)) + } + + if len(data) == 0 { + return 0, common.Hash{}, fmt.Errorf("%w for %s", ErrEmptyLastFinality, string(key)) + } + + if err = json.Unmarshal(data, lastTV); err != nil { + log.Error(fmt.Sprintf("Unable to unmarshal the last %s block number in database", string(key)), "err", err) + + return 0, common.Hash{}, fmt.Errorf("%w(%v) for %s, data %v(%q)", + ErrIncorrectFinality, err, string(key), data, string(data)) + } + + block, hash := lastTV.block() + + return block, hash, nil +} + +func WriteLastFinality[T BlockFinality[T]](db ethdb.KeyValueWriter, block uint64, hash common.Hash) error { + lastTV, key := getKey[T]() + + lastTV.set(block, hash) + + enc, err := json.Marshal(lastTV) + if err != nil { + log.Error(fmt.Sprintf("Failed to marshal the %s struct", string(key)), "err", err) + + return fmt.Errorf("%w: %v for %s struct", ErrIncorrectFinalityToStore, err, string(key)) + } + + if err := db.Put(key, enc); err != nil { + log.Error(fmt.Sprintf("Failed to store the %s struct", string(key)), "err", err) + + return fmt.Errorf("%w: %v for %s struct", ErrDBNotResponding, err, string(key)) + } + + return nil +} + +type BlockFinality[T any] interface { + set(block uint64, hash common.Hash) + clone() T + block() (uint64, common.Hash) +} + +func getKey[T BlockFinality[T]]() (T, []byte) { + lastT := gererics.Empty[T]().clone() + + var key []byte + + switch any(lastT).(type) { + case *Milestone: + key = lastMilestone + case *Checkpoint: + key = lastCheckpoint + } + + return lastT, key +} + +func WriteLockField(db ethdb.KeyValueWriter, val bool, block uint64, hash common.Hash, idListMap map[string]struct{}) error { + + lockField := LockField{ + Val: val, + Block: block, + Hash: hash, + IdList: idListMap, + } + + key := lockFieldKey + + enc, err := json.Marshal(lockField) + if err != nil { + log.Error("Failed to marshal the lock field struct", "err", err) + + return fmt.Errorf("%w: %v for lock field struct", ErrIncorrectLockFieldToStore, err) + } + + if err := db.Put(key, enc); err != nil { + log.Error("Failed to store the lock field struct", "err", err) + + return fmt.Errorf("%w: %v for lock field struct", ErrDBNotResponding, err) + } + + return nil +} + +func ReadLockField(db ethdb.KeyValueReader) (bool, uint64, common.Hash, map[string]struct{}, error) { + key := lockFieldKey + lockField := LockField{} + + data, err := db.Get(key) + if err != nil { + return false, 0, common.Hash{}, nil, fmt.Errorf("%w: empty response for lock field", err) + } + + if len(data) == 0 { + return false, 0, common.Hash{}, nil, fmt.Errorf("%w for %s", ErrIncorrectLockField, string(key)) + } + + if err = json.Unmarshal(data, &lockField); err != nil { + log.Error(fmt.Sprintf("Unable to unmarshal the lock field in database"), "err", err) + + return false, 0, common.Hash{}, nil, fmt.Errorf("%w(%v) for lock field , data %v(%q)", + ErrIncorrectLockField, err, data, string(data)) + } + + val, block, hash, idList := lockField.Val, lockField.Block, lockField.Hash, lockField.IdList + + return val, block, hash, idList, nil +} + +func WriteFutureMilestoneList(db ethdb.KeyValueWriter, order []uint64, list map[uint64]common.Hash) error { + + futureMilestoneField := FutureMilestoneField{ + Order: order, + List: list, + } + + key := futureMilestoneKey + + enc, err := json.Marshal(futureMilestoneField) + if err != nil { + log.Error("Failed to marshal the future milestone field struct", "err", err) + + return fmt.Errorf("%w: %v for future milestone field struct", ErrIncorrectFutureMilestoneFieldToStore, err) + } + + if err = db.Put(key, enc); err != nil { + log.Error("Failed to store the future milestone field struct", "err", err) + + return fmt.Errorf("%w: %v for future milestone field struct", ErrDBNotResponding, err) + } + + return nil +} + +func ReadFutureMilestoneList(db ethdb.KeyValueReader) ([]uint64, map[uint64]common.Hash, error) { + key := futureMilestoneKey + futureMilestoneField := FutureMilestoneField{} + + data, err := db.Get(key) + if err != nil { + return nil, nil, fmt.Errorf("%w: empty response for future milestone field", err) + } + + if len(data) == 0 { + return nil, nil, fmt.Errorf("%w for %s", ErrIncorrectLockField, string(key)) + } + + if err = json.Unmarshal(data, &futureMilestoneField); err != nil { + log.Error(fmt.Sprintf("Unable to unmarshal the future milestone field in database"), "err", err) + + return nil, nil, fmt.Errorf("%w(%v) for future milestone field, data %v(%q)", + ErrIncorrectFutureMilestoneField, err, data, string(data)) + } + + order, list := futureMilestoneField.Order, futureMilestoneField.List + + return order, list, nil +} diff --git a/core/state/state_object.go b/core/state/state_object.go index cd720019db..69caf3256f 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -201,7 +201,9 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has s.db.setError(err) return common.Hash{} } - enc, err = tr.TryGet(key.Bytes()) + + enc, err = tr.GetStorage(s.address, key.Bytes()) + if metrics.EnabledExpensive { s.db.StorageReads += time.Since(start) } diff --git a/core/state/statedb.go b/core/state/statedb.go index 8ec9de32cb..96ed7aab66 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -25,6 +25,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/blockstm" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" @@ -78,6 +79,14 @@ type StateDB struct { stateObjectsDirty map[common.Address]struct{} // State objects modified in the current execution stateObjectsDestruct map[common.Address]struct{} // State objects destructed in the block + // Block-stm related fields + mvHashmap *blockstm.MVHashMap + incarnation int + readMap map[blockstm.Key]blockstm.ReadDescriptor + writeMap map[blockstm.Key]blockstm.WriteDescriptor + revertedKeys map[blockstm.Key]struct{} + dep int + // DB error. // State objects are used by the consensus core and VM which are // unable to deal with database-level errors. Any error that occurs diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index c258eee4f4..1139c4e56b 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -17,6 +17,7 @@ package core import ( + "context" "sync/atomic" "github.com/ethereum/go-ethereum/consensus" @@ -47,7 +48,7 @@ func newStatePrefetcher(config *params.ChainConfig, bc *BlockChain, engine conse // Prefetch processes the state changes according to the Ethereum rules by running // the transaction messages using the statedb, but any changes are discarded. The // only goal is to pre-cache transaction signatures and state trie nodes. -func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32) { +func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *atomic.Bool) { var ( header = block.Header() gaspool = new(GasPool).AddGas(block.GasLimit()) @@ -59,7 +60,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c byzantium := p.config.IsByzantium(block.Number()) for i, tx := range block.Transactions() { // If block precaching was interrupted, abort - if interrupt != nil && atomic.LoadUint32(interrupt) == 1 { + if interrupt != nil && interrupt.Load() { return } // Convert the transaction into an executable message and pre-cache its sender @@ -85,10 +86,11 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c // precacheTransaction attempts to apply a transaction to the given state database // and uses the input parameters for its environment. The goal is not to execute // the transaction successfully, rather to warm up touched data slots. -func precacheTransaction(msg *Message, config *params.ChainConfig, gaspool *GasPool, statedb *state.StateDB, header *types.Header, evm *vm.EVM) error { +func precacheTransaction(msg *Message, _ *params.ChainConfig, gaspool *GasPool, statedb *state.StateDB, _ *types.Header, evm *vm.EVM) error { // Update the evm with the new transaction context. evm.Reset(NewEVMTxContext(msg), statedb) // Add addresses to access list if applicable - _, err := ApplyMessage(evm, msg, gaspool) + _, err := ApplyMessage(evm, msg, gaspool, context.Background()) + return err } diff --git a/core/state_processor.go b/core/state_processor.go index 7fded51006..9c367ab43e 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -17,6 +17,7 @@ package core import ( + "context" "fmt" "math/big" @@ -56,7 +57,7 @@ func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consen // Process returns the receipts and logs accumulated during the process and // returns the amount of gas that was used in the process. If any of the // transactions failed to execute due to insufficient gas it will return an error. -func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) { +func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config, interruptCtx context.Context) (types.Receipts, []*types.Log, uint64, error) { var ( receipts types.Receipts usedGas = new(uint64) @@ -74,12 +75,21 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) // Iterate over and process the individual transactions for i, tx := range block.Transactions() { + if interruptCtx != nil { + select { + case <-interruptCtx.Done(): + return nil, nil, 0, interruptCtx.Err() + default: + } + } + msg, err := TransactionToMessage(tx, types.MakeSigner(p.config, header.Number), header.BaseFee) if err != nil { return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) } statedb.SetTxContext(tx.Hash(), i) - receipt, err := applyTransaction(msg, p.config, gp, statedb, blockNumber, blockHash, tx, usedGas, vmenv, nil) + + receipt, err := applyTransaction(msg, p.config, gp, statedb, blockNumber, blockHash, tx, usedGas, vmenv, interruptCtx) if err != nil { return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) } @@ -97,68 +107,60 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg return receipts, allLogs, *usedGas, nil } -func applyTransaction(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM, preFinalizeHook func() error) (*types.Receipt, error) { +// nolint : unparam +func applyTransaction(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM, interruptCtx context.Context) (*types.Receipt, error) { // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(msg) evm.Reset(txContext, statedb) - snapshot := statedb.Snapshot() - // Apply the transaction to the current state (included in the env). - result, err := ApplyMessage(evm, msg, gp) + var result *ExecutionResult + + var err error + + backupMVHashMap := statedb.GetMVHashmap() + + // pause recording read and write + statedb.SetMVHashmap(nil) + + coinbaseBalance := statedb.GetBalance(evm.Context.Coinbase) + + // resume recording read and write + statedb.SetMVHashmap(backupMVHashMap) + + result, err = ApplyMessageNoFeeBurnOrTip(evm, *msg, gp, interruptCtx) if err != nil { return nil, err } - if preFinalizeHook != nil { - err = preFinalizeHook() - if err != nil { - statedb.RevertToSnapshot(snapshot) - return nil, err - } - } - // Update the state with pending changes. - var root []byte - if config.IsByzantium(blockNumber) { - statedb.Finalise(true) - } else { - root = statedb.IntermediateRoot(config.IsEIP158(blockNumber)).Bytes() - } - *usedGas += result.UsedGas + // stop recording read and write + statedb.SetMVHashmap(nil) - // Create a new receipt for the transaction, storing the intermediate root and gas used - // by the tx. - receipt := &types.Receipt{Type: tx.Type(), PostState: root, CumulativeGasUsed: *usedGas} - if result.Failed() { - receipt.Status = types.ReceiptStatusFailed - } else { - receipt.Status = types.ReceiptStatusSuccessful + if evm.ChainConfig().IsLondon(blockNumber) { + statedb.AddBalance(result.BurntContractAddress, result.FeeBurnt) } - receipt.TxHash = tx.Hash() - receipt.GasUsed = result.UsedGas - // If the transaction created a contract, store the creation address in the receipt. - if msg.To == nil { - receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce()) - } + // TODO(raneet10) Double check + statedb.AddBalance(evm.Context.Coinbase, result.FeeTipped) + output1 := new(big.Int).SetBytes(result.SenderInitBalance.Bytes()) + output2 := new(big.Int).SetBytes(coinbaseBalance.Bytes()) - // Set the receipt logs and create the bloom filter. - receipt.Logs = statedb.GetLogs(tx.Hash(), blockNumber.Uint64(), blockHash) - receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) - receipt.BlockHash = blockHash - receipt.BlockNumber = blockNumber - receipt.TransactionIndex = uint(statedb.TxIndex()) - return receipt, err -} + // Deprecating transfer log and will be removed in future fork. PLEASE DO NOT USE this transfer log going forward. Parameters won't get updated as expected going forward with EIP1559 + // add transfer log + AddFeeTransferLog( + statedb, -func applyTransactionWithResult(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, *ExecutionResult, error) { - // Create a new context to be used in the EVM environment. - txContext := NewEVMTxContext(msg) - evm.Reset(txContext, statedb) + msg.From, + evm.Context.Coinbase, - // Apply the transaction to the current state (included in the env). - result, err := ApplyMessage(evm, msg, gp) - if err != nil { - return nil, nil, err + result.FeeTipped, + result.SenderInitBalance, + coinbaseBalance, + output1.Sub(output1, result.FeeTipped), + output2.Add(output2, result.FeeTipped), + ) + + if result.Err == vm.ErrInterrupt { + return nil, result.Err } // Update the state with pending changes. @@ -192,14 +194,59 @@ func applyTransactionWithResult(msg *Message, config *params.ChainConfig, gp *Ga receipt.BlockHash = blockHash receipt.BlockNumber = blockNumber receipt.TransactionIndex = uint(statedb.TxIndex()) - return receipt, result, err + return receipt, err } +//func applyTransactionWithResult(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, *ExecutionResult, error) { +// // Create a new context to be used in the EVM environment. +// txContext := NewEVMTxContext(msg) +// evm.Reset(txContext, statedb) +// +// // Apply the transaction to the current state (included in the env). +// result, err := ApplyMessage(evm, msg, gp) +// if err != nil { +// return nil, nil, err +// } +// +// // Update the state with pending changes. +// var root []byte +// if config.IsByzantium(blockNumber) { +// statedb.Finalise(true) +// } else { +// root = statedb.IntermediateRoot(config.IsEIP158(blockNumber)).Bytes() +// } +// *usedGas += result.UsedGas +// +// // Create a new receipt for the transaction, storing the intermediate root and gas used +// // by the tx. +// receipt := &types.Receipt{Type: tx.Type(), PostState: root, CumulativeGasUsed: *usedGas} +// if result.Failed() { +// receipt.Status = types.ReceiptStatusFailed +// } else { +// receipt.Status = types.ReceiptStatusSuccessful +// } +// receipt.TxHash = tx.Hash() +// receipt.GasUsed = result.UsedGas +// +// // If the transaction created a contract, store the creation address in the receipt. +// if msg.To == nil { +// receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce()) +// } +// +// // Set the receipt logs and create the bloom filter. +// receipt.Logs = statedb.GetLogs(tx.Hash(), blockNumber.Uint64(), blockHash) +// receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) +// receipt.BlockHash = blockHash +// receipt.BlockNumber = blockNumber +// receipt.TransactionIndex = uint(statedb.TxIndex()) +// return receipt, result, err +//} + // ApplyTransaction attempts to apply a transaction to the given state database // and uses the input parameters for its environment. It returns the receipt // for the transaction, gas used and an error if the transaction failed, // indicating the block was invalid. -func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, preFinalizeHook func() error) (*types.Receipt, error) { +func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config, interruptCtx context.Context) (*types.Receipt, error) { msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), header.BaseFee) if err != nil { return nil, err @@ -207,16 +254,6 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo // Create a new context to be used in the EVM environment blockContext := NewEVMBlockContext(header, bc, author) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, config, cfg) - return applyTransaction(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv, preFinalizeHook) -} -func ApplyTransactionWithResult(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, *ExecutionResult, error) { - msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), header.BaseFee) - if err != nil { - return nil, nil, err - } - // Create a new context to be used in the EVM environment - blockContext := NewEVMBlockContext(header, bc, author) - vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, config, cfg) - return applyTransactionWithResult(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv) + return applyTransaction(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv, interruptCtx) } diff --git a/core/types.go b/core/types.go index 4c5b74a498..1bb04fbd75 100644 --- a/core/types.go +++ b/core/types.go @@ -17,6 +17,9 @@ package core import ( + "context" + "sync/atomic" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -39,7 +42,7 @@ type Prefetcher interface { // Prefetch processes the state changes according to the Ethereum rules by running // the transaction messages using the statedb, but any changes are discarded. The // only goal is to pre-cache transaction signatures and state trie nodes. - Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32) + Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *atomic.Bool) } // Processor is an interface for processing blocks using a given initial state. @@ -47,5 +50,5 @@ type Processor interface { // Process processes the state changes according to the Ethereum rules by running // the transaction messages using the statedb and applying any rewards to both // the processor (coinbase) and any included uncles. - Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) + Process(block *types.Block, statedb *state.StateDB, cfg vm.Config, interruptCtx context.Context) (types.Receipts, []*types.Log, uint64, error) } diff --git a/core/types/block.go b/core/types/block.go index e2c71abebd..2310d353b6 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -28,9 +28,16 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" ) +var ( + ExtraVanityLength = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity + ExtraSealLength = 65 // Fixed number of extra-data suffix bytes reserved for signer seal +) + // A BlockNonce is a 64-bit hash which proves (combined with the // mix-hash) that a sufficient amount of computation has been carried // out on a block. @@ -85,6 +92,9 @@ type Header struct { // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` + // ExcessDataGas was added by EIP-4844 and is ignored in legacy headers. + ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` + /* TODO (MariusVanDerWijden) Add this field once needed // Random was added during the merge and contains the BeaconState randomness @@ -92,6 +102,16 @@ type Header struct { */ } +// Used for Encoding and Decoding of the Extra Data Field +type BlockExtraData struct { + ValidatorBytes []byte + + // length of TxDependency -> n (n = number of transactions in the block) + // length of TxDependency[i] -> k (k = a whole number) + // k elements in TxDependency[i] -> transaction indexes on which transaction i is dependent on + TxDependency [][]uint64 +} + // field type overrides for gencodec type headerMarshaling struct { Difficulty *hexutil.Big @@ -160,6 +180,44 @@ func (h *Header) EmptyReceipts() bool { return h.ReceiptHash == EmptyReceiptsHash } +// ValidateBlockNumberOptions4337 validates the block range passed as in the options parameter in the conditional transaction (EIP-4337) +func (h *Header) ValidateBlockNumberOptions4337(minBlockNumber *big.Int, maxBlockNumber *big.Int) error { + currentBlockNumber := h.Number + + if minBlockNumber != nil { + if currentBlockNumber.Cmp(minBlockNumber) == -1 { + return fmt.Errorf("current block number %v is less than minimum block number: %v", currentBlockNumber, minBlockNumber) + } + } + + if maxBlockNumber != nil { + if currentBlockNumber.Cmp(maxBlockNumber) == 1 { + return fmt.Errorf("current block number %v is greater than maximum block number: %v", currentBlockNumber, maxBlockNumber) + } + } + + return nil +} + +// ValidateBlockNumberOptions4337 validates the timestamp range passed as in the options parameter in the conditional transaction (EIP-4337) +func (h *Header) ValidateTimestampOptions4337(minTimestamp *uint64, maxTimestamp *uint64) error { + currentBlockTime := h.Time + + if minTimestamp != nil { + if currentBlockTime < *minTimestamp { + return fmt.Errorf("current block time %v is less than minimum timestamp: %v", currentBlockTime, minTimestamp) + } + } + + if maxTimestamp != nil { + if currentBlockTime > *maxTimestamp { + return fmt.Errorf("current block time %v is greater than maximum timestamp: %v", currentBlockTime, maxTimestamp) + } + } + + return nil +} + // Body is a simple (mutable, non-safe) data container for storing and moving // a block's data contents (transactions and uncles) together. type Body struct { @@ -339,6 +397,40 @@ func (b *Block) ReceiptHash() common.Hash { return b.header.ReceiptHash } func (b *Block) UncleHash() common.Hash { return b.header.UncleHash } func (b *Block) Extra() []byte { return common.CopyBytes(b.header.Extra) } +func (b *Block) GetTxDependency() [][]uint64 { + if len(b.header.Extra) < ExtraVanityLength+ExtraSealLength { + log.Error("length of extra less is than vanity and seal") + return nil + } + + var blockExtraData BlockExtraData + if err := rlp.DecodeBytes(b.header.Extra[ExtraVanityLength:len(b.header.Extra)-ExtraSealLength], &blockExtraData); err != nil { + log.Debug("error while decoding block extra data", "err", err) + return nil + } + + return blockExtraData.TxDependency +} + +func (h *Header) GetValidatorBytes(config *params.BorConfig) []byte { + if !config.IsParallelUniverse(h.Number) { + return h.Extra[ExtraVanityLength : len(h.Extra)-ExtraSealLength] + } + + if len(h.Extra) < ExtraVanityLength+ExtraSealLength { + log.Error("length of extra less is than vanity and seal") + return nil + } + + var blockExtraData BlockExtraData + if err := rlp.DecodeBytes(h.Extra[ExtraVanityLength:len(h.Extra)-ExtraSealLength], &blockExtraData); err != nil { + log.Debug("error while decoding block extra data", "err", err) + return nil + } + + return blockExtraData.ValidatorBytes +} + func (b *Block) BaseFee() *big.Int { if b.header.BaseFee == nil { return nil diff --git a/core/types/bor_receipt.go b/core/types/bor_receipt.go new file mode 100644 index 0000000000..4c0a48fc82 --- /dev/null +++ b/core/types/bor_receipt.go @@ -0,0 +1,99 @@ +package types + +import ( + "encoding/binary" + "math/big" + "sort" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" +) + +// TenToTheFive - To be used while sorting bor logs +// +// Sorted using ( blockNumber * (10 ** 5) + logIndex ) +const TenToTheFive uint64 = 100000 + +var ( + borReceiptPrefix = []byte("matic-bor-receipt-") // borReceiptPrefix + number + block hash -> bor block receipt + + // SystemAddress address for system sender + SystemAddress = common.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE") +) + +// BorReceiptKey = borReceiptPrefix + num (uint64 big endian) + hash +func BorReceiptKey(number uint64, hash common.Hash) []byte { + enc := make([]byte, 8) + binary.BigEndian.PutUint64(enc, number) + + return append(append(borReceiptPrefix, enc...), hash.Bytes()...) +} + +// GetDerivedBorTxHash get derived tx hash from receipt key +func GetDerivedBorTxHash(receiptKey []byte) common.Hash { + return common.BytesToHash(crypto.Keccak256(receiptKey)) +} + +// NewBorTransaction create new bor transaction for bor receipt +func NewBorTransaction() *Transaction { + return NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), make([]byte, 0)) +} + +// DeriveFieldsForBorReceipt fills the receipts with their computed fields based on consensus +// data and contextual infos like containing block and transactions. +func DeriveFieldsForBorReceipt(receipt *Receipt, hash common.Hash, number uint64, receipts Receipts) error { + // get derived tx hash + txHash := GetDerivedBorTxHash(BorReceiptKey(number, hash)) + txIndex := uint(len(receipts)) + + // set tx hash and tx index + receipt.TxHash = txHash + receipt.TransactionIndex = txIndex + receipt.BlockHash = hash + receipt.BlockNumber = big.NewInt(0).SetUint64(number) + + logIndex := 0 + for i := 0; i < len(receipts); i++ { + logIndex += len(receipts[i].Logs) + } + + // The derived log fields can simply be set from the block and transaction + for j := 0; j < len(receipt.Logs); j++ { + receipt.Logs[j].BlockNumber = number + receipt.Logs[j].BlockHash = hash + receipt.Logs[j].TxHash = txHash + receipt.Logs[j].TxIndex = txIndex + receipt.Logs[j].Index = uint(logIndex) + logIndex++ + } + + return nil +} + +// DeriveFieldsForBorLogs fills the receipts with their computed fields based on consensus +// data and contextual infos like containing block and transactions. +func DeriveFieldsForBorLogs(logs []*Log, hash common.Hash, number uint64, txIndex uint, logIndex uint) { + // get derived tx hash + txHash := GetDerivedBorTxHash(BorReceiptKey(number, hash)) + + // the derived log fields can simply be set from the block and transaction + for j := 0; j < len(logs); j++ { + logs[j].BlockNumber = number + logs[j].BlockHash = hash + logs[j].TxHash = txHash + logs[j].TxIndex = txIndex + logs[j].Index = logIndex + logIndex++ + } +} + +// MergeBorLogs merges receipt logs and block receipt logs +func MergeBorLogs(logs []*Log, borLogs []*Log) []*Log { + result := append(logs, borLogs...) + + sort.SliceStable(result, func(i int, j int) bool { + return (result[i].BlockNumber*TenToTheFive + uint64(result[i].Index)) < (result[j].BlockNumber*TenToTheFive + uint64(result[j].Index)) + }) + + return result +} diff --git a/core/types/state_data.go b/core/types/state_data.go new file mode 100644 index 0000000000..d04f91ec53 --- /dev/null +++ b/core/types/state_data.go @@ -0,0 +1,11 @@ +package types + +import "github.com/ethereum/go-ethereum/common" + +// StateSyncData represents state received from Ethereum Blockchain +type StateSyncData struct { + ID uint64 + Contract common.Address + Data string + TxHash common.Hash +} diff --git a/core/vm/interface.go b/core/vm/interface.go index b83f78307e..beaac6d469 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -76,6 +76,8 @@ type StateDB interface { AddLog(*types.Log) AddPreimage(common.Hash, []byte) + + Finalise(bool) } // CallContext provides a basic interface for the EVM calling conventions. The EVM diff --git a/eth/downloader/whitelist/checkpoint.go b/eth/downloader/whitelist/checkpoint.go new file mode 100644 index 0000000000..b0eaae8c49 --- /dev/null +++ b/eth/downloader/whitelist/checkpoint.go @@ -0,0 +1,67 @@ +package whitelist + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/metrics" +) + +type checkpoint struct { + finality[*rawdb.Checkpoint] +} + +type checkpointService interface { + finalityService +} + +var ( + //Metrics for collecting the whitelisted milestone number + whitelistedCheckpointNumberMeter = metrics.NewRegisteredGauge("chain/checkpoint/latest", nil) + + //Metrics for collecting the number of invalid chains received + CheckpointChainMeter = metrics.NewRegisteredMeter("chain/checkpoint/isvalidchain", nil) + + //Metrics for collecting the number of valid peers received + CheckpointPeerMeter = metrics.NewRegisteredMeter("chain/checkpoint/isvalidpeer", nil) +) + +// IsValidChain checks the validity of chain by comparing it +// against the local checkpoint entry +func (w *checkpoint) IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) { + w.finality.RLock() + defer w.finality.RUnlock() + + res, err := w.finality.IsValidChain(currentHeader, chain) + + if res { + CheckpointChainMeter.Mark(int64(1)) + } else { + CheckpointPeerMeter.Mark(int64(-1)) + } + + return res, err +} + +// IsValidPeer checks if the chain we're about to receive from a peer is valid or not +// in terms of reorgs. We won't reorg beyond the last bor finality submitted to mainchain. +func (w *checkpoint) IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) { + res, err := w.finality.IsValidPeer(fetchHeadersByNumber) + + if res { + CheckpointPeerMeter.Mark(int64(1)) + } else { + CheckpointPeerMeter.Mark(int64(-1)) + } + + return res, err +} + +func (w *checkpoint) Process(block uint64, hash common.Hash) { + w.finality.Lock() + defer w.finality.Unlock() + + w.finality.Process(block, hash) + + whitelistedCheckpointNumberMeter.Update(int64(block)) +} diff --git a/eth/downloader/whitelist/finality.go b/eth/downloader/whitelist/finality.go new file mode 100644 index 0000000000..7ab684d88a --- /dev/null +++ b/eth/downloader/whitelist/finality.go @@ -0,0 +1,96 @@ +package whitelist + +import ( + "fmt" + "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" +) + +type finality[T rawdb.BlockFinality[T]] struct { + sync.RWMutex + db ethdb.Database + Hash common.Hash // Whitelisted Hash, populated by reaching out to heimdall + Number uint64 // Number , populated by reaching out to heimdall + interval uint64 // Interval, until which we can allow importing + doExist bool +} + +type finalityService interface { + IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) + IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) + Get() (bool, uint64, common.Hash) + Process(block uint64, hash common.Hash) + Purge() +} + +// IsValidPeer checks if the chain we're about to receive from a peer is valid or not +// in terms of reorgs. We won't reorg beyond the last bor finality submitted to mainchain. +func (f *finality[T]) IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) { + // We want to validate the chain by comparing the last finalized block + f.RLock() + + doExist := f.doExist + number := f.Number + hash := f.Hash + + f.RUnlock() + + return isValidPeer(fetchHeadersByNumber, doExist, number, hash) +} + +// IsValidChain checks the validity of chain by comparing it +// against the local checkpoint entry +// todo: need changes +func (f *finality[T]) IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) { + // Return if we've received empty chain + if len(chain) == 0 { + return false, nil + } + + res, err := isValidChain(currentHeader, chain, f.doExist, f.Number, f.Hash) + + return res, err +} + +func (f *finality[T]) Process(block uint64, hash common.Hash) { + f.doExist = true + f.Hash = hash + f.Number = block + + err := rawdb.WriteLastFinality[T](f.db, block, hash) + if err != nil { + log.Error("Error in writing whitelist state to db", "err", err) + } +} + +// Get returns the existing whitelisted +// entries of checkpoint of the form (doExist,block number,block hash.) +func (f *finality[T]) Get() (bool, uint64, common.Hash) { + f.RLock() + defer f.RUnlock() + + if f.doExist { + return f.doExist, f.Number, f.Hash + } + + block, hash, err := rawdb.ReadFinality[T](f.db) + if err != nil { + fmt.Println("Error while reading whitelisted state from Db", "err", err) + return false, f.Number, f.Hash + } + + return true, block, hash +} + +// Purge purges the whitlisted checkpoint +func (f *finality[T]) Purge() { + f.Lock() + defer f.Unlock() + + f.doExist = false +} diff --git a/eth/downloader/whitelist/milestone.go b/eth/downloader/whitelist/milestone.go new file mode 100644 index 0000000000..d2ea7f7bed --- /dev/null +++ b/eth/downloader/whitelist/milestone.go @@ -0,0 +1,315 @@ +package whitelist + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/flags" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" +) + +type milestone struct { + finality[*rawdb.Milestone] + + LockedMilestoneNumber uint64 // Locked sprint number + LockedMilestoneHash common.Hash //Hash for the locked endBlock + Locked bool // + LockedMilestoneIDs map[string]struct{} //list of milestone ids + + FutureMilestoneList map[uint64]common.Hash // Future Milestone list + FutureMilestoneOrder []uint64 // Future Milestone Order + MaxCapacity int //Capacity of future Milestone list +} + +type milestoneService interface { + finalityService + + GetMilestoneIDsList() []string + RemoveMilestoneID(milestoneId string) + LockMutex(endBlockNum uint64) bool + UnlockMutex(doLock bool, milestoneId string, endBlockNum uint64, endBlockHash common.Hash) + UnlockSprint(endBlockNum uint64) + ProcessFutureMilestone(num uint64, hash common.Hash) +} + +var ( + //Metrics for collecting the whitelisted milestone number + whitelistedMilestoneMeter = metrics.NewRegisteredGauge("chain/milestone/latest", nil) + + //Metrics for collecting the future milestone number + FutureMilestoneMeter = metrics.NewRegisteredGauge("chain/milestone/future", nil) + + //Metrics for collecting the length of the MilestoneIds map + MilestoneIdsLengthMeter = metrics.NewRegisteredGauge("chain/milestone/idslength", nil) + + //Metrics for collecting the number of valid chains received + MilestoneChainMeter = metrics.NewRegisteredMeter("chain/milestone/isvalidchain", nil) + + //Metrics for collecting the number of valid peers received + MilestonePeerMeter = metrics.NewRegisteredMeter("chain/milestone/isvalidpeer", nil) +) + +// IsValidChain checks the validity of chain by comparing it +// against the local milestone entries +func (m *milestone) IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) { + //Checking for the milestone flag + if !flags.Milestone { + return true, nil + } + + m.finality.RLock() + defer m.finality.RUnlock() + + var isValid bool = false + + defer func() { + if isValid { + MilestoneChainMeter.Mark(int64(1)) + } else { + MilestoneChainMeter.Mark(int64(-1)) + } + }() + + res, err := m.finality.IsValidChain(currentHeader, chain) + + if !res { + isValid = false + return isValid, err + } + + if m.Locked && !m.IsReorgAllowed(chain, m.LockedMilestoneNumber, m.LockedMilestoneHash) { + isValid = false + return isValid, nil + } + + if !m.IsFutureMilestoneCompatible(chain) { + isValid = false + return isValid, nil + } + + isValid = true + + return isValid, nil +} + +// IsValidPeer checks if the chain we're about to receive from a peer is valid or not +// in terms of reorgs. We won't reorg beyond the last bor finality submitted to mainchain. +func (m *milestone) IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) { + if !flags.Milestone { + return true, nil + } + + res, err := m.finality.IsValidPeer(fetchHeadersByNumber) + + if res { + MilestonePeerMeter.Mark(int64(1)) + } else { + MilestonePeerMeter.Mark(int64(-1)) + } + + return res, err +} + +func (m *milestone) Process(block uint64, hash common.Hash) { + m.finality.Lock() + defer m.finality.Unlock() + + m.finality.Process(block, hash) + + for i := 0; i < len(m.FutureMilestoneOrder); i++ { + if m.FutureMilestoneOrder[i] <= block { + m.dequeueFutureMilestone() + } else { + break + } + } + + whitelistedMilestoneMeter.Update(int64(block)) + + m.UnlockSprint(block) +} + +// This function will Lock the mutex at the time of voting +// fixme: get rid of it +func (m *milestone) LockMutex(endBlockNum uint64) bool { + m.finality.Lock() + + if m.doExist && endBlockNum <= m.Number { //if endNum is less than whitelisted milestone, then we won't lock the sprint + log.Debug("endBlockNumber is less than or equal to latesMilestoneNumber", "endBlock Number", endBlockNum, "LatestMilestone Number", m.Number) + return false + } + + if m.Locked && endBlockNum < m.LockedMilestoneNumber { + log.Debug("endBlockNum is less than locked milestone number", "endBlock Number", endBlockNum, "Locked Milestone Number", m.LockedMilestoneNumber) + return false + } + + return true +} + +// This function will unlock the mutex locked in LockMutex +// fixme: get rid of it +func (m *milestone) UnlockMutex(doLock bool, milestoneId string, endBlockNum uint64, endBlockHash common.Hash) { + m.Locked = m.Locked || doLock + + if doLock { + m.UnlockSprint(m.LockedMilestoneNumber) + m.Locked = true + m.LockedMilestoneHash = endBlockHash + m.LockedMilestoneNumber = endBlockNum + m.LockedMilestoneIDs[milestoneId] = struct{}{} + } + + err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs) + if err != nil { + log.Error("Error in writing lock data of milestone to db", "err", err) + } + + milestoneIDLength := int64(len(m.LockedMilestoneIDs)) + MilestoneIdsLengthMeter.Update(milestoneIDLength) + + m.finality.Unlock() +} + +// This function will unlock the locked sprint +func (m *milestone) UnlockSprint(endBlockNum uint64) { + if endBlockNum < m.LockedMilestoneNumber { + return + } + + m.Locked = false + m.purgeMilestoneIDsList() + + err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs) + + if err != nil { + log.Error("Error in writing lock data of milestone to db", "err", err) + } +} + +// This function will remove the stored milestoneID +func (m *milestone) RemoveMilestoneID(milestoneId string) { + m.finality.Lock() + + delete(m.LockedMilestoneIDs, milestoneId) + + if len(m.LockedMilestoneIDs) == 0 { + m.Locked = false + } + + err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs) + if err != nil { + log.Error("Error in writing lock data of milestone to db", "err", err) + } + + m.finality.Unlock() +} + +// This will check whether the incoming chain matches the locked sprint hash +func (m *milestone) IsReorgAllowed(chain []*types.Header, lockedMilestoneNumber uint64, lockedMilestoneHash common.Hash) bool { + if chain[len(chain)-1].Number.Uint64() <= lockedMilestoneNumber { //Can't reorg if the end block of incoming + return false //chain is less than locked sprint number + } + + for i := 0; i < len(chain); i++ { + if chain[i].Number.Uint64() == lockedMilestoneNumber { + return chain[i].Hash() == lockedMilestoneHash + } + } + + return true +} + +// This will return the list of milestoneIDs stored. +func (m *milestone) GetMilestoneIDsList() []string { + m.finality.RLock() + defer m.finality.RUnlock() + + // fixme: use generics :) + keys := make([]string, 0, len(m.LockedMilestoneIDs)) + for key := range m.LockedMilestoneIDs { + keys = append(keys, key) + } + + return keys +} + +// This is remove the milestoneIDs stored in the list. +func (m *milestone) purgeMilestoneIDsList() { + m.LockedMilestoneIDs = make(map[string]struct{}) +} + +func (m *milestone) IsFutureMilestoneCompatible(chain []*types.Header) bool { + //Tip of the received chain + chainTipNumber := chain[len(chain)-1].Number.Uint64() + + for i := len(m.FutureMilestoneOrder) - 1; i >= 0; i-- { + //Finding out the highest future milestone number + //which is less or equal to received chain tip + if chainTipNumber >= m.FutureMilestoneOrder[i] { + //Looking for the received chain 's particular block number(matching future milestone number) + for j := len(chain) - 1; j >= 0; j-- { + if chain[j].Number.Uint64() == m.FutureMilestoneOrder[i] { + endBlockNum := m.FutureMilestoneOrder[i] + endBlockHash := m.FutureMilestoneList[endBlockNum] + + //Checking the received chain matches with future milestone + return chain[j].Hash() == endBlockHash + } + } + } + } + + return true +} + +func (m *milestone) ProcessFutureMilestone(num uint64, hash common.Hash) { + if len(m.FutureMilestoneOrder) < m.MaxCapacity { + m.enqueueFutureMilestone(num, hash) + } + + if num < m.LockedMilestoneNumber { + return + } + + m.Locked = false + m.purgeMilestoneIDsList() + + err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs) + + if err != nil { + log.Error("Error in writing lock data of milestone to db", "err", err) + } +} + +// EnqueueFutureMilestone add the future milestone to the list +func (m *milestone) enqueueFutureMilestone(key uint64, hash common.Hash) { + if _, ok := m.FutureMilestoneList[key]; ok { + log.Debug("Future milestone already exist", "endBlockNumber", key, "futureMilestoneHash", hash) + return + } + + log.Debug("Enqueing new future milestone", "endBlockNumber", key, "futureMilestoneHash", hash) + + m.FutureMilestoneList[key] = hash + m.FutureMilestoneOrder = append(m.FutureMilestoneOrder, key) + + err := rawdb.WriteFutureMilestoneList(m.db, m.FutureMilestoneOrder, m.FutureMilestoneList) + if err != nil { + log.Error("Error in writing future milestone data to db", "err", err) + } + + FutureMilestoneMeter.Update(int64(key)) +} + +// DequeueFutureMilestone remove the future milestone entry from the list. +func (m *milestone) dequeueFutureMilestone() { + delete(m.FutureMilestoneList, m.FutureMilestoneOrder[0]) + m.FutureMilestoneOrder = m.FutureMilestoneOrder[1:] + + err := rawdb.WriteFutureMilestoneList(m.db, m.FutureMilestoneOrder, m.FutureMilestoneList) + if err != nil { + log.Error("Error in writing future milestone data to db", "err", err) + } +} diff --git a/eth/downloader/whitelist/service.go b/eth/downloader/whitelist/service.go new file mode 100644 index 0000000000..08b92c536e --- /dev/null +++ b/eth/downloader/whitelist/service.go @@ -0,0 +1,235 @@ +package whitelist + +import ( + "errors" + "fmt" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" +) + +var ( + ErrMismatch = errors.New("mismatch error") + ErrNoRemote = errors.New("remote peer doesn't have a target block number") + + ErrCheckpointMismatch = errors.New("checkpoint mismatch") + ErrLongFutureChain = errors.New("received future chain of unacceptable length") + ErrNoRemoteCheckpoint = errors.New("remote peer doesn't have a checkpoint") +) + +type Service struct { + checkpointService + milestoneService +} + +func NewService(db ethdb.Database) *Service { + var checkpointDoExist = true + + checkpointNumber, checkpointHash, err := rawdb.ReadFinality[*rawdb.Checkpoint](db) + + if err != nil { + checkpointDoExist = false + } + + var milestoneDoExist = true + + milestoneNumber, milestoneHash, err := rawdb.ReadFinality[*rawdb.Milestone](db) + if err != nil { + milestoneDoExist = false + } + + locked, lockedMilestoneNumber, lockedMilestoneHash, lockedMilestoneIDs, err := rawdb.ReadLockField(db) + if err != nil || !locked { + locked = false + lockedMilestoneIDs = make(map[string]struct{}) + } + + order, list, err := rawdb.ReadFutureMilestoneList(db) + if err != nil { + order = make([]uint64, 0) + list = make(map[uint64]common.Hash) + } + + return &Service{ + &checkpoint{ + finality[*rawdb.Checkpoint]{ + doExist: checkpointDoExist, + Number: checkpointNumber, + Hash: checkpointHash, + interval: 256, + db: db, + }, + }, + + &milestone{ + finality: finality[*rawdb.Milestone]{ + doExist: milestoneDoExist, + Number: milestoneNumber, + Hash: milestoneHash, + interval: 256, + db: db, + }, + + Locked: locked, + LockedMilestoneNumber: lockedMilestoneNumber, + LockedMilestoneHash: lockedMilestoneHash, + LockedMilestoneIDs: lockedMilestoneIDs, + FutureMilestoneList: list, + FutureMilestoneOrder: order, + MaxCapacity: 10, + }, + } +} + +// IsValidPeer checks if the chain we're about to receive from a peer is valid or not +// in terms of reorgs. We won't reorg beyond the last bor checkpoint submitted to mainchain and last milestone voted in the heimdall +func (s *Service) IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) { + checkpointBool, err := s.checkpointService.IsValidPeer(fetchHeadersByNumber) + if !checkpointBool { + return checkpointBool, err + } + + milestoneBool, err := s.milestoneService.IsValidPeer(fetchHeadersByNumber) + if !milestoneBool { + return milestoneBool, err + } + + return true, nil +} + +func (s *Service) PurgeWhitelistedCheckpoint() { + s.checkpointService.Purge() +} + +func (s *Service) PurgeWhitelistedMilestone() { + s.milestoneService.Purge() +} + +func (s *Service) GetWhitelistedCheckpoint() (bool, uint64, common.Hash) { + return s.checkpointService.Get() +} + +func (s *Service) GetWhitelistedMilestone() (bool, uint64, common.Hash) { + return s.milestoneService.Get() +} + +func (s *Service) ProcessMilestone(endBlockNum uint64, endBlockHash common.Hash) { + s.milestoneService.Process(endBlockNum, endBlockHash) +} + +func (s *Service) ProcessCheckpoint(endBlockNum uint64, endBlockHash common.Hash) { + s.checkpointService.Process(endBlockNum, endBlockHash) +} + +func (s *Service) IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) { + checkpointBool, err := s.checkpointService.IsValidChain(currentHeader, chain) + if !checkpointBool { + return checkpointBool, err + } + + milestoneBool, err := s.milestoneService.IsValidChain(currentHeader, chain) + if !milestoneBool { + return milestoneBool, err + } + + return true, nil +} + +func (s *Service) GetMilestoneIDsList() []string { + return s.milestoneService.GetMilestoneIDsList() +} + +func splitChain(current uint64, chain []*types.Header) ([]*types.Header, []*types.Header) { + var ( + pastChain []*types.Header + futureChain []*types.Header + first = chain[0].Number.Uint64() + last = chain[len(chain)-1].Number.Uint64() + ) + + if current >= first { + if len(chain) == 1 || current >= last { + pastChain = chain + } else { + pastChain = chain[:current-first+1] + } + } + + if current < last { + if len(chain) == 1 || current < first { + futureChain = chain + } else { + futureChain = chain[current-first+1:] + } + } + + return pastChain, futureChain +} + +//nolint:unparam +func isValidChain(currentHeader *types.Header, chain []*types.Header, doExist bool, number uint64, hash common.Hash) (bool, error) { + // Check if we have milestone to validate incoming chain in memory + if !doExist { + // We don't have any entry, no additional validation will be possible + return true, nil + } + + current := currentHeader.Number.Uint64() + + // Check if imported chain is less than whitelisted number + if chain[len(chain)-1].Number.Uint64() < number { + if current >= number { //If current tip of the chain is greater than whitelist number then return false + return false, nil + } else { + return true, nil + } + } + + // Split the chain into past and future chain + pastChain, _ := splitChain(current, chain) + + // Iterate over the chain and validate against the last milestone + // It will handle all cases when the incoming chain has atleast one milestone + for i := len(pastChain) - 1; i >= 0; i-- { + if pastChain[i].Number.Uint64() == number { + res := pastChain[i].Hash() == hash + + return res, nil + } + } + + return true, nil +} + +// FIXME: remoteHeader is not used +func isValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error), doExist bool, number uint64, hash common.Hash) (bool, error) { + // Check for availaibility of the last milestone block. + // This can be also be empty if our heimdall is not responding + // or we're running without it. + if !doExist { + // worst case, we don't have the milestone in memory + return true, nil + } + + // todo: we can extract this as an interface and mock as well or just test IsValidChain in isolation from downloader passing fake fetchHeadersByNumber functions + headers, hashes, err := fetchHeadersByNumber(number, 1, 0, false) + if err != nil { + return false, fmt.Errorf("%w: last whitelisted block number %d, err %v", ErrNoRemote, number, err) + } + + if len(headers) == 0 { + return false, fmt.Errorf("%w: last whitlisted block number %d", ErrNoRemote, number) + } + + reqBlockNum := headers[0].Number.Uint64() + reqBlockHash := hashes[0] + + // Check against the whitelisted blocks + if reqBlockNum == number && reqBlockHash == hash { + return true, nil + } + + return false, ErrMismatch +} diff --git a/eth/downloader/whitelist/service_test.go b/eth/downloader/whitelist/service_test.go new file mode 100644 index 0000000000..f37af30f0c --- /dev/null +++ b/eth/downloader/whitelist/service_test.go @@ -0,0 +1,1152 @@ +// nolint +package whitelist + +import ( + "errors" + "fmt" + "math/big" + "reflect" + "sort" + "testing" + "time" + + "pgregory.net/rapid" + + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" +) + +// NewMockService creates a new mock whitelist service +func NewMockService(db ethdb.Database) *Service { + return &Service{ + + &checkpoint{ + finality[*rawdb.Checkpoint]{ + doExist: false, + interval: 256, + db: db, + }, + }, + + &milestone{ + finality: finality[*rawdb.Milestone]{ + doExist: false, + interval: 256, + db: db, + }, + LockedMilestoneIDs: make(map[string]struct{}), + FutureMilestoneList: make(map[uint64]common.Hash), + FutureMilestoneOrder: make([]uint64, 0), + MaxCapacity: 10, + }, + } +} + +// TestWhitelistCheckpoint checks the checkpoint whitelist setter and getter functions. +func TestWhitelistedCheckpoint(t *testing.T) { + t.Parallel() + + db := rawdb.NewMemoryDatabase() + + //Creating the service for the whitelisting the checkpoints + s := NewMockService(db) + + cp := s.checkpointService.(*checkpoint) + + require.Equal(t, cp.doExist, false, "expected false as no cp exist at this point") + + _, _, err := rawdb.ReadFinality[*rawdb.Checkpoint](db) + require.NotNil(t, err, "Error should be nil while reading from the db") + + //Adding the checkpoint + s.ProcessCheckpoint(11, common.Hash{}) + + require.Equal(t, cp.doExist, true, "expected true as cp exist") + + //Removing the checkpoint + s.PurgeWhitelistedCheckpoint() + + require.Equal(t, cp.doExist, false, "expected false as no cp exist at this point") + + //Adding the checkpoint + s.ProcessCheckpoint(12, common.Hash{1}) + + //Receiving the stored checkpoint + doExist, number, hash := s.GetWhitelistedCheckpoint() + + //Validating the values received + require.Equal(t, doExist, true, "expected true ascheckpoint exist at this point") + require.Equal(t, number, uint64(12), "expected number to be 11 but got", number) + require.Equal(t, hash, common.Hash{1}, "expected the 1 hash but got", hash) + require.NotEqual(t, hash, common.Hash{}, "expected the hash to be different from zero hash") + + c1 := s.checkpointService.(*checkpoint) + fmt.Println("!!!-0", c1.doExist) + s.PurgeWhitelistedCheckpoint() + fmt.Println("!!!-1", c1.doExist) + doExist, number, hash = s.GetWhitelistedCheckpoint() + fmt.Println("!!!-2", c1.doExist) + //Validating the values received from the db, not memory + require.Equal(t, doExist, true, "expected true ascheckpoint exist at this point") + require.Equal(t, number, uint64(12), "expected number to be 11 but got", number) + require.Equal(t, hash, common.Hash{1}, "expected the 1 hash but got", hash) + require.NotEqual(t, hash, common.Hash{}, "expected the hash to be different from zero hash") + + checkpointNumber, checkpointHash, err := rawdb.ReadFinality[*rawdb.Checkpoint](db) + require.Nil(t, err, "Error should be nil while reading from the db") + require.Equal(t, checkpointHash, common.Hash{1}, "expected the 1 hash but got", hash) + require.Equal(t, checkpointNumber, uint64(12), "expected number to be 11 but got", number) +} + +// TestMilestone checks the milestone whitelist setter and getter functions +func TestMilestone(t *testing.T) { + t.Parallel() + + db := rawdb.NewMemoryDatabase() + s := NewMockService(db) + + milestone := s.milestoneService.(*milestone) + + //Checking for the variables when no milestone is Processed + require.Equal(t, milestone.doExist, false, "expected false as no milestone exist at this point") + require.Equal(t, milestone.Locked, false, "expected false as it was not locked") + require.Equal(t, milestone.LockedMilestoneNumber, uint64(0), "expected 0 as it was not initialized") + + _, _, err := rawdb.ReadFinality[*rawdb.Milestone](db) + require.NotNil(t, err, "Error should be nil while reading from the db") + + //Acquiring the mutex lock + milestone.LockMutex(11) + require.Equal(t, milestone.Locked, false, "expected false as sprint is not locked till this point") + + //Releasing the mutex lock + milestone.UnlockMutex(true, "milestoneID1", uint64(11), common.Hash{}) + require.Equal(t, milestone.LockedMilestoneNumber, uint64(11), "expected 11 as it was not initialized") + require.Equal(t, milestone.Locked, true, "expected true as sprint is locked now") + require.Equal(t, len(milestone.LockedMilestoneIDs), 1, "expected 1 as only 1 milestoneID has been entered") + + _, ok := milestone.LockedMilestoneIDs["milestoneID1"] + require.True(t, ok, "milestoneID1 should exist in the LockedMilestoneIDs map") + + _, ok = milestone.LockedMilestoneIDs["milestoneID2"] + require.False(t, ok, "milestoneID2 shouldn't exist in the LockedMilestoneIDs map") + + milestone.LockMutex(11) + milestone.UnlockMutex(true, "milestoneID2", uint64(11), common.Hash{}) + require.Equal(t, len(milestone.LockedMilestoneIDs), 1, "expected 1 as only 1 milestoneID has been entered") + + _, ok = milestone.LockedMilestoneIDs["milestoneID2"] + require.True(t, ok, "milestoneID2 should exist in the LockedMilestoneIDs map") + + milestone.RemoveMilestoneID("milestoneID1") + require.Equal(t, len(milestone.LockedMilestoneIDs), 1, "expected 1 as one out of two has been removed in previous step") + require.Equal(t, milestone.Locked, true, "expected true as sprint is locked now") + + milestone.RemoveMilestoneID("milestoneID2") + require.Equal(t, len(milestone.LockedMilestoneIDs), 0, "expected 1 as both the milestonesIDs has been removed in previous step") + require.Equal(t, milestone.Locked, false, "expected false") + + milestone.LockMutex(11) + milestone.UnlockMutex(true, "milestoneID3", uint64(11), common.Hash{}) + require.True(t, milestone.Locked, "expected true") + require.Equal(t, milestone.LockedMilestoneNumber, uint64(11), "Expected 11") + + milestone.LockMutex(15) + require.True(t, milestone.Locked, "expected true") + require.Equal(t, milestone.LockedMilestoneNumber, uint64(11), "Expected 11") + milestone.UnlockMutex(true, "milestoneID4", uint64(15), common.Hash{}) + require.True(t, milestone.Locked, "expected true as final confirmation regarding the lock has been made") + require.Equal(t, len(milestone.LockedMilestoneIDs), 1, "expected 1 as previous milestonesIDs has been removed in previous step") + + //Adding the milestone + s.ProcessMilestone(11, common.Hash{}) + + require.True(t, milestone.Locked, "expected true as locked sprint is of number 15") + require.Equal(t, milestone.doExist, true, "expected true as milestone exist") + require.Equal(t, len(milestone.LockedMilestoneIDs), 1, "expected 1 as still last milestone of sprint number 15 exist") + + //Reading from the Db + locked, lockedMilestoneNumber, lockedMilestoneHash, lockedMilestoneIDs, err := rawdb.ReadLockField(db) + + require.Nil(t, err) + require.True(t, locked, "expected true as locked sprint is of number 15") + require.Equal(t, lockedMilestoneNumber, uint64(15), "Expected 15") + require.Equal(t, lockedMilestoneHash, common.Hash{}, "Expected", common.Hash{}) + require.Equal(t, len(lockedMilestoneIDs), 1, "expected 1 as still last milestone of sprint number 15 exist") + + _, ok = lockedMilestoneIDs["milestoneID4"] + require.True(t, ok, "expected true as milestoneIDList should contain 'milestoneID4'") + + //Asking the lock for sprintNumber less than last whitelisted milestone + require.False(t, milestone.LockMutex(11), "Cant lock the sprintNumber less than equal to latest whitelisted milestone") + milestone.UnlockMutex(false, "", uint64(11), common.Hash{}) //Unlock is required after every lock to release the mutex + + //Adding the milestone + s.ProcessMilestone(51, common.Hash{}) + require.False(t, milestone.Locked, "expected false as lock from sprint number 15 is removed") + require.Equal(t, milestone.doExist, true, "expected true as milestone exist") + require.Equal(t, len(milestone.LockedMilestoneIDs), 0, "expected 0 as all the milestones have been removed") + + //Reading from the Db + locked, _, _, lockedMilestoneIDs, err = rawdb.ReadLockField(db) + + require.Nil(t, err) + require.False(t, locked, "expected true as locked sprint is of number 15") + require.Equal(t, len(lockedMilestoneIDs), 0, "expected 0 as milestoneID exist in the map") + + //Removing the milestone + s.PurgeWhitelistedMilestone() + + require.Equal(t, milestone.doExist, false, "expected false as no milestone exist at this point") + + //Removing the milestone + s.ProcessMilestone(11, common.Hash{1}) + + doExist, number, hash := s.GetWhitelistedMilestone() + + //validating the values received + require.Equal(t, doExist, true, "expected true as milestone exist at this point") + require.Equal(t, number, uint64(11), "expected number to be 11 but got", number) + require.Equal(t, hash, common.Hash{1}, "expected the 1 hash but got", hash) + + s.PurgeWhitelistedMilestone() + doExist, number, hash = s.GetWhitelistedMilestone() + + //Validating the values received from the db, not memory + require.Equal(t, doExist, true, "expected true as milestone exist at this point") + require.Equal(t, number, uint64(11), "expected number to be 11 but got", number) + require.Equal(t, hash, common.Hash{1}, "expected the 1 hash but got", hash) + + milestoneNumber, milestoneHash, err := rawdb.ReadFinality[*rawdb.Milestone](db) + require.Nil(t, err, "Error should be nil while reading from the db") + require.Equal(t, milestoneHash, common.Hash{1}, "expected the 1 hash but got", hash) + require.Equal(t, milestoneNumber, uint64(11), "expected number to be 11 but got", number) + + _, _, err = rawdb.ReadFutureMilestoneList(db) + require.NotNil(t, err, "Error should be not nil") + + s.ProcessFutureMilestone(16, common.Hash{16}) + require.Equal(t, len(milestone.FutureMilestoneOrder), 1, "expected length is 1 as we added only 1 future milestone") + require.Equal(t, milestone.FutureMilestoneOrder[0], uint64(16), "expected value is 16 but got", milestone.FutureMilestoneOrder[0]) + require.Equal(t, milestone.FutureMilestoneList[16], common.Hash{16}, "expected value is", common.Hash{16}.String()[2:], "but got", milestone.FutureMilestoneList[16]) + + order, list, err := rawdb.ReadFutureMilestoneList(db) + require.Nil(t, err, "Error should be nil while reading from the db") + require.Equal(t, len(order), 1, "expected the 1 hash but got", len(order)) + require.Equal(t, order[0], uint64(16), "expected number to be 16 but got", order[0]) + require.Equal(t, list[order[0]], common.Hash{16}, "expected value is", common.Hash{16}.String()[2:], "but got", list[order[0]]) + + capicity := milestone.MaxCapacity + for i := 16; i <= 16*(capicity+1); i = i + 16 { + s.ProcessFutureMilestone(uint64(i), common.Hash{16}) + } + + require.Equal(t, len(milestone.FutureMilestoneOrder), capicity, "expected length is", capicity) + require.Equal(t, milestone.FutureMilestoneOrder[capicity-1], uint64(16*capicity), "expected value is", uint64(16*capicity), "but got", milestone.FutureMilestoneOrder[capicity-1]) +} + +// TestIsValidPeer checks the IsValidPeer function in isolation +// for different cases by providing a mock fetchHeadersByNumber function +func TestIsValidPeer(t *testing.T) { + t.Parallel() + + db := rawdb.NewMemoryDatabase() + s := NewMockService(db) + + // case1: no checkpoint whitelist, should consider the chain as valid + res, err := s.IsValidPeer(nil) + require.NoError(t, err, "expected no error") + require.Equal(t, res, true, "expected chain to be valid") + + // add checkpoint entry and mock fetchHeadersByNumber function + s.ProcessCheckpoint(uint64(1), common.Hash{}) + + // add milestone entry and mock fetchHeadersByNumber function + s.ProcessMilestone(uint64(1), common.Hash{}) + + checkpoint := s.checkpointService.(*checkpoint) + milestone := s.milestoneService.(*milestone) + + //Check whether the milestone and checkpoint exist + require.Equal(t, checkpoint.doExist, true, "expected true as checkpoint exists") + require.Equal(t, milestone.doExist, true, "expected true as milestone exists") + + // create a false function, returning absolutely nothing + falseFetchHeadersByNumber := func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error) { + return nil, nil, nil + } + + // case2: false fetchHeadersByNumber function provided, should consider the chain as invalid + // and throw `ErrNoRemoteCheckoint` error + res, err = s.IsValidPeer(falseFetchHeadersByNumber) + if err == nil { + t.Fatal("expected error, got nil") + } + + if !errors.Is(err, ErrNoRemote) { + t.Fatalf("expected error ErrNoRemote, got %v", err) + } + + require.Equal(t, res, false, "expected peer chain to be invalid") + + // create a mock function, returning the required header + fetchHeadersByNumber := func(number uint64, _ int, _ int, _ bool) ([]*types.Header, []common.Hash, error) { + hash := common.Hash{} + header := types.Header{Number: big.NewInt(0)} + + switch number { + case 0: + return []*types.Header{&header}, []common.Hash{hash}, nil + case 1: + header.Number = big.NewInt(1) + return []*types.Header{&header}, []common.Hash{hash}, nil + case 2: + header.Number = big.NewInt(1) // sending wrong header for misamatch + return []*types.Header{&header}, []common.Hash{hash}, nil + default: + return nil, nil, errors.New("invalid number") + } + } + + // case3: correct fetchHeadersByNumber function provided, should consider the chain as valid + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.NoError(t, err, "expected no error") + require.Equal(t, res, true, "expected chain to be valid") + + // add checkpoint whitelist entry + s.ProcessCheckpoint(uint64(2), common.Hash{}) + require.Equal(t, checkpoint.doExist, true, "expected true as checkpoint exists") + + // case4: correct fetchHeadersByNumber function provided with wrong header + // for block number 2. Should consider the chain as invalid and throw an error + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.Equal(t, err, ErrMismatch, "expected mismatch error") + require.Equal(t, res, false, "expected chain to be invalid") + + // create a mock function, returning the required header + fetchHeadersByNumber = func(number uint64, _ int, _ int, _ bool) ([]*types.Header, []common.Hash, error) { + hash := common.Hash{} + header := types.Header{Number: big.NewInt(0)} + + switch number { + case 0: + return []*types.Header{&header}, []common.Hash{hash}, nil + case 1: + header.Number = big.NewInt(1) + return []*types.Header{&header}, []common.Hash{hash}, nil + case 2: + header.Number = big.NewInt(2) + return []*types.Header{&header}, []common.Hash{hash}, nil + + case 3: + header.Number = big.NewInt(3) + hash3 := common.Hash{3} + + return []*types.Header{&header}, []common.Hash{hash3}, nil + + default: + return nil, nil, errors.New("invalid number") + } + } + + s.ProcessMilestone(uint64(3), common.Hash{}) + + //Case5: correct fetchHeadersByNumber function provided with hash mismatch, should consider the chain as invalid + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.Equal(t, err, ErrMismatch, "expected milestone mismatch error") + require.Equal(t, res, false, "expected chain to be invalid") + + s.ProcessMilestone(uint64(2), common.Hash{}) + + // create a mock function, returning the required header + fetchHeadersByNumber = func(number uint64, _ int, _ int, _ bool) ([]*types.Header, []common.Hash, error) { + hash := common.Hash{} + header := types.Header{Number: big.NewInt(0)} + + switch number { + case 0: + return []*types.Header{&header}, []common.Hash{hash}, nil + case 1: + header.Number = big.NewInt(1) + return []*types.Header{&header}, []common.Hash{hash}, nil + case 2: + header.Number = big.NewInt(2) + return []*types.Header{&header}, []common.Hash{hash}, nil + default: + return nil, nil, errors.New("invalid number") + } + } + + // case6: correct fetchHeadersByNumber function provided, should consider the chain as valid + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.NoError(t, err, "expected no error") + require.Equal(t, res, true, "expected chain to be valid") + + // create a mock function, returning the required header + fetchHeadersByNumber = func(number uint64, _ int, _ int, _ bool) ([]*types.Header, []common.Hash, error) { + hash := common.Hash{} + hash3 := common.Hash{3} + header := types.Header{Number: big.NewInt(0)} + + switch number { + case 0: + return []*types.Header{&header}, []common.Hash{hash}, nil + case 1: + header.Number = big.NewInt(1) + return []*types.Header{&header}, []common.Hash{hash}, nil + case 2: + header.Number = big.NewInt(2) + return []*types.Header{&header}, []common.Hash{hash}, nil + + case 3: + header.Number = big.NewInt(2) // sending wrong header for misamatch + return []*types.Header{&header}, []common.Hash{hash}, nil + + case 4: + header.Number = big.NewInt(4) // sending wrong header for misamatch + return []*types.Header{&header}, []common.Hash{hash3}, nil + default: + return nil, nil, errors.New("invalid number") + } + } + + //Add one more milestone in the list + s.ProcessMilestone(uint64(3), common.Hash{}) + + // case7: correct fetchHeadersByNumber function provided with wrong header for block 3, should consider the chain as invalid + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.Equal(t, err, ErrMismatch, "expected milestone mismatch error") + require.Equal(t, res, false, "expected chain to be invalid") + + //require.Equal(t, milestone.length(), 3, "expected 3 items in milestoneList") + + //Add one more milestone in the list + s.ProcessMilestone(uint64(4), common.Hash{}) + + // case8: correct fetchHeadersByNumber function provided with wrong hash for block 3, should consider the chain as valid + res, err = s.IsValidPeer(fetchHeadersByNumber) + require.Equal(t, err, ErrMismatch, "expected milestone mismatch error") + require.Equal(t, res, false, "expected chain to be invalid") +} + +// TestIsValidChain checks the IsValidChain function in isolation +// for different cases by providing a mock current header and chain +func TestIsValidChain(t *testing.T) { + t.Parallel() + + db := rawdb.NewMemoryDatabase() + s := NewMockService(db) + chainA := createMockChain(1, 20) // A1->A2...A19->A20 + + //Case1: no checkpoint whitelist and no milestone and no locking, should consider the chain as valid + res, err := s.IsValidChain(nil, chainA) + require.Nil(t, err) + require.Equal(t, res, true, "Expected chain to be valid") + + tempChain := createMockChain(21, 22) // A21->A22 + + // add mock checkpoint entry + s.ProcessCheckpoint(tempChain[1].Number.Uint64(), tempChain[1].Hash()) + + //Make the mock chain with zero blocks + zeroChain := make([]*types.Header, 0) + + //Case2: As input chain is of zero length,should consider the chain as invalid + res, err = s.IsValidChain(nil, zeroChain) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid", len(zeroChain)) + + //Case3A: As the received chain and current tip of local chain is behind the oldest whitelisted block entry, should consider + // the chain as valid + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + //Case3B: As the received chain is behind the oldest whitelisted block entry,but current tip is at par with whitelisted checkpoint, should consider + // the chain as invalid + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid ") + + // add mock milestone entry + s.ProcessMilestone(tempChain[1].Number.Uint64(), tempChain[1].Hash()) + + //Case4A: As the received chain and current tip of local chain is behind the oldest whitelisted block entry, should consider + // the chain as valid + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + //Case4B: As the received chain is behind the oldest whitelisted block entry and but current tip is at par with whitelisted milestine, should consider + // the chain as invalid + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid") + + //Remove the whitelisted checkpoint + s.PurgeWhitelistedCheckpoint() + + //Case5: As the received chain is still invalid after removing the checkpoint as it is + //still behind the whitelisted milestone + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid") + + //Remove the whitelisted milestone + s.PurgeWhitelistedMilestone() + + //At this stage there is no whitelisted milestone and checkpoint + + checkpoint := s.checkpointService.(*checkpoint) + milestone := s.milestoneService.(*milestone) + + //Locking for sprintNumber 15 + milestone.LockMutex(chainA[len(chainA)-5].Number.Uint64()) + milestone.UnlockMutex(true, "MilestoneID1", chainA[len(chainA)-5].Number.Uint64(), chainA[len(chainA)-5].Hash()) + + //Case6: As the received chain is valid as the locked sprintHash matches with the incoming chain. + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid as incoming chain matches with the locked value ") + + hash3 := common.Hash{3} + + //Locking for sprintNumber 16 with different hash + milestone.LockMutex(chainA[len(chainA)-4].Number.Uint64()) + milestone.UnlockMutex(true, "MilestoneID2", chainA[len(chainA)-4].Number.Uint64(), hash3) + + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid as incoming chain does match with the locked value hash ") + + //Locking for sprintNumber 19 + milestone.LockMutex(chainA[len(chainA)-1].Number.Uint64()) + milestone.UnlockMutex(true, "MilestoneID1", chainA[len(chainA)-1].Number.Uint64(), chainA[len(chainA)-1].Hash()) + + //Case7: As the received chain is valid as the locked sprintHash matches with the incoming chain. + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid as incoming chain is less than the locked value ") + + //Locking for sprintNumber 19 + milestone.LockMutex(uint64(21)) + milestone.UnlockMutex(true, "MilestoneID1", uint64(21), hash3) + + //Case8: As the received chain is invalid as the locked sprintHash matches is ahead of incoming chain. + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid as incoming chain is less than the locked value ") + + //Unlocking the sprint + milestone.UnlockSprint(uint64(21)) + + // Clear checkpoint whitelist and add block A15 in whitelist + s.PurgeWhitelistedCheckpoint() + s.ProcessCheckpoint(chainA[15].Number.Uint64(), chainA[15].Hash()) + + require.Equal(t, checkpoint.doExist, true, "expected true as checkpoint exists.") + + // case9: As the received chain is having valid checkpoint,should consider the chain as valid. + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + // add mock milestone entries + s.ProcessMilestone(tempChain[1].Number.Uint64(), tempChain[1].Hash()) + + // case10: Try importing a past chain having valid checkpoint, should + // consider the chain as invalid as still lastest milestone is ahead of the chain. + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid") + + // add mock milestone entries + s.ProcessMilestone(chainA[19].Number.Uint64(), chainA[19].Hash()) + + // case12: Try importing a chain having valid checkpoint and milestone, should + // consider the chain as valid + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be invalid") + + // add mock milestone entries + s.ProcessMilestone(chainA[19].Number.Uint64(), chainA[19].Hash()) + + // case13: Try importing a past chain having valid checkpoint and milestone, should + // consider the chain as valid + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + // add mock milestone entries with wrong hash + s.ProcessMilestone(chainA[19].Number.Uint64(), chainA[18].Hash()) + + // case14: Try importing a past chain having valid checkpoint and milestone with wrong hash, should + // consider the chain as invalid + res, err = s.IsValidChain(chainA[len(chainA)-1], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid as hash mismatches") + + // Clear milestone and add blocks A15 in whitelist + s.ProcessMilestone(chainA[15].Number.Uint64(), chainA[15].Hash()) + + // case16: Try importing a past chain having valid checkpoint, should + // consider the chain as valid + res, err = s.IsValidChain(tempChain[1], chainA) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + // Clear checkpoint whitelist and mock blocks in whitelist + tempChain = createMockChain(20, 20) // A20 + + s.PurgeWhitelistedCheckpoint() + s.ProcessCheckpoint(tempChain[0].Number.Uint64(), tempChain[0].Hash()) + + require.Equal(t, checkpoint.doExist, true, "expected true") + + // case17: Try importing a past chain having invalid checkpoint,should consider the chain as invalid + res, err = s.IsValidChain(tempChain[0], chainA) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid") + // Not checking error here because we return nil in case of checkpoint mismatch + + // case18: Try importing a future chain but within interval, should consider the chain as valid + res, err = s.IsValidChain(tempChain[len(tempChain)-1], tempChain) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be invalid") + + // create a future chain to be imported of length <= `checkpointInterval` + chainB := createMockChain(21, 30) // B21->B22...B29->B30 + + // case19: Try importing a future chain of acceptable length,should consider the chain as valid + res, err = s.IsValidChain(tempChain[0], chainB) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + s.PurgeWhitelistedCheckpoint() + s.PurgeWhitelistedMilestone() + + chainB = createMockChain(21, 29) // C21->C22....C29 + + s.milestoneService.ProcessFutureMilestone(29, chainB[8].Hash()) + + // case20: Try importing a future chain which match the future milestone should the chain as valid + res, err = s.IsValidChain(tempChain[0], chainB) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + chainB = createMockChain(21, 27) // C21->C22...C39->C40...C->256 + + // case21: Try importing a chain whose end point is less than future milestone + res, err = s.IsValidChain(tempChain[0], chainB) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be valid") + + chainB = createMockChain(30, 39) // C21->C22...C39->C40...C->256 + + //Processing wrong hash + s.milestoneService.ProcessFutureMilestone(38, chainB[9].Hash()) + + // case22: Try importing a future chain with mismatch future milestone + res, err = s.IsValidChain(tempChain[0], chainB) + require.Nil(t, err) + require.Equal(t, res, false, "expected chain to be invalid") + + chainB = createMockChain(40, 49) // C40->C41...C48->C49 + + // case23: Try importing a future chain whose starting point is ahead of latest future milestone + res, err = s.IsValidChain(tempChain[0], chainB) + require.Nil(t, err) + require.Equal(t, res, true, "expected chain to be invalid") + +} + +func TestPropertyBasedTestingMilestone(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + + db := rawdb.NewMemoryDatabase() + + milestone := milestone{ + finality: finality[*rawdb.Milestone]{ + doExist: false, + Number: 0, + Hash: common.Hash{}, + interval: 256, + db: db, + }, + + Locked: false, + LockedMilestoneNumber: 0, + LockedMilestoneHash: common.Hash{}, + LockedMilestoneIDs: make(map[string]struct{}), + FutureMilestoneList: make(map[uint64]common.Hash), + FutureMilestoneOrder: make([]uint64, 0), + MaxCapacity: 10, + } + + var ( + milestoneEndNum = rapid.Uint64().Draw(t, "endBlock") + milestoneID = rapid.String().Draw(t, "MilestoneID") + doLock = rapid.Bool().Draw(t, "Voted") + ) + + val := milestone.LockMutex(milestoneEndNum.(uint64)) + if !val { + t.Error("LockMutex need to return true when there is no whitelisted milestone and locked milestone") + } + + milestone.UnlockMutex(doLock.(bool), milestoneID.(string), milestoneEndNum.(uint64), common.Hash{}) + + if doLock.(bool) { + //Milestone should not be whitelisted + if milestone.doExist { + t.Error("Milestone is not expected to be whitelisted") + } + + //Local chain should be locked + if !milestone.Locked { + t.Error("Milestone is expected to be locked at", milestoneEndNum.(uint64)) + } + + if milestone.LockedMilestoneNumber != milestoneEndNum.(uint64) { + t.Error("Locked milestone number is expected to be", milestoneEndNum.(uint64)) + } + + if len(milestone.LockedMilestoneIDs) != 1 { + t.Error("List should contain 1 milestone") + } + + _, ok := milestone.LockedMilestoneIDs[milestoneID.(string)] + + if !ok { + t.Error("List doesn't contain correct milestoneID") + } + } + + if !doLock.(bool) { + if milestone.doExist { + t.Error("Milestone is not expected to be whitelisted") + } + + if milestone.Locked { + t.Error("Milestone is expected not to be locked") + } + + if milestone.LockedMilestoneNumber != 0 { + t.Error("Locked milestone number is expected to be", 0) + } + + if len(milestone.LockedMilestoneIDs) != 0 { + t.Error("List should not contain milestone") + } + + _, ok := milestone.LockedMilestoneIDs[milestoneID.(string)] + + if ok { + t.Error("List shouldn't contain any milestoneID") + } + } + + fitlerFn := func(i uint64) bool { + if i <= uint64(1000) { + return true + } + + return false + } + + var ( + start = rapid.Uint64Max(milestoneEndNum.(uint64)).Draw(t, "start for mock chain") + end = rapid.Uint64Min(start.(uint64)).Filter(fitlerFn).Draw(t, "end for mock chain") + ) + + chainTemp := createMockChain(start.(uint64), end.(uint64)) + + val, err := milestone.IsValidChain(chainTemp[0], chainTemp) + if err != nil { + t.Error("Error", err) + } + + if doLock.(bool) && val { + t.Error("When the chain is locked at milestone, it should not pass IsValidChain for incompatible incoming chain") + } + + if !doLock.(bool) && !val { + t.Error("When the chain is not locked at milestone, it should pass IsValidChain for incoming chain") + } + + var ( + milestoneEndNum2 = rapid.Uint64().Draw(t, "endBlockNum 2") + milestoneID2 = rapid.String().Draw(t, "MilestoneID 2") + doLock2 = rapid.Bool().Draw(t, "Voted 2") + ) + + val = milestone.LockMutex(milestoneEndNum2.(uint64)) + + if doLock.(bool) && milestoneEndNum.(uint64) > milestoneEndNum2.(uint64) && val { + t.Error("LockMutex need to return false as previous locked milestone is greater") + } + + if doLock.(bool) && milestoneEndNum.(uint64) <= milestoneEndNum2.(uint64) && !val { + t.Error("LockMutex need to return true as previous locked milestone is less") + } + + milestone.UnlockMutex(doLock2.(bool), milestoneID2.(string), milestoneEndNum2.(uint64), common.Hash{}) + + if doLock2.(bool) { + if milestone.doExist { + t.Error("Milestone is not expected to be whitelisted") + } + + if !milestone.Locked { + t.Error("Milestone is expected to be locked at", milestoneEndNum2.(uint64)) + } + + if milestone.LockedMilestoneNumber != milestoneEndNum2.(uint64) { + t.Error("Locked milestone number is expected to be", milestoneEndNum.(uint64)) + } + + if len(milestone.LockedMilestoneIDs) != 1 { + t.Error("List should contain 1 milestone") + } + + _, ok := milestone.LockedMilestoneIDs[milestoneID2.(string)] + + if !ok { + t.Error("List doesn't contain correct milestoneID") + } + } + + if !doLock2.(bool) { + if milestone.doExist { + t.Error("Milestone is not expected to be whitelisted") + } + + if !doLock.(bool) && milestone.Locked { + t.Error("Milestone is expected not to be locked") + } + + if doLock.(bool) && !milestone.Locked { + t.Error("Milestone is expected to be locked at", milestoneEndNum.(uint64)) + } + + if !doLock.(bool) && milestone.LockedMilestoneNumber != 0 { + t.Error("Locked milestone number is expected to be", 0) + } + + if doLock.(bool) && milestone.LockedMilestoneNumber != milestoneEndNum.(uint64) { + t.Error("Locked milestone number is expected to be", milestoneEndNum.(uint64)) + } + + if !doLock.(bool) && len(milestone.LockedMilestoneIDs) != 0 { + t.Error("List should not contain milestone") + } + + if doLock.(bool) && len(milestone.LockedMilestoneIDs) != 1 { + t.Error("List should not contain milestone") + } + + _, ok := milestone.LockedMilestoneIDs[milestoneID.(string)] + + if !doLock.(bool) && ok { + t.Error("List shouldn't contain any milestoneID") + } + + if doLock.(bool) && !ok { + t.Error("List should contain milestoneID") + } + } + + var ( + milestoneNum = rapid.Uint64().Draw(t, "milestone Number") + ) + + lockedValue := milestone.LockedMilestoneNumber + + milestone.Process(milestoneNum.(uint64), common.Hash{}) + + isChainLocked := doLock.(bool) || doLock2.(bool) + + if !milestone.doExist { + t.Error("Should have the whitelisted milestone") + } + + if milestone.finality.Number != milestoneNum.(uint64) { + t.Error("Should have the whitelisted milestone", milestoneNum.(uint64)) + } + + if isChainLocked { + if milestoneNum.(uint64) < lockedValue { + if !milestone.Locked { + t.Error("Milestone is expected to be locked") + } + } else { + if milestone.Locked { + t.Error("Milestone is expected not to be locked") + } + } + } + + var ( + futureMilestoneNum = rapid.Uint64Min(milestoneNum.(uint64)).Draw(t, "future milestone Number") + ) + + isChainLocked = milestone.Locked + + milestone.ProcessFutureMilestone(futureMilestoneNum.(uint64), common.Hash{}) + + if isChainLocked { + if futureMilestoneNum.(uint64) < lockedValue { + if !milestone.Locked { + t.Error("Milestone is expected to be locked") + } + } else { + if milestone.Locked { + t.Error("Milestone is expected not to be locked") + } + } + } + }) +} + +func TestSplitChain(t *testing.T) { + t.Parallel() + + type Result struct { + pastStart uint64 + pastEnd uint64 + futureStart uint64 + futureEnd uint64 + pastLength int + futureLength int + } + + // Current chain is at block: X + // Incoming chain is represented as [N, M] + testCases := []struct { + name string + current uint64 + chain []*types.Header + result Result + }{ + {name: "X = 10, N = 11, M = 20", current: uint64(10), chain: createMockChain(11, 20), result: Result{futureStart: 11, futureEnd: 20, futureLength: 10}}, + {name: "X = 10, N = 13, M = 20", current: uint64(10), chain: createMockChain(13, 20), result: Result{futureStart: 13, futureEnd: 20, futureLength: 8}}, + {name: "X = 10, N = 2, M = 10", current: uint64(10), chain: createMockChain(2, 10), result: Result{pastStart: 2, pastEnd: 10, pastLength: 9}}, + {name: "X = 10, N = 2, M = 9", current: uint64(10), chain: createMockChain(2, 9), result: Result{pastStart: 2, pastEnd: 9, pastLength: 8}}, + {name: "X = 10, N = 2, M = 8", current: uint64(10), chain: createMockChain(2, 8), result: Result{pastStart: 2, pastEnd: 8, pastLength: 7}}, + {name: "X = 10, N = 5, M = 15", current: uint64(10), chain: createMockChain(5, 15), result: Result{pastStart: 5, pastEnd: 10, pastLength: 6, futureStart: 11, futureEnd: 15, futureLength: 5}}, + {name: "X = 10, N = 10, M = 20", current: uint64(10), chain: createMockChain(10, 20), result: Result{pastStart: 10, pastEnd: 10, pastLength: 1, futureStart: 11, futureEnd: 20, futureLength: 10}}, + } + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + past, future := splitChain(tc.current, tc.chain) + require.Equal(t, len(past), tc.result.pastLength) + require.Equal(t, len(future), tc.result.futureLength) + + if len(past) > 0 { + // Check if we have expected block/s + require.Equal(t, past[0].Number.Uint64(), tc.result.pastStart) + require.Equal(t, past[len(past)-1].Number.Uint64(), tc.result.pastEnd) + } + + if len(future) > 0 { + // Check if we have expected block/s + require.Equal(t, future[0].Number.Uint64(), tc.result.futureStart) + require.Equal(t, future[len(future)-1].Number.Uint64(), tc.result.futureEnd) + } + }) + } +} + +//nolint:gocognit +func TestSplitChainProperties(t *testing.T) { + t.Parallel() + + // Current chain is at block: X + // Incoming chain is represented as [N, M] + + currentChain := []int{0, 1, 2, 3, 10, 100} // blocks starting from genesis + blockDiffs := []int{0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 90, 100, 101, 102} + + caseParams := make(map[int]map[int]map[int]struct{}) // X -> N -> M + + for _, current := range currentChain { + // past cases only + past to current + for _, diff := range blockDiffs { + from := current - diff + + // use int type for everything to not care about underflow + if from < 0 { + continue + } + + for _, diff := range blockDiffs { + to := current - diff + + if to >= from { + addTestCaseParams(caseParams, current, from, to) + } + } + } + + // future only + current to future + for _, diff := range blockDiffs { + from := current + diff + + if from < 0 { + continue + } + + for _, diff := range blockDiffs { + to := current + diff + + if to >= from { + addTestCaseParams(caseParams, current, from, to) + } + } + } + + // past-current-future + for _, diff := range blockDiffs { + from := current - diff + + if from < 0 { + continue + } + + for _, diff := range blockDiffs { + to := current + diff + + if to >= from { + addTestCaseParams(caseParams, current, from, to) + } + } + } + } + + type testCase struct { + current int + remoteStart int + remoteEnd int + } + + var ts []testCase + + // X -> N -> M + for x, nm := range caseParams { + for n, mMap := range nm { + for m := range mMap { + ts = append(ts, testCase{x, n, m}) + } + } + } + + //nolint:paralleltest + for i, tc := range ts { + tc := tc + + name := fmt.Sprintf("test case: index = %d, X = %d, N = %d, M = %d", i, tc.current, tc.remoteStart, tc.remoteEnd) + + t.Run(name, func(t *testing.T) { + t.Parallel() + + chain := createMockChain(uint64(tc.remoteStart), uint64(tc.remoteEnd)) + + past, future := splitChain(uint64(tc.current), chain) + + // properties + if len(past) > 0 { + // Check if the chain is ordered + isOrdered := sort.SliceIsSorted(past, func(i, j int) bool { + return past[i].Number.Uint64() < past[j].Number.Uint64() + }) + + require.True(t, isOrdered, "an ordered past chain expected: %v", past) + + isSequential := sort.SliceIsSorted(past, func(i, j int) bool { + return past[i].Number.Uint64() == past[j].Number.Uint64()-1 + }) + + require.True(t, isSequential, "a sequential past chain expected: %v", past) + + // Check if current block >= past chain's last block + require.Equal(t, past[len(past)-1].Number.Uint64() <= uint64(tc.current), true) + } + + if len(future) > 0 { + // Check if the chain is ordered + isOrdered := sort.SliceIsSorted(future, func(i, j int) bool { + return future[i].Number.Uint64() < future[j].Number.Uint64() + }) + + require.True(t, isOrdered, "an ordered future chain expected: %v", future) + + isSequential := sort.SliceIsSorted(future, func(i, j int) bool { + return future[i].Number.Uint64() == future[j].Number.Uint64()-1 + }) + + require.True(t, isSequential, "a sequential future chain expected: %v", future) + + // Check if future chain's first block > current block + require.Equal(t, future[len(future)-1].Number.Uint64() > uint64(tc.current), true) + } + + // Check if both chains are continuous + if len(past) > 0 && len(future) > 0 { + require.Equal(t, past[len(past)-1].Number.Uint64(), future[0].Number.Uint64()-1) + } + + // Check if we get the original chain on appending both + gotChain := append(past, future...) + require.Equal(t, reflect.DeepEqual(gotChain, chain), true) + }) + } +} + +// createMockChain returns a chain with dummy headers +// starting from `start` to `end` (inclusive) +func createMockChain(start, end uint64) []*types.Header { + var ( + i uint64 + idx uint64 + ) + + chain := make([]*types.Header, end-start+1) + + for i = start; i <= end; i++ { + header := &types.Header{ + Number: big.NewInt(int64(i)), + Time: uint64(time.Now().UnixMicro()) + i, + } + chain[idx] = header + idx++ + } + + return chain +} + +// mXNM should be initialized +func addTestCaseParams(mXNM map[int]map[int]map[int]struct{}, x, n, m int) { + //nolint:ineffassign + mNM, ok := mXNM[x] + if !ok { + mNM = make(map[int]map[int]struct{}) + mXNM[x] = mNM + } + + //nolint:ineffassign + _, ok = mNM[n] + if !ok { + mM := make(map[int]struct{}) + mNM[n] = mM + } + + mXNM[x][n][m] = struct{}{} +} diff --git a/ethclient/bor_ethclient.go b/ethclient/bor_ethclient.go new file mode 100644 index 0000000000..d40cdc6d8e --- /dev/null +++ b/ethclient/bor_ethclient.go @@ -0,0 +1,41 @@ +package ethclient + +import ( + "context" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +// GetRootHash returns the merkle root of the block headers +func (ec *Client) GetRootHash(ctx context.Context, startBlockNumber uint64, endBlockNumber uint64) (string, error) { + var rootHash string + if err := ec.c.CallContext(ctx, &rootHash, "bor_getRootHash", startBlockNumber, endBlockNumber); err != nil { + return "", err + } + + return rootHash, nil +} + +// GetRootHash returns the merkle root of the block headers +func (ec *Client) GetVoteOnHash(ctx context.Context, startBlockNumber uint64, endBlockNumber uint64, hash string, milestoneID string) (bool, error) { + var value bool + if err := ec.c.CallContext(ctx, &value, "bor_getVoteOnHash", startBlockNumber, endBlockNumber, hash, milestoneID); err != nil { + return false, err + } + + return value, nil +} + +// GetBorBlockReceipt returns bor block receipt +func (ec *Client) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) { + var r *types.Receipt + + err := ec.c.CallContext(ctx, &r, "eth_getBorBlockReceipt", hash) + if err == nil && r == nil { + return nil, ethereum.NotFound + } + + return r, err +} diff --git a/go.mod b/go.mod index 651b1a2ab6..bb958cba5b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ethereum/go-ethereum -go 1.19 +go 1.20 require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 @@ -16,11 +16,13 @@ require ( github.com/cloudflare/cloudflare-go v0.14.0 github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 github.com/consensys/gnark-crypto v0.11.0 + github.com/cosmos/cosmos-sdk v0.46.2 github.com/davecgh/go-spew v1.1.1 github.com/deckarep/golang-set/v2 v2.1.0 github.com/docker/docker v1.6.2 github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 github.com/edsrzf/mmap-go v1.0.0 + github.com/emirpasic/gods v1.18.1 github.com/fatih/color v1.13.0 github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 @@ -32,14 +34,16 @@ require ( github.com/go-stack/stack v1.8.1 github.com/gofrs/flock v0.8.1 github.com/golang-jwt/jwt/v4 v4.3.0 - github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf v1.5.3 github.com/golang/snappy v0.0.4 - github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa + github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 github.com/graph-gophers/graphql-go v1.3.0 + github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/hashicorp/go-bexpr v0.1.10 + github.com/heimdalr/dag v1.2.1 github.com/holiman/bloomfilter/v2 v2.0.3 github.com/holiman/uint256 v1.2.2 github.com/huin/goupnp v1.0.3 @@ -52,34 +56,150 @@ require ( github.com/karalabe/usb v0.0.2 github.com/kylelemons/godebug v1.1.0 github.com/lib/pq v1.2.0 + github.com/maticnetwork/crand v1.0.2 + github.com/maticnetwork/heimdall v0.3.1-0.20230227104835-81bd1055b0bc + github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53 github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-isatty v0.0.16 github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 github.com/olekukonko/tablewriter v0.0.5 - github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 + github.com/peterh/liner v1.2.0 github.com/rs/cors v1.7.0 github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible - github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 - github.com/stretchr/testify v1.8.2 + github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d + github.com/stretchr/testify v1.8.4 github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tyler-smith/go-bip39 v1.1.0 github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa - golang.org/x/crypto v0.7.0 + golang.org/x/crypto v0.13.0 golang.org/x/exp v0.0.0-20230206171751-46f607a40771 - golang.org/x/sync v0.1.0 - golang.org/x/sys v0.6.0 - golang.org/x/text v0.8.0 - golang.org/x/time v0.0.0-20220922220347-f3bd1da661af + golang.org/x/sync v0.3.0 + golang.org/x/sys v0.12.0 + golang.org/x/text v0.13.0 + golang.org/x/time v0.3.0 golang.org/x/tools v0.6.0 gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce + gotest.tools v2.2.0+incompatible + pgregory.net/rapid v0.4.8 ) require ( + cloud.google.com/go v0.110.4 // indirect + cloud.google.com/go/compute v1.21.0 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/iam v1.1.1 // indirect + cloud.google.com/go/pubsub v1.32.0 // indirect + github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect + github.com/RichardKnop/machinery v1.7.4 // indirect + github.com/RichardKnop/redsync v1.2.0 // indirect + github.com/aws/aws-sdk-go v1.34.28 // indirect + github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect + github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect + github.com/btcsuite/btcd v0.22.0-beta // indirect + github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect + github.com/cbergoon/merkletree v0.2.0 // indirect + github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8 // indirect + github.com/cosmos/ledger-cosmos-go v0.10.3 // indirect + github.com/cosmos/ledger-go v0.9.2 // indirect + github.com/etcd-io/bbolt v1.3.3 // indirect + github.com/go-kit/kit v0.10.0 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/go-redis/redis v6.15.7+incompatible // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/gomodule/redigo v2.0.0+incompatible // indirect + github.com/google/s2a-go v0.1.4 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect + github.com/googleapis/gax-go/v2 v2.11.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/jmhodges/levigo v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kelseyhightower/envconfig v1.4.0 // indirect + github.com/libp2p/go-buffer-pool v0.0.2 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pborman/uuid v1.2.1 // indirect + github.com/pelletier/go-toml/v2 v2.0.5 // indirect + github.com/rakyll/statik v0.1.7 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/cobra v1.5.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.13.0 // indirect + github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71 // indirect + github.com/stumble/gorocksdb v0.0.3 // indirect + github.com/subosito/gotenv v1.4.1 // indirect + github.com/tendermint/btcd v0.1.1 // indirect + github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect + github.com/tendermint/go-amino v0.15.0 // indirect + github.com/tendermint/iavl v0.12.4 // indirect + github.com/tendermint/tm-db v0.2.0 // indirect + github.com/xdg/scram v1.0.3 // indirect + github.com/xdg/stringprep v1.0.3 // indirect + github.com/zondax/hid v0.9.0 // indirect + go.mongodb.org/mongo-driver v1.3.0 // indirect + go.opencensus.io v0.24.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + google.golang.org/api v0.126.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect +) + +require ( + github.com/BurntSushi/toml v1.3.2 + github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.1 // indirect + github.com/agext/levenshtein v1.2.1 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bits-and-blooms/bitset v1.5.0 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/golang/mock v1.6.0 + github.com/google/go-cmp v0.5.9 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.0.0 // indirect + github.com/hashicorp/golang-lru v1.0.2 + github.com/hashicorp/hcl/v2 v2.18.0 + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.11 + github.com/mitchellh/cli v1.1.5 + github.com/mitchellh/copystructure v1.0.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/mitchellh/reflectwalk v1.0.0 // indirect + github.com/pelletier/go-toml v1.9.5 + github.com/posener/complete v1.1.1 // indirect + github.com/ryanuber/columnize v2.1.2+incompatible + github.com/shopspring/decimal v1.2.0 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/tendermint/tendermint v0.32.7 + github.com/xsleonard/go-merkle v1.1.0 + github.com/zclconf/go-cty v1.13.0 // indirect + go.opentelemetry.io/otel v1.19.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 + go.opentelemetry.io/otel/metric v1.19.0 // indirect + go.opentelemetry.io/otel/sdk v1.19.0 + go.opentelemetry.io/otel/trace v1.19.0 + go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.23.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/grpc v1.58.2 gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect ) @@ -87,14 +207,13 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect - github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.0.2 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.0.2 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.1.1 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.1.1 // indirect github.com/aws/smithy-go v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect @@ -108,7 +227,7 @@ require ( github.com/ferranbt/fastssz v0.1.3 // indirect github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect - github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-ole/go-ole v1.2.5 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/goccy/go-yaml v1.9.6 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -133,17 +252,23 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect github.com/tklauser/numcpus v0.2.2 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.8.0 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/net v0.12.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +replace github.com/cosmos/cosmos-sdk => github.com/maticnetwork/cosmos-sdk v0.37.5-0.20220311095845-81690c6a53e7 + +replace github.com/tendermint/tendermint => github.com/maticnetwork/tendermint v0.26.0-dev0.0.20220923185258-3e7c7f86ce9f + +replace github.com/ethereum/go-ethereum => github.com/maticnetwork/bor v0.4.0 diff --git a/go.sum b/go.sum index c92e8bf331..394fd3cf17 100644 --- a/go.sum +++ b/go.sum @@ -4,20 +4,55 @@ cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSR cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= +cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= +cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= +cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= +cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= +cloud.google.com/go/kms v1.12.1 h1:xZmZuwy2cwzsocmKDOPu4BL7umg8QXagQx6fKVmf45U= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/pubsub v1.32.0 h1:JOEkgEYBuUTHSyHS4TcqOFuWr+vD6qO/imsFqShUCp4= +cloud.google.com/go/pubsub v1.32.0/go.mod h1:f+w71I33OMyxf9VpMVcZbnG5KSUkCOUHYpFd5U1GdRc= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= +git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1 h1:qoVeMsc9/fh/yhxVaA0obYjVH/oI/ihrOoMwsLS9KSA= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= @@ -26,32 +61,91 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSu github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 h1:Px2UA+2RvSSvv+RvJNuUB6n7rs5Wsel4dXLe90Um2n4= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/JekaMas/crand v1.0.1/go.mod h1:GGzGpMCht/tbaNQ5A4kSiKSqEoNAhhyTfSDQyIENBQU= +github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d h1:RO27lgfZF8s9lZ3pWyzc0gCE0RZC+6/PXbRjAa0CNp8= +github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d/go.mod h1:romz7UPgSYhfJkKOalzEEyV6sWtt/eAEm0nX2aOrod0= +github.com/JekaMas/workerpool v1.1.5/go.mod h1:IoDWPpwMcA27qbuugZKeBslDrgX09lVmksuh9sjzbhc= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig/v3 v3.2.1 h1:n6EPaDyLSvCEa3frruQvAiHuNp2dhBlMSmkEr+HuzGc= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae h1:DcFpTQBYQ9Ct2d6sC7ol0/ynxc2pO1cpGUM+f4t5adg= +github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae/go.mod h1:rJJ84PyA/Wlmw1hO+xTzV2wsSUon6J5ktg0g8BF2PuU= +github.com/RichardKnop/machinery v1.7.4 h1:QMHik7BaeN3TsfXcg48xw6tsM9IqzC8rBgoK5i6/IPA= +github.com/RichardKnop/machinery v1.7.4/go.mod h1:W87mnh7t91WdrwGbdnAjvDzqD/bqBV+0+GF276gv/bU= +github.com/RichardKnop/redsync v1.2.0 h1:gK35hR3zZkQigHKm8wOGb9MpJ9BsrW6MzxezwjTcHP0= +github.com/RichardKnop/redsync v1.2.0/go.mod h1:9b8nBGAX3bE2uCfJGSnsDvF23mKyHTZzmvmj5FH3Tp0= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY= +github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= +github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= +github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= +github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc= +github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/attestantio/go-builder-client v0.3.0 h1:NY7pUNT070T3tx/N8hCaO5KpExvaVQhH//9zsgRh43M= github.com/attestantio/go-builder-client v0.3.0/go.mod h1:DwesMTOqnCp4u+n3uZ+fWL8wwnSBZVD9VMIVPDR+AZE= github.com/attestantio/go-eth2-client v0.16.3 h1:D6LLwswDlHbUwsAqfBKaKXjWdBzRlNQRXUoC+5vFsDw= github.com/attestantio/go-eth2-client v0.16.3/go.mod h1:Om16oH+H34E2JHoOY8hLWg+64twlO+AjAE7kkK3f1Xc= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.29.15/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg= +github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPIk= +github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.2.0 h1:BS+UYpbsElC82gB+2E2jiCBg36i8HlubTB/dO/moQ9c= github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2/config v1.1.1 h1:ZAoq32boMzcaTW9bcUacBswAmHTbvlvDJICgHFZuECo= @@ -71,34 +165,77 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.1.1/go.mod h1:Wi0EBZwiz/K44YliU0EKxq github.com/aws/smithy-go v1.1.0 h1:D6CSsM3gdxaGaqXnPgOBCeL6Mophqzu7KJOu7zW78sU= github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d h1:1aAija9gr0Hyv4KfQcRcwlmFIrhkDmIj2dz5bkg/s/8= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8= github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= +github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0= +github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= +github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= +github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cbergoon/merkletree v0.2.0 h1:Bttqr3OuoiZEo4ed1L7fTasHka9II+BF9fhBfbNEEoQ= +github.com/cbergoon/merkletree v0.2.0/go.mod h1:5c15eckUgiucMGDOCanvalj/yJnD+KAZj1qyJtRW5aM= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.14.0 h1:gFqGlGl/5f9UGXAaKapCGUfaTCgRKKnzu2VvzMZlOFA= github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD93PBm/jA= github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= @@ -110,31 +247,53 @@ github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoG github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= +github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks= github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8 h1:Iwin12wRQtyZhH6FV3ykFcdGNlYEzoeR0jN8Vn+JWsI= +github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/ledger-cosmos-go v0.10.3 h1:Qhi5yTR5Pg1CaTpd00pxlGwNl4sFRdtK1J96OTjeFFc= +github.com/cosmos/ledger-cosmos-go v0.10.3/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= +github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20220523130400-f11357ae11c7 h1:6IrxszG5G+O7zhtkWxq6+unVvnrm1fqV2Pe+T95DUzw= github.com/crate-crypto/go-ipa v0.0.0-20220523130400-f11357ae11c7/go.mod h1:gFnFS95y8HstDP6P9pPwzrxOOC5TRDkwbM+ao15ChAI= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= @@ -142,30 +301,55 @@ github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6ps github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/docker/docker v1.6.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v1.6.2 h1:HlFGsy+9/xrgMmhmN+NGhCc5SHGJ7I+kHosRR1xc/aI= github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 h1:kgvzE5wLsLa7XKfV85VZl40QXaMCaeFtHpPwJ8fhotY= github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/etcd-io/bbolt v1.3.3 h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -181,10 +365,18 @@ github.com/flashbots/go-boost-utils v1.6.1-0.20230530114823-e5d0f8730a0f/go.mod github.com/flashbots/go-utils v0.4.8 h1:WDJXryrqShGq4HFe+p1kGjObXSqzT7Sy/+9YvFpr5tM= github.com/flashbots/go-utils v0.4.8/go.mod h1:dBmSv4Cpqij4xKP50bdisAvFIo4/EgsY97BMpVjPzr0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gammazero/deque v0.2.0/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= +github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= @@ -206,16 +398,38 @@ github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclK github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= +github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= +github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= +github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= +github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= +github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= +github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -223,14 +437,45 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= +github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= +github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -240,9 +485,12 @@ github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -253,14 +501,31 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -269,15 +534,20 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= @@ -287,55 +557,137 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= +github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= +github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY41SORZyNJ0= github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/hcl/v2 v2.10.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= +github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/heimdalr/dag v1.2.1 h1:XJOMaoWqJK1UKdp+4zaO2uwav9GFbHMGCirdViKMRIQ= +github.com/heimdalr/dag v1.2.1/go.mod h1:Of/wUB7Yoj4dwiOcGOOYIq6MHlPF/8/QMBKFJpwg+yc= +github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e/go.mod h1:j9cQbcqHQujT0oKJ38PylVfqohClLr3CvDC+Qcg+lhU= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.2.2 h1:TXKcSGc2WaxPD2+bmzAsVthL4+pEN0YwXcL5qED83vk= github.com/holiman/uint256 v1.2.2/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= github.com/influxdata/influxdb v1.8.3 h1:WEypI1BQFTT4teLM+1qkEcvUi0dAvopAI/ir0vAiBg8= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k= github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= @@ -354,12 +706,29 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e h1:UvSe12bq+Uj2hWd8aOlwPmoZ+CITRFrdit+sDGfAg8U= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= +github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= @@ -367,22 +736,32 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= +github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= +github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.10.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= @@ -393,6 +772,9 @@ github.com/klauspost/cpuid/v2 v2.2.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -403,6 +785,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= @@ -415,26 +798,54 @@ github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= +github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/maticnetwork/bor v0.4.0/go.mod h1:l1YMTszDgq9ljutxKU6iYEDbDRjFjUIuf4Z32R94dWY= +github.com/maticnetwork/cosmos-sdk v0.37.5-0.20220311095845-81690c6a53e7 h1:8NoEtDFvY0r9KTow/jgEwOfTCPnXOs6MlEdUhRUQY78= +github.com/maticnetwork/cosmos-sdk v0.37.5-0.20220311095845-81690c6a53e7/go.mod h1:uW55Ru86N5o3L8SVkVL1TPE+mV/WRM2la8sC3TR/Ajc= +github.com/maticnetwork/crand v1.0.2 h1:Af0tAivC8zrxXDpGWNWVT/0s1fOz8w0eRbahZgURS8I= +github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxpj5ZKxfHjyg= +github.com/maticnetwork/heimdall v0.3.1-0.20230105132832-d0063f71e3f0/go.mod h1:A3bUSe9jjMQHEPPOUW1JytM3x2g3t+jvsbPY66KBPIs= +github.com/maticnetwork/heimdall v0.3.1-0.20230227104835-81bd1055b0bc h1:7wEWQbYs6ESGsVBhjiVp7fZZyfaN4lg4XYLOLfRIpmY= +github.com/maticnetwork/heimdall v0.3.1-0.20230227104835-81bd1055b0bc/go.mod h1:P2DoKhovYP9G9Kj2EH/zHaiRJF1jNU7ZJOyelG4UCa8= +github.com/maticnetwork/polyproto v0.0.2/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= +github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53 h1:PjYV+lghs106JKkrYgOnrsfDLoTc11BxZd4rUa4Rus4= +github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= +github.com/maticnetwork/tendermint v0.26.0-dev0.0.20220923185258-3e7c7f86ce9f h1:iV69PJUEdwJJFXQvbADYVEMxDrkKAsPdHTg4U3F510I= +github.com/maticnetwork/tendermint v0.26.0-dev0.0.20220923185258-3e7c7f86ce9f/go.mod h1:90S74348uYSGfWwNIgvzQiRRakSH/c7VVt1TR5mzIuY= github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -448,57 +859,113 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= +github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= +github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/naoina/go-stringutil v0.1.0 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 h1:shk/vn9oCoOTmwcouEdwIeOtOGA/ELRUw/GwvxwfT+0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= +github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= +github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= -github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM= -github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= +github.com/peterh/liner v1.2.0 h1:w/UPXyl5GfahFxcTOz2j9wCIHNI+pUPr2laqpojKNCg= +github.com/peterh/liner v1.2.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= +github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= +github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= @@ -507,88 +974,197 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc h1:zAsgcP8MhzAbhMnB1QQ2O7ZhWYVGYSR2iVcjzQuPV+o= github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc/go.mod h1:S8xSOnV3CgpNrWd0GQ/OoQfMtlg2uPRSuTzcSGrzwK8= +github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= +github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= +github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= +github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= +github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/columnize v2.1.2+incompatible h1:C89EOx/XBWwIXl8wm8OPJBd7kPF25UfsK2X7Ph/zCAk= +github.com/ryanuber/columnize v2.1.2+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= -github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU= +github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw= +github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d h1:vmirMegf1vqPJ+lDBxLQ0MAt3tz+JL57UPxu44JBOjA= +github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d/go.mod h1:97vT0Rym0wCnK4B++hNA3nCetr0Mh1KXaVxzSt1arjg= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71 h1:2MR0pKUzlP3SGgj5NYJe/zRYDwOu9ku6YHy+Iw7l5DM= +github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stumble/gorocksdb v0.0.3 h1:9UU+QA1pqFYJuf9+5p7z1IqdE5k0mma4UAeu2wmX8kA= +github.com/stumble/gorocksdb v0.0.3/go.mod h1:v6IHdFBXk5DJ1K4FZ0xi+eY737quiiBxYtSWXadLybY= +github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM= +github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8= +github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= +github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 h1:m+8fKfQwCAy1QjzINvKe/pYtLjo2dl59x2w9YSEJxuY= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= +github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= +github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= +github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= +github.com/tendermint/go-amino v0.15.0 h1:TC4e66P59W7ML9+bxio17CPKnxW3nKIRAYskntMAoRk= +github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/iavl v0.12.4 h1:hd1woxUGISKkfUWBA4mmmTwOua6PQZTJM/F0FDrmMV8= +github.com/tendermint/iavl v0.12.4/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o= +github.com/tendermint/tm-db v0.1.1/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tendermint/tm-db v0.2.0 h1:rJxgdqn6fIiVJZy4zLpY1qVlyD0TU6vhkT4kEf71TQQ= +github.com/tendermint/tm-db v0.2.0/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/trailofbits/go-fuzz-utils v0.0.0-20210901195358-9657fcfd256c h1:4WU+p200eLYtBsx3M5CKXvkjVdf5SC3W9nMg37y0TFI= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= @@ -597,6 +1173,9 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/umbracle/gohashtree v0.0.2-alpha.0.20230207094856-5b775a815c10 h1:CQh33pStIp/E30b7TxDlXfM0145bn2e8boI30IxAhTg= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= @@ -606,51 +1185,132 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/scram v1.0.3 h1:nTadYh2Fs4BK2xdldEa2g5bbaZp0/+1nJMMPtPxS/to= +github.com/xdg/scram v1.0.3/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xsleonard/go-merkle v1.1.0 h1:fHe1fuhJjGH22ZzVTAH0jqHLhTGhOq3wQjJN+8P0jQg= +github.com/xsleonard/go-merkle v1.1.0/go.mod h1:cW4z+UZ/4f2n9IJgIiyDCdYguchoDyDAPmpuOWGxdGg= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= +github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= +github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.mongodb.org/mongo-driver v1.3.0 h1:ew6uUIeJOo+qdUUv7LxFCUhtWmVv7ZV/Xuy4FAUsw2E= +go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= +go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= +go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0/go.mod h1:14T5gr+Y6s2AgHPqBMgnGwp04csUjQmYXFWPeiBoq5s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0/go.mod h1:9mLBBnPRf3sf+ASVH2p9xREXVBvwib02FxcKnavtExg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S281UTjM+AbF31XSOYn1qXn3BgIdWl8HNEpx08Jk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= +go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= +go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/sdk v1.2.0/go.mod h1:jNN8QtpvbsKhgaC6V5lHiejMoKD+V8uadoSafgHPx1U= +go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= +go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= +go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= +go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -658,14 +1318,30 @@ golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20200228211341-fcea875c7e85/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -674,119 +1350,226 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200107162124-548cf772de50/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -795,15 +1578,24 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -815,40 +1607,87 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200108203644-89082a384178/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200303165918-5bcca83a7881/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.6/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= +gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= +gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= +gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= +gonum.org/v1/plot v0.10.1/go.mod h1:VZW5OlhkL1mysU9vaqNHnsy86inf6Ot+jB3r+BczCEo= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -856,17 +1695,39 @@ google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEn google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= +google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= @@ -876,17 +1737,78 @@ google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200108215221-bd8f9a0ef82f/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200303153909-beee998c1893/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= +google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -895,11 +1817,15 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= @@ -908,20 +1834,30 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= +gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -932,12 +1868,23 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= +pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw= +pgregory.net/rapid v0.4.8/go.mod h1:Z5PbWqjvWR1I3UGjvboUuan4fe4ZYEYNLNQLExzCoUs= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/interfaces.go b/interfaces.go index eb9af60076..40b614a14d 100644 --- a/interfaces.go +++ b/interfaces.go @@ -241,3 +241,28 @@ type GasEstimator interface { type PendingStateEventer interface { SubscribePendingTransactions(ctx context.Context, ch chan<- *types.Transaction) (Subscription, error) } + +// StateSyncFilter state sync filter +type StateSyncFilter struct { + ID uint64 + Contract common.Address +} + +// interface for whitelist service +type ChainValidator interface { + IsValidPeer(fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) + IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) + GetWhitelistedCheckpoint() (bool, uint64, common.Hash) + GetWhitelistedMilestone() (bool, uint64, common.Hash) + ProcessCheckpoint(endBlockNum uint64, endBlockHash common.Hash) + ProcessMilestone(endBlockNum uint64, endBlockHash common.Hash) + ProcessFutureMilestone(num uint64, hash common.Hash) + PurgeWhitelistedCheckpoint() + PurgeWhitelistedMilestone() + + LockMutex(endBlockNum uint64) bool + UnlockMutex(doLock bool, milestoneId string, endBlockNum uint64, endBlockHash common.Hash) + UnlockSprint(endBlockNum uint64) + RemoveMilestoneID(milestoneId string) + GetMilestoneIDsList() []string +} diff --git a/internal/cli/account.go b/internal/cli/account.go new file mode 100644 index 0000000000..bb8b30b892 --- /dev/null +++ b/internal/cli/account.go @@ -0,0 +1,53 @@ +package cli + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +type Account struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (a *Account) MarkDown() string { + items := []string{ + "# Account", + "The ```account``` command groups actions to interact with accounts:", + "- [```account new```](./account_new.md): Create a new account in the Bor client.", + "- [```account list```](./account_list.md): List the wallets in the Bor client.", + "- [```account import```](./account_import.md): Import an account to the Bor client.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (a *Account) Help() string { + return `Usage: bor account + + This command groups actions to interact with accounts. + + List the running deployments: + + $ bor account new + + Display the status of a specific deployment: + + $ bor account import + + List the imported accounts in the keystore: + + $ bor account list` +} + +// Synopsis implements the cli.Command interface +func (a *Account) Synopsis() string { + return "Interact with accounts" +} + +// Run implements the cli.Command interface +func (a *Account) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/internal/cli/account_import.go b/internal/cli/account_import.go new file mode 100644 index 0000000000..a3f65ab512 --- /dev/null +++ b/internal/cli/account_import.go @@ -0,0 +1,90 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/internal/cli/flagset" +) + +type AccountImportCommand struct { + *Meta +} + +// MarkDown implements cli.MarkDown interface +func (a *AccountImportCommand) MarkDown() string { + items := []string{ + "# Account import", + "The ```account import``` command imports an account in Json format to the Bor data directory.", + a.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (a *AccountImportCommand) Help() string { + return `Usage: bor account import + + Import a private key into a new account. + + Import an account: + + $ bor account import key.json + + ` + a.Flags().Help() +} + +func (a *AccountImportCommand) Flags() *flagset.Flagset { + return a.NewFlagSet("account import") +} + +// Synopsis implements the cli.Command interface +func (a *AccountImportCommand) Synopsis() string { + return "Import a private key into a new account" +} + +// Run implements the cli.Command interface +func (a *AccountImportCommand) Run(args []string) int { + flags := a.Flags() + if err := flags.Parse(args); err != nil { + a.UI.Error(err.Error()) + return 1 + } + + args = flags.Args() + if len(args) != 1 { + a.UI.Error("Expected one argument") + return 1 + } + + key, err := crypto.LoadECDSA(args[0]) + + if err != nil { + a.UI.Error(fmt.Sprintf("Failed to load the private key '%s': %v", args[0], err)) + return 1 + } + + keystore, err := a.GetKeystore() + if err != nil { + a.UI.Error(fmt.Sprintf("Failed to get keystore: %v", err)) + return 1 + } + + password, err := a.AskPassword() + if err != nil { + a.UI.Error(err.Error()) + return 1 + } + + acct, err := keystore.ImportECDSA(key, password) + if err != nil { + utils.Fatalf("Could not create the account: %v", err) + } + + a.UI.Output(fmt.Sprintf("Account created: %s", acct.Address.String())) + + return 0 +} diff --git a/internal/cli/account_list.go b/internal/cli/account_list.go new file mode 100644 index 0000000000..854934c447 --- /dev/null +++ b/internal/cli/account_list.go @@ -0,0 +1,78 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/internal/cli/flagset" +) + +type AccountListCommand struct { + *Meta +} + +// MarkDown implements cli.MarkDown interface +func (a *AccountListCommand) MarkDown() string { + items := []string{ + "# Account list", + "The `account list` command lists all the accounts in the Bor data directory.", + a.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (a *AccountListCommand) Help() string { + return `Usage: bor account list + + List the local accounts. + + ` + a.Flags().Help() +} + +func (a *AccountListCommand) Flags() *flagset.Flagset { + return a.NewFlagSet("account list") +} + +// Synopsis implements the cli.Command interface +func (a *AccountListCommand) Synopsis() string { + return "List the local accounts" +} + +// Run implements the cli.Command interface +func (a *AccountListCommand) Run(args []string) int { + flags := a.Flags() + if err := flags.Parse(args); err != nil { + a.UI.Error(err.Error()) + return 1 + } + + keystore, err := a.GetKeystore() + if err != nil { + a.UI.Error(fmt.Sprintf("Failed to get keystore: %v", err)) + return 1 + } + + a.UI.Output(formatAccounts(keystore.Accounts())) + + return 0 +} + +func formatAccounts(accts []accounts.Account) string { + if len(accts) == 0 { + return "No accounts found" + } + + rows := make([]string, len(accts)+1) + rows[0] = "Index|Address" + + for i, d := range accts { + rows[i+1] = fmt.Sprintf("%d|%s", + i, + d.Address.String()) + } + + return formatList(rows) +} diff --git a/internal/cli/account_new.go b/internal/cli/account_new.go new file mode 100644 index 0000000000..aef272a389 --- /dev/null +++ b/internal/cli/account_new.go @@ -0,0 +1,74 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" +) + +type AccountNewCommand struct { + *Meta +} + +// MarkDown implements cli.MarkDown interface +func (a *AccountNewCommand) MarkDown() string { + items := []string{ + "# Account new", + "The `account new` command creates a new local account file on the Bor data directory. Bor should not be running to execute this command.", + a.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (a *AccountNewCommand) Help() string { + return `Usage: bor account new + + Create a new local account. + + ` + a.Flags().Help() +} + +func (a *AccountNewCommand) Flags() *flagset.Flagset { + return a.NewFlagSet("account new") +} + +// Synopsis implements the cli.Command interface +func (a *AccountNewCommand) Synopsis() string { + return "Create a new local account" +} + +// Run implements the cli.Command interface +func (a *AccountNewCommand) Run(args []string) int { + flags := a.Flags() + if err := flags.Parse(args); err != nil { + a.UI.Error(err.Error()) + return 1 + } + + keystore, err := a.GetKeystore() + if err != nil { + a.UI.Error(fmt.Sprintf("Failed to get keystore: %v", err)) + return 1 + } + + password, err := a.AskPassword() + if err != nil { + a.UI.Error(err.Error()) + return 1 + } + + account, err := keystore.NewAccount(password) + if err != nil { + a.UI.Error(fmt.Sprintf("Failed to create new account: %v", err)) + return 1 + } + + a.UI.Output("\nYour new key was generated") + a.UI.Output(fmt.Sprintf("Public address of the key: %s", account.Address.Hex())) + a.UI.Output(fmt.Sprintf("Path of the secret key file: %s", account.URL.Path)) + + return 0 +} diff --git a/internal/cli/attach.go b/internal/cli/attach.go new file mode 100644 index 0000000000..134a282180 --- /dev/null +++ b/internal/cli/attach.go @@ -0,0 +1,193 @@ +package cli + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/console" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/rpc" + + "github.com/mitchellh/cli" +) + +// AttachCommand is the command to Connect to remote Bor IPC console +type AttachCommand struct { + UI cli.Ui + Meta *Meta + Meta2 *Meta2 + ExecCMD string + Endpoint string + PreloadJSFlag string + JSpathFlag string +} + +// MarkDown implements cli.MarkDown interface +func (c *AttachCommand) MarkDown() string { + items := []string{ + "# Attach", + "Connect to remote Bor IPC console.", + c.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *AttachCommand) Help() string { + return `Usage: bor attach + + Connect to remote Bor IPC console.` +} + +// Synopsis implements the cli.Command interface +func (c *AttachCommand) Synopsis() string { + return "Connect to Bor via IPC" +} + +func (c *AttachCommand) Flags() *flagset.Flagset { + f := flagset.NewFlagSet("attach") + + f.StringFlag(&flagset.StringFlag{ + Name: "exec", + Usage: "Command to run in remote console", + Value: &c.ExecCMD, + }) + + f.StringFlag(&flagset.StringFlag{ + Name: "preload", + Usage: "Comma separated list of JavaScript files to preload into the console", + Value: &c.PreloadJSFlag, + }) + + f.StringFlag(&flagset.StringFlag{ + Name: "jspath", + Usage: "JavaScript root path for `loadScript`", + Value: &c.JSpathFlag, + }) + + return f +} + +// Run implements the cli.Command interface +func (c *AttachCommand) Run(args []string) int { + flags := c.Flags() + + //check if first arg is flag or IPC location + if len(args) == 0 { + args = append(args, "") + } + + if args[0] != "" && strings.HasPrefix(args[0], "--") { + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + } else { + c.Endpoint = args[0] + if err := flags.Parse(args[1:]); err != nil { + c.UI.Error(err.Error()) + return 1 + } + } + + if err := c.remoteConsole(); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + return 0 +} + +// remoteConsole will connect to a remote bor instance, attaching a JavaScript +// console to it. +// nolint: unparam +func (c *AttachCommand) remoteConsole() error { + // Attach to a remotely running geth instance and start the JavaScript console + path := node.DefaultDataDir() + + if c.Endpoint == "" { + if c.Meta.dataDir != "" { + path = c.Meta.dataDir + } + + if path != "" { + homeDir, _ := os.UserHomeDir() + path = filepath.Join(homeDir, "/.bor/data") + } + + c.Endpoint = fmt.Sprintf("%s/bor.ipc", path) + } + + client, err := dialRPC(c.Endpoint) + + if err != nil { + utils.Fatalf("Unable to attach to remote bor: %v", err) + } + + config := console.Config{ + DataDir: path, + DocRoot: c.JSpathFlag, + Client: client, + Preload: c.makeConsolePreloads(), + } + + console, err := console.New(config) + if err != nil { + utils.Fatalf("Failed to start the JavaScript console: %v", err) + } + + defer func() { + if err := console.Stop(false); err != nil { + c.UI.Error(err.Error()) + } + }() + + if c.ExecCMD != "" { + console.Evaluate(c.ExecCMD) + return nil + } + + // Otherwise print the welcome screen and enter interactive mode + console.Welcome() + console.Interactive() + + return nil +} + +// dialRPC returns a RPC client which connects to the given endpoint. +// The check for empty endpoint implements the defaulting logic +// for "geth attach" with no argument. +func dialRPC(endpoint string) (*rpc.Client, error) { + if endpoint == "" { + endpoint = node.DefaultIPCEndpoint("bor") + } else if strings.HasPrefix(endpoint, "rpc:") || strings.HasPrefix(endpoint, "ipc:") { + // Backwards compatibility with geth < 1.5 which required + // these prefixes. + endpoint = endpoint[4:] + } + + return rpc.Dial(endpoint) +} + +// MakeConsolePreloads retrieves the absolute paths for the console JavaScript +// scripts to preload before starting. +func (c *AttachCommand) makeConsolePreloads() []string { + // Skip preloading if there's nothing to preload + if c.PreloadJSFlag == "" { + return nil + } + // Otherwise resolve absolute paths and return them + splitFlags := strings.Split(c.PreloadJSFlag, ",") + preloads := make([]string, 0, len(splitFlags)) + + for _, file := range splitFlags { + preloads = append(preloads, strings.TrimSpace(file)) + } + + return preloads +} diff --git a/internal/cli/bootnode.go b/internal/cli/bootnode.go new file mode 100644 index 0000000000..756956daa9 --- /dev/null +++ b/internal/cli/bootnode.go @@ -0,0 +1,287 @@ +package cli + +import ( + "crypto/ecdsa" + "errors" + "fmt" + "net" + "net/http" + "os" + "os/signal" + "path/filepath" + "strings" + "syscall" + "time" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/metrics/prometheus" + "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/enode" + "github.com/ethereum/go-ethereum/p2p/nat" + + "github.com/mitchellh/cli" +) + +type BootnodeCommand struct { + UI cli.Ui + + listenAddr string + enableMetrics bool + prometheusAddr string + v5 bool + verbosity int + logLevel string + nat string + nodeKey string + saveKey string + dryRun bool +} + +// Help implements the cli.Command interface +func (b *BootnodeCommand) Help() string { + return `Usage: bor bootnode` +} + +// MarkDown implements cli.MarkDown interface +func (c *BootnodeCommand) MarkDown() string { + items := []string{ + "# Bootnode", + c.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +func (b *BootnodeCommand) Flags() *flagset.Flagset { + flags := flagset.NewFlagSet("bootnode") + + flags.StringFlag(&flagset.StringFlag{ + Name: "listen-addr", + Default: "0.0.0.0:30303", + Usage: "listening address of bootnode (:)", + Value: &b.listenAddr, + }) + flags.BoolFlag(&flagset.BoolFlag{ + Name: "metrics", + Usage: "Enable metrics collection and reporting", + Value: &b.enableMetrics, + Default: true, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "prometheus-addr", + Default: "127.0.0.1:7071", + Usage: "listening address of bootnode (:)", + Value: &b.prometheusAddr, + }) + flags.BoolFlag(&flagset.BoolFlag{ + Name: "v5", + Default: false, + Usage: "Enable UDP v5", + Value: &b.v5, + }) + flags.IntFlag(&flagset.IntFlag{ + Name: "verbosity", + Default: 3, + Usage: "Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit)", + Value: &b.verbosity, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "log-level", + Default: "info", + Usage: "log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead", + Value: &b.logLevel, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "nat", + Default: "none", + Usage: "port mapping mechanism (any|none|upnp|pmp|extip:)", + Value: &b.nat, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "node-key", + Default: "", + Usage: "file or hex node key", + Value: &b.nodeKey, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "save-key", + Default: "", + Usage: "path to save the ecdsa private key", + Value: &b.saveKey, + }) + flags.BoolFlag(&flagset.BoolFlag{ + Name: "dry-run", + Default: false, + Usage: "validates parameters and prints bootnode configurations, but does not start bootnode", + Value: &b.dryRun, + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (b *BootnodeCommand) Synopsis() string { + return "Start a bootnode" +} + +// Run implements the cli.Command interface +// nolint: gocognit +func (b *BootnodeCommand) Run(args []string) int { + flags := b.Flags() + if err := flags.Parse(args); err != nil { + b.UI.Error(err.Error()) + return 1 + } + + glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + + var logInfo string + + if b.verbosity != 0 && b.logLevel != "" { + b.UI.Warn(fmt.Sprintf("Both verbosity and log-level provided, using verbosity: %v", b.verbosity)) + logInfo = server.VerbosityIntToString(b.verbosity) + } else if b.verbosity != 0 { + logInfo = server.VerbosityIntToString(b.verbosity) + } else { + logInfo = b.logLevel + } + + lvl, err := log.LvlFromString(strings.ToLower(logInfo)) + if err == nil { + glogger.Verbosity(lvl) + } else { + glogger.Verbosity(log.LvlInfo) + } + + log.Root().SetHandler(glogger) + + natm, err := nat.Parse(b.nat) + if err != nil { + b.UI.Error(fmt.Sprintf("failed to parse nat: %v", err)) + return 1 + } + + // create a one time key + var nodeKey *ecdsa.PrivateKey + // nolint: nestif + if b.nodeKey != "" { + // try to read the key either from file or command line + if _, err := os.Stat(b.nodeKey); errors.Is(err, os.ErrNotExist) { + if nodeKey, err = crypto.HexToECDSA(b.nodeKey); err != nil { + b.UI.Error(fmt.Sprintf("failed to parse hex address: %v", err)) + return 1 + } + } else { + if nodeKey, err = crypto.LoadECDSA(b.nodeKey); err != nil { + b.UI.Error(fmt.Sprintf("failed to load node key: %v", err)) + return 1 + } + } + } else { + // generate a new temporal key + if nodeKey, err = crypto.GenerateKey(); err != nil { + b.UI.Error(fmt.Sprintf("could not generate key: %v", err)) + return 1 + } + + if b.saveKey != "" { + path := b.saveKey + + // save the private key + if err = crypto.SaveECDSA(filepath.Join(path, "priv.key"), nodeKey); err != nil { + b.UI.Error(fmt.Sprintf("failed to write node priv key: %v", err)) + return 1 + } + // save the public key + pubRaw := fmt.Sprintf("%x", crypto.FromECDSAPub(&nodeKey.PublicKey)[1:]) + if err := os.WriteFile(filepath.Join(path, "pub.key"), []byte(pubRaw), 0600); err != nil { + b.UI.Error(fmt.Sprintf("failed to write node pub key: %v", err)) + return 1 + } + } + } + + addr, err := net.ResolveUDPAddr("udp", b.listenAddr) + if err != nil { + b.UI.Error(fmt.Sprintf("could not resolve udp addr '%s': %v", b.listenAddr, err)) + return 1 + } + + conn, err := net.ListenUDP("udp", addr) + + if err != nil { + b.UI.Error(fmt.Sprintf("failed to listen udp addr '%s': %v", b.listenAddr, err)) + return 1 + } + + realaddr := conn.LocalAddr().(*net.UDPAddr) + if natm != nil { + if !realaddr.IP.IsLoopback() { + go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") + } + + if ext, err := natm.ExternalIP(); err == nil { + // nolint: govet + realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port} + } + } + + n := enode.NewV4(&nodeKey.PublicKey, addr.IP, addr.Port, addr.Port) + b.UI.Info(n.String()) + + if b.dryRun { + return 0 + } + + db, _ := enode.OpenDB("") + ln := enode.NewLocalNode(db, nodeKey) + cfg := discover.Config{ + PrivateKey: nodeKey, + Log: log.Root(), + } + + if b.v5 { + if _, err := discover.ListenV5(conn, ln, cfg); err != nil { + utils.Fatalf("%v", err) + } + } else { + if _, err := discover.ListenUDP(conn, ln, cfg); err != nil { + utils.Fatalf("%v", err) + } + } + + if b.enableMetrics { + prometheusMux := http.NewServeMux() + + prometheusMux.Handle("/debug/metrics/prometheus", prometheus.Handler(metrics.DefaultRegistry)) + + promServer := &http.Server{ + Addr: b.prometheusAddr, + Handler: prometheusMux, + ReadHeaderTimeout: 30 * time.Second, + } + + go func() { + if err := promServer.ListenAndServe(); err != nil { + log.Error("Failure in running Prometheus server", "err", err) + } + }() + + log.Info("Enabling metrics export to prometheus", "path", fmt.Sprintf("http://%s/debug/metrics/prometheus", b.prometheusAddr)) + } + + signalCh := make(chan os.Signal, 4) + signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) + + sig := <-signalCh + + b.UI.Output(fmt.Sprintf("Caught signal: %v", sig)) + b.UI.Output("Gracefully shutting down agent...") + + return 0 +} diff --git a/internal/cli/bor_fingerprint.go b/internal/cli/bor_fingerprint.go new file mode 100644 index 0000000000..4e21f02956 --- /dev/null +++ b/internal/cli/bor_fingerprint.go @@ -0,0 +1,188 @@ +package cli + +import ( + "fmt" + "math" + "os/exec" + "strings" + + "github.com/ethereum/go-ethereum/params" + + "github.com/mitchellh/cli" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/host" + "github.com/shirou/gopsutil/mem" +) + +// VersionCommand is the command to show the version of the agent +type FingerprintCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (c *FingerprintCommand) MarkDown() string { + items := []string{ + "# Fingerprint", + "Display the system fingerprint", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *FingerprintCommand) Help() string { + return `Usage: bor fingerprint + + Display the system fingerprint` +} + +// Synopsis implements the cli.Command interface +func (c *FingerprintCommand) Synopsis() string { + return "Display the system fingerprint" +} + +func getCoresCount(cp []cpu.InfoStat) int { + cores := 0 + for i := 0; i < len(cp); i++ { + cores += int(cp[i].Cores) + } + + return cores +} + +type MemoryDetails struct { + TotalMem float64 `json:"totalMem"` + FreeMem float64 `json:"freeMem"` + UsedMem float64 `json:"usedMem"` +} + +type DiskDetails struct { + TotalDisk float64 `json:"totalDisk"` + FreeDisk float64 `json:"freeDisk"` + UsedDisk float64 `json:"usedDisk"` +} + +type BorFingerprint struct { + CoresCount int `json:"coresCount"` + OsName string `json:"osName"` + OsVer string `json:"osVer"` + DiskDetails *DiskDetails `json:"diskDetails"` + MemoryDetails *MemoryDetails `json:"memoryDetails"` +} + +func formatFingerprint(borFingerprint *BorFingerprint) string { + base := formatKV([]string{ + fmt.Sprintf("Bor Version : %s", params.VersionWithMeta), + fmt.Sprintf("CPU : %d cores", borFingerprint.CoresCount), + fmt.Sprintf("OS : %s %s ", borFingerprint.OsName, borFingerprint.OsVer), + fmt.Sprintf("RAM :: total : %v GB, free : %v GB, used : %v GB", borFingerprint.MemoryDetails.TotalMem, borFingerprint.MemoryDetails.FreeMem, borFingerprint.MemoryDetails.UsedMem), + fmt.Sprintf("STORAGE :: total : %v GB, free : %v GB, used : %v GB", borFingerprint.DiskDetails.TotalDisk, borFingerprint.DiskDetails.FreeDisk, borFingerprint.DiskDetails.UsedDisk), + }) + + return base +} + +func convertBytesToGB(bytesValue uint64) float64 { + return math.Floor(float64(bytesValue)/(1024*1024*1024)*100) / 100 +} + +// Checks if fio exists on the node +func (c *FingerprintCommand) checkFio() error { + cmd := exec.Command("/bin/sh", "-c", "fio -v") + + _, err := cmd.CombinedOutput() + if err != nil { + message := "\nFio package not installed. Install Fio for IOPS Benchmarking :\n\nDebianOS : 'sudo apt-get update && sudo apt-get install fio -y'\nAWS AMI/CentOS : 'sudo yum install fio -y'\nOracle LinuxOS : 'sudo dnf install fio -y'\n" + c.UI.Output(message) + + return err + } + + return nil +} + +// Run the IOPS benchmark for the node +func (c *FingerprintCommand) benchmark() error { + var b []byte + + err := c.checkFio() + + if err != nil { + // Missing Fio is not a fatal error. A message will be logged in console when it is missing in "checkFio()". + return nil //nolint:nilerr + } + + c.UI.Output("\nRunning a 10 second test...\n") + + cmd := exec.Command("/bin/sh", "-c", "sudo fio --filename=/file --size=2GB --direct=1 --rw=randrw --bs=64k --ioengine=libaio --iodepth=64 --runtime=10 --numjobs=4 --time_based --group_reporting --name=throughput-test-job --eta-newline=1 | grep -e 'read:' -e 'write:' | awk '{print $1,$2}' ") + + b, err = cmd.CombinedOutput() + if err != nil { + return err + } + + out := string(b) + c.UI.Output(out) + + return nil +} + +// Run implements the cli.Command interface +func (c *FingerprintCommand) Run(args []string) int { + v, err := mem.VirtualMemory() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + h, err := host.Info() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + cp, err := cpu.Info() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + d, err := disk.Usage("/") + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + diskDetails := &DiskDetails{ + TotalDisk: convertBytesToGB(d.Total), + FreeDisk: convertBytesToGB(d.Free), + UsedDisk: convertBytesToGB(d.Used), + } + + memoryDetails := &MemoryDetails{ + TotalMem: convertBytesToGB(v.Total), + FreeMem: convertBytesToGB(v.Available), + UsedMem: convertBytesToGB(v.Used), + } + + borFingerprint := &BorFingerprint{ + CoresCount: getCoresCount(cp), + OsName: h.OS, + OsVer: h.Platform + " - " + h.PlatformVersion + " - " + h.KernelArch, + DiskDetails: diskDetails, + MemoryDetails: memoryDetails, + } + + c.UI.Output(formatFingerprint(borFingerprint)) + + if borFingerprint.OsName == "linux" { + err = c.benchmark() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + } + + return 0 +} diff --git a/internal/cli/chain.go b/internal/cli/chain.go new file mode 100644 index 0000000000..9a7e9e8537 --- /dev/null +++ b/internal/cli/chain.go @@ -0,0 +1,45 @@ +package cli + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +// ChainCommand is the command to group the peers commands +type ChainCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (c *ChainCommand) MarkDown() string { + items := []string{ + "# Chain", + "The ```chain``` command groups actions to interact with the blockchain in the client:", + "- [```chain sethead```](./chain_sethead.md): Set the current chain to a certain block.", + "- [```chain watch```](./chain_watch.md): Watch the chainHead, reorg and fork events in real-time.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *ChainCommand) Help() string { + return `Usage: bor chain + + This command groups actions to interact with the chain. + + Set the new head of the chain: + + $ bor chain sethead ` +} + +// Synopsis implements the cli.Command interface +func (c *ChainCommand) Synopsis() string { + return "Interact with the chain" +} + +// Run implements the cli.Command interface +func (c *ChainCommand) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/internal/cli/chain_sethead.go b/internal/cli/chain_sethead.go new file mode 100644 index 0000000000..718ada4648 --- /dev/null +++ b/internal/cli/chain_sethead.go @@ -0,0 +1,108 @@ +package cli + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// ChainSetHeadCommand is the command to group the peers commands +type ChainSetHeadCommand struct { + *Meta2 + + yes bool +} + +// MarkDown implements cli.MarkDown interface +func (a *ChainSetHeadCommand) MarkDown() string { + items := []string{ + "# Chain sethead", + "The ```chain sethead ``` command sets the current chain to a certain block.", + "## Arguments", + "- ```number```: The block number to roll back.", + a.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *ChainSetHeadCommand) Help() string { + return `Usage: bor chain sethead [--yes] + + This command sets the current chain to a certain block` +} + +func (c *ChainSetHeadCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("chain sethead") + + flags.BoolFlag(&flagset.BoolFlag{ + Name: "yes", + Usage: "Force set head", + Default: false, + Value: &c.yes, + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *ChainSetHeadCommand) Synopsis() string { + return "Set the new head of the chain" +} + +// Run implements the cli.Command interface +func (c *ChainSetHeadCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + args = flags.Args() + if len(args) != 1 { + c.UI.Error("No number provided") + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + arg := args[0] + fmt.Println(arg) + + number, err := strconv.Atoi(arg) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if !c.yes { + response, err := c.UI.Ask("Are you sure you want to reset the database? (y/n)") + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if response != "y" { + c.UI.Output("set head aborted") + return 0 + } + } + + if _, err := borClt.ChainSetHead(context.Background(), &proto.ChainSetHeadRequest{Number: uint64(number)}); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.UI.Output("Done!") + + return 0 +} diff --git a/internal/cli/chain_watch.go b/internal/cli/chain_watch.go new file mode 100644 index 0000000000..17a65a8d99 --- /dev/null +++ b/internal/cli/chain_watch.go @@ -0,0 +1,105 @@ +package cli + +import ( + "context" + "fmt" + "os" + "os/signal" + "strings" + "syscall" + + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// ChainWatchCommand is the command to group the peers commands +type ChainWatchCommand struct { + *Meta2 +} + +// MarkDown implements cli.MarkDown interface +func (c *ChainWatchCommand) MarkDown() string { + items := []string{ + "# Chain watch", + "The ```chain watch``` command is used to view the chainHead, reorg and fork events in real-time.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *ChainWatchCommand) Help() string { + return `Usage: bor chain watch + + This command is used to view the chainHead, reorg and fork events in real-time` +} + +func (c *ChainWatchCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("chain watch") + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *ChainWatchCommand) Synopsis() string { + return "Watch the chainHead, reorg and fork events in real-time" +} + +// Run implements the cli.Command interface +func (c *ChainWatchCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + sub, err := borClt.ChainWatch(context.Background(), &proto.ChainWatchRequest{}) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + signalCh := make(chan os.Signal, 1) + signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM) + + go func() { + <-signalCh + + if err := sub.CloseSend(); err != nil { + c.UI.Error(err.Error()) + } + }() + + for { + msg, err := sub.Recv() + if err != nil { + // if err == EOF if finished on the other side + c.UI.Output(err.Error()) + break + } + + c.UI.Output(formatHeadEvent(msg)) + } + + return 0 +} + +func formatHeadEvent(msg *proto.ChainWatchResponse) string { + var out string + if msg.Type == core.Chain2HeadCanonicalEvent { + out = fmt.Sprintf("Block Added : %v", msg.Newchain) + } else if msg.Type == core.Chain2HeadForkEvent { + out = fmt.Sprintf("New Fork Block : %v", msg.Newchain) + } else if msg.Type == core.Chain2HeadReorgEvent { + out = fmt.Sprintf("Reorg Detected \nAdded : %v \nRemoved : %v", msg.Newchain, msg.Oldchain) + } + + return out +} diff --git a/internal/cli/command.go b/internal/cli/command.go new file mode 100644 index 0000000000..95f7776df6 --- /dev/null +++ b/internal/cli/command.go @@ -0,0 +1,303 @@ +package cli + +import ( + "fmt" + "os" + + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" + "github.com/ethereum/go-ethereum/node" + + "github.com/mitchellh/cli" + "github.com/ryanuber/columnize" + "google.golang.org/grpc" +) + +const ( + emptyPlaceHolder = "" +) + +type MarkDownCommand interface { + MarkDown + cli.Command +} + +type MarkDownCommandFactory func() (MarkDownCommand, error) + +func Run(args []string) int { + commands := Commands() + + mappedCommands := make(map[string]cli.CommandFactory) + + for k, v := range commands { + // Declare a new v to limit the scope of v to inside the block, so the anonymous function below + // can get the "current" value of v, instead of the value of last v in the loop. + // See this post: https://stackoverflow.com/questions/10116507/go-transfer-var-into-anonymous-function for more explanation + v := v + mappedCommands[k] = func() (cli.Command, error) { + cmd, err := v() + return cmd.(cli.Command), err + } + } + + cli := &cli.CLI{ + Name: "bor", + Args: args, + Commands: mappedCommands, + } + + exitCode, err := cli.Run() + if err != nil { + fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error()) + return 1 + } + + return exitCode +} + +func Commands() map[string]MarkDownCommandFactory { + ui := &cli.BasicUi{ + Reader: os.Stdin, + Writer: os.Stdout, + ErrorWriter: os.Stderr, + } + + meta2 := &Meta2{ + UI: ui, + } + meta := &Meta{ + UI: ui, + } + + return map[string]MarkDownCommandFactory{ + "server": func() (MarkDownCommand, error) { + return &server.Command{ + UI: ui, + }, nil + }, + "version": func() (MarkDownCommand, error) { + return &VersionCommand{ + UI: ui, + }, nil + }, + "dumpconfig": func() (MarkDownCommand, error) { + return &DumpconfigCommand{ + Meta2: meta2, + }, nil + }, + "debug": func() (MarkDownCommand, error) { + return &DebugCommand{ + UI: ui, + }, nil + }, + "debug pprof": func() (MarkDownCommand, error) { + return &DebugPprofCommand{ + Meta2: meta2, + }, nil + }, + "debug block": func() (MarkDownCommand, error) { + return &DebugBlockCommand{ + Meta2: meta2, + }, nil + }, + "chain": func() (MarkDownCommand, error) { + return &ChainCommand{ + UI: ui, + }, nil + }, + "chain watch": func() (MarkDownCommand, error) { + return &ChainWatchCommand{ + Meta2: meta2, + }, nil + }, + "chain sethead": func() (MarkDownCommand, error) { + return &ChainSetHeadCommand{ + Meta2: meta2, + }, nil + }, + "account": func() (MarkDownCommand, error) { + return &Account{ + UI: ui, + }, nil + }, + "account new": func() (MarkDownCommand, error) { + return &AccountNewCommand{ + Meta: meta, + }, nil + }, + "account import": func() (MarkDownCommand, error) { + return &AccountImportCommand{ + Meta: meta, + }, nil + }, + "account list": func() (MarkDownCommand, error) { + return &AccountListCommand{ + Meta: meta, + }, nil + }, + "peers": func() (MarkDownCommand, error) { + return &PeersCommand{ + UI: ui, + }, nil + }, + "peers add": func() (MarkDownCommand, error) { + return &PeersAddCommand{ + Meta2: meta2, + }, nil + }, + "peers remove": func() (MarkDownCommand, error) { + return &PeersRemoveCommand{ + Meta2: meta2, + }, nil + }, + "peers list": func() (MarkDownCommand, error) { + return &PeersListCommand{ + Meta2: meta2, + }, nil + }, + "peers status": func() (MarkDownCommand, error) { + return &PeersStatusCommand{ + Meta2: meta2, + }, nil + }, + "status": func() (MarkDownCommand, error) { + return &StatusCommand{ + Meta2: meta2, + }, nil + }, + "fingerprint": func() (MarkDownCommand, error) { + return &FingerprintCommand{ + UI: ui, + }, nil + }, + "attach": func() (MarkDownCommand, error) { + return &AttachCommand{ + UI: ui, + Meta: meta, + Meta2: meta2, + }, nil + }, + "bootnode": func() (MarkDownCommand, error) { + return &BootnodeCommand{ + UI: ui, + }, nil + }, + "removedb": func() (MarkDownCommand, error) { + return &RemoveDBCommand{ + Meta2: meta2, + }, nil + }, + "snapshot": func() (MarkDownCommand, error) { + return &SnapshotCommand{ + UI: ui, + }, nil + }, + "snapshot prune-state": func() (MarkDownCommand, error) { + return &PruneStateCommand{ + Meta: meta, + }, nil + }, + } +} + +type Meta2 struct { + UI cli.Ui + + addr string +} + +func (m *Meta2) NewFlagSet(n string) *flagset.Flagset { + f := flagset.NewFlagSet(n) + + f.StringFlag(&flagset.StringFlag{ + Name: "address", + Value: &m.addr, + Usage: "Address of the grpc endpoint", + Default: "127.0.0.1:3131", + }) + + return f +} + +func (m *Meta2) Conn() (*grpc.ClientConn, error) { + conn, err := grpc.Dial(m.addr, grpc.WithInsecure()) + if err != nil { + return nil, fmt.Errorf("failed to connect to server: %v", err) + } + + return conn, nil +} + +func (m *Meta2) BorConn() (proto.BorClient, error) { + conn, err := m.Conn() + if err != nil { + return nil, err + } + + return proto.NewBorClient(conn), nil +} + +// Meta is a helper utility for the commands +type Meta struct { + UI cli.Ui + + dataDir string + keyStoreDir string +} + +func (m *Meta) NewFlagSet(n string) *flagset.Flagset { + f := flagset.NewFlagSet(n) + + f.StringFlag(&flagset.StringFlag{ + Name: "datadir", + Value: &m.dataDir, + Usage: "Path of the data directory to store information", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "keystore", + Value: &m.keyStoreDir, + Usage: "Path of the data directory to store keys", + }) + + return f +} + +func (m *Meta) AskPassword() (string, error) { + return m.UI.AskSecret("Your new account is locked with a password. Please give a password. Do not forget this password") +} + +func (m *Meta) GetKeystore() (*keystore.KeyStore, error) { + cfg := node.DefaultConfig + cfg.DataDir = m.dataDir + cfg.KeyStoreDir = m.keyStoreDir + + stack, err := node.New(&cfg) + if err != nil { + return nil, err + } + + keydir := stack.KeyStoreDir() + scryptN := keystore.StandardScryptN + scryptP := keystore.StandardScryptP + + keys := keystore.NewKeyStore(keydir, scryptN, scryptP) + + return keys, nil +} + +func formatList(in []string) string { + columnConf := columnize.DefaultConfig() + columnConf.Empty = emptyPlaceHolder + + return columnize.Format(in, columnConf) +} + +func formatKV(in []string) string { + columnConf := columnize.DefaultConfig() + columnConf.Empty = emptyPlaceHolder + columnConf.Glue = " = " + + return columnize.Format(in, columnConf) +} diff --git a/internal/cli/debug.go b/internal/cli/debug.go new file mode 100644 index 0000000000..9b3d224699 --- /dev/null +++ b/internal/cli/debug.go @@ -0,0 +1,275 @@ +package cli + +import ( + "archive/tar" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "os/signal" + "path/filepath" + "strings" + "syscall" + "time" + + "github.com/mitchellh/cli" + + "github.com/ethereum/go-ethereum/internal/cli/server/proto" + + grpc_net_conn "github.com/JekaMas/go-grpc-net-conn" + "google.golang.org/grpc" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/reflect/protoreflect" +) + +// DebugCommand is the command to group the peers commands +type DebugCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (d *DebugCommand) MarkDown() string { + examples := []string{ + "## Examples", + "By default it creates a tar.gz file with the output:", + CodeBlock([]string{ + "$ bor debug", + "Starting debugger...\n", + "Created debug archive: bor-debug-2021-10-26-073819Z.tar.gz", + }), + "Send the output to a specific directory:", + CodeBlock([]string{ + "$ bor debug --output data", + "Starting debugger...\n", + "Created debug directory: data/bor-debug-2021-10-26-075437Z", + }), + } + + items := []string{ + "# Debug", + "The ```bor debug``` command takes a debug dump of the running client.", + "- [```bor debug pprof```](./debug_pprof.md): Dumps bor pprof traces.", + "- [```bor debug block ```](./debug_block.md): Dumps bor block traces.", + } + items = append(items, examples...) + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *DebugCommand) Help() string { + return `Usage: bor debug + + This command takes a debug dump of the running client. + + Get the pprof traces: + + $ bor debug pprof + + Get the block traces: + + $ bor debug block ` +} + +// Synopsis implements the cli.Command interface +func (c *DebugCommand) Synopsis() string { + return "Get traces of the running client" +} + +// Run implements the cli.Command interface +func (c *DebugCommand) Run(args []string) int { + return cli.RunResultHelp +} + +type debugEnv struct { + output string + prefix string + + name string + dst string +} + +func (d *debugEnv) init() error { + d.name = d.prefix + time.Now().UTC().Format("2006-01-02-150405Z") + + var err error + + // Create the output directory + var tmp string + if d.output != "" { + // User specified output directory + tmp = filepath.Join(d.output, d.name) + _, err := os.Stat(tmp) + + if !os.IsNotExist(err) { + return fmt.Errorf("output directory already exists") + } + } else { + // Generate temp directory + tmp, err = ioutil.TempDir(os.TempDir(), d.name) + if err != nil { + return fmt.Errorf("error creating tmp directory: %s", err.Error()) + } + } + + // ensure destine folder exists + if err := os.MkdirAll(tmp, os.ModePerm); err != nil { + return fmt.Errorf("failed to create parent directory: %v", err) + } + + d.dst = tmp + + return nil +} + +func (d *debugEnv) tarName() string { + return d.name + ".tar.gz" +} + +func (d *debugEnv) finish() error { + // Exit before archive if output directory was specified + if d.output != "" { + return nil + } + + // Create archive tarball + archiveFile := d.tarName() + if err := tarCZF(archiveFile, d.dst, d.name); err != nil { + return fmt.Errorf("error creating archive: %s", err.Error()) + } + + return nil +} + +type debugStream interface { + Recv() (*proto.DebugFileResponse, error) + grpc.ClientStream +} + +func (d *debugEnv) writeFromStream(name string, stream debugStream) error { + // wait for open request + msg, err := stream.Recv() + if err != nil { + return err + } + + if _, ok := msg.Event.(*proto.DebugFileResponse_Open_); !ok { + return fmt.Errorf("expected open message") + } + + // create the stream + conn := &grpc_net_conn.Conn[*proto.DebugFileResponse_Input, *proto.DebugFileResponse_Input]{ + Stream: stream, + Response: &proto.DebugFileResponse_Input{}, + Decode: grpc_net_conn.SimpleDecoder(func(msg *proto.DebugFileResponse_Input) *[]byte { + return &msg.Data + }), + } + + file, err := os.OpenFile(filepath.Join(d.dst, name), os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + return err + } + defer file.Close() + + if _, err := io.Copy(file, conn); err != nil { + return err + } + + return nil +} + +func (d *debugEnv) writeJSON(name string, msg protoreflect.ProtoMessage) error { + m := protojson.MarshalOptions{} + data, err := m.Marshal(msg) + + if err != nil { + return err + } + + if err := ioutil.WriteFile(filepath.Join(d.dst, name), data, 0600); err != nil { + return fmt.Errorf("failed to write status: %v", err) + } + + return nil +} + +func trapSignal(cancel func()) { + sigCh := make(chan os.Signal, 1) + signal.Notify(sigCh, + syscall.SIGHUP, + syscall.SIGINT, + syscall.SIGTERM, + syscall.SIGQUIT) + + go func() { + <-sigCh + cancel() + }() +} + +func tarCZF(archive string, src, target string) error { + // ensure the src actually exists before trying to tar it + if _, err := os.Stat(src); err != nil { + return fmt.Errorf("unable to tar files - %v", err.Error()) + } + + // create the archive + fh, err := os.Create(archive) + if err != nil { + return err + } + defer fh.Close() + + zz := gzip.NewWriter(fh) + defer zz.Close() + + tw := tar.NewWriter(zz) + defer tw.Close() + + // tar + return filepath.Walk(src, func(file string, fi os.FileInfo, err error) error { + // return on any error + if err != nil { + return err + } + + if !fi.Mode().IsRegular() { + return nil + } + + header, err := tar.FileInfoHeader(fi, fi.Name()) + if err != nil { + return err + } + + // remove leading path to the src, so files are relative to the archive + path := strings.ReplaceAll(file, src, "") + if target != "" { + path = filepath.Join([]string{target, path}...) + } + + path = strings.TrimPrefix(path, string(filepath.Separator)) + + header.Name = path + + if err := tw.WriteHeader(header); err != nil { + return err + } + + // copy the file contents + f, err := os.Open(file) + if err != nil { + return err + } + + if _, err := io.Copy(tw, f); err != nil { + return err + } + + f.Close() + + return nil + }) +} diff --git a/internal/cli/debug_block.go b/internal/cli/debug_block.go new file mode 100644 index 0000000000..5a282cc550 --- /dev/null +++ b/internal/cli/debug_block.go @@ -0,0 +1,126 @@ +package cli + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// DebugBlockCommand is the command to group the peers commands +type DebugBlockCommand struct { + *Meta2 + + output string +} + +func (p *DebugBlockCommand) MarkDown() string { + items := []string{ + "# Debug trace", + "The ```bor debug block ``` command will create an archive containing traces of a bor block.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *DebugBlockCommand) Help() string { + return `Usage: bor debug block + + This command is used get traces of a bor block` +} + +func (c *DebugBlockCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("trace") + + flags.StringFlag(&flagset.StringFlag{ + Name: "output", + Value: &c.output, + Usage: "Output directory", + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *DebugBlockCommand) Synopsis() string { + return "Get trace of a bor block" +} + +// Run implements the cli.Command interface +func (c *DebugBlockCommand) Run(args []string) int { + flags := c.Flags() + + var number *int64 = nil + + // parse the block number (if available) + if len(args)%2 != 0 { + num, err := strconv.ParseInt(args[0], 10, 64) + if err == nil { + number = &num + } + + args = args[1:] + } + // parse output directory + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + dEnv := &debugEnv{ + output: c.output, + prefix: "bor-block-trace-", + } + if err := dEnv.init(); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.UI.Output("Starting block tracer...") + c.UI.Output("") + + // create a debug block request + var debugRequest *proto.DebugBlockRequest = &proto.DebugBlockRequest{} + if number != nil { + debugRequest.Number = *number + } else { + debugRequest.Number = -1 + } + + // send the request + // receives a grpc stream of debug block response + stream, err := borClt.DebugBlock(context.Background(), debugRequest) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if err := dEnv.writeFromStream("block.json", stream); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if err := dEnv.finish(); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if c.output != "" { + c.UI.Output(fmt.Sprintf("Created debug directory: %s", dEnv.dst)) + } else { + c.UI.Output(fmt.Sprintf("Created block trace archive: %s", dEnv.tarName())) + } + + return 0 +} diff --git a/internal/cli/debug_pprof.go b/internal/cli/debug_pprof.go new file mode 100644 index 0000000000..ddb4520e9c --- /dev/null +++ b/internal/cli/debug_pprof.go @@ -0,0 +1,176 @@ +package cli + +// Based on https://github.com/hashicorp/nomad/blob/main/command/operator_debug.go + +import ( + "context" + "fmt" + "strings" + + "google.golang.org/grpc" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +type DebugPprofCommand struct { + *Meta2 + + seconds uint64 + output string + skiptrace bool +} + +func (p *DebugPprofCommand) MarkDown() string { + items := []string{ + "# Debug Pprof", + "The ```debug pprof ``` command will create an archive containing bor pprof traces.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (d *DebugPprofCommand) Help() string { + return `Usage: bor debug + + Build an archive containing Bor pprof traces + + ` + d.Flags().Help() +} + +func (d *DebugPprofCommand) Flags() *flagset.Flagset { + flags := d.NewFlagSet("debug") + + flags.Uint64Flag(&flagset.Uint64Flag{ + Name: "seconds", + Usage: "seconds to profile", + Value: &d.seconds, + Default: 2, + }) + flags.StringFlag(&flagset.StringFlag{ + Name: "output", + Value: &d.output, + Usage: "Output directory", + }) + + // Trace profiles can be expensive and take too much size (for grpc). + // This flag will help in making it optional. + flags.BoolFlag(&flagset.BoolFlag{ + Name: "skiptrace", + Value: &d.skiptrace, + Usage: "Skip running the trace", + Default: false, + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (d *DebugPprofCommand) Synopsis() string { + return "Build an archive containing Bor pprof traces" +} + +// Run implements the cli.Command interface +func (d *DebugPprofCommand) Run(args []string) int { + flags := d.Flags() + if err := flags.Parse(args); err != nil { + d.UI.Error(err.Error()) + return 1 + } + + clt, err := d.BorConn() + if err != nil { + d.UI.Error(err.Error()) + return 1 + } + + dEnv := &debugEnv{ + output: d.output, + prefix: "bor-debug-", + } + if err := dEnv.init(); err != nil { + d.UI.Error(err.Error()) + return 1 + } + + d.UI.Output("Starting debugger...") + d.UI.Output("") + + pprofProfile := func(ctx context.Context, profile string, filename string) error { + req := &proto.DebugPprofRequest{ + Seconds: int64(d.seconds), + } + + switch profile { + case "cpu": + req.Type = proto.DebugPprofRequest_CPU + case "trace": + req.Type = proto.DebugPprofRequest_TRACE + default: + req.Type = proto.DebugPprofRequest_LOOKUP + req.Profile = profile + } + + stream, err := clt.DebugPprof(ctx, req, grpc.MaxCallRecvMsgSize(1024*1024*1024)) + + if err != nil { + return err + } + + if err := dEnv.writeFromStream(filename+".prof", stream); err != nil { + return err + } + + return nil + } + + ctx, cancelFn := context.WithCancel(context.Background()) + trapSignal(cancelFn) + + // Only take cpu and heap profiles by default + profiles := map[string]string{ + "heap": "heap", + "cpu": "cpu", + "mutex": "mutex", + } + + if !d.skiptrace { + profiles["trace"] = "trace" + } + + for profile, filename := range profiles { + if err := pprofProfile(ctx, profile, filename); err != nil { + d.UI.Error(fmt.Sprintf("Error creating profile '%s': %v", profile, err)) + return 1 + } + } + + // append the status + { + statusResp, err := clt.Status(ctx, &proto.StatusRequest{}) + if err != nil { + d.UI.Output(fmt.Sprintf("Failed to get status: %v", err)) + return 1 + } + + if err := dEnv.writeJSON("status.json", statusResp); err != nil { + d.UI.Error(err.Error()) + return 1 + } + } + + if err := dEnv.finish(); err != nil { + d.UI.Error(err.Error()) + return 1 + } + + if d.output != "" { + d.UI.Output(fmt.Sprintf("Created debug directory: %s", dEnv.dst)) + } else { + d.UI.Output(fmt.Sprintf("Created debug archive: %s", dEnv.tarName())) + } + + return 0 +} diff --git a/internal/cli/debug_test.go b/internal/cli/debug_test.go new file mode 100644 index 0000000000..aa1e4a8bf1 --- /dev/null +++ b/internal/cli/debug_test.go @@ -0,0 +1,113 @@ +package cli + +import ( + "os" + "path" + "strconv" + "testing" + "time" + + "github.com/mitchellh/cli" + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/internal/cli/server" +) + +var currentDir string + +func TestCommand_DebugBlock(t *testing.T) { + t.Parallel() + + // Start a blockchain in developer mode and get trace of block + config := server.DefaultConfig() + + // enable developer mode + config.Developer.Enabled = true + config.Developer.Period = 2 // block time + config.Developer.GasLimit = 11500000 // initial block gaslimit + + // enable archive mode for getting traces of ancient blocks + config.GcMode = "archive" + + // start the mock server + srv, err := server.CreateMockServer(config) + require.NoError(t, err) + + defer server.CloseMockServer(srv) + + // get the grpc port + port := srv.GetGrpcAddr() + + // wait for 4 seconds to mine a 2 blocks + time.Sleep(2 * time.Duration(config.Developer.Period) * time.Second) + + // add prefix for debug trace + prefix := "bor-block-trace-" + + // output dir + output := "debug_block_test" + + // set current directory + currentDir, _ = os.Getwd() + + // trace 1st block + start := time.Now() + dst1 := path.Join(output, prefix+time.Now().UTC().Format("2006-01-02-150405Z"), "block.json") + res := traceBlock(port, 1, output) + require.Equal(t, 0, res) + t.Logf("Completed trace of block %d in %d ms at %s", 1, time.Since(start).Milliseconds(), dst1) + + // adding this to avoid debug directory name conflicts + time.Sleep(time.Second) + + // trace last/recent block + start = time.Now() + latestBlock := srv.GetLatestBlockNumber().Int64() + dst2 := path.Join(output, prefix+time.Now().UTC().Format("2006-01-02-150405Z"), "block.json") + res = traceBlock(port, latestBlock, output) + require.Equal(t, 0, res) + t.Logf("Completed trace of block %d in %d ms at %s", latestBlock, time.Since(start).Milliseconds(), dst2) + + // verify if the trace files are created + done := verify(dst1) + require.Equal(t, true, done) + done = verify(dst2) + require.Equal(t, true, done) + + // delete the traces + deleteTraces(output) +} + +// traceBlock calls the cli command to trace a block +func traceBlock(port string, number int64, output string) int { + ui := cli.NewMockUi() + command := &DebugBlockCommand{ + Meta2: &Meta2{ + UI: ui, + addr: "127.0.0.1:" + port, + }, + } + + // run trace (by explicitly passing the output directory and grpc address) + return command.Run([]string{strconv.FormatInt(number, 10), "--output", output, "--address", command.Meta2.addr}) +} + +// verify checks if the trace file is created at the destination +// directory or not +func verify(dst string) bool { + dst = path.Join(currentDir, dst) + if file, err := os.Stat(dst); err == nil { + // check if the file has content + if file.Size() > 0 { + return true + } + } + + return false +} + +// deleteTraces removes the traces created during the test +func deleteTraces(dst string) { + dst = path.Join(currentDir, dst) + os.RemoveAll(dst) +} diff --git a/internal/cli/dumpconfig.go b/internal/cli/dumpconfig.go new file mode 100644 index 0000000000..0cd0958ae9 --- /dev/null +++ b/internal/cli/dumpconfig.go @@ -0,0 +1,77 @@ +package cli + +import ( + "os" + "strings" + + "github.com/BurntSushi/toml" + + "github.com/ethereum/go-ethereum/internal/cli/server" +) + +// DumpconfigCommand is for exporting user provided flags into a config file +type DumpconfigCommand struct { + *Meta2 +} + +// MarkDown implements cli.MarkDown interface +func (p *DumpconfigCommand) MarkDown() string { + items := []string{ + "# Dumpconfig", + "The ```bor dumpconfig ``` command will export the user provided flags into a configuration file", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *DumpconfigCommand) Help() string { + return `Usage: bor dumpconfig + + This command will will export the user provided flags into a configuration file` +} + +// Synopsis implements the cli.Command interface +func (c *DumpconfigCommand) Synopsis() string { + return "Export configuration file" +} + +// TODO: add flags for file location and format (toml, json, hcl) of the configuration file. + +// Run implements the cli.Command interface +func (c *DumpconfigCommand) Run(args []string) int { + // Initialize an empty command instance to get flags + command := server.Command{} + flags := command.Flags() + + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + userConfig := command.GetConfig() + + // convert the big.Int and time.Duration fields to their corresponding Raw fields + userConfig.JsonRPC.RPCEVMTimeoutRaw = userConfig.JsonRPC.RPCEVMTimeout.String() + userConfig.JsonRPC.HttpTimeout.ReadTimeoutRaw = userConfig.JsonRPC.HttpTimeout.ReadTimeout.String() + userConfig.JsonRPC.HttpTimeout.WriteTimeoutRaw = userConfig.JsonRPC.HttpTimeout.WriteTimeout.String() + userConfig.JsonRPC.HttpTimeout.IdleTimeoutRaw = userConfig.JsonRPC.HttpTimeout.IdleTimeout.String() + userConfig.JsonRPC.Http.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Http.ExecutionPoolRequestTimeout.String() + userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout.String() + userConfig.TxPool.RejournalRaw = userConfig.TxPool.Rejournal.String() + userConfig.TxPool.LifeTimeRaw = userConfig.TxPool.LifeTime.String() + userConfig.Sealer.GasPriceRaw = userConfig.Sealer.GasPrice.String() + userConfig.Sealer.RecommitRaw = userConfig.Sealer.Recommit.String() + userConfig.Gpo.MaxPriceRaw = userConfig.Gpo.MaxPrice.String() + userConfig.Gpo.IgnorePriceRaw = userConfig.Gpo.IgnorePrice.String() + userConfig.Cache.RejournalRaw = userConfig.Cache.Rejournal.String() + userConfig.Cache.TrieTimeoutRaw = userConfig.Cache.TrieTimeout.String() + userConfig.P2P.TxArrivalWaitRaw = userConfig.P2P.TxArrivalWait.String() + + if err := toml.NewEncoder(os.Stdout).Encode(userConfig); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + return 0 +} diff --git a/internal/cli/flagset/flagset.go b/internal/cli/flagset/flagset.go new file mode 100644 index 0000000000..25b7b4c3c3 --- /dev/null +++ b/internal/cli/flagset/flagset.go @@ -0,0 +1,393 @@ +package flagset + +import ( + "flag" + "fmt" + "math/big" + "sort" + "strings" + "time" +) + +type Flagset struct { + flags []*FlagVar + set *flag.FlagSet +} + +func NewFlagSet(name string) *Flagset { + f := &Flagset{ + flags: []*FlagVar{}, + set: flag.NewFlagSet(name, flag.ContinueOnError), + } + + return f +} + +type FlagVar struct { + Name string + Usage string + Group string + Default any +} + +func (f *Flagset) addFlag(fl *FlagVar) { + f.flags = append(f.flags, fl) +} + +func (f *Flagset) Help() string { + str := "Options:\n\n" + + items := []string{} + + for _, item := range f.flags { + if item.Default != nil { + items = append(items, fmt.Sprintf(" -%s\n %s (default: %v)", item.Name, item.Usage, item.Default)) + } else { + items = append(items, fmt.Sprintf(" -%s\n %s", item.Name, item.Usage)) + } + } + + return str + strings.Join(items, "\n\n") +} + +func (f *Flagset) GetAllFlags() []string { + flags := []string{} + for _, flag := range f.flags { + flags = append(flags, flag.Name) + } + + return flags +} + +// MarkDown implements cli.MarkDown interface +func (f *Flagset) MarkDown() string { + if len(f.flags) == 0 { + return "" + } + + groups := make(map[string][]*FlagVar) + + for _, item := range f.flags { + groups[item.Group] = append(groups[item.Group], item) + } + + i := 0 + keys := make([]string, len(groups)) + + for k := range groups { + keys[i] = k + i++ + } + + sort.Strings(keys) + + items := []string{} + + for _, k := range keys { + if k == "" { + items = append(items, "## Options") + } else { + items = append(items, fmt.Sprintf("### %s Options", k)) + } + + for _, item := range groups[k] { + if item.Default != nil { + items = append(items, fmt.Sprintf("- ```%s```: %s (default: %v)", item.Name, item.Usage, item.Default)) + } else { + items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage)) + } + } + } + + return strings.Join(items, "\n\n") +} + +func (f *Flagset) Parse(args []string) error { + return f.set.Parse(args) +} + +func (f *Flagset) Args() []string { + return f.set.Args() +} + +type BoolFlag struct { + Name string + Usage string + Default bool + Value *bool + Group string +} + +func (f *Flagset) BoolFlag(b *BoolFlag) { + f.addFlag(&FlagVar{ + Name: b.Name, + Usage: b.Usage, + Group: b.Group, + Default: b.Default, + }) + f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage) +} + +type StringFlag struct { + Name string + Usage string + Default string + Value *string + Group string + HideDefaultFromDoc bool +} + +func (f *Flagset) StringFlag(b *StringFlag) { + if b.Default == "" || b.HideDefaultFromDoc { + f.addFlag(&FlagVar{ + Name: b.Name, + Usage: b.Usage, + Group: b.Group, + Default: nil, + }) + } else { + f.addFlag(&FlagVar{ + Name: b.Name, + Usage: b.Usage, + Group: b.Group, + Default: b.Default, + }) + } + + f.set.StringVar(b.Value, b.Name, b.Default, b.Usage) +} + +type IntFlag struct { + Name string + Usage string + Value *int + Default int + Group string +} + +func (f *Flagset) IntFlag(i *IntFlag) { + f.addFlag(&FlagVar{ + Name: i.Name, + Usage: i.Usage, + Group: i.Group, + Default: i.Default, + }) + f.set.IntVar(i.Value, i.Name, i.Default, i.Usage) +} + +type Uint64Flag struct { + Name string + Usage string + Value *uint64 + Default uint64 + Group string +} + +func (f *Flagset) Uint64Flag(i *Uint64Flag) { + f.addFlag(&FlagVar{ + Name: i.Name, + Usage: i.Usage, + Group: i.Group, + Default: fmt.Sprintf("%d", i.Default), + }) + f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage) +} + +type BigIntFlag struct { + Name string + Usage string + Value *big.Int + Group string + Default *big.Int +} + +func (b *BigIntFlag) String() string { + if b.Value == nil { + return "" + } + + return b.Value.String() +} + +func (b *BigIntFlag) Set(value string) error { + num := new(big.Int) + + var ok bool + if strings.HasPrefix(value, "0x") { + num, ok = num.SetString(value[2:], 16) + *b.Value = *num + } else { + num, ok = num.SetString(value, 10) + *b.Value = *num + } + + if !ok { + return fmt.Errorf("failed to set big int") + } + + return nil +} + +func (f *Flagset) BigIntFlag(b *BigIntFlag) { + f.addFlag(&FlagVar{ + Name: b.Name, + Usage: b.Usage, + Group: b.Group, + Default: b.Default, + }) + f.set.Var(b, b.Name, b.Usage) +} + +type SliceStringFlag struct { + Name string + Usage string + Value *[]string + Default []string + Group string +} + +// SplitAndTrim splits input separated by a comma +// and trims excessive white space from the substrings. +func SplitAndTrim(input string) (ret []string) { + l := strings.Split(input, ",") + for _, r := range l { + if r = strings.TrimSpace(r); r != "" { + ret = append(ret, r) + } + } + + return ret +} + +func (i *SliceStringFlag) String() string { + if i.Value == nil { + return "" + } + + return strings.Join(*i.Value, ",") +} + +func (i *SliceStringFlag) Set(value string) error { + // overwritting insted of appending + *i.Value = SplitAndTrim(value) + return nil +} + +func (f *Flagset) SliceStringFlag(s *SliceStringFlag) { + if s.Default == nil || len(s.Default) == 0 { + f.addFlag(&FlagVar{ + Name: s.Name, + Usage: s.Usage, + Group: s.Group, + Default: nil, + }) + } else { + f.addFlag(&FlagVar{ + Name: s.Name, + Usage: s.Usage, + Group: s.Group, + Default: strings.Join(s.Default, ","), + }) + } + + f.set.Var(s, s.Name, s.Usage) +} + +type DurationFlag struct { + Name string + Usage string + Value *time.Duration + Default time.Duration + Group string +} + +func (f *Flagset) DurationFlag(d *DurationFlag) { + f.addFlag(&FlagVar{ + Name: d.Name, + Usage: d.Usage, + Group: d.Group, + Default: d.Default, + }) + f.set.DurationVar(d.Value, d.Name, d.Default, "") +} + +type MapStringFlag struct { + Name string + Usage string + Value *map[string]string + Group string + Default map[string]string +} + +func formatMapString(m map[string]string) string { + if len(m) == 0 { + return "" + } + + ls := []string{} + for k, v := range m { + ls = append(ls, k+"="+v) + } + + return strings.Join(ls, ",") +} + +func (m *MapStringFlag) String() string { + return formatMapString(*m.Value) +} + +func (m *MapStringFlag) Set(value string) error { + if m.Value == nil { + m.Value = &map[string]string{} + } + + for _, t := range strings.Split(value, ",") { + if t != "" { + kv := strings.Split(t, "=") + + if len(kv) == 2 { + (*m.Value)[kv[0]] = kv[1] + } + } + } + + return nil +} + +func (f *Flagset) MapStringFlag(m *MapStringFlag) { + if m.Default == nil || len(m.Default) == 0 { + f.addFlag(&FlagVar{ + Name: m.Name, + Usage: m.Usage, + Group: m.Group, + Default: nil, + }) + } else { + f.addFlag(&FlagVar{ + Name: m.Name, + Usage: m.Usage, + Group: m.Group, + Default: formatMapString(m.Default), + }) + } + + f.set.Var(m, m.Name, m.Usage) +} + +type Float64Flag struct { + Name string + Usage string + Value *float64 + Default float64 + Group string +} + +func (f *Flagset) Float64Flag(i *Float64Flag) { + f.addFlag(&FlagVar{ + Name: i.Name, + Usage: i.Usage, + Group: i.Group, + Default: i.Default, + }) + f.set.Float64Var(i.Value, i.Name, i.Default, "") +} diff --git a/internal/cli/flagset/flagset_test.go b/internal/cli/flagset/flagset_test.go new file mode 100644 index 0000000000..118361320d --- /dev/null +++ b/internal/cli/flagset/flagset_test.go @@ -0,0 +1,63 @@ +package flagset + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestFlagsetBool(t *testing.T) { + f := NewFlagSet("") + + value := false + f.BoolFlag(&BoolFlag{ + Name: "flag", + Value: &value, + }) + + assert.NoError(t, f.Parse([]string{"--flag", "true"})) + assert.Equal(t, value, true) +} + +func TestFlagsetSliceString(t *testing.T) { + f := NewFlagSet("") + + value := []string{"a", "b", "c"} + f.SliceStringFlag(&SliceStringFlag{ + Name: "flag", + Value: &value, + Default: value, + }) + + assert.NoError(t, f.Parse([]string{})) + assert.Equal(t, value, []string{"a", "b", "c"}) + assert.NoError(t, f.Parse([]string{"--flag", "a,b"})) + assert.Equal(t, value, []string{"a", "b"}) +} + +func TestFlagsetDuration(t *testing.T) { + f := NewFlagSet("") + + value := time.Duration(0) + f.DurationFlag(&DurationFlag{ + Name: "flag", + Value: &value, + }) + + assert.NoError(t, f.Parse([]string{"--flag", "1m"})) + assert.Equal(t, value, 1*time.Minute) +} + +func TestFlagsetMapString(t *testing.T) { + f := NewFlagSet("") + + value := map[string]string{} + f.MapStringFlag(&MapStringFlag{ + Name: "flag", + Value: &value, + }) + + assert.NoError(t, f.Parse([]string{"--flag", "a=b,c=d"})) + assert.Equal(t, value, map[string]string{"a": "b", "c": "d"}) +} diff --git a/internal/cli/markdown.go b/internal/cli/markdown.go new file mode 100644 index 0000000000..652c98e56b --- /dev/null +++ b/internal/cli/markdown.go @@ -0,0 +1,14 @@ +package cli + +import ( + "strings" +) + +type MarkDown interface { + MarkDown() string +} + +// Create a Markdown code block from a slice of string, where each string is a line of code +func CodeBlock(lines []string) string { + return "```\n" + strings.Join(lines, "\n") + "\n```" +} diff --git a/internal/cli/markdown_test.go b/internal/cli/markdown_test.go new file mode 100644 index 0000000000..24a0e40e11 --- /dev/null +++ b/internal/cli/markdown_test.go @@ -0,0 +1,20 @@ +package cli + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCodeBlock(t *testing.T) { + t.Parallel() + assert := require.New(t) + + lines := []string{ + "abc", + "bcd", + } + + expected := "```\n" + "abc\n" + "bcd\n" + "```" + assert.Equal(expected, CodeBlock(lines)) +} diff --git a/internal/cli/peers.go b/internal/cli/peers.go new file mode 100644 index 0000000000..fbbca24fad --- /dev/null +++ b/internal/cli/peers.go @@ -0,0 +1,59 @@ +package cli + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +// PeersCommand is the command to group the peers commands +type PeersCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (a *PeersCommand) MarkDown() string { + items := []string{ + "# Peers", + "The ```peers``` command groups actions to interact with peers:", + "- [```peers add```](./peers_add.md): Joins the local client to another remote peer.", + "- [```peers list```](./peers_list.md): Lists the connected peers to the Bor client.", + "- [```peers remove```](./peers_remove.md): Disconnects the local client from a connected peer if exists.", + "- [```peers status```](./peers_status.md): Display the status of a peer by its id.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *PeersCommand) Help() string { + return `Usage: bor peers + + This command groups actions to interact with peers. + + List the connected peers: + + $ bor peers list + + Add a new peer by enode: + + $ bor peers add + + Remove a connected peer by enode: + + $ bor peers remove + + Display information about a peer: + + $ bor peers status ` +} + +// Synopsis implements the cli.Command interface +func (c *PeersCommand) Synopsis() string { + return "Interact with peers" +} + +// Run implements the cli.Command interface +func (c *PeersCommand) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/internal/cli/peers_add.go b/internal/cli/peers_add.go new file mode 100644 index 0000000000..3df1a6b6cb --- /dev/null +++ b/internal/cli/peers_add.go @@ -0,0 +1,85 @@ +package cli + +import ( + "context" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// PeersAddCommand is the command to group the peers commands +type PeersAddCommand struct { + *Meta2 + + trusted bool +} + +// MarkDown implements cli.MarkDown interface +func (p *PeersAddCommand) MarkDown() string { + items := []string{ + "# Peers add", + "The ```peers add ``` command joins the local client to another remote peer.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (p *PeersAddCommand) Help() string { + return `Usage: bor peers add + + Joins the local client to another remote peer. + + ` + p.Flags().Help() +} + +func (p *PeersAddCommand) Flags() *flagset.Flagset { + flags := p.NewFlagSet("peers add") + + flags.BoolFlag(&flagset.BoolFlag{ + Name: "trusted", + Usage: "Add the peer as a trusted", + Value: &p.trusted, + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *PeersAddCommand) Synopsis() string { + return "Join the client to a remote peer" +} + +// Run implements the cli.Command interface +func (c *PeersAddCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + args = flags.Args() + if len(args) != 1 { + c.UI.Error("No enode address provided") + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + req := &proto.PeersAddRequest{ + Enode: args[0], + Trusted: c.trusted, + } + if _, err := borClt.PeersAdd(context.Background(), req); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + return 0 +} diff --git a/internal/cli/peers_list.go b/internal/cli/peers_list.go new file mode 100644 index 0000000000..4a572447c1 --- /dev/null +++ b/internal/cli/peers_list.go @@ -0,0 +1,96 @@ +package cli + +import ( + "context" + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// PeersListCommand is the command to group the peers commands +type PeersListCommand struct { + *Meta2 +} + +// MarkDown implements cli.MarkDown interface +func (p *PeersListCommand) MarkDown() string { + items := []string{ + "# Peers add", + "The ```peers list``` command lists the connected peers.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (p *PeersListCommand) Help() string { + return `Usage: bor peers list + + Lists the connected peers + + ` + p.Flags().Help() +} + +func (p *PeersListCommand) Flags() *flagset.Flagset { + flags := p.NewFlagSet("peers list") + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *PeersListCommand) Synopsis() string { + return "" +} + +// Run implements the cli.Command interface +func (c *PeersListCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + req := &proto.PeersListRequest{} + resp, err := borClt.PeersList(context.Background(), req) + + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.UI.Output(formatPeers(resp.Peers)) + + return 0 +} + +func formatPeers(peers []*proto.Peer) string { + if len(peers) == 0 { + return "No peers found" + } + + rows := make([]string, len(peers)+1) + rows[0] = "ID|Enode|Name|Caps|Static|Trusted" + + for i, d := range peers { + enode := strings.TrimPrefix(d.Enode, "enode://") + + rows[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%v", + d.Id, + enode[:10], + d.Name, + strings.Join(d.Caps, ","), + d.Static, + d.Trusted) + } + + return formatList(rows) +} diff --git a/internal/cli/peers_remove.go b/internal/cli/peers_remove.go new file mode 100644 index 0000000000..f53284c40c --- /dev/null +++ b/internal/cli/peers_remove.go @@ -0,0 +1,85 @@ +package cli + +import ( + "context" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// PeersRemoveCommand is the command to group the peers commands +type PeersRemoveCommand struct { + *Meta2 + + trusted bool +} + +// MarkDown implements cli.MarkDown interface +func (p *PeersRemoveCommand) MarkDown() string { + items := []string{ + "# Peers remove", + "The ```peers remove ``` command disconnects the local client from a connected peer if exists.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (p *PeersRemoveCommand) Help() string { + return `Usage: bor peers remove + + Disconnects the local client from a connected peer if exists. + + ` + p.Flags().Help() +} + +func (p *PeersRemoveCommand) Flags() *flagset.Flagset { + flags := p.NewFlagSet("peers remove") + + flags.BoolFlag(&flagset.BoolFlag{ + Name: "trusted", + Usage: "Add the peer as a trusted", + Value: &p.trusted, + }) + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *PeersRemoveCommand) Synopsis() string { + return "Disconnects a peer from the client" +} + +// Run implements the cli.Command interface +func (c *PeersRemoveCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + args = flags.Args() + if len(args) != 1 { + c.UI.Error("No enode address provided") + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + req := &proto.PeersRemoveRequest{ + Enode: args[0], + Trusted: c.trusted, + } + if _, err := borClt.PeersRemove(context.Background(), req); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + return 0 +} diff --git a/internal/cli/peers_status.go b/internal/cli/peers_status.go new file mode 100644 index 0000000000..f5d700a273 --- /dev/null +++ b/internal/cli/peers_status.go @@ -0,0 +1,95 @@ +package cli + +import ( + "context" + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// PeersStatusCommand is the command to group the peers commands +type PeersStatusCommand struct { + *Meta2 +} + +// MarkDown implements cli.MarkDown interface +func (p *PeersStatusCommand) MarkDown() string { + items := []string{ + "# Peers status", + "The ```peers status ``` command displays the status of a peer by its id.", + p.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (p *PeersStatusCommand) Help() string { + return `Usage: bor peers status + + Display the status of a peer by its id. + + ` + p.Flags().Help() +} + +func (p *PeersStatusCommand) Flags() *flagset.Flagset { + flags := p.NewFlagSet("peers status") + + return flags +} + +// Synopsis implements the cli.Command interface +func (c *PeersStatusCommand) Synopsis() string { + return "Display the status of a peer" +} + +// Run implements the cli.Command interface +func (c *PeersStatusCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + args = flags.Args() + if len(args) != 1 { + c.UI.Error("No enode address provided") + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + req := &proto.PeersStatusRequest{ + Enode: args[0], + } + resp, err := borClt.PeersStatus(context.Background(), req) + + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.UI.Output(formatPeer(resp.Peer)) + + return 0 +} + +func formatPeer(peer *proto.Peer) string { + base := formatKV([]string{ + fmt.Sprintf("Name|%s", peer.Name), + fmt.Sprintf("ID|%s", peer.Id), + fmt.Sprintf("ENR|%s", peer.Enr), + fmt.Sprintf("Capabilities|%s", strings.Join(peer.Caps, ",")), + fmt.Sprintf("Enode|%s", peer.Enode), + fmt.Sprintf("Static|%v", peer.Static), + fmt.Sprintf("Trusted|%v", peer.Trusted), + }) + + return base +} diff --git a/internal/cli/removedb.go b/internal/cli/removedb.go new file mode 100644 index 0000000000..ce0a9f4f19 --- /dev/null +++ b/internal/cli/removedb.go @@ -0,0 +1,156 @@ +package cli + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/node" + + "github.com/mitchellh/cli" +) + +// RemoveDBCommand is for removing blockchain and state databases +type RemoveDBCommand struct { + *Meta2 + + datadir string +} + +const ( + chaindataPath string = "chaindata" + ancientPath string = "ancient" + trieCacheJournalPath string = "triecache" + lightchaindataPath string = "lightchaindata" +) + +// MarkDown implements cli.MarkDown interface +func (c *RemoveDBCommand) MarkDown() string { + items := []string{ + "# RemoveDB", + "The ```bor removedb``` command will remove the blockchain and state databases at the given datadir location", + c.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *RemoveDBCommand) Help() string { + return `Usage: bor removedb + + This command will remove the blockchain and state databases at the given datadir location` +} + +// Synopsis implements the cli.Command interface +func (c *RemoveDBCommand) Synopsis() string { + return "Remove blockchain and state databases" +} + +func (c *RemoveDBCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("removedb") + + flags.StringFlag(&flagset.StringFlag{ + Name: "datadir", + Value: &c.datadir, + Usage: "Path of the data directory to store information", + }) + + return flags +} + +// Run implements the cli.Command interface +func (c *RemoveDBCommand) Run(args []string) int { + flags := c.Flags() + + // parse datadir + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + datadir := c.datadir + if datadir == "" { + datadir = server.DefaultDataDir() + } + + // create ethereum node config with just the datadir + nodeCfg := &node.Config{DataDir: datadir} + + // Remove the full node state database + path := nodeCfg.ResolvePath(chaindataPath) + if common.FileExist(path) { + confirmAndRemoveDB(c.UI, path, "full node state database") + } else { + log.Info("Full node state database missing", "path", path) + } + + // Remove the full node ancient database + // Note: The old cli used DatabaseFreezer path from config if provided explicitly + // We don't have access to eth config and hence we assume it to be + // under the "chaindata" folder. + path = filepath.Join(nodeCfg.ResolvePath(chaindataPath), ancientPath) + if common.FileExist(path) { + confirmAndRemoveDB(c.UI, path, "full node ancient database") + } else { + log.Info("Full node ancient database missing", "path", path) + } + + // Remove the light node database + path = nodeCfg.ResolvePath(lightchaindataPath) + if common.FileExist(path) { + confirmAndRemoveDB(c.UI, path, "light node database") + } else { + log.Info("Light node database missing", "path", path) + } + + return 0 +} + +// confirmAndRemoveDB prompts the user for a last confirmation and removes the +// folder if accepted. +func confirmAndRemoveDB(ui cli.Ui, database string, kind string) { + for { + confirm, err := ui.Ask(fmt.Sprintf("Remove %s (%s)? [y/n]", kind, database)) + + switch { + case err != nil: + ui.Output(err.Error()) + return + case confirm != "": + switch strings.ToLower(confirm) { + case "y": + start := time.Now() + err = filepath.Walk(database, func(path string, info os.FileInfo, err error) error { + // If we're at the top level folder, recurse into + if path == database { + return nil + } + // Delete all the files, but not subfolders + if !info.IsDir() { + return os.Remove(path) + } + + return filepath.SkipDir + }) + + if err != nil && err != filepath.SkipDir { + ui.Output(err.Error()) + } else { + log.Info("Database successfully deleted", "path", database, "elapsed", common.PrettyDuration(time.Since(start))) + } + + return + case "n": + log.Info("Database deletion skipped", "path", database) + return + } + } + } +} diff --git a/internal/cli/server/chains/allocs/mainnet.json b/internal/cli/server/chains/allocs/mainnet.json new file mode 100644 index 0000000000..897fb053bf --- /dev/null +++ b/internal/cli/server/chains/allocs/mainnet.json @@ -0,0 +1,35 @@ +{ + "0000000000000000000000000000000000001000": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a9190810190612c14565b610706565b60405161021e93929190613553565b60405180910390f35b610241600480360361023c9190810190612c14565b61075d565b60405161024f929190613374565b60405180910390f35b610272600480360361026d9190810190612c3d565b610939565b60405161027f91906133ab565b60405180910390f35b6102a2600480360361029d9190810190612d1c565b610a91565b005b6102be60048036036102b99190810190612c3d565b61112a565b6040516102cb91906133ab565b60405180910390f35b6102dc611281565b6040516102e99190613501565b60405180910390f35b61030c60048036036103079190810190612b71565b611286565b60405161031991906133c6565b60405180910390f35b61033c60048036036103379190810190612c14565b611307565b6040516103499190613501565b60405180910390f35b61035a611437565b6040516103679190613359565b60405180910390f35b61038a60048036036103859190810190612bad565b61144f565b60405161039791906133ab565b60405180910390f35b6103a861151a565b6040516103b591906133c6565b60405180910390f35b6103d860048036036103d39190810190612c79565b611531565b6040516103e59190613501565b60405180910390f35b61040860048036036104039190810190612c3d565b611619565b60405161041591906134e6565b60405180910390f35b610426611781565b6040516104339190613501565b60405180910390f35b61045660048036036104519190810190612af6565b611791565b60405161046391906133ab565b60405180910390f35b61048660048036036104819190810190612b1f565b6117ab565b60405161049391906133c6565b60405180910390f35b6104a4611829565b6040516104b393929190613553565b60405180910390f35b6104c461189d565b6040516104d2929190613374565b60405180910390f35b6104e3611c5e565b6040516104f09190613501565b60405180910390f35b610513600480360361050e9190810190612ce0565b611c63565b6040516105229392919061351c565b60405180910390f35b61054560048036036105409190810190612af6565b611cc7565b60405161055291906133ab565b60405180910390f35b610563611ce1565b60405161057091906133c6565b60405180910390f35b610593600480360361058e9190810190612c14565b611cf8565b6040516105a09190613501565b60405180910390f35b6105b1611e29565b6040516105be91906133c6565b60405180910390f35b6105cf611e40565b6040516105de93929190613553565b60405180910390f35b61060160048036036105fc9190810190612c14565b611ea1565b60405161060e9190613501565b60405180910390f35b61061f611fa1565b60405161062d929190613374565b60405180910390f35b610650600480360361064b9190810190612c14565b611fb5565b60405161065d9190613501565b60405180910390f35b61066e611fd6565b60405161067b919061358a565b60405180910390f35b61069e60048036036106999190810190612ce0565b611fdb565b6040516106ad9392919061351c565b60405180910390f35b6106be61203f565b6040516106cb9190613501565b60405180910390f35b6106ee60048036036106e99190810190612c14565b612051565b6040516106fd93929190613553565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611ea1565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a906134c6565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b3061207b565b5b610b4560018261239c90919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d90613446565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf906134a6565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1190613486565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a90613426565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc390613466565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d6691906128f0565b506000600160008a815260200190815260200160002081610d8791906128f0565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506123bb565b6123e9565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b60200260200101516123e9565b90506000808c81526020019081526020016000208054809190600101610e3491906128f0565b506040518060600160405280610e5d83600081518110610e5057fe5b60200260200101516124c6565b8152602001610e7f83600181518110610e7257fe5b60200260200101516124c6565b8152602001610ea183600281518110610e9457fe5b6020026020010151612537565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506123bb565b6123e9565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b60200260200101516123e9565b9050600160008d81526020019081526020016000208054809190600101610fff91906128f0565b5060405180606001604052806110288360008151811061101b57fe5b60200260200101516124c6565b815260200161104a8360018151811061103d57fe5b60200260200101516124c6565b815260200161106c8360028151811061105f57fe5b6020026020010151612537565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a3939291906132c6565b6040516020818303038152906040526040516112bf9190613303565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff9190810190612b48565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b6020026020010151602001518361239c90919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b60405161152690613344565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff16604161255a565b9050600061158582896125e690919063ffffffff16565b905061158f612922565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb81602001518761239c90919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b611621612922565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611ea1565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c692919061329a565b6040516020818303038152906040526040516117e29190613303565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506118229190810190612b48565b9050919050565b60008060008061184a600161183c611781565b61239c90919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060076040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b509050735973918275c01f50555d44e92c9d9b353cadad54816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073b8bb158b93c94ed35c1970d610d1e2b34e26652c8160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073f84c74dea96df0ec22e11e7c33996c73fcc2d822816002815181106119af57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073b702f1c9154ac9c08da247a8e30ee6f2f3373f4181600381518110611a0b57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050737fcd58c2d53d980b247f1612fdba93e9a76193e681600481518110611a6757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050730375b2fc7140977c9c76d45421564e354ed4227781600581518110611ac357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507342eefcda06ead475cde3731b8eb138e88cd0bac381600681518110611b1f57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060606007604051908082528060200260200182016040528015611b8b5781602001602082028038833980820191505090505b50905061271081600081518110611b9e57fe5b60200260200101818152505061271081600181518110611bba57fe5b60200260200101818152505061271081600281518110611bd657fe5b60200260200101818152505061271081600381518110611bf257fe5b60200260200101818152505061271081600481518110611c0e57fe5b60200260200101818152505061271081600581518110611c2a57fe5b60200260200101818152505061271081600681518110611c4657fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611c7c57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611cda611cd4611781565b83610939565b9050919050565b604051611ced9061331a565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611dcb578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611d2f565b505050509050600080905060008090505b8251811015611e1e57611e0f838281518110611df457fe5b6020026020010151602001518361239c90919063ffffffff16565b91508080600101915050611ddc565b508092505050919050565b604051611e359061332f565b604051809103902081565b600080600080611e4e611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611f6157611ebe612959565b6002600060036001850381548110611ed257fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611f2f57506000816040015114155b8015611f3f575080604001518411155b15611f5257806000015192505050611f9c565b50808060019003915050611ead565b5060006003805490501115611f9757600360016003805490500381548110611f8557fe5b90600052602060002001549050611f9c565b600090505b919050565b606080611fad4361075d565b915091509091565b60038181548110611fc257fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611ff457fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b60006040438161204b57fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b60608061208661189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff81525060026000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600381908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008381526020019081526020016000208161212f91906128f0565b506000600160008381526020019081526020016000208161215091906128f0565b5060008090505b835181101561227257600080838152602001908152602001600020805480919060010161218491906128f0565b5060405180606001604052808281526020018483815181106121a257fe5b602002602001015181526020018583815181106121bb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1681525060008084815260200190815260200160002082815481106121f957fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612157565b5060008090505b8351811015612396576001600083815260200190815260200160002080548091906001016122a791906128f0565b5060405180606001604052808281526020018483815181106122c557fe5b602002602001015181526020018583815181106122de57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1681525060016000848152602001908152602001600020828154811061231d57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612279565b50505050565b6000808284019050838110156123b157600080fd5b8091505092915050565b6123c361297a565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606123f4826126f0565b6123fd57600080fd5b60006124088361273e565b905060608160405190808252806020026020018201604052801561244657816020015b612433612994565b81526020019060019003908161242b5790505b509050600061245885602001516127af565b8560200151019050600080600090505b848110156124b95761247983612838565b915060405180604001604052808381526020018481525084828151811061249c57fe5b602002602001018190525081830192508080600101915050612468565b5082945050505050919050565b60008082600001511180156124e057506021826000015111155b6124e957600080fd5b60006124f883602001516127af565b9050600081846000015103905060008083866020015101905080519150602083101561252b57826020036101000a820491505b81945050505050919050565b6000601582600001511461254a57600080fd5b612553826124c6565b9050919050565b60608183018451101561256c57600080fd5b6060821560008114612589576040519150602082016040526125da565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156125c757805183526020830192506020810190506125aa565b50868552601f19601f8301166040525050505b50809150509392505050565b600080600080604185511461260157600093505050506126ea565b602085015192506040850151915060ff6041860151169050601b8160ff16101561262c57601b810190505b601b8160ff16141580156126445750601c8160ff1614155b1561265557600093505050506126ea565b60006001878386866040516000815260200160405260405161267a94939291906133e1565b6020604051602081039080840390855afa15801561269c573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156126e257600080fd5b809450505050505b92915050565b600080826000015114156127075760009050612739565b60008083602001519050805160001a915060c060ff168260ff16101561273257600092505050612739565b6001925050505b919050565b6000808260000151141561275557600090506127aa565b6000809050600061276984602001516127af565b84602001510190506000846000015185602001510190505b808210156127a35761279282612838565b820191508280600101935050612781565b8293505050505b919050565b600080825160001a9050608060ff168110156127cf576000915050612833565b60b860ff168110806127f4575060c060ff1681101580156127f3575060f860ff1681105b5b15612803576001915050612833565b60c060ff168110156128235760018060b80360ff16820301915050612833565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561285957600191506128e6565b60b860ff16811015612876576001608060ff1682030191506128e5565b60c060ff168110156128a65760b78103600185019450806020036101000a855104600182018101935050506128e4565b60f860ff168110156128c357600160c060ff1682030191506128e3565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b81548183558181111561291d5760030281600302836000526020600020918201910161291c91906129ae565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b612a0191905b808211156129fd5760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506003016129b4565b5090565b90565b600081359050612a1381613783565b92915050565b600081359050612a288161379a565b92915050565b600081519050612a3d8161379a565b92915050565b60008083601f840112612a5557600080fd5b8235905067ffffffffffffffff811115612a6e57600080fd5b602083019150836001820283011115612a8657600080fd5b9250929050565b600082601f830112612a9e57600080fd5b8135612ab1612aac826135d2565b6135a5565b91508082526020830160208301858383011115612acd57600080fd5b612ad883828461372d565b50505092915050565b600081359050612af0816137b1565b92915050565b600060208284031215612b0857600080fd5b6000612b1684828501612a04565b91505092915050565b600060208284031215612b3157600080fd5b6000612b3f84828501612a19565b91505092915050565b600060208284031215612b5a57600080fd5b6000612b6884828501612a2e565b91505092915050565b60008060408385031215612b8457600080fd5b6000612b9285828601612a19565b9250506020612ba385828601612a19565b9150509250929050565b600080600060608486031215612bc257600080fd5b6000612bd086828701612a19565b9350506020612be186828701612a19565b925050604084013567ffffffffffffffff811115612bfe57600080fd5b612c0a86828701612a8d565b9150509250925092565b600060208284031215612c2657600080fd5b6000612c3484828501612ae1565b91505092915050565b60008060408385031215612c5057600080fd5b6000612c5e85828601612ae1565b9250506020612c6f85828601612a04565b9150509250929050565b600080600060608486031215612c8e57600080fd5b6000612c9c86828701612ae1565b9350506020612cad86828701612a19565b925050604084013567ffffffffffffffff811115612cca57600080fd5b612cd686828701612a8d565b9150509250925092565b60008060408385031215612cf357600080fd5b6000612d0185828601612ae1565b9250506020612d1285828601612ae1565b9150509250929050565b600080600080600080600060a0888a031215612d3757600080fd5b6000612d458a828b01612ae1565b9750506020612d568a828b01612ae1565b9650506040612d678a828b01612ae1565b955050606088013567ffffffffffffffff811115612d8457600080fd5b612d908a828b01612a43565b9450945050608088013567ffffffffffffffff811115612daf57600080fd5b612dbb8a828b01612a43565b925092505092959891949750929550565b6000612dd88383612dfc565b60208301905092915050565b6000612df0838361326d565b60208301905092915050565b612e05816136a2565b82525050565b612e14816136a2565b82525050565b6000612e258261361e565b612e2f8185613659565b9350612e3a836135fe565b8060005b83811015612e6b578151612e528882612dcc565b9750612e5d8361363f565b925050600181019050612e3e565b5085935050505092915050565b6000612e8382613629565b612e8d818561366a565b9350612e988361360e565b8060005b83811015612ec9578151612eb08882612de4565b9750612ebb8361364c565b925050600181019050612e9c565b5085935050505092915050565b612edf816136b4565b82525050565b612ef6612ef1826136c0565b61376f565b82525050565b612f05816136ec565b82525050565b612f1c612f17826136ec565b613779565b82525050565b6000612f2d82613634565b612f37818561367b565b9350612f4781856020860161373c565b80840191505092915050565b6000612f60600483613697565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612fa0602d83613686565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000613006600383613697565b91507f31333700000000000000000000000000000000000000000000000000000000006000830152600382019050919050565b6000613046600f83613686565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000613086601383613686565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b60006130c6604583613686565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000613152600c83613697565b91507f6865696d64616c6c2d31333700000000000000000000000000000000000000006000830152600c82019050919050565b6000613192602a83613686565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b60006131f8601283613686565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b606082016000820151613241600085018261326d565b506020820151613254602085018261326d565b5060408201516132676040850182612dfc565b50505050565b61327681613716565b82525050565b61328581613716565b82525050565b61329481613720565b82525050565b60006132a68285612ee5565b6001820191506132b68284612f0b565b6020820191508190509392505050565b60006132d28286612ee5565b6001820191506132e28285612f0b565b6020820191506132f28284612f0b565b602082019150819050949350505050565b600061330f8284612f22565b915081905092915050565b600061332582612f53565b9150819050919050565b600061333a82612ff9565b9150819050919050565b600061334f82613145565b9150819050919050565b600060208201905061336e6000830184612e0b565b92915050565b6000604082019050818103600083015261338e8185612e1a565b905081810360208301526133a28184612e78565b90509392505050565b60006020820190506133c06000830184612ed6565b92915050565b60006020820190506133db6000830184612efc565b92915050565b60006080820190506133f66000830187612efc565b613403602083018661328b565b6134106040830185612efc565b61341d6060830184612efc565b95945050505050565b6000602082019050818103600083015261343f81612f93565b9050919050565b6000602082019050818103600083015261345f81613039565b9050919050565b6000602082019050818103600083015261347f81613079565b9050919050565b6000602082019050818103600083015261349f816130b9565b9050919050565b600060208201905081810360008301526134bf81613185565b9050919050565b600060208201905081810360008301526134df816131eb565b9050919050565b60006060820190506134fb600083018461322b565b92915050565b6000602082019050613516600083018461327c565b92915050565b6000606082019050613531600083018661327c565b61353e602083018561327c565b61354b6040830184612e0b565b949350505050565b6000606082019050613568600083018661327c565b613575602083018561327c565b613582604083018461327c565b949350505050565b600060208201905061359f600083018461328b565b92915050565b6000604051905081810181811067ffffffffffffffff821117156135c857600080fd5b8060405250919050565b600067ffffffffffffffff8211156135e957600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006136ad826136f6565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b8381101561375a57808201518184015260208101905061373f565b83811115613769576000848401525b50505050565b6000819050919050565b6000819050919050565b61378c816136a2565b811461379757600080fd5b50565b6137a3816136ec565b81146137ae57600080fd5b50565b6137ba81613716565b81146137c557600080fd5b5056fea365627a7a72315820638c74b73aaddeb2f2fb9267028e09737291458f6da93b6619d30c86432701d96c6578706572696d656e74616cf564736f6c634300050b0040" + }, + "0000000000000000000000000000000000001001": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a7231582083fbdacb76f32b4112d0f7db9a596937925824798a0026ba0232322390b5263764736f6c634300050b0032" + }, + "0000000000000000000000000000000000001010": { + "balance": "0x204fcce2c5a141f7f9a00000", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a2565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116a8565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611735565b005b348015610b2e57600080fd5b50610b37611752565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa828488611778565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3590919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f036023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5590919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ee06023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b74565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600181526020017f890000000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c7338484611778565b90505b92915050565b6040518060800160405280605b8152602001611f78605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6c565b611d42565b9050949350505050565b608981565b60015481565b604051806080016040528060528152602001611f26605291396040516020018082805190602001908083835b602083106116f757805182526020820191506020810190506020830392506116d4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173d6114dd565b61174657600080fd5b61174f81611b74565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117f857600080fd5b505afa15801561180c573d6000803e3d6000fd5b505050506040513d602081101561182257600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b457600080fd5b505afa1580156118c8573d6000803e3d6000fd5b505050506040513d60208110156118de57600080fd5b810190808051906020019092919050505090506118fc868686611d8c565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0457600080fd5b505afa158015611a18573d6000803e3d6000fd5b505050506040513d6020811015611a2e57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abc57600080fd5b505afa158015611ad0573d6000803e3d6000fd5b505050506040513d6020811015611ae657600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4457600080fd5b600082840390508091505092915050565b600080828401905083811015611b6a57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bae57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611f78605b91396040516020018082805190602001908083835b60208310611cbe5780518252602082019150602081019050602083039250611c9b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e2e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611e74573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a7231582098247ec3c8d127ebf969c8f317e340b1cd6c481af077234c38e0c7d92aba4d6364736f6c634300050b0032" + }, + "5973918275C01F50555d44e92c9d9b353CaDAD54": { + "balance": "0x3635c9adc5dea00000" + }, + "b8bB158B93c94ed35c1970D610d1E2B34E26652c": { + "balance": "0x3635c9adc5dea00000" + }, + "F84C74dEa96DF0EC22e11e7C33996C73FCC2D822": { + "balance": "0x3635c9adc5dea00000" + }, + "b702f1C9154ac9c08Da247a8e30ee6F2F3373f41": { + "balance": "0x3635c9adc5dea00000" + }, + "7fCD58C2D53D980b247F1612FdbA93E9a76193E6": { + "balance": "0x3635c9adc5dea00000" + }, + "0375b2fc7140977c9c76D45421564e354ED42277": { + "balance": "0x3635c9adc5dea00000" + }, + "42EEfcda06eaD475cdE3731B8eb138e88CD0bAC3": { + "balance": "0x3635c9adc5dea00000" + } +} diff --git a/internal/cli/server/chains/allocs/mumbai.json b/internal/cli/server/chains/allocs/mumbai.json new file mode 100644 index 0000000000..e90415e319 --- /dev/null +++ b/internal/cli/server/chains/allocs/mumbai.json @@ -0,0 +1,30 @@ +{ + "0000000000000000000000000000000000001000": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a9190810190612b24565b610706565b60405161021e93929190613463565b60405180910390f35b610241600480360361023c9190810190612b24565b61075d565b60405161024f929190613284565b60405180910390f35b610272600480360361026d9190810190612b4d565b610939565b60405161027f91906132bb565b60405180910390f35b6102a2600480360361029d9190810190612c2c565b610a91565b005b6102be60048036036102b99190810190612b4d565b61112a565b6040516102cb91906132bb565b60405180910390f35b6102dc611281565b6040516102e99190613411565b60405180910390f35b61030c60048036036103079190810190612a81565b611286565b60405161031991906132d6565b60405180910390f35b61033c60048036036103379190810190612b24565b611307565b6040516103499190613411565b60405180910390f35b61035a611437565b6040516103679190613269565b60405180910390f35b61038a60048036036103859190810190612abd565b61144f565b60405161039791906132bb565b60405180910390f35b6103a861151a565b6040516103b591906132d6565b60405180910390f35b6103d860048036036103d39190810190612b89565b611531565b6040516103e59190613411565b60405180910390f35b61040860048036036104039190810190612b4d565b611619565b60405161041591906133f6565b60405180910390f35b610426611781565b6040516104339190613411565b60405180910390f35b61045660048036036104519190810190612a06565b611791565b60405161046391906132bb565b60405180910390f35b61048660048036036104819190810190612a2f565b6117ab565b60405161049391906132d6565b60405180910390f35b6104a4611829565b6040516104b393929190613463565b60405180910390f35b6104c461189d565b6040516104d2929190613284565b60405180910390f35b6104e3611b6e565b6040516104f09190613411565b60405180910390f35b610513600480360361050e9190810190612bf0565b611b73565b6040516105229392919061342c565b60405180910390f35b61054560048036036105409190810190612a06565b611bd7565b60405161055291906132bb565b60405180910390f35b610563611bf1565b60405161057091906132d6565b60405180910390f35b610593600480360361058e9190810190612b24565b611c08565b6040516105a09190613411565b60405180910390f35b6105b1611d39565b6040516105be91906132d6565b60405180910390f35b6105cf611d50565b6040516105de93929190613463565b60405180910390f35b61060160048036036105fc9190810190612b24565b611db1565b60405161060e9190613411565b60405180910390f35b61061f611eb1565b60405161062d929190613284565b60405180910390f35b610650600480360361064b9190810190612b24565b611ec5565b60405161065d9190613411565b60405180910390f35b61066e611ee6565b60405161067b919061349a565b60405180910390f35b61069e60048036036106999190810190612bf0565b611eeb565b6040516106ad9392919061342c565b60405180910390f35b6106be611f4f565b6040516106cb9190613411565b60405180910390f35b6106ee60048036036106e99190810190612b24565b611f61565b6040516106fd93929190613463565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611db1565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a906133d6565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b30611f8b565b5b610b456001826122ac90919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d90613356565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf906133b6565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1190613396565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a90613336565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc390613376565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d669190612800565b506000600160008a815260200190815260200160002081610d879190612800565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b60200260200101516122f9565b90506000808c81526020019081526020016000208054809190600101610e349190612800565b506040518060600160405280610e5d83600081518110610e5057fe5b60200260200101516123d6565b8152602001610e7f83600181518110610e7257fe5b60200260200101516123d6565b8152602001610ea183600281518110610e9457fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b60200260200101516122f9565b9050600160008d81526020019081526020016000208054809190600101610fff9190612800565b5060405180606001604052806110288360008151811061101b57fe5b60200260200101516123d6565b815260200161104a8360018151811061103d57fe5b60200260200101516123d6565b815260200161106c8360028151811061105f57fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a3939291906131d6565b6040516020818303038152906040526040516112bf9190613213565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff9190810190612a58565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b602002602001015160200151836122ac90919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b60405161152690613254565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff16604161246a565b9050600061158582896124f690919063ffffffff16565b905061158f612832565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb8160200151876122ac90919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b611621612832565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611db1565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c69291906131aa565b6040516020818303038152906040526040516117e29190613213565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506118229190810190612a58565b9050919050565b60008060008061184a600161183c611781565b6122ac90919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060056040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b50905073c26880a0af2ea0c7e8130e6ec47af756465452e8816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073be188d6641e8b680743a4815dfa0f6208038960f8160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073c275dc8be39f50d12f66b6a63629c39da5bae5bd816002815181106119af57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073f903ba9e006193c1527bfbe65fe2123704ea3f9981600381518110611a0b57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073928ed6a3e94437bbd316ccad78479f1d163a6a8c81600481518110611a6757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060606005604051908082528060200260200182016040528015611ad35781602001602082028038833980820191505090505b50905061271081600081518110611ae657fe5b60200260200101818152505061271081600181518110611b0257fe5b60200260200101818152505061271081600281518110611b1e57fe5b60200260200101818152505061271081600381518110611b3a57fe5b60200260200101818152505061271081600481518110611b5657fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611b8c57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611bea611be4611781565b83610939565b9050919050565b604051611bfd9061322a565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611cdb578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611c3f565b505050509050600080905060008090505b8251811015611d2e57611d1f838281518110611d0457fe5b602002602001015160200151836122ac90919063ffffffff16565b91508080600101915050611cec565b508092505050919050565b604051611d459061323f565b604051809103902081565b600080600080611d5e611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611e7157611dce612869565b6002600060036001850381548110611de257fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611e3f57506000816040015114155b8015611e4f575080604001518411155b15611e6257806000015192505050611eac565b50808060019003915050611dbd565b5060006003805490501115611ea757600360016003805490500381548110611e9557fe5b90600052602060002001549050611eac565b600090505b919050565b606080611ebd4361075d565b915091509091565b60038181548110611ed257fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611f0457fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060404381611f5b57fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b606080611f9661189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff81525060026000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600381908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008381526020019081526020016000208161203f9190612800565b50600060016000838152602001908152602001600020816120609190612800565b5060008090505b83518110156121825760008083815260200190815260200160002080548091906001016120949190612800565b5060405180606001604052808281526020018483815181106120b257fe5b602002602001015181526020018583815181106120cb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16815250600080848152602001908152602001600020828154811061210957fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612067565b5060008090505b83518110156122a6576001600083815260200190815260200160002080548091906001016121b79190612800565b5060405180606001604052808281526020018483815181106121d557fe5b602002602001015181526020018583815181106121ee57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1681525060016000848152602001908152602001600020828154811061222d57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612189565b50505050565b6000808284019050838110156122c157600080fd5b8091505092915050565b6122d361288a565b600060208301905060405180604001604052808451815260200182815250915050919050565b606061230482612600565b61230d57600080fd5b60006123188361264e565b905060608160405190808252806020026020018201604052801561235657816020015b6123436128a4565b81526020019060019003908161233b5790505b509050600061236885602001516126bf565b8560200151019050600080600090505b848110156123c95761238983612748565b91506040518060400160405280838152602001848152508482815181106123ac57fe5b602002602001018190525081830192508080600101915050612378565b5082945050505050919050565b60008082600001511180156123f057506021826000015111155b6123f957600080fd5b600061240883602001516126bf565b9050600081846000015103905060008083866020015101905080519150602083101561243b57826020036101000a820491505b81945050505050919050565b6000601582600001511461245a57600080fd5b612463826123d6565b9050919050565b60608183018451101561247c57600080fd5b6060821560008114612499576040519150602082016040526124ea565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156124d757805183526020830192506020810190506124ba565b50868552601f19601f8301166040525050505b50809150509392505050565b600080600080604185511461251157600093505050506125fa565b602085015192506040850151915060ff6041860151169050601b8160ff16101561253c57601b810190505b601b8160ff16141580156125545750601c8160ff1614155b1561256557600093505050506125fa565b60006001878386866040516000815260200160405260405161258a94939291906132f1565b6020604051602081039080840390855afa1580156125ac573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125f257600080fd5b809450505050505b92915050565b600080826000015114156126175760009050612649565b60008083602001519050805160001a915060c060ff168260ff16101561264257600092505050612649565b6001925050505b919050565b6000808260000151141561266557600090506126ba565b6000809050600061267984602001516126bf565b84602001510190506000846000015185602001510190505b808210156126b3576126a282612748565b820191508280600101935050612691565b8293505050505b919050565b600080825160001a9050608060ff168110156126df576000915050612743565b60b860ff16811080612704575060c060ff168110158015612703575060f860ff1681105b5b15612713576001915050612743565b60c060ff168110156127335760018060b80360ff16820301915050612743565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561276957600191506127f6565b60b860ff16811015612786576001608060ff1682030191506127f5565b60c060ff168110156127b65760b78103600185019450806020036101000a855104600182018101935050506127f4565b60f860ff168110156127d357600160c060ff1682030191506127f3565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b81548183558181111561282d5760030281600302836000526020600020918201910161282c91906128be565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b61291191905b8082111561290d5760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506003016128c4565b5090565b90565b60008135905061292381613693565b92915050565b600081359050612938816136aa565b92915050565b60008151905061294d816136aa565b92915050565b60008083601f84011261296557600080fd5b8235905067ffffffffffffffff81111561297e57600080fd5b60208301915083600182028301111561299657600080fd5b9250929050565b600082601f8301126129ae57600080fd5b81356129c16129bc826134e2565b6134b5565b915080825260208301602083018583830111156129dd57600080fd5b6129e883828461363d565b50505092915050565b600081359050612a00816136c1565b92915050565b600060208284031215612a1857600080fd5b6000612a2684828501612914565b91505092915050565b600060208284031215612a4157600080fd5b6000612a4f84828501612929565b91505092915050565b600060208284031215612a6a57600080fd5b6000612a788482850161293e565b91505092915050565b60008060408385031215612a9457600080fd5b6000612aa285828601612929565b9250506020612ab385828601612929565b9150509250929050565b600080600060608486031215612ad257600080fd5b6000612ae086828701612929565b9350506020612af186828701612929565b925050604084013567ffffffffffffffff811115612b0e57600080fd5b612b1a8682870161299d565b9150509250925092565b600060208284031215612b3657600080fd5b6000612b44848285016129f1565b91505092915050565b60008060408385031215612b6057600080fd5b6000612b6e858286016129f1565b9250506020612b7f85828601612914565b9150509250929050565b600080600060608486031215612b9e57600080fd5b6000612bac868287016129f1565b9350506020612bbd86828701612929565b925050604084013567ffffffffffffffff811115612bda57600080fd5b612be68682870161299d565b9150509250925092565b60008060408385031215612c0357600080fd5b6000612c11858286016129f1565b9250506020612c22858286016129f1565b9150509250929050565b600080600080600080600060a0888a031215612c4757600080fd5b6000612c558a828b016129f1565b9750506020612c668a828b016129f1565b9650506040612c778a828b016129f1565b955050606088013567ffffffffffffffff811115612c9457600080fd5b612ca08a828b01612953565b9450945050608088013567ffffffffffffffff811115612cbf57600080fd5b612ccb8a828b01612953565b925092505092959891949750929550565b6000612ce88383612d0c565b60208301905092915050565b6000612d00838361317d565b60208301905092915050565b612d15816135b2565b82525050565b612d24816135b2565b82525050565b6000612d358261352e565b612d3f8185613569565b9350612d4a8361350e565b8060005b83811015612d7b578151612d628882612cdc565b9750612d6d8361354f565b925050600181019050612d4e565b5085935050505092915050565b6000612d9382613539565b612d9d818561357a565b9350612da88361351e565b8060005b83811015612dd9578151612dc08882612cf4565b9750612dcb8361355c565b925050600181019050612dac565b5085935050505092915050565b612def816135c4565b82525050565b612e06612e01826135d0565b61367f565b82525050565b612e15816135fc565b82525050565b612e2c612e27826135fc565b613689565b82525050565b6000612e3d82613544565b612e47818561358b565b9350612e5781856020860161364c565b80840191505092915050565b6000612e706004836135a7565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612eb0602d83613596565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000612f16600f83613596565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000612f56601383613596565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b6000612f96604583613596565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000613022602a83613596565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b6000613088601283613596565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b60006130c86005836135a7565b91507f38303030310000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000613108600e836135a7565b91507f6865696d64616c6c2d38303030310000000000000000000000000000000000006000830152600e82019050919050565b606082016000820151613151600085018261317d565b506020820151613164602085018261317d565b5060408201516131776040850182612d0c565b50505050565b61318681613626565b82525050565b61319581613626565b82525050565b6131a481613630565b82525050565b60006131b68285612df5565b6001820191506131c68284612e1b565b6020820191508190509392505050565b60006131e28286612df5565b6001820191506131f28285612e1b565b6020820191506132028284612e1b565b602082019150819050949350505050565b600061321f8284612e32565b915081905092915050565b600061323582612e63565b9150819050919050565b600061324a826130bb565b9150819050919050565b600061325f826130fb565b9150819050919050565b600060208201905061327e6000830184612d1b565b92915050565b6000604082019050818103600083015261329e8185612d2a565b905081810360208301526132b28184612d88565b90509392505050565b60006020820190506132d06000830184612de6565b92915050565b60006020820190506132eb6000830184612e0c565b92915050565b60006080820190506133066000830187612e0c565b613313602083018661319b565b6133206040830185612e0c565b61332d6060830184612e0c565b95945050505050565b6000602082019050818103600083015261334f81612ea3565b9050919050565b6000602082019050818103600083015261336f81612f09565b9050919050565b6000602082019050818103600083015261338f81612f49565b9050919050565b600060208201905081810360008301526133af81612f89565b9050919050565b600060208201905081810360008301526133cf81613015565b9050919050565b600060208201905081810360008301526133ef8161307b565b9050919050565b600060608201905061340b600083018461313b565b92915050565b6000602082019050613426600083018461318c565b92915050565b6000606082019050613441600083018661318c565b61344e602083018561318c565b61345b6040830184612d1b565b949350505050565b6000606082019050613478600083018661318c565b613485602083018561318c565b613492604083018461318c565b949350505050565b60006020820190506134af600083018461319b565b92915050565b6000604051905081810181811067ffffffffffffffff821117156134d857600080fd5b8060405250919050565b600067ffffffffffffffff8211156134f957600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006135bd82613606565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b8381101561366a57808201518184015260208101905061364f565b83811115613679576000848401525b50505050565b6000819050919050565b6000819050919050565b61369c816135b2565b81146136a757600080fd5b50565b6136b3816135fc565b81146136be57600080fd5b50565b6136ca81613626565b81146136d557600080fd5b5056fea365627a7a723158208f52ee07630ffe523cc6ad3e15f437f973dcfa36729cd697f9b0fc4a145a48f06c6578706572696d656e74616cf564736f6c634300050b0040" + }, + "0000000000000000000000000000000000001001": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a7231582083fbdacb76f32b4112d0f7db9a596937925824798a0026ba0232322390b5263764736f6c634300050b0032" + }, + "0000000000000000000000000000000000001010": { + "balance": "0x204fcd4f31349d83b6e00000", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a4565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116aa565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611737565b005b348015610b2e57600080fd5b50610b37611754565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa82848861177a565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3790919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e636023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5790919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e406023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b76565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c733848461177a565b90505b92915050565b6040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6e565b611d44565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611e86605291396040516020018082805190602001908083835b602083106116f957805182526020820191506020810190506020830392506116d6565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173f6114dd565b61174857600080fd5b61175181611b76565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d602081101561182457600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b657600080fd5b505afa1580156118ca573d6000803e3d6000fd5b505050506040513d60208110156118e057600080fd5b810190808051906020019092919050505090506118fe868686611d8e565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0657600080fd5b505afa158015611a1a573d6000803e3d6000fd5b505050506040513d6020811015611a3057600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d6020811015611ae857600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4657600080fd5b600082840390508091505092915050565b600080828401905083811015611b6c57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bb057600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b60208310611cc05780518252602082019150602081019050602083039250611c9d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611dd4573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a723158208f81700133738d766ae3d68af591ad588b0125bd91449192179f460893f79f6b64736f6c634300050b0032" + }, + "C26880A0AF2EA0c7E8130e6EC47Af756465452E8": { + "balance": "0x3635c9adc5dea00000" + }, + "be188D6641E8b680743A4815dFA0f6208038960F": { + "balance": "0x3635c9adc5dea00000" + }, + "c275DC8bE39f50D12F66B6a63629C39dA5BAe5bd": { + "balance": "0x3635c9adc5dea00000" + }, + "F903ba9E006193c1527BfBe65fe2123704EA3F99": { + "balance": "0x3635c9adc5dea00000" + }, + "928Ed6A3e94437bbd316cCAD78479f1d163A6A8C": { + "balance": "0x3635c9adc5dea00000" + } + } + \ No newline at end of file diff --git a/internal/cli/server/chains/chain.go b/internal/cli/server/chains/chain.go new file mode 100644 index 0000000000..582ef64d21 --- /dev/null +++ b/internal/cli/server/chains/chain.go @@ -0,0 +1,84 @@ +package chains + +import ( + "encoding/json" + "errors" + "fmt" + "os" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/log" +) + +type Chain struct { + Hash common.Hash + Genesis *core.Genesis + Bootnodes []string + NetworkId uint64 + DNS []string +} + +var chains = map[string]*Chain{ + "mainnet": mainnetBor, + "mumbai": mumbaiTestnet, +} + +func GetChain(name string) (*Chain, error) { + var ( + chain *Chain + err error + ) + + if _, fileErr := os.Stat(name); fileErr == nil { + if chain, err = ImportFromFile(name); err != nil { + return nil, fmt.Errorf("error importing chain from file: %v", err) + } + + return chain, nil + } else if errors.Is(fileErr, os.ErrNotExist) { + var ok bool + if chain, ok = chains[name]; !ok { + return nil, fmt.Errorf("chain %s not found", name) + } + + return chain, nil + } else { + return nil, fileErr + } +} + +func ImportFromFile(filename string) (*Chain, error) { + data, err := os.ReadFile(filename) + if err != nil { + return nil, err + } + + return importChain(data) +} + +func importChain(content []byte) (*Chain, error) { + var chain *Chain + + if err := json.Unmarshal(content, &chain); err != nil { + return nil, err + } + + if chain.Genesis == nil { + log.Info("Try reading as legacy genesis") + + var genesis core.Genesis + if err := json.Unmarshal(content, &genesis); err != nil { + return nil, err + } + + if genesis.Config != nil { + chain.Genesis = &genesis + chain.NetworkId = genesis.Config.ChainID.Uint64() + } else { + return nil, fmt.Errorf("unable to parse chain config") + } + } + + return chain, nil +} diff --git a/internal/cli/server/chains/chain_test.go b/internal/cli/server/chains/chain_test.go new file mode 100644 index 0000000000..b372a3c4b9 --- /dev/null +++ b/internal/cli/server/chains/chain_test.go @@ -0,0 +1,54 @@ +package chains + +import ( + "testing" +) + +func TestChain_ImportFromFile(t *testing.T) { + t.Parallel() + + type args struct { + filename string + } + + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "ImportFromFile correct json file", + args: args{filename: "test_files/chain_test.json"}, + wantErr: false, + }, + { + name: "ImportFromFile correct legacy json file", + args: args{filename: "test_files/chain_legacy_test.json"}, + wantErr: false, + }, + { + name: "ImportFromFile wrong json file", + args: args{filename: "test_files/wrong_chain.json"}, + wantErr: true, + }, + { + name: "ImportFromFile nonexistent json file", + args: args{filename: "test_files/chain_test_nonexistent.json"}, + wantErr: true, + }, + } + + for _, tt := range tests { + tt := tt + + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + _, err := ImportFromFile(tt.args.filename) + if (err != nil) != tt.wantErr { + t.Errorf("ImportFromFile() error = %v, wantErr %v", err, tt.wantErr) + return + } + }) + } +} diff --git a/internal/cli/server/chains/developer.go b/internal/cli/server/chains/developer.go new file mode 100644 index 0000000000..40d65005f9 --- /dev/null +++ b/internal/cli/server/chains/developer.go @@ -0,0 +1,47 @@ +package chains + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" +) + +// GetDeveloperChain returns the developer mode configs. +func GetDeveloperChain(period uint64, gasLimitt uint64, faucet common.Address) *Chain { + // Override the default period to the user requested one + config := *params.AllCliqueProtocolChanges + config.Clique = ¶ms.CliqueConfig{ + Period: period, + Epoch: config.Clique.Epoch, + } + + // Assemble and return the chain having genesis with the + // precompiles and faucet pre-funded + return &Chain{ + Hash: common.Hash{}, + NetworkId: 1337, + Genesis: &core.Genesis{ + Config: &config, + ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...), + GasLimit: gasLimitt, + BaseFee: big.NewInt(params.InitialBaseFee), + Difficulty: big.NewInt(1), + Alloc: map[common.Address]core.GenesisAccount{ + common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover + common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256 + common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD + common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity + common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp + common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd + common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul + common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing + common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b + faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, + }, + }, + Bootnodes: []string{}, + } +} diff --git a/internal/cli/server/chains/mainnet.go b/internal/cli/server/chains/mainnet.go new file mode 100644 index 0000000000..324288b2b4 --- /dev/null +++ b/internal/cli/server/chains/mainnet.go @@ -0,0 +1,91 @@ +package chains + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/params" +) + +var mainnetBor = &Chain{ + Hash: common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b"), + NetworkId: 137, + Genesis: &core.Genesis{ + Config: ¶ms.ChainConfig{ + ChainID: big.NewInt(137), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(3395000), + MuirGlacierBlock: big.NewInt(3395000), + BerlinBlock: big.NewInt(14750000), + LondonBlock: big.NewInt(23850000), + Bor: ¶ms.BorConfig{ + JaipurBlock: big.NewInt(23850000), + DelhiBlock: big.NewInt(38189056), + ParallelUniverseBlock: big.NewInt(0), + IndoreBlock: big.NewInt(44934656), + StateSyncConfirmationDelay: map[string]uint64{ + "44934656": 128, + }, + Period: map[string]uint64{ + "0": 2, + }, + ProducerDelay: map[string]uint64{ + "0": 6, + "38189056": 4, + }, + Sprint: map[string]uint64{ + "0": 64, + "38189056": 16, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + OverrideStateSyncRecords: map[string]int{ + "14949120": 8, + "14949184": 0, + "14953472": 0, + "14953536": 5, + "14953600": 0, + "14953664": 0, + "14953728": 0, + "14953792": 0, + "14953856": 0, + }, + BurntContract: map[string]string{ + "23850000": "0x70bca57f4579f58670ab2d18ef16e02c17553c38", + }, + BlockAlloc: map[string]interface{}{ + // write as interface since that is how it is decoded in genesis + "22156660": map[string]interface{}{ + "0000000000000000000000000000000000001010": map[string]interface{}{ + "balance": "0x0", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611546565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154c565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d9565b005b348015610b2e57600080fd5b50610b376115f6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161c90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da76023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163c90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d846023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165b565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600181526020017f890000000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611753565b90505b92915050565b6040518060800160405280605b8152602001611e1c605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b10565b611be6565b9050949350505050565b608981565b60015481565b604051806080016040528060528152602001611dca605291396040516020018082805190602001908083835b6020831061159b5780518252602082019150602081019050602083039250611578565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e1611381565b6115ea57600080fd5b6115f38161165b565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162b57600080fd5b600082840390508091505092915050565b60008082840190508381101561165157600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d357600080fd5b505afa1580156117e7573d6000803e3d6000fd5b505050506040513d60208110156117fd57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561188f57600080fd5b505afa1580156118a3573d6000803e3d6000fd5b505050506040513d60208110156118b957600080fd5b810190808051906020019092919050505090506118d7868686611c30565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119df57600080fd5b505afa1580156119f3573d6000803e3d6000fd5b505050506040513d6020811015611a0957600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9757600080fd5b505afa158015611aab573d6000803e3d6000fd5b505050506040513d6020811015611ac157600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1c605b91396040516020018082805190602001908083835b60208310611b625780518252602082019150602081019050602083039250611b3f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d18573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820a4a6f71a98ac3fc613c3a8f1e2e11b9eb9b6b39f125f7d9508916c2b8fb02c7164736f6c63430005100032", + }, + }, + }, + }, + }, + Nonce: 0, + Timestamp: 1590824836, + GasLimit: 10000000, + Difficulty: big.NewInt(1), + Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), + Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), + Alloc: readPrealloc("allocs/mainnet.json"), + }, + Bootnodes: []string{ + "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", + "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303", + }, +} diff --git a/internal/cli/server/chains/mumbai.go b/internal/cli/server/chains/mumbai.go new file mode 100644 index 0000000000..91fe0c440c --- /dev/null +++ b/internal/cli/server/chains/mumbai.go @@ -0,0 +1,84 @@ +package chains + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/params" +) + +var mumbaiTestnet = &Chain{ + Hash: common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7"), + NetworkId: 80001, + Genesis: &core.Genesis{ + Config: ¶ms.ChainConfig{ + ChainID: big.NewInt(80001), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(2722000), + MuirGlacierBlock: big.NewInt(2722000), + BerlinBlock: big.NewInt(13996000), + LondonBlock: big.NewInt(22640000), + Bor: ¶ms.BorConfig{ + JaipurBlock: big.NewInt(22770000), + DelhiBlock: big.NewInt(29638656), + ParallelUniverseBlock: big.NewInt(0), + IndoreBlock: big.NewInt(37075456), + StateSyncConfirmationDelay: map[string]uint64{ + "37075456": 128, + }, + Period: map[string]uint64{ + "0": 2, + "25275000": 5, + "29638656": 2, + }, + ProducerDelay: map[string]uint64{ + "0": 6, + "29638656": 4, + }, + Sprint: map[string]uint64{ + "0": 64, + "29638656": 16, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + "25275000": 5, + "29638656": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + BurntContract: map[string]string{ + "22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38", + }, + BlockAlloc: map[string]interface{}{ + // write as interface since that is how it is decoded in genesis + "22244000": map[string]interface{}{ + "0000000000000000000000000000000000001010": map[string]interface{}{ + "balance": "0x0", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611548565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154e565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115db565b005b348015610b2e57600080fd5b50610b376115f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161e90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da96023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163e90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d866023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165d565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611755565b90505b92915050565b6040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b12565b611be8565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611dcc605291396040516020018082805190602001908083835b6020831061159d578051825260208201915060208101905060208303925061157a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e3611381565b6115ec57600080fd5b6115f58161165d565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162d57600080fd5b600082840390508091505092915050565b60008082840190508381101561165357600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d557600080fd5b505afa1580156117e9573d6000803e3d6000fd5b505050506040513d60208110156117ff57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d60208110156118bb57600080fd5b810190808051906020019092919050505090506118d9868686611c32565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119e157600080fd5b505afa1580156119f5573d6000803e3d6000fd5b505050506040513d6020811015611a0b57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9957600080fd5b505afa158015611aad573d6000803e3d6000fd5b505050506040513d6020811015611ac357600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b60208310611b645780518252602082019150602081019050602083039250611b41565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d1a573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820ccd6c2a9c259832bbb367986ee06cd87af23022681b0cb22311a864b701d939564736f6c63430005100032", + }, + }, + }, + }, + }, + Nonce: 0, + Timestamp: 1558348305, + GasLimit: 10000000, + Difficulty: big.NewInt(1), + Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), + Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), + Alloc: readPrealloc("allocs/mumbai.json"), + }, + Bootnodes: []string{ + "enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303", + "enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303", + }, +} diff --git a/internal/cli/server/chains/test_files/chain_legacy_test.json b/internal/cli/server/chains/test_files/chain_legacy_test.json new file mode 100644 index 0000000000..a9f6a0923a --- /dev/null +++ b/internal/cli/server/chains/test_files/chain_legacy_test.json @@ -0,0 +1,99 @@ +{ + "config": { + "chainId": 80001, + "homesteadBlock": 0, + "daoForkSupport": true, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 2722000, + "muirGlacierBlock": 2722000, + "berlinBlock": 13996000, + "londonBlock": 13996000, + "bor": { + "period": { + "0": 2, + "25275000": 5, + "29638656": 2 + }, + "producerDelay": { + "0": 6, + "29638656": 4 + }, + "sprint": { + "0": 64, + "29638656": 16 + }, + "backupMultiplier": { + "0": 2, + "25275000": 5, + "29638656": 2 + }, + "validatorContract": "0x0000000000000000000000000000000000001000", + "stateReceiverContract": "0x0000000000000000000000000000000000001001", + "overrideStateSyncRecords": null, + "blockAlloc": { + "22244000": { + "0000000000000000000000000000000000001010": { + "balance": "0x0", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611548565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154e565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115db565b005b348015610b2e57600080fd5b50610b376115f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161e90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da96023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163e90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d866023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165d565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611755565b90505b92915050565b6040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b12565b611be8565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611dcc605291396040516020018082805190602001908083835b6020831061159d578051825260208201915060208101905060208303925061157a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e3611381565b6115ec57600080fd5b6115f58161165d565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162d57600080fd5b600082840390508091505092915050565b60008082840190508381101561165357600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d557600080fd5b505afa1580156117e9573d6000803e3d6000fd5b505050506040513d60208110156117ff57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d60208110156118bb57600080fd5b810190808051906020019092919050505090506118d9868686611c32565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119e157600080fd5b505afa1580156119f5573d6000803e3d6000fd5b505050506040513d6020811015611a0b57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9957600080fd5b505afa158015611aad573d6000803e3d6000fd5b505050506040513d6020811015611ac357600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b60208310611b645780518252602082019150602081019050602083039250611b41565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d1a573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820ccd6c2a9c259832bbb367986ee06cd87af23022681b0cb22311a864b701d939564736f6c63430005100032" + } + } + }, + "burntContract": { + "22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" + }, + "jaipurBlock": 22770000, + "delhiBlock": 29638656, + "parallelUniverseBlock": 0, + "indoreBlock": 37075456, + "stateSyncConfirmationDelay": { + "37075456": 128 + } + } + }, + "nonce": "0x0", + "timestamp": "0x5ce28211", + "extraData": "0x", + "gasLimit": "0x989680", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "0000000000000000000000000000000000001000": { + "code": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a9190810190612b24565b610706565b60405161021e93929190613463565b60405180910390f35b610241600480360361023c9190810190612b24565b61075d565b60405161024f929190613284565b60405180910390f35b610272600480360361026d9190810190612b4d565b610939565b60405161027f91906132bb565b60405180910390f35b6102a2600480360361029d9190810190612c2c565b610a91565b005b6102be60048036036102b99190810190612b4d565b61112a565b6040516102cb91906132bb565b60405180910390f35b6102dc611281565b6040516102e99190613411565b60405180910390f35b61030c60048036036103079190810190612a81565b611286565b60405161031991906132d6565b60405180910390f35b61033c60048036036103379190810190612b24565b611307565b6040516103499190613411565b60405180910390f35b61035a611437565b6040516103679190613269565b60405180910390f35b61038a60048036036103859190810190612abd565b61144f565b60405161039791906132bb565b60405180910390f35b6103a861151a565b6040516103b591906132d6565b60405180910390f35b6103d860048036036103d39190810190612b89565b611531565b6040516103e59190613411565b60405180910390f35b61040860048036036104039190810190612b4d565b611619565b60405161041591906133f6565b60405180910390f35b610426611781565b6040516104339190613411565b60405180910390f35b61045660048036036104519190810190612a06565b611791565b60405161046391906132bb565b60405180910390f35b61048660048036036104819190810190612a2f565b6117ab565b60405161049391906132d6565b60405180910390f35b6104a4611829565b6040516104b393929190613463565b60405180910390f35b6104c461189d565b6040516104d2929190613284565b60405180910390f35b6104e3611b6e565b6040516104f09190613411565b60405180910390f35b610513600480360361050e9190810190612bf0565b611b73565b6040516105229392919061342c565b60405180910390f35b61054560048036036105409190810190612a06565b611bd7565b60405161055291906132bb565b60405180910390f35b610563611bf1565b60405161057091906132d6565b60405180910390f35b610593600480360361058e9190810190612b24565b611c08565b6040516105a09190613411565b60405180910390f35b6105b1611d39565b6040516105be91906132d6565b60405180910390f35b6105cf611d50565b6040516105de93929190613463565b60405180910390f35b61060160048036036105fc9190810190612b24565b611db1565b60405161060e9190613411565b60405180910390f35b61061f611eb1565b60405161062d929190613284565b60405180910390f35b610650600480360361064b9190810190612b24565b611ec5565b60405161065d9190613411565b60405180910390f35b61066e611ee6565b60405161067b919061349a565b60405180910390f35b61069e60048036036106999190810190612bf0565b611eeb565b6040516106ad9392919061342c565b60405180910390f35b6106be611f4f565b6040516106cb9190613411565b60405180910390f35b6106ee60048036036106e99190810190612b24565b611f61565b6040516106fd93929190613463565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611db1565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a906133d6565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b30611f8b565b5b610b456001826122ac90919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d90613356565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf906133b6565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1190613396565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a90613336565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc390613376565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d669190612800565b506000600160008a815260200190815260200160002081610d879190612800565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b60200260200101516122f9565b90506000808c81526020019081526020016000208054809190600101610e349190612800565b506040518060600160405280610e5d83600081518110610e5057fe5b60200260200101516123d6565b8152602001610e7f83600181518110610e7257fe5b60200260200101516123d6565b8152602001610ea183600281518110610e9457fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b60200260200101516122f9565b9050600160008d81526020019081526020016000208054809190600101610fff9190612800565b5060405180606001604052806110288360008151811061101b57fe5b60200260200101516123d6565b815260200161104a8360018151811061103d57fe5b60200260200101516123d6565b815260200161106c8360028151811061105f57fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a3939291906131d6565b6040516020818303038152906040526040516112bf9190613213565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff9190810190612a58565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b602002602001015160200151836122ac90919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b60405161152690613254565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff16604161246a565b9050600061158582896124f690919063ffffffff16565b905061158f612832565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb8160200151876122ac90919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b611621612832565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611db1565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c69291906131aa565b6040516020818303038152906040526040516117e29190613213565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506118229190810190612a58565b9050919050565b60008060008061184a600161183c611781565b6122ac90919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060056040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b50905073c26880a0af2ea0c7e8130e6ec47af756465452e8816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073be188d6641e8b680743a4815dfa0f6208038960f8160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073c275dc8be39f50d12f66b6a63629c39da5bae5bd816002815181106119af57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073f903ba9e006193c1527bfbe65fe2123704ea3f9981600381518110611a0b57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073928ed6a3e94437bbd316ccad78479f1d163a6a8c81600481518110611a6757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060606005604051908082528060200260200182016040528015611ad35781602001602082028038833980820191505090505b50905061271081600081518110611ae657fe5b60200260200101818152505061271081600181518110611b0257fe5b60200260200101818152505061271081600281518110611b1e57fe5b60200260200101818152505061271081600381518110611b3a57fe5b60200260200101818152505061271081600481518110611b5657fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611b8c57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611bea611be4611781565b83610939565b9050919050565b604051611bfd9061322a565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611cdb578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611c3f565b505050509050600080905060008090505b8251811015611d2e57611d1f838281518110611d0457fe5b602002602001015160200151836122ac90919063ffffffff16565b91508080600101915050611cec565b508092505050919050565b604051611d459061323f565b604051809103902081565b600080600080611d5e611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611e7157611dce612869565b6002600060036001850381548110611de257fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611e3f57506000816040015114155b8015611e4f575080604001518411155b15611e6257806000015192505050611eac565b50808060019003915050611dbd565b5060006003805490501115611ea757600360016003805490500381548110611e9557fe5b90600052602060002001549050611eac565b600090505b919050565b606080611ebd4361075d565b915091509091565b60038181548110611ed257fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611f0457fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060404381611f5b57fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b606080611f9661189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff81525060026000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600381908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008381526020019081526020016000208161203f9190612800565b50600060016000838152602001908152602001600020816120609190612800565b5060008090505b83518110156121825760008083815260200190815260200160002080548091906001016120949190612800565b5060405180606001604052808281526020018483815181106120b257fe5b602002602001015181526020018583815181106120cb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16815250600080848152602001908152602001600020828154811061210957fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612067565b5060008090505b83518110156122a6576001600083815260200190815260200160002080548091906001016121b79190612800565b5060405180606001604052808281526020018483815181106121d557fe5b602002602001015181526020018583815181106121ee57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1681525060016000848152602001908152602001600020828154811061222d57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612189565b50505050565b6000808284019050838110156122c157600080fd5b8091505092915050565b6122d361288a565b600060208301905060405180604001604052808451815260200182815250915050919050565b606061230482612600565b61230d57600080fd5b60006123188361264e565b905060608160405190808252806020026020018201604052801561235657816020015b6123436128a4565b81526020019060019003908161233b5790505b509050600061236885602001516126bf565b8560200151019050600080600090505b848110156123c95761238983612748565b91506040518060400160405280838152602001848152508482815181106123ac57fe5b602002602001018190525081830192508080600101915050612378565b5082945050505050919050565b60008082600001511180156123f057506021826000015111155b6123f957600080fd5b600061240883602001516126bf565b9050600081846000015103905060008083866020015101905080519150602083101561243b57826020036101000a820491505b81945050505050919050565b6000601582600001511461245a57600080fd5b612463826123d6565b9050919050565b60608183018451101561247c57600080fd5b6060821560008114612499576040519150602082016040526124ea565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156124d757805183526020830192506020810190506124ba565b50868552601f19601f8301166040525050505b50809150509392505050565b600080600080604185511461251157600093505050506125fa565b602085015192506040850151915060ff6041860151169050601b8160ff16101561253c57601b810190505b601b8160ff16141580156125545750601c8160ff1614155b1561256557600093505050506125fa565b60006001878386866040516000815260200160405260405161258a94939291906132f1565b6020604051602081039080840390855afa1580156125ac573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125f257600080fd5b809450505050505b92915050565b600080826000015114156126175760009050612649565b60008083602001519050805160001a915060c060ff168260ff16101561264257600092505050612649565b6001925050505b919050565b6000808260000151141561266557600090506126ba565b6000809050600061267984602001516126bf565b84602001510190506000846000015185602001510190505b808210156126b3576126a282612748565b820191508280600101935050612691565b8293505050505b919050565b600080825160001a9050608060ff168110156126df576000915050612743565b60b860ff16811080612704575060c060ff168110158015612703575060f860ff1681105b5b15612713576001915050612743565b60c060ff168110156127335760018060b80360ff16820301915050612743565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561276957600191506127f6565b60b860ff16811015612786576001608060ff1682030191506127f5565b60c060ff168110156127b65760b78103600185019450806020036101000a855104600182018101935050506127f4565b60f860ff168110156127d357600160c060ff1682030191506127f3565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b81548183558181111561282d5760030281600302836000526020600020918201910161282c91906128be565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b61291191905b8082111561290d5760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506003016128c4565b5090565b90565b60008135905061292381613693565b92915050565b600081359050612938816136aa565b92915050565b60008151905061294d816136aa565b92915050565b60008083601f84011261296557600080fd5b8235905067ffffffffffffffff81111561297e57600080fd5b60208301915083600182028301111561299657600080fd5b9250929050565b600082601f8301126129ae57600080fd5b81356129c16129bc826134e2565b6134b5565b915080825260208301602083018583830111156129dd57600080fd5b6129e883828461363d565b50505092915050565b600081359050612a00816136c1565b92915050565b600060208284031215612a1857600080fd5b6000612a2684828501612914565b91505092915050565b600060208284031215612a4157600080fd5b6000612a4f84828501612929565b91505092915050565b600060208284031215612a6a57600080fd5b6000612a788482850161293e565b91505092915050565b60008060408385031215612a9457600080fd5b6000612aa285828601612929565b9250506020612ab385828601612929565b9150509250929050565b600080600060608486031215612ad257600080fd5b6000612ae086828701612929565b9350506020612af186828701612929565b925050604084013567ffffffffffffffff811115612b0e57600080fd5b612b1a8682870161299d565b9150509250925092565b600060208284031215612b3657600080fd5b6000612b44848285016129f1565b91505092915050565b60008060408385031215612b6057600080fd5b6000612b6e858286016129f1565b9250506020612b7f85828601612914565b9150509250929050565b600080600060608486031215612b9e57600080fd5b6000612bac868287016129f1565b9350506020612bbd86828701612929565b925050604084013567ffffffffffffffff811115612bda57600080fd5b612be68682870161299d565b9150509250925092565b60008060408385031215612c0357600080fd5b6000612c11858286016129f1565b9250506020612c22858286016129f1565b9150509250929050565b600080600080600080600060a0888a031215612c4757600080fd5b6000612c558a828b016129f1565b9750506020612c668a828b016129f1565b9650506040612c778a828b016129f1565b955050606088013567ffffffffffffffff811115612c9457600080fd5b612ca08a828b01612953565b9450945050608088013567ffffffffffffffff811115612cbf57600080fd5b612ccb8a828b01612953565b925092505092959891949750929550565b6000612ce88383612d0c565b60208301905092915050565b6000612d00838361317d565b60208301905092915050565b612d15816135b2565b82525050565b612d24816135b2565b82525050565b6000612d358261352e565b612d3f8185613569565b9350612d4a8361350e565b8060005b83811015612d7b578151612d628882612cdc565b9750612d6d8361354f565b925050600181019050612d4e565b5085935050505092915050565b6000612d9382613539565b612d9d818561357a565b9350612da88361351e565b8060005b83811015612dd9578151612dc08882612cf4565b9750612dcb8361355c565b925050600181019050612dac565b5085935050505092915050565b612def816135c4565b82525050565b612e06612e01826135d0565b61367f565b82525050565b612e15816135fc565b82525050565b612e2c612e27826135fc565b613689565b82525050565b6000612e3d82613544565b612e47818561358b565b9350612e5781856020860161364c565b80840191505092915050565b6000612e706004836135a7565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612eb0602d83613596565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000612f16600f83613596565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000612f56601383613596565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b6000612f96604583613596565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000613022602a83613596565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b6000613088601283613596565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b60006130c86005836135a7565b91507f38303030310000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000613108600e836135a7565b91507f6865696d64616c6c2d38303030310000000000000000000000000000000000006000830152600e82019050919050565b606082016000820151613151600085018261317d565b506020820151613164602085018261317d565b5060408201516131776040850182612d0c565b50505050565b61318681613626565b82525050565b61319581613626565b82525050565b6131a481613630565b82525050565b60006131b68285612df5565b6001820191506131c68284612e1b565b6020820191508190509392505050565b60006131e28286612df5565b6001820191506131f28285612e1b565b6020820191506132028284612e1b565b602082019150819050949350505050565b600061321f8284612e32565b915081905092915050565b600061323582612e63565b9150819050919050565b600061324a826130bb565b9150819050919050565b600061325f826130fb565b9150819050919050565b600060208201905061327e6000830184612d1b565b92915050565b6000604082019050818103600083015261329e8185612d2a565b905081810360208301526132b28184612d88565b90509392505050565b60006020820190506132d06000830184612de6565b92915050565b60006020820190506132eb6000830184612e0c565b92915050565b60006080820190506133066000830187612e0c565b613313602083018661319b565b6133206040830185612e0c565b61332d6060830184612e0c565b95945050505050565b6000602082019050818103600083015261334f81612ea3565b9050919050565b6000602082019050818103600083015261336f81612f09565b9050919050565b6000602082019050818103600083015261338f81612f49565b9050919050565b600060208201905081810360008301526133af81612f89565b9050919050565b600060208201905081810360008301526133cf81613015565b9050919050565b600060208201905081810360008301526133ef8161307b565b9050919050565b600060608201905061340b600083018461313b565b92915050565b6000602082019050613426600083018461318c565b92915050565b6000606082019050613441600083018661318c565b61344e602083018561318c565b61345b6040830184612d1b565b949350505050565b6000606082019050613478600083018661318c565b613485602083018561318c565b613492604083018461318c565b949350505050565b60006020820190506134af600083018461319b565b92915050565b6000604051905081810181811067ffffffffffffffff821117156134d857600080fd5b8060405250919050565b600067ffffffffffffffff8211156134f957600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006135bd82613606565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b8381101561366a57808201518184015260208101905061364f565b83811115613679576000848401525b50505050565b6000819050919050565b6000819050919050565b61369c816135b2565b81146136a757600080fd5b50565b6136b3816135fc565b81146136be57600080fd5b50565b6136ca81613626565b81146136d557600080fd5b5056fea365627a7a723158208f52ee07630ffe523cc6ad3e15f437f973dcfa36729cd697f9b0fc4a145a48f06c6578706572696d656e74616cf564736f6c634300050b0040", + "balance": "0x0" + }, + "0000000000000000000000000000000000001001": { + "code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a7231582083fbdacb76f32b4112d0f7db9a596937925824798a0026ba0232322390b5263764736f6c634300050b0032", + "balance": "0x0" + }, + "0000000000000000000000000000000000001010": { + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a4565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116aa565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611737565b005b348015610b2e57600080fd5b50610b37611754565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa82848861177a565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3790919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e636023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5790919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e406023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b76565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c733848461177a565b90505b92915050565b6040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6e565b611d44565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611e86605291396040516020018082805190602001908083835b602083106116f957805182526020820191506020810190506020830392506116d6565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173f6114dd565b61174857600080fd5b61175181611b76565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d602081101561182457600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b657600080fd5b505afa1580156118ca573d6000803e3d6000fd5b505050506040513d60208110156118e057600080fd5b810190808051906020019092919050505090506118fe868686611d8e565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0657600080fd5b505afa158015611a1a573d6000803e3d6000fd5b505050506040513d6020811015611a3057600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d6020811015611ae857600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4657600080fd5b600082840390508091505092915050565b600080828401905083811015611b6c57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bb057600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b60208310611cc05780518252602082019150602081019050602083039250611c9d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611dd4573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a723158208f81700133738d766ae3d68af591ad588b0125bd91449192179f460893f79f6b64736f6c634300050b0032", + "balance": "0x204fcd4f31349d83b6e00000" + }, + "928ed6a3e94437bbd316ccad78479f1d163a6a8c": { + "balance": "0x3635c9adc5dea00000" + }, + "be188d6641e8b680743a4815dfa0f6208038960f": { + "balance": "0x3635c9adc5dea00000" + }, + "c26880a0af2ea0c7e8130e6ec47af756465452e8": { + "balance": "0x3635c9adc5dea00000" + }, + "c275dc8be39f50d12f66b6a63629c39da5bae5bd": { + "balance": "0x3635c9adc5dea00000" + }, + "f903ba9e006193c1527bfbe65fe2123704ea3f99": { + "balance": "0x3635c9adc5dea00000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas": null +} diff --git a/internal/cli/server/chains/test_files/chain_test.json b/internal/cli/server/chains/test_files/chain_test.json new file mode 100644 index 0000000000..e367547b6a --- /dev/null +++ b/internal/cli/server/chains/test_files/chain_test.json @@ -0,0 +1,108 @@ +{ + "Hash":"0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7", + "Genesis":{ + "config":{ + "chainId":80001, + "homesteadBlock":0, + "daoForkSupport":true, + "eip150Block":0, + "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block":0, + "eip158Block":0, + "byzantiumBlock":0, + "constantinopleBlock":0, + "petersburgBlock":0, + "istanbulBlock":2722000, + "muirGlacierBlock":2722000, + "berlinBlock":13996000, + "londonBlock":13996000, + "bor":{ + "period":{ + "0":2, + "25275000": 5, + "29638656": 2 + }, + "producerDelay":{ + "0": 6, + "29638656": 4 + }, + "sprint":{ + "0": 64, + "29638656": 16 + }, + "backupMultiplier":{ + "0": 2, + "25275000": 5, + "29638656": 2 + }, + "validatorContract":"0x0000000000000000000000000000000000001000", + "stateReceiverContract":"0x0000000000000000000000000000000000001001", + "overrideStateSyncRecords":null, + "blockAlloc":{ + "22244000":{ + "0000000000000000000000000000000000001010":{ + "balance":"0x0", + "code":"0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611548565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154e565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115db565b005b348015610b2e57600080fd5b50610b376115f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161e90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da96023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163e90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d866023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165d565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611755565b90505b92915050565b6040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b12565b611be8565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611dcc605291396040516020018082805190602001908083835b6020831061159d578051825260208201915060208101905060208303925061157a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e3611381565b6115ec57600080fd5b6115f58161165d565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162d57600080fd5b600082840390508091505092915050565b60008082840190508381101561165357600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d557600080fd5b505afa1580156117e9573d6000803e3d6000fd5b505050506040513d60208110156117ff57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d60208110156118bb57600080fd5b810190808051906020019092919050505090506118d9868686611c32565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119e157600080fd5b505afa1580156119f5573d6000803e3d6000fd5b505050506040513d6020811015611a0b57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9957600080fd5b505afa158015611aad573d6000803e3d6000fd5b505050506040513d6020811015611ac357600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b60208310611b645780518252602082019150602081019050602083039250611b41565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d1a573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820ccd6c2a9c259832bbb367986ee06cd87af23022681b0cb22311a864b701d939564736f6c63430005100032" + } + } + }, + "burntContract":{ + "22640000":"0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" + }, + "jaipurBlock":22770000, + "delhiBlock": 29638656, + "parallelUniverseBlock": 0, + "indoreBlock": 37075456, + "stateSyncConfirmationDelay": { + "37075456": 128 + } + } + }, + "nonce":"0x0", + "timestamp":"0x5ce28211", + "extraData":"0x", + "gasLimit":"0x989680", + "difficulty":"0x1", + "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase":"0x0000000000000000000000000000000000000000", + "alloc":{ + "0000000000000000000000000000000000001000":{ + "code":"0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a9190810190612b24565b610706565b60405161021e93929190613463565b60405180910390f35b610241600480360361023c9190810190612b24565b61075d565b60405161024f929190613284565b60405180910390f35b610272600480360361026d9190810190612b4d565b610939565b60405161027f91906132bb565b60405180910390f35b6102a2600480360361029d9190810190612c2c565b610a91565b005b6102be60048036036102b99190810190612b4d565b61112a565b6040516102cb91906132bb565b60405180910390f35b6102dc611281565b6040516102e99190613411565b60405180910390f35b61030c60048036036103079190810190612a81565b611286565b60405161031991906132d6565b60405180910390f35b61033c60048036036103379190810190612b24565b611307565b6040516103499190613411565b60405180910390f35b61035a611437565b6040516103679190613269565b60405180910390f35b61038a60048036036103859190810190612abd565b61144f565b60405161039791906132bb565b60405180910390f35b6103a861151a565b6040516103b591906132d6565b60405180910390f35b6103d860048036036103d39190810190612b89565b611531565b6040516103e59190613411565b60405180910390f35b61040860048036036104039190810190612b4d565b611619565b60405161041591906133f6565b60405180910390f35b610426611781565b6040516104339190613411565b60405180910390f35b61045660048036036104519190810190612a06565b611791565b60405161046391906132bb565b60405180910390f35b61048660048036036104819190810190612a2f565b6117ab565b60405161049391906132d6565b60405180910390f35b6104a4611829565b6040516104b393929190613463565b60405180910390f35b6104c461189d565b6040516104d2929190613284565b60405180910390f35b6104e3611b6e565b6040516104f09190613411565b60405180910390f35b610513600480360361050e9190810190612bf0565b611b73565b6040516105229392919061342c565b60405180910390f35b61054560048036036105409190810190612a06565b611bd7565b60405161055291906132bb565b60405180910390f35b610563611bf1565b60405161057091906132d6565b60405180910390f35b610593600480360361058e9190810190612b24565b611c08565b6040516105a09190613411565b60405180910390f35b6105b1611d39565b6040516105be91906132d6565b60405180910390f35b6105cf611d50565b6040516105de93929190613463565b60405180910390f35b61060160048036036105fc9190810190612b24565b611db1565b60405161060e9190613411565b60405180910390f35b61061f611eb1565b60405161062d929190613284565b60405180910390f35b610650600480360361064b9190810190612b24565b611ec5565b60405161065d9190613411565b60405180910390f35b61066e611ee6565b60405161067b919061349a565b60405180910390f35b61069e60048036036106999190810190612bf0565b611eeb565b6040516106ad9392919061342c565b60405180910390f35b6106be611f4f565b6040516106cb9190613411565b60405180910390f35b6106ee60048036036106e99190810190612b24565b611f61565b6040516106fd93929190613463565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611db1565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a906133d6565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b30611f8b565b5b610b456001826122ac90919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d90613356565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf906133b6565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1190613396565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a90613336565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc390613376565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d669190612800565b506000600160008a815260200190815260200160002081610d879190612800565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b60200260200101516122f9565b90506000808c81526020019081526020016000208054809190600101610e349190612800565b506040518060600160405280610e5d83600081518110610e5057fe5b60200260200101516123d6565b8152602001610e7f83600181518110610e7257fe5b60200260200101516123d6565b8152602001610ea183600281518110610e9457fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506122cb565b6122f9565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b60200260200101516122f9565b9050600160008d81526020019081526020016000208054809190600101610fff9190612800565b5060405180606001604052806110288360008151811061101b57fe5b60200260200101516123d6565b815260200161104a8360018151811061103d57fe5b60200260200101516123d6565b815260200161106c8360028151811061105f57fe5b6020026020010151612447565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a3939291906131d6565b6040516020818303038152906040526040516112bf9190613213565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff9190810190612a58565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b602002602001015160200151836122ac90919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b60405161152690613254565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff16604161246a565b9050600061158582896124f690919063ffffffff16565b905061158f612832565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb8160200151876122ac90919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b611621612832565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611db1565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c69291906131aa565b6040516020818303038152906040526040516117e29190613213565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506118229190810190612a58565b9050919050565b60008060008061184a600161183c611781565b6122ac90919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060056040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b50905073c26880a0af2ea0c7e8130e6ec47af756465452e8816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073be188d6641e8b680743a4815dfa0f6208038960f8160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073c275dc8be39f50d12f66b6a63629c39da5bae5bd816002815181106119af57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073f903ba9e006193c1527bfbe65fe2123704ea3f9981600381518110611a0b57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073928ed6a3e94437bbd316ccad78479f1d163a6a8c81600481518110611a6757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060606005604051908082528060200260200182016040528015611ad35781602001602082028038833980820191505090505b50905061271081600081518110611ae657fe5b60200260200101818152505061271081600181518110611b0257fe5b60200260200101818152505061271081600281518110611b1e57fe5b60200260200101818152505061271081600381518110611b3a57fe5b60200260200101818152505061271081600481518110611b5657fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611b8c57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611bea611be4611781565b83610939565b9050919050565b604051611bfd9061322a565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611cdb578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611c3f565b505050509050600080905060008090505b8251811015611d2e57611d1f838281518110611d0457fe5b602002602001015160200151836122ac90919063ffffffff16565b91508080600101915050611cec565b508092505050919050565b604051611d459061323f565b604051809103902081565b600080600080611d5e611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611e7157611dce612869565b6002600060036001850381548110611de257fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611e3f57506000816040015114155b8015611e4f575080604001518411155b15611e6257806000015192505050611eac565b50808060019003915050611dbd565b5060006003805490501115611ea757600360016003805490500381548110611e9557fe5b90600052602060002001549050611eac565b600090505b919050565b606080611ebd4361075d565b915091509091565b60038181548110611ed257fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611f0457fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060404381611f5b57fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b606080611f9661189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff81525060026000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600381908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008381526020019081526020016000208161203f9190612800565b50600060016000838152602001908152602001600020816120609190612800565b5060008090505b83518110156121825760008083815260200190815260200160002080548091906001016120949190612800565b5060405180606001604052808281526020018483815181106120b257fe5b602002602001015181526020018583815181106120cb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16815250600080848152602001908152602001600020828154811061210957fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612067565b5060008090505b83518110156122a6576001600083815260200190815260200160002080548091906001016121b79190612800565b5060405180606001604052808281526020018483815181106121d557fe5b602002602001015181526020018583815181106121ee57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1681525060016000848152602001908152602001600020828154811061222d57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050612189565b50505050565b6000808284019050838110156122c157600080fd5b8091505092915050565b6122d361288a565b600060208301905060405180604001604052808451815260200182815250915050919050565b606061230482612600565b61230d57600080fd5b60006123188361264e565b905060608160405190808252806020026020018201604052801561235657816020015b6123436128a4565b81526020019060019003908161233b5790505b509050600061236885602001516126bf565b8560200151019050600080600090505b848110156123c95761238983612748565b91506040518060400160405280838152602001848152508482815181106123ac57fe5b602002602001018190525081830192508080600101915050612378565b5082945050505050919050565b60008082600001511180156123f057506021826000015111155b6123f957600080fd5b600061240883602001516126bf565b9050600081846000015103905060008083866020015101905080519150602083101561243b57826020036101000a820491505b81945050505050919050565b6000601582600001511461245a57600080fd5b612463826123d6565b9050919050565b60608183018451101561247c57600080fd5b6060821560008114612499576040519150602082016040526124ea565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156124d757805183526020830192506020810190506124ba565b50868552601f19601f8301166040525050505b50809150509392505050565b600080600080604185511461251157600093505050506125fa565b602085015192506040850151915060ff6041860151169050601b8160ff16101561253c57601b810190505b601b8160ff16141580156125545750601c8160ff1614155b1561256557600093505050506125fa565b60006001878386866040516000815260200160405260405161258a94939291906132f1565b6020604051602081039080840390855afa1580156125ac573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125f257600080fd5b809450505050505b92915050565b600080826000015114156126175760009050612649565b60008083602001519050805160001a915060c060ff168260ff16101561264257600092505050612649565b6001925050505b919050565b6000808260000151141561266557600090506126ba565b6000809050600061267984602001516126bf565b84602001510190506000846000015185602001510190505b808210156126b3576126a282612748565b820191508280600101935050612691565b8293505050505b919050565b600080825160001a9050608060ff168110156126df576000915050612743565b60b860ff16811080612704575060c060ff168110158015612703575060f860ff1681105b5b15612713576001915050612743565b60c060ff168110156127335760018060b80360ff16820301915050612743565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561276957600191506127f6565b60b860ff16811015612786576001608060ff1682030191506127f5565b60c060ff168110156127b65760b78103600185019450806020036101000a855104600182018101935050506127f4565b60f860ff168110156127d357600160c060ff1682030191506127f3565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b81548183558181111561282d5760030281600302836000526020600020918201910161282c91906128be565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b61291191905b8082111561290d5760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506003016128c4565b5090565b90565b60008135905061292381613693565b92915050565b600081359050612938816136aa565b92915050565b60008151905061294d816136aa565b92915050565b60008083601f84011261296557600080fd5b8235905067ffffffffffffffff81111561297e57600080fd5b60208301915083600182028301111561299657600080fd5b9250929050565b600082601f8301126129ae57600080fd5b81356129c16129bc826134e2565b6134b5565b915080825260208301602083018583830111156129dd57600080fd5b6129e883828461363d565b50505092915050565b600081359050612a00816136c1565b92915050565b600060208284031215612a1857600080fd5b6000612a2684828501612914565b91505092915050565b600060208284031215612a4157600080fd5b6000612a4f84828501612929565b91505092915050565b600060208284031215612a6a57600080fd5b6000612a788482850161293e565b91505092915050565b60008060408385031215612a9457600080fd5b6000612aa285828601612929565b9250506020612ab385828601612929565b9150509250929050565b600080600060608486031215612ad257600080fd5b6000612ae086828701612929565b9350506020612af186828701612929565b925050604084013567ffffffffffffffff811115612b0e57600080fd5b612b1a8682870161299d565b9150509250925092565b600060208284031215612b3657600080fd5b6000612b44848285016129f1565b91505092915050565b60008060408385031215612b6057600080fd5b6000612b6e858286016129f1565b9250506020612b7f85828601612914565b9150509250929050565b600080600060608486031215612b9e57600080fd5b6000612bac868287016129f1565b9350506020612bbd86828701612929565b925050604084013567ffffffffffffffff811115612bda57600080fd5b612be68682870161299d565b9150509250925092565b60008060408385031215612c0357600080fd5b6000612c11858286016129f1565b9250506020612c22858286016129f1565b9150509250929050565b600080600080600080600060a0888a031215612c4757600080fd5b6000612c558a828b016129f1565b9750506020612c668a828b016129f1565b9650506040612c778a828b016129f1565b955050606088013567ffffffffffffffff811115612c9457600080fd5b612ca08a828b01612953565b9450945050608088013567ffffffffffffffff811115612cbf57600080fd5b612ccb8a828b01612953565b925092505092959891949750929550565b6000612ce88383612d0c565b60208301905092915050565b6000612d00838361317d565b60208301905092915050565b612d15816135b2565b82525050565b612d24816135b2565b82525050565b6000612d358261352e565b612d3f8185613569565b9350612d4a8361350e565b8060005b83811015612d7b578151612d628882612cdc565b9750612d6d8361354f565b925050600181019050612d4e565b5085935050505092915050565b6000612d9382613539565b612d9d818561357a565b9350612da88361351e565b8060005b83811015612dd9578151612dc08882612cf4565b9750612dcb8361355c565b925050600181019050612dac565b5085935050505092915050565b612def816135c4565b82525050565b612e06612e01826135d0565b61367f565b82525050565b612e15816135fc565b82525050565b612e2c612e27826135fc565b613689565b82525050565b6000612e3d82613544565b612e47818561358b565b9350612e5781856020860161364c565b80840191505092915050565b6000612e706004836135a7565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612eb0602d83613596565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000612f16600f83613596565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000612f56601383613596565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b6000612f96604583613596565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000613022602a83613596565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b6000613088601283613596565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b60006130c86005836135a7565b91507f38303030310000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000613108600e836135a7565b91507f6865696d64616c6c2d38303030310000000000000000000000000000000000006000830152600e82019050919050565b606082016000820151613151600085018261317d565b506020820151613164602085018261317d565b5060408201516131776040850182612d0c565b50505050565b61318681613626565b82525050565b61319581613626565b82525050565b6131a481613630565b82525050565b60006131b68285612df5565b6001820191506131c68284612e1b565b6020820191508190509392505050565b60006131e28286612df5565b6001820191506131f28285612e1b565b6020820191506132028284612e1b565b602082019150819050949350505050565b600061321f8284612e32565b915081905092915050565b600061323582612e63565b9150819050919050565b600061324a826130bb565b9150819050919050565b600061325f826130fb565b9150819050919050565b600060208201905061327e6000830184612d1b565b92915050565b6000604082019050818103600083015261329e8185612d2a565b905081810360208301526132b28184612d88565b90509392505050565b60006020820190506132d06000830184612de6565b92915050565b60006020820190506132eb6000830184612e0c565b92915050565b60006080820190506133066000830187612e0c565b613313602083018661319b565b6133206040830185612e0c565b61332d6060830184612e0c565b95945050505050565b6000602082019050818103600083015261334f81612ea3565b9050919050565b6000602082019050818103600083015261336f81612f09565b9050919050565b6000602082019050818103600083015261338f81612f49565b9050919050565b600060208201905081810360008301526133af81612f89565b9050919050565b600060208201905081810360008301526133cf81613015565b9050919050565b600060208201905081810360008301526133ef8161307b565b9050919050565b600060608201905061340b600083018461313b565b92915050565b6000602082019050613426600083018461318c565b92915050565b6000606082019050613441600083018661318c565b61344e602083018561318c565b61345b6040830184612d1b565b949350505050565b6000606082019050613478600083018661318c565b613485602083018561318c565b613492604083018461318c565b949350505050565b60006020820190506134af600083018461319b565b92915050565b6000604051905081810181811067ffffffffffffffff821117156134d857600080fd5b8060405250919050565b600067ffffffffffffffff8211156134f957600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006135bd82613606565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b8381101561366a57808201518184015260208101905061364f565b83811115613679576000848401525b50505050565b6000819050919050565b6000819050919050565b61369c816135b2565b81146136a757600080fd5b50565b6136b3816135fc565b81146136be57600080fd5b50565b6136ca81613626565b81146136d557600080fd5b5056fea365627a7a723158208f52ee07630ffe523cc6ad3e15f437f973dcfa36729cd697f9b0fc4a145a48f06c6578706572696d656e74616cf564736f6c634300050b0040", + "balance":"0x0" + }, + "0000000000000000000000000000000000001001":{ + "code":"0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a7231582083fbdacb76f32b4112d0f7db9a596937925824798a0026ba0232322390b5263764736f6c634300050b0032", + "balance":"0x0" + }, + "0000000000000000000000000000000000001010":{ + "code":"0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a4565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116aa565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611737565b005b348015610b2e57600080fd5b50610b37611754565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa82848861177a565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3790919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e636023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5790919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611e406023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b76565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c733848461177a565b90505b92915050565b6040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6e565b611d44565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611e86605291396040516020018082805190602001908083835b602083106116f957805182526020820191506020810190506020830392506116d6565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173f6114dd565b61174857600080fd5b61175181611b76565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d602081101561182457600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b657600080fd5b505afa1580156118ca573d6000803e3d6000fd5b505050506040513d60208110156118e057600080fd5b810190808051906020019092919050505090506118fe868686611d8e565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0657600080fd5b505afa158015611a1a573d6000803e3d6000fd5b505050506040513d6020811015611a3057600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d6020811015611ae857600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4657600080fd5b600082840390508091505092915050565b600080828401905083811015611b6c57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bb057600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611ed8605b91396040516020018082805190602001908083835b60208310611cc05780518252602082019150602081019050602083039250611c9d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611dd4573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a723158208f81700133738d766ae3d68af591ad588b0125bd91449192179f460893f79f6b64736f6c634300050b0032", + "balance":"0x204fcd4f31349d83b6e00000" + }, + "928ed6a3e94437bbd316ccad78479f1d163a6a8c":{ + "balance":"0x3635c9adc5dea00000" + }, + "be188d6641e8b680743a4815dfa0f6208038960f":{ + "balance":"0x3635c9adc5dea00000" + }, + "c26880a0af2ea0c7e8130e6ec47af756465452e8":{ + "balance":"0x3635c9adc5dea00000" + }, + "c275dc8be39f50d12f66b6a63629c39da5bae5bd":{ + "balance":"0x3635c9adc5dea00000" + }, + "f903ba9e006193c1527bfbe65fe2123704ea3f99":{ + "balance":"0x3635c9adc5dea00000" + } + }, + "number":"0x0", + "gasUsed":"0x0", + "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas":null + }, + "Bootnodes":[ + "enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@54.147.31.250:30303", + "enode://f0f48a8781629f95ff02606081e6e43e4aebd503f3d07fc931fad7dd5ca1ba52bd849a6f6c3be0e375cf13c9ae04d859c4a9ae3546dc8ed4f10aa5dbb47d4998@34.226.134.117:30303" + ], + "NetworkId":80001, + "DNS":null + } diff --git a/internal/cli/server/chains/test_files/wrong_chain.json b/internal/cli/server/chains/test_files/wrong_chain.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/internal/cli/server/chains/test_files/wrong_chain.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/internal/cli/server/chains/utils.go b/internal/cli/server/chains/utils.go new file mode 100644 index 0000000000..860ff5b6ee --- /dev/null +++ b/internal/cli/server/chains/utils.go @@ -0,0 +1,30 @@ +package chains + +import ( + "embed" + "encoding/json" + "fmt" + + "github.com/ethereum/go-ethereum/core" +) + +//go:embed allocs +var allocs embed.FS + +func readPrealloc(filename string) core.GenesisAlloc { + f, err := allocs.Open(filename) + if err != nil { + panic(fmt.Sprintf("Could not open genesis preallocation for %s: %v", filename, err)) + } + + defer f.Close() + decoder := json.NewDecoder(f) + ga := make(core.GenesisAlloc) + + err = decoder.Decode(&ga) + if err != nil { + panic(fmt.Sprintf("Could not parse genesis preallocation for %s: %v", filename, err)) + } + + return ga +} diff --git a/internal/cli/server/command.go b/internal/cli/server/command.go new file mode 100644 index 0000000000..4d7ab6f108 --- /dev/null +++ b/internal/cli/server/command.go @@ -0,0 +1,192 @@ +package server + +import ( + "context" + "fmt" + "os" + "os/signal" + "strings" + "syscall" + + "github.com/maticnetwork/heimdall/cmd/heimdalld/service" + "github.com/mitchellh/cli" + "github.com/pelletier/go-toml" + + "github.com/ethereum/go-ethereum/log" +) + +// Command is the command to start the sever +type Command struct { + UI cli.Ui + + // cli configuration + cliConfig *Config + + // final configuration + config *Config + + configFile string + + srv *Server +} + +// MarkDown implements cli.MarkDown interface +func (c *Command) MarkDown() string { + items := []string{ + "# Server", + "The ```bor server``` command runs the Bor client.", + c.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *Command) Help() string { + return `Usage: bor [options] + + Run the Bor server. + ` + c.Flags().Help() +} + +// Synopsis implements the cli.Command interface +func (c *Command) Synopsis() string { + return "Run the Bor server" +} + +func (c *Command) extractFlags(args []string) error { + config := *DefaultConfig() + + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + c.config = &config + + return err + } + + // TODO: Check if this can be removed or not + // read cli flags + if err := config.Merge(c.cliConfig); err != nil { + c.UI.Error(err.Error()) + c.config = &config + + return err + } + // read if config file is provided, this will overwrite the cli flags, if provided + if c.configFile != "" { + log.Warn("Config File provided, this will overwrite the cli flags", "path", c.configFile) + + cfg, err := readConfigFile(c.configFile) + if err != nil { + c.UI.Error(err.Error()) + c.config = &config + + return err + } + + if err := config.Merge(cfg); err != nil { + c.UI.Error(err.Error()) + c.config = &config + + return err + } + } + + // nolint: nestif + // check for log-level and verbosity here + if c.configFile != "" { + data, _ := toml.LoadFile(c.configFile) + if data.Has("verbosity") && data.Has("log-level") { + log.Warn("Config contains both, verbosity and log-level, log-level will be deprecated soon. Use verbosity only.", "using", data.Get("verbosity")) + } else if !data.Has("verbosity") && data.Has("log-level") { + log.Warn("Config contains log-level only, note that log-level will be deprecated soon. Use verbosity instead.", "using", data.Get("log-level")) + config.Verbosity = VerbosityStringToInt(strings.ToLower(data.Get("log-level").(string))) + } + } else { + tempFlag := 0 + + for _, val := range args { + if (strings.HasPrefix(val, "-verbosity") || strings.HasPrefix(val, "--verbosity")) && config.LogLevel != "" { + tempFlag = 1 + break + } + } + + if tempFlag == 1 { + log.Warn("Both, verbosity and log-level flags are provided, log-level will be deprecated soon. Use verbosity only.", "using", config.Verbosity) + } else if tempFlag == 0 && config.LogLevel != "" { + log.Warn("Only log-level flag is provided, note that log-level will be deprecated soon. Use verbosity instead.", "using", config.LogLevel) + config.Verbosity = VerbosityStringToInt(strings.ToLower(config.LogLevel)) + } + } + + c.config = &config + + return nil +} + +// Run implements the cli.Command interface +func (c *Command) Run(args []string) int { + err := c.extractFlags(args) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if c.config.Heimdall.RunHeimdall { + shutdownCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + defer stop() + + go func() { + service.NewHeimdallService(shutdownCtx, c.getHeimdallArgs()) + }() + } + + srv, err := NewServer(c.config, WithGRPCAddress()) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.srv = srv + + return c.handleSignals() +} + +func (c *Command) handleSignals() int { + signalCh := make(chan os.Signal, 4) + signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) + + sig := <-signalCh + + c.UI.Output(fmt.Sprintf("Caught signal: %v", sig)) + c.UI.Output("Gracefully shutting down agent...") + + gracefulCh := make(chan struct{}) + go func() { + c.srv.Stop() + close(gracefulCh) + }() + + for i := 10; i > 0; i-- { + select { + case <-signalCh: + log.Warn("Already shutting down, interrupt more force stop.", "times", i-1) + case <-gracefulCh: + return 0 + } + } + + return 1 +} + +// GetConfig returns the user specified config +func (c *Command) GetConfig() *Config { + return c.cliConfig +} + +func (c *Command) getHeimdallArgs() []string { + heimdallArgs := strings.Split(c.config.Heimdall.RunHeimdallArgs, ",") + return append([]string{"start"}, heimdallArgs...) +} diff --git a/internal/cli/server/command_test.go b/internal/cli/server/command_test.go new file mode 100644 index 0000000000..ab28de5ee6 --- /dev/null +++ b/internal/cli/server/command_test.go @@ -0,0 +1,50 @@ +package server + +import ( + "math/big" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestFlags(t *testing.T) { + t.Parallel() + + var c Command + + args := []string{ + "--txpool.rejournal", "30m0s", + "--txpool.lifetime", "30m0s", + "--miner.gasprice", "20000000000", + "--gpo.maxprice", "70000000000", + "--gpo.ignoreprice", "1", + "--cache.trie.rejournal", "40m0s", + "--dev", + "--dev.period", "2", + "--datadir", "./data", + "--maxpeers", "30", + "--eth.requiredblocks", "a=b", + "--http.api", "eth,web3,bor", + } + err := c.extractFlags(args) + + require.NoError(t, err) + + txRe, _ := time.ParseDuration("30m0s") + txLt, _ := time.ParseDuration("30m0s") + caRe, _ := time.ParseDuration("40m0s") + + require.Equal(t, c.config.DataDir, "./data") + require.Equal(t, c.config.Developer.Enabled, true) + require.Equal(t, c.config.Developer.Period, uint64(2)) + require.Equal(t, c.config.TxPool.Rejournal, txRe) + require.Equal(t, c.config.TxPool.LifeTime, txLt) + require.Equal(t, c.config.Sealer.GasPrice, big.NewInt(20000000000)) + require.Equal(t, c.config.Gpo.MaxPrice, big.NewInt(70000000000)) + require.Equal(t, c.config.Gpo.IgnorePrice, big.NewInt(1)) + require.Equal(t, c.config.Cache.Rejournal, caRe) + require.Equal(t, c.config.P2P.MaxPeers, uint64(30)) + require.Equal(t, c.config.RequiredBlocks, map[string]string{"a": "b"}) + require.Equal(t, c.config.JsonRPC.Http.API, []string{"eth", "web3", "bor"}) +} diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go new file mode 100644 index 0000000000..0a9c7dd704 --- /dev/null +++ b/internal/cli/server/config.go @@ -0,0 +1,1543 @@ +package server + +import ( + "crypto/ecdsa" + "fmt" + "io/ioutil" + "math" + "math/big" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + "time" + + godebug "runtime/debug" + + "github.com/hashicorp/hcl/v2/hclsimple" + "github.com/imdario/mergo" + "github.com/mitchellh/go-homedir" + gopsutil "github.com/shirou/gopsutil/mem" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/fdlimit" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/gasprice" + "github.com/ethereum/go-ethereum/internal/cli/server/chains" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enode" + "github.com/ethereum/go-ethereum/p2p/nat" + "github.com/ethereum/go-ethereum/p2p/netutil" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rpc" +) + +type Config struct { + chain *chains.Chain + + // Chain is the chain to sync with + Chain string `hcl:"chain,optional" toml:"chain,optional"` + + // Identity of the node + Identity string `hcl:"identity,optional" toml:"identity,optional"` + + // RequiredBlocks is a list of required (block number, hash) pairs to accept + RequiredBlocks map[string]string `hcl:"eth.requiredblocks,optional" toml:"eth.requiredblocks,optional"` + + // Verbosity is the level of the logs to put out + Verbosity int `hcl:"verbosity,optional" toml:"verbosity,optional"` + + // LogLevel is the level of the logs to put out + LogLevel string `hcl:"log-level,optional" toml:"log-level,optional"` + + // Record information useful for VM and contract debugging + EnablePreimageRecording bool `hcl:"vmdebug,optional" toml:"vmdebug,optional"` + + // DataDir is the directory to store the state in + DataDir string `hcl:"datadir,optional" toml:"datadir,optional"` + + // Ancient is the directory to store the state in + Ancient string `hcl:"ancient,optional" toml:"ancient,optional"` + + // DBEngine is used to select leveldb or pebble as database + DBEngine string `hcl:"db.engine,optional" toml:"db.engine,optional"` + + // KeyStoreDir is the directory to store keystores + KeyStoreDir string `hcl:"keystore,optional" toml:"keystore,optional"` + + // Maximum number of messages in a batch (default=100, use 0 for no limits) + RPCBatchLimit uint64 `hcl:"rpc.batchlimit,optional" toml:"rpc.batchlimit,optional"` + + // Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits) + RPCReturnDataLimit uint64 `hcl:"rpc.returndatalimit,optional" toml:"rpc.returndatalimit,optional"` + + // SyncMode selects the sync protocol + SyncMode string `hcl:"syncmode,optional" toml:"syncmode,optional"` + + // GcMode selects the garbage collection mode for the trie + GcMode string `hcl:"gcmode,optional" toml:"gcmode,optional"` + + // Snapshot enables the snapshot database mode + Snapshot bool `hcl:"snapshot,optional" toml:"snapshot,optional"` + + // BorLogs enables bor log retrieval + BorLogs bool `hcl:"bor.logs,optional" toml:"bor.logs,optional"` + + // Ethstats is the address of the ethstats server to send telemetry + Ethstats string `hcl:"ethstats,optional" toml:"ethstats,optional"` + + // Logging has the logging related settings + Logging *LoggingConfig `hcl:"log,block" toml:"log,block"` + + // P2P has the p2p network related settings + P2P *P2PConfig `hcl:"p2p,block" toml:"p2p,block"` + + // Heimdall has the heimdall connection related settings + Heimdall *HeimdallConfig `hcl:"heimdall,block" toml:"heimdall,block"` + + // TxPool has the transaction pool related settings + TxPool *TxPoolConfig `hcl:"txpool,block" toml:"txpool,block"` + + // Sealer has the validator related settings + Sealer *SealerConfig `hcl:"miner,block" toml:"miner,block"` + + // JsonRPC has the json-rpc related settings + JsonRPC *JsonRPCConfig `hcl:"jsonrpc,block" toml:"jsonrpc,block"` + + // Gpo has the gas price oracle related settings + Gpo *GpoConfig `hcl:"gpo,block" toml:"gpo,block"` + + // Telemetry has the telemetry related settings + Telemetry *TelemetryConfig `hcl:"telemetry,block" toml:"telemetry,block"` + + // Cache has the cache related settings + Cache *CacheConfig `hcl:"cache,block" toml:"cache,block"` + + ExtraDB *ExtraDBConfig `hcl:"leveldb,block" toml:"leveldb,block"` + + // Account has the validator account related settings + Accounts *AccountsConfig `hcl:"accounts,block" toml:"accounts,block"` + + // GRPC has the grpc server related settings + GRPC *GRPCConfig `hcl:"grpc,block" toml:"grpc,block"` + + // Developer has the developer mode related settings + Developer *DeveloperConfig `hcl:"developer,block" toml:"developer,block"` + + // ParallelEVM has the parallel evm related settings + ParallelEVM *ParallelEVMConfig `hcl:"parallelevm,block" toml:"parallelevm,block"` + + // Develop Fake Author mode to produce blocks without authorisation + DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"` + + // Pprof has the pprof related settings + Pprof *PprofConfig `hcl:"pprof,block" toml:"pprof,block"` +} + +type LoggingConfig struct { + // Per-module verbosity: comma-separated list of = (e.g. eth/*=5,p2p=4) + Vmodule string `hcl:"vmodule,optional" toml:"vmodule,optional"` + + // Format logs with JSON + Json bool `hcl:"json,optional" toml:"json,optional"` + + // Request a stack trace at a specific logging statement (e.g. "block.go:271") + Backtrace string `hcl:"backtrace,optional" toml:"backtrace,optional"` + + // Prepends log messages with call-site location (file and line number) + Debug bool `hcl:"debug,optional" toml:"debug,optional"` + + // TODO - implement this + // // Write execution trace to the given file + // Trace string `hcl:"trace,optional" toml:"trace,optional"` +} + +type PprofConfig struct { + // Enableed enable the pprof HTTP server + Enabled bool `hcl:"pprof,optional" toml:"pprof,optional"` + + // pprof HTTP server listening port + Port int `hcl:"port,optional" toml:"port,optional"` + + // pprof HTTP server listening interface + Addr string `hcl:"addr,optional" toml:"addr,optional"` + + // Turn on memory profiling with the given rate + MemProfileRate int `hcl:"memprofilerate,optional" toml:"memprofilerate,optional"` + + // Turn on block profiling with the given rate + BlockProfileRate int `hcl:"blockprofilerate,optional" toml:"blockprofilerate,optional"` + + // // Write CPU profile to the given file + // CPUProfile string `hcl:"cpuprofile,optional" toml:"cpuprofile,optional"` +} + +type P2PConfig struct { + // MaxPeers sets the maximum number of connected peers + MaxPeers uint64 `hcl:"maxpeers,optional" toml:"maxpeers,optional"` + + // MaxPendPeers sets the maximum number of pending connected peers + MaxPendPeers uint64 `hcl:"maxpendpeers,optional" toml:"maxpendpeers,optional"` + + // Bind is the bind address + Bind string `hcl:"bind,optional" toml:"bind,optional"` + + // Port is the port number + Port uint64 `hcl:"port,optional" toml:"port,optional"` + + // NoDiscover is used to disable discovery + NoDiscover bool `hcl:"nodiscover,optional" toml:"nodiscover,optional"` + + // NAT it used to set NAT options + NAT string `hcl:"nat,optional" toml:"nat,optional"` + + // Connectivity can be restricted to certain IP networks. + // If this option is set to a non-nil value, only hosts which match one of the + // IP networks contained in the list are considered. + NetRestrict string `hcl:"netrestrict,optional" toml:"netrestrict,optional"` + + // P2P node key file + NodeKey string `hcl:"nodekey,optional" toml:"nodekey,optional"` + + // P2P node key as hex + NodeKeyHex string `hcl:"nodekeyhex,optional" toml:"nodekeyhex,optional"` + + // Discovery has the p2p discovery related settings + Discovery *P2PDiscovery `hcl:"discovery,block" toml:"discovery,block"` + + // TxArrivalWait sets the maximum duration the transaction fetcher will wait for + // an announced transaction to arrive before explicitly requesting it + TxArrivalWait time.Duration `hcl:"-,optional" toml:"-"` + TxArrivalWaitRaw string `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"` +} + +type P2PDiscovery struct { + // V5Enabled is used to enable disc v5 discovery mode + V5Enabled bool `hcl:"v5disc,optional" toml:"v5disc,optional"` + + // Bootnodes is the list of initial bootnodes + Bootnodes []string `hcl:"bootnodes,optional" toml:"bootnodes,optional"` + + // BootnodesV4 is the list of initial v4 bootnodes + BootnodesV4 []string `hcl:"bootnodesv4,optional" toml:"bootnodesv4,optional"` + + // BootnodesV5 is the list of initial v5 bootnodes + BootnodesV5 []string `hcl:"bootnodesv5,optional" toml:"bootnodesv5,optional"` + + // StaticNodes is the list of static nodes + StaticNodes []string `hcl:"static-nodes,optional" toml:"static-nodes,optional"` + + // TrustedNodes is the list of trusted nodes + TrustedNodes []string `hcl:"trusted-nodes,optional" toml:"trusted-nodes,optional"` + + // DNS is the list of enrtree:// URLs which will be queried for nodes to connect to + DNS []string `hcl:"dns,optional" toml:"dns,optional"` +} + +type HeimdallConfig struct { + // URL is the url of the heimdall server + URL string `hcl:"url,optional" toml:"url,optional"` + + // Without is used to disable remote heimdall during testing + Without bool `hcl:"bor.without,optional" toml:"bor.without,optional"` + + // GRPCAddress is the address of the heimdall grpc server + GRPCAddress string `hcl:"grpc-address,optional" toml:"grpc-address,optional"` + + // RunHeimdall is used to run heimdall as a child process + RunHeimdall bool `hcl:"bor.runheimdall,optional" toml:"bor.runheimdall,optional"` + + // RunHeimdal args are the arguments to run heimdall with + RunHeimdallArgs string `hcl:"bor.runheimdallargs,optional" toml:"bor.runheimdallargs,optional"` + + // UseHeimdallApp is used to fetch data from heimdall app when running heimdall as a child process + UseHeimdallApp bool `hcl:"bor.useheimdallapp,optional" toml:"bor.useheimdallapp,optional"` +} + +type TxPoolConfig struct { + // Locals are the addresses that should be treated by default as local + Locals []string `hcl:"locals,optional" toml:"locals,optional"` + + // NoLocals enables whether local transaction handling should be disabled + NoLocals bool `hcl:"nolocals,optional" toml:"nolocals,optional"` + + // Journal is the path to store local transactions to survive node restarts + Journal string `hcl:"journal,optional" toml:"journal,optional"` + + // Rejournal is the time interval to regenerate the local transaction journal + Rejournal time.Duration `hcl:"-,optional" toml:"-"` + RejournalRaw string `hcl:"rejournal,optional" toml:"rejournal,optional"` + + // PriceLimit is the minimum gas price to enforce for acceptance into the pool + PriceLimit uint64 `hcl:"pricelimit,optional" toml:"pricelimit,optional"` + + // PriceBump is the minimum price bump percentage to replace an already existing transaction (nonce) + PriceBump uint64 `hcl:"pricebump,optional" toml:"pricebump,optional"` + + // AccountSlots is the number of executable transaction slots guaranteed per account + AccountSlots uint64 `hcl:"accountslots,optional" toml:"accountslots,optional"` + + // GlobalSlots is the maximum number of executable transaction slots for all accounts + GlobalSlots uint64 `hcl:"globalslots,optional" toml:"globalslots,optional"` + + // AccountQueue is the maximum number of non-executable transaction slots permitted per account + AccountQueue uint64 `hcl:"accountqueue,optional" toml:"accountqueue,optional"` + + // GlobalQueueis the maximum number of non-executable transaction slots for all accounts + GlobalQueue uint64 `hcl:"globalqueue,optional" toml:"globalqueue,optional"` + + // lifetime is the maximum amount of time non-executable transaction are queued + LifeTime time.Duration `hcl:"-,optional" toml:"-"` + LifeTimeRaw string `hcl:"lifetime,optional" toml:"lifetime,optional"` +} + +type SealerConfig struct { + // Enabled is used to enable validator mode + Enabled bool `hcl:"mine,optional" toml:"mine,optional"` + + // Etherbase is the address of the validator + Etherbase string `hcl:"etherbase,optional" toml:"etherbase,optional"` + + // ExtraData is the block extra data set by the miner + ExtraData string `hcl:"extradata,optional" toml:"extradata,optional"` + + // GasCeil is the target gas ceiling for mined blocks. + GasCeil uint64 `hcl:"gaslimit,optional" toml:"gaslimit,optional"` + + // GasPrice is the minimum gas price for mining a transaction + GasPrice *big.Int `hcl:"-,optional" toml:"-"` + GasPriceRaw string `hcl:"gasprice,optional" toml:"gasprice,optional"` + + // The time interval for miner to re-create mining work. + Recommit time.Duration `hcl:"-,optional" toml:"-"` + RecommitRaw string `hcl:"recommit,optional" toml:"recommit,optional"` + + CommitInterruptFlag bool `hcl:"commitinterrupt,optional" toml:"commitinterrupt,optional"` +} + +type JsonRPCConfig struct { + // IPCDisable enables whether ipc is enabled or not + IPCDisable bool `hcl:"ipcdisable,optional" toml:"ipcdisable,optional"` + + // IPCPath is the path of the ipc endpoint + IPCPath string `hcl:"ipcpath,optional" toml:"ipcpath,optional"` + + // GasCap is the global gas cap for eth-call variants. + GasCap uint64 `hcl:"gascap,optional" toml:"gascap,optional"` + + // Sets a timeout used for eth_call (0=infinite) + RPCEVMTimeout time.Duration `hcl:"-,optional" toml:"-"` + RPCEVMTimeoutRaw string `hcl:"evmtimeout,optional" toml:"evmtimeout,optional"` + + // TxFeeCap is the global transaction fee cap for send-transaction variants + TxFeeCap float64 `hcl:"txfeecap,optional" toml:"txfeecap,optional"` + + // Http has the json-rpc http related settings + Http *APIConfig `hcl:"http,block" toml:"http,block"` + + // Ws has the json-rpc websocket related settings + Ws *APIConfig `hcl:"ws,block" toml:"ws,block"` + + // Graphql has the json-rpc graphql related settings + Graphql *APIConfig `hcl:"graphql,block" toml:"graphql,block"` + + // AUTH RPC related settings + Auth *AUTHConfig `hcl:"auth,block" toml:"auth,block"` + + HttpTimeout *HttpTimeouts `hcl:"timeouts,block" toml:"timeouts,block"` + + AllowUnprotectedTxs bool `hcl:"allow-unprotected-txs,optional" toml:"allow-unprotected-txs,optional"` + + // EnablePersonal enables the deprecated personal namespace. + EnablePersonal bool `hcl:"enabledeprecatedpersonal,optional" toml:"enabledeprecatedpersonal,optional"` +} + +type AUTHConfig struct { + // JWTSecret is the hex-encoded jwt secret. + JWTSecret string `hcl:"jwtsecret,optional" toml:"jwtsecret,optional"` + + // Addr is the listening address on which authenticated APIs are provided. + Addr string `hcl:"addr,optional" toml:"addr,optional"` + + // Port is the port number on which authenticated APIs are provided. + Port uint64 `hcl:"port,optional" toml:"port,optional"` + + // VHosts is the list of virtual hostnames which are allowed on incoming requests + // for the authenticated api. This is by default {'localhost'}. + VHosts []string `hcl:"vhosts,optional" toml:"vhosts,optional"` +} + +type GRPCConfig struct { + // Addr is the bind address for the grpc rpc server + Addr string `hcl:"addr,optional" toml:"addr,optional"` +} + +type APIConfig struct { + // Enabled selects whether the api is enabled + Enabled bool `hcl:"enabled,optional" toml:"enabled,optional"` + + // Port is the port number for this api + Port uint64 `hcl:"port,optional" toml:"port,optional"` + + // Prefix is the http prefix to expose this api + Prefix string `hcl:"prefix,optional" toml:"prefix,optional"` + + // Host is the address to bind the api + Host string `hcl:"host,optional" toml:"host,optional"` + + // API is the list of enabled api modules + API []string `hcl:"api,optional" toml:"api,optional"` + + // VHost is the list of valid virtual hosts + VHost []string `hcl:"vhosts,optional" toml:"vhosts,optional"` + + // Cors is the list of Cors endpoints + Cors []string `hcl:"corsdomain,optional" toml:"corsdomain,optional"` + + // Origins is the list of endpoints to accept requests from (only consumed for websockets) + Origins []string `hcl:"origins,optional" toml:"origins,optional"` + + // ExecutionPoolSize is max size of workers to be used for rpc execution + ExecutionPoolSize uint64 `hcl:"ep-size,optional" toml:"ep-size,optional"` + + // ExecutionPoolRequestTimeout is timeout used by execution pool for rpc execution + ExecutionPoolRequestTimeout time.Duration `hcl:"-,optional" toml:"-"` + ExecutionPoolRequestTimeoutRaw string `hcl:"ep-requesttimeout,optional" toml:"ep-requesttimeout,optional"` +} + +// Used from rpc.HTTPTimeouts +type HttpTimeouts struct { + // ReadTimeout is the maximum duration for reading the entire + // request, including the body. + // + // Because ReadTimeout does not let Handlers make per-request + // decisions on each request body's acceptable deadline or + // upload rate, most users will prefer to use + // ReadHeaderTimeout. It is valid to use them both. + ReadTimeout time.Duration `hcl:"-,optional" toml:"-"` + ReadTimeoutRaw string `hcl:"read,optional" toml:"read,optional"` + + // WriteTimeout is the maximum duration before timing out + // writes of the response. It is reset whenever a new + // request's header is read. Like ReadTimeout, it does not + // let Handlers make decisions on a per-request basis. + WriteTimeout time.Duration `hcl:"-,optional" toml:"-"` + WriteTimeoutRaw string `hcl:"write,optional" toml:"write,optional"` + + // IdleTimeout is the maximum amount of time to wait for the + // next request when keep-alives are enabled. If IdleTimeout + // is zero, the value of ReadTimeout is used. If both are + // zero, ReadHeaderTimeout is used. + IdleTimeout time.Duration `hcl:"-,optional" toml:"-"` + IdleTimeoutRaw string `hcl:"idle,optional" toml:"idle,optional"` +} + +type GpoConfig struct { + // Blocks is the number of blocks to track to compute the price oracle + Blocks uint64 `hcl:"blocks,optional" toml:"blocks,optional"` + + // Percentile sets the weights to new blocks + Percentile uint64 `hcl:"percentile,optional" toml:"percentile,optional"` + + // Maximum header history of gasprice oracle + MaxHeaderHistory int `hcl:"maxheaderhistory,optional" toml:"maxheaderhistory,optional"` + + // Maximum block history of gasprice oracle + MaxBlockHistory int `hcl:"maxblockhistory,optional" toml:"maxblockhistory,optional"` + + // MaxPrice is an upper bound gas price + MaxPrice *big.Int `hcl:"-,optional" toml:"-"` + MaxPriceRaw string `hcl:"maxprice,optional" toml:"maxprice,optional"` + + // IgnorePrice is a lower bound gas price + IgnorePrice *big.Int `hcl:"-,optional" toml:"-"` + IgnorePriceRaw string `hcl:"ignoreprice,optional" toml:"ignoreprice,optional"` +} + +type TelemetryConfig struct { + // Enabled enables metrics + Enabled bool `hcl:"metrics,optional" toml:"metrics,optional"` + + // Expensive enables expensive metrics + Expensive bool `hcl:"expensive,optional" toml:"expensive,optional"` + + // InfluxDB has the influxdb related settings + InfluxDB *InfluxDBConfig `hcl:"influx,block" toml:"influx,block"` + + // Prometheus Address + PrometheusAddr string `hcl:"prometheus-addr,optional" toml:"prometheus-addr,optional"` + + // Open collector endpoint + OpenCollectorEndpoint string `hcl:"opencollector-endpoint,optional" toml:"opencollector-endpoint,optional"` +} + +type InfluxDBConfig struct { + // V1Enabled enables influx v1 mode + V1Enabled bool `hcl:"influxdb,optional" toml:"influxdb,optional"` + + // Endpoint is the url endpoint of the influxdb service + Endpoint string `hcl:"endpoint,optional" toml:"endpoint,optional"` + + // Database is the name of the database in Influxdb to store the metrics. + Database string `hcl:"database,optional" toml:"database,optional"` + + // Enabled is the username to authorize access to Influxdb + Username string `hcl:"username,optional" toml:"username,optional"` + + // Password is the password to authorize access to Influxdb + Password string `hcl:"password,optional" toml:"password,optional"` + + // Tags are tags attaches to all generated metrics + Tags map[string]string `hcl:"tags,optional" toml:"tags,optional"` + + // Enabled enables influx v2 mode + V2Enabled bool `hcl:"influxdbv2,optional" toml:"influxdbv2,optional"` + + // Token is the token to authorize access to Influxdb V2. + Token string `hcl:"token,optional" toml:"token,optional"` + + // Bucket is the bucket to store metrics in Influxdb V2. + Bucket string `hcl:"bucket,optional" toml:"bucket,optional"` + + // Organization is the name of the organization for Influxdb V2. + Organization string `hcl:"organization,optional" toml:"organization,optional"` +} + +type CacheConfig struct { + // Cache is the amount of cache of the node + Cache uint64 `hcl:"cache,optional" toml:"cache,optional"` + + // PercGc is percentage of cache used for garbage collection + PercGc uint64 `hcl:"gc,optional" toml:"gc,optional"` + + // PercSnapshot is percentage of cache used for snapshots + PercSnapshot uint64 `hcl:"snapshot,optional" toml:"snapshot,optional"` + + // PercDatabase is percentage of cache used for the database + PercDatabase uint64 `hcl:"database,optional" toml:"database,optional"` + + // PercTrie is percentage of cache used for the trie + PercTrie uint64 `hcl:"trie,optional" toml:"trie,optional"` + + // Journal is the disk journal directory for trie cache to survive node restarts + Journal string `hcl:"journal,optional" toml:"journal,optional"` + + // Rejournal is the time interval to regenerate the journal for clean cache + Rejournal time.Duration `hcl:"-,optional" toml:"-"` + RejournalRaw string `hcl:"rejournal,optional" toml:"rejournal,optional"` + + // NoPrefetch is used to disable prefetch of tries + NoPrefetch bool `hcl:"noprefetch,optional" toml:"noprefetch,optional"` + + // Preimages is used to enable the track of hash preimages + Preimages bool `hcl:"preimages,optional" toml:"preimages,optional"` + + // TxLookupLimit sets the maximum number of blocks from head whose tx indices are reserved. + TxLookupLimit uint64 `hcl:"txlookuplimit,optional" toml:"txlookuplimit,optional"` + + // Number of block states to keep in memory (default = 128) + TriesInMemory uint64 `hcl:"triesinmemory,optional" toml:"triesinmemory,optional"` + // Time after which the Merkle Patricia Trie is stored to disc from memory + TrieTimeout time.Duration `hcl:"-,optional" toml:"-"` + TrieTimeoutRaw string `hcl:"timeout,optional" toml:"timeout,optional"` + + // Raise the open file descriptor resource limit (default = system fd limit) + FDLimit int `hcl:"fdlimit,optional" toml:"fdlimit,optional"` +} + +type ExtraDBConfig struct { + LevelDbCompactionTableSize uint64 `hcl:"compactiontablesize,optional" toml:"compactiontablesize,optional"` + LevelDbCompactionTableSizeMultiplier float64 `hcl:"compactiontablesizemultiplier,optional" toml:"compactiontablesizemultiplier,optional"` + LevelDbCompactionTotalSize uint64 `hcl:"compactiontotalsize,optional" toml:"compactiontotalsize,optional"` + LevelDbCompactionTotalSizeMultiplier float64 `hcl:"compactiontotalsizemultiplier,optional" toml:"compactiontotalsizemultiplier,optional"` +} + +type AccountsConfig struct { + // Unlock is the list of addresses to unlock in the node + Unlock []string `hcl:"unlock,optional" toml:"unlock,optional"` + + // PasswordFile is the file where the account passwords are stored + PasswordFile string `hcl:"password,optional" toml:"password,optional"` + + // AllowInsecureUnlock allows user to unlock accounts in unsafe http environment. + AllowInsecureUnlock bool `hcl:"allow-insecure-unlock,optional" toml:"allow-insecure-unlock,optional"` + + // UseLightweightKDF enables a faster but less secure encryption of accounts + UseLightweightKDF bool `hcl:"lightkdf,optional" toml:"lightkdf,optional"` + + // DisableBorWallet disables the personal wallet endpoints + DisableBorWallet bool `hcl:"disable-bor-wallet,optional" toml:"disable-bor-wallet,optional"` +} + +type DeveloperConfig struct { + // Enabled enables the developer mode + Enabled bool `hcl:"dev,optional" toml:"dev,optional"` + + // Period is the block period to use in developer mode + Period uint64 `hcl:"period,optional" toml:"period,optional"` + + // Initial block gas limit + GasLimit uint64 `hcl:"gaslimit,optional" toml:"gaslimit,optional"` +} + +type ParallelEVMConfig struct { + Enable bool `hcl:"enable,optional" toml:"enable,optional"` + + SpeculativeProcesses int `hcl:"procs,optional" toml:"procs,optional"` +} + +func DefaultConfig() *Config { + return &Config{ + Chain: "mainnet", + Identity: Hostname(), + RequiredBlocks: map[string]string{}, + Verbosity: 3, + LogLevel: "", + EnablePreimageRecording: false, + DataDir: DefaultDataDir(), + Ancient: "", + DBEngine: "leveldb", + Logging: &LoggingConfig{ + Vmodule: "", + Json: false, + Backtrace: "", + Debug: false, + }, + RPCBatchLimit: 100, + RPCReturnDataLimit: 100000, + P2P: &P2PConfig{ + MaxPeers: 50, + MaxPendPeers: 50, + Bind: "0.0.0.0", + Port: 30303, + NoDiscover: false, + NAT: "any", + NetRestrict: "", + TxArrivalWait: 500 * time.Millisecond, + Discovery: &P2PDiscovery{ + V5Enabled: false, + Bootnodes: []string{}, + BootnodesV4: []string{}, + BootnodesV5: []string{}, + StaticNodes: []string{}, + TrustedNodes: []string{}, + DNS: []string{}, + }, + }, + Heimdall: &HeimdallConfig{ + URL: "http://localhost:1317", + Without: false, + GRPCAddress: "", + }, + SyncMode: "full", + GcMode: "full", + Snapshot: true, + BorLogs: false, + TxPool: &TxPoolConfig{ + Locals: []string{}, + NoLocals: false, + Journal: "transactions.rlp", + Rejournal: 1 * time.Hour, + PriceLimit: 1, // geth's default + PriceBump: 10, + AccountSlots: 16, + GlobalSlots: 32768, + AccountQueue: 16, + GlobalQueue: 32768, + LifeTime: 3 * time.Hour, + }, + Sealer: &SealerConfig{ + Enabled: false, + Etherbase: "", + GasCeil: 30_000_000, // geth's default + GasPrice: big.NewInt(1 * params.GWei), // geth's default + ExtraData: "", + Recommit: 125 * time.Second, + CommitInterruptFlag: true, + }, + Gpo: &GpoConfig{ + Blocks: 20, + Percentile: 60, + MaxHeaderHistory: 1024, + MaxBlockHistory: 1024, + MaxPrice: gasprice.DefaultMaxPrice, + IgnorePrice: gasprice.DefaultIgnorePrice, + }, + JsonRPC: &JsonRPCConfig{ + IPCDisable: false, + IPCPath: "", + GasCap: ethconfig.Defaults.RPCGasCap, + TxFeeCap: ethconfig.Defaults.RPCTxFeeCap, + RPCEVMTimeout: ethconfig.Defaults.RPCEVMTimeout, + AllowUnprotectedTxs: false, + EnablePersonal: false, + Http: &APIConfig{ + Enabled: false, + Port: 8545, + Prefix: "", + Host: "localhost", + API: []string{"eth", "net", "web3", "txpool", "bor"}, + Cors: []string{"localhost"}, + VHost: []string{"localhost"}, + ExecutionPoolSize: 40, + ExecutionPoolRequestTimeout: 0, + }, + Ws: &APIConfig{ + Enabled: false, + Port: 8546, + Prefix: "", + Host: "localhost", + API: []string{"net", "web3"}, + Origins: []string{"localhost"}, + ExecutionPoolSize: 40, + ExecutionPoolRequestTimeout: 0, + }, + Graphql: &APIConfig{ + Enabled: false, + Cors: []string{"localhost"}, + VHost: []string{"localhost"}, + }, + HttpTimeout: &HttpTimeouts{ + ReadTimeout: 10 * time.Second, + WriteTimeout: 30 * time.Second, + IdleTimeout: 120 * time.Second, + }, + Auth: &AUTHConfig{ + JWTSecret: "", + Port: node.DefaultAuthPort, + Addr: node.DefaultAuthHost, + VHosts: node.DefaultAuthVhosts, + }, + }, + Ethstats: "", + Telemetry: &TelemetryConfig{ + Enabled: false, + Expensive: false, + PrometheusAddr: "127.0.0.1:7071", + OpenCollectorEndpoint: "", + InfluxDB: &InfluxDBConfig{ + V1Enabled: false, + Endpoint: "", + Database: "", + Username: "", + Password: "", + Tags: map[string]string{}, + V2Enabled: false, + Token: "", + Bucket: "", + Organization: "", + }, + }, + Cache: &CacheConfig{ + Cache: 1024, // geth's default (suitable for mumbai) + PercDatabase: 50, + PercTrie: 15, + PercGc: 25, + PercSnapshot: 10, + Journal: "triecache", + Rejournal: 60 * time.Minute, + NoPrefetch: false, + Preimages: false, + TxLookupLimit: 2350000, + TriesInMemory: 128, + TrieTimeout: 60 * time.Minute, + FDLimit: 0, + }, + ExtraDB: &ExtraDBConfig{ + // These are LevelDB defaults, specifying here for clarity in code and in logging. + // See: https://github.com/syndtr/goleveldb/blob/126854af5e6d8295ef8e8bee3040dd8380ae72e8/leveldb/opt/options.go + LevelDbCompactionTableSize: 2, // MiB + LevelDbCompactionTableSizeMultiplier: 1, + LevelDbCompactionTotalSize: 10, // MiB + LevelDbCompactionTotalSizeMultiplier: 10, + }, + Accounts: &AccountsConfig{ + Unlock: []string{}, + PasswordFile: "", + AllowInsecureUnlock: false, + UseLightweightKDF: false, + DisableBorWallet: true, + }, + GRPC: &GRPCConfig{ + Addr: ":3131", + }, + Developer: &DeveloperConfig{ + Enabled: false, + Period: 0, + GasLimit: 11500000, + }, + DevFakeAuthor: false, + Pprof: &PprofConfig{ + Enabled: false, + Port: 6060, + Addr: "127.0.0.1", + MemProfileRate: 512 * 1024, + BlockProfileRate: 0, + // CPUProfile: "", + }, + ParallelEVM: &ParallelEVMConfig{ + Enable: true, + SpeculativeProcesses: 8, + }, + } +} + +func (c *Config) fillBigInt() error { + tds := []struct { + path string + td **big.Int + str *string + }{ + {"gpo.maxprice", &c.Gpo.MaxPrice, &c.Gpo.MaxPriceRaw}, + {"gpo.ignoreprice", &c.Gpo.IgnorePrice, &c.Gpo.IgnorePriceRaw}, + {"miner.gasprice", &c.Sealer.GasPrice, &c.Sealer.GasPriceRaw}, + } + + for _, x := range tds { + if *x.str != "" { + b := new(big.Int) + + var ok bool + + if strings.HasPrefix(*x.str, "0x") { + b, ok = b.SetString((*x.str)[2:], 16) + } else { + b, ok = b.SetString(*x.str, 10) + } + + if !ok { + return fmt.Errorf("%s can't parse big int %s", x.path, *x.str) + } + + *x.str = "" + *x.td = b + } + } + + return nil +} + +func (c *Config) fillTimeDurations() error { + tds := []struct { + path string + td *time.Duration + str *string + }{ + {"jsonrpc.evmtimeout", &c.JsonRPC.RPCEVMTimeout, &c.JsonRPC.RPCEVMTimeoutRaw}, + {"miner.recommit", &c.Sealer.Recommit, &c.Sealer.RecommitRaw}, + {"jsonrpc.timeouts.read", &c.JsonRPC.HttpTimeout.ReadTimeout, &c.JsonRPC.HttpTimeout.ReadTimeoutRaw}, + {"jsonrpc.timeouts.write", &c.JsonRPC.HttpTimeout.WriteTimeout, &c.JsonRPC.HttpTimeout.WriteTimeoutRaw}, + {"jsonrpc.timeouts.idle", &c.JsonRPC.HttpTimeout.IdleTimeout, &c.JsonRPC.HttpTimeout.IdleTimeoutRaw}, + {"jsonrpc.ws.ep-requesttimeout", &c.JsonRPC.Ws.ExecutionPoolRequestTimeout, &c.JsonRPC.Ws.ExecutionPoolRequestTimeoutRaw}, + {"jsonrpc.http.ep-requesttimeout", &c.JsonRPC.Http.ExecutionPoolRequestTimeout, &c.JsonRPC.Http.ExecutionPoolRequestTimeoutRaw}, + {"txpool.lifetime", &c.TxPool.LifeTime, &c.TxPool.LifeTimeRaw}, + {"txpool.rejournal", &c.TxPool.Rejournal, &c.TxPool.RejournalRaw}, + {"cache.rejournal", &c.Cache.Rejournal, &c.Cache.RejournalRaw}, + {"cache.timeout", &c.Cache.TrieTimeout, &c.Cache.TrieTimeoutRaw}, + {"p2p.txarrivalwait", &c.P2P.TxArrivalWait, &c.P2P.TxArrivalWaitRaw}, + } + + for _, x := range tds { + if x.td != nil && x.str != nil && *x.str != "" { + d, err := time.ParseDuration(*x.str) + if err != nil { + return fmt.Errorf("%s can't parse time duration %s", x.path, *x.str) + } + + *x.str = "" + *x.td = d + } + } + + return nil +} + +func readConfigFile(path string) (*Config, error) { + ext := filepath.Ext(path) + if ext == ".toml" { + return readLegacyConfig(path) + } + + config := &Config{ + TxPool: &TxPoolConfig{}, + Cache: &CacheConfig{}, + Sealer: &SealerConfig{}, + } + + if err := hclsimple.DecodeFile(path, nil, config); err != nil { + return nil, fmt.Errorf("failed to decode config file '%s': %v", path, err) + } + + if err := config.fillBigInt(); err != nil { + return nil, err + } + + if err := config.fillTimeDurations(); err != nil { + return nil, err + } + + return config, nil +} + +func (c *Config) loadChain() error { + chain, err := chains.GetChain(c.Chain) + if err != nil { + return err + } + + c.chain = chain + + // preload some default values that depend on the chain file + if c.P2P.Discovery.DNS == nil { + c.P2P.Discovery.DNS = c.chain.DNS + } + + return nil +} + +//nolint:gocognit +func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*ethconfig.Config, error) { + dbHandles, err := MakeDatabaseHandles(c.Cache.FDLimit) + if err != nil { + return nil, err + } + + n := ethconfig.Defaults + + // only update for non-developer mode as we don't yet + // have the chain object for it. + if !c.Developer.Enabled { + n.NetworkId = c.chain.NetworkId + n.Genesis = c.chain.Genesis + } + + n.HeimdallURL = c.Heimdall.URL + n.WithoutHeimdall = c.Heimdall.Without + n.HeimdallgRPCAddress = c.Heimdall.GRPCAddress + n.RunHeimdall = c.Heimdall.RunHeimdall + n.RunHeimdallArgs = c.Heimdall.RunHeimdallArgs + n.UseHeimdallApp = c.Heimdall.UseHeimdallApp + + // Developer Fake Author for producing blocks without authorisation on bor consensus + n.DevFakeAuthor = c.DevFakeAuthor + + // Developer Fake Author for producing blocks without authorisation on bor consensus + n.DevFakeAuthor = c.DevFakeAuthor + + // gas price oracle + { + n.GPO.Blocks = int(c.Gpo.Blocks) + n.GPO.Percentile = int(c.Gpo.Percentile) + n.GPO.MaxHeaderHistory = uint64(c.Gpo.MaxHeaderHistory) + n.GPO.MaxBlockHistory = uint64(c.Gpo.MaxBlockHistory) + n.GPO.MaxPrice = c.Gpo.MaxPrice + n.GPO.IgnorePrice = c.Gpo.IgnorePrice + } + + n.EnablePreimageRecording = c.EnablePreimageRecording + + // txpool options + { + n.TxPool.NoLocals = c.TxPool.NoLocals + n.TxPool.Journal = c.TxPool.Journal + n.TxPool.Rejournal = c.TxPool.Rejournal + n.TxPool.PriceLimit = c.TxPool.PriceLimit + n.TxPool.PriceBump = c.TxPool.PriceBump + n.TxPool.AccountSlots = c.TxPool.AccountSlots + n.TxPool.GlobalSlots = c.TxPool.GlobalSlots + n.TxPool.AccountQueue = c.TxPool.AccountQueue + n.TxPool.GlobalQueue = c.TxPool.GlobalQueue + n.TxPool.Lifetime = c.TxPool.LifeTime + } + + // miner options + { + n.Miner.Recommit = c.Sealer.Recommit + n.Miner.GasPrice = c.Sealer.GasPrice + n.Miner.GasCeil = c.Sealer.GasCeil + n.Miner.ExtraData = []byte(c.Sealer.ExtraData) + n.Miner.CommitInterruptFlag = c.Sealer.CommitInterruptFlag + + if etherbase := c.Sealer.Etherbase; etherbase != "" { + if !common.IsHexAddress(etherbase) { + return nil, fmt.Errorf("etherbase is not an address: %s", etherbase) + } + + n.Miner.Etherbase = common.HexToAddress(etherbase) + } + } + + // unlock accounts + if len(c.Accounts.Unlock) > 0 { + if !stack.Config().InsecureUnlockAllowed && stack.Config().ExtRPCEnabled() { + return nil, fmt.Errorf("account unlock with HTTP access is forbidden") + } + + ks := accountManager.Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) + + passwords, err := MakePasswordListFromFile(c.Accounts.PasswordFile) + if err != nil { + return nil, err + } + + if len(passwords) < len(c.Accounts.Unlock) { + return nil, fmt.Errorf("number of passwords provided (%v) is less than number of accounts (%v) to unlock", + len(passwords), len(c.Accounts.Unlock)) + } + + for i, account := range c.Accounts.Unlock { + unlockAccount(ks, account, i, passwords) + } + } + + // update for developer mode + if c.Developer.Enabled { + // Get a keystore + var ks *keystore.KeyStore + if keystores := accountManager.Backends(keystore.KeyStoreType); len(keystores) > 0 { + ks = keystores[0].(*keystore.KeyStore) + } + + // Create new developer account or reuse existing one + var ( + developer accounts.Account + passphrase string + err error + ) + + // etherbase has been set above, configuring the miner address from command line flags. + if n.Miner.Etherbase != (common.Address{}) { + developer = accounts.Account{Address: n.Miner.Etherbase} + } else if accs := ks.Accounts(); len(accs) > 0 { + developer = ks.Accounts()[0] + } else { + developer, err = ks.NewAccount(passphrase) + if err != nil { + return nil, fmt.Errorf("failed to create developer account: %v", err) + } + } + if err := ks.Unlock(developer, passphrase); err != nil { + return nil, fmt.Errorf("failed to unlock developer account: %v", err) + } + + log.Info("Using developer account", "address", developer.Address) + + // Set the Etherbase + c.Sealer.Etherbase = developer.Address.Hex() + n.Miner.Etherbase = developer.Address + + // get developer mode chain config + c.chain = chains.GetDeveloperChain(c.Developer.Period, c.Developer.GasLimit, developer.Address) + + // update the parameters + n.NetworkId = c.chain.NetworkId + n.Genesis = c.chain.Genesis + + // Update cache + c.Cache.Cache = 1024 + + // Update sync mode + c.SyncMode = "full" + + // update miner gas price + if n.Miner.GasPrice == nil { + n.Miner.GasPrice = big.NewInt(1) + } + } + + // discovery (this params should be in node.Config) + { + n.EthDiscoveryURLs = c.P2P.Discovery.DNS + n.SnapDiscoveryURLs = c.P2P.Discovery.DNS + } + + // RequiredBlocks + { + n.RequiredBlocks = map[uint64]common.Hash{} + + for k, v := range c.RequiredBlocks { + number, err := strconv.ParseUint(k, 0, 64) + if err != nil { + return nil, fmt.Errorf("invalid required block number %s: %v", k, err) + } + + var hash common.Hash + if err = hash.UnmarshalText([]byte(v)); err != nil { + return nil, fmt.Errorf("invalid required block hash %s: %v", v, err) + } + + n.RequiredBlocks[number] = hash + } + } + + // cache + { + cache := c.Cache.Cache + calcPerc := func(val uint64) int { + return int(cache * (val) / 100) + } + + // Cap the cache allowance + mem, err := gopsutil.VirtualMemory() + if err == nil { + if 32<<(^uintptr(0)>>63) == 32 && mem.Total > 2*1024*1024*1024 { + log.Warn("Lowering memory allowance on 32bit arch", "available", mem.Total/1024/1024, "addressable", 2*1024) + mem.Total = 2 * 1024 * 1024 * 1024 + } + + allowance := uint64(mem.Total / 1024 / 1024 / 3) + if cache > allowance { + log.Warn("Sanitizing cache to Go's GC limits", "provided", cache, "updated", allowance) + cache = allowance + } + } + // Tune the garbage collector + gogc := math.Max(20, math.Min(100, 100/(float64(cache)/1024))) + + log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) + godebug.SetGCPercent(int(gogc)) + + n.TrieCleanCacheJournal = c.Cache.Journal + n.TrieCleanCacheRejournal = c.Cache.Rejournal + n.DatabaseCache = calcPerc(c.Cache.PercDatabase) + n.SnapshotCache = calcPerc(c.Cache.PercSnapshot) + n.TrieCleanCache = calcPerc(c.Cache.PercTrie) + n.TrieDirtyCache = calcPerc(c.Cache.PercGc) + n.NoPrefetch = c.Cache.NoPrefetch + n.Preimages = c.Cache.Preimages + n.TxLookupLimit = c.Cache.TxLookupLimit + n.TrieTimeout = c.Cache.TrieTimeout + n.TriesInMemory = c.Cache.TriesInMemory + } + + // LevelDB + { + n.LevelDbCompactionTableSize = c.ExtraDB.LevelDbCompactionTableSize + n.LevelDbCompactionTableSizeMultiplier = c.ExtraDB.LevelDbCompactionTableSizeMultiplier + n.LevelDbCompactionTotalSize = c.ExtraDB.LevelDbCompactionTotalSize + n.LevelDbCompactionTotalSizeMultiplier = c.ExtraDB.LevelDbCompactionTotalSizeMultiplier + } + + n.RPCGasCap = c.JsonRPC.GasCap + if n.RPCGasCap != 0 { + log.Info("Set global gas cap", "cap", n.RPCGasCap) + } else { + log.Info("Global gas cap disabled") + } + + n.RPCEVMTimeout = c.JsonRPC.RPCEVMTimeout + + n.RPCTxFeeCap = c.JsonRPC.TxFeeCap + + // sync mode. It can either be "fast", "full" or "snap". We disable + // for now the "light" mode. + switch c.SyncMode { + case "full": + n.SyncMode = downloader.FullSync + case "snap": + // n.SyncMode = downloader.SnapSync // TODO(snap): Uncomment when we have snap sync working + n.SyncMode = downloader.FullSync + + log.Warn("Bor doesn't support Snap Sync yet, switching to Full Sync mode") + default: + return nil, fmt.Errorf("sync mode '%s' not found", c.SyncMode) + } + + // archive mode. It can either be "archive" or "full". + switch c.GcMode { + case "full": + n.NoPruning = false + case "archive": + n.NoPruning = true + if !n.Preimages { + n.Preimages = true + + log.Info("Enabling recording of key preimages since archive mode is used") + } + default: + return nil, fmt.Errorf("gcmode '%s' not found", c.GcMode) + } + + // snapshot disable check + if !c.Snapshot { + if n.SyncMode == downloader.SnapSync { + log.Info("Snap sync requested, enabling --snapshot") + } else { + // disable snapshot + n.TrieCleanCache += n.SnapshotCache + n.SnapshotCache = 0 + } + } + + n.BorLogs = c.BorLogs + n.DatabaseHandles = dbHandles + + n.ParallelEVM.Enable = c.ParallelEVM.Enable + n.ParallelEVM.SpeculativeProcesses = c.ParallelEVM.SpeculativeProcesses + n.RPCReturnDataLimit = c.RPCReturnDataLimit + + if c.Ancient != "" { + n.DatabaseFreezer = c.Ancient + } + + return &n, nil +} + +var ( + clientIdentifier = "bor" + gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags) + gitDate = "" // Git commit date YYYYMMDD of the release (set via linker flags) +) + +// tries unlocking the specified account a few times. +func unlockAccount(ks *keystore.KeyStore, address string, i int, passwords []string) (accounts.Account, string) { + account, err := utils.MakeAddress(ks, address) + + if err != nil { + utils.Fatalf("Could not list accounts: %v", err) + } + + for trials := 0; trials < 3; trials++ { + prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3) + password := utils.GetPassPhraseWithList(prompt, false, i, passwords) + err = ks.Unlock(account, password) + + if err == nil { + log.Info("Unlocked account", "address", account.Address.Hex()) + return account, password + } + + if err, ok := err.(*keystore.AmbiguousAddrError); ok { + log.Info("Unlocked account", "address", account.Address.Hex()) + return ambiguousAddrRecovery(ks, err, password), password + } + + if err != keystore.ErrDecrypt { + // No need to prompt again if the error is not decryption-related. + break + } + } + // All trials expended to unlock account, bail out + utils.Fatalf("Failed to unlock account %s (%v)", address, err) + + return accounts.Account{}, "" +} + +func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrError, auth string) accounts.Account { + log.Warn("Multiple key files exist for", "address", err.Addr) + + for _, a := range err.Matches { + log.Info("Multiple keys", "file", a.URL.String()) + } + + log.Info("Testing your password against all of them...") + + var match *accounts.Account + + for _, a := range err.Matches { + if err := ks.Unlock(a, auth); err == nil { + // nolint: gosec, exportloopref + match = &a + break + } + } + + if match == nil { + utils.Fatalf("None of the listed files could be unlocked.") + } + + log.Info("Your password unlocked", "key", match.URL.String()) + log.Warn("In order to avoid this warning, you need to remove the following duplicate key files:") + + for _, a := range err.Matches { + if a != *match { + log.Warn("Duplicate", "key", a.URL.String()) + } + } + + return *match +} + +// setNodeKey creates a node key from set command line flags, either loading it +// from a file or as a specified hex value. If neither flags were provided, this +// method returns nil and an emphemeral key is to be generated. +func getNodeKey(hex string, file string) *ecdsa.PrivateKey { + var ( + key *ecdsa.PrivateKey + err error + ) + + switch { + case file != "" && hex != "": + utils.Fatalf("Options %q and %q are mutually exclusive", file, hex) + case file != "": + if key, err = crypto.LoadECDSA(file); err != nil { + utils.Fatalf("Option %q: %v", file, err) + } + + return key + case hex != "": + if key, err = crypto.HexToECDSA(hex); err != nil { + utils.Fatalf("Option %q: %v", hex, err) + } + + return key + } + + return nil +} + +func (c *Config) buildNode() (*node.Config, error) { + ipcPath := "" + if !c.JsonRPC.IPCDisable { + ipcPath = clientIdentifier + ".ipc" + if c.JsonRPC.IPCPath != "" { + ipcPath = c.JsonRPC.IPCPath + } + } + + cfg := &node.Config{ + Name: clientIdentifier, + DataDir: c.DataDir, + DBEngine: c.DBEngine, + KeyStoreDir: c.KeyStoreDir, + UseLightweightKDF: c.Accounts.UseLightweightKDF, + InsecureUnlockAllowed: c.Accounts.AllowInsecureUnlock, + Version: params.VersionWithCommit(gitCommit, gitDate), + IPCPath: ipcPath, + AllowUnprotectedTxs: c.JsonRPC.AllowUnprotectedTxs, + EnablePersonal: c.JsonRPC.EnablePersonal, + P2P: p2p.Config{ + MaxPeers: int(c.P2P.MaxPeers), + MaxPendingPeers: int(c.P2P.MaxPendPeers), + ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)), + DiscoveryV5: c.P2P.Discovery.V5Enabled, + TxArrivalWait: c.P2P.TxArrivalWait, + }, + HTTPModules: c.JsonRPC.Http.API, + HTTPCors: c.JsonRPC.Http.Cors, + HTTPVirtualHosts: c.JsonRPC.Http.VHost, + HTTPPathPrefix: c.JsonRPC.Http.Prefix, + WSModules: c.JsonRPC.Ws.API, + WSOrigins: c.JsonRPC.Ws.Origins, + WSPathPrefix: c.JsonRPC.Ws.Prefix, + GraphQLCors: c.JsonRPC.Graphql.Cors, + GraphQLVirtualHosts: c.JsonRPC.Graphql.VHost, + HTTPTimeouts: rpc.HTTPTimeouts{ + ReadTimeout: c.JsonRPC.HttpTimeout.ReadTimeout, + WriteTimeout: c.JsonRPC.HttpTimeout.WriteTimeout, + IdleTimeout: c.JsonRPC.HttpTimeout.IdleTimeout, + }, + JWTSecret: c.JsonRPC.Auth.JWTSecret, + AuthPort: int(c.JsonRPC.Auth.Port), + AuthAddr: c.JsonRPC.Auth.Addr, + AuthVirtualHosts: c.JsonRPC.Auth.VHosts, + RPCBatchLimit: c.RPCBatchLimit, + WSJsonRPCExecutionPoolSize: c.JsonRPC.Ws.ExecutionPoolSize, + WSJsonRPCExecutionPoolRequestTimeout: c.JsonRPC.Ws.ExecutionPoolRequestTimeout, + HTTPJsonRPCExecutionPoolSize: c.JsonRPC.Http.ExecutionPoolSize, + HTTPJsonRPCExecutionPoolRequestTimeout: c.JsonRPC.Http.ExecutionPoolRequestTimeout, + } + + if c.P2P.NetRestrict != "" { + list, err := netutil.ParseNetlist(c.P2P.NetRestrict) + if err != nil { + utils.Fatalf("Option %q: %v", c.P2P.NetRestrict, err) + } + + cfg.P2P.NetRestrict = list + } + + key := getNodeKey(c.P2P.NodeKeyHex, c.P2P.NodeKey) + if key != nil { + cfg.P2P.PrivateKey = key + } + + // dev mode + if c.Developer.Enabled { + cfg.UseLightweightKDF = true + + // disable p2p networking + c.P2P.NoDiscover = true + cfg.P2P.ListenAddr = "" + cfg.P2P.NoDial = true + cfg.P2P.DiscoveryV5 = false + + // enable JsonRPC HTTP API + c.JsonRPC.Http.Enabled = true + cfg.HTTPModules = []string{"admin", "debug", "eth", "miner", "net", "personal", "txpool", "web3", "bor"} + } + + // enable jsonrpc endpoints + { + if c.JsonRPC.Http.Enabled { + cfg.HTTPHost = c.JsonRPC.Http.Host + cfg.HTTPPort = int(c.JsonRPC.Http.Port) + } + + if c.JsonRPC.Ws.Enabled { + cfg.WSHost = c.JsonRPC.Ws.Host + cfg.WSPort = int(c.JsonRPC.Ws.Port) + } + } + + natif, err := nat.Parse(c.P2P.NAT) + if err != nil { + return nil, fmt.Errorf("wrong 'nat' flag: %v", err) + } + + cfg.P2P.NAT = natif + + // only check for non-developer modes + if !c.Developer.Enabled { + // Discovery + // if no bootnodes are defined, use the ones from the chain file. + bootnodes := c.P2P.Discovery.Bootnodes + if len(bootnodes) == 0 { + bootnodes = c.chain.Bootnodes + } + + if cfg.P2P.BootstrapNodes, err = parseBootnodes(bootnodes); err != nil { + return nil, err + } + + if cfg.P2P.BootstrapNodesV5, err = parseBootnodes(c.P2P.Discovery.BootnodesV5); err != nil { + return nil, err + } + + if cfg.P2P.StaticNodes, err = parseBootnodes(c.P2P.Discovery.StaticNodes); err != nil { + return nil, err + } + + if len(cfg.P2P.StaticNodes) == 0 { + cfg.P2P.StaticNodes = cfg.StaticNodes() + } + + if cfg.P2P.TrustedNodes, err = parseBootnodes(c.P2P.Discovery.TrustedNodes); err != nil { + return nil, err + } + + if len(cfg.P2P.TrustedNodes) == 0 { + cfg.P2P.TrustedNodes = cfg.TrustedNodes() + } + } + + if c.P2P.NoDiscover { + // Disable peer discovery + cfg.P2P.NoDiscovery = true + } + + return cfg, nil +} + +func (c *Config) Merge(cc ...*Config) error { + for _, elem := range cc { + if err := mergo.Merge(c, elem, mergo.WithOverwriteWithEmptyValue); err != nil { + return fmt.Errorf("failed to merge configurations: %v", err) + } + } + + return nil +} + +func MakeDatabaseHandles(max int) (int, error) { + limit, err := fdlimit.Maximum() + if err != nil { + return -1, err + } + + switch { + case max == 0: + // User didn't specify a meaningful value, use system limits + case max < 128: + // User specified something unhealthy, just use system defaults + log.Error("File descriptor limit invalid (<128)", "had", max, "updated", limit) + case max > limit: + // User requested more than the OS allows, notify that we can't allocate it + log.Warn("Requested file descriptors denied by OS", "req", max, "limit", limit) + default: + // User limit is meaningful and within allowed range, use that + limit = max + } + + raised, err := fdlimit.Raise(uint64(limit)) + if err != nil { + return -1, err + } + + return int(raised / 2), nil // Leave half for networking and other stuff +} + +func parseBootnodes(urls []string) ([]*enode.Node, error) { + dst := []*enode.Node{} + + for _, url := range urls { + if url != "" { + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + return nil, fmt.Errorf("invalid bootstrap url '%s': %v", url, err) + } + + dst = append(dst, node) + } + } + + return dst, nil +} + +func DefaultDataDir() string { + // Try to place the data folder in the user's home dir + home, _ := homedir.Dir() + if home == "" { + // we cannot guess a stable location + return "" + } + + switch runtime.GOOS { + case "darwin": + return filepath.Join(home, "Library", "Bor") + case "windows": + appdata := os.Getenv("LOCALAPPDATA") + if appdata == "" { + // Windows XP and below don't have LocalAppData. + panic("environment variable LocalAppData is undefined") + } + + return filepath.Join(appdata, "Bor") + default: + return filepath.Join(home, ".bor") + } +} + +func Hostname() string { + hostname, err := os.Hostname() + if err != nil { + return "bor" + } + + return hostname +} + +func MakePasswordListFromFile(path string) ([]string, error) { + text, err := ioutil.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read password file: %v", err) + } + + lines := strings.Split(string(text), "\n") + + // Sanitise DOS line endings. + for i := range lines { + lines[i] = strings.TrimRight(lines[i], "\r") + } + + return lines, nil +} diff --git a/internal/cli/server/config_legacy.go b/internal/cli/server/config_legacy.go new file mode 100644 index 0000000000..ccc05eb4a7 --- /dev/null +++ b/internal/cli/server/config_legacy.go @@ -0,0 +1,33 @@ +package server + +import ( + "fmt" + "os" + + "github.com/BurntSushi/toml" +) + +func readLegacyConfig(path string) (*Config, error) { + data, err := os.ReadFile(path) + tomlData := string(data) + + if err != nil { + return nil, fmt.Errorf("failed to read toml config file: %v", err) + } + + conf := *DefaultConfig() + + if _, err := toml.Decode(tomlData, &conf); err != nil { + return nil, fmt.Errorf("failed to decode toml config file: %v", err) + } + + if err := conf.fillBigInt(); err != nil { + return nil, err + } + + if err := conf.fillTimeDurations(); err != nil { + return nil, err + } + + return &conf, nil +} diff --git a/internal/cli/server/config_legacy_test.go b/internal/cli/server/config_legacy_test.go new file mode 100644 index 0000000000..8ac61b094f --- /dev/null +++ b/internal/cli/server/config_legacy_test.go @@ -0,0 +1,41 @@ +package server + +import ( + "math/big" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestConfigLegacy(t *testing.T) { + readFile := func(path string) { + expectedConfig, err := readLegacyConfig(path) + assert.NoError(t, err) + + testConfig := DefaultConfig() + + testConfig.DataDir = "./data" + testConfig.Snapshot = false + testConfig.RequiredBlocks = map[string]string{ + "31000000": "0x2087b9e2b353209c2c21e370c82daa12278efd0fe5f0febe6c29035352cf050e", + "32000000": "0x875500011e5eecc0c554f95d07b31cf59df4ca2505f4dbbfffa7d4e4da917c68", + } + testConfig.P2P.MaxPeers = 30 + testConfig.TxPool.Locals = []string{} + testConfig.TxPool.LifeTime = time.Second + testConfig.Sealer.Enabled = true + testConfig.Sealer.GasCeil = 30000000 + testConfig.Sealer.GasPrice = big.NewInt(1000000000) + testConfig.Gpo.IgnorePrice = big.NewInt(4) + testConfig.Cache.Cache = 1024 + testConfig.Cache.Rejournal = time.Second + + assert.Equal(t, expectedConfig, testConfig) + } + + // read file in hcl format + t.Run("toml", func(t *testing.T) { + readFile("./testdata/test.toml") + }) +} diff --git a/internal/cli/server/config_test.go b/internal/cli/server/config_test.go new file mode 100644 index 0000000000..3e6bb76b59 --- /dev/null +++ b/internal/cli/server/config_test.go @@ -0,0 +1,135 @@ +package server + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestConfigDefault(t *testing.T) { + // the default config should work out of the box + config := DefaultConfig() + assert.NoError(t, config.loadChain()) + + _, err := config.buildNode() + assert.NoError(t, err) + + _, err = config.buildEth(nil, nil) + assert.NoError(t, err) +} + +func TestConfigMerge(t *testing.T) { + c0 := &Config{ + Chain: "0", + Snapshot: true, + RequiredBlocks: map[string]string{ + "a": "b", + }, + TxPool: &TxPoolConfig{ + LifeTime: 5 * time.Second, + }, + P2P: &P2PConfig{ + Discovery: &P2PDiscovery{ + StaticNodes: []string{ + "a", + }, + }, + }, + } + c1 := &Config{ + Chain: "1", + RequiredBlocks: map[string]string{ + "b": "c", + }, + P2P: &P2PConfig{ + MaxPeers: 10, + Discovery: &P2PDiscovery{ + StaticNodes: []string{ + "b", + }, + }, + }, + } + + expected := &Config{ + Chain: "1", + Snapshot: false, + RequiredBlocks: map[string]string{ + "a": "b", + "b": "c", + }, + P2P: &P2PConfig{ + MaxPeers: 10, + Discovery: &P2PDiscovery{ + StaticNodes: []string{ + "b", + }, + }, + }, + } + + assert.NoError(t, c0.Merge(c1)) + assert.Equal(t, c0, expected) +} + +func TestDefaultDatatypeOverride(t *testing.T) { + t.Parallel() + + // This test is specific to `maxpeers` flag (for now) to check + // if default datatype value (0 in case of uint64) is overridden. + c0 := &Config{ + P2P: &P2PConfig{ + MaxPeers: 30, + }, + } + + c1 := &Config{ + P2P: &P2PConfig{ + MaxPeers: 0, + }, + } + + expected := &Config{ + P2P: &P2PConfig{ + MaxPeers: 0, + }, + } + + assert.NoError(t, c0.Merge(c1)) + assert.Equal(t, c0, expected) +} + +var dummyEnodeAddr = "enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303" + +func TestConfigBootnodesDefault(t *testing.T) { + t.Run("EmptyBootnodes", func(t *testing.T) { + // if no bootnodes are specific, we use the ones from the genesis chain + config := DefaultConfig() + assert.NoError(t, config.loadChain()) + + cfg, err := config.buildNode() + assert.NoError(t, err) + assert.NotEmpty(t, cfg.P2P.BootstrapNodes) + }) + t.Run("NotEmptyBootnodes", func(t *testing.T) { + // if bootnodes specific, DO NOT load the genesis bootnodes + config := DefaultConfig() + config.P2P.Discovery.Bootnodes = []string{dummyEnodeAddr} + + cfg, err := config.buildNode() + assert.NoError(t, err) + assert.Len(t, cfg.P2P.BootstrapNodes, 1) + }) +} + +func TestMakePasswordListFromFile(t *testing.T) { + t.Parallel() + + t.Run("ReadPasswordFile", func(t *testing.T) { + t.Parallel() + + result, _ := MakePasswordListFromFile("./testdata/password.txt") + assert.Equal(t, []string{"test1", "test2"}, result) + }) +} diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go new file mode 100644 index 0000000000..1edacc9ac0 --- /dev/null +++ b/internal/cli/server/flags.go @@ -0,0 +1,1010 @@ +package server + +import ( + "github.com/ethereum/go-ethereum/internal/cli/flagset" +) + +func (c *Command) Flags() *flagset.Flagset { + c.cliConfig = DefaultConfig() + + f := flagset.NewFlagSet("server") + + f.StringFlag(&flagset.StringFlag{ + Name: "chain", + Usage: "Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file", + Value: &c.cliConfig.Chain, + Default: c.cliConfig.Chain, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "identity", + Usage: "Name/Identity of the node", + Value: &c.cliConfig.Identity, + Default: c.cliConfig.Identity, + HideDefaultFromDoc: true, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "verbosity", + Usage: "Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3", + Value: &c.cliConfig.Verbosity, + Default: c.cliConfig.Verbosity, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "log-level", + Usage: "Log level for the server (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead", + Value: &c.cliConfig.LogLevel, + Default: c.cliConfig.LogLevel, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "datadir", + Usage: "Path of the data directory to store information", + Value: &c.cliConfig.DataDir, + Default: c.cliConfig.DataDir, + HideDefaultFromDoc: true, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "vmdebug", + Usage: "Record information useful for VM and contract debugging", + Value: &c.cliConfig.EnablePreimageRecording, + Default: c.cliConfig.EnablePreimageRecording, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "datadir.ancient", + Usage: "Data directory for ancient chain segments (default = inside chaindata)", + Value: &c.cliConfig.Ancient, + Default: c.cliConfig.Ancient, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "db.engine", + Usage: "Backing database implementation to use ('leveldb' or 'pebble')", + Value: &c.cliConfig.DBEngine, + Default: c.cliConfig.DBEngine, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "keystore", + Usage: "Path of the directory where keystores are located", + Value: &c.cliConfig.KeyStoreDir, + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "rpc.batchlimit", + Usage: "Maximum number of messages in a batch (default=100, use 0 for no limits)", + Value: &c.cliConfig.RPCBatchLimit, + Default: c.cliConfig.RPCBatchLimit, + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "rpc.returndatalimit", + Usage: "Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits)", + Value: &c.cliConfig.RPCReturnDataLimit, + Default: c.cliConfig.RPCReturnDataLimit, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "config", + Usage: "Path to the TOML configuration file", + Value: &c.configFile, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "syncmode", + Usage: `Blockchain sync mode (only "full" sync supported)`, + Value: &c.cliConfig.SyncMode, + Default: c.cliConfig.SyncMode, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "gcmode", + Usage: `Blockchain garbage collection mode ("full", "archive")`, + Value: &c.cliConfig.GcMode, + Default: c.cliConfig.GcMode, + }) + f.MapStringFlag(&flagset.MapStringFlag{ + Name: "eth.requiredblocks", + Usage: "Comma separated block number-to-hash mappings to require for peering (=)", + Value: &c.cliConfig.RequiredBlocks, + Default: c.cliConfig.RequiredBlocks, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "snapshot", + Usage: `Enables the snapshot-database mode`, + Value: &c.cliConfig.Snapshot, + Default: c.cliConfig.Snapshot, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.logs", + Usage: `Enables bor log retrieval`, + Value: &c.cliConfig.BorLogs, + Default: c.cliConfig.BorLogs, + }) + + // logging related flags (log-level and verbosity is present above, it will be removed soon) + f.StringFlag(&flagset.StringFlag{ + Name: "vmodule", + Usage: "Per-module verbosity: comma-separated list of = (e.g. eth/*=5,p2p=4)", + Value: &c.cliConfig.Logging.Vmodule, + Default: c.cliConfig.Logging.Vmodule, + Group: "Logging", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "log.json", + Usage: "Format logs with JSON", + Value: &c.cliConfig.Logging.Json, + Default: c.cliConfig.Logging.Json, + Group: "Logging", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "log.backtrace", + Usage: "Request a stack trace at a specific logging statement (e.g. 'block.go:271')", + Value: &c.cliConfig.Logging.Backtrace, + Default: c.cliConfig.Logging.Backtrace, + Group: "Logging", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "log.debug", + Usage: "Prepends log messages with call-site location (file and line number)", + Value: &c.cliConfig.Logging.Debug, + Default: c.cliConfig.Logging.Debug, + Group: "Logging", + }) + + // heimdall + f.StringFlag(&flagset.StringFlag{ + Name: "bor.heimdall", + Usage: "URL of Heimdall service", + Value: &c.cliConfig.Heimdall.URL, + Default: c.cliConfig.Heimdall.URL, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.withoutheimdall", + Usage: "Run without Heimdall service (for testing purpose)", + Value: &c.cliConfig.Heimdall.Without, + Default: c.cliConfig.Heimdall.Without, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.devfakeauthor", + Usage: "Run miner without validator set authorization [dev mode] : Use with '--bor.withoutheimdall'", + Value: &c.cliConfig.DevFakeAuthor, + Default: c.cliConfig.DevFakeAuthor, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "bor.heimdallgRPC", + Usage: "Address of Heimdall gRPC service", + Value: &c.cliConfig.Heimdall.GRPCAddress, + Default: c.cliConfig.Heimdall.GRPCAddress, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.runheimdall", + Usage: "Run Heimdall service as a child process", + Value: &c.cliConfig.Heimdall.RunHeimdall, + Default: c.cliConfig.Heimdall.RunHeimdall, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "bor.runheimdallargs", + Usage: "Arguments to pass to Heimdall service", + Value: &c.cliConfig.Heimdall.RunHeimdallArgs, + Default: c.cliConfig.Heimdall.RunHeimdallArgs, + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.useheimdallapp", + Usage: "Use child heimdall process to fetch data, Only works when bor.runheimdall is true", + Value: &c.cliConfig.Heimdall.UseHeimdallApp, + Default: c.cliConfig.Heimdall.UseHeimdallApp, + }) + + // txpool options + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "txpool.locals", + Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)", + Value: &c.cliConfig.TxPool.Locals, + Default: c.cliConfig.TxPool.Locals, + Group: "Transaction Pool", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "txpool.nolocals", + Usage: "Disables price exemptions for locally submitted transactions", + Value: &c.cliConfig.TxPool.NoLocals, + Default: c.cliConfig.TxPool.NoLocals, + Group: "Transaction Pool", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "txpool.journal", + Usage: "Disk journal for local transaction to survive node restarts", + Value: &c.cliConfig.TxPool.Journal, + Default: c.cliConfig.TxPool.Journal, + Group: "Transaction Pool", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "txpool.rejournal", + Usage: "Time interval to regenerate the local transaction journal", + Value: &c.cliConfig.TxPool.Rejournal, + Default: c.cliConfig.TxPool.Rejournal, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.pricelimit", + Usage: "Minimum gas price limit to enforce for acceptance into the pool", + Value: &c.cliConfig.TxPool.PriceLimit, + Default: c.cliConfig.TxPool.PriceLimit, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.pricebump", + Usage: "Price bump percentage to replace an already existing transaction", + Value: &c.cliConfig.TxPool.PriceBump, + Default: c.cliConfig.TxPool.PriceBump, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.accountslots", + Usage: "Minimum number of executable transaction slots guaranteed per account", + Value: &c.cliConfig.TxPool.AccountSlots, + Default: c.cliConfig.TxPool.AccountSlots, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.globalslots", + Usage: "Maximum number of executable transaction slots for all accounts", + Value: &c.cliConfig.TxPool.GlobalSlots, + Default: c.cliConfig.TxPool.GlobalSlots, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.accountqueue", + Usage: "Maximum number of non-executable transaction slots permitted per account", + Value: &c.cliConfig.TxPool.AccountQueue, + Default: c.cliConfig.TxPool.AccountQueue, + Group: "Transaction Pool", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txpool.globalqueue", + Usage: "Maximum number of non-executable transaction slots for all accounts", + Value: &c.cliConfig.TxPool.GlobalQueue, + Default: c.cliConfig.TxPool.GlobalQueue, + Group: "Transaction Pool", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "txpool.lifetime", + Usage: "Maximum amount of time non-executable transaction are queued", + Value: &c.cliConfig.TxPool.LifeTime, + Default: c.cliConfig.TxPool.LifeTime, + Group: "Transaction Pool", + }) + + // sealer options + f.BoolFlag(&flagset.BoolFlag{ + Name: "mine", + Usage: "Enable mining", + Value: &c.cliConfig.Sealer.Enabled, + Default: c.cliConfig.Sealer.Enabled, + Group: "Sealer", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "miner.etherbase", + Usage: "Public address for block mining rewards", + Value: &c.cliConfig.Sealer.Etherbase, + Default: c.cliConfig.Sealer.Etherbase, + Group: "Sealer", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "miner.extradata", + Usage: "Block extra data set by the miner (default = client version)", + Value: &c.cliConfig.Sealer.ExtraData, + Default: c.cliConfig.Sealer.ExtraData, + Group: "Sealer", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "miner.gaslimit", + Usage: "Target gas ceiling (gas limit) for mined blocks", + Value: &c.cliConfig.Sealer.GasCeil, + Default: c.cliConfig.Sealer.GasCeil, + Group: "Sealer", + }) + f.BigIntFlag(&flagset.BigIntFlag{ + Name: "miner.gasprice", + Usage: "Minimum gas price for mining a transaction", + Value: c.cliConfig.Sealer.GasPrice, + Group: "Sealer", + Default: c.cliConfig.Sealer.GasPrice, + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "miner.recommit", + Usage: "The time interval for miner to re-create mining work", + Value: &c.cliConfig.Sealer.Recommit, + Default: c.cliConfig.Sealer.Recommit, + Group: "Sealer", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "miner.interruptcommit", + Usage: "Interrupt block commit when block creation time is passed", + Value: &c.cliConfig.Sealer.CommitInterruptFlag, + Default: c.cliConfig.Sealer.CommitInterruptFlag, + Group: "Sealer", + }) + + // ethstats + f.StringFlag(&flagset.StringFlag{ + Name: "ethstats", + Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)", + Value: &c.cliConfig.Ethstats, + Default: c.cliConfig.Ethstats, + }) + + // gas price oracle + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "gpo.blocks", + Usage: "Number of recent blocks to check for gas prices", + Value: &c.cliConfig.Gpo.Blocks, + Default: c.cliConfig.Gpo.Blocks, + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "gpo.percentile", + Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices", + Value: &c.cliConfig.Gpo.Percentile, + Default: c.cliConfig.Gpo.Percentile, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "gpo.maxheaderhistory", + Usage: "Maximum header history of gasprice oracle", + Value: &c.cliConfig.Gpo.MaxHeaderHistory, + Default: c.cliConfig.Gpo.MaxHeaderHistory, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "gpo.maxblockhistory", + Usage: "Maximum block history of gasprice oracle", + Value: &c.cliConfig.Gpo.MaxBlockHistory, + Default: c.cliConfig.Gpo.MaxBlockHistory, + }) + f.BigIntFlag(&flagset.BigIntFlag{ + Name: "gpo.maxprice", + Usage: "Maximum gas price will be recommended by gpo", + Value: c.cliConfig.Gpo.MaxPrice, + Default: c.cliConfig.Gpo.MaxPrice, + }) + f.BigIntFlag(&flagset.BigIntFlag{ + Name: "gpo.ignoreprice", + Usage: "Gas price below which gpo will ignore transactions", + Value: c.cliConfig.Gpo.IgnorePrice, + Default: c.cliConfig.Gpo.IgnorePrice, + }) + + // cache options + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache", + Usage: "Megabytes of memory allocated to internal caching", + Value: &c.cliConfig.Cache.Cache, + Default: c.cliConfig.Cache.Cache, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.database", + Usage: "Percentage of cache memory allowance to use for database io", + Value: &c.cliConfig.Cache.PercDatabase, + Default: c.cliConfig.Cache.PercDatabase, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.trie", + Usage: "Percentage of cache memory allowance to use for trie caching", + Value: &c.cliConfig.Cache.PercTrie, + Default: c.cliConfig.Cache.PercTrie, + Group: "Cache", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "cache.trie.journal", + Usage: "Disk journal directory for trie cache to survive node restarts", + Value: &c.cliConfig.Cache.Journal, + Default: c.cliConfig.Cache.Journal, + Group: "Cache", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "cache.trie.rejournal", + Usage: "Time interval to regenerate the trie cache journal", + Value: &c.cliConfig.Cache.Rejournal, + Default: c.cliConfig.Cache.Rejournal, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.gc", + Usage: "Percentage of cache memory allowance to use for trie pruning", + Value: &c.cliConfig.Cache.PercGc, + Default: c.cliConfig.Cache.PercGc, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.snapshot", + Usage: "Percentage of cache memory allowance to use for snapshot caching", + Value: &c.cliConfig.Cache.PercSnapshot, + Default: c.cliConfig.Cache.PercSnapshot, + Group: "Cache", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "cache.noprefetch", + Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)", + Value: &c.cliConfig.Cache.NoPrefetch, + Default: c.cliConfig.Cache.NoPrefetch, + Group: "Cache", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "cache.preimages", + Usage: "Enable recording the SHA3/keccak preimages of trie keys", + Value: &c.cliConfig.Cache.Preimages, + Default: c.cliConfig.Cache.Preimages, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.triesinmemory", + Usage: "Number of block states (tries) to keep in memory (default = 128)", + Value: &c.cliConfig.Cache.TriesInMemory, + Default: c.cliConfig.Cache.TriesInMemory, + Group: "Cache", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "txlookuplimit", + Usage: "Number of recent blocks to maintain transactions index for", + Value: &c.cliConfig.Cache.TxLookupLimit, + Default: c.cliConfig.Cache.TxLookupLimit, + Group: "Cache", + }) + f.IntFlag(&flagset.IntFlag{ + Name: "fdlimit", + Usage: "Raise the open file descriptor resource limit (default = system fd limit)", + Value: &c.cliConfig.Cache.FDLimit, + Default: c.cliConfig.Cache.FDLimit, + Group: "Cache", + }) + + // LevelDB options + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "leveldb.compaction.table.size", + Usage: "LevelDB SSTable/file size in mebibytes", + Value: &c.cliConfig.ExtraDB.LevelDbCompactionTableSize, + Default: c.cliConfig.ExtraDB.LevelDbCompactionTableSize, + Group: "ExtraDB", + }) + f.Float64Flag(&flagset.Float64Flag{ + Name: "leveldb.compaction.table.size.multiplier", + Usage: "Multiplier on LevelDB SSTable/file size. Size for a level is determined by: `leveldb.compaction.table.size * (leveldb.compaction.table.size.multiplier ^ Level)`", + Value: &c.cliConfig.ExtraDB.LevelDbCompactionTableSizeMultiplier, + Default: c.cliConfig.ExtraDB.LevelDbCompactionTableSizeMultiplier, + Group: "ExtraDB", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "leveldb.compaction.total.size", + Usage: "Total size in mebibytes of SSTables in a given LevelDB level. Size for a level is determined by: `leveldb.compaction.total.size * (leveldb.compaction.total.size.multiplier ^ Level)`", + Value: &c.cliConfig.ExtraDB.LevelDbCompactionTotalSize, + Default: c.cliConfig.ExtraDB.LevelDbCompactionTotalSize, + Group: "ExtraDB", + }) + f.Float64Flag(&flagset.Float64Flag{ + Name: "leveldb.compaction.total.size.multiplier", + Usage: "Multiplier on level size on LevelDB levels. Size for a level is determined by: `leveldb.compaction.total.size * (leveldb.compaction.total.size.multiplier ^ Level)`", + Value: &c.cliConfig.ExtraDB.LevelDbCompactionTotalSizeMultiplier, + Default: c.cliConfig.ExtraDB.LevelDbCompactionTotalSizeMultiplier, + Group: "ExtraDB", + }) + + // rpc options + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "rpc.gascap", + Usage: "Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)", + Value: &c.cliConfig.JsonRPC.GasCap, + Default: c.cliConfig.JsonRPC.GasCap, + Group: "JsonRPC", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "rpc.evmtimeout", + Usage: "Sets a timeout used for eth_call (0=infinite)", + Value: &c.cliConfig.JsonRPC.RPCEVMTimeout, + Default: c.cliConfig.JsonRPC.RPCEVMTimeout, + Group: "JsonRPC", + }) + f.Float64Flag(&flagset.Float64Flag{ + Name: "rpc.txfeecap", + Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)", + Value: &c.cliConfig.JsonRPC.TxFeeCap, + Default: c.cliConfig.JsonRPC.TxFeeCap, + Group: "JsonRPC", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "rpc.allow-unprotected-txs", + Usage: "Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC", + Value: &c.cliConfig.JsonRPC.AllowUnprotectedTxs, + Default: c.cliConfig.JsonRPC.AllowUnprotectedTxs, + Group: "JsonRPC", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "rpc.enabledeprecatedpersonal", + Usage: "Enables the (deprecated) personal namespace", + Value: &c.cliConfig.JsonRPC.EnablePersonal, + Default: c.cliConfig.JsonRPC.EnablePersonal, + Group: "JsonRPC", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "ipcdisable", + Usage: "Disable the IPC-RPC server", + Value: &c.cliConfig.JsonRPC.IPCDisable, + Default: c.cliConfig.JsonRPC.IPCDisable, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "ipcpath", + Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)", + Value: &c.cliConfig.JsonRPC.IPCPath, + Default: c.cliConfig.JsonRPC.IPCPath, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "authrpc.jwtsecret", + Usage: "Path to a JWT secret to use for authenticated RPC endpoints", + Value: &c.cliConfig.JsonRPC.Auth.JWTSecret, + Default: c.cliConfig.JsonRPC.Auth.JWTSecret, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "authrpc.addr", + Usage: "Listening address for authenticated APIs", + Value: &c.cliConfig.JsonRPC.Auth.Addr, + Default: c.cliConfig.JsonRPC.Auth.Addr, + Group: "JsonRPC", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "authrpc.port", + Usage: "Listening port for authenticated APIs", + Value: &c.cliConfig.JsonRPC.Auth.Port, + Default: c.cliConfig.JsonRPC.Auth.Port, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "authrpc.vhosts", + Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", + Value: &c.cliConfig.JsonRPC.Auth.VHosts, + Default: c.cliConfig.JsonRPC.Auth.VHosts, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "http.corsdomain", + Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", + Value: &c.cliConfig.JsonRPC.Http.Cors, + Default: c.cliConfig.JsonRPC.Http.Cors, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "http.vhosts", + Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", + Value: &c.cliConfig.JsonRPC.Http.VHost, + Default: c.cliConfig.JsonRPC.Http.VHost, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "ws.origins", + Usage: "Origins from which to accept websockets requests", + Value: &c.cliConfig.JsonRPC.Ws.Origins, + Default: c.cliConfig.JsonRPC.Ws.Origins, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "graphql.corsdomain", + Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", + Value: &c.cliConfig.JsonRPC.Graphql.Cors, + Default: c.cliConfig.JsonRPC.Graphql.Cors, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "graphql.vhosts", + Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", + Value: &c.cliConfig.JsonRPC.Graphql.VHost, + Default: c.cliConfig.JsonRPC.Graphql.VHost, + Group: "JsonRPC", + }) + + // http options + f.BoolFlag(&flagset.BoolFlag{ + Name: "http", + Usage: "Enable the HTTP-RPC server", + Value: &c.cliConfig.JsonRPC.Http.Enabled, + Default: c.cliConfig.JsonRPC.Http.Enabled, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "http.addr", + Usage: "HTTP-RPC server listening interface", + Value: &c.cliConfig.JsonRPC.Http.Host, + Default: c.cliConfig.JsonRPC.Http.Host, + Group: "JsonRPC", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "http.port", + Usage: "HTTP-RPC server listening port", + Value: &c.cliConfig.JsonRPC.Http.Port, + Default: c.cliConfig.JsonRPC.Http.Port, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "http.rpcprefix", + Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", + Value: &c.cliConfig.JsonRPC.Http.Prefix, + Default: c.cliConfig.JsonRPC.Http.Prefix, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "http.api", + Usage: "API's offered over the HTTP-RPC interface", + Value: &c.cliConfig.JsonRPC.Http.API, + Default: c.cliConfig.JsonRPC.Http.API, + Group: "JsonRPC", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "http.ep-size", + Usage: "Maximum size of workers to run in rpc execution pool for HTTP requests", + Value: &c.cliConfig.JsonRPC.Http.ExecutionPoolSize, + Default: c.cliConfig.JsonRPC.Http.ExecutionPoolSize, + Group: "JsonRPC", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "http.ep-requesttimeout", + Usage: "Request Timeout for rpc execution pool for HTTP requests", + Value: &c.cliConfig.JsonRPC.Http.ExecutionPoolRequestTimeout, + Default: c.cliConfig.JsonRPC.Http.ExecutionPoolRequestTimeout, + Group: "JsonRPC", + }) + + // ws options + f.BoolFlag(&flagset.BoolFlag{ + Name: "ws", + Usage: "Enable the WS-RPC server", + Value: &c.cliConfig.JsonRPC.Ws.Enabled, + Default: c.cliConfig.JsonRPC.Ws.Enabled, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "ws.addr", + Usage: "WS-RPC server listening interface", + Value: &c.cliConfig.JsonRPC.Ws.Host, + Default: c.cliConfig.JsonRPC.Ws.Host, + Group: "JsonRPC", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "ws.port", + Usage: "WS-RPC server listening port", + Value: &c.cliConfig.JsonRPC.Ws.Port, + Default: c.cliConfig.JsonRPC.Ws.Port, + Group: "JsonRPC", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "ws.rpcprefix", + Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", + Value: &c.cliConfig.JsonRPC.Ws.Prefix, + Default: c.cliConfig.JsonRPC.Ws.Prefix, + Group: "JsonRPC", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "ws.api", + Usage: "API's offered over the WS-RPC interface", + Value: &c.cliConfig.JsonRPC.Ws.API, + Default: c.cliConfig.JsonRPC.Ws.API, + Group: "JsonRPC", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "ws.ep-size", + Usage: "Maximum size of workers to run in rpc execution pool for WS requests", + Value: &c.cliConfig.JsonRPC.Ws.ExecutionPoolSize, + Default: c.cliConfig.JsonRPC.Ws.ExecutionPoolSize, + Group: "JsonRPC", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "ws.ep-requesttimeout", + Usage: "Request Timeout for rpc execution pool for WS requests", + Value: &c.cliConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout, + Default: c.cliConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout, + Group: "JsonRPC", + }) + + // graphql options + f.BoolFlag(&flagset.BoolFlag{ + Name: "graphql", + Usage: "Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.", + Value: &c.cliConfig.JsonRPC.Graphql.Enabled, + Default: c.cliConfig.JsonRPC.Graphql.Enabled, + Group: "JsonRPC", + }) + + // p2p options + f.StringFlag(&flagset.StringFlag{ + Name: "bind", + Usage: "Network binding address", + Value: &c.cliConfig.P2P.Bind, + Default: c.cliConfig.P2P.Bind, + Group: "P2P", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "port", + Usage: "Network listening port", + Value: &c.cliConfig.P2P.Port, + Default: c.cliConfig.P2P.Port, + Group: "P2P", + }) + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "bootnodes", + Usage: "Comma separated enode URLs for P2P discovery bootstrap", + Value: &c.cliConfig.P2P.Discovery.Bootnodes, + Default: c.cliConfig.P2P.Discovery.Bootnodes, + Group: "P2P", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "maxpeers", + Usage: "Maximum number of network peers (network disabled if set to 0)", + Value: &c.cliConfig.P2P.MaxPeers, + Default: c.cliConfig.P2P.MaxPeers, + Group: "P2P", + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "maxpendpeers", + Usage: "Maximum number of pending connection attempts", + Value: &c.cliConfig.P2P.MaxPendPeers, + Default: c.cliConfig.P2P.MaxPendPeers, + Group: "P2P", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "nat", + Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:)", + Value: &c.cliConfig.P2P.NAT, + Default: c.cliConfig.P2P.NAT, + Group: "P2P", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "netrestrict", + Usage: "Restricts network communication to the given IP networks (CIDR masks)", + Value: &c.cliConfig.P2P.NetRestrict, + Default: c.cliConfig.P2P.NetRestrict, + Group: "P2P", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "nodekey", + Usage: " P2P node key file", + Value: &c.cliConfig.P2P.NodeKey, + Default: c.cliConfig.P2P.NodeKey, + Group: "P2P", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "nodekeyhex", + Usage: "P2P node key as hex", + Value: &c.cliConfig.P2P.NodeKeyHex, + Default: c.cliConfig.P2P.NodeKeyHex, + Group: "P2P", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "nodiscover", + Usage: "Disables the peer discovery mechanism (manual peer addition)", + Value: &c.cliConfig.P2P.NoDiscover, + Default: c.cliConfig.P2P.NoDiscover, + Group: "P2P", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "v5disc", + Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism", + Value: &c.cliConfig.P2P.Discovery.V5Enabled, + Default: c.cliConfig.P2P.Discovery.V5Enabled, + Group: "P2P", + }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "txarrivalwait", + Usage: "Maximum duration to wait for a transaction before explicitly requesting it (defaults to 500ms)", + Value: &c.cliConfig.P2P.TxArrivalWait, + Default: c.cliConfig.P2P.TxArrivalWait, + Group: "P2P", + }) + + // metrics + f.BoolFlag(&flagset.BoolFlag{ + Name: "metrics", + Usage: "Enable metrics collection and reporting", + Value: &c.cliConfig.Telemetry.Enabled, + Default: c.cliConfig.Telemetry.Enabled, + Group: "Telemetry", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "metrics.expensive", + Usage: "Enable expensive metrics collection and reporting", + Value: &c.cliConfig.Telemetry.Expensive, + Default: c.cliConfig.Telemetry.Expensive, + Group: "Telemetry", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "metrics.influxdb", + Usage: "Enable metrics export/push to an external InfluxDB database (v1)", + Value: &c.cliConfig.Telemetry.InfluxDB.V1Enabled, + Default: c.cliConfig.Telemetry.InfluxDB.V1Enabled, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.endpoint", + Usage: "InfluxDB API endpoint to report metrics to", + Value: &c.cliConfig.Telemetry.InfluxDB.Endpoint, + Default: c.cliConfig.Telemetry.InfluxDB.Endpoint, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.database", + Usage: "InfluxDB database name to push reported metrics to", + Value: &c.cliConfig.Telemetry.InfluxDB.Database, + Default: c.cliConfig.Telemetry.InfluxDB.Database, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.username", + Usage: "Username to authorize access to the database", + Value: &c.cliConfig.Telemetry.InfluxDB.Username, + Default: c.cliConfig.Telemetry.InfluxDB.Username, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.password", + Usage: "Password to authorize access to the database", + Value: &c.cliConfig.Telemetry.InfluxDB.Password, + Default: c.cliConfig.Telemetry.InfluxDB.Password, + Group: "Telemetry", + }) + f.MapStringFlag(&flagset.MapStringFlag{ + Name: "metrics.influxdb.tags", + Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", + Value: &c.cliConfig.Telemetry.InfluxDB.Tags, + Group: "Telemetry", + Default: c.cliConfig.Telemetry.InfluxDB.Tags, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.prometheus-addr", + Usage: "Address for Prometheus Server", + Value: &c.cliConfig.Telemetry.PrometheusAddr, + Default: c.cliConfig.Telemetry.PrometheusAddr, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.opencollector-endpoint", + Usage: "OpenCollector Endpoint (host:port)", + Value: &c.cliConfig.Telemetry.OpenCollectorEndpoint, + Default: c.cliConfig.Telemetry.OpenCollectorEndpoint, + Group: "Telemetry", + }) + // influx db v2 + f.BoolFlag(&flagset.BoolFlag{ + Name: "metrics.influxdbv2", + Usage: "Enable metrics export/push to an external InfluxDB v2 database", + Value: &c.cliConfig.Telemetry.InfluxDB.V2Enabled, + Default: c.cliConfig.Telemetry.InfluxDB.V2Enabled, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.token", + Usage: "Token to authorize access to the database (v2 only)", + Value: &c.cliConfig.Telemetry.InfluxDB.Token, + Default: c.cliConfig.Telemetry.InfluxDB.Token, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.bucket", + Usage: "InfluxDB bucket name to push reported metrics to (v2 only)", + Value: &c.cliConfig.Telemetry.InfluxDB.Bucket, + Default: c.cliConfig.Telemetry.InfluxDB.Bucket, + Group: "Telemetry", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "metrics.influxdb.organization", + Usage: "InfluxDB organization name (v2 only)", + Value: &c.cliConfig.Telemetry.InfluxDB.Organization, + Default: c.cliConfig.Telemetry.InfluxDB.Organization, + Group: "Telemetry", + }) + + // account + f.SliceStringFlag(&flagset.SliceStringFlag{ + Name: "unlock", + Usage: "Comma separated list of accounts to unlock", + Value: &c.cliConfig.Accounts.Unlock, + Default: c.cliConfig.Accounts.Unlock, + Group: "Account Management", + }) + f.StringFlag(&flagset.StringFlag{ + Name: "password", + Usage: "Password file to use for non-interactive password input", + Value: &c.cliConfig.Accounts.PasswordFile, + Default: c.cliConfig.Accounts.PasswordFile, + Group: "Account Management", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "allow-insecure-unlock", + Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http", + Value: &c.cliConfig.Accounts.AllowInsecureUnlock, + Default: c.cliConfig.Accounts.AllowInsecureUnlock, + Group: "Account Management", + }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "lightkdf", + Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", + Value: &c.cliConfig.Accounts.UseLightweightKDF, + Default: c.cliConfig.Accounts.UseLightweightKDF, + Group: "Account Management", + }) + f.BoolFlag((&flagset.BoolFlag{ + Name: "disable-bor-wallet", + Usage: "Disable the personal wallet endpoints", + Value: &c.cliConfig.Accounts.DisableBorWallet, + Default: c.cliConfig.Accounts.DisableBorWallet, + })) + + // grpc + f.StringFlag(&flagset.StringFlag{ + Name: "grpc.addr", + Usage: "Address and port to bind the GRPC server", + Value: &c.cliConfig.GRPC.Addr, + Default: c.cliConfig.GRPC.Addr, + }) + + // developer + f.BoolFlag(&flagset.BoolFlag{ + Name: "dev", + Usage: "Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled", + Value: &c.cliConfig.Developer.Enabled, + Default: c.cliConfig.Developer.Enabled, + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "dev.period", + Usage: "Block period to use in developer mode (0 = mine only if transaction pending)", + Value: &c.cliConfig.Developer.Period, + Default: c.cliConfig.Developer.Period, + }) + + // parallelevm + f.BoolFlag(&flagset.BoolFlag{ + Name: "parallelevm.enable", + Usage: "Enable Block STM", + Value: &c.cliConfig.ParallelEVM.Enable, + Default: c.cliConfig.ParallelEVM.Enable, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "parallelevm.procs", + Usage: "Number of speculative processes (cores) in Block STM", + Value: &c.cliConfig.ParallelEVM.SpeculativeProcesses, + Default: c.cliConfig.ParallelEVM.SpeculativeProcesses, + }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "dev.gaslimit", + Usage: "Initial block gas limit", + Value: &c.cliConfig.Developer.GasLimit, + Default: c.cliConfig.Developer.GasLimit, + }) + + // pprof + f.BoolFlag(&flagset.BoolFlag{ + Name: "pprof", + Usage: "Enable the pprof HTTP server", + Value: &c.cliConfig.Pprof.Enabled, + Default: c.cliConfig.Pprof.Enabled, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "pprof.port", + Usage: "pprof HTTP server listening port", + Value: &c.cliConfig.Pprof.Port, + Default: c.cliConfig.Pprof.Port, + }) + f.StringFlag(&flagset.StringFlag{ + Name: "pprof.addr", + Usage: "pprof HTTP server listening interface", + Value: &c.cliConfig.Pprof.Addr, + Default: c.cliConfig.Pprof.Addr, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "pprof.memprofilerate", + Usage: "Turn on memory profiling with the given rate", + Value: &c.cliConfig.Pprof.MemProfileRate, + Default: c.cliConfig.Pprof.MemProfileRate, + }) + f.IntFlag(&flagset.IntFlag{ + Name: "pprof.blockprofilerate", + Usage: "Turn on block profiling with the given rate", + Value: &c.cliConfig.Pprof.BlockProfileRate, + Default: c.cliConfig.Pprof.BlockProfileRate, + }) + // f.StringFlag(&flagset.StringFlag{ + // Name: "pprof.cpuprofile", + // Usage: "Write CPU profile to the given file", + // Value: &c.cliConfig.Pprof.CPUProfile, + // Default: c.cliConfig.Pprof.CPUProfile, + // }) + + return f +} diff --git a/internal/cli/server/helper.go b/internal/cli/server/helper.go new file mode 100644 index 0000000000..97c49dcad3 --- /dev/null +++ b/internal/cli/server/helper.go @@ -0,0 +1,43 @@ +package server + +import ( + "fmt" + "os" + + "github.com/ethereum/go-ethereum/common/network" +) + +func CreateMockServer(config *Config) (*Server, error) { + if config == nil { + config = DefaultConfig() + } + + // get grpc port and listener + grpcPort, gRPCListener, err := network.FindAvailablePort() + if err != nil { + return nil, err + } + + // The test uses grpc port from config so setting it here. + config.GRPC.Addr = fmt.Sprintf(":%d", grpcPort) + + // datadir + datadir, err := os.MkdirTemp("", "bor-cli-test") + if err != nil { + return nil, err + } + + config.DataDir = datadir + config.JsonRPC.Http.Port = 0 // It will choose a free/available port + + // start the server + return NewServer(config, WithGRPCListener(gRPCListener)) +} + +func CloseMockServer(server *Server) { + // remove the contents of temp data dir + os.RemoveAll(server.config.DataDir) + + // close the server + server.Stop() +} diff --git a/internal/cli/server/pprof/pprof.go b/internal/cli/server/pprof/pprof.go new file mode 100644 index 0000000000..7360ec2619 --- /dev/null +++ b/internal/cli/server/pprof/pprof.go @@ -0,0 +1,138 @@ +package pprof + +import ( + "bytes" + "context" + "fmt" + "net/http" + "runtime" + "runtime/pprof" + "runtime/trace" + "time" + + "github.com/ethereum/go-ethereum/log" +) + +// Profile generates a pprof.Profile report for the given profile name. +func Profile(profile string, debug, gc int) ([]byte, map[string]string, error) { + p := pprof.Lookup(profile) + if p == nil { + return nil, nil, fmt.Errorf("profile '%s' not found", profile) + } + + if profile == "heap" && gc > 0 { + runtime.GC() + } + + var buf bytes.Buffer + if err := p.WriteTo(&buf, debug); err != nil { + return nil, nil, err + } + + headers := map[string]string{ + "X-Content-Type-Options": "nosniff", + } + if debug != 0 { + headers["Content-Type"] = "text/plain; charset=utf-8" + } else { + headers["Content-Type"] = "application/octet-stream" + headers["Content-Disposition"] = fmt.Sprintf(`attachment; filename="%s"`, profile) + } + + return buf.Bytes(), headers, nil +} + +// CPUProfile generates a CPU Profile for a given duration +func CPUProfile(ctx context.Context, sec int) ([]byte, map[string]string, error) { + if sec <= 0 { + sec = 1 + } + + var buf bytes.Buffer + if err := pprof.StartCPUProfile(&buf); err != nil { + return nil, nil, err + } + + sleep(ctx, time.Duration(sec)*time.Second) + + pprof.StopCPUProfile() + + return buf.Bytes(), + map[string]string{ + "X-Content-Type-Options": "nosniff", + "Content-Type": "application/octet-stream", + "Content-Disposition": `attachment; filename="profile"`, + }, nil +} + +// CPUProfile generates a CPU Profile for a given duration +func CPUProfileWithChannel(done chan bool) ([]byte, map[string]string, error) { + var buf bytes.Buffer + if err := pprof.StartCPUProfile(&buf); err != nil { + return nil, nil, err + } + + select { + case <-done: + case <-time.After(30 * time.Second): + } + + pprof.StopCPUProfile() + + return buf.Bytes(), + map[string]string{ + "X-Content-Type-Options": "nosniff", + "Content-Type": "application/octet-stream", + "Content-Disposition": `attachment; filename="profile"`, + }, nil +} + +// Trace runs a trace profile for a given duration +func Trace(ctx context.Context, sec int) ([]byte, map[string]string, error) { + if sec <= 0 { + sec = 1 + } + + var buf bytes.Buffer + if err := trace.Start(&buf); err != nil { + return nil, nil, err + } + + sleep(ctx, time.Duration(sec)*time.Second) + + trace.Stop() + + return buf.Bytes(), + map[string]string{ + "X-Content-Type-Options": "nosniff", + "Content-Type": "application/octet-stream", + "Content-Disposition": `attachment; filename="trace"`, + }, nil +} + +func sleep(ctx context.Context, d time.Duration) { + // Sleep until duration is met or ctx is cancelled + select { + case <-time.After(d): + case <-ctx.Done(): + } +} + +func SetMemProfileRate(rate int) { + runtime.MemProfileRate = rate +} + +func SetSetBlockProfileRate(rate int) { + runtime.SetBlockProfileRate(rate) +} + +func StartPProf(address string) { + log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address)) + + go func() { + // nolint: gosec + if err := http.ListenAndServe(address, nil); err != nil { + log.Error("Failure in running pprof server", "err", err) + } + }() +} diff --git a/internal/cli/server/proto/server.pb.go b/internal/cli/server/proto/server.pb.go new file mode 100644 index 0000000000..01071cfd19 --- /dev/null +++ b/internal/cli/server/proto/server.pb.go @@ -0,0 +1,2231 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: internal/cli/server/proto/server.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DebugPprofRequest_Type int32 + +const ( + DebugPprofRequest_LOOKUP DebugPprofRequest_Type = 0 + DebugPprofRequest_CPU DebugPprofRequest_Type = 1 + DebugPprofRequest_TRACE DebugPprofRequest_Type = 2 +) + +// Enum value maps for DebugPprofRequest_Type. +var ( + DebugPprofRequest_Type_name = map[int32]string{ + 0: "LOOKUP", + 1: "CPU", + 2: "TRACE", + } + DebugPprofRequest_Type_value = map[string]int32{ + "LOOKUP": 0, + "CPU": 1, + "TRACE": 2, + } +) + +func (x DebugPprofRequest_Type) Enum() *DebugPprofRequest_Type { + p := new(DebugPprofRequest_Type) + *p = x + + return p +} + +func (x DebugPprofRequest_Type) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DebugPprofRequest_Type) Descriptor() protoreflect.EnumDescriptor { + return file_internal_cli_server_proto_server_proto_enumTypes[0].Descriptor() +} + +func (DebugPprofRequest_Type) Type() protoreflect.EnumType { + return &file_internal_cli_server_proto_server_proto_enumTypes[0] +} + +func (x DebugPprofRequest_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DebugPprofRequest_Type.Descriptor instead. +func (DebugPprofRequest_Type) EnumDescriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{19, 0} +} + +type TraceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number int64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *TraceRequest) Reset() { + *x = TraceRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TraceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TraceRequest) ProtoMessage() {} + +func (x *TraceRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[0] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use TraceRequest.ProtoReflect.Descriptor instead. +func (*TraceRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{0} +} + +func (x *TraceRequest) GetNumber() int64 { + if x != nil { + return x.Number + } + + return 0 +} + +type TraceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TraceResponse) Reset() { + *x = TraceResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TraceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TraceResponse) ProtoMessage() {} + +func (x *TraceResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[1] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use TraceResponse.ProtoReflect.Descriptor instead. +func (*TraceResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{1} +} + +type ChainWatchRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ChainWatchRequest) Reset() { + *x = ChainWatchRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainWatchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainWatchRequest) ProtoMessage() {} + +func (x *ChainWatchRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[2] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use ChainWatchRequest.ProtoReflect.Descriptor instead. +func (*ChainWatchRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{2} +} + +type ChainWatchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Oldchain []*BlockStub `protobuf:"bytes,1,rep,name=oldchain,proto3" json:"oldchain,omitempty"` + Newchain []*BlockStub `protobuf:"bytes,2,rep,name=newchain,proto3" json:"newchain,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` +} + +func (x *ChainWatchResponse) Reset() { + *x = ChainWatchResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainWatchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainWatchResponse) ProtoMessage() {} + +func (x *ChainWatchResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[3] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use ChainWatchResponse.ProtoReflect.Descriptor instead. +func (*ChainWatchResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{3} +} + +func (x *ChainWatchResponse) GetOldchain() []*BlockStub { + if x != nil { + return x.Oldchain + } + + return nil +} + +func (x *ChainWatchResponse) GetNewchain() []*BlockStub { + if x != nil { + return x.Newchain + } + + return nil +} + +func (x *ChainWatchResponse) GetType() string { + if x != nil { + return x.Type + } + + return "" +} + +type BlockStub struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Number uint64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *BlockStub) Reset() { + *x = BlockStub{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockStub) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockStub) ProtoMessage() {} + +func (x *BlockStub) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[4] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use BlockStub.ProtoReflect.Descriptor instead. +func (*BlockStub) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{4} +} + +func (x *BlockStub) GetHash() string { + if x != nil { + return x.Hash + } + + return "" +} + +func (x *BlockStub) GetNumber() uint64 { + if x != nil { + return x.Number + } + + return 0 +} + +type PeersAddRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enode string `protobuf:"bytes,1,opt,name=enode,proto3" json:"enode,omitempty"` + Trusted bool `protobuf:"varint,2,opt,name=trusted,proto3" json:"trusted,omitempty"` +} + +func (x *PeersAddRequest) Reset() { + *x = PeersAddRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersAddRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersAddRequest) ProtoMessage() {} + +func (x *PeersAddRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[5] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersAddRequest.ProtoReflect.Descriptor instead. +func (*PeersAddRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{5} +} + +func (x *PeersAddRequest) GetEnode() string { + if x != nil { + return x.Enode + } + + return "" +} + +func (x *PeersAddRequest) GetTrusted() bool { + if x != nil { + return x.Trusted + } + + return false +} + +type PeersAddResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PeersAddResponse) Reset() { + *x = PeersAddResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersAddResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersAddResponse) ProtoMessage() {} + +func (x *PeersAddResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[6] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersAddResponse.ProtoReflect.Descriptor instead. +func (*PeersAddResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{6} +} + +type PeersRemoveRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enode string `protobuf:"bytes,1,opt,name=enode,proto3" json:"enode,omitempty"` + Trusted bool `protobuf:"varint,2,opt,name=trusted,proto3" json:"trusted,omitempty"` +} + +func (x *PeersRemoveRequest) Reset() { + *x = PeersRemoveRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersRemoveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersRemoveRequest) ProtoMessage() {} + +func (x *PeersRemoveRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[7] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersRemoveRequest.ProtoReflect.Descriptor instead. +func (*PeersRemoveRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{7} +} + +func (x *PeersRemoveRequest) GetEnode() string { + if x != nil { + return x.Enode + } + + return "" +} + +func (x *PeersRemoveRequest) GetTrusted() bool { + if x != nil { + return x.Trusted + } + + return false +} + +type PeersRemoveResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PeersRemoveResponse) Reset() { + *x = PeersRemoveResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersRemoveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersRemoveResponse) ProtoMessage() {} + +func (x *PeersRemoveResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[8] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersRemoveResponse.ProtoReflect.Descriptor instead. +func (*PeersRemoveResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{8} +} + +type PeersListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PeersListRequest) Reset() { + *x = PeersListRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersListRequest) ProtoMessage() {} + +func (x *PeersListRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[9] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersListRequest.ProtoReflect.Descriptor instead. +func (*PeersListRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{9} +} + +type PeersListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Peers []*Peer `protobuf:"bytes,1,rep,name=peers,proto3" json:"peers,omitempty"` +} + +func (x *PeersListResponse) Reset() { + *x = PeersListResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersListResponse) ProtoMessage() {} + +func (x *PeersListResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[10] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersListResponse.ProtoReflect.Descriptor instead. +func (*PeersListResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{10} +} + +func (x *PeersListResponse) GetPeers() []*Peer { + if x != nil { + return x.Peers + } + + return nil +} + +type PeersStatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enode string `protobuf:"bytes,1,opt,name=enode,proto3" json:"enode,omitempty"` +} + +func (x *PeersStatusRequest) Reset() { + *x = PeersStatusRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersStatusRequest) ProtoMessage() {} + +func (x *PeersStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[11] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersStatusRequest.ProtoReflect.Descriptor instead. +func (*PeersStatusRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{11} +} + +func (x *PeersStatusRequest) GetEnode() string { + if x != nil { + return x.Enode + } + + return "" +} + +type PeersStatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Peer *Peer `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"` +} + +func (x *PeersStatusResponse) Reset() { + *x = PeersStatusResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersStatusResponse) ProtoMessage() {} + +func (x *PeersStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[12] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use PeersStatusResponse.ProtoReflect.Descriptor instead. +func (*PeersStatusResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{12} +} + +func (x *PeersStatusResponse) GetPeer() *Peer { + if x != nil { + return x.Peer + } + + return nil +} + +type Peer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Enode string `protobuf:"bytes,2,opt,name=enode,proto3" json:"enode,omitempty"` + Enr string `protobuf:"bytes,3,opt,name=enr,proto3" json:"enr,omitempty"` + Caps []string `protobuf:"bytes,4,rep,name=caps,proto3" json:"caps,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Trusted bool `protobuf:"varint,6,opt,name=trusted,proto3" json:"trusted,omitempty"` + Static bool `protobuf:"varint,7,opt,name=static,proto3" json:"static,omitempty"` +} + +func (x *Peer) Reset() { + *x = Peer{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Peer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Peer) ProtoMessage() {} + +func (x *Peer) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[13] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use Peer.ProtoReflect.Descriptor instead. +func (*Peer) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{13} +} + +func (x *Peer) GetId() string { + if x != nil { + return x.Id + } + + return "" +} + +func (x *Peer) GetEnode() string { + if x != nil { + return x.Enode + } + + return "" +} + +func (x *Peer) GetEnr() string { + if x != nil { + return x.Enr + } + + return "" +} + +func (x *Peer) GetCaps() []string { + if x != nil { + return x.Caps + } + + return nil +} + +func (x *Peer) GetName() string { + if x != nil { + return x.Name + } + + return "" +} + +func (x *Peer) GetTrusted() bool { + if x != nil { + return x.Trusted + } + + return false +} + +func (x *Peer) GetStatic() bool { + if x != nil { + return x.Static + } + + return false +} + +type ChainSetHeadRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *ChainSetHeadRequest) Reset() { + *x = ChainSetHeadRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainSetHeadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainSetHeadRequest) ProtoMessage() {} + +func (x *ChainSetHeadRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[14] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use ChainSetHeadRequest.ProtoReflect.Descriptor instead. +func (*ChainSetHeadRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{14} +} + +func (x *ChainSetHeadRequest) GetNumber() uint64 { + if x != nil { + return x.Number + } + + return 0 +} + +type ChainSetHeadResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ChainSetHeadResponse) Reset() { + *x = ChainSetHeadResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChainSetHeadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChainSetHeadResponse) ProtoMessage() {} + +func (x *ChainSetHeadResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[15] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use ChainSetHeadResponse.ProtoReflect.Descriptor instead. +func (*ChainSetHeadResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{15} +} + +type StatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Wait bool `protobuf:"varint,1,opt,name=Wait,proto3" json:"Wait,omitempty"` +} + +func (x *StatusRequest) Reset() { + *x = StatusRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusRequest) ProtoMessage() {} + +func (x *StatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[16] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. +func (*StatusRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{16} +} + +func (x *StatusRequest) GetWait() bool { + if x != nil { + return x.Wait + } + + return false +} + +type StatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CurrentBlock *Header `protobuf:"bytes,1,opt,name=currentBlock,proto3" json:"currentBlock,omitempty"` + CurrentHeader *Header `protobuf:"bytes,2,opt,name=currentHeader,proto3" json:"currentHeader,omitempty"` + NumPeers int64 `protobuf:"varint,3,opt,name=numPeers,proto3" json:"numPeers,omitempty"` + SyncMode string `protobuf:"bytes,4,opt,name=syncMode,proto3" json:"syncMode,omitempty"` + Syncing *StatusResponse_Syncing `protobuf:"bytes,5,opt,name=syncing,proto3" json:"syncing,omitempty"` + Forks []*StatusResponse_Fork `protobuf:"bytes,6,rep,name=forks,proto3" json:"forks,omitempty"` +} + +func (x *StatusResponse) Reset() { + *x = StatusResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusResponse) ProtoMessage() {} + +func (x *StatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[17] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. +func (*StatusResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17} +} + +func (x *StatusResponse) GetCurrentBlock() *Header { + if x != nil { + return x.CurrentBlock + } + + return nil +} + +func (x *StatusResponse) GetCurrentHeader() *Header { + if x != nil { + return x.CurrentHeader + } + + return nil +} + +func (x *StatusResponse) GetNumPeers() int64 { + if x != nil { + return x.NumPeers + } + + return 0 +} + +func (x *StatusResponse) GetSyncMode() string { + if x != nil { + return x.SyncMode + } + + return "" +} + +func (x *StatusResponse) GetSyncing() *StatusResponse_Syncing { + if x != nil { + return x.Syncing + } + + return nil +} + +func (x *StatusResponse) GetForks() []*StatusResponse_Fork { + if x != nil { + return x.Forks + } + + return nil +} + +type Header struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Number uint64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *Header) Reset() { + *x = Header{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Header) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Header) ProtoMessage() {} + +func (x *Header) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[18] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use Header.ProtoReflect.Descriptor instead. +func (*Header) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{18} +} + +func (x *Header) GetHash() string { + if x != nil { + return x.Hash + } + + return "" +} + +func (x *Header) GetNumber() uint64 { + if x != nil { + return x.Number + } + + return 0 +} + +type DebugPprofRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type DebugPprofRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=proto.DebugPprofRequest_Type" json:"type,omitempty"` + Profile string `protobuf:"bytes,2,opt,name=profile,proto3" json:"profile,omitempty"` + Seconds int64 `protobuf:"varint,3,opt,name=seconds,proto3" json:"seconds,omitempty"` +} + +func (x *DebugPprofRequest) Reset() { + *x = DebugPprofRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugPprofRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugPprofRequest) ProtoMessage() {} + +func (x *DebugPprofRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[19] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use DebugPprofRequest.ProtoReflect.Descriptor instead. +func (*DebugPprofRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{19} +} + +func (x *DebugPprofRequest) GetType() DebugPprofRequest_Type { + if x != nil { + return x.Type + } + + return DebugPprofRequest_LOOKUP +} + +func (x *DebugPprofRequest) GetProfile() string { + if x != nil { + return x.Profile + } + + return "" +} + +func (x *DebugPprofRequest) GetSeconds() int64 { + if x != nil { + return x.Seconds + } + + return 0 +} + +type DebugBlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number int64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *DebugBlockRequest) Reset() { + *x = DebugBlockRequest{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugBlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugBlockRequest) ProtoMessage() {} + +func (x *DebugBlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[20] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use DebugBlockRequest.ProtoReflect.Descriptor instead. +func (*DebugBlockRequest) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{20} +} + +func (x *DebugBlockRequest) GetNumber() int64 { + if x != nil { + return x.Number + } + + return 0 +} + +type DebugFileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Event: + // + // *DebugFileResponse_Open_ + // *DebugFileResponse_Input_ + // *DebugFileResponse_Eof + Event isDebugFileResponse_Event `protobuf_oneof:"event"` +} + +func (x *DebugFileResponse) Reset() { + *x = DebugFileResponse{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugFileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugFileResponse) ProtoMessage() {} + +func (x *DebugFileResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[21] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use DebugFileResponse.ProtoReflect.Descriptor instead. +func (*DebugFileResponse) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21} +} + +func (m *DebugFileResponse) GetEvent() isDebugFileResponse_Event { + if m != nil { + return m.Event + } + + return nil +} + +func (x *DebugFileResponse) GetOpen() *DebugFileResponse_Open { + if x, ok := x.GetEvent().(*DebugFileResponse_Open_); ok { + return x.Open + } + + return nil +} + +func (x *DebugFileResponse) GetInput() *DebugFileResponse_Input { + if x, ok := x.GetEvent().(*DebugFileResponse_Input_); ok { + return x.Input + } + + return nil +} + +func (x *DebugFileResponse) GetEof() *emptypb.Empty { + if x, ok := x.GetEvent().(*DebugFileResponse_Eof); ok { + return x.Eof + } + + return nil +} + +type isDebugFileResponse_Event interface { + isDebugFileResponse_Event() +} + +type DebugFileResponse_Open_ struct { + Open *DebugFileResponse_Open `protobuf:"bytes,1,opt,name=open,proto3,oneof"` +} + +type DebugFileResponse_Input_ struct { + Input *DebugFileResponse_Input `protobuf:"bytes,2,opt,name=input,proto3,oneof"` +} + +type DebugFileResponse_Eof struct { + Eof *emptypb.Empty `protobuf:"bytes,3,opt,name=eof,proto3,oneof"` +} + +func (*DebugFileResponse_Open_) isDebugFileResponse_Event() {} + +func (*DebugFileResponse_Input_) isDebugFileResponse_Event() {} + +func (*DebugFileResponse_Eof) isDebugFileResponse_Event() {} + +type StatusResponse_Fork struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Block int64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` + Disabled bool `protobuf:"varint,3,opt,name=disabled,proto3" json:"disabled,omitempty"` +} + +func (x *StatusResponse_Fork) Reset() { + *x = StatusResponse_Fork{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusResponse_Fork) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusResponse_Fork) ProtoMessage() {} + +func (x *StatusResponse_Fork) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[22] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use StatusResponse_Fork.ProtoReflect.Descriptor instead. +func (*StatusResponse_Fork) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17, 0} +} + +func (x *StatusResponse_Fork) GetName() string { + if x != nil { + return x.Name + } + + return "" +} + +func (x *StatusResponse_Fork) GetBlock() int64 { + if x != nil { + return x.Block + } + + return 0 +} + +func (x *StatusResponse_Fork) GetDisabled() bool { + if x != nil { + return x.Disabled + } + + return false +} + +type StatusResponse_Syncing struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StartingBlock int64 `protobuf:"varint,1,opt,name=startingBlock,proto3" json:"startingBlock,omitempty"` + HighestBlock int64 `protobuf:"varint,2,opt,name=highestBlock,proto3" json:"highestBlock,omitempty"` + CurrentBlock int64 `protobuf:"varint,3,opt,name=currentBlock,proto3" json:"currentBlock,omitempty"` +} + +func (x *StatusResponse_Syncing) Reset() { + *x = StatusResponse_Syncing{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusResponse_Syncing) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusResponse_Syncing) ProtoMessage() {} + +func (x *StatusResponse_Syncing) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[23] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use StatusResponse_Syncing.ProtoReflect.Descriptor instead. +func (*StatusResponse_Syncing) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17, 1} +} + +func (x *StatusResponse_Syncing) GetStartingBlock() int64 { + if x != nil { + return x.StartingBlock + } + + return 0 +} + +func (x *StatusResponse_Syncing) GetHighestBlock() int64 { + if x != nil { + return x.HighestBlock + } + + return 0 +} + +func (x *StatusResponse_Syncing) GetCurrentBlock() int64 { + if x != nil { + return x.CurrentBlock + } + + return 0 +} + +type DebugFileResponse_Open struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *DebugFileResponse_Open) Reset() { + *x = DebugFileResponse_Open{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugFileResponse_Open) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugFileResponse_Open) ProtoMessage() {} + +func (x *DebugFileResponse_Open) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[24] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use DebugFileResponse_Open.ProtoReflect.Descriptor instead. +func (*DebugFileResponse_Open) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21, 0} +} + +func (x *DebugFileResponse_Open) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + + return nil +} + +type DebugFileResponse_Input struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *DebugFileResponse_Input) Reset() { + *x = DebugFileResponse_Input{} + + if protoimpl.UnsafeEnabled { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugFileResponse_Input) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugFileResponse_Input) ProtoMessage() {} + +func (x *DebugFileResponse_Input) ProtoReflect() protoreflect.Message { + mi := &file_internal_cli_server_proto_server_proto_msgTypes[25] + + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + + return ms + } + + return mi.MessageOf(x) +} + +// Deprecated: Use DebugFileResponse_Input.ProtoReflect.Descriptor instead. +func (*DebugFileResponse_Input) Descriptor() ([]byte, []int) { + return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21, 1} +} + +func (x *DebugFileResponse_Input) GetData() []byte { + if x != nil { + return x.Data + } + + return nil +} + +var File_internal_cli_server_proto_server_proto protoreflect.FileDescriptor + +var file_internal_cli_server_proto_server_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, 0x0c, + 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, + 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x84, 0x01, 0x0a, 0x12, 0x43, + 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x2c, 0x0a, 0x08, 0x6f, 0x6c, 0x64, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x53, 0x74, 0x75, 0x62, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, + 0x2c, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, + 0x74, 0x75, 0x62, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x22, 0x37, 0x0a, 0x09, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x75, 0x62, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, + 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x41, 0x0a, 0x0f, 0x50, 0x65, + 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, + 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x22, 0x12, 0x0a, + 0x10, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x50, 0x65, 0x65, 0x72, 0x73, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, + 0x0a, 0x10, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x36, 0x0a, 0x11, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, + 0x65, 0x65, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0x2a, 0x0a, 0x12, 0x50, 0x65, + 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x36, 0x0a, 0x13, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, + 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x22, 0x98, + 0x01, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, + 0x03, 0x65, 0x6e, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72, 0x12, + 0x12, 0x0a, 0x04, 0x63, 0x61, 0x70, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x63, + 0x61, 0x70, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x72, 0x75, 0x73, 0x74, + 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x22, 0x2d, 0x0a, 0x13, 0x43, 0x68, 0x61, + 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x16, 0x0a, 0x14, 0x43, 0x68, 0x61, 0x69, + 0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x23, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x57, 0x61, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x04, 0x57, 0x61, 0x69, 0x74, 0x22, 0xe2, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x33, 0x0a, 0x0d, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x52, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x08, 0x6e, 0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, + 0x73, 0x79, 0x6e, 0x63, 0x4d, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x73, 0x79, 0x6e, 0x63, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63, + 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, + 0x67, 0x12, 0x30, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x05, 0x66, 0x6f, + 0x72, 0x6b, 0x73, 0x1a, 0x4c, 0x0a, 0x04, 0x46, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x1a, 0x77, 0x0a, 0x07, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x0a, 0x0d, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x22, 0x0a, 0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x34, 0x0a, 0x06, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x22, 0xa2, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, + 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, + 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x26, 0x0a, + 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x4f, 0x4f, 0x4b, 0x55, 0x50, 0x10, + 0x00, 0x12, 0x07, 0x0a, 0x03, 0x43, 0x50, 0x55, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, + 0x41, 0x43, 0x45, 0x10, 0x02, 0x22, 0x2b, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x22, 0xdd, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x04, 0x6f, 0x70, 0x65, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x48, 0x00, 0x52, 0x04, 0x6f, 0x70, 0x65, 0x6e, 0x12, 0x36, 0x0a, + 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x48, 0x00, 0x52, 0x05, + 0x69, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x2a, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x03, 0x65, 0x6f, + 0x66, 0x1a, 0x88, 0x01, 0x0a, 0x04, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x44, 0x0a, 0x07, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, + 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x1b, 0x0a, 0x05, + 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x32, 0xdb, 0x04, 0x0a, 0x03, 0x42, 0x6f, 0x72, 0x12, 0x3b, 0x0a, 0x08, 0x50, 0x65, + 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, + 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, + 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, + 0x09, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, + 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, + 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48, + 0x65, 0x61, 0x64, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, + 0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, + 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, + 0x68, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, + 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a, 0x44, 0x65, 0x62, 0x75, + 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, + 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, + 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, + 0x42, 0x1c, 0x5a, 0x1a, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c, + 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_cli_server_proto_server_proto_rawDescOnce sync.Once + file_internal_cli_server_proto_server_proto_rawDescData = file_internal_cli_server_proto_server_proto_rawDesc +) + +func file_internal_cli_server_proto_server_proto_rawDescGZIP() []byte { + file_internal_cli_server_proto_server_proto_rawDescOnce.Do(func() { + file_internal_cli_server_proto_server_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_cli_server_proto_server_proto_rawDescData) + }) + + return file_internal_cli_server_proto_server_proto_rawDescData +} + +var file_internal_cli_server_proto_server_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_internal_cli_server_proto_server_proto_msgTypes = make([]protoimpl.MessageInfo, 27) +var file_internal_cli_server_proto_server_proto_goTypes = []interface{}{ + (DebugPprofRequest_Type)(0), // 0: proto.DebugPprofRequest.Type + (*TraceRequest)(nil), // 1: proto.TraceRequest + (*TraceResponse)(nil), // 2: proto.TraceResponse + (*ChainWatchRequest)(nil), // 3: proto.ChainWatchRequest + (*ChainWatchResponse)(nil), // 4: proto.ChainWatchResponse + (*BlockStub)(nil), // 5: proto.BlockStub + (*PeersAddRequest)(nil), // 6: proto.PeersAddRequest + (*PeersAddResponse)(nil), // 7: proto.PeersAddResponse + (*PeersRemoveRequest)(nil), // 8: proto.PeersRemoveRequest + (*PeersRemoveResponse)(nil), // 9: proto.PeersRemoveResponse + (*PeersListRequest)(nil), // 10: proto.PeersListRequest + (*PeersListResponse)(nil), // 11: proto.PeersListResponse + (*PeersStatusRequest)(nil), // 12: proto.PeersStatusRequest + (*PeersStatusResponse)(nil), // 13: proto.PeersStatusResponse + (*Peer)(nil), // 14: proto.Peer + (*ChainSetHeadRequest)(nil), // 15: proto.ChainSetHeadRequest + (*ChainSetHeadResponse)(nil), // 16: proto.ChainSetHeadResponse + (*StatusRequest)(nil), // 17: proto.StatusRequest + (*StatusResponse)(nil), // 18: proto.StatusResponse + (*Header)(nil), // 19: proto.Header + (*DebugPprofRequest)(nil), // 20: proto.DebugPprofRequest + (*DebugBlockRequest)(nil), // 21: proto.DebugBlockRequest + (*DebugFileResponse)(nil), // 22: proto.DebugFileResponse + (*StatusResponse_Fork)(nil), // 23: proto.StatusResponse.Fork + (*StatusResponse_Syncing)(nil), // 24: proto.StatusResponse.Syncing + (*DebugFileResponse_Open)(nil), // 25: proto.DebugFileResponse.Open + (*DebugFileResponse_Input)(nil), // 26: proto.DebugFileResponse.Input + nil, // 27: proto.DebugFileResponse.Open.HeadersEntry + (*emptypb.Empty)(nil), // 28: google.protobuf.Empty +} +var file_internal_cli_server_proto_server_proto_depIdxs = []int32{ + 5, // 0: proto.ChainWatchResponse.oldchain:type_name -> proto.BlockStub + 5, // 1: proto.ChainWatchResponse.newchain:type_name -> proto.BlockStub + 14, // 2: proto.PeersListResponse.peers:type_name -> proto.Peer + 14, // 3: proto.PeersStatusResponse.peer:type_name -> proto.Peer + 19, // 4: proto.StatusResponse.currentBlock:type_name -> proto.Header + 19, // 5: proto.StatusResponse.currentHeader:type_name -> proto.Header + 24, // 6: proto.StatusResponse.syncing:type_name -> proto.StatusResponse.Syncing + 23, // 7: proto.StatusResponse.forks:type_name -> proto.StatusResponse.Fork + 0, // 8: proto.DebugPprofRequest.type:type_name -> proto.DebugPprofRequest.Type + 25, // 9: proto.DebugFileResponse.open:type_name -> proto.DebugFileResponse.Open + 26, // 10: proto.DebugFileResponse.input:type_name -> proto.DebugFileResponse.Input + 28, // 11: proto.DebugFileResponse.eof:type_name -> google.protobuf.Empty + 27, // 12: proto.DebugFileResponse.Open.headers:type_name -> proto.DebugFileResponse.Open.HeadersEntry + 6, // 13: proto.Bor.PeersAdd:input_type -> proto.PeersAddRequest + 8, // 14: proto.Bor.PeersRemove:input_type -> proto.PeersRemoveRequest + 10, // 15: proto.Bor.PeersList:input_type -> proto.PeersListRequest + 12, // 16: proto.Bor.PeersStatus:input_type -> proto.PeersStatusRequest + 15, // 17: proto.Bor.ChainSetHead:input_type -> proto.ChainSetHeadRequest + 17, // 18: proto.Bor.Status:input_type -> proto.StatusRequest + 3, // 19: proto.Bor.ChainWatch:input_type -> proto.ChainWatchRequest + 20, // 20: proto.Bor.DebugPprof:input_type -> proto.DebugPprofRequest + 21, // 21: proto.Bor.DebugBlock:input_type -> proto.DebugBlockRequest + 7, // 22: proto.Bor.PeersAdd:output_type -> proto.PeersAddResponse + 9, // 23: proto.Bor.PeersRemove:output_type -> proto.PeersRemoveResponse + 11, // 24: proto.Bor.PeersList:output_type -> proto.PeersListResponse + 13, // 25: proto.Bor.PeersStatus:output_type -> proto.PeersStatusResponse + 16, // 26: proto.Bor.ChainSetHead:output_type -> proto.ChainSetHeadResponse + 18, // 27: proto.Bor.Status:output_type -> proto.StatusResponse + 4, // 28: proto.Bor.ChainWatch:output_type -> proto.ChainWatchResponse + 22, // 29: proto.Bor.DebugPprof:output_type -> proto.DebugFileResponse + 22, // 30: proto.Bor.DebugBlock:output_type -> proto.DebugFileResponse + 22, // [22:31] is the sub-list for method output_type + 13, // [13:22] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name +} + +func init() { file_internal_cli_server_proto_server_proto_init() } +func file_internal_cli_server_proto_server_proto_init() { + if File_internal_cli_server_proto_server_proto != nil { + return + } + + if !protoimpl.UnsafeEnabled { + file_internal_cli_server_proto_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainWatchRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainWatchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockStub); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersAddRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersAddResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersRemoveRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersRemoveResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersStatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersStatusResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Peer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainSetHeadRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainSetHeadResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Header); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugPprofRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugBlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugFileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse_Fork); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse_Syncing); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugFileResponse_Open); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_cli_server_proto_server_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DebugFileResponse_Input); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + + file_internal_cli_server_proto_server_proto_msgTypes[21].OneofWrappers = []interface{}{ + (*DebugFileResponse_Open_)(nil), + (*DebugFileResponse_Input_)(nil), + (*DebugFileResponse_Eof)(nil), + } + + type x struct{} + + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_cli_server_proto_server_proto_rawDesc, + NumEnums: 1, + NumMessages: 27, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_cli_server_proto_server_proto_goTypes, + DependencyIndexes: file_internal_cli_server_proto_server_proto_depIdxs, + EnumInfos: file_internal_cli_server_proto_server_proto_enumTypes, + MessageInfos: file_internal_cli_server_proto_server_proto_msgTypes, + }.Build() + File_internal_cli_server_proto_server_proto = out.File + file_internal_cli_server_proto_server_proto_rawDesc = nil + file_internal_cli_server_proto_server_proto_goTypes = nil + file_internal_cli_server_proto_server_proto_depIdxs = nil +} diff --git a/internal/cli/server/proto/server.proto b/internal/cli/server/proto/server.proto new file mode 100644 index 0000000000..fce787b1db --- /dev/null +++ b/internal/cli/server/proto/server.proto @@ -0,0 +1,162 @@ +syntax = "proto3"; + +package proto; + +import "google/protobuf/empty.proto"; + +option go_package = "/internal/cli/server/proto"; + +service Bor { + rpc PeersAdd(PeersAddRequest) returns (PeersAddResponse); + + rpc PeersRemove(PeersRemoveRequest) returns (PeersRemoveResponse); + + rpc PeersList(PeersListRequest) returns (PeersListResponse); + + rpc PeersStatus(PeersStatusRequest) returns (PeersStatusResponse); + + rpc ChainSetHead(ChainSetHeadRequest) returns (ChainSetHeadResponse); + + rpc Status(StatusRequest) returns (StatusResponse); + + rpc ChainWatch(ChainWatchRequest) returns (stream ChainWatchResponse); + + rpc DebugPprof(DebugPprofRequest) returns (stream DebugFileResponse); + + rpc DebugBlock(DebugBlockRequest) returns (stream DebugFileResponse); +} + +message TraceRequest { + int64 number = 1; +} + +message TraceResponse { + +} + +message ChainWatchRequest { + +} + +message ChainWatchResponse { + repeated BlockStub oldchain = 1; + repeated BlockStub newchain = 2; + string type = 3; +} + +message BlockStub { + string hash = 1; + uint64 number = 2; +} + +message PeersAddRequest { + string enode = 1; + bool trusted = 2; +} + +message PeersAddResponse { +} + +message PeersRemoveRequest { + string enode = 1; + bool trusted = 2; +} + +message PeersRemoveResponse { +} + +message PeersListRequest { +} + +message PeersListResponse { + repeated Peer peers = 1; +} + +message PeersStatusRequest { + string enode = 1; +} + +message PeersStatusResponse { + Peer peer = 1; +} + +message Peer { + string id = 1; + string enode = 2; + string enr = 3; + repeated string caps = 4; + string name = 5; + bool trusted = 6; + bool static = 7; +} + +message ChainSetHeadRequest { + uint64 number = 1; +} + +message ChainSetHeadResponse { +} + +message StatusRequest { + bool Wait = 1; +} + +message StatusResponse { + Header currentBlock = 1; + Header currentHeader = 2; + int64 numPeers = 3; + string syncMode = 4; + Syncing syncing = 5; + repeated Fork forks = 6; + + message Fork { + string name = 1; + int64 block = 2; + bool disabled = 3; + } + + message Syncing { + int64 startingBlock = 1; + int64 highestBlock = 2; + int64 currentBlock = 3; + } +} + +message Header { + string hash = 1; + uint64 number = 2; +} + +message DebugPprofRequest { + Type type = 1; + + string profile = 2; + + int64 seconds = 3; + + enum Type { + LOOKUP = 0; + CPU = 1; + TRACE = 2; + } +} + +message DebugBlockRequest { + int64 number = 1; +} + +message DebugFileResponse { + oneof event { + Open open = 1; + Input input = 2; + google.protobuf.Empty eof = 3; + } + + message Open { + map headers = 1; + } + + message Input { + bytes data = 1; + } +} diff --git a/internal/cli/server/proto/server_grpc.pb.go b/internal/cli/server/proto/server_grpc.pb.go new file mode 100644 index 0000000000..3d74a5fde6 --- /dev/null +++ b/internal/cli/server/proto/server_grpc.pb.go @@ -0,0 +1,520 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.12 +// source: internal/cli/server/proto/server.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// BorClient is the client API for Bor service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BorClient interface { + PeersAdd(ctx context.Context, in *PeersAddRequest, opts ...grpc.CallOption) (*PeersAddResponse, error) + PeersRemove(ctx context.Context, in *PeersRemoveRequest, opts ...grpc.CallOption) (*PeersRemoveResponse, error) + PeersList(ctx context.Context, in *PeersListRequest, opts ...grpc.CallOption) (*PeersListResponse, error) + PeersStatus(ctx context.Context, in *PeersStatusRequest, opts ...grpc.CallOption) (*PeersStatusResponse, error) + ChainSetHead(ctx context.Context, in *ChainSetHeadRequest, opts ...grpc.CallOption) (*ChainSetHeadResponse, error) + Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) + ChainWatch(ctx context.Context, in *ChainWatchRequest, opts ...grpc.CallOption) (Bor_ChainWatchClient, error) + DebugPprof(ctx context.Context, in *DebugPprofRequest, opts ...grpc.CallOption) (Bor_DebugPprofClient, error) + DebugBlock(ctx context.Context, in *DebugBlockRequest, opts ...grpc.CallOption) (Bor_DebugBlockClient, error) +} + +type borClient struct { + cc grpc.ClientConnInterface +} + +func NewBorClient(cc grpc.ClientConnInterface) BorClient { + return &borClient{cc} +} + +func (c *borClient) PeersAdd(ctx context.Context, in *PeersAddRequest, opts ...grpc.CallOption) (*PeersAddResponse, error) { + out := new(PeersAddResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/PeersAdd", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) PeersRemove(ctx context.Context, in *PeersRemoveRequest, opts ...grpc.CallOption) (*PeersRemoveResponse, error) { + out := new(PeersRemoveResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/PeersRemove", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) PeersList(ctx context.Context, in *PeersListRequest, opts ...grpc.CallOption) (*PeersListResponse, error) { + out := new(PeersListResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/PeersList", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) PeersStatus(ctx context.Context, in *PeersStatusRequest, opts ...grpc.CallOption) (*PeersStatusResponse, error) { + out := new(PeersStatusResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/PeersStatus", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) ChainSetHead(ctx context.Context, in *ChainSetHeadRequest, opts ...grpc.CallOption) (*ChainSetHeadResponse, error) { + out := new(ChainSetHeadResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/ChainSetHead", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + + err := c.cc.Invoke(ctx, "/proto.Bor/Status", in, out, opts...) + if err != nil { + return nil, err + } + + return out, nil +} + +func (c *borClient) ChainWatch(ctx context.Context, in *ChainWatchRequest, opts ...grpc.CallOption) (Bor_ChainWatchClient, error) { + stream, err := c.cc.NewStream(ctx, &Bor_ServiceDesc.Streams[0], "/proto.Bor/ChainWatch", opts...) + if err != nil { + return nil, err + } + + x := &borChainWatchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + + return x, nil +} + +type Bor_ChainWatchClient interface { + Recv() (*ChainWatchResponse, error) + grpc.ClientStream +} + +type borChainWatchClient struct { + grpc.ClientStream +} + +func (x *borChainWatchClient) Recv() (*ChainWatchResponse, error) { + m := new(ChainWatchResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + + return m, nil +} + +func (c *borClient) DebugPprof(ctx context.Context, in *DebugPprofRequest, opts ...grpc.CallOption) (Bor_DebugPprofClient, error) { + stream, err := c.cc.NewStream(ctx, &Bor_ServiceDesc.Streams[1], "/proto.Bor/DebugPprof", opts...) + if err != nil { + return nil, err + } + + x := &borDebugPprofClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + + return x, nil +} + +type Bor_DebugPprofClient interface { + Recv() (*DebugFileResponse, error) + grpc.ClientStream +} + +type borDebugPprofClient struct { + grpc.ClientStream +} + +func (x *borDebugPprofClient) Recv() (*DebugFileResponse, error) { + m := new(DebugFileResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + + return m, nil +} + +func (c *borClient) DebugBlock(ctx context.Context, in *DebugBlockRequest, opts ...grpc.CallOption) (Bor_DebugBlockClient, error) { + stream, err := c.cc.NewStream(ctx, &Bor_ServiceDesc.Streams[2], "/proto.Bor/DebugBlock", opts...) + if err != nil { + return nil, err + } + + x := &borDebugBlockClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + + return x, nil +} + +type Bor_DebugBlockClient interface { + Recv() (*DebugFileResponse, error) + grpc.ClientStream +} + +type borDebugBlockClient struct { + grpc.ClientStream +} + +func (x *borDebugBlockClient) Recv() (*DebugFileResponse, error) { + m := new(DebugFileResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + + return m, nil +} + +// BorServer is the server API for Bor service. +// All implementations must embed UnimplementedBorServer +// for forward compatibility +type BorServer interface { + PeersAdd(context.Context, *PeersAddRequest) (*PeersAddResponse, error) + PeersRemove(context.Context, *PeersRemoveRequest) (*PeersRemoveResponse, error) + PeersList(context.Context, *PeersListRequest) (*PeersListResponse, error) + PeersStatus(context.Context, *PeersStatusRequest) (*PeersStatusResponse, error) + ChainSetHead(context.Context, *ChainSetHeadRequest) (*ChainSetHeadResponse, error) + Status(context.Context, *StatusRequest) (*StatusResponse, error) + ChainWatch(*ChainWatchRequest, Bor_ChainWatchServer) error + DebugPprof(*DebugPprofRequest, Bor_DebugPprofServer) error + DebugBlock(*DebugBlockRequest, Bor_DebugBlockServer) error + mustEmbedUnimplementedBorServer() +} + +// UnimplementedBorServer must be embedded to have forward compatible implementations. +type UnimplementedBorServer struct { +} + +func (UnimplementedBorServer) PeersAdd(context.Context, *PeersAddRequest) (*PeersAddResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PeersAdd not implemented") +} +func (UnimplementedBorServer) PeersRemove(context.Context, *PeersRemoveRequest) (*PeersRemoveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PeersRemove not implemented") +} +func (UnimplementedBorServer) PeersList(context.Context, *PeersListRequest) (*PeersListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PeersList not implemented") +} +func (UnimplementedBorServer) PeersStatus(context.Context, *PeersStatusRequest) (*PeersStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PeersStatus not implemented") +} +func (UnimplementedBorServer) ChainSetHead(context.Context, *ChainSetHeadRequest) (*ChainSetHeadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChainSetHead not implemented") +} +func (UnimplementedBorServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} +func (UnimplementedBorServer) ChainWatch(*ChainWatchRequest, Bor_ChainWatchServer) error { + return status.Errorf(codes.Unimplemented, "method ChainWatch not implemented") +} +func (UnimplementedBorServer) DebugPprof(*DebugPprofRequest, Bor_DebugPprofServer) error { + return status.Errorf(codes.Unimplemented, "method DebugPprof not implemented") +} +func (UnimplementedBorServer) DebugBlock(*DebugBlockRequest, Bor_DebugBlockServer) error { + return status.Errorf(codes.Unimplemented, "method DebugBlock not implemented") +} +func (UnimplementedBorServer) mustEmbedUnimplementedBorServer() {} + +// UnsafeBorServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BorServer will +// result in compilation errors. +type UnsafeBorServer interface { + mustEmbedUnimplementedBorServer() +} + +func RegisterBorServer(s grpc.ServiceRegistrar, srv BorServer) { + s.RegisterService(&Bor_ServiceDesc, srv) +} + +func _Bor_PeersAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeersAddRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).PeersAdd(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/PeersAdd", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).PeersAdd(ctx, req.(*PeersAddRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_PeersRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeersRemoveRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).PeersRemove(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/PeersRemove", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).PeersRemove(ctx, req.(*PeersRemoveRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_PeersList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeersListRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).PeersList(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/PeersList", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).PeersList(ctx, req.(*PeersListRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_PeersStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeersStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).PeersStatus(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/PeersStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).PeersStatus(ctx, req.(*PeersStatusRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_ChainSetHead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ChainSetHeadRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).ChainSetHead(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/ChainSetHead", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).ChainSetHead(ctx, req.(*ChainSetHeadRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) + if err := dec(in); err != nil { + return nil, err + } + + if interceptor == nil { + return srv.(BorServer).Status(ctx, in) + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Bor/Status", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BorServer).Status(ctx, req.(*StatusRequest)) + } + + return interceptor(ctx, in, info, handler) +} + +func _Bor_ChainWatch_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ChainWatchRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + + return srv.(BorServer).ChainWatch(m, &borChainWatchServer{stream}) +} + +type Bor_ChainWatchServer interface { + Send(*ChainWatchResponse) error + grpc.ServerStream +} + +type borChainWatchServer struct { + grpc.ServerStream +} + +func (x *borChainWatchServer) Send(m *ChainWatchResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Bor_DebugPprof_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DebugPprofRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + + return srv.(BorServer).DebugPprof(m, &borDebugPprofServer{stream}) +} + +type Bor_DebugPprofServer interface { + Send(*DebugFileResponse) error + grpc.ServerStream +} + +type borDebugPprofServer struct { + grpc.ServerStream +} + +func (x *borDebugPprofServer) Send(m *DebugFileResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Bor_DebugBlock_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DebugBlockRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + + return srv.(BorServer).DebugBlock(m, &borDebugBlockServer{stream}) +} + +type Bor_DebugBlockServer interface { + Send(*DebugFileResponse) error + grpc.ServerStream +} + +type borDebugBlockServer struct { + grpc.ServerStream +} + +func (x *borDebugBlockServer) Send(m *DebugFileResponse) error { + return x.ServerStream.SendMsg(m) +} + +// Bor_ServiceDesc is the grpc.ServiceDesc for Bor service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Bor_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Bor", + HandlerType: (*BorServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PeersAdd", + Handler: _Bor_PeersAdd_Handler, + }, + { + MethodName: "PeersRemove", + Handler: _Bor_PeersRemove_Handler, + }, + { + MethodName: "PeersList", + Handler: _Bor_PeersList_Handler, + }, + { + MethodName: "PeersStatus", + Handler: _Bor_PeersStatus_Handler, + }, + { + MethodName: "ChainSetHead", + Handler: _Bor_ChainSetHead_Handler, + }, + { + MethodName: "Status", + Handler: _Bor_Status_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "ChainWatch", + Handler: _Bor_ChainWatch_Handler, + ServerStreams: true, + }, + { + StreamName: "DebugPprof", + Handler: _Bor_DebugPprof_Handler, + ServerStreams: true, + }, + { + StreamName: "DebugBlock", + Handler: _Bor_DebugBlock_Handler, + ServerStreams: true, + }, + }, + Metadata: "internal/cli/server/proto/server.proto", +} diff --git a/internal/cli/server/server.go b/internal/cli/server/server.go new file mode 100644 index 0000000000..171b7e167e --- /dev/null +++ b/internal/cli/server/server.go @@ -0,0 +1,517 @@ +package server + +import ( + "context" + "fmt" + "io" + "math/big" + "net" + "net/http" + "os" + "runtime" + "strings" + "time" + + "github.com/mattn/go-colorable" + "github.com/mattn/go-isatty" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/propagation" + "go.opentelemetry.io/otel/sdk/resource" + sdktrace "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "google.golang.org/grpc" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/consensus/beacon" //nolint:typecheck + "github.com/ethereum/go-ethereum/consensus/bor" //nolint:typecheck + "github.com/ethereum/go-ethereum/consensus/clique" + "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/ethereum/go-ethereum/ethstats" + "github.com/ethereum/go-ethereum/graphql" + "github.com/ethereum/go-ethereum/internal/cli/server/pprof" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/metrics/influxdb" + "github.com/ethereum/go-ethereum/metrics/prometheus" + "github.com/ethereum/go-ethereum/node" + + // Force-load the tracer engines to trigger registration + _ "github.com/ethereum/go-ethereum/eth/tracers/js" + _ "github.com/ethereum/go-ethereum/eth/tracers/native" +) + +type Server struct { + proto.UnimplementedBorServer + node *node.Node + backend *eth.Ethereum + grpcServer *grpc.Server + tracer *sdktrace.TracerProvider + config *Config + + // tracerAPI to trace block executions + tracerAPI *tracers.API +} + +type serverOption func(srv *Server, config *Config) error + +var glogger *log.GlogHandler + +func init() { + glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + glogger.Verbosity(log.LvlInfo) + log.Root().SetHandler(glogger) +} + +func WithGRPCAddress() serverOption { + return func(srv *Server, config *Config) error { + return srv.gRPCServerByAddress(config.GRPC.Addr) + } +} + +func WithGRPCListener(lis net.Listener) serverOption { + return func(srv *Server, _ *Config) error { + return srv.gRPCServerByListener(lis) + } +} + +func VerbosityIntToString(verbosity int) string { + mapIntToString := map[int]string{ + 5: "trace", + 4: "debug", + 3: "info", + 2: "warn", + 1: "error", + 0: "crit", + } + + return mapIntToString[verbosity] +} + +func VerbosityStringToInt(loglevel string) int { + mapStringToInt := map[string]int{ + "trace": 5, + "debug": 4, + "info": 3, + "warn": 2, + "error": 1, + "crit": 0, + } + + return mapStringToInt[loglevel] +} + +//nolint:gocognit +func NewServer(config *Config, opts ...serverOption) (*Server, error) { + // start pprof + if config.Pprof.Enabled { + pprof.SetMemProfileRate(config.Pprof.MemProfileRate) + pprof.SetSetBlockProfileRate(config.Pprof.BlockProfileRate) + pprof.StartPProf(fmt.Sprintf("%s:%d", config.Pprof.Addr, config.Pprof.Port)) + } + + runtime.SetMutexProfileFraction(5) + + srv := &Server{ + config: config, + } + + // start the logger + setupLogger(VerbosityIntToString(config.Verbosity), *config.Logging) + + var err error + + for _, opt := range opts { + err = opt(srv, config) + if err != nil { + return nil, err + } + } + + // load the chain genesis + if err = config.loadChain(); err != nil { + return nil, err + } + + // create the node/stack + nodeCfg, err := config.buildNode() + if err != nil { + return nil, err + } + + stack, err := node.New(nodeCfg) + if err != nil { + return nil, err + } + + // setup account manager (only keystore) + // create a new account manager, only for the scope of this function + accountManager := accounts.NewManager(&accounts.Config{}) + + // register backend to account manager with keystore for signing + keydir := stack.KeyStoreDir() + + n, p := keystore.StandardScryptN, keystore.StandardScryptP + if config.Accounts.UseLightweightKDF { + n, p = keystore.LightScryptN, keystore.LightScryptP + } + + // proceed to authorize the local account manager in any case + accountManager.AddBackend(keystore.NewKeyStore(keydir, n, p)) + + // flag to set if we're authorizing consensus here + authorized := false + + var ethCfg *ethconfig.Config + + // check if personal wallet endpoints are disabled or not + // nolint:nestif + if !config.Accounts.DisableBorWallet { + // add keystore globally to the node's account manager if personal wallet is enabled + stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p)) + + // register the ethereum backend + ethCfg, err = config.buildEth(stack, stack.AccountManager()) + if err != nil { + return nil, err + } + + backend, err := eth.New(stack, ethCfg) + if err != nil { + return nil, err + } + + srv.backend = backend + } else { + // register the ethereum backend (with temporary created account manager) + ethCfg, err = config.buildEth(stack, accountManager) + if err != nil { + return nil, err + } + + backend, err := eth.New(stack, ethCfg) + if err != nil { + return nil, err + } + + srv.backend = backend + + // authorize only if mining or in developer mode + if config.Sealer.Enabled || config.Developer.Enabled { + // get the etherbase + eb, err := srv.backend.Etherbase() + if err != nil { + log.Error("Cannot start mining without etherbase", "err", err) + + return nil, fmt.Errorf("etherbase missing: %v", err) + } + + // Authorize the clique consensus (if chosen) to sign using wallet signer + var cli *clique.Clique + if c, ok := srv.backend.Engine().(*clique.Clique); ok { + cli = c + } else if cl, ok := srv.backend.Engine().(*beacon.Beacon); ok { + if c, ok := cl.InnerEngine().(*clique.Clique); ok { + cli = c + } + } + + if cli != nil { + wallet, err := accountManager.Find(accounts.Account{Address: eb}) + if wallet == nil || err != nil { + log.Error("Etherbase account unavailable locally", "err", err) + return nil, fmt.Errorf("signer missing: %v", err) + } + + cli.Authorize(eb, wallet.SignData) + + authorized = true + } + + // Authorize the bor consensus (if chosen) to sign using wallet signer + if bor, ok := srv.backend.Engine().(*bor.Bor); ok { + wallet, err := accountManager.Find(accounts.Account{Address: eb}) + if wallet == nil || err != nil { + log.Error("Etherbase account unavailable locally", "err", err) + return nil, fmt.Errorf("signer missing: %v", err) + } + + bor.Authorize(eb, wallet.SignData) + + authorized = true + } + } + } + + // set the auth status in backend + srv.backend.SetAuthorized(authorized) + + filterSystem := utils.RegisterFilterAPI(stack, srv.backend.APIBackend, ethCfg) + + // debug tracing is enabled by default + stack.RegisterAPIs(tracers.APIs(srv.backend.APIBackend)) + srv.tracerAPI = tracers.NewAPI(srv.backend.APIBackend) + + // graphql is started from another place + if config.JsonRPC.Graphql.Enabled { + if err := graphql.New(stack, srv.backend.APIBackend, filterSystem, config.JsonRPC.Graphql.Cors, config.JsonRPC.Graphql.VHost); err != nil { + return nil, fmt.Errorf("failed to register the GraphQL service: %v", err) + } + } + + // register ethash service + if config.Ethstats != "" { + if err := ethstats.New(stack, srv.backend.APIBackend, srv.backend.Engine(), config.Ethstats); err != nil { + return nil, err + } + } + + // sealing (if enabled) or in dev mode + if config.Sealer.Enabled || config.Developer.Enabled { + if err := srv.backend.StartMining(1); err != nil { + return nil, err + } + } + + if err := srv.setupMetrics(config.Telemetry, config.Identity); err != nil { + return nil, err + } + + // Set the node instance + srv.node = stack + + // start the node + if err := srv.node.Start(); err != nil { + return nil, err + } + + return srv, nil +} + +func (s *Server) Stop() { + if s.node != nil { + s.node.Close() + } + + if s.grpcServer != nil { + s.grpcServer.Stop() + } + + // shutdown the tracer + if s.tracer != nil { + if err := s.tracer.Shutdown(context.Background()); err != nil { + log.Error("Failed to shutdown open telemetry tracer") + } + } +} + +func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error { + // Check the global metrics if they're matching with the provided config + if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive { + log.Warn( + "Metric misconfiguration, some of them might not be visible", + "metrics", metrics.Enabled, + "config.metrics", config.Enabled, + "expensive", metrics.EnabledExpensive, + "config.expensive", config.Expensive, + ) + } + + // Update the values anyways (for services which don't need immediate attention) + metrics.Enabled = config.Enabled + metrics.EnabledExpensive = config.Expensive + + if !metrics.Enabled { + // metrics are disabled, do not set up any sink + return nil + } + + log.Info("Enabling metrics collection") + + if metrics.EnabledExpensive { + log.Info("Enabling expensive metrics collection") + } + + // influxdb + if v1Enabled, v2Enabled := config.InfluxDB.V1Enabled, config.InfluxDB.V2Enabled; v1Enabled || v2Enabled { + if v1Enabled && v2Enabled { + return fmt.Errorf("both influx v1 and influx v2 cannot be enabled") + } + + cfg := config.InfluxDB + tags := cfg.Tags + endpoint := cfg.Endpoint + + if v1Enabled { + log.Info("Enabling metrics export to InfluxDB (v1)") + + go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, cfg.Database, cfg.Username, cfg.Password, "geth.", tags) + } + + if v2Enabled { + log.Info("Enabling metrics export to InfluxDB (v2)") + + go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, cfg.Token, cfg.Bucket, cfg.Organization, "geth.", tags) + } + } + + // Start system runtime metrics collection + go metrics.CollectProcessMetrics(3 * time.Second) + + if config.PrometheusAddr != "" { + prometheusMux := http.NewServeMux() + + prometheusMux.Handle("/debug/metrics/prometheus", prometheus.Handler(metrics.DefaultRegistry)) + + promServer := &http.Server{ + Addr: config.PrometheusAddr, + Handler: prometheusMux, + } + + go func() { + if err := promServer.ListenAndServe(); err != nil { + log.Error("Failure in running Prometheus server", "err", err) + } + }() + + log.Info("Enabling metrics export to prometheus", "path", fmt.Sprintf("http://%s/debug/metrics/prometheus", config.PrometheusAddr)) + } + + if config.OpenCollectorEndpoint != "" { + // setup open collector tracer + ctx := context.Background() + + res, err := resource.New(ctx, + resource.WithAttributes( + // the service name used to display traces in backends + semconv.ServiceNameKey.String(serviceName), + ), + ) + if err != nil { + return fmt.Errorf("failed to create open telemetry resource for service: %v", err) + } + + // Set up a trace exporter + traceExporter, err := otlptracegrpc.New( + ctx, + otlptracegrpc.WithInsecure(), + otlptracegrpc.WithEndpoint(config.OpenCollectorEndpoint), + ) + if err != nil { + return fmt.Errorf("failed to create open telemetry tracer exporter for service: %v", err) + } + + // Register the trace exporter with a TracerProvider, using a batch + // span processor to aggregate spans before export. + bsp := sdktrace.NewBatchSpanProcessor(traceExporter) + tracerProvider := sdktrace.NewTracerProvider( + sdktrace.WithSampler(sdktrace.AlwaysSample()), + sdktrace.WithResource(res), + sdktrace.WithSpanProcessor(bsp), + ) + otel.SetTracerProvider(tracerProvider) + + // set global propagator to tracecontext (the default is no-op). + otel.SetTextMapPropagator(propagation.TraceContext{}) + + // set the tracer + s.tracer = tracerProvider + + log.Info("Open collector tracing started", "address", config.OpenCollectorEndpoint) + } + + return nil +} + +func (s *Server) gRPCServerByAddress(addr string) error { + lis, err := net.Listen("tcp", addr) + if err != nil { + return err + } + + return s.gRPCServerByListener(lis) +} + +func (s *Server) gRPCServerByListener(listener net.Listener) error { + s.grpcServer = grpc.NewServer(s.withLoggingUnaryInterceptor()) + proto.RegisterBorServer(s.grpcServer, s) + + go func() { + if err := s.grpcServer.Serve(listener); err != nil { + log.Error("failed to serve grpc server", "err", err) + } + }() + + log.Info("GRPC Server started", "addr", listener.Addr()) + + return nil +} + +func (s *Server) withLoggingUnaryInterceptor() grpc.ServerOption { + return grpc.UnaryInterceptor(s.loggingServerInterceptor) +} + +func (s *Server) loggingServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + start := time.Now() + h, err := handler(ctx, req) + + log.Trace("Request", "method", info.FullMethod, "duration", time.Since(start), "error", err) + + return h, err +} + +func setupLogger(logLevel string, loggingInfo LoggingConfig) { + var ostream log.Handler + + output := io.Writer(os.Stderr) + + if loggingInfo.Json { + ostream = log.StreamHandler(output, log.JSONFormat()) + } else { + usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb" + if usecolor { + output = colorable.NewColorableStderr() + } + + ostream = log.StreamHandler(output, log.TerminalFormat(usecolor)) + } + + glogger.SetHandler(ostream) + + // logging + lvl, err := log.LvlFromString(strings.ToLower(logLevel)) + if err == nil { + glogger.Verbosity(lvl) + } else { + glogger.Verbosity(log.LvlInfo) + } + + if loggingInfo.Vmodule != "" { + if err := glogger.Vmodule(loggingInfo.Vmodule); err != nil { + log.Error("failed to set Vmodule", "err", err) + } + } + + log.PrintOrigins(loggingInfo.Debug) + + if loggingInfo.Backtrace != "" { + if err := glogger.BacktraceAt(loggingInfo.Backtrace); err != nil { + log.Error("failed to set BacktraceAt", "err", err) + } + } + + log.Root().SetHandler(glogger) +} + +func (s *Server) GetLatestBlockNumber() *big.Int { + return s.backend.BlockChain().CurrentBlock().Number +} + +func (s *Server) GetGrpcAddr() string { + return s.config.GRPC.Addr[1:] +} diff --git a/internal/cli/server/server_test.go b/internal/cli/server/server_test.go new file mode 100644 index 0000000000..ab14c31a5d --- /dev/null +++ b/internal/cli/server/server_test.go @@ -0,0 +1,64 @@ +package server + +import ( + "fmt" + "net" + "sync/atomic" + "testing" + "time" + + "github.com/ethereum/go-ethereum/log" + + "github.com/stretchr/testify/assert" +) + +var initialPort uint64 = 61000 + +// nextPort gives the next available port starting from 60000 +func nextPort() uint64 { + log.Info("Checking for new port", "current", initialPort) + port := atomic.AddUint64(&initialPort, 1) + addr := fmt.Sprintf("localhost:%d", port) + + lis, err := net.Listen("tcp", addr) + if err == nil { + lis.Close() + + return port + } else { + return nextPort() + } +} + +func TestServer_DeveloperMode(t *testing.T) { + t.Parallel() + + // get the default config + config := DefaultConfig() + + // enable developer mode + config.Developer.Enabled = true + config.Developer.Period = 2 // block time + + // start the mock server + server, err := CreateMockServer(config) + assert.NoError(t, err) + + defer CloseMockServer(server) + + // record the initial block number + blockNumber := server.backend.BlockChain().CurrentBlock().Number.Int64() + + var i int64 = 0 + for i = 0; i < 3; i++ { + // We expect the node to mine blocks every `config.Developer.Period` time period + time.Sleep(time.Duration(config.Developer.Period) * time.Second) + + currBlock := server.backend.BlockChain().CurrentBlock().Number.Int64() + expected := blockNumber + i + 1 + + if res := assert.Equal(t, currBlock, expected); res == false { + break + } + } +} diff --git a/internal/cli/server/service.go b/internal/cli/server/service.go new file mode 100644 index 0000000000..bf72a0e848 --- /dev/null +++ b/internal/cli/server/service.go @@ -0,0 +1,347 @@ +package server + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "math/big" + "reflect" + "strings" + "time" + + grpc_net_conn "github.com/JekaMas/go-grpc-net-conn" + + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/ethereum/go-ethereum/eth/tracers/logger" + "github.com/ethereum/go-ethereum/internal/cli/server/pprof" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" + "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enode" +) + +const chunkSize = 1024 * 1024 * 1024 + +var ErrUnavailable = errors.New("bor service is currently unavailable, try again later") +var ErrUnavailable2 = errors.New("bor service unavailable even after waiting for 10 seconds, make sure bor is running") + +func sendStreamDebugFile(stream proto.Bor_DebugPprofServer, headers map[string]string, data []byte) error { + // open the stream and send the headers + err := stream.Send(&proto.DebugFileResponse{ + Event: &proto.DebugFileResponse_Open_{ + Open: &proto.DebugFileResponse_Open{ + Headers: headers, + }, + }, + }) + if err != nil { + return err + } + + // Wrap our conn around the response. + encoder := grpc_net_conn.SimpleEncoder(func(msg *proto.DebugFileResponse_Input) *[]byte { + return &msg.Data + }) + + conn := &grpc_net_conn.Conn[*proto.DebugFileResponse_Input, *proto.DebugFileResponse_Input]{ + Stream: stream, + Request: &proto.DebugFileResponse_Input{}, + Encode: grpc_net_conn.ChunkedEncoder(encoder, chunkSize), + } + + if _, err := conn.Write(data); err != nil { + return err + } + + // send the eof + err = stream.Send(&proto.DebugFileResponse{ + Event: &proto.DebugFileResponse_Eof{}, + }) + if err != nil { + return err + } + + return nil +} + +func (s *Server) DebugPprof(req *proto.DebugPprofRequest, stream proto.Bor_DebugPprofServer) error { + var ( + payload []byte + headers map[string]string + err error + ) + + ctx := context.Background() + + switch req.Type { + case proto.DebugPprofRequest_CPU: + payload, headers, err = pprof.CPUProfile(ctx, int(req.Seconds)) + case proto.DebugPprofRequest_TRACE: + payload, headers, err = pprof.Trace(ctx, int(req.Seconds)) + case proto.DebugPprofRequest_LOOKUP: + payload, headers, err = pprof.Profile(req.Profile, 0, 0) + } + + if err != nil { + return err + } + + // send the file on a grpc stream + if err := sendStreamDebugFile(stream, headers, payload); err != nil { + return err + } + + return nil +} + +func (s *Server) PeersAdd(ctx context.Context, req *proto.PeersAddRequest) (*proto.PeersAddResponse, error) { + node, err := enode.Parse(enode.ValidSchemes, req.Enode) + if err != nil { + return nil, fmt.Errorf("invalid enode: %v", err) + } + + srv := s.node.Server() + if req.Trusted { + srv.AddTrustedPeer(node) + } else { + srv.AddPeer(node) + } + + return &proto.PeersAddResponse{}, nil +} + +func (s *Server) PeersRemove(ctx context.Context, req *proto.PeersRemoveRequest) (*proto.PeersRemoveResponse, error) { + node, err := enode.Parse(enode.ValidSchemes, req.Enode) + if err != nil { + return nil, fmt.Errorf("invalid enode: %v", err) + } + + srv := s.node.Server() + if req.Trusted { + srv.RemoveTrustedPeer(node) + } else { + srv.RemovePeer(node) + } + + return &proto.PeersRemoveResponse{}, nil +} + +func (s *Server) PeersList(ctx context.Context, req *proto.PeersListRequest) (*proto.PeersListResponse, error) { + resp := &proto.PeersListResponse{} + + peers := s.node.Server().PeersInfo() + for _, p := range peers { + resp.Peers = append(resp.Peers, peerInfoToPeer(p)) + } + + return resp, nil +} + +func (s *Server) PeersStatus(ctx context.Context, req *proto.PeersStatusRequest) (*proto.PeersStatusResponse, error) { + var peerInfo *p2p.PeerInfo + + for _, p := range s.node.Server().PeersInfo() { + if strings.HasPrefix(p.ID, req.Enode) { + if peerInfo != nil { + return nil, fmt.Errorf("more than one peer with the same prefix") + } + + peerInfo = p + } + } + + resp := &proto.PeersStatusResponse{} + if peerInfo != nil { + resp.Peer = peerInfoToPeer(peerInfo) + } + + return resp, nil +} + +func peerInfoToPeer(info *p2p.PeerInfo) *proto.Peer { + return &proto.Peer{ + Id: info.ID, + Enode: info.Enode, + Enr: info.ENR, + Caps: info.Caps, + Name: info.Name, + Trusted: info.Network.Trusted, + Static: info.Network.Static, + } +} + +func (s *Server) ChainSetHead(ctx context.Context, req *proto.ChainSetHeadRequest) (*proto.ChainSetHeadResponse, error) { + s.backend.APIBackend.SetHead(req.Number) + return &proto.ChainSetHeadResponse{}, nil +} + +func (s *Server) Status(ctx context.Context, in *proto.StatusRequest) (*proto.StatusResponse, error) { + if s.backend == nil && !in.Wait { + return nil, ErrUnavailable + } + + // check for s.backend at an interval of 2 seconds + // wait for a maximum of 10 seconds (5 iterations) + if s.backend == nil && in.Wait { + i := 1 + + for { + time.Sleep(2 * time.Second) + + if s.backend == nil { + if i == 5 { + return nil, ErrUnavailable2 + } + } else { + break + } + + i++ + } + } + + apiBackend := s.backend.APIBackend + syncProgress := apiBackend.SyncProgress() + + resp := &proto.StatusResponse{ + CurrentHeader: headerToProtoHeader(apiBackend.CurrentHeader()), + CurrentBlock: headerToProtoHeader(apiBackend.CurrentBlock()), + NumPeers: int64(len(s.node.Server().PeersInfo())), + SyncMode: s.config.SyncMode, + Syncing: &proto.StatusResponse_Syncing{ + StartingBlock: int64(syncProgress.StartingBlock), + HighestBlock: int64(syncProgress.HighestBlock), + CurrentBlock: int64(syncProgress.CurrentBlock), + }, + Forks: gatherForks(s.config.chain.Genesis.Config, s.config.chain.Genesis.Config.Bor), + } + + return resp, nil +} + +func headerToProtoHeader(h *types.Header) *proto.Header { + return &proto.Header{ + Hash: h.Hash().String(), + Number: h.Number.Uint64(), + } +} + +func (s *Server) DebugBlock(req *proto.DebugBlockRequest, stream proto.Bor_DebugBlockServer) error { + traceReq := &tracers.TraceBlockRequest{ + Number: req.Number, + Config: &tracers.TraceConfig{ + Config: &logger.Config{ + EnableMemory: true, + }, + }, + } + + res, err := s.tracerAPI.TraceBorBlock(traceReq) + if err != nil { + return err + } + + // this is memory heavy + data, err := json.Marshal(res) + if err != nil { + return err + } + + if err := sendStreamDebugFile(stream, map[string]string{}, data); err != nil { + return err + } + + return nil +} + +var bigIntT = reflect.TypeOf(new(big.Int)).Kind() + +// gatherForks gathers all the fork numbers via reflection +func gatherForks(configList ...interface{}) []*proto.StatusResponse_Fork { + var forks []*proto.StatusResponse_Fork + + for _, config := range configList { + kind := reflect.TypeOf(config) + for kind.Kind() == reflect.Ptr { + kind = kind.Elem() + } + + skip := "DAOForkBlock" + + conf := reflect.ValueOf(config).Elem() + + for i := 0; i < kind.NumField(); i++ { + // Fetch the next field and skip non-fork rules + field := kind.Field(i) + if strings.Contains(field.Name, skip) { + continue + } + + if !strings.HasSuffix(field.Name, "Block") { + continue + } + + fork := &proto.StatusResponse_Fork{ + Name: strings.TrimSuffix(field.Name, "Block"), + } + + val := conf.Field(i) + + switch field.Type.Kind() { + case bigIntT: + rule := val.Interface().(*big.Int) + if rule != nil { + fork.Block = rule.Int64() + } else { + fork.Disabled = true + } + case reflect.Uint64: + fork.Block = int64(val.Uint()) + + default: + continue + } + + forks = append(forks, fork) + } + } + + return forks +} + +func convertBlockToBlockStub(blocks []*types.Block) []*proto.BlockStub { + var blockStubs []*proto.BlockStub + + for _, block := range blocks { + blockStub := &proto.BlockStub{ + Hash: block.Hash().String(), + Number: block.NumberU64(), + } + blockStubs = append(blockStubs, blockStub) + } + + return blockStubs +} + +func (s *Server) ChainWatch(req *proto.ChainWatchRequest, reply proto.Bor_ChainWatchServer) error { + chain2HeadChanSize := 10 + + chain2HeadCh := make(chan core.Chain2HeadEvent, chain2HeadChanSize) + + headSub := s.backend.APIBackend.SubscribeChain2HeadEvent(chain2HeadCh) + defer headSub.Unsubscribe() + + for { + msg := <-chain2HeadCh + + err := reply.Send(&proto.ChainWatchResponse{Type: msg.Type, + Newchain: convertBlockToBlockStub(msg.NewChain), + Oldchain: convertBlockToBlockStub(msg.OldChain), + }) + if err != nil { + return err + } + } +} diff --git a/internal/cli/server/service_test.go b/internal/cli/server/service_test.go new file mode 100644 index 0000000000..47e8013e57 --- /dev/null +++ b/internal/cli/server/service_test.go @@ -0,0 +1,46 @@ +package server + +import ( + "math/big" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +func TestGatherBlocks(t *testing.T) { + type c struct { + ABlock *big.Int + BBlock *big.Int + } + + type d struct { + DBlock uint64 + } + + val := &c{ + BBlock: new(big.Int).SetInt64(1), + } + val2 := &d{ + DBlock: 10, + } + + expect := []*proto.StatusResponse_Fork{ + { + Name: "A", + Disabled: true, + }, + { + Name: "B", + Block: 1, + }, + { + Name: "D", + Block: 10, + }, + } + + res := gatherForks(val, val2) + assert.Equal(t, res, expect) +} diff --git a/internal/cli/server/testdata/password.txt b/internal/cli/server/testdata/password.txt new file mode 100644 index 0000000000..1827ffa521 --- /dev/null +++ b/internal/cli/server/testdata/password.txt @@ -0,0 +1,2 @@ +test1 +test2 \ No newline at end of file diff --git a/internal/cli/server/testdata/test.toml b/internal/cli/server/testdata/test.toml new file mode 100644 index 0000000000..4ccc644ee9 --- /dev/null +++ b/internal/cli/server/testdata/test.toml @@ -0,0 +1,25 @@ +datadir = "./data" +snapshot = false + +["eth.requiredblocks"] +"31000000" = "0x2087b9e2b353209c2c21e370c82daa12278efd0fe5f0febe6c29035352cf050e" +"32000000" = "0x875500011e5eecc0c554f95d07b31cf59df4ca2505f4dbbfffa7d4e4da917c68" + +[p2p] +maxpeers = 30 + +[txpool] +locals = [] +lifetime = "1s" + +[miner] +mine = true +gaslimit = 30000000 +gasprice = "1000000000" + +[gpo] +ignoreprice = "4" + +[cache] +cache = 1024 +rejournal = "1s" diff --git a/internal/cli/snapshot.go b/internal/cli/snapshot.go new file mode 100644 index 0000000000..60034103d3 --- /dev/null +++ b/internal/cli/snapshot.go @@ -0,0 +1,190 @@ +// Snapshot related commands + +package cli + +import ( + "strings" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/state/pruner" + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/node" + + "github.com/mitchellh/cli" +) + +// SnapshotCommand is the command to group the snapshot commands +type SnapshotCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (a *SnapshotCommand) MarkDown() string { + items := []string{ + "# snapshot", + "The ```snapshot``` command groups snapshot related actions:", + "- [```snapshot prune-state```](./snapshot_prune-state.md): Prune state databases at the given datadir location.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *SnapshotCommand) Help() string { + return `Usage: bor snapshot + + This command groups snapshot related actions. + + Prune the state trie: + + $ bor snapshot prune-state` +} + +// Synopsis implements the cli.Command interface +func (c *SnapshotCommand) Synopsis() string { + return "Snapshot related commands" +} + +// Run implements the cli.Command interface +func (c *SnapshotCommand) Run(args []string) int { + return cli.RunResultHelp +} + +type PruneStateCommand struct { + *Meta + + datadirAncient string + cache uint64 + cacheTrie uint64 + cacheTrieJournal string + bloomfilterSize uint64 +} + +// MarkDown implements cli.MarkDown interface +func (c *PruneStateCommand) MarkDown() string { + items := []string{ + "# Prune state", + "The ```bor snapshot prune-state``` command will prune historical state data with the help of the state snapshot. All trie nodes and contract codes that do not belong to the specified version state will be deleted from the database. After pruning, only two version states are available: genesis and the specific one.", + c.Flags().MarkDown(), + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *PruneStateCommand) Help() string { + return `Usage: bor snapshot prune-state + + This command will prune state databases at the given datadir location` + c.Flags().Help() +} + +// Synopsis implements the cli.Command interface +func (c *PruneStateCommand) Synopsis() string { + return "Prune state databases" +} + +// Flags: datadir, datadir.ancient, cache.trie.journal, bloomfilter.size +func (c *PruneStateCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("prune-state") + + flags.StringFlag(&flagset.StringFlag{ + Name: "datadir.ancient", + Value: &c.datadirAncient, + Usage: "Path of the ancient data directory to store information", + Default: "", + }) + + flags.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache", + Usage: "Megabytes of memory allocated to internal caching", + Value: &c.cache, + Default: 1024.0, + Group: "Cache", + }) + + flags.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.trie", + Usage: "Percentage of cache memory allowance to use for trie caching", + Value: &c.cacheTrie, + Default: 25, + Group: "Cache", + }) + + flags.StringFlag(&flagset.StringFlag{ + Name: "cache.trie.journal", + Value: &c.cacheTrieJournal, + Usage: "Path of the trie journal directory to store information", + Default: trieCacheJournalPath, + Group: "Cache", + }) + + flags.Uint64Flag(&flagset.Uint64Flag{ + Name: "bloomfilter.size", + Value: &c.bloomfilterSize, + Usage: "Size of the bloom filter", + Default: 2048, + }) + + return flags +} + +// Run implements the cli.Command interface +func (c *PruneStateCommand) Run(args []string) int { + flags := c.Flags() + + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + datadir := c.dataDir + if datadir == "" { + c.UI.Error("datadir is required") + return 1 + } + + // Create the node + node, err := node.New(&node.Config{ + DataDir: datadir, + }) + + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + dbHandles, err := server.MakeDatabaseHandles(0) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + chaindb, err := node.OpenDatabaseWithFreezer(chaindataPath, int(c.cache), dbHandles, c.datadirAncient, "", false, rawdb.ExtraDBConfig{}) + + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + prunerconfig := pruner.Config{ + Datadir: node.ResolvePath(""), + Cachedir: node.ResolvePath(c.cacheTrieJournal), + BloomSize: c.bloomfilterSize, + } + + pruner, err := pruner.NewPruner(chaindb, prunerconfig) + if err != nil { + log.Error("Failed to open snapshot tree", "err", err) + return 1 + } + + if err = pruner.Prune(common.Hash{}); err != nil { + log.Error("Failed to prune state", "err", err) + return 1 + } + + return 0 +} diff --git a/internal/cli/status.go b/internal/cli/status.go new file mode 100644 index 0000000000..63386d9680 --- /dev/null +++ b/internal/cli/status.go @@ -0,0 +1,115 @@ +package cli + +import ( + "context" + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/internal/cli/flagset" + "github.com/ethereum/go-ethereum/internal/cli/server/proto" +) + +// StatusCommand is the command to output the status of the client +type StatusCommand struct { + *Meta2 + + wait bool +} + +func (c *StatusCommand) Flags() *flagset.Flagset { + flags := c.NewFlagSet("status") + + flags.BoolFlag(&flagset.BoolFlag{ + Name: "w", + Value: &c.wait, + Usage: "wait for Bor node to be available", + Default: false, + }) + + return flags +} + +// MarkDown implements cli.MarkDown interface +func (p *StatusCommand) MarkDown() string { + items := []string{ + "# Status", + "The ```status``` command outputs the status of the client.", + } + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (p *StatusCommand) Help() string { + return `Usage: bor status + + Output the status of the client` +} + +// Synopsis implements the cli.Command interface +func (c *StatusCommand) Synopsis() string { + return "Output the status of the client" +} + +// Run implements the cli.Command interface +func (c *StatusCommand) Run(args []string) int { + flags := c.Flags() + if err := flags.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + borClt, err := c.BorConn() + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + status, err := borClt.Status(context.Background(), &proto.StatusRequest{Wait: c.wait}) + if err != nil { + c.UI.Error(err.Error()) + return 1 + } + + c.UI.Output(printStatus(status)) + + return 0 +} + +func printStatus(status *proto.StatusResponse) string { + printHeader := func(h *proto.Header) string { + return formatKV([]string{ + fmt.Sprintf("Hash|%s", h.Hash), + fmt.Sprintf("Number|%d", h.Number), + }) + } + + forks := make([]string, len(status.Forks)+1) + forks[0] = "Name|Block|Enabled" + + for i, d := range status.Forks { + forks[i+1] = fmt.Sprintf("%s|%d|%v", d.Name, d.Block, !d.Disabled) + } + + full := []string{ + "General", + formatKV([]string{ + fmt.Sprintf("Num peers|%d", status.NumPeers), + fmt.Sprintf("Sync mode|%s", status.SyncMode), + }), + "\nCurrent Header", + printHeader(status.CurrentHeader), + "\nCurrent Block", + printHeader(status.CurrentBlock), + "\nSyncing", + formatKV([]string{ + fmt.Sprintf("Current block|%d", status.Syncing.CurrentBlock), + fmt.Sprintf("Highest block|%d", status.Syncing.HighestBlock), + fmt.Sprintf("Starting block|%d", status.Syncing.StartingBlock), + }), + "\nForks", + formatList(forks), + } + + return strings.Join(full, "\n") +} diff --git a/internal/cli/status_test.go b/internal/cli/status_test.go new file mode 100644 index 0000000000..f45e050da8 --- /dev/null +++ b/internal/cli/status_test.go @@ -0,0 +1,42 @@ +package cli + +import ( + "testing" + + "github.com/mitchellh/cli" + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/internal/cli/server" +) + +func TestStatusCommand(t *testing.T) { + t.Parallel() + + // Start a blockchain in developer + config := server.DefaultConfig() + + // enable developer mode + config.Developer.Enabled = true + config.Developer.Period = 2 + + // start the mock server + srv, err := server.CreateMockServer(config) + require.NoError(t, err) + + defer server.CloseMockServer(srv) + + // get the grpc port + port := srv.GetGrpcAddr() + + command1 := &StatusCommand{ + Meta2: &Meta2{ + UI: cli.NewMockUi(), + addr: "127.0.0.1:" + port, + }, + wait: true, + } + + status := command1.Run([]string{"-w", "--address", command1.Meta2.addr}) + + require.Equal(t, 0, status) +} diff --git a/internal/cli/version.go b/internal/cli/version.go new file mode 100644 index 0000000000..949599904e --- /dev/null +++ b/internal/cli/version.go @@ -0,0 +1,52 @@ +package cli + +import ( + "strings" + + "github.com/ethereum/go-ethereum/params" + + "github.com/mitchellh/cli" +) + +// VersionCommand is the command to show the version of the agent +type VersionCommand struct { + UI cli.Ui +} + +// MarkDown implements cli.MarkDown interface +func (d *VersionCommand) MarkDown() string { + examples := []string{ + "## Usage", + CodeBlock([]string{ + "$ bor version", + "0.2.9-stable", + }), + } + + items := []string{ + "# Version", + "The ```bor version``` command outputs the version of the binary.", + } + items = append(items, examples...) + + return strings.Join(items, "\n\n") +} + +// Help implements the cli.Command interface +func (c *VersionCommand) Help() string { + return `Usage: bor version + + Display the Bor version` +} + +// Synopsis implements the cli.Command interface +func (c *VersionCommand) Synopsis() string { + return "Display the Bor version" +} + +// Run implements the cli.Command interface +func (c *VersionCommand) Run(args []string) int { + c.UI.Output(params.VersionWithMetaCommitDetails) + + return 0 +} diff --git a/params/config.go b/params/config.go index e04b16673c..d821940e54 100644 --- a/params/config.go +++ b/params/config.go @@ -20,6 +20,8 @@ import ( "encoding/binary" "fmt" "math/big" + "sort" + "strconv" "github.com/ethereum/go-ethereum/common" "golang.org/x/crypto/sha3" @@ -27,10 +29,13 @@ import ( // Genesis hashes to enforce below configs on. var ( - MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") - SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9") - RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177") - GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a") + MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") + SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9") + RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177") + GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a") + MumbaiGenesisHash = common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7") + BorMainnetGenesisHash = common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b") + KilnGenesisHash = common.HexToHash("0x51c7fe41be669f69c45c33a56982cbde405313342d9e2b00d7c91a7b284dd4f8") ) // TrustedCheckpoints associates each known checkpoint with the genesis hash of @@ -223,6 +228,204 @@ var ( Threshold: 2, } + // BorTestChainConfig contains the chain parameters to run a node on the Test network. + BorTestChainConfig = &ChainConfig{ + ChainID: big.NewInt(80002), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + Bor: &BorConfig{ + Period: map[string]uint64{ + "0": 2, + }, + ProducerDelay: map[string]uint64{ + "0": 6, + }, + Sprint: map[string]uint64{ + "0": 64, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + BurntContract: map[string]string{ + "0": "0x00000000000000000000000000000000000000000", + }, + }, + } + BorUnittestChainConfig = &ChainConfig{ + ChainID: big.NewInt(80003), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + Bor: &BorConfig{ + ParallelUniverseBlock: big.NewInt(5), + Period: map[string]uint64{ + "0": 1, + }, + ProducerDelay: map[string]uint64{ + "0": 3, + }, + Sprint: map[string]uint64{ + "0": 32, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + BurntContract: map[string]string{ + "0": "0x00000000000000000000000000000000000000000", + }, + }, + } + + // MumbaiChainConfig contains the chain parameters to run a node on the Mumbai test network. + MumbaiChainConfig = &ChainConfig{ + ChainID: big.NewInt(80001), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(2722000), + MuirGlacierBlock: big.NewInt(2722000), + BerlinBlock: big.NewInt(13996000), + LondonBlock: big.NewInt(22640000), + Bor: &BorConfig{ + JaipurBlock: big.NewInt(22770000), + DelhiBlock: big.NewInt(29638656), + ParallelUniverseBlock: big.NewInt(0), + IndoreBlock: big.NewInt(37075456), + StateSyncConfirmationDelay: map[string]uint64{ + "37075456": 128, + }, + Period: map[string]uint64{ + "0": 2, + "25275000": 5, + "29638656": 2, + }, + ProducerDelay: map[string]uint64{ + "0": 6, + "29638656": 4, + }, + Sprint: map[string]uint64{ + "0": 64, + "29638656": 16, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + "25275000": 5, + "29638656": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + BurntContract: map[string]string{ + "22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38", + }, + BlockAlloc: map[string]interface{}{ + // write as interface since that is how it is decoded in genesis + "22244000": map[string]interface{}{ + "0000000000000000000000000000000000001010": map[string]interface{}{ + "balance": "0x0", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611548565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154e565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115db565b005b348015610b2e57600080fd5b50610b376115f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161e90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da96023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163e90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d866023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165d565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600381526020017f013881000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611755565b90505b92915050565b6040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b12565b611be8565b9050949350505050565b6201388181565b60015481565b604051806080016040528060528152602001611dcc605291396040516020018082805190602001908083835b6020831061159d578051825260208201915060208101905060208303925061157a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e3611381565b6115ec57600080fd5b6115f58161165d565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162d57600080fd5b600082840390508091505092915050565b60008082840190508381101561165357600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d557600080fd5b505afa1580156117e9573d6000803e3d6000fd5b505050506040513d60208110156117ff57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d60208110156118bb57600080fd5b810190808051906020019092919050505090506118d9868686611c32565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119e157600080fd5b505afa1580156119f5573d6000803e3d6000fd5b505050506040513d6020811015611a0b57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9957600080fd5b505afa158015611aad573d6000803e3d6000fd5b505050506040513d6020811015611ac357600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1e605b91396040516020018082805190602001908083835b60208310611b645780518252602082019150602081019050602083039250611b41565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d1a573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820ccd6c2a9c259832bbb367986ee06cd87af23022681b0cb22311a864b701d939564736f6c63430005100032", + }, + }, + }, + }, + } + + BorMainnetChainConfig = &ChainConfig{ + ChainID: big.NewInt(137), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(3395000), + MuirGlacierBlock: big.NewInt(3395000), + BerlinBlock: big.NewInt(14750000), + LondonBlock: big.NewInt(23850000), + Bor: &BorConfig{ + JaipurBlock: big.NewInt(23850000), + DelhiBlock: big.NewInt(38189056), + ParallelUniverseBlock: big.NewInt(0), + IndoreBlock: big.NewInt(44934656), + StateSyncConfirmationDelay: map[string]uint64{ + "44934656": 128, + }, + + Period: map[string]uint64{ + "0": 2, + }, + ProducerDelay: map[string]uint64{ + "0": 6, + "38189056": 4, + }, + Sprint: map[string]uint64{ + "0": 64, + "38189056": 16, + }, + BackupMultiplier: map[string]uint64{ + "0": 2, + }, + ValidatorContract: "0x0000000000000000000000000000000000001000", + StateReceiverContract: "0x0000000000000000000000000000000000001001", + OverrideStateSyncRecords: map[string]int{ + "14949120": 8, + "14949184": 0, + "14953472": 0, + "14953536": 5, + "14953600": 0, + "14953664": 0, + "14953728": 0, + "14953792": 0, + "14953856": 0, + }, + BurntContract: map[string]string{ + "23850000": "0x70bca57f4579f58670ab2d18ef16e02c17553c38", + }, + BlockAlloc: map[string]interface{}{ + // write as interface since that is how it is decoded in genesis + "22156660": map[string]interface{}{ + "0000000000000000000000000000000000001010": map[string]interface{}{ + "balance": "0x0", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610caa565b005b3480156103eb57600080fd5b506103f4610dfc565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e05565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b005b3480156104e857600080fd5b506104f1611090565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b506105486110b6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110dc565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b506106046110fd565b005b34801561061257600080fd5b5061061b6111cd565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506111d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b50610758611358565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af611381565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de6113d8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e611411565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061144e565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b50610964611474565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b8101908080359060200190929190505050611501565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611521565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a65611541565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a90611546565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb61154c565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d9565b005b348015610b2e57600080fd5b50610b376115f6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b60006040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b60003390506000610cba826110dc565b9050610cd18360065461161c90919063ffffffff16565b600681905550600083118015610ce657508234145b610d58576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610dd4876110dc565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610e0d611381565b610e1657600080fd5b600081118015610e535750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611da76023913960400191505060405180910390fd5b6000610eb3836110dc565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610f00573d6000803e3d6000fd5b50610f168360065461163c90919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f68585610f98896110dc565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611027576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611d846023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108c8261165b565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b611105611381565b61110e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b60008060008060418551146111ee5760009350505050611352565b602085015192506040850151915060ff6041860151169050601b8160ff16101561121957601b810190505b601b8160ff16141580156112315750601c8160ff1614155b156112425760009350505050611352565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561129f573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600181526020017f890000000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b6000813414611460576000905061146e565b61146b338484611753565b90505b92915050565b6040518060800160405280605b8152602001611e1c605b91396040516020018082805190602001908083835b602083106114c357805182526020820191506020810190506020830392506114a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061153761153286868686611b10565b611be6565b9050949350505050565b608981565b60015481565b604051806080016040528060528152602001611dca605291396040516020018082805190602001908083835b6020831061159b5780518252602082019150602081019050602083039250611578565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b6115e1611381565b6115ea57600080fd5b6115f38161165b565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282111561162b57600080fd5b600082840390508091505092915050565b60008082840190508381101561165157600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561169557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117d357600080fd5b505afa1580156117e7573d6000803e3d6000fd5b505050506040513d60208110156117fd57600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561188f57600080fd5b505afa1580156118a3573d6000803e3d6000fd5b505050506040513d60208110156118b957600080fd5b810190808051906020019092919050505090506118d7868686611c30565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119df57600080fd5b505afa1580156119f3573d6000803e3d6000fd5b505050506040513d6020811015611a0957600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a9757600080fd5b505afa158015611aab573d6000803e3d6000fd5b505050506040513d6020811015611ac157600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b6000806040518060800160405280605b8152602001611e1c605b91396040516020018082805190602001908083835b60208310611b625780518252602082019150602081019050602083039250611b3f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cd2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d18573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a72315820a4a6f71a98ac3fc613c3a8f1e2e11b9eb9b6b39f125f7d9508916c2b8fb02c7164736f6c63430005100032", + }, + }, + }, + }, + } + // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. AllEthashProtocolChanges = &ChainConfig{ @@ -281,6 +484,7 @@ var ( TerminalTotalDifficultyPassed: false, Ethash: nil, Clique: &CliqueConfig{Period: 0, Epoch: 30000}, + Bor: &BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}}, } // TestChainConfig contains every protocol change (EIPs) introduced @@ -311,6 +515,10 @@ var ( TerminalTotalDifficultyPassed: false, Ethash: new(EthashConfig), Clique: nil, + Bor: &BorConfig{ + Sprint: map[string]uint64{ + "0": 4}, + BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}}, } // NonActivatedConfig defines the chain configuration without activating @@ -347,10 +555,12 @@ var ( // NetworkNames are user friendly names to use in the chain spec banner. var NetworkNames = map[string]string{ - MainnetChainConfig.ChainID.String(): "mainnet", - RinkebyChainConfig.ChainID.String(): "rinkeby", - GoerliChainConfig.ChainID.String(): "goerli", - SepoliaChainConfig.ChainID.String(): "sepolia", + MainnetChainConfig.ChainID.String(): "mainnet", + RinkebyChainConfig.ChainID.String(): "rinkeby", + GoerliChainConfig.ChainID.String(): "goerli", + SepoliaChainConfig.ChainID.String(): "sepolia", + BorMainnetChainConfig.ChainID.String(): "bor", + MumbaiChainConfig.ChainID.String(): "mumbai", } // TrustedCheckpoint represents a set of post-processed trie roots (CHT and @@ -450,6 +660,7 @@ type ChainConfig struct { // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"` + Bor *BorConfig `json:"bor,omitempty"` } // EthashConfig is the consensus engine configs for proof-of-work based sealing. @@ -471,6 +682,136 @@ func (c *CliqueConfig) String() string { return "clique" } +// BorConfig is the consensus engine configs for Matic bor based sealing. +type BorConfig struct { + Period map[string]uint64 `json:"period"` // Number of seconds between blocks to enforce + ProducerDelay map[string]uint64 `json:"producerDelay"` // Number of seconds delay between two producer interval + Sprint map[string]uint64 `json:"sprint"` // Epoch length to proposer + BackupMultiplier map[string]uint64 `json:"backupMultiplier"` // Backup multiplier to determine the wiggle time + ValidatorContract string `json:"validatorContract"` // Validator set contract + StateReceiverContract string `json:"stateReceiverContract"` // State receiver contract + OverrideStateSyncRecords map[string]int `json:"overrideStateSyncRecords"` // override state records count + BlockAlloc map[string]interface{} `json:"blockAlloc"` + BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork + JaipurBlock *big.Int `json:"jaipurBlock"` // Jaipur switch block (nil = no fork, 0 = already on jaipur) + DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi) + ParallelUniverseBlock *big.Int `json:"parallelUniverseBlock"` // TODO: update all occurrence, change name and finalize number (hardfork for block-stm related changes) + IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore) + StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to` +} + +// String implements the stringer interface, returning the consensus engine details. +func (b *BorConfig) String() string { + return "bor" +} + +func (c *BorConfig) CalculateProducerDelay(number uint64) uint64 { + return borKeyValueConfigHelper(c.ProducerDelay, number) +} + +func (c *BorConfig) CalculateSprint(number uint64) uint64 { + return borKeyValueConfigHelper(c.Sprint, number) +} + +func (c *BorConfig) CalculateBackupMultiplier(number uint64) uint64 { + return c.calculateBorConfigHelper(c.BackupMultiplier, number) +} + +func (c *BorConfig) CalculatePeriod(number uint64) uint64 { + return c.calculateBorConfigHelper(c.Period, number) +} + +func (c *BorConfig) IsJaipur(number *big.Int) bool { + return isBlockForked(c.JaipurBlock, number) +} + +func (c *BorConfig) IsDelhi(number *big.Int) bool { + return isBlockForked(c.DelhiBlock, number) +} + +func (c *BorConfig) IsIndore(number *big.Int) bool { + return isBlockForked(c.IndoreBlock, number) +} + +func (c *BorConfig) CalculateStateSyncDelay(number uint64) uint64 { + return borKeyValueConfigHelper(c.StateSyncConfirmationDelay, number) +} + +// TODO: modify this function once the block number is finalized +func (c *BorConfig) IsParallelUniverse(number *big.Int) bool { + if c.ParallelUniverseBlock != nil { + if c.ParallelUniverseBlock.Cmp(big.NewInt(0)) == 0 { + return false + } + } + + return isBlockForked(c.ParallelUniverseBlock, number) +} + +func (c *BorConfig) IsSprintStart(number uint64) bool { + return number%c.CalculateSprint(number) == 0 +} + +func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 { + keys := make([]string, 0, len(field)) + for k := range field { + keys = append(keys, k) + } + + sort.Strings(keys) + + for i := 0; i < len(keys)-1; i++ { + valUint, _ := strconv.ParseUint(keys[i], 10, 64) + valUintNext, _ := strconv.ParseUint(keys[i+1], 10, 64) + + if number > valUint && number < valUintNext { + return field[keys[i]] + } + } + + return field[keys[len(keys)-1]] +} + +func borKeyValueConfigHelper(field map[string]uint64, number uint64) uint64 { + keys := make([]string, 0, len(field)) + for k := range field { + keys = append(keys, k) + } + + sort.Strings(keys) + + for i := 0; i < len(keys)-1; i++ { + valUint, _ := strconv.ParseUint(keys[i], 10, 64) + valUintNext, _ := strconv.ParseUint(keys[i+1], 10, 64) + + if number >= valUint && number < valUintNext { + return field[keys[i]] + } + } + + return field[keys[len(keys)-1]] +} + +func (c *BorConfig) CalculateBurntContract(number uint64) string { + keys := make([]string, 0, len(c.BurntContract)) + for k := range c.BurntContract { + keys = append(keys, k) + } + + sort.Strings(keys) + + for i := 0; i < len(keys)-1; i++ { + valUint, _ := strconv.ParseUint(keys[i], 10, 64) + valUintNext, _ := strconv.ParseUint(keys[i+1], 10, 64) + + if number > valUint && number < valUintNext { + return c.BurntContract[keys[i]] + } + } + + return c.BurntContract[keys[len(keys)-1]] +} + // Description returns a human-readable description of ChainConfig. func (c *ChainConfig) Description() string { var banner string @@ -498,6 +839,8 @@ func (c *ChainConfig) Description() string { } else { banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n" } + case c.Bor != nil: + banner += "Consensus: Bor (proof-of-stake), merged from Ethash (proof-of-work)\n" default: banner += "Consensus: unknown\n" }