Skip to content

Commit

Permalink
stop flushing deferred info into receipt store (#1909)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Su <[email protected]>
  • Loading branch information
codchen and philipsu522 authored Oct 30, 2024
1 parent 6a3c5f3 commit 97346a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x/evm/keeper/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/iavl"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -91,12 +92,12 @@ func (k *Keeper) MockReceipt(ctx sdk.Context, txHash common.Hash, receipt *types
}

func (k *Keeper) FlushTransientReceipts(ctx sdk.Context) error {
iter := ctx.TransientStore(k.transientStoreKey).Iterator(nil, nil)
iter := prefix.NewStore(ctx.TransientStore(k.transientStoreKey), types.ReceiptKeyPrefix).Iterator(nil, nil)
defer iter.Close()
var pairs []*iavl.KVPair
var changesets []*proto.NamedChangeSet
for ; iter.Valid(); iter.Next() {
kvPair := &iavl.KVPair{Key: iter.Key(), Value: iter.Value()}
kvPair := &iavl.KVPair{Key: types.ReceiptKey(common.Hash(iter.Key())), Value: iter.Value()}
pairs = append(pairs, kvPair)
}
if len(pairs) == 0 {
Expand Down
5 changes: 5 additions & 0 deletions x/evm/keeper/receipt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package keeper_test
import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper"
"github.com/sei-protocol/sei-chain/x/evm/types"
"github.com/stretchr/testify/require"
Expand All @@ -16,7 +18,10 @@ func TestReceipt(t *testing.T) {
_, err := k.GetReceipt(ctx, txHash)
require.NotNil(t, err)
k.MockReceipt(ctx, txHash, &types.Receipt{TxHashHex: txHash.Hex()})
k.AppendToEvmTxDeferredInfo(ctx, ethtypes.Bloom{}, common.Hash{1}, sdk.NewInt(1)) // make sure this isn't flushed into receipt store
r, err := k.GetReceipt(ctx, txHash)
require.Nil(t, err)
require.Equal(t, txHash.Hex(), r.TxHashHex)
_, err = k.GetReceipt(ctx, common.Hash{1})
require.Equal(t, "not found", err.Error())
}

0 comments on commit 97346a2

Please sign in to comment.