Skip to content

Commit

Permalink
Merge branch 'main' of github.com:No0key/charon into fix-dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
No0key committed Oct 12, 2024
2 parents 8ee649e + 009a5a1 commit 98d0bbe
Show file tree
Hide file tree
Showing 33 changed files with 466 additions and 293 deletions.
71 changes: 59 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,62 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Disable shallow checkout
- uses: ./.github/actions/setup-go
- run: go run . --help > cli-reference.txt
- run: go run testutil/genchangelog/main.go
- uses: softprops/action-gh-release@v1
with:
draft: true
files: cli-reference.txt
body_path: changelog.md
token: ${{ secrets.RELEASE_SECRET }}
- name: Checkout repository
uses: actions /checkout@v4
with:
fetch-depth: 0 # Disable shallow checkout

- name: Setup Go environment
uses: ./.github/actions/setup-go

- name: Generate CLI reference
run: go run . --help > cli-reference.txt

- name: Generate changelog
run: go run testutil/genchangelog/main.go

- name: Create GitHub release draft
uses: softprops/action-gh-release@v1
with:
draft: true
files: cli-reference.txt
body_path: changelog.md
token: ${{ secrets.RELEASE_SECRET }}

trigger-dispatch:
runs-on: ubuntu-latest
steps:
- name: Extract tag name
run: echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Trigger dispatch for obol-docs
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.OBOL_PLATFORM_PAT }}
repository: ObolNetwork/obol-docs
event-type: update-version
client-payload: '{"tag": "${{ env.TAG_NAME }}"}'

- name: Trigger dispatch for obol-infrastructure
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.OBOL_PLATFORM_PAT }}
repository: ObolNetwork/obol-infrastructure
event-type: update-version
client-payload: '{"tag": "${{ env.TAG_NAME }}"}'

- name: Trigger dispatch for helm-charts
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.OBOL_PLATFORM_PAT }}
repository: ObolNetwork/helm-charts
event-type: update-version
client-payload: '{"tag": "${{ env.TAG_NAME }}"}'

- name: Trigger dispatch for obol-ansible
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.OBOL_PLATFORM_PAT }}
repository: ObolNetwork/obol-ansible
event-type: update-version
client-payload: '{"tag": "${{ env.TAG_NAME }}"}'
32 changes: 12 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func Run(ctx context.Context, conf Config) (err error) {

wirePeerInfo(life, tcpNode, peerIDs, cluster.GetInitialMutationHash(), sender, conf.BuilderAPI)

qbftDebug := newQBFTDebugger()
consensusDebugger := consensus.NewDebugger()

// seenPubkeys channel to send seen public keys from validatorapi to monitoringapi.
seenPubkeys := make(chan core.PubKey)
Expand All @@ -282,10 +282,10 @@ func Run(ctx context.Context, conf Config) (err error) {
}

wireMonitoringAPI(ctx, life, conf.MonitoringAddr, conf.DebugAddr, tcpNode, eth2Cl, peerIDs,
promRegistry, qbftDebug, pubkeys, seenPubkeys, vapiCalls, len(cluster.GetValidators()))
promRegistry, consensusDebugger, pubkeys, seenPubkeys, vapiCalls, len(cluster.GetValidators()))

