mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 22:13:47 +00:00
Cleanup debug statements
This commit is contained in:
parent
e6de60b80e
commit
2ea69833dd
5 changed files with 13 additions and 25 deletions
|
|
@ -30,10 +30,6 @@ type API struct {
|
||||||
bor *Bor
|
bor *Bor
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBorApi(chain consensus.ChainReader, bor *Bor) API {
|
|
||||||
return API{chain: chain, bor: bor}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSnapshot retrieves the state snapshot at a given block.
|
// GetSnapshot retrieves the state snapshot at a given block.
|
||||||
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
|
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
|
||||||
// Retrieve the requested block number (or current if none requested)
|
// Retrieve the requested block number (or current if none requested)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
// "net/http"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -327,6 +326,7 @@ func (c *Bor) verifyHeader(chain consensus.ChainReader, header *types.Header, pa
|
||||||
return errUnknownBlock
|
return errUnknownBlock
|
||||||
}
|
}
|
||||||
number := header.Number.Uint64()
|
number := header.Number.Uint64()
|
||||||
|
|
||||||
// Don't waste time checking blocks from the future
|
// Don't waste time checking blocks from the future
|
||||||
if header.Time > uint64(time.Now().Unix()) {
|
if header.Time > uint64(time.Now().Unix()) {
|
||||||
return consensus.ErrFutureBlock
|
return consensus.ErrFutureBlock
|
||||||
|
|
@ -338,8 +338,10 @@ func (c *Bor) verifyHeader(chain consensus.ChainReader, header *types.Header, pa
|
||||||
if len(header.Extra) < extraVanity+extraSeal {
|
if len(header.Extra) < extraVanity+extraSeal {
|
||||||
return errMissingSignature
|
return errMissingSignature
|
||||||
}
|
}
|
||||||
|
|
||||||
// check extr adata
|
// check extr adata
|
||||||
isSprintEnd := (number+1)%c.config.Sprint == 0
|
isSprintEnd := (number+1)%c.config.Sprint == 0
|
||||||
|
|
||||||
// Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
|
// Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
|
||||||
signersBytes := len(header.Extra) - extraVanity - extraSeal
|
signersBytes := len(header.Extra) - extraVanity - extraSeal
|
||||||
if !isSprintEnd && signersBytes != 0 {
|
if !isSprintEnd && signersBytes != 0 {
|
||||||
|
|
@ -425,7 +427,6 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainReader, header *types.H
|
||||||
}
|
}
|
||||||
|
|
||||||
// All basic checks passed, verify the seal and return
|
// All basic checks passed, verify the seal and return
|
||||||
// return nil
|
|
||||||
return c.verifySeal(chain, header, parents)
|
return c.verifySeal(chain, header, parents)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -562,6 +563,7 @@ func (c *Bor) verifySeal(chain consensus.ChainReader, header *types.Header, pare
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
|
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
|
||||||
return errUnauthorizedSigner
|
return errUnauthorizedSigner
|
||||||
}
|
}
|
||||||
|
|
@ -662,13 +664,10 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
// commit span
|
// commit span
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
|
|
||||||
// @todo check if this is required
|
if headerNumber%c.config.Sprint == 0 {
|
||||||
if /* headerNumber > 0 && */
|
|
||||||
headerNumber%c.config.Sprint == 0 {
|
|
||||||
cx := chainContext{Chain: chain, Bor: c}
|
cx := chainContext{Chain: chain, Bor: c}
|
||||||
// check and commit span
|
// check and commit span
|
||||||
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
|
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
|
||||||
fmt.Println("Error while committing span", err)
|
|
||||||
log.Error("Error while committing span", "error", err)
|
log.Error("Error while committing span", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -991,22 +990,16 @@ func (c *Bor) checkAndCommitSpan(
|
||||||
pending := false
|
pending := false
|
||||||
var span *Span = nil
|
var span *Span = nil
|
||||||
errors := make(chan error)
|
errors := make(chan error)
|
||||||
// var wg sync.WaitGroup
|
|
||||||
// wg.Add(1)
|
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
pending, err = c.isSpanPending(headerNumber - 1)
|
pending, err = c.isSpanPending(headerNumber - 1)
|
||||||
// pending, err = c.isSpanPending(headerNumber)
|
|
||||||
errors <- err
|
errors <- err
|
||||||
// wg.Done()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// wg.Add(1)
|
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
span, err = c.GetCurrentSpan(headerNumber - 1)
|
span, err = c.GetCurrentSpan(headerNumber - 1)
|
||||||
errors <- err
|
errors <- err
|
||||||
// wg.Done()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -1061,6 +1054,7 @@ func (c *Bor) fetchAndCommitSpan(
|
||||||
if err := json.Unmarshal(response.Result, &heimdallSpan); err != nil {
|
if err := json.Unmarshal(response.Result, &heimdallSpan); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if chain id matches with heimdall span
|
// check if chain id matches with heimdall span
|
||||||
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
|
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
|
@ -1069,6 +1063,7 @@ func (c *Bor) fetchAndCommitSpan(
|
||||||
c.chainConfig.ChainID,
|
c.chainConfig.ChainID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get validators bytes
|
// get validators bytes
|
||||||
var validators []MinimalVal
|
var validators []MinimalVal
|
||||||
for _, val := range heimdallSpan.ValidatorSet.Validators {
|
for _, val := range heimdallSpan.ValidatorSet.Validators {
|
||||||
|
|
@ -1078,6 +1073,7 @@ func (c *Bor) fetchAndCommitSpan(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// get producers bytes
|
// get producers bytes
|
||||||
var producers []MinimalVal
|
var producers []MinimalVal
|
||||||
for _, val := range heimdallSpan.SelectedProducers {
|
for _, val := range heimdallSpan.SelectedProducers {
|
||||||
|
|
@ -1097,6 +1093,7 @@ func (c *Bor) fetchAndCommitSpan(
|
||||||
"validatorBytes", hex.EncodeToString(validatorBytes),
|
"validatorBytes", hex.EncodeToString(validatorBytes),
|
||||||
"producerBytes", hex.EncodeToString(producerBytes),
|
"producerBytes", hex.EncodeToString(producerBytes),
|
||||||
)
|
)
|
||||||
|
|
||||||
// get packed data
|
// get packed data
|
||||||
data, err := c.validatorSetABI.Pack(method,
|
data, err := c.validatorSetABI.Pack(method,
|
||||||
big.NewInt(0).SetUint64(heimdallSpan.ID),
|
big.NewInt(0).SetUint64(heimdallSpan.ID),
|
||||||
|
|
@ -1109,8 +1106,10 @@ func (c *Bor) fetchAndCommitSpan(
|
||||||
log.Error("Unable to pack tx for commitSpan", "error", err)
|
log.Error("Unable to pack tx for commitSpan", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// get system message
|
// get system message
|
||||||
msg := getSystemMessage(common.HexToAddress(c.config.ValidatorContract), data)
|
msg := getSystemMessage(common.HexToAddress(c.config.ValidatorContract), data)
|
||||||
|
|
||||||
// apply message
|
// apply message
|
||||||
return applyMessage(msg, state, header, c.chainConfig, chain)
|
return applyMessage(msg, state, header, c.chainConfig, chain)
|
||||||
}
|
}
|
||||||
|
|
@ -1235,6 +1234,7 @@ func (c *Bor) IsValidatorAction(chain consensus.ChainReader, from common.Address
|
||||||
snap, err := c.snapshot(chain, header.Number.Uint64(), header.Hash(), nil)
|
snap, err := c.snapshot(chain, header.Number.Uint64(), header.Hash(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed fetching snapshot", err)
|
log.Error("Failed fetching snapshot", err)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidator := false
|
isValidator := false
|
||||||
|
|
@ -1276,10 +1276,6 @@ type chainContext struct {
|
||||||
Bor consensus.Engine
|
Bor consensus.Engine
|
||||||
}
|
}
|
||||||
|
|
||||||
// func NewChainContext(chain consensus.ChainReader, bor consensus.Engine) (chainContext) {
|
|
||||||
// return {Chain: chain, Bor: bor}
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (c chainContext) Engine() consensus.Engine {
|
func (c chainContext) Engine() consensus.Engine {
|
||||||
return c.Bor
|
return c.Bor
|
||||||
}
|
}
|
||||||
|
|
@ -1341,6 +1337,7 @@ func applyMessage(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Finalise(true)
|
state.Finalise(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
||||||
if len(msg) != 32 {
|
if len(msg) != 32 {
|
||||||
return nil, ErrInvalidMsgLen
|
return nil, ErrInvalidMsgLen
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(seckey) != 32 {
|
if len(seckey) != 32 {
|
||||||
return nil, ErrInvalidKey
|
return nil, ErrInvalidKey
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -730,7 +730,6 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNr rpc.BlockNumb
|
||||||
defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
|
defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
|
||||||
|
|
||||||
state, header, err := b.StateAndHeaderByNumber(ctx, blockNr)
|
state, header, err := b.StateAndHeaderByNumber(ctx, blockNr)
|
||||||
// fmt.Println("statedb.IntermediateRoot in DoCall", state.IntermediateRoot(false).Hex())
|
|
||||||
if state == nil || err != nil {
|
if state == nil || err != nil {
|
||||||
return nil, 0, false, err
|
return nil, 0, false, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package les
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/maticnetwork/bor/accounts"
|
"github.com/maticnetwork/bor/accounts"
|
||||||
|
|
@ -61,10 +60,8 @@ func (b *LesApiBackend) SetHead(number uint64) {
|
||||||
|
|
||||||
func (b *LesApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
|
func (b *LesApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
|
||||||
if blockNr == rpc.LatestBlockNumber || blockNr == rpc.PendingBlockNumber {
|
if blockNr == rpc.LatestBlockNumber || blockNr == rpc.PendingBlockNumber {
|
||||||
fmt.Println("20")
|
|
||||||
return b.eth.blockchain.CurrentHeader(), nil
|
return b.eth.blockchain.CurrentHeader(), nil
|
||||||
}
|
}
|
||||||
fmt.Println("21")
|
|
||||||
return b.eth.blockchain.GetHeaderByNumberOdr(ctx, uint64(blockNr))
|
return b.eth.blockchain.GetHeaderByNumberOdr(ctx, uint64(blockNr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue