Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
corverroos committed May 31, 2022
1 parent 0071ec2 commit 464d6bd
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 22 deletions.
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,16 +587,16 @@ func callValidatorMock(ctx context.Context, duty core.Duty, cl eth2client.Servic
case core.DutyAttester:
err := validatormock.Attest(ctx, cl.(*eth2http.Service), signer, eth2p0.Slot(duty.Slot), pubshares...)
if err != nil {
log.Warn(ctx, "Attestation failed", err)
log.Warn(ctx, "Mock attestation failed", err)
} else {
log.Info(ctx, "Attestation success", z.I64("slot", duty.Slot))
log.Info(ctx, "Mock attestation submitted to validatorapi", z.I64("slot", duty.Slot))
}
case core.DutyProposer:
err := validatormock.ProposeBlock(ctx, cl.(*eth2http.Service), signer, eth2p0.Slot(duty.Slot), addr, pubshares...)
if err != nil {
log.Warn(ctx, "Failed to propose block", err)
log.Warn(ctx, "Mock block proposal failed", err)
} else {
log.Info(ctx, "Block proposed successfully", z.I64("slot", duty.Slot))
log.Info(ctx, "Mock block proposal submitted to validatorapi", z.I64("slot", duty.Slot))
}
default:
log.Warn(ctx, "Invalid duty type", nil)
Expand Down
4 changes: 4 additions & 0 deletions core/sigagg/sigagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
"github.com/coinbase/kryptology/pkg/signatures/bls/bls_sig"

"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/app/log"
"github.com/obolnetwork/charon/app/tracer"
"github.com/obolnetwork/charon/app/z"
"github.com/obolnetwork/charon/core"
"github.com/obolnetwork/charon/tbls"
"github.com/obolnetwork/charon/tbls/tblsconv"
Expand Down Expand Up @@ -101,6 +103,8 @@ func (a *Aggregator) Aggregate(ctx context.Context, duty core.Duty, pubkey core.
return err
}

log.Debug(ctx, "Aggregated threshold partial signatures", z.Any("duty", duty))

// Call subscriptions.
for _, sub := range a.subs {
err := sub(ctx, duty, pubkey, aggSig)
Expand Down
13 changes: 7 additions & 6 deletions testutil/compose/compose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func newDockerCmd(use string, short string, runFunc runFunc) *cobra.Command {
return cmd
}

func newAutoCmd(tmplCallback func(data compose.TmplData)) *cobra.Command {
func newAutoCmd(tmplCallback func(data *compose.TmplData)) *cobra.Command {
cmd := &cobra.Command{
Use: "auto",
Short: "Convenience function that runs `compose define && compose lock && compose run`",
Expand All @@ -150,7 +150,7 @@ func newAutoCmd(tmplCallback func(data compose.TmplData)) *cobra.Command {
}

if tmplCallback != nil {
tmplCallback(lastTmpl)
tmplCallback(&lastTmpl)
err := compose.WriteDockerCompose(*dir, lastTmpl)
if err != nil {
return err
Expand All @@ -172,11 +172,11 @@ func newAutoCmd(tmplCallback func(data compose.TmplData)) *cobra.Command {
return err
}

if err := execUp(ctx, *dir); !errors.Is(err, context.DeadlineExceeded) {
return err
}
defer func() {
_ = execDown(rootCtx, *dir)
}()

if err := execDown(rootCtx, *dir); err != nil {
if err := execUp(ctx, *dir); !errors.Is(err, context.DeadlineExceeded) {
return err
}

Expand Down Expand Up @@ -260,6 +260,7 @@ func execUp(ctx context.Context, dir string) error {
"--remove-orphans",
"--build",
"--abort-on-container-exit",
"--quiet-pull",
)
cmd.Dir = dir
cmd.Stdout = os.Stdout
Expand Down
30 changes: 26 additions & 4 deletions testutil/compose/compose/smoke_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"flag"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -37,7 +38,7 @@ func TestSmoke(t *testing.T) {
tests := []struct {
Name string
ConfigFunc func(*compose.Config)
TmplFunc func(compose.TmplData)
TmplFunc func(*compose.TmplData)
}{
{
Name: "default alpha",
Expand Down Expand Up @@ -77,7 +78,7 @@ func TestSmoke(t *testing.T) {
},
{
Name: "version matrix",
TmplFunc: func(data compose.TmplData) {
TmplFunc: func(data *compose.TmplData) {
data.Nodes[0].ImageTag = "latest"
data.Nodes[1].ImageTag = "latest"
data.Nodes[2].ImageTag = "v0.5.0" // TODO(corver): Update this with new releases.
Expand All @@ -89,13 +90,24 @@ func TestSmoke(t *testing.T) {
ConfigFunc: func(conf *compose.Config) {
conf.VCs = []compose.VCType{compose.VCTeku}
},
TmplFunc: func(data compose.TmplData) {
TmplFunc: func(data *compose.TmplData) {
data.VCs[0].Image = "consensys/teku:latest"
data.VCs[1].Image = "consensys/teku:22.5"
data.VCs[2].Image = "consensys/teku:22.4"
data.VCs[3].Image = "consensys/teku:22.3"
},
},
{
Name: "1 of 4 down",
TmplFunc: func(data *compose.TmplData) {
node0 := data.Nodes[0]
for i := 0; i < len(node0.EnvVars); i++ {
if strings.HasPrefix(node0.EnvVars[i].Key, "p2p") {
data.Nodes[0].EnvVars[i].Key = "unset" // Zero p2p flags to it cannot communicate
}
}
},
},
}

for _, test := range tests {
Expand All @@ -109,7 +121,12 @@ func TestSmoke(t *testing.T) {
}
require.NoError(t, compose.WriteConfig(dir, conf))

cmd := newAutoCmd(test.TmplFunc)
cmd := newAutoCmd(func(data *compose.TmplData) {
data.MonitoringPorts = false
if test.TmplFunc != nil {
test.TmplFunc(data)
}
})
require.NoError(t, cmd.Flags().Set("compose-dir", dir))
require.NoError(t, cmd.Flags().Set("alert-timeout", "30s"))

Expand All @@ -118,3 +135,8 @@ func TestSmoke(t *testing.T) {
})
}
}

// TestFlagFalse ensures the integration flag default value is false.
func TestFlagFalse(t *testing.T) {
require.False(t, *integration)
}
6 changes: 6 additions & 0 deletions testutil/compose/docker-compose.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ services:
{{if .Monitoring}}
prometheus:
image: prom/prometheus:latest
{{- if .MonitoringPorts}}
ports:
- "9090:9090"
{{end -}}
networks: [compose]
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml

grafana:
image: grafana/grafana:latest
{{- if .MonitoringPorts}}
ports:
- "3000:3000"
{{end -}}
networks: [compose]
volumes:
- ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
Expand All @@ -82,8 +86,10 @@ services:
jaeger:
image: jaegertracing/all-in-one:latest
networks: [compose]
{{- if .MonitoringPorts}}
ports:
- "16686:16686"
{{end -}}
{{end}}
networks:
compose:
1 change: 1 addition & 0 deletions testutil/compose/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func Run(ctx context.Context, dir string, conf Config) (TmplData, error) {
Nodes: nodes,
Bootnode: true,
Monitoring: true,
MonitoringPorts: true,
VCs: vcs,
}

Expand Down
5 changes: 3 additions & 2 deletions testutil/compose/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ type TmplData struct {
Nodes []node
VCs []vc

Bootnode bool
Monitoring bool
Bootnode bool
Monitoring bool
MonitoringPorts bool
}

// vc represents a validator client service in a docker-compose.yml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
],
"VCs": null,
"Bootnode": false,
"Monitoring": false
"Monitoring": false,
"MonitoringPorts": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
],
"VCs": null,
"Bootnode": false,
"Monitoring": false
"Monitoring": false,
"MonitoringPorts": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
],
"VCs": null,
"Bootnode": false,
"Monitoring": false
"Monitoring": false,
"MonitoringPorts": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,6 @@
],
"VCs": null,
"Bootnode": true,
"Monitoring": false
"Monitoring": false,
"MonitoringPorts": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,6 @@
}
],
"Bootnode": true,
"Monitoring": true
"Monitoring": true,
"MonitoringPorts": true
}
2 changes: 1 addition & 1 deletion testutil/compose/testdata/TestDockerCompose_run_yml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ services:
networks: [compose]
ports:
- "16686:16686"

networks:
compose:

0 comments on commit 464d6bd

Please sign in to comment.