Skip to content
Open
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
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,8 @@ func New(

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)
stakingHooks := stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks())
app.StakingKeeper = *stakingKeeper.SetHooks(&stakingHooks)

// ... other modules keepers

Expand Down Expand Up @@ -806,6 +805,7 @@ func New(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, app.ParamsKeeper, govRouter,
)
stakingHooks.AddHooks(app.GovKeeper.StakingHooks())

// this line is used by starport scaffolding # stargate/app/keeperDefinition

Expand Down Expand Up @@ -848,6 +848,7 @@ func New(
DistrKeeper: &app.DistrKeeper,
SlashingKeeper: &app.SlashingKeeper,
EvidenceKeeper: &app.EvidenceKeeper,
GovKeeper: &app.GovKeeper,
StakingKeeper: &app.StakingKeeper,
EvmKeeper: &app.EvmKeeper,
}
Expand Down
6 changes: 6 additions & 0 deletions app/legacyabci/begin_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/sei-protocol/sei-chain/sei-cosmos/x/evidence"
evidencekeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/evidence/keeper"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/gov"
govkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/gov/keeper"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/slashing"
slashingkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/slashing/keeper"

Expand All @@ -30,6 +32,7 @@ type BeginBlockKeepers struct {
DistrKeeper *distrkeeper.Keeper
SlashingKeeper *slashingkeeper.Keeper
EvidenceKeeper *evidencekeeper.Keeper
GovKeeper *govkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
EvmKeeper *evmkeeper.Keeper
}
Expand All @@ -48,6 +51,9 @@ func BeginBlock(
telemetry.MeasureSince(start, "module", "total_begin_block")
}()

if keepers.GovKeeper != nil {
gov.BeginBlocker(ctx, *keepers.GovKeeper)
}
keepers.EpochKeeper.BeginBlock(ctx)
upgrade.BeginBlocker(*keepers.UpgradeKeeper, ctx)
distribution.BeginBlocker(ctx, votes, *keepers.DistrKeeper)
Expand Down
16 changes: 16 additions & 0 deletions evmrpc/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package evmrpc

import (
"context"
"errors"
"math/big"
"sync"

Expand All @@ -18,6 +19,21 @@ import (
"github.com/sei-protocol/sei-chain/x/evm/keeper"
)

// HoldSimulationSlotsForTest occupies simulation request slots until the returned function is called.
func (s *SimulationAPI) HoldSimulationSlotsForTest(ctx context.Context, slots int64) (func(), error) {
if s.requestLimiter == nil {
return nil, errors.New("simulation request limiter is disabled")
}
if slots <= 0 {
return nil, errors.New("simulation slot count must be positive")
}
if err := s.requestLimiter.Acquire(ctx, slots); err != nil {
return nil, err
}

return func() { s.requestLimiter.Release(slots) }, nil
}

// RangeQueryWindowBlocksForTest exposes rangeQueryWindowBlocks so integration
// tests can assert tryFilterLogsRange's window boundaries without hardcoding
// the constant.
Expand Down
23 changes: 23 additions & 0 deletions evmrpc/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/sei-protocol/sei-chain/sei-cosmos/baseapp"
"github.com/sei-protocol/sei-chain/sei-cosmos/client"
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
govkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/gov/keeper"
abci "github.com/sei-protocol/sei-chain/sei-tendermint/abci/types"
"github.com/sei-protocol/sei-chain/sei-tendermint/rpc/coretypes"
tmtypes "github.com/sei-protocol/sei-chain/sei-tendermint/types"
Expand Down Expand Up @@ -312,6 +313,11 @@ func (b *Backend) isV67ActiveAtHeight(height int64) bool {
return b.keeper.UpgradeKeeper().IsUpgradeActiveAtHeight(ctx, "v6.7", height)
}

func (b *Backend) isV68ActiveAtHeight(height int64) bool {
ctx := b.ctxProvider(LatestCtxHeight).WithGasMeter(sdk.NewInfiniteGasMeter(1, 1))
return b.keeper.UpgradeKeeper().IsUpgradeActiveAtHeight(ctx, "v6.8", height)
}

func (b *Backend) SetTraceContextProvider(provider TraceContextProvider) {
if provider != nil {
b.traceCtxProvider = provider
Expand Down Expand Up @@ -734,6 +740,10 @@ func (b *Backend) initializeBlock(ctx context.Context, block *ethtypes.Block, ct
// iteration can pass it into the SS MVCC skip loops.
sdkCtx = sdkCtx.WithContext(ctx)
}
if err := b.activateIncrementalTallyForTrace(sdkCtx, blockNumber); err != nil {
release()
return sdk.Context{}, nil, emptyRelease, fmt.Errorf("activate incremental governance tally: %w", err)
}
runTraceBeginBlock(sdkCtx, blockNumber, reqBeginBlock.LastCommitInfo.Votes, tmBlock.Block.Evidence.ToABCI(), b.beginBlockKeepers)
var nextCtx sdk.Context
nextCtx, nextRelease = ctxProvider(sdkCtx.BlockHeight())
Expand All @@ -744,6 +754,19 @@ func (b *Backend) initializeBlock(ctx context.Context, block *ethtypes.Block, ct
return sdkCtx, tmBlock, release, nil
}

func (b *Backend) activateIncrementalTallyForTrace(ctx sdk.Context, height int64) error {
if b.keeper == nil || b.beginBlockKeepers.GovKeeper == nil {
return nil
}
govKeeper := *b.beginBlockKeepers.GovKeeper
if govKeeper.IncrementalTallyEnabled(ctx) ||
!b.isV68ActiveAtHeight(height) ||
b.isV68ActiveAtHeight(height-1) {
return nil
}
return govkeeper.NewMigrator(govKeeper).Migrate3to4(ctx)
}

// runTraceBeginBlock is the BeginBlock used when reconstructing historical
// state for traces.
var runTraceBeginBlock = legacyabci.BeginBlock
Expand Down
Loading
Loading