Skip to content

Commit

Permalink
Merge branch 'e35' into e35_mainnet_bodies_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Jan 5, 2024
2 parents b43995d + acd9a9a commit 4c0534e
Show file tree
Hide file tree
Showing 39 changed files with 1,017 additions and 401 deletions.
24 changes: 13 additions & 11 deletions cl/beacon/validatorapi/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ func (v *ValidatorApiHandler) GetEthV1NodeSyncing(w http.ResponseWriter, r *http
}

return map[string]any{
"head_slot": strconv.FormatUint(slot, 10),
"sync_distance": syncDistance,
"is_syncing": isSyncing,
"el_offline": elOffline,
// TODO: figure out how to populat this field
"is_optimistic": true,
}, nil
"data": map[string]any{
"head_slot": strconv.FormatUint(slot, 10),
"sync_distance": syncDistance,
"is_syncing": isSyncing,
"el_offline": elOffline,
// TODO: figure out how to populat this field
"is_optimistic": true,
}}, nil
}

func (v *ValidatorApiHandler) GetEthV1ConfigSpec(w http.ResponseWriter, r *http.Request) (*clparams.BeaconChainConfig, error) {
Expand All @@ -67,10 +68,11 @@ func (v *ValidatorApiHandler) GetEthV1BeaconGenesis(w http.ResponseWriter, r *ht
return nil, beaconhttp.NewEndpointError(http.StatusInternalServerError, err.Error())
}
return map[string]any{
"genesis_time": v.GenesisCfg.GenesisTime,
"genesis_validator_root": v.GenesisCfg.GenesisValidatorRoot,
"genesis_fork_version": hexutility.Bytes(digest[:]),
}, nil
"data": map[string]any{
"genesis_time": v.GenesisCfg.GenesisTime,
"genesis_validator_root": v.GenesisCfg.GenesisValidatorRoot,
"genesis_fork_version": hexutility.Bytes(digest[:]),
}}, nil
}

