Skip to content

Commit

Permalink
add valsetModule engine at SetupKaiaxModules
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomee1313 committed Dec 19, 2024
1 parent eec259c commit 3fdc1b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 0 additions & 5 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2151,11 +2151,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
}
}

// update governance CurrentSet if it is at an epoch block
if bc.engine.CreateSnapshot(bc, block.NumberU64(), block.Hash(), nil) != nil {
return i, events, coalescedLogs, err
}

// update governance parameters
if istanbul, ok := bc.engine.(consensus.Istanbul); ok {
if err = istanbul.UpdateParam(block.NumberU64()); err != nil {
Expand Down
16 changes: 13 additions & 3 deletions node/cn/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/kaiachain/kaia/kaiax/staking"
staking_impl "github.com/kaiachain/kaia/kaiax/staking/impl"
supply_impl "github.com/kaiachain/kaia/kaiax/supply/impl"
valset_impl "github.com/kaiachain/kaia/kaiax/valset/impl"
"github.com/kaiachain/kaia/networks/p2p"
"github.com/kaiachain/kaia/networks/rpc"
"github.com/kaiachain/kaia/node"
Expand Down Expand Up @@ -538,6 +539,7 @@ func (s *CN) SetupKaiaxModules() error {
mReward = reward_impl.NewRewardModule()
mSupply = supply_impl.NewSupplyModule()
mGov = gov_impl.NewGovModule()
mValset = valset_impl.NewValsetModule()
)

// Initialize modules
Expand Down Expand Up @@ -565,19 +567,27 @@ func (s *CN) SetupKaiaxModules() error {
Chain: s.blockchain,
NodeAddress: s.nodeAddress,
}),
mValset.Init(&valset_impl.InitOpts{
ChainKv: s.chainDB.GetMiscDB(),
Chain: s.blockchain,
Governance: mGov,
StakingInfo: mStaking,
NodeAddress: s.nodeAddress,
}),
)
if err != nil {
return err
}

// Register modules to respective components
// TODO-kaiax: Organize below lines.
s.RegisterBaseModules(mStaking, mReward, mSupply, mGov)
s.RegisterBaseModules(mStaking, mReward, mSupply, mGov, mValset)
s.RegisterJsonRpcModules(mStaking, mReward, mSupply, mGov)
s.miner.RegisterExecutionModule(mStaking, mSupply, mGov)
s.blockchain.RegisterExecutionModule(mSupply, mGov)
s.blockchain.RegisterRewindableModule(mStaking, mSupply, mGov)
s.blockchain.RegisterExecutionModule(mSupply, mGov, mValset)
s.blockchain.RegisterRewindableModule(mStaking, mSupply, mGov, mValset)
if engine, ok := s.engine.(consensus.Istanbul); ok {
engine.RegisterValsetModule(mValset)
engine.RegisterStakingModule(mStaking)
engine.RegisterConsensusModule(mReward, mGov)
}
Expand Down

0 comments on commit 3fdc1b1

Please sign in to comment.