mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-15 00:13:46 +00:00
Merge pull request #10 from maticnetwork/log_updates
log usage standardised
This commit is contained in:
commit
b6f6ce9630
3 changed files with 41 additions and 17 deletions
|
|
@ -667,13 +667,13 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
|
|
||||||
// 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)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit statees
|
// commit statees
|
||||||
if err := c.CommitStates(state, header, cx); err != nil {
|
if err := c.CommitStates(state, header, cx); err != nil {
|
||||||
fmt.Println("Error while committing states", err)
|
log.Error("Error while committing states", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -693,13 +693,13 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Hea
|
||||||
// check and commit span
|
// check and commit span
|
||||||
err := c.checkAndCommitSpan(state, header, cx)
|
err := c.checkAndCommitSpan(state, header, cx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error while committing span", err)
|
log.Error("Error while committing span", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit statees
|
// commit statees
|
||||||
if err := c.CommitStates(state, header, cx); err != nil {
|
if err := c.CommitStates(state, header, cx); err != nil {
|
||||||
fmt.Println("Error while committing states", err)
|
log.Error("Error while committing states", "error", err)
|
||||||
// return nil, err
|
// return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -779,8 +779,8 @@ func (c *Bor) Seal(chain consensus.ChainReader, block *types.Block, results chan
|
||||||
wiggle := time.Duration(2*c.config.Period) * time.Second * time.Duration(tempIndex-proposerIndex)
|
wiggle := time.Duration(2*c.config.Period) * time.Second * time.Duration(tempIndex-proposerIndex)
|
||||||
delay += wiggle
|
delay += wiggle
|
||||||
|
|
||||||
fmt.Println("Out-of-turn signing requested", "wiggle", common.PrettyDuration(wiggle))
|
log.Info("Out-of-turn signing requested", "wiggle", common.PrettyDuration(wiggle))
|
||||||
fmt.Println("Sealing block with", "number", number, "delay", delay, "headerDifficulty", header.Difficulty, "signer", signer.Hex(), "proposer", proposer.Hex())
|
log.Info("Sealing block with", "number", number, "delay", delay, "headerDifficulty", header.Difficulty, "signer", signer.Hex(), "proposer", proposer.Hex())
|
||||||
|
|
||||||
// Sign all the things!
|
// Sign all the things!
|
||||||
sighash, err := signFn(accounts.Account{Address: signer}, accounts.MimetypeBor, BorRLP(header))
|
sighash, err := signFn(accounts.Account{Address: signer}, accounts.MimetypeBor, BorRLP(header))
|
||||||
|
|
@ -848,7 +848,7 @@ func (c *Bor) isSpanPending(snapshotNumber uint64) (bool, error) {
|
||||||
// get packed data
|
// get packed data
|
||||||
data, err := c.validatorSetABI.Pack(method)
|
data, err := c.validatorSetABI.Pack(method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for spanProposalPending", "error", err)
|
log.Error("Unable to pack tx for spanProposalPending", "error", err)
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -886,7 +886,7 @@ func (c *Bor) GetCurrentSpan(snapshotNumber uint64) (*Span, error) {
|
||||||
|
|
||||||
data, err := c.validatorSetABI.Pack(method)
|
data, err := c.validatorSetABI.Pack(method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for getCurrentSpan", "error", err)
|
log.Error("Unable to pack tx for getCurrentSpan", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -936,7 +936,7 @@ func (c *Bor) GetCurrentValidators(snapshotNumber uint64, blockNumber uint64) ([
|
||||||
|
|
||||||
data, err := c.validatorSetABI.Pack(method, big.NewInt(0).SetUint64(blockNumber))
|
data, err := c.validatorSetABI.Pack(method, big.NewInt(0).SetUint64(blockNumber))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for getValidator", "error", err)
|
log.Error("Unable to pack tx for getValidator", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1070,8 +1070,7 @@ func (c *Bor) commitSpan(
|
||||||
|
|
||||||
// method
|
// method
|
||||||
method := "commitSpan"
|
method := "commitSpan"
|
||||||
|
log.Info("✅ Committing new span",
|
||||||
fmt.Println(
|
|
||||||
"id", heimdallSpan.ID,
|
"id", heimdallSpan.ID,
|
||||||
"startBlock", heimdallSpan.StartBlock,
|
"startBlock", heimdallSpan.StartBlock,
|
||||||
"endBlock", heimdallSpan.EndBlock,
|
"endBlock", heimdallSpan.EndBlock,
|
||||||
|
|
@ -1088,7 +1087,7 @@ func (c *Bor) commitSpan(
|
||||||
producerBytes,
|
producerBytes,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for commitSpan", "error", err)
|
log.Error("Unable to pack tx for commitSpan", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1109,7 +1108,7 @@ func (c *Bor) GetPendingStateProposals(snapshotNumber uint64) ([]*big.Int, error
|
||||||
|
|
||||||
data, err := c.stateReceiverABI.Pack(method)
|
data, err := c.stateReceiverABI.Pack(method)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for getPendingStates", "error", err)
|
log.Error("Unable to pack tx for getPendingStates", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1150,7 +1149,7 @@ func (c *Bor) CommitStates(
|
||||||
|
|
||||||
// state ids
|
// state ids
|
||||||
if len(stateIds) > 0 {
|
if len(stateIds) > 0 {
|
||||||
fmt.Println("Found new proposed states", len(stateIds))
|
log.Debug("Found new proposed states", "numberOfStates", len(stateIds))
|
||||||
}
|
}
|
||||||
|
|
||||||
method := "commitState"
|
method := "commitState"
|
||||||
|
|
@ -1168,6 +1167,12 @@ func (c *Bor) CommitStates(
|
||||||
if err := json.Unmarshal(response.Result, &eventRecord); err != nil {
|
if err := json.Unmarshal(response.Result, &eventRecord); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Info("→ committing new state",
|
||||||
|
"id", eventRecord.ID,
|
||||||
|
"contract", eventRecord.Contract,
|
||||||
|
"data", hex.EncodeToString(eventRecord.Data),
|
||||||
|
"txHash", eventRecord.TxHash,
|
||||||
|
)
|
||||||
|
|
||||||
recordBytes, err := rlp.EncodeToBytes(eventRecord)
|
recordBytes, err := rlp.EncodeToBytes(eventRecord)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1177,7 +1182,7 @@ func (c *Bor) CommitStates(
|
||||||
// get packed data for commit state
|
// get packed data for commit state
|
||||||
data, err := c.stateReceiverABI.Pack(method, recordBytes)
|
data, err := c.stateReceiverABI.Pack(method, recordBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to pack tx for commitState", "error", err)
|
log.Error("Unable to pack tx for commitState", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/maticnetwork/bor/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResponseWithHeight defines a response object type that wraps an original
|
// ResponseWithHeight defines a response object type that wraps an original
|
||||||
|
|
@ -63,7 +65,7 @@ func FetchFromHeimdallWithRetry(client http.Client, urlString string, paths ...s
|
||||||
if err == nil && res != nil {
|
if err == nil && res != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
fmt.Println("Retrying again in 5 seconds", u.String())
|
log.Info("Retrying again in 5 seconds", u.String())
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ package bor
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/maticnetwork/bor/common"
|
"github.com/maticnetwork/bor/common"
|
||||||
"github.com/maticnetwork/bor/core/types"
|
"github.com/maticnetwork/bor/core/types"
|
||||||
"github.com/maticnetwork/bor/ethdb"
|
"github.com/maticnetwork/bor/ethdb"
|
||||||
"github.com/maticnetwork/bor/internal/ethapi"
|
"github.com/maticnetwork/bor/internal/ethapi"
|
||||||
|
"github.com/maticnetwork/bor/log"
|
||||||
"github.com/maticnetwork/bor/params"
|
"github.com/maticnetwork/bor/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -150,6 +150,23 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
// change validator set and change proposer
|
||||||
|
if number > 0 && (number+1)%s.config.Sprint == 0 {
|
||||||
|
validatorBytes := header.Extra[extraVanity : len(header.Extra)-extraSeal]
|
||||||
|
|
||||||
|
// get validators from headers and use that for new validator set
|
||||||
|
newVals, _ := ParseValidators(validatorBytes)
|
||||||
|
v := getUpdatedValidatorSet(snap.ValidatorSet.Copy(), newVals)
|
||||||
|
v.IncrementProposerPriority(1)
|
||||||
|
snap.ValidatorSet = v
|
||||||
|
|
||||||
|
// log new validator set
|
||||||
|
log.Info("Current validator set", "number", snap.Number, "validatorSet", snap.ValidatorSet)
|
||||||
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> origin/mat-494
|
||||||
// check if signer is in validator set
|
// check if signer is in validator set
|
||||||
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
|
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
|
||||||
return nil, errUnauthorizedSigner
|
return nil, errUnauthorizedSigner
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue