From 669b26b280326d6bd5f4c6f50dc66fd50a1d311a Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Mon, 2 Feb 2026 17:44:41 -0500 Subject: [PATCH] simplify blockchain logic --- core/block_validator.go | 2 ++ core/blockchain.go | 26 +------------------------- core/state/bal_reader.go | 4 ++++ core/state_processor.go | 7 +++++++ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index 60804e5a03..3a5379d1a9 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -122,6 +122,8 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { } else if err := block.AccessList().Validate(len(block.Transactions())); err != nil { return fmt.Errorf("invalid block access list: %v", err) } + } else { + //panic("TODO: implement local access list construction path if importing a block without an access list") } } else { // if experimental.bal is not enabled, block headers cannot have access list hash and bodies cannot have access lists. diff --git a/core/blockchain.go b/core/blockchain.go index f563c87e7b..4ed9ea35ad 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2189,26 +2189,10 @@ func (bpr *blockProcessingResult) Stats() *ExecuteStats { // ProcessBlock executes and validates the given block. If there was no error // it writes the block and associated state to database. func (bc *BlockChain) ProcessBlock(parentRoot common.Hash, block *types.Block, setHead bool, makeWitness bool) (result *blockProcessingResult, blockEndErr error) { - var constructBALForTesting bool enableBALFork := bc.chainConfig.IsAmsterdam(block.Number(), block.Time()) - if enableBALFork || !bc.chainConfig.IsCancun(block.Number(), block.Time()) { - // disable testmode construction of BALs if we are not in the range [cancun, amsterdam) - constructBALForTesting = false - } // TODO: need to check that the block is also postcancun if it contained an access list? // this should be checked during decoding (?) blockHasAccessList := block.AccessList() != nil - // only construct and embed BALs in the block if: - // * it has been enabled for testing purposes (preAmsterdam/postCancun blocks with experimental.bal) - // * we are after Amsterdam and the block was provided with bal omitted - // (importing any historical block not near the chain head) - constructBAL := constructBALForTesting || (enableBALFork && !blockHasAccessList) - // do not verify the integrity of the BAL hash wrt the headerreported value - // for any nonAmsterdam blocks: if the block being imported has been created - // via experimental.bal, the block access list hash is unset in the header - // to keep the block hash unchanged (allow for importing historical blocks - // with BALs for testing purposes). - verifyBALHeader := enableBALFork // optimized execution path for blocks which contain BALs if blockHasAccessList { @@ -2357,15 +2341,7 @@ func (bc *BlockChain) ProcessBlock(parentRoot common.Hash, block *types.Block, s } vtime = time.Since(vstart) - if constructBAL { - if verifyBALHeader && *block.Header().BlockAccessListHash != balTracer.AccessList().ToEncodingObj().Hash() { - err := fmt.Errorf("block access list hash mismatch (reported=%x, computed=%x)", *block.Header().BlockAccessListHash, balTracer.AccessList().ToEncodingObj().Hash()) - bc.reportBadBlock(block, res, err) - return nil, err - - } - block = block.WithAccessList(balTracer.AccessList().ToEncodingObj()) - } else if enableBALFork { + if enableBALFork { computedAccessList := balTracer.AccessList().ToEncodingObj() computedAccessListHash := computedAccessList.Hash() diff --git a/core/state/bal_reader.go b/core/state/bal_reader.go index c03788796b..a93ccee264 100644 --- a/core/state/bal_reader.go +++ b/core/state/bal_reader.go @@ -61,6 +61,10 @@ func (p *prestateResolver) stop() { p.cancel() } +func (p *prestateResolver) storage(addr common.Address, key common.Hash) common.Hash { + return common.Hash{} +} + // account returns the state account for the given address, blocking if it is // still being resolved from disk. func (p *prestateResolver) account(addr common.Address) *types.StateAccount { diff --git a/core/state_processor.go b/core/state_processor.go index e5ddf2cbd2..f61c20035d 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -109,6 +109,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } receipts = append(receipts, receipt) allLogs = append(allLogs, receipt.Logs...) + + /* + enc, _ := json.MarshalIndent(receipt, "", " ") + fmt.Printf("receipt json %s\n", string(enc)) + encRLP, _ := rlp.EncodeToBytes(receipt) + fmt.Printf("receipt rlp %x\n", encRLP) + */ } // Read requests if Prague is enabled.