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