forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: transient store usage not compatible with parallel tx execution
Currently we use shared transient store keys to accumulate some states, which cause issues when developing parallel tx execution Solution: - remove some transient stores. - the others are used in a per-tx fasion.
- Loading branch information
Showing
16 changed files
with
165 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
|
||
storetypes "cosmossdk.io/store/types" | ||
abci "github.com/cometbft/cometbft/abci/types" | ||
evmtypes "github.com/evmos/ethermint/x/evm/types" | ||
) | ||
|
||
func DefaultTxExecutor(_ context.Context, | ||
blockSize int, | ||
ms storetypes.MultiStore, | ||
deliverTxWithMultiStore func(int, storetypes.MultiStore) *abci.ExecTxResult, | ||
) ([]*abci.ExecTxResult, error) { | ||
results := make([]*abci.ExecTxResult, blockSize) | ||
for i := 0; i < blockSize; i++ { | ||
results[i] = deliverTxWithMultiStore(i, ms) | ||
} | ||
return evmtypes.PatchTxResponses(results), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package keeper | ||
|
||
import ( | ||
"math/big" | ||
|
||
"cosmossdk.io/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/evmos/ethermint/x/evm/types" | ||
) | ||
|
||
func (k Keeper) SetTxBloom(ctx sdk.Context, bloom []byte) { | ||
store := ctx.KVStore(k.transientKey) | ||
store.Set(types.TransientBloomKey(ctx.TxIndex(), ctx.MsgIndex()), bloom) | ||
} | ||
|
||
func (k Keeper) CollectTxBloom(ctx sdk.Context) { | ||
store := prefix.NewStore(ctx.KVStore(k.transientKey), types.KeyPrefixTransientBloom) | ||
it := store.Iterator(nil, nil) | ||
defer it.Close() | ||
|
||
bloom := new(big.Int) | ||
for ; it.Valid(); it.Next() { | ||
bloom.Or(bloom, big.NewInt(0).SetBytes(it.Value())) | ||
} | ||
|
||
k.EmitBlockBloomEvent(ctx, bloom.Bytes()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package types | ||
|
||
import ( | ||
"strconv" | ||
|
||
abci "github.com/cometbft/cometbft/abci/types" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
proto "github.com/cosmos/gogoproto/proto" | ||
) | ||
|
||
// PatchTxResponses fills the evm tx index and log indexes in the tx result | ||
func PatchTxResponses(input []*abci.ExecTxResult) []*abci.ExecTxResult { | ||
var ( | ||
txIndex uint64 | ||
logIndex uint64 | ||
) | ||
for _, res := range input { | ||
// assume no error result in msg handler | ||
if res.Code != 0 { | ||
continue | ||
} | ||
|
||
var txMsgData sdk.TxMsgData | ||
if err := proto.Unmarshal(res.Data, &txMsgData); err != nil { | ||
continue | ||
} | ||
|
||
var dirty bool | ||
for i, rsp := range txMsgData.MsgResponses { | ||
var response MsgEthereumTxResponse | ||
if rsp.TypeUrl != "/"+proto.MessageName(&response) { | ||
continue | ||
} | ||
if err := proto.Unmarshal(rsp.Value, &response); err != nil { | ||
continue | ||
} | ||
|
||
res.Events = append(res.Events, abci.Event(sdk.NewEvent( | ||
EventTypeEthereumTx, | ||
sdk.NewAttribute(AttributeKeyTxIndex, strconv.FormatUint(txIndex, 10)), | ||
))) | ||
for _, log := range response.Logs { | ||
log.TxIndex = txIndex | ||
log.Index = logIndex | ||
logIndex++ | ||
} | ||
txIndex++ | ||
|
||
dirty = true | ||
anyRsp, err := codectypes.NewAnyWithValue(&response) | ||
if err != nil { | ||
panic(err) | ||
} | ||
txMsgData.MsgResponses[i] = anyRsp | ||
} | ||
|
||
if dirty { | ||
if data, err := proto.Marshal(&txMsgData); err != nil { | ||
res.Data = data | ||
} | ||
} | ||
} | ||
return input | ||
} |
Oops, something went wrong.