Skip to content
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
57 changes: 57 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "CodeQL"

on:
pull_request:
paths:
- "**.go"
push:
branches:
- main
- release/**
paths:
- "**.go"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-go@v6
with:
go-version: '1.25.6'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: "go"
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
126 changes: 55 additions & 71 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/sei-protocol/sei-chain/sei-cosmos/codec"
"github.com/sei-protocol/sei-chain/sei-cosmos/codec/types"
cryptotypes "github.com/sei-protocol/sei-chain/sei-cosmos/crypto/types"
"github.com/sei-protocol/sei-chain/sei-cosmos/server"
"github.com/sei-protocol/sei-chain/sei-cosmos/server/api"
"github.com/sei-protocol/sei-chain/sei-cosmos/server/config"
servertypes "github.com/sei-protocol/sei-chain/sei-cosmos/server/types"
Expand Down Expand Up @@ -117,6 +118,7 @@ import (
gigautils "github.com/sei-protocol/sei-chain/giga/executor/utils"
"github.com/sei-protocol/sei-chain/precompiles"
putils "github.com/sei-protocol/sei-chain/precompiles/utils"
ssconfig "github.com/sei-protocol/sei-chain/sei-db/config"
"github.com/sei-protocol/sei-chain/sei-ibc-go/modules/apps/transfer"
ibctransferkeeper "github.com/sei-protocol/sei-chain/sei-ibc-go/modules/apps/transfer/keeper"
ibctransfertypes "github.com/sei-protocol/sei-chain/sei-ibc-go/modules/apps/transfer/types"
Expand Down Expand Up @@ -676,10 +678,10 @@ func New(
wasmOpts...,
)

receiptConfig, err := readReceiptStoreConfig(homePath, appOpts)
if err != nil {
panic(fmt.Sprintf("error reading receipt store config: %s", err))
}
receiptStorePath := filepath.Join(homePath, "data", "receipt.db")
receiptConfig := ssconfig.DefaultReceiptStoreConfig()
receiptConfig.DBDirectory = receiptStorePath
receiptConfig.KeepRecent = cast.ToInt(appOpts.Get(server.FlagMinRetainBlocks))
if app.receiptStore == nil {
receiptStore, err := receipt.NewReceiptStore(logger, receiptConfig, keys[evmtypes.StoreKey])
if err != nil {
Expand Down Expand Up @@ -747,7 +749,7 @@ func New(
if gigaExecutorConfig.OCCEnabled {
logger.Info("benchmark: Giga Executor with OCC is ENABLED - using new EVM execution path with parallel execution")
} else {
logger.Info("benchmark: Giga Executor is ENABLED - using new EVM execution path (sequential)")
logger.Info("benchmark: Giga Executor (evmone-based) is ENABLED - using new EVM execution path (sequential)")
}
} else {
logger.Info("benchmark: Giga Executor is DISABLED - using default GETH interpreter")
Expand Down Expand Up @@ -1544,89 +1546,71 @@ func (app *App) ProcessTXsWithOCCV2(ctx sdk.Context, txs [][]byte, typedTxs []sd
func (app *App) ProcessTXsWithOCCGiga(ctx sdk.Context, txs [][]byte, typedTxs []sdk.Tx) ([]*abci.ExecTxResult, sdk.Context) {
evmEntries := make([]*sdk.DeliverTxEntry, 0, len(txs))
v2Entries := make([]*sdk.DeliverTxEntry, 0, len(txs))
firstCosmosSeen := false
for txIndex, tx := range txs {
if app.GetEVMMsg(typedTxs[txIndex]) != nil {
if firstCosmosSeen {
ctx.Logger().Error("Giga OCC cannot execute block due to tx ordering, falling back to V2")
// Oops! This isn't "all EVM txs, then all Cosmos txs" - we need to fallback to V2.
return app.ProcessTXsWithOCCV2(ctx, txs, typedTxs)
}

evmEntries = append(evmEntries, app.GetDeliverTxEntry(ctx, txIndex, tx, typedTxs[txIndex]))
} else {
if !firstCosmosSeen {
firstCosmosSeen = true
}
v2Entries = append(v2Entries, app.GetDeliverTxEntry(ctx, txIndex, tx, typedTxs[txIndex]))
}
}

var evmBatchResult []abci.ResponseDeliverTx
fallbackToV2 := false

if len(evmEntries) > 0 {
// Run EVM txs against a cache so we can discard all changes on fallback.
evmCtx, evmCache := app.CacheContext(ctx)
// Run EVM txs against a cache so we can discard all changes on fallback.
evmCtx, evmCache := app.CacheContext(ctx)

// Cache block-level constants (identical for all txs in this block).
// Must use evmCtx (not ctx) because giga KV stores are registered in CacheContext.
cache, cacheErr := newGigaBlockCache(evmCtx, &app.GigaEvmKeeper)
if cacheErr != nil {
ctx.Logger().Error("failed to build giga block cache", "error", cacheErr, "height", ctx.BlockHeight())
return nil, ctx
}
// Cache block-level constants (identical for all txs in this block).
// Must use evmCtx (not ctx) because giga KV stores are registered in CacheContext.
cache, cacheErr := newGigaBlockCache(evmCtx, &app.GigaEvmKeeper)
if cacheErr != nil {
ctx.Logger().Error("failed to build giga block cache", "error", cacheErr, "height", ctx.BlockHeight())
return nil, ctx
}

// Create OCC scheduler with giga executor deliverTx capturing the cache.
evmScheduler := tasks.NewScheduler(
app.ConcurrencyWorkers(),
app.TracingInfo,
app.makeGigaDeliverTx(cache),
)
// Create OCC scheduler with giga executor deliverTx capturing the cache.
evmScheduler := tasks.NewScheduler(
app.ConcurrencyWorkers(),
app.TracingInfo,
app.makeGigaDeliverTx(cache),
)

var evmSchedErr error
evmBatchResult, evmSchedErr = evmScheduler.ProcessAll(evmCtx, evmEntries)
if evmSchedErr != nil {
ctx.Logger().Error("benchmark OCC scheduler error (EVM txs)", "error", evmSchedErr, "height", ctx.BlockHeight(), "txCount", len(evmEntries))
return nil, ctx
}
evmBatchResult, evmSchedErr := evmScheduler.ProcessAll(evmCtx, evmEntries)
if evmSchedErr != nil {
// TODO: DeliverTxBatch panics in this case
// TODO: detect if it was interop, and use v2 if so
ctx.Logger().Error("benchmark OCC scheduler error (EVM txs)", "error", evmSchedErr, "height", ctx.BlockHeight(), "txCount", len(evmEntries))
return nil, ctx
}

for _, r := range evmBatchResult {
if r.Code == gigautils.GigaAbortCode && r.Codespace == gigautils.GigaAbortCodespace {
fallbackToV2 = true
break
}
fallbackToV2 := false
for _, r := range evmBatchResult {
if r.Code == gigautils.GigaAbortCode && r.Codespace == gigautils.GigaAbortCodespace {
fallbackToV2 = true
break
}
}

if fallbackToV2 {
metrics.IncrGigaFallbackToV2Counter()
// Discard all EVM changes by skipping cache writes, then re-run all txs via DeliverTx.
evmBatchResult = nil
v2Entries = make([]*sdk.DeliverTxEntry, len(txs))
for txIndex, tx := range txs {
v2Entries[txIndex] = app.GetDeliverTxEntry(ctx, txIndex, tx, typedTxs[txIndex])
}
} else {
// Commit EVM cache to main store before processing non-EVM txs.
evmCache.Write()
evmCtx.GigaMultiStore().WriteGiga()
if fallbackToV2 {
metrics.IncrGigaFallbackToV2Counter()
// Discard all EVM changes by skipping cache writes, then re-run all txs via DeliverTx.
evmBatchResult = nil
v2Entries = make([]*sdk.DeliverTxEntry, len(txs))
for txIndex, tx := range txs {
v2Entries[txIndex] = app.GetDeliverTxEntry(ctx, txIndex, tx, typedTxs[txIndex])
}
} else {
// Commit EVM cache to main store before processing non-EVM txs.
evmCache.Write()
evmCtx.GigaMultiStore().WriteGiga()
}

var v2BatchResult []abci.ResponseDeliverTx

if len(v2Entries) > 0 {
v2Scheduler := tasks.NewScheduler(
app.ConcurrencyWorkers(),
app.TracingInfo,
app.DeliverTx,
)
var v2SchedErr error
v2BatchResult, v2SchedErr = v2Scheduler.ProcessAll(ctx, v2Entries)
if v2SchedErr != nil {
ctx.Logger().Error("benchmark OCC scheduler error", "error", v2SchedErr, "height", ctx.BlockHeight(), "txCount", len(v2Entries))
return nil, ctx
}
v2Scheduler := tasks.NewScheduler(
app.ConcurrencyWorkers(),
app.TracingInfo,
app.DeliverTx,
)
v2BatchResult, v2SchedErr := v2Scheduler.ProcessAll(ctx, v2Entries)
if v2SchedErr != nil {
ctx.Logger().Error("benchmark OCC scheduler error", "error", v2SchedErr, "height", ctx.BlockHeight(), "txCount", len(v2Entries))
return nil, ctx
}

execResults := make([]*abci.ExecTxResult, 0, len(evmBatchResult)+len(v2BatchResult))
Expand Down
26 changes: 0 additions & 26 deletions app/receipt_store_config.go

This file was deleted.

3 changes: 0 additions & 3 deletions app/seidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
FlagSCHistoricalProofBurst = "state-commit.sc-historical-proof-burst"
FlagSCWriteMode = "state-commit.sc-write-mode"
FlagSCReadMode = "state-commit.sc-read-mode"
FlagSCEnableLatticeHash = "state-commit.sc-enable-lattice-hash"

// SS Store configs
FlagSSEnable = "state-store.ss-enable"
Expand Down Expand Up @@ -121,8 +120,6 @@ func parseSCConfigs(appOpts servertypes.AppOptions) config.StateCommitConfig {
scConfig.ReadMode = parsedRM
}

scConfig.EnableLatticeHash = cast.ToBool(appOpts.Get(FlagSCEnableLatticeHash))

if v := appOpts.Get(FlagSCHistoricalProofMaxInFlight); v != nil {
scConfig.HistoricalProofMaxInFlight = cast.ToInt(v)
}
Expand Down
Loading
Loading