Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: logs in callback contract are lost #1233

Merged
merged 11 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [#1217](https://github.com/crypto-org-chain/cronos/pull/1217) Use the default chain-id behavour in sdk.
- [#1216](https://github.com/crypto-org-chain/cronos/pull/1216) Update ethermint to fix of avoid redundant parse chainID from gensis when start server.
- [#1230](https://github.com/crypto-org-chain/cronos/pull/1230) Fix mem store in versiondb multistore.
- [#1233](https://github.com/crypto-org-chain/cronos/pull/1233) Re-emit logs in callback contract.

*October 17, 2023*

Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_ica_precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,5 @@ def submit_msgs_ro(func, str):
assert expected_seq == last_seq
assert status == Status.FAIL
assert cli_host.balance(ica_address, denom=denom) == balance

print(tcontract.events.OnPacketResult().get_logs())
yihuang marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 12 additions & 2 deletions x/cronos/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
cronosprecompiles "github.com/crypto-org-chain/cronos/v2/x/cronos/keeper/precompiles"
"github.com/crypto-org-chain/cronos/v2/x/cronos/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
// this line is used by starport scaffolding # ibc/keeper/import
)

Expand Down Expand Up @@ -298,8 +299,17 @@ func (k Keeper) onPacketResult(
return err
}
gasLimit := k.GetParams(ctx).MaxCallbackGas
_, _, err = k.CallEVM(ctx, &contractAddr, data, big.NewInt(0), gasLimit)
return err
_, rsp, err := k.CallEVM(ctx, &contractAddr, data, big.NewInt(0), gasLimit)
if err != nil {
return err
}

if stateDB, ok := ctx.Value("statedb").(vm.StateDB); ok {
for _, l := range rsp.Logs {
stateDB.AddLog(l.ToEthereum())
thomas-nguy marked this conversation as resolved.
Show resolved Hide resolved
}
}
return nil
}

func (k Keeper) IBCOnAcknowledgementPacketCallback(
Expand Down
1 change: 1 addition & 0 deletions x/cronos/keeper/precompiles/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func exec[Req any, PReq interface {
var res Resp
if err := stateDB.ExecuteNativeAction(contract, converter, func(ctx sdk.Context) error {
var err error
ctx = ctx.WithValue("statedb", stateDB)
res, err = action(ctx, msg)
return err
}); err != nil {
Expand Down
Loading