Skip to content
Open
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
4 changes: 0 additions & 4 deletions .cursor/rules/xlayer-db.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ globs:
- "cmd/geth/dbcmd.go"
- "core/rawdb/*_test.go"
- "core/rawdb/ancienttest/**/*.go"
- "core/rawdb/accessors_inner_tx_xlayer.go"
- "core/types/innertx_xlayer.go"
- "core/state_processor_xlayer.go"
- "core/vm/evm_xlayer.go"

alwaysApply: false
---
Expand Down
15 changes: 0 additions & 15 deletions cmd/utils/flags_xlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ import (
)

var (
// InnerTx
InnerTxFlag = &cli.BoolFlag{
Name: "innertx",
Usage: "Enable inner transaction capture and storage (disabled by default)",
Value: false,
Category: flags.XLayerCategory,
}
// Migration flags for XLayer routing
MigrationBlockFlag = &cli.Uint64Flag{
Name: "migration-block",
Expand Down Expand Up @@ -55,7 +48,6 @@ var (

// XLayerFlags are the default flags for X Layer features
XLayerFlags = []cli.Flag{
InnerTxFlag,
MigrationBlockFlag,
PPRPCUrlFlag,
PPRPCTimeoutFlag,
Expand All @@ -66,17 +58,10 @@ var (

// SetXLayerConfig is a public wrapper function to internally call all XLayer configuration functions
func SetXLayerConfig(ctx *cli.Context, cfg *ethconfig.Config) {
setInnerTxXLayer(ctx, cfg)
setMigrationXLayer(ctx, cfg)
setMonitorXLayer(ctx, cfg)
}

func setInnerTxXLayer(ctx *cli.Context, cfg *ethconfig.Config) {
if ctx.IsSet(InnerTxFlag.Name) {
cfg.XLayer.EnableInnerTx = ctx.Bool(InnerTxFlag.Name)
}
}

func setMigrationXLayer(ctx *cli.Context, cfg *ethconfig.Config) {
// Migration configuration
if ctx.IsSet(MigrationBlockFlag.Name) {
Expand Down
40 changes: 6 additions & 34 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,17 +1085,6 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha
// removed by the hc.SetHead function.
rawdb.DeleteBody(db, hash, num)
rawdb.DeleteReceipts(db, hash, num)

// For X Layer
// Delete inner transactions for this block during SetHead rollback
if block := bc.GetBlock(hash, num); block != nil {
txCount := len(block.Transactions())
if err := rawdb.DeleteBlockInnerTxs(db, num, txCount); err != nil {
log.Error("Failed to delete inner transactions during SetHead rollback",
"block", num, "hash", hash, "err", err)
// Continue with rollback even if inner tx deletion fails
}
}
}

// Todo(rjl493456442) txlookup, log index, etc
Expand Down Expand Up @@ -1629,31 +1618,19 @@ func (bc *BlockChain) writeKnownBlock(block *types.Block) error {

// writeBlockWithState writes block, metadata and corresponding state data to the
// database.
func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, statedb *state.StateDB, sortedInnerTxs [][]*types.InnerTx) error {
func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, statedb *state.StateDB) error {
if !bc.HasHeader(block.ParentHash(), block.NumberU64()-1) {
return consensus.ErrUnknownAncestor
}
// Irrelevant of the canonical status, write the block itself to the database.
//
// Note all the components of block(hash->number map, header, body, receipts, innerTxs)
// Note all the components of block(hash->number map, header, body, receipts)
// should be written atomically. BlockBatch is used for containing all components.
blockBatch := bc.db.NewBatch()
rawdb.WriteBlock(blockBatch, block)
rawdb.WriteReceipts(blockBatch, block.Hash(), block.NumberU64(), receipts)
rawdb.WritePreimages(blockBatch, statedb.Preimages())

// For X Layer
// Write inner transactions for each transaction in the block
for i, txInnerTxs := range sortedInnerTxs {
if len(txInnerTxs) > 0 {
if err := rawdb.WriteInnerTxs(blockBatch, block.NumberU64(), uint32(i), txInnerTxs); err != nil {
log.Error("Failed to write inner transactions to batch",
"block", block.NumberU64(), "tx", i, "count", len(txInnerTxs), "err", err)
// Continue processing even if inner tx storage fails
}
}
}

if err := blockBatch.Write(); err != nil {
log.Crit("Failed to write block into disk", "err", err)
}
Expand Down Expand Up @@ -1728,8 +1705,8 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.

// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
// This function expects the chain mutex to be held.
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool, innerTxs [][]*types.InnerTx) (status WriteStatus, err error) {
if err := bc.writeBlockWithState(block, receipts, state, innerTxs); err != nil {
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
if err := bc.writeBlockWithState(block, receipts, state); err != nil {
return NonStatTy, err
}
currentBlock := bc.CurrentBlock()
Expand Down Expand Up @@ -2209,9 +2186,9 @@ func (bc *BlockChain) ProcessBlock(parentRoot common.Hash, block *types.Block, s
)
if !setHead {
// Don't set the head, only insert the block
err = bc.writeBlockWithState(block, res.Receipts, statedb, res.InnerTxs)
err = bc.writeBlockWithState(block, res.Receipts, statedb)
} else {
status, err = bc.writeBlockAndSetHead(block, res.Receipts, res.Logs, statedb, false, res.InnerTxs)
status, err = bc.writeBlockAndSetHead(block, res.Receipts, res.Logs, statedb, false)
}
if err != nil {
return nil, err
Expand Down Expand Up @@ -2601,11 +2578,6 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error
rawdb.DeleteTxLookupEntry(batch, tx)
}

// For X Layer - delete inner transactions for all deleted blocks
for _, block := range deletedBlocks {
rawdb.DeleteBlockInnerTxsBatch(batch, block.Number().Uint64(), len(block.Transactions()))
}

// Delete all hash markers that are not part of the new canonical chain.
// Because the reorg function does not handle new chain head, all hash
// markers greater than or equal to new chain head should be deleted.
Expand Down
133 changes: 0 additions & 133 deletions core/rawdb/accessors_inner_tx_xlayer.go

This file was deleted.

15 changes: 3 additions & 12 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
blockHash = block.Hash()
blockNumber = block.Number()
allLogs []*types.Log
gp = new(GasPool).AddGas(block.GasLimit())

// For X Layer
allInnerTxs [][]*types.InnerTx
gp = new(GasPool).AddGas(block.GasLimit())
)

// Mutate the block and state according to any hard-fork specs
Expand Down Expand Up @@ -104,16 +101,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}
statedb.SetTxContext(tx.Hash(), i)

receipt, innerTxs, err := ApplyTransactionWithEVM_XLayer(msg, gp, statedb, blockNumber, blockHash, context.Time, tx, usedGas, evm)
receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, context.Time, tx, usedGas, evm)
if err != nil {
return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}

receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...)

// For X Layer
allInnerTxs = append(allInnerTxs, innerTxs)
}

isIsthmus := config.IsIsthmus(block.Time())
Expand Down Expand Up @@ -147,10 +141,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
Receipts: receipts,
Requests: requests,
Logs: allLogs,
GasUsed: *usedGas,

// For X Layer
InnerTxs: allInnerTxs,
GasUsed: *usedGas,
}, nil
}

Expand Down
80 changes: 0 additions & 80 deletions core/state_processor_xlayer.go

This file was deleted.

Loading