func (v *ValidatorApiHandler) GetEthV1BeaconStatesStateIdFork(w http.ResponseWriter, r *http.Request) (any, error) {
Expand Down
7 changes: 5 additions & 2 deletions cmd/devnet/networks/devnet_bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package networks
import (
"time"

"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon-lib/chain/networkname"
"github.com/ledgerwatch/erigon/cmd/devnet/accounts"
"github.com/ledgerwatch/erigon/cmd/devnet/args"
"github.com/ledgerwatch/erigon/cmd/devnet/devnet"
account_services "github.com/ledgerwatch/erigon/cmd/devnet/services/accounts"
"github.com/ledgerwatch/erigon/cmd/devnet/services/polygon"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/consensus/bor/borcfg"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
)

func NewBorDevnetWithoutHeimdall(
Expand Down Expand Up @@ -190,8 +192,9 @@ func NewBorDevnetWithLocalHeimdall(
logger log.Logger,
) devnet.Devnet {
config := *params.BorDevnetChainConfig
borConfig := config.Bor.(*borcfg.BorConfig)
if sprintSize > 0 {
config.Bor.Sprint = map[string]uint64{"0": sprintSize}
borConfig.Sprint = map[string]uint64{"0": sprintSize}
}

checkpointOwner := accounts.NewAccount("checkpoint-owner")
Expand Down
9 changes: 6 additions & 3 deletions cmd/devnet/services/polygon/heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/ledgerwatch/erigon/cmd/devnet/blocks"
"github.com/ledgerwatch/erigon/cmd/devnet/contracts"
"github.com/ledgerwatch/erigon/cmd/devnet/devnet"
"github.com/ledgerwatch/erigon/consensus/bor/borcfg"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/checkpoint"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/milestone"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/span"
Expand Down Expand Up @@ -68,6 +69,7 @@ type CheckpointConfig struct {
type Heimdall struct {
sync.Mutex
chainConfig *chain.Config
borConfig *borcfg.BorConfig
grpcAddr string
validatorSet *valset.ValidatorSet
pendingCheckpoint *checkpoint.Checkpoint
Expand Down Expand Up @@ -97,6 +99,7 @@ func NewHeimdall(
) *Heimdall {
heimdall := &Heimdall{
chainConfig: chainConfig,
borConfig: chainConfig.Bor.(*borcfg.BorConfig),
grpcAddr: grpcAddr,
checkpointConfig: *checkpointConfig,
spans: map[uint64]*span.HeimdallSpan{},
Expand Down Expand Up @@ -159,7 +162,7 @@ func (h *Heimdall) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan,
nextSpan.StartBlock = h.currentSpan.EndBlock + 1
}

nextSpan.EndBlock = nextSpan.StartBlock + (100 * h.chainConfig.Bor.CalculateSprint(nextSpan.StartBlock)) - 1
nextSpan.EndBlock = nextSpan.StartBlock + (100 * h.borConfig.CalculateSprintLength(nextSpan.StartBlock)) - 1

// TODO we should use a subset here - see: https://wiki.polygon.technology/docs/pos/bor/

Expand All @@ -183,10 +186,10 @@ func (h *Heimdall) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan,

func (h *Heimdall) currentSprintLength() int {
if h.currentSpan != nil {
return int(h.chainConfig.Bor.CalculateSprint(h.currentSpan.StartBlock))
return int(h.borConfig.CalculateSprintLength(h.currentSpan.StartBlock))
}

return int(h.chainConfig.Bor.CalculateSprint(256))
return int(h.borConfig.CalculateSprintLength(256))
}

func (h *Heimdall) getSpanOverrideHeight() uint64 {
Expand Down
22 changes: 14 additions & 8 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
libstate "github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/bor/borcfg"
"github.com/ledgerwatch/erigon/consensus/bor/contract"
"github.com/ledgerwatch/erigon/consensus/bor/heimdall/span"
"github.com/ledgerwatch/erigon/consensus/ethash"
Expand All @@ -36,6 +37,13 @@ import (
"github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/snap"

"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
"golang.org/x/sync/semaphore"
"google.golang.org/grpc"
grpcHealth "google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/ledgerwatch/erigon-lib/direct"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon-lib/gointerfaces/grpcutil"
Expand All @@ -46,12 +54,6 @@ import (
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
"github.com/ledgerwatch/erigon-lib/kv/remotedb"
"github.com/ledgerwatch/erigon-lib/kv/remotedbserver"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
"golang.org/x/sync/semaphore"
"google.golang.org/grpc"
grpcHealth "google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli/httpcfg"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/graphql"
Expand Down Expand Up @@ -504,9 +506,11 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
}
// Skip the compatibility check, until we have a schema in erigon-lib

borConfig := cc.Bor.(*borcfg.BorConfig)

engine = bor.NewRo(cc, borKv, blockReader,
span.NewChainSpanner(contract.ValidatorSet(), cc, true, logger),
contract.NewGenesisContractsClient(cc, cc.Bor.ValidatorContract, cc.Bor.StateReceiverContract, logger), logger)
contract.NewGenesisContractsClient(cc, borConfig.ValidatorContract, borConfig.StateReceiverContract, logger), logger)

default:
engine = ethash.NewFaker()
Expand Down Expand Up @@ -912,9 +916,11 @@ func (e *remoteConsensusEngine) init(db kv.RoDB, blockReader services.FullBlockR
return false
}

borConfig := cc.Bor.(*borcfg.BorConfig)

e.engine = bor.NewRo(cc, borKv, blockReader,
span.NewChainSpanner(contract.ValidatorSet(), cc, true, logger),
contract.NewGenesisContractsClient(cc, cc.Bor.ValidatorContract, cc.Bor.StateReceiverContract, logger), logger)
contract.NewGenesisContractsClient(cc, borConfig.ValidatorContract, borConfig.StateReceiverContract, logger), logger)
} else {
e.engine = ethash.NewFaker()
}
Expand Down
Loading

0 comments on commit 4c0534e

Please sign in to comment.