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

fix: minor #106

Merged
merged 2 commits into from
Nov 11, 2024
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
8 changes: 5 additions & 3 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"sync/atomic"

"cosmossdk.io/collections"
"cosmossdk.io/core/address"
Expand Down Expand Up @@ -49,7 +50,7 @@ type Keeper struct {

// execIndex is unique index for each execution, which is used
// unique key for transient stores.
execIndex *uint64
execIndex *atomic.Uint64
beer-1 marked this conversation as resolved.
Show resolved Hide resolved

// transient store
TSchema collections.Schema
Expand Down Expand Up @@ -109,7 +110,8 @@ func NewKeeper(
panic(err)
}

execIndex := uint64(0)
execIndex := &atomic.Uint64{}
execIndex.Store(0)
k := &Keeper{
ac: ac,
cdc: cdc,
Expand All @@ -130,7 +132,7 @@ func NewKeeper(
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
VMStore: collections.NewMap(sb, types.VMStorePrefix, "vm_store", collections.BytesKey, collections.BytesValue),

execIndex: &execIndex,
execIndex: execIndex,

TransientVMStore: collections.NewMap(tsb, types.TransientVMStorePrefix, "transient_vm_store", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), collections.BytesValue),
TransientCreated: collections.NewKeySet(tsb, types.TransientCreatedPrefix, "transient_created", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey)),
Expand Down
8 changes: 2 additions & 6 deletions x/evm/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,18 @@ func NewStateDB(
transientLogSize collections.Map[uint64, uint64],
transientAccessList collections.KeySet[collections.Pair[uint64, []byte]],
transientRefund collections.Map[uint64, uint64],
execIndex *uint64,
execIndex *atomic.Uint64,
// erc20 params
evm callableEVM,
erc20ABI *abi.ABI,
feeContractAddr common.Address,
) (*StateDB, error) {
eidx := atomic.AddUint64(execIndex, 1)
eidx := execIndex.Add(1)

err := transientLogSize.Set(ctx, eidx, 0)
if err != nil {
return nil, err
}
err = transientLogSize.Set(ctx, eidx, 0)
if err != nil {
return nil, err
}
err = transientRefund.Set(ctx, eidx, 0)
if err != nil {
return nil, err
Expand Down
Loading