err = wireCoreWorkflow(ctx, life, conf, cluster, nodeIdx, tcpNode, p2pKey, eth2Cl, subEth2Cl,
peerIDs, sender, qbftDebug.AddInstance, seenPubkeysFunc, vapiCallsFunc)
peerIDs, sender, consensusDebugger, seenPubkeysFunc, vapiCallsFunc)
if err != nil {
return err
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func wireP2P(ctx context.Context, life *lifecycle.Manager, conf Config,
func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config,
cluster *manifestpb.Cluster, nodeIdx cluster.NodeIdx, tcpNode host.Host, p2pKey *k1.PrivateKey,
eth2Cl, submissionEth2Cl eth2wrap.Client, peerIDs []peer.ID, sender *p2p.Sender,
qbftSniffer func(*pbv1.SniffedConsensusInstance), seenPubkeys func(core.PubKey),
consensusDebugger consensus.Debugger, seenPubkeys func(core.PubKey),
vapiCalls func(),
) error {
// Convert and prep public keys and public shares
Expand Down Expand Up @@ -420,9 +420,7 @@ func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config,
return core.NewDeadliner(ctx, label, deadlineFunc)
}

mutableConf := newMutableConfig(ctx, conf)

sched, err := scheduler.New(corePubkeys, eth2Cl, mutableConf.BuilderAPI)
sched, err := scheduler.New(corePubkeys, eth2Cl, conf.BuilderAPI)
if err != nil {
return err
}
Expand Down Expand Up @@ -479,20 +477,19 @@ func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config,
return err
}

fetch, err := fetcher.New(eth2Cl, feeRecipientFunc, mutableConf.BuilderAPI)
fetch, err := fetcher.New(eth2Cl, feeRecipientFunc, conf.BuilderAPI)
if err != nil {
return err
}

dutyDB := dutydb.NewMemDB(deadlinerFunc("dutydb"))

vapi, err := validatorapi.NewComponent(eth2Cl, allPubSharesByKey, nodeIdx.ShareIdx, feeRecipientFunc,
mutableConf.BuilderAPI, seenPubkeys)
vapi, err := validatorapi.NewComponent(eth2Cl, allPubSharesByKey, nodeIdx.ShareIdx, feeRecipientFunc, conf.BuilderAPI, seenPubkeys)
if err != nil {
return err
}

if err := wireVAPIRouter(ctx, life, conf.ValidatorAPIAddr, eth2Cl, vapi, vapiCalls, mutableConf); err != nil {
if err := wireVAPIRouter(ctx, life, conf.ValidatorAPIAddr, eth2Cl, vapi, vapiCalls, conf.BuilderAPI); err != nil {
return err
}

Expand Down Expand Up @@ -530,13 +527,13 @@ func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config,
retryer := retry.New[core.Duty](deadlineFunc)

cons, startCons, err := newConsensus(cluster, tcpNode, p2pKey, sender,
deadlinerFunc("consensus"), gaterFunc, qbftSniffer)
deadlinerFunc("consensus"), gaterFunc, consensusDebugger.AddInstance)
if err != nil {
return err
}

