mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 02:24:29 +00:00
529d359ca6
An update to the devnet to introduce a local heimdall to facilitate multiple validators without the need for an external process, and hence validator registration/staking etc. In this initial release only span generation is supported. It has the following changes: * Introduction of a local grpc heimdall interface * Allocation of accounts via a devnet account generator () * Introduction on 'Services' for the network config "--chain bor-devnet --bor.localheimdall" will run a 2 validator network with a local service "--chain bor-devnet --bor.withoutheimdall" will sun a single validator with no heimdall service as before --------- Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package heimdallgrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/span"
|
|
"github.com/ledgerwatch/erigon/consensus/bor/valset"
|
|
|
|
proto "github.com/maticnetwork/polyproto/heimdall"
|
|
protoutils "github.com/maticnetwork/polyproto/utils"
|
|
)
|
|
|
|
func (h *HeimdallGRPCClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) {
|
|
req := &proto.SpanRequest{
|
|
ID: spanID,
|
|
}
|
|
|
|
h.logger.Info("Fetching span", "spanID", spanID)
|
|
|
|
res, err := h.client.Span(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
h.logger.Info("Fetched span", "spanID", spanID)
|
|
|
|
return parseSpan(res.Result), nil
|
|
}
|
|
|
|
func parseSpan(protoSpan *proto.Span) *span.HeimdallSpan {
|
|
resp := &span.HeimdallSpan{
|
|
Span: span.Span{
|
|
ID: protoSpan.ID,
|
|
StartBlock: protoSpan.StartBlock,
|
|
EndBlock: protoSpan.EndBlock,
|
|
},
|
|
ValidatorSet: valset.ValidatorSet{},
|
|
SelectedProducers: []valset.Validator{},
|
|
ChainID: protoSpan.ChainID,
|
|
}
|
|
|
|
for _, validator := range protoSpan.ValidatorSet.Validators {
|
|
resp.ValidatorSet.Validators = append(resp.ValidatorSet.Validators, parseValidator(validator))
|
|
}
|
|
|
|
resp.ValidatorSet.Proposer = parseValidator(protoSpan.ValidatorSet.Proposer)
|
|
|
|
for _, validator := range protoSpan.SelectedProducers {
|
|
resp.SelectedProducers = append(resp.SelectedProducers, *parseValidator(validator))
|
|
}
|
|
|
|
return resp
|
|
}
|
|
|
|
func parseValidator(validator *proto.Validator) *valset.Validator {
|
|
return &valset.Validator{
|
|
ID: validator.ID,
|
|
Address: protoutils.ConvertH160toAddress(validator.Address),
|
|
VotingPower: validator.VotingPower,
|
|
ProposerPriority: validator.ProposerPriority,
|
|
}
|
|
}
|