mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 03:51:20 +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>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package heimdallgrpc
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
|
|
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/checkpoint"
|
|
|
|
proto "github.com/maticnetwork/polyproto/heimdall"
|
|
protoutils "github.com/maticnetwork/polyproto/utils"
|
|
)
|
|
|
|
func (h *HeimdallGRPCClient) FetchCheckpointCount(ctx context.Context) (int64, error) {
|
|
h.logger.Info("Fetching checkpoint count")
|
|
|
|
res, err := h.client.FetchCheckpointCount(ctx, nil)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
h.logger.Info("Fetched checkpoint count")
|
|
|
|
return res.Result.Result, nil
|
|
}
|
|
|
|
func (h *HeimdallGRPCClient) FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) {
|
|
req := &proto.FetchCheckpointRequest{
|
|
ID: number,
|
|
}
|
|
|
|
h.logger.Info("Fetching checkpoint", "number", number)
|
|
|
|
res, err := h.client.FetchCheckpoint(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
h.logger.Info("Fetched checkpoint", "number", number)
|
|
|
|
checkpoint := &checkpoint.Checkpoint{
|
|
StartBlock: new(big.Int).SetUint64(res.Result.StartBlock),
|
|
EndBlock: new(big.Int).SetUint64(res.Result.EndBlock),
|
|
RootHash: protoutils.ConvertH256ToHash(res.Result.RootHash),
|
|
Proposer: protoutils.ConvertH160toAddress(res.Result.Proposer),
|
|
BorChainID: res.Result.BorChainID,
|
|
Timestamp: uint64(res.Result.Timestamp.GetSeconds()),
|
|
}
|
|
|
|
return checkpoint, nil
|
|
}
|