interface for public api

This commit is contained in:
Sina Mahmoodi 2026-05-11 15:48:01 +00:00
parent 35d19278e7
commit b9999244e5
5 changed files with 11 additions and 11 deletions

View file

@ -324,7 +324,7 @@ type BlockChain struct {
flushInterval atomic.Int64 // Time interval (processing time) after which to flush a state
triedb *triedb.Database // The database handler for maintaining trie nodes.
codedb *state.CodeDB // The database handler for maintaining contract codes.
jumpDest *JumpDestCache // Shared JUMPDEST analysis cache for block processing
jumpDest vm.JumpDestCache // Shared JUMPDEST analysis cache for block processing
txIndexer *txIndexer // Transaction indexer, might be nil if not enabled
hc *HeaderChain

View file

@ -38,19 +38,19 @@ const (
jumpDestBucketSize = 8 * 1024 * 1024
)
// JumpDestCache is a thread-safe, byte-bounded LRU of JUMPDEST analysis
// shardedJumpDestCache is a thread-safe, byte-bounded LRU of JUMPDEST analysis
// bitmaps, sharded into independent buckets to reduce lock contention. It is
// owned by BlockChain and shared across block processing and prefetching,
// keyed by the immutable contract code hash.
type JumpDestCache struct {
type shardedJumpDestCache struct {
buckets [jumpDestBuckets]struct {
dest *lru.SizeConstrainedCache[common.Hash, vm.BitVec]
}
}
// NewJumpDestCache constructs the analysis cache.
func NewJumpDestCache() *JumpDestCache {
c := new(JumpDestCache)
func NewJumpDestCache() vm.JumpDestCache {
c := new(shardedJumpDestCache)
for i := range c.buckets {
c.buckets[i].dest = lru.NewSizeConstrainedCache[common.Hash, vm.BitVec](jumpDestBucketSize)
}
@ -58,7 +58,7 @@ func NewJumpDestCache() *JumpDestCache {
}
// Load retrieves the cached jumpdest analysis for the given code hash.
func (c *JumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
func (c *shardedJumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
bucket := &c.buckets[hash[0]&(jumpDestBuckets-1)]
v, ok := bucket.dest.Get(hash)
if ok {
@ -70,7 +70,7 @@ func (c *JumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
}
// Store saves the jumpdest analysis for the given code hash.
func (c *JumpDestCache) Store(hash common.Hash, b vm.BitVec) {
func (c *shardedJumpDestCache) Store(hash common.Hash, b vm.BitVec) {
bucket := &c.buckets[hash[0]&(jumpDestBuckets-1)]
bucket.dest.Add(hash, b)
}

View file

@ -49,7 +49,7 @@ func newStatePrefetcher(config *params.ChainConfig, chain *HeaderChain) *statePr
// Prefetch processes the state changes according to the Ethereum rules by running
// the transaction messages using the statedb, but any changes are discarded. The
// only goal is to warm the state caches.
func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config, interrupt *atomic.Bool) {
func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config, interrupt *atomic.Bool) {
var (
fails atomic.Int64
header = block.Header()

View file

@ -61,7 +61,7 @@ func (p *StateProcessor) chainConfig() *params.ChainConfig {
// Process returns the receipts and logs accumulated during the process and
// returns the amount of gas that was used in the process. If any of the
// transactions failed to execute due to insufficient gas it will return an error.
func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config) (*ProcessResult, error) {
func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config) (*ProcessResult, error) {
var (
config = p.chainConfig()
receipts = make(types.Receipts, 0, len(block.Transactions()))

View file

@ -41,7 +41,7 @@ type Prefetcher interface {
// Prefetch processes the state changes according to the Ethereum rules by running
// the transaction messages using the statedb, but any changes are discarded. The
// only goal is to pre-cache transaction signatures and state trie nodes.
Prefetch(block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config, interrupt *atomic.Bool)
Prefetch(block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config, interrupt *atomic.Bool)
}
// Processor is an interface for processing blocks using a given initial state.
@ -49,7 +49,7 @@ type Processor interface {
// Process processes the state changes according to the Ethereum rules by running
// the transaction messages using the statedb and applying any rewards to both
// the processor (coinbase) and any included uncles.
Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config) (*ProcessResult, error)
Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config) (*ProcessResult, error)
}
// ProcessResult contains the values computed by Process.