Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb9c935
add new timer and corresponding feature
DiogoSantoss Jan 7, 2025
5052b77
formatting
DiogoSantoss Jan 7, 2025
834c826
add timer test and fix first round to be one instead of zero
DiogoSantoss Jan 7, 2025
9d0bfd0
fix typo in round timer test
DiogoSantoss Jan 7, 2025
19b8a46
add exponential timer to GetTimerFunc()
DiogoSantoss Jan 7, 2025
d7065be
add consensus round timer documentation
DiogoSantoss Jan 7, 2025
b206e2f
add precedence warning to exponential round timer feature
DiogoSantoss Jan 7, 2025
c8a03d3
add exponential to GetTimerFunc test and fix name consistency
DiogoSantoss Jan 7, 2025
f5ca318
fix lint issue
DiogoSantoss Jan 7, 2025
a4eba85
add same timer warning, cli flag, default timer and more exponential …
DiogoSantoss Jan 8, 2025
0ee9b60
fix default timer doc
DiogoSantoss Jan 8, 2025
1afc273
Update docs/consensus.md
DiogoSantoss Jan 14, 2025
f7da772
Update docs/consensus.md
DiogoSantoss Jan 14, 2025
caec6c3
app/eth2wrap: fallback beacon nodes (#3342)
gsora Jan 7, 2025
e4997eb
*: bump protobuf to 1.36.2 (#3439)
KaloyanTanev Jan 7, 2025
1fdc58f
build(deps): Bump go.opentelemetry.io/otel/trace from 1.32.0 to 1.33.…
dependabot[bot] Jan 7, 2025
bc3c6e7
build(deps): Bump go.opentelemetry.io/contrib/instrumentation/net/htt…
dependabot[bot] Jan 8, 2025
8ce78aa
build(deps): Bump google.golang.org/protobuf from 1.35.2 to 1.36.2 (#…
dependabot[bot] Jan 8, 2025
80d5bf9
build(deps): Bump go.opentelemetry.io/otel/exporters/stdout/stdouttra…
dependabot[bot] Jan 8, 2025
d33769e
build(deps): Bump golang.org/x/tools from 0.28.0 to 0.29.0 (#3443)
dependabot[bot] Jan 8, 2025
66f9e65
app/peerinfo: add nickname field to peerinfo protocol (#3428)
DiogoSantoss Jan 8, 2025
586c265
core/validatorapi: v1/v2 endpoints warning (#3431)
pinebit Jan 8, 2025
1bfee74
app: eth2wrap latency logging (#3417)
KaloyanTanev Jan 8, 2025
bd8efb3
*: bump linter to 1.63.4 (#3444)
KaloyanTanev Jan 8, 2025
7752c0b
build: allow golangci-lint parallel on .pre-commit (#3455)
KaloyanTanev Jan 13, 2025
7109f7e
fix: chown -R runner:docker 001 folder (#3441)
apham0001 Jan 13, 2025
b6841e1
docs: contributing discord channel (#3452)
KaloyanTanev Jan 14, 2025
cf785b5
build(deps): Bump github.com/showwin/speedtest-go from 1.7.9 to 1.7.1…
dependabot[bot] Jan 14, 2025
b8d208d
build(deps): Bump golang.org/x/time from 0.8.0 to 0.9.0 (#3446)
dependabot[bot] Jan 14, 2025
a1985c0
build(deps): Bump sigp/lighthouse from v6.0.0 to v6.0.1 in /testutil/…
dependabot[bot] Jan 14, 2025
9e47a84
build(deps): Bump chainsafe/lodestar from v1.23.1 to v1.24.0 in /test…
dependabot[bot] Jan 14, 2025
7dc6b41
build(deps): Bump github.com/attestantio/go-builder-client from 0.5.2…
dependabot[bot] Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.2
version: v1.63.4
- name: notify failure
if: failure() && github.ref == 'refs/heads/main'
env:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit/run_linter.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="1.62.2"
VERSION="1.63.4"

if ! command -v golangci-lint &> /dev/null
then
Expand All @@ -14,4 +14,4 @@ if [[ $version_check != *"$VERSION"* ]]; then
echo "golangci-lint version is not $VERSION"
fi

golangci-lint run
golangci-lint run --allow-parallel-runners
10 changes: 7 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
TestnetConfig eth2util.Network
ProcDirectory string
ConsensusProtocol string
Nickname string

TestConfig TestConfig
}
Expand Down Expand Up @@ -257,7 +258,10 @@

sender := new(p2p.Sender)

wirePeerInfo(life, tcpNode, peerIDs, cluster.GetInitialMutationHash(), sender, conf.BuilderAPI)
if len(conf.Nickname) > 32 {
return errors.New("nickname can not exceed 32 characters")
}
wirePeerInfo(life, tcpNode, peerIDs, cluster.GetInitialMutationHash(), sender, conf.BuilderAPI, conf.Nickname)

Check warning on line 264 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L261-L264

Added lines #L261 - L264 were not covered by tests

// seenPubkeys channel to send seen public keys from validatorapi to monitoringapi.
seenPubkeys := make(chan core.PubKey)
Expand Down Expand Up @@ -297,9 +301,9 @@
}

// wirePeerInfo wires the peerinfo protocol.
func wirePeerInfo(life *lifecycle.Manager, tcpNode host.Host, peers []peer.ID, lockHash []byte, sender *p2p.Sender, builderEnabled bool) {
func wirePeerInfo(life *lifecycle.Manager, tcpNode host.Host, peers []peer.ID, lockHash []byte, sender *p2p.Sender, builderEnabled bool, nickname string) {

Check warning on line 304 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L304

Added line #L304 was not covered by tests
gitHash, _ := version.GitCommit()
peerInfo := peerinfo.New(tcpNode, peers, version.Version, lockHash, gitHash, sender.SendReceive, builderEnabled)
peerInfo := peerinfo.New(tcpNode, peers, version.Version, lockHash, gitHash, sender.SendReceive, builderEnabled, nickname)

Check warning on line 306 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L306

Added line #L306 was not covered by tests
life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartPeerInfo, lifecycle.HookFuncCtx(peerInfo.Run))
}

Expand Down
117 changes: 81 additions & 36 deletions app/eth2wrap/eth2wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/app/featureset"
"github.com/obolnetwork/charon/app/forkjoin"
"github.com/obolnetwork/charon/app/log"
"github.com/obolnetwork/charon/app/promauto"
"github.com/obolnetwork/charon/app/z"
)
Expand Down Expand Up @@ -57,7 +58,21 @@
return nil, errors.New("clients empty")
}

return newMulti(clients), nil
// TODO(gsora): remove once the implementation is agreed upon and
// wiring is complete.
fb := NewFallbackClient(0, [4]byte{}, nil)

return newMulti(clients, fb), nil
}

// InstrumentWithFallback returns a new multi instrumented client using the provided clients as backends and fallback
// respectively.
func InstrumentWithFallback(fallback *FallbackClient, clients ...Client) (Client, error) {
if len(clients) == 0 {
return nil, errors.New("clients empty")
}

Check warning on line 73 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L70-L73

Added lines #L70 - L73 were not covered by tests

return newMulti(clients, fallback), nil

Check warning on line 75 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L75

Added line #L75 was not covered by tests
}

// WithSyntheticDuties wraps the provided client adding synthetic duties.
Expand All @@ -71,43 +86,58 @@

// NewMultiHTTP returns a new instrumented multi eth2 http client.
func NewMultiHTTP(timeout time.Duration, forkVersion [4]byte, addresses ...string) (Client, error) {
return Instrument(newClients(timeout, forkVersion, addresses)...)
}

// newClients returns a slice of Client initialized with the provided settings.
func newClients(timeout time.Duration, forkVersion [4]byte, addresses []string) []Client {
var clients []Client
for _, address := range addresses {
parameters := []eth2http.Parameter{
eth2http.WithLogLevel(zeroLogInfo),
eth2http.WithAddress(address),
eth2http.WithTimeout(timeout),
eth2http.WithAllowDelayedStart(true),
eth2http.WithEnforceJSON(featureset.Enabled(featureset.JSONRequests)),
}
clients = append(clients, newBeaconClient(timeout, forkVersion, address))
}

cl := newLazy(func(ctx context.Context) (Client, error) {
eth2Svc, err := eth2http.New(ctx, parameters...)
if err != nil {
return nil, wrapError(ctx, err, "new eth2 client", z.Str("address", address))
}
eth2Http, ok := eth2Svc.(*eth2http.Service)
if !ok {
return nil, errors.New("invalid eth2 http service")
}
return clients
}

adaptedCl := AdaptEth2HTTP(eth2Http, timeout)
adaptedCl.SetForkVersion(forkVersion)
// newBeaconClient returns a Client with the provided settings.
func newBeaconClient(timeout time.Duration, forkVersion [4]byte, address string) Client {
parameters := []eth2http.Parameter{
eth2http.WithLogLevel(zeroLogInfo),
eth2http.WithAddress(address),
eth2http.WithTimeout(timeout),
eth2http.WithAllowDelayedStart(true),
eth2http.WithEnforceJSON(featureset.Enabled(featureset.JSONRequests)),
}

return adaptedCl, nil
})
cl := newLazy(func(ctx context.Context) (Client, error) {
eth2Svc, err := eth2http.New(ctx, parameters...)
if err != nil {
return nil, wrapError(ctx, err, "new eth2 client", z.Str("address", address))
}

Check warning on line 116 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L115-L116

Added lines #L115 - L116 were not covered by tests
eth2Http, ok := eth2Svc.(*eth2http.Service)
if !ok {
return nil, errors.New("invalid eth2 http service")
}

Check warning on line 120 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L119-L120

Added lines #L119 - L120 were not covered by tests

clients = append(clients, cl)
}
adaptedCl := AdaptEth2HTTP(eth2Http, timeout)
adaptedCl.SetForkVersion(forkVersion)

return adaptedCl, nil
})

return Instrument(clients...)
return cl
}

type provideArgs struct {
client Client
fallback *FallbackClient
}

// provide calls the work function with each client in parallel, returning the
// first successful result or first error.
// The bestIdxFunc is called with the index of the client returning a successful response.
func provide[O any](ctx context.Context, clients []Client,
work forkjoin.Work[Client, O], isSuccessFunc func(O) bool, bestSelector *bestSelector,
func provide[O any](ctx context.Context, clients []Client, fallback *FallbackClient,
work forkjoin.Work[provideArgs, O], isSuccessFunc func(O) bool, bestSelector *bestSelector,
) (O, error) {
if isSuccessFunc == nil {
isSuccessFunc = func(O) bool { return true }
Expand All @@ -118,12 +148,15 @@
forkjoin.WithWorkers(len(clients)),
)
for _, client := range clients {
fork(client)
fork(provideArgs{
client: client,
fallback: fallback,
})
}
defer cancel()

var (
nokResp forkjoin.Result[Client, O]
nokResp forkjoin.Result[provideArgs, O]
hasNokResp bool
zero O
)
Expand All @@ -132,7 +165,7 @@
return zero, ctx.Err()
} else if res.Err == nil && isSuccessFunc(res.Output) {
if bestSelector != nil {
bestSelector.Increment(res.Input.Address())
bestSelector.Increment(res.Input.client.Address())
}

return res.Output, nil
Expand All @@ -154,25 +187,37 @@
type empty struct{}

// submit proxies provide, but returns nil instead of a successful result.
func submit(ctx context.Context, clients []Client, work func(context.Context, Client) error, selector *bestSelector) error {
_, err := provide(ctx, clients,
func(ctx context.Context, cl Client) (empty, error) {
return empty{}, work(ctx, cl)
func submit(ctx context.Context, clients []Client, fallback *FallbackClient, work func(context.Context, provideArgs) error, selector *bestSelector) error {
_, err := provide(ctx, clients, fallback,
func(ctx context.Context, args provideArgs) (empty, error) {
return empty{}, work(ctx, args)
},
nil, selector,
)

return err
}

// latency measures endpoint latency.
// latency measures endpoint latency and writes metrics and logs results.
// Usage:
//
// defer latency("endpoint")()
func latency(endpoint string) func() {
func latency(ctx context.Context, endpoint string, enableLogs bool) func() {
if enableLogs {
log.Debug(ctx, "Calling beacon node endpoint...", z.Str("endpoint", endpoint))
}
t0 := time.Now()

return func() {
latencyHist.WithLabelValues(endpoint).Observe(time.Since(t0).Seconds())
rtt := time.Since(t0)
latencyHist.WithLabelValues(endpoint).Observe(rtt.Seconds())
if enableLogs {
log.Debug(ctx, "Beacon node call finished", z.Str("endpoint", endpoint))
}
// If BN call took more than 1 second, send WARN log
if rtt > time.Second {
log.Warn(ctx, "Beacon node call took longer than expected", nil, z.Str("endpoint", endpoint), z.Str("rtt", rtt.String()))
}

Check warning on line 220 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L219-L220

Added lines #L219 - L220 were not covered by tests
}
}

Expand Down
Loading
Loading