diff --git a/app/receipt.go b/app/receipt.go index 6ba273d21..02a987c8e 100644 --- a/app/receipt.go +++ b/app/receipt.go @@ -39,17 +39,18 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. return } logs := []*ethtypes.Log{} - wasmGasLimit := app.EvmKeeper.GetDeliverTxHookWasmGasLimit(ctx) - queryCtx := ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, wasmGasLimit)) + // Note: txs with a very large number of WASM events may run out of gas due to + // additional gas consumption from EVM receipt generation and event translation + wasmToEvmEventGasLimit := app.EvmKeeper.GetDeliverTxHookWasmGasLimit(ctx.WithGasMeter(sdk.NewInfiniteGasMeter(1, 1))) + wasmToEvmEventCtx := ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, wasmToEvmEventGasLimit)) for _, wasmEvent := range wasmEvents { contractAddr, found := GetAttributeValue(wasmEvent, wasmtypes.AttributeKeyContractAddr) if !found { continue } - // check if there is a ERC20 pointer to contractAddr - pointerAddr, _, exists := app.EvmKeeper.GetERC20CW20Pointer(queryCtx, contractAddr) + pointerAddr, _, exists := app.EvmKeeper.GetERC20CW20Pointer(wasmToEvmEventCtx, contractAddr) if exists { - log, eligible := app.translateCW20Event(queryCtx, wasmEvent, pointerAddr, contractAddr) + log, eligible := app.translateCW20Event(wasmToEvmEventCtx, wasmEvent, pointerAddr, contractAddr) if eligible { log.Index = uint(len(logs)) logs = append(logs, log) @@ -57,9 +58,9 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. continue } // check if there is a ERC721 pointer to contract Addr - pointerAddr, _, exists = app.EvmKeeper.GetERC721CW721Pointer(queryCtx, contractAddr) + pointerAddr, _, exists = app.EvmKeeper.GetERC721CW721Pointer(wasmToEvmEventCtx, contractAddr) if exists { - log, eligible := app.translateCW721Event(queryCtx, wasmEvent, pointerAddr, contractAddr) + log, eligible := app.translateCW721Event(wasmToEvmEventCtx, wasmEvent, pointerAddr, contractAddr) if eligible { log.Index = uint(len(logs)) logs = append(logs, log) @@ -75,14 +76,14 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. txHash = common.HexToHash(response.EvmTxInfo.TxHash) } var bloom ethtypes.Bloom - if r, err := app.EvmKeeper.GetTransientReceipt(ctx, txHash); err == nil && r != nil { + if r, err := app.EvmKeeper.GetTransientReceipt(wasmToEvmEventCtx, txHash); err == nil && r != nil { r.Logs = append(r.Logs, utils.Map(logs, evmkeeper.ConvertSyntheticEthLog)...) for i, l := range r.Logs { l.Index = uint32(i) } bloom = ethtypes.CreateBloom(ethtypes.Receipts{ðtypes.Receipt{Logs: evmkeeper.GetLogsForTx(r)}}) r.LogsBloom = bloom[:] - _ = app.EvmKeeper.SetTransientReceipt(ctx, txHash, r) + _ = app.EvmKeeper.SetTransientReceipt(wasmToEvmEventCtx, txHash, r) } else { bloom = ethtypes.CreateBloom(ethtypes.Receipts{ðtypes.Receipt{Logs: logs}}) receipt := &evmtypes.Receipt{ @@ -98,14 +99,14 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. sigTx, ok := tx.(authsigning.SigVerifiableTx) if ok && len(sigTx.GetSigners()) > 0 { // use the first signer as the `from` - receipt.From = app.EvmKeeper.GetEVMAddressOrDefault(ctx, sigTx.GetSigners()[0]).Hex() + receipt.From = app.EvmKeeper.GetEVMAddressOrDefault(wasmToEvmEventCtx, sigTx.GetSigners()[0]).Hex() } - _ = app.EvmKeeper.SetTransientReceipt(ctx, txHash, receipt) + _ = app.EvmKeeper.SetTransientReceipt(wasmToEvmEventCtx, txHash, receipt) } if d, found := app.EvmKeeper.GetEVMTxDeferredInfo(ctx); found { - app.EvmKeeper.AppendToEvmTxDeferredInfo(ctx, bloom, txHash, d.Surplus) + app.EvmKeeper.AppendToEvmTxDeferredInfo(wasmToEvmEventCtx, bloom, txHash, d.Surplus) } else { - app.EvmKeeper.AppendToEvmTxDeferredInfo(ctx, bloom, txHash, sdk.ZeroInt()) + app.EvmKeeper.AppendToEvmTxDeferredInfo(wasmToEvmEventCtx, bloom, txHash, sdk.ZeroInt()) } } diff --git a/app/seidb.go b/app/seidb.go index a50614639..d51aadc6e 100644 --- a/app/seidb.go +++ b/app/seidb.go @@ -56,7 +56,7 @@ func SetupSeiDB( // cms must be overridden before the other options, because they may use the cms, // make sure the cms aren't be overridden by the other options later on. - cms := rootmulti.NewStore(homePath, logger, scConfig, ssConfig) + cms := rootmulti.NewStore(homePath, logger, scConfig, ssConfig, false) baseAppOptions = append([]func(*baseapp.BaseApp){ func(baseApp *baseapp.BaseApp) { baseApp.SetCMS(cms) diff --git a/go.mod b/go.mod index ba4e98156..d02d3f8a3 100644 --- a/go.mod +++ b/go.mod @@ -346,7 +346,7 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.39 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.41 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-23 diff --git a/go.sum b/go.sum index 9e29d9773..1d4d9e7db 100644 --- a/go.sum +++ b/go.sum @@ -1347,8 +1347,8 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-23 h1:rkgeOHC56QTco4mIyGd6cZHtlo github.com/sei-protocol/go-ethereum v1.13.5-sei-23/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= -github.com/sei-protocol/sei-cosmos v0.3.39 h1:EaAoJNyN11MJCkgZG5D92UGXLy0X2NAPz0HltOHEBxk= -github.com/sei-protocol/sei-cosmos v0.3.39/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= +github.com/sei-protocol/sei-cosmos v0.3.41 h1:w5ekTGC5J/7kxJhRkfdHk2KWOqi1zhic0gOXNm6W5vI= +github.com/sei-protocol/sei-cosmos v0.3.41/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= github.com/sei-protocol/sei-db v0.0.44 h1:HMgcyDTQlmXdJysHJxmIo66EKeXn1CSQT9qXDnxjJgI= github.com/sei-protocol/sei-db v0.0.44/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= diff --git a/tools/migration/sc/migrator.go b/tools/migration/sc/migrator.go index 5eec43a62..b4d66e85c 100644 --- a/tools/migration/sc/migrator.go +++ b/tools/migration/sc/migrator.go @@ -77,7 +77,7 @@ func NewMigrator(homeDir string, db dbm.DB) *Migrator { scConfig.Enable = true ssConfig := config.DefaultStateStoreConfig() ssConfig.Enable = false - cmsV2 := rootmulti2.NewStore(homeDir, logger, scConfig, ssConfig) + cmsV2 := rootmulti2.NewStore(homeDir, logger, scConfig, ssConfig, false) for _, key := range Keys { cmsV2.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) }