mukan-ibc/modules/core/02-client/abci.go
Mukan Erkin Törük 88dd97a9f8
Some checks failed
CodeQL / Analyze (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:22 +03:00

35 lines
1.4 KiB
Go

package client
import (
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
"git.cw.tr/mukan-network/mukan-ibc/modules/core/02-client/keeper"
"git.cw.tr/mukan-network/mukan-ibc/modules/core/02-client/types"
ibctm "git.cw.tr/mukan-network/mukan-ibc/modules/light-clients/07-tendermint"
)
// BeginBlocker is used to perform IBC client upgrades
func BeginBlocker(ctx sdk.Context, k *keeper.Keeper) {
plan, err := k.GetUpgradePlan(ctx)
if err == nil {
// Once we are at the last block this chain will commit, set the upgraded consensus state
// so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
// headers on the next version of the chain.
// Set the time to the last block time of the current chain.
// In order for a client to upgrade successfully, the first block of the new chain must be committed
// within the trusting period of the last block time on this chain.
_, err := k.GetUpgradedClient(ctx, plan.Height)
if err == nil && ctx.BlockHeight() == plan.Height-1 {
upgradedConsState := &ibctm.ConsensusState{
Timestamp: ctx.BlockTime(),
NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
}
bz := types.MustMarshalConsensusState(k.Codec(), upgradedConsState)
// SetUpgradedConsensusState always returns nil, hence the blank here.
_ = k.SetUpgradedConsensusState(ctx, plan.Height, bz)
keeper.EmitUpgradeChainEvent(ctx, plan.Height)
}
}
}