diff --git a/consensus/istanbul/backend/engine_test.go b/consensus/istanbul/backend/engine_test.go index fd9b86066..5336617d8 100644 --- a/consensus/istanbul/backend/engine_test.go +++ b/consensus/istanbul/backend/engine_test.go @@ -1186,25 +1186,25 @@ func Test_BasedOnStaking(t *testing.T) { []int{}, }, { - []uint64{5000000, 5000000, 5000000, 6000000}, + []uint64{6000000, 5000000, 5000000, 5000000}, true, false, - []int{3}, - []int{0, 1, 2}, + []int{0}, + []int{1, 2, 3}, }, { - []uint64{5000000, 5000000, 6000000, 6000000}, + []uint64{6000000, 5000000, 5000000, 6000000}, true, false, - []int{2, 3}, - []int{0, 1}, + []int{0, 3}, + []int{1, 2}, }, { - []uint64{5000000, 6000000, 6000000, 6000000}, + []uint64{6000000, 5000000, 6000000, 6000000}, true, false, - []int{1, 2, 3}, - []int{0}, + []int{0, 2, 3}, + []int{1}, }, { []uint64{6000000, 6000000, 6000000, 6000000}, diff --git a/consensus/istanbul/validator.go b/consensus/istanbul/validator.go index 852c7fff5..0a8e47ddb 100644 --- a/consensus/istanbul/validator.go +++ b/consensus/istanbul/validator.go @@ -144,12 +144,14 @@ func NewBlockValSet(council, qualified valset.AddressList) *BlockValSet { func (cs *BlockValSet) Council() valset.AddressList { return cs.council } func (cs *BlockValSet) Qualified() valset.AddressList { return cs.qualified } func (cs *BlockValSet) Demoted() valset.AddressList { return cs.demoted } -func (cs *BlockValSet) IsQualifiedMember(addr common.Address) bool { - return cs.qualified.GetIdxByAddress(addr) >= 0 -} func (cs *BlockValSet) IsCouncilMember(addr common.Address) bool { return cs.council.GetIdxByAddress(addr) >= 0 } + +func (cs *BlockValSet) IsQualifiedMember(addr common.Address) bool { + return cs.qualified.GetIdxByAddress(addr) >= 0 +} + func (cs *BlockValSet) CheckValidatorSignature(data []byte, sig []byte) (common.Address, error) { // 1. Get signature address signer, err := GetSignatureAddress(data, sig) @@ -182,11 +184,11 @@ func (cs *RoundCommitteeState) Committee() valset.AddressList { return cs.commit func (cs *RoundCommitteeState) NonCommittee() valset.AddressList { return cs.qualified.Subtract(cs.committee) } -func (cs *RoundCommitteeState) Proposer() common.Address { return cs.proposer } +func (cs *RoundCommitteeState) Proposer() common.Address { return cs.proposer } +func (cs *RoundCommitteeState) IsProposer(addr common.Address) bool { return cs.proposer == addr } func (cs *RoundCommitteeState) IsCommitteeMember(addr common.Address) bool { return cs.committee.GetIdxByAddress(addr) >= 0 } -func (cs *RoundCommitteeState) IsProposer(addr common.Address) bool { return cs.proposer == addr } // RequiredMessageCount returns a minimum required number of consensus messages to proceed func (cs *RoundCommitteeState) RequiredMessageCount() int { diff --git a/kaiax/valset/addressList.go b/kaiax/valset/addressList.go index 00edfaae6..b6a5320cd 100644 --- a/kaiax/valset/addressList.go +++ b/kaiax/valset/addressList.go @@ -41,7 +41,7 @@ func (sc *AddressList) Remove(addr common.Address) bool { } func (sc AddressList) Copy() AddressList { - var copied AddressList + copied := make(AddressList, 0) for _, val := range sc { copied = append(copied, val) } diff --git a/tests/hard_fork_test.go b/tests/hard_fork_test.go index fed40674b..129fb7e9e 100644 --- a/tests/hard_fork_test.go +++ b/tests/hard_fork_test.go @@ -23,7 +23,6 @@ import ( "encoding/json" "errors" "fmt" - valset_impl "github.com/kaiachain/kaia/kaiax/valset/impl" "math/big" "os" "strings" @@ -43,6 +42,7 @@ import ( gov_impl "github.com/kaiachain/kaia/kaiax/gov/impl" reward_impl "github.com/kaiachain/kaia/kaiax/reward/impl" staking_impl "github.com/kaiachain/kaia/kaiax/staking/impl" + valset_impl "github.com/kaiachain/kaia/kaiax/valset/impl" "github.com/kaiachain/kaia/log" "github.com/kaiachain/kaia/params" "github.com/kaiachain/kaia/rlp" diff --git a/tests/init.go b/tests/init.go index ac452abfa..9edaf3536 100644 --- a/tests/init.go +++ b/tests/init.go @@ -94,9 +94,8 @@ var Forks = map[string]*params.ChainConfig{ Kip103CompatibleBlock: new(big.Int), ShanghaiCompatibleBlock: new(big.Int), CancunCompatibleBlock: new(big.Int), - //RandaoCompatibleBlock: new(big.Int), - KaiaCompatibleBlock: new(big.Int), - Kip160CompatibleBlock: new(big.Int), + KaiaCompatibleBlock: new(big.Int), + Kip160CompatibleBlock: new(big.Int), }, "Prague": { ChainID: big.NewInt(1), @@ -108,10 +107,9 @@ var Forks = map[string]*params.ChainConfig{ Kip103CompatibleBlock: new(big.Int), ShanghaiCompatibleBlock: new(big.Int), CancunCompatibleBlock: new(big.Int), - //RandaoCompatibleBlock: new(big.Int), - KaiaCompatibleBlock: new(big.Int), - Kip160CompatibleBlock: new(big.Int), - PragueCompatibleBlock: new(big.Int), + KaiaCompatibleBlock: new(big.Int), + Kip160CompatibleBlock: new(big.Int), + PragueCompatibleBlock: new(big.Int), }, } diff --git a/tests/tx_validation_test.go b/tests/tx_validation_test.go index a8d110367..ff6c10aa4 100644 --- a/tests/tx_validation_test.go +++ b/tests/tx_validation_test.go @@ -976,7 +976,7 @@ func TestInvalidBalance(t *testing.T) { prof := profile.NewProfiler() // Initialize blockchain - bcdata, err := NewBCData(6, 4) + bcdata, err := NewBCDataWithForkConfig(6, 4, Forks["Prague"]) if err != nil { t.Fatal(err) } @@ -1370,7 +1370,7 @@ func TestInvalidBalanceBlockTx(t *testing.T) { prof := profile.NewProfiler() // Initialize blockchain - bcdata, err := NewBCData(6, 4) + bcdata, err := NewBCDataWithForkConfig(6, 4, Forks["Prague"]) if err != nil { t.Fatal(err) }