err = wirePrioritise(ctx, conf, life, tcpNode, peerIDs, int(cluster.GetThreshold()),
sender.SendReceive, cons, sched, p2pKey, deadlineFunc, mutableConf)
sender.SendReceive, cons, sched, p2pKey, deadlineFunc)
if err != nil {
return err
}
Expand Down Expand Up @@ -588,7 +585,6 @@ func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config,
func wirePrioritise(ctx context.Context, conf Config, life *lifecycle.Manager, tcpNode host.Host,
peers []peer.ID, threshold int, sendFunc p2p.SendReceiveFunc, coreCons core.Consensus,
sched core.Scheduler, p2pKey *k1.PrivateKey, deadlineFunc func(duty core.Duty) (time.Time, bool),
mutableConf *mutableConfig,
) error {
cons, ok := coreCons.(*consensus.Component)
if !ok {
Expand All @@ -612,8 +608,6 @@ func wirePrioritise(ctx context.Context, conf Config, life *lifecycle.Manager, t
ProposalTypes(conf.BuilderAPI, conf.SyntheticBlockProposals),
)

mutableConf.SetInfoSync(isync)

// Trigger info syncs in last slot of the epoch (for the next epoch).
sched.SubscribeSlots(func(ctx context.Context, slot core.Slot) error {
if !slot.LastInEpoch() {
Expand Down Expand Up @@ -967,11 +961,9 @@ func createMockValidators(pubkeys []eth2p0.BLSPubKey) beaconmock.ValidatorSet {

// wireVAPIRouter constructs the validator API router and registers it with the life cycle manager.
func wireVAPIRouter(ctx context.Context, life *lifecycle.Manager, vapiAddr string, eth2Cl eth2wrap.Client,
handler validatorapi.Handler, vapiCalls func(), mutableConf *mutableConfig,
handler validatorapi.Handler, vapiCalls func(), builderEnabled bool,
) error {
vrouter, err := validatorapi.NewRouter(ctx, handler, eth2Cl, func(slot uint64) bool {
return mutableConf.BuilderAPI(slot)
})
vrouter, err := validatorapi.NewRouter(ctx, handler, eth2Cl, builderEnabled)
if err != nil {
return errors.Wrap(err, "new monitoring server")
}
Expand Down
6 changes: 3 additions & 3 deletions app/monitoringapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
// It serves prometheus metrics, pprof profiling and the runtime enr.
func wireMonitoringAPI(ctx context.Context, life *lifecycle.Manager, promAddr, debugAddr string,
tcpNode host.Host, eth2Cl eth2wrap.Client,
peerIDs []peer.ID, registry *prometheus.Registry, qbftDebug http.Handler,
peerIDs []peer.ID, registry *prometheus.Registry, consensusDebugger http.Handler,
pubkeys []core.PubKey, seenPubkeys <-chan core.PubKey, vapiCalls <-chan struct{},
numValidators int,
) {
Expand Down Expand Up @@ -93,8 +93,8 @@ func wireMonitoringAPI(ctx context.Context, life *lifecycle.Manager, promAddr, d
if debugAddr != "" {
debugMux := http.NewServeMux()

// Serve sniffed qbft instances messages in gzipped protobuf format.
debugMux.Handle("/debug/qbft", qbftDebug)
// Serve sniffed consensus instances messages in gzipped protobuf format.
debugMux.Handle("/debug/consensus", consensusDebugger)

// Copied from net/http/pprof/pprof.go
debugMux.HandleFunc("/debug/pprof/", pprof.Index)
Expand Down
47 changes: 0 additions & 47 deletions app/priorities.go

This file was deleted.

27 changes: 16 additions & 11 deletions cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/json"
"fmt"
"io"
"math"
"net/url"
"os"
"path"
Expand Down Expand Up @@ -100,6 +99,22 @@ func newCreateClusterCmd(runFunc func(context.Context, io.Writer, clusterConfig)
bindClusterFlags(cmd.Flags(), &conf)
bindInsecureFlags(cmd.Flags(), &conf.InsecureKeys)

wrapPreRunE(cmd, func(cmd *cobra.Command, _ []string) error {
thresholdPresent := cmd.Flags().Lookup("threshold").Changed

if thresholdPresent {
if conf.Threshold < minThreshold {
return errors.New("threshold must be greater than 1", z.Int("threshold", conf.Threshold), z.Int("min", minThreshold))
}
if conf.Threshold > conf.NumNodes {
return errors.New("threshold cannot be greater than number of operators",
z.Int("threshold", conf.Threshold), z.Int("operators", conf.NumNodes))
}
}

return nil
})

return cmd
}

Expand Down Expand Up @@ -374,16 +389,6 @@ func validateCreateConfig(ctx context.Context, conf clusterConfig) error {
return errors.New("number of operators is below minimum", z.Int("operators", conf.NumNodes), z.Int("min", minNodes))
}

// Check for threshold parameter
minThreshold := int(math.Ceil(float64(conf.NumNodes*2) / 3))
if conf.Threshold < minThreshold {
return errors.New("threshold cannot be smaller than BFT quorum", z.Int("threshold", conf.Threshold), z.Int("min", minThreshold))
}
if conf.Threshold > conf.NumNodes {
return errors.New("threshold cannot be greater than number of operators",
z.Int("threshold", conf.Threshold), z.Int("operators", conf.NumNodes))
}

return nil
}

Expand Down
Loading

0 comments on commit 98d0bbe

Please sign in to comment.