mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
* lock, unlock to rlock, runlock * add : tracing Pending() and Locals() * Log time spent in committing a tx during mining * Remove data from logging * Move log into case where a tx completes without error * profile fillTransactions * fix conflict * bug fixes * add logs * txpool: add tracing in Pending() * rearrange tracing * add attributes * fix * fix * log error in profiling * update file mode and file path for profiling * full profiling * fix log * fix log * less wait * fix * fix * logs * worker: use block number for prof files * initial * txList add * fix gas calculation * fix * green tests * linters * prettify * allocate less * no locks between pending and reorg * no locks * no locks on locals * more tests * linters * less allocs * comment * optimize errors * linters * fix * fix * Linters * linters * linters * simplify errors * atomics for transactions * fix * optimize workers * fix copy * linters * txpool tracing * linters * fix tracing * duration in mcs * locks * metrics * fix * cache hit/miss * less locks on evict * remove once * remove once * switch off pprof * fix data race * fix data race * add : sealed total/empty blocks metric gauge * add : RPC debug_getTraceStack * fix : RPC debug_getTraceStack * fix : RPC debug_getTraceStack for all go-routines * linters * add data race test on txpool * fix concurrency * noleak * increase batch size * prettify * tests * baseFee mutex * panic fix * linters * fix gas fee data race * linters * more transactions * debug * debug * fix ticker * fix test * add cacheMu * more tests * fix test panic * linters * add statistics * add statistics * txitems data race * fix tx list Has * fix : lint Co-authored-by: Arpit Temani <temaniarpit27@gmail.com> Co-authored-by: Jerry <jerrycgh@gmail.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Evgeny Danienko <6655321@bk.ru>
61 lines
1.9 KiB
Go
61 lines
1.9 KiB
Go
package eth
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint"
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
)
|
|
|
|
type checkpointVerifier struct {
|
|
verify func(ctx context.Context, handler *ethHandler, checkpoint *checkpoint.Checkpoint) (string, error)
|
|
}
|
|
|
|
func newCheckpointVerifier(verifyFn func(ctx context.Context, handler *ethHandler, checkpoint *checkpoint.Checkpoint) (string, error)) *checkpointVerifier {
|
|
if verifyFn != nil {
|
|
return &checkpointVerifier{verifyFn}
|
|
}
|
|
|
|
verifyFn = func(ctx context.Context, handler *ethHandler, checkpoint *checkpoint.Checkpoint) (string, error) {
|
|
var (
|
|
startBlock = checkpoint.StartBlock.Uint64()
|
|
endBlock = checkpoint.EndBlock.Uint64()
|
|
)
|
|
|
|
// check if we have the checkpoint blocks
|
|
//nolint:contextcheck
|
|
head := handler.ethAPI.BlockNumber()
|
|
if head < hexutil.Uint64(endBlock) {
|
|
log.Debug("Head block behind checkpoint block", "head", head, "checkpoint end block", endBlock)
|
|
return "", errMissingCheckpoint
|
|
}
|
|
|
|
// verify the root hash of checkpoint
|
|
roothash, err := handler.ethAPI.GetRootHash(ctx, startBlock, endBlock)
|
|
if err != nil {
|
|
log.Debug("Failed to get root hash of checkpoint while whitelisting", "err", err)
|
|
return "", errRootHash
|
|
}
|
|
|
|
if roothash != checkpoint.RootHash.String()[2:] {
|
|
log.Warn("Checkpoint root hash mismatch while whitelisting", "expected", checkpoint.RootHash.String()[2:], "got", roothash)
|
|
return "", errCheckpointRootHashMismatch
|
|
}
|
|
|
|
// fetch the end checkpoint block hash
|
|
block, err := handler.ethAPI.GetBlockByNumber(ctx, rpc.BlockNumber(endBlock), false)
|
|
if err != nil {
|
|
log.Debug("Failed to get end block hash of checkpoint while whitelisting", "err", err)
|
|
return "", errEndBlock
|
|
}
|
|
|
|
hash := fmt.Sprintf("%v", block["hash"])
|
|
|
|
return hash, nil
|
|
}
|
|
|
|
return &checkpointVerifier{verifyFn}
|
|
}
|