mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +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
|
||||
}
|
||||
|
||||
func NewBorApi(chain consensus.ChainReader, bor *Bor) API {
|
||||
return API{chain: chain, bor: bor}
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"math"
|
||||
"math/big"
|
||||
|
||||
// "net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -327,6 +326,7 @@ func (c *Bor) verifyHeader(chain consensus.ChainReader, header *types.Header, pa
|
|||
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
|
||||
|
|
@ -338,8 +338,10 @@ func (c *Bor) verifyHeader(chain consensus.ChainReader, header *types.Header, pa
|
|||
if len(header.Extra) < extraVanity+extraSeal {
|
||||
return errMissingSignature
|
||||
}
|
||||
|
||||
// check extr adata
|
||||
isSprintEnd := (number+1)%c.config.Sprint == 0
|
||||
|
||||
// Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
|
||||
signersBytes := len(header.Extra) - extraVanity - extraSeal
|
||||
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
|
||||
// return nil
|
||||
return c.verifySeal(chain, header, parents)
|
||||
}
|
||||
|
||||
|
|
@ -562,6 +563,7 @@ func (c *Bor) verifySeal(chain consensus.ChainReader, header *types.Header, pare
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
|
||||
return errUnauthorizedSigner
|
||||
}
|
||||
|
|
@ -662,13 +664,10 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
|
|||
// commit span
|
||||
headerNumber := header.Number.Uint64()
|
||||
|
||||
// @todo check if this is required
|
||||
if /* headerNumber > 0 && */
|
||||
headerNumber%c.config.Sprint == 0 {
|
||||
if headerNumber%c.config.Sprint == 0 {
|
||||
cx := chainContext{Chain: chain, Bor: c}
|
||||
// check and commit span
|
||||
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
|
||||
fmt.Println("Error while committing span", err)
|
||||
log.Error("Error while committing span", "error", err)
|
||||
return
|
||||
}
|
||||
|
|
@ -991,22 +990,16 @@ func (c *Bor) checkAndCommitSpan(
|
|||
pending := false
|
||||
var span *Span = nil
|
||||
errors := make(chan error)
|
||||
// var wg sync.WaitGroup
|
||||
// wg.Add(1)
|
||||
go func() {
|
||||
var err error
|
||||
pending, err = c.isSpanPending(headerNumber - 1)
|
||||
// pending, err = c.isSpanPending(headerNumber)
|
||||
errors <- err
|
||||
// wg.Done()
|
||||
}()
|
||||
|
||||
// wg.Add(1)
|
||||
go func() {
|
||||
var err error
|
||||
span, err = c.GetCurrentSpan(headerNumber - 1)
|
||||
errors <- err
|
||||
// wg.Done()
|
||||
}()
|
||||
|
||||
var err error
|
||||
|
|
@ -1061,6 +1054,7 @@ func (c *Bor) fetchAndCommitSpan(
|
|||
if err := json.Unmarshal(response.Result, &heimdallSpan); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check if chain id matches with heimdall span
|
||||
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
|
||||
return fmt.Errorf(
|
||||
|
|
@ -1069,6 +1063,7 @@ func (c *Bor) fetchAndCommitSpan(
|
|||
c.chainConfig.ChainID,
|
||||
)
|
||||
}
|
||||
|
||||
// get validators bytes
|
||||
var validators []MinimalVal
|
||||
for _, val := range heimdallSpan.ValidatorSet.Validators {
|
||||
|
|
@ -1078,6 +1073,7 @@ func (c *Bor) fetchAndCommitSpan(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// get producers bytes
|
||||
var producers []MinimalVal
|
||||
for _, val := range heimdallSpan.SelectedProducers {
|
||||
|
|
@ -1097,6 +1093,7 @@ func (c *Bor) fetchAndCommitSpan(
|
|||
"validatorBytes", hex.EncodeToString(validatorBytes),
|
||||
"producerBytes", hex.EncodeToString(producerBytes),
|
||||
)
|
||||
|
||||
// get packed data
|
||||
data, err := c.validatorSetABI.Pack(method,
|
||||
big.NewInt(0).SetUint64(heimdallSpan.ID),
|
||||
|
|
@ -1109,8 +1106,10 @@ func (c *Bor) fetchAndCommitSpan(
|
|||
log.Error("Unable to pack tx for commitSpan", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// get system message
|
||||
msg := getSystemMessage(common.HexToAddress(c.config.ValidatorContract), data)
|
||||
|
||||
// apply message
|
||||
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)
|
||||
if err != nil {
|
||||
log.Error("Failed fetching snapshot", err)
|
||||
return false
|
||||
}
|
||||
|
||||
isValidator := false
|
||||
|
|
@ -1276,10 +1276,6 @@ type chainContext struct {
|
|||
Bor consensus.Engine
|
||||
}
|
||||
|
||||
// func NewChainContext(chain consensus.ChainReader, bor consensus.Engine) (chainContext) {
|
||||
// return {Chain: chain, Bor: bor}
|
||||
// }
|
||||
|
||||
func (c chainContext) Engine() consensus.Engine {
|
||||
return c.Bor
|
||||
}
|
||||
|
|
@ -1341,6 +1337,7 @@ func applyMessage(
|
|||
if err != nil {
|
||||
state.Finalise(true)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
|||
if len(msg) != 32 {
|
||||
return nil, ErrInvalidMsgLen
|
||||
}
|
||||
|
||||
if len(seckey) != 32 {
|
||||
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())
|
||||
|
||||
state, header, err := b.StateAndHeaderByNumber(ctx, blockNr)
|
||||
// fmt.Println("statedb.IntermediateRoot in DoCall", state.IntermediateRoot(false).Hex())
|
||||
if state == nil || err != nil {
|
||||
return nil, 0, false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package les
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"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) {
|
||||
if blockNr == rpc.LatestBlockNumber || blockNr == rpc.PendingBlockNumber {
|
||||
fmt.Println("20")
|
||||
return b.eth.blockchain.CurrentHeader(), nil
|
||||
}
|
||||
fmt.Println("21")
|
||||
return b.eth.blockchain.GetHeaderByNumberOdr(ctx, uint64(blockNr))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue