mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
fix: quorum
This commit is contained in:
parent
93cceff23c
commit
e3e47e5e2f
@ -29,13 +29,14 @@ const (
|
||||
)
|
||||
|
||||
var RequiredGasBasic = map[string]uint64{
|
||||
"epochNumber": 1000,
|
||||
"getSigner": 10000,
|
||||
"getSigners": 1000000,
|
||||
"updateSocket": 50000,
|
||||
"registerNextEpoch": 100000,
|
||||
"registerSigner": 100000,
|
||||
"getAggPkG1": 1000000,
|
||||
DASignersFunctionEpochNumber: 1000,
|
||||
DASignersFunctionQuorumCount: 1000,
|
||||
DASignersFunctionGetSigner: 100000,
|
||||
DASignersFunctionGetQuorum: 100000,
|
||||
DASignersFunctionRegisterSigner: 100000,
|
||||
DASignersFunctionUpdateSocket: 50000,
|
||||
DASignersFunctionRegisterNextEpoch: 100000,
|
||||
DASignersFunctionGetAggPkG1: 1000000,
|
||||
}
|
||||
|
||||
var KVGasConfig storetypes.GasConfig = storetypes.GasConfig{
|
||||
|
@ -86,7 +86,7 @@ func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
||||
}
|
||||
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||
}
|
||||
} else {
|
||||
} else if len(ballots) > 0 {
|
||||
quorum := types.Quorum{
|
||||
Signers: make([]string, params.EncodedSlices),
|
||||
}
|
||||
@ -95,6 +95,10 @@ func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
||||
quorum.Signers[i] = ballots[i%n].account
|
||||
}
|
||||
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||
} else {
|
||||
quorums.Quorums = append(quorums.Quorums, &types.Quorum{
|
||||
Signers: make([]string, 0),
|
||||
})
|
||||
}
|
||||
|
||||
// save to store
|
||||
|
@ -84,13 +84,15 @@ func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggrega
|
||||
hit := 0
|
||||
added := make(map[string]struct{})
|
||||
for i, signer := range quorum.Signers {
|
||||
if _, ok := added[signer]; ok {
|
||||
hit += 1
|
||||
continue
|
||||
}
|
||||
b := request.QuorumBitmap[i/8] & (1 << (i % 8))
|
||||
if b == 0 {
|
||||
continue
|
||||
}
|
||||
if _, ok := added[signer]; ok {
|
||||
continue
|
||||
}
|
||||
hit += 1
|
||||
added[signer] = struct{}{}
|
||||
signer, found, err := k.GetSigner(ctx, signer)
|
||||
if err != nil {
|
||||
@ -99,7 +101,6 @@ func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggrega
|
||||
if !found {
|
||||
return nil, types.ErrSignerNotFound
|
||||
}
|
||||
hit += 1
|
||||
aggPubkeyG1.Add(aggPubkeyG1, bn254util.DeserializeG1(signer.PubkeyG1))
|
||||
}
|
||||
return &types.QueryAggregatePubkeyG1Response{
|
||||
|
@ -9,5 +9,5 @@ var (
|
||||
ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature")
|
||||
ErrQuorumNotFound = errorsmod.Register(ModuleName, 5, "quorum for epoch not found")
|
||||
ErrQuorumIdOutOfBound = errorsmod.Register(ModuleName, 6, "quorum id out of bound")
|
||||
ErrQuorumBitmapLengthMismatch = errorsmod.Register(ModuleName, 6, "quorum bitmap length mismatch")
|
||||
ErrQuorumBitmapLengthMismatch = errorsmod.Register(ModuleName, 7, "quorum bitmap length mismatch")
|
||||
)
|
||||
|
@ -19,7 +19,9 @@ func DefaultGenesisState() *GenesisState {
|
||||
MaxVotes: 100,
|
||||
EpochBlocks: 1000,
|
||||
EncodedSlices: 3072,
|
||||
}, 0, make([]*Signer, 0), make([]*Quorums, 0))
|
||||
}, 0, make([]*Signer, 0), []*Quorums{{
|
||||
Quorums: make([]*Quorum, 0),
|
||||
}})
|
||||
}
|
||||
|
||||
// Validate performs basic validation of genesis data.
|
||||
@ -31,7 +33,7 @@ func (gs GenesisState) Validate() error {
|
||||
}
|
||||
registered[signer.Account] = struct{}{}
|
||||
}
|
||||
if len(gs.QuorumsByEpoch) != int(gs.EpochNumber) {
|
||||
if len(gs.QuorumsByEpoch) != int(gs.EpochNumber)+1 {
|
||||
return fmt.Errorf("epoch history missing")
|
||||
}
|
||||
for _, quorums := range gs.QuorumsByEpoch {
|
||||
|
Loading…
Reference in New Issue
Block a user