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
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, msg *evmtypes.MsgE
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))

// Create state DB for this transaction
stateDB := gigaevmstate.NewDBImpl(ctx, &app.GigaEvmKeeper, false)
stateDB := gigaevmstate.NewDBImplWithoutSnapshot(ctx, &app.GigaEvmKeeper, false)
defer stateDB.Cleanup()

// Get gas pool
Expand Down
3 changes: 3 additions & 0 deletions giga/deps/xevm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func (s *DBImpl) CreateAccount(acc common.Address) {
}

func (s *DBImpl) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
if len(s.snapshottedCtxs) == 0 {
return s.getState(s.ctx, addr, hash)
}
return s.getState(s.snapshottedCtxs[0], addr, hash)
}

Expand Down
22 changes: 22 additions & 0 deletions giga/deps/xevm/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ func NewDBImpl(ctx sdk.Context, k EVMKeeper, simulation bool) *DBImpl {
return s
}

// NewDBImplWithoutSnapshot creates a DBImpl without the initial Snapshot() call.
// Use this only when the caller guarantees that Prepare() (which calls Snapshot)
// will be called before any state reads/writes — e.g. in the OCC executor path
// where core.ApplyMessage always calls Prepare before EVM execution.
// This avoids creating a redundant CacheMultiStore layer.
func NewDBImplWithoutSnapshot(ctx sdk.Context, k EVMKeeper, simulation bool) *DBImpl {
feeCollector, _ := k.GetFeeCollectorAddress(ctx)
return &DBImpl{
ctx: ctx,
k: k,
snapshottedCtxs: []sdk.Context{},
coinbaseAddress: GetCoinbaseAddress(ctx.TxIndex()),
simulation: simulation,
tempState: NewTemporaryState(),
journal: []journalEntry{},
coinbaseEvmAddress: feeCollector,
}
}

func (s *DBImpl) DisableEvents() {
s.eventsSuppressed = true
}
Expand Down Expand Up @@ -141,6 +160,9 @@ func (s *DBImpl) flushCtx(ctx sdk.Context) {
}

func (s *DBImpl) flushEvents(ctx sdk.Context) {
if len(s.snapshottedCtxs) == 0 {
return
}
s.snapshottedCtxs[0].EventManager().EmitEvents(ctx.EventManager().Events())
}

Expand Down
Loading