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

chore: add OE Abort rate debug flag (backport #2366) #2401

Merged
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
14 changes: 13 additions & 1 deletion protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"context"
"encoding/json"
"fmt"
"io"
"math/big"
"net/http"
Expand Down Expand Up @@ -33,6 +34,7 @@ import (
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/baseapp/oe"
"github.com/cosmos/cosmos-sdk/client"
cosmosflags "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
Expand Down Expand Up @@ -413,7 +415,17 @@ func New(
// Enable optimistic block execution.
if appFlags.OptimisticExecutionEnabled {
logger.Info("optimistic execution is enabled.")
baseAppOptions = append(baseAppOptions, baseapp.SetOptimisticExecution())
if appFlags.OptimisticExecutionTestAbortRate > 0 {
logger.Warn(fmt.Sprintf(
"Test flag optimistic-execution-test-abort-rate is set: %v\n",
appFlags.OptimisticExecutionTestAbortRate,
))
}
baseAppOptions = append(
baseAppOptions,
baseapp.SetOptimisticExecution(
oe.WithAbortRate(int(appFlags.OptimisticExecutionTestAbortRate)),
))
}

bApp := baseapp.NewBaseApp(appconstants.AppName, logger, db, txConfig.TxDecoder(), baseAppOptions...)
Expand Down
28 changes: 22 additions & 6 deletions protocol/app/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ type Flags struct {

VEOracleEnabled bool // Slinky Vote Extensions
// Optimistic block execution
OptimisticExecutionEnabled bool
OptimisticExecutionEnabled bool
OptimisticExecutionTestAbortRate uint16
}

// List of CLI flags.
Expand All @@ -58,7 +59,8 @@ const (
VEOracleEnabled = "slinky-vote-extension-oracle-enabled"

// Enable optimistic block execution.
OptimisticExecutionEnabled = "optimistic-execution-enabled"
OptimisticExecutionEnabled = "optimistic-execution-enabled"
OptimisticExecutionTestAbortRate = "optimistic-execution-test-abort-rate"
)

// Default values.
Expand All @@ -76,8 +78,10 @@ const (
DefaultWebsocketStreamingPort = 9092
DefaultFullNodeStreamingSnapshotInterval = 0

DefaultVEOracleEnabled = true
DefaultOptimisticExecutionEnabled = false
DefaultVEOracleEnabled = true

DefaultOptimisticExecutionEnabled = false
DefaultOptimisticExecutionTestAbortRate = 0
)

// AddFlagsToCmd adds flags to app initialization.
Expand Down Expand Up @@ -152,6 +156,11 @@ func AddFlagsToCmd(cmd *cobra.Command) {
DefaultOptimisticExecutionEnabled,
"Whether to enable optimistic block execution",
)
cmd.Flags().Uint16(
OptimisticExecutionTestAbortRate,
DefaultOptimisticExecutionTestAbortRate,
"[Test only] Abort rate for optimistic execution",
)
}

// Validate checks that the flags are valid.
Expand Down Expand Up @@ -210,8 +219,9 @@ func GetFlagValuesFromOptions(
WebsocketStreamingPort: DefaultWebsocketStreamingPort,
FullNodeStreamingSnapshotInterval: DefaultFullNodeStreamingSnapshotInterval,

VEOracleEnabled: true,
OptimisticExecutionEnabled: DefaultOptimisticExecutionEnabled,
VEOracleEnabled: true,
OptimisticExecutionEnabled: DefaultOptimisticExecutionEnabled,
OptimisticExecutionTestAbortRate: DefaultOptimisticExecutionTestAbortRate,
}

// Populate the flags if they exist.
Expand Down Expand Up @@ -304,5 +314,11 @@ func GetFlagValuesFromOptions(
result.OptimisticExecutionEnabled = v
}
}

if option := appOpts.Get(OptimisticExecutionTestAbortRate); option != nil {
if v, err := cast.ToUint16E(option); err == nil {
result.OptimisticExecutionTestAbortRate = v
}
}
return result
}
Loading