Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ var (
headFinalizedBlockGauge = metrics.NewRegisteredGauge("chain/head/finalized", nil)
headSafeBlockGauge = metrics.NewRegisteredGauge("chain/head/safe", nil)

chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
chainMgaspsGauge = metrics.NewRegisteredGauge("chain/mgasps", nil)

accountReadTimer = metrics.NewRegisteredTimer("chain/account/reads", nil)
accountHashTimer = metrics.NewRegisteredTimer("chain/account/hashes", nil)
Expand Down
16 changes: 0 additions & 16 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import (
"math/big"
"reflect"
"slices"
"sync"
"sync/atomic"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/common/hexutil"
"github.com/CortexFoundation/CortexTheseus/crypto"
"github.com/CortexFoundation/CortexTheseus/rlp"
)

Expand Down Expand Up @@ -167,20 +165,6 @@ func (h *Header) SanityCheck() error {
return nil
}

// hasherPool holds LegacyKeccak hashers.
var hasherPool = sync.Pool{
New: func() interface{} { return crypto.NewKeccakState() },
}

func rlpHash(x any) (h common.Hash) {
sha := hasherPool.Get().(crypto.KeccakState)
defer hasherPool.Put(sha)
sha.Reset()
rlp.Encode(sha, x)
sha.Read(h[:])
return h
}

// EmptyBody returns true if there is no additional 'body' to complete the header
// that is: no transactions and no uncles.
func (h *Header) EmptyBody() bool {
Expand Down
15 changes: 15 additions & 0 deletions core/types/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import (
"github.com/CortexFoundation/CortexTheseus/rlp"
)

// hasherPool holds LegacyKeccak256 hashers for rlpHash.
var hasherPool = sync.Pool{
New: func() interface{} { return crypto.NewKeccakState() },
}

// encodeBufferPool holds temporary encoder buffers for DeriveSha and TX encoding.
var encodeBufferPool = sync.Pool{
New: func() interface{} { return new(bytes.Buffer) },
Expand All @@ -48,6 +53,16 @@ func getPooledBuffer(size uint64) ([]byte, *bytes.Buffer, error) {
return b, buf, nil
}

// rlpHash encodes x and hashes the encoded bytes.
func rlpHash(x interface{}) (h common.Hash) {
sha := hasherPool.Get().(crypto.KeccakState)
defer hasherPool.Put(sha)
sha.Reset()
rlp.Encode(sha, x)
sha.Read(h[:])
return h
}

// prefixedRlpHash writes the prefix into the hasher before rlp-encoding x.
// It's used for typed transactions.
func prefixedRlpHash(prefix byte, x interface{}) (h common.Hash) {
Expand Down
32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.1
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
github.com/CortexFoundation/torrentfs v1.0.69-0.20250426172722-0e7ce3e83e62
github.com/CortexFoundation/torrentfs v1.0.69-0.20250506101620-39689adc3b78
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/arsham/figurine v1.3.0
github.com/aws/aws-sdk-go-v2 v1.36.3
Expand All @@ -25,7 +25,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
github.com/dop251/goja v0.0.0-20250309171923-bcd7cc6bf64c
github.com/ethereum/c-kzg-4844 v1.0.3
github.com/ethereum/go-ethereum v1.15.10
github.com/ethereum/go-ethereum v1.15.11
github.com/ethereum/go-verkle v0.2.2
github.com/ferranbt/fastssz v0.1.4
github.com/fjl/gencodec v0.1.0
Expand Down Expand Up @@ -63,13 +63,13 @@ require (
github.com/ucwong/color v1.10.1-0.20200624105241-fba1e010fe1e
github.com/urfave/cli/v2 v2.27.6
go.uber.org/automaxprocs v1.6.0
golang.org/x/crypto v0.37.0
golang.org/x/crypto v0.38.0
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f
golang.org/x/sync v0.13.0
golang.org/x/sys v0.32.0
golang.org/x/text v0.24.0
golang.org/x/sync v0.14.0
golang.org/x/sys v0.33.0
golang.org/x/text v0.25.0
golang.org/x/time v0.11.0
golang.org/x/tools v0.32.0
golang.org/x/tools v0.33.0
google.golang.org/protobuf v1.36.6
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
Expand Down Expand Up @@ -100,8 +100,8 @@ require (
github.com/anacrolix/mmsg v1.1.1 // indirect
github.com/anacrolix/multiless v0.4.0 // indirect
github.com/anacrolix/stm v0.5.0 // indirect
github.com/anacrolix/sync v0.5.3 // indirect
github.com/anacrolix/torrent v1.58.2-0.20250425050513-ddc29fedcde0 // indirect
github.com/anacrolix/sync v0.5.4 // indirect
github.com/anacrolix/torrent v1.58.2-0.20250506021736-1e3f1bf041ca // indirect
github.com/anacrolix/upnp v0.1.4 // indirect
github.com/anacrolix/utp v0.2.0 // indirect
github.com/antlabs/stl v0.0.2 // indirect
Expand Down Expand Up @@ -132,7 +132,7 @@ require (
github.com/charmbracelet/x/ansi v0.9.2 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/errors v1.12.0 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
github.com/cockroachdb/redact v1.1.6 // indirect
Expand Down Expand Up @@ -163,7 +163,7 @@ require (
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v25.2.10+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20250423184734-337e5dd93bb4 // indirect
github.com/google/pprof v0.0.0-20250501235452-c0086092b71a // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
Expand Down Expand Up @@ -244,14 +244,14 @@ require (
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/term v0.32.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.4.0 // indirect
modernc.org/libc v1.65.0 // indirect
lukechampine.com/blake3 v1.4.1 // indirect
modernc.org/libc v1.65.3 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.10.0 // indirect
modernc.org/sqlite v1.37.0 // indirect
Expand Down
Loading