-
Notifications
You must be signed in to change notification settings - Fork 887
fixed support for AllowEmptyBlocks = false for autobahn #3739
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
base: main
Are you sure you want to change the base?
Changes from all commits
1286e90
83ebfc9
3ae26f4
bea7c5c
0a3b50f
4b6e218
938076d
cb430dc
488d686
7d59c9b
c71cc3d
0e8f795
a83325d
60080e1
433c3da
70dc88c
155c338
269dfde
a649a1c
f93a5d5
c931ea9
c6f98c4
02ad2d8
eb4c28b
b5d3490
41dfedb
c088f11
3867df2
7543d79
5b44c29
65d4d7b
646608e
a519f9f
e70dd2e
e38febe
6c766e0
1d5e176
6575b1a
470d8e5
e5812ea
f6e7f28
f1554af
772b3cc
9920a5a
ca5a7a8
8e76c4d
3a94888
a24c628
453ca49
1f26888
f9f4654
809f5a7
caabca4
1b9a602
1993f43
3324da2
7959d12
cdcacc2
e7edda7
33562a1
9ba3d55
a3f6157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -476,11 +476,6 @@ type App struct { | |
|
|
||
| forkInitializer func(sdk.Context) | ||
|
|
||
| httpServerStartSignal chan struct{} | ||
| wsServerStartSignal chan struct{} | ||
| httpServerStartSignalSent bool | ||
| wsServerStartSignalSent bool | ||
|
|
||
| // evmHTTPServer/evmWSServer hold the EVM JSON-RPC HTTP and WebSocket listeners | ||
| // constructed in RegisterLocalServices so an embedding orchestrator (the | ||
| // in-process harness) can Stop() them at teardown. Nil when the respective | ||
|
|
@@ -539,21 +534,19 @@ func New( | |
| memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, banktypes.DeferredCacheStoreKey, oracletypes.MemStoreKey) | ||
|
|
||
| app := &App{ | ||
| BaseApp: bApp, | ||
| cdc: cdc, | ||
| appCodec: appCodec, | ||
| interfaceRegistry: interfaceRegistry, | ||
| keys: keys, | ||
| tkeys: tkeys, | ||
| memKeys: memKeys, | ||
| txDecoder: encodingConfig.TxConfig.TxDecoder(), | ||
| versionInfo: version.NewInfo(), | ||
| metricCounter: &map[string]float32{}, | ||
| encodingConfig: encodingConfig, | ||
| legacyEncodingConfig: MakeLegacyEncodingConfig(), | ||
| stateStore: stateStore, | ||
| httpServerStartSignal: make(chan struct{}, 1), | ||
| wsServerStartSignal: make(chan struct{}, 1), | ||
| BaseApp: bApp, | ||
| cdc: cdc, | ||
| appCodec: appCodec, | ||
| interfaceRegistry: interfaceRegistry, | ||
| keys: keys, | ||
| tkeys: tkeys, | ||
| memKeys: memKeys, | ||
| txDecoder: encodingConfig.TxConfig.TxDecoder(), | ||
| versionInfo: version.NewInfo(), | ||
| metricCounter: &map[string]float32{}, | ||
| encodingConfig: encodingConfig, | ||
| legacyEncodingConfig: MakeLegacyEncodingConfig(), | ||
| stateStore: stateStore, | ||
| } | ||
|
|
||
| for _, option := range appOptions { | ||
|
|
@@ -1946,17 +1939,6 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req *BlockProcessReq | |
| } | ||
| }() | ||
|
|
||
| defer func() { | ||
| if !app.httpServerStartSignalSent { | ||
| app.httpServerStartSignalSent = true | ||
| app.httpServerStartSignal <- struct{}{} | ||
| } | ||
| if !app.wsServerStartSignalSent { | ||
| app.wsServerStartSignalSent = true | ||
| app.wsServerStartSignal <- struct{}{} | ||
| } | ||
| }() | ||
|
|
||
| ctx = ctx.WithIsOCCEnabled(app.OccEnabled()) | ||
|
|
||
| blockSpanCtx, blockSpan := app.GetBaseApp().TracingInfo.Start("Block") | ||
|
|
@@ -2061,13 +2043,17 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, msg *evmtypes.MsgE | |
| }, nil | ||
| } | ||
|
|
||
| // Prepare context for EVM transaction (set infinite gas meter like original flow) | ||
| ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx)) | ||
|
|
||
| _, isAssociated := app.GigaEvmKeeper.GetEVMAddress(ctx, seiAddr) | ||
|
|
||
| // Run validation checks (fee/nonce/balance - stateless checks done earlier) | ||
| validation := app.validateGigaEVMTx(ctx, ethTx, sender, seiAddr, isAssociated) | ||
| // Create state DB before validation so balance checks use DBImpl hooks. | ||
| stateDB := gigaevmstate.NewDBImpl(ctx, &app.GigaEvmKeeper, false) | ||
| defer stateDB.Cleanup() | ||
|
|
||
| // Prepare context for EVM transaction (set infinite gas meter like original flow) | ||
| ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx)) | ||
| // Run validation checks (fee/nonce/balance - stateless checks done earlier) | ||
| validation := app.validateGigaEVMTx(ctx, stateDB, ethTx, sender, seiAddr, isAssociated) | ||
|
|
||
| if validation.err != nil { | ||
| // v2 rejects fee/nonce/balance failures in its ante chain, whose | ||
|
|
@@ -2092,10 +2078,6 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, msg *evmtypes.MsgE | |
| return nil, gigaprecompiles.ErrBalanceMigrationRequired | ||
| } | ||
|
|
||
| // Create state DB for this transaction (only for valid transactions) | ||
| stateDB := gigaevmstate.NewDBImpl(ctx, &app.GigaEvmKeeper, false) | ||
| defer stateDB.Cleanup() | ||
|
|
||
| // Pre-charge gas fee (like V2's ante handler), then execute with feeAlreadyCharged=true. | ||
| // V2 charges fees in the ante handler, then runs the EVM with feeAlreadyCharged=true | ||
| // which skips buyGas/refundGas/coinbase. Without this, GasUsed differs between Giga | ||
|
|
@@ -2640,19 +2622,7 @@ func (app *App) LegacyAmino() *codec.LegacyAmino { | |
| } | ||
|
|
||
| func (app *App) GetValidators() []abci.ValidatorUpdate { | ||
| // AUTOBAHN: After InitChain but before the first Commit, the committed | ||
| // store is empty — staking params don't exist, so reading from committed | ||
| // store panics in MaxValidators. Use DeliverContext when available at | ||
| // height 0, since it has the uncommitted staking state from InitChain. | ||
| // CometBFT consensus never hits this because its handshaker commits | ||
| // after InitChain before any block processing begins. | ||
| if app.LastBlockHeight() == 0 { | ||
| if dctx := app.DeliverContext(); dctx != nil { | ||
| return app.StakingKeeper.GetBondedValidators(*dctx) | ||
| } | ||
| } | ||
| ctx := app.NewUncachedContext(false, tmproto.Header{Height: max(app.LastBlockHeight(), 1)}) | ||
| return app.StakingKeeper.GetBondedValidators(ctx) | ||
| return app.StakingKeeper.GetBondedValidators(app.GetCheckCtx()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validators read raced check stateMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 809f5a7. Configure here. |
||
| } | ||
|
|
||
| // AppCodec returns an app codec. | ||
|
|
@@ -2811,7 +2781,7 @@ func (app *App) RegisterLocalServices(node client.LocalClient, txConfig client.T | |
| } | ||
| app.evmHTTPServer = evmHTTPServer | ||
| go func() { | ||
| <-app.httpServerStartSignal | ||
| <-app.Initialized() | ||
| if err := evmHTTPServer.Start(); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
@@ -2826,7 +2796,7 @@ func (app *App) RegisterLocalServices(node client.LocalClient, txConfig client.T | |
| } | ||
| app.evmWSServer = evmWSServer | ||
| go func() { | ||
| <-app.wsServerStartSignal | ||
| <-app.Initialized() | ||
| if err := evmWSServer.Start(); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
@@ -3085,6 +3055,7 @@ type gigaValidationResult struct { | |
| // 7. Balance check | ||
| func (app *App) validateGigaEVMTx( | ||
| ctx sdk.Context, | ||
| stateDB *gigaevmstate.DBImpl, | ||
| ethTx *ethtypes.Transaction, | ||
| sender common.Address, | ||
| seiAddr sdk.AccAddress, | ||
|
|
@@ -3235,13 +3206,17 @@ func (app *App) validateGigaEVMTx( | |
| balanceCheck := new(big.Int).Mul(new(big.Int).SetUint64(ethTx.Gas()), ethTx.GasFeeCap()) | ||
| balanceCheck.Add(balanceCheck, ethTx.Value()) | ||
|
|
||
| senderBalance := app.GigaEvmKeeper.GetBalance(ctx, seiAddr) | ||
| // Route validation balance reads through DBImpl so mock_balances follows | ||
| // the same ensureMinimumBalance behavior as V2's StateTransition.BuyGas. | ||
| senderBalance := stateDB.GetBalance(sender).ToBig() | ||
|
|
||
| // Include cast address balance for unassociated addresses (matches V2 PreprocessDecorator) | ||
| // Include the derived Sei address balance for unassociated addresses (matches V2 PreprocessDecorator). | ||
| if !isAssociated { | ||
| castAddr := sdk.AccAddress(sender[:]) | ||
| castBalance := app.GigaEvmKeeper.GetBalance(ctx, castAddr) | ||
| senderBalance = new(big.Int).Add(senderBalance, castBalance) | ||
| seiEVMAddr := common.BytesToAddress(seiAddr) | ||
| if seiEVMAddr != sender { | ||
| seiBalance := stateDB.GetBalance(seiEVMAddr).ToBig() | ||
| senderBalance = new(big.Int).Add(senderBalance, seiBalance) | ||
| } | ||
| } | ||
|
|
||
| if senderBalance.Cmp(balanceCheck) < 0 { | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Genesis gentx ante checks incomplete
High Severity
SetGasMeterandCheckSignaturesdropped the height-0 genesis special cases without switching toctx.IsGenesis(), unlikeGetGasMeterSetterand the classicSigVerificationDecorator.InitChainnow delivers gentxs on anIsGenesiscontext throughCosmosDeliverTxAnte, so gentxs signed with account number 0 can fail signature verification and lose infinite-gas genesis metering.Additional Locations (1)
app/ante/cosmos_checktx.go#L446-L453Reviewed by Cursor Bugbot for commit 7959d12. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmos_checktx.go does not belong to the initChainer path. It does not need the special case.