Skip to content

Commit

Permalink
merge main branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
HoytRen committed Jul 17, 2023
2 parents 7578e4f + 9c40a7f commit 6abc2de
Show file tree
Hide file tree
Showing 54 changed files with 695 additions and 532 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.2.0 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.2.2 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SHELL=/usr/bin/env bash
PROJECTNAME=$(shell basename "$(PWD)")
LDFLAGS=-ldflags="-X 'main.buildTime=$(shell date)' -X 'main.lastCommit=$(shell git rev-parse HEAD)' -X 'main.semanticVersion=$(shell git describe --tags --dirty=-dev 2>/dev/null || git rev-parse --abbrev-ref HEAD)'"
versioningPath := "github.com/celestiaorg/celestia-node/nodebuilder/node"
LDFLAGS=-ldflags="-X '$(versioningPath).buildTime=$(shell date)' -X '$(versioningPath).lastCommit=$(shell git rev-parse HEAD)' -X '$(versioningPath).semanticVersion=$(shell git describe --tags --dirty=-dev 2>/dev/null || git rev-parse --abbrev-ref HEAD)'"
ifeq (${PREFIX},)
PREFIX := /usr/local
endif
Expand Down
4 changes: 2 additions & 2 deletions cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func parseParams(method string, params []string) []interface{} {
// 1. Height
num, err := strconv.ParseUint(params[0], 10, 64)
if err != nil {
panic("Error parsing gas limit: uint64 could not be parsed.")
panic("Error parsing height: uint64 could not be parsed.")
}
parsedParams[0] = num
// 2. NamespaceID
Expand All @@ -215,7 +215,7 @@ func parseParams(method string, params []string) []interface{} {
// 1. Height
num, err := strconv.ParseUint(params[0], 10, 64)
if err != nil {
panic("Error parsing gas limit: uint64 could not be parsed.")
panic("Error parsing height: uint64 could not be parsed.")
}
parsedParams[0] = num
// 2. Namespace
Expand Down
6 changes: 0 additions & 6 deletions cmd/celestia/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ func persistentPreRunEnv(cmd *cobra.Command, nodeType node.Type, _ []string) err
return err
}
ctx = cmdnode.WithNetwork(ctx, parsedNetwork)
ctx = cmdnode.WithNodeBuildInfo(ctx, &node.BuildInfo{
LastCommit: lastCommit,
SemanticVersion: semanticVersion,
SystemVersion: systemVersion,
GolangVersion: golangVersion,
})

// loads existing config into the environment
ctx, err = cmdnode.ParseNodeFlags(ctx, cmd, cmdnode.Network(ctx))
Expand Down
21 changes: 7 additions & 14 deletions cmd/celestia/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@ package main

import (
"fmt"
"runtime"

"github.com/spf13/cobra"
)

var (
buildTime string
lastCommit string
semanticVersion string

systemVersion = fmt.Sprintf("%s/%s", runtime.GOARCH, runtime.GOOS)
golangVersion = runtime.Version()
"github.com/celestiaorg/celestia-node/nodebuilder/node"
)

var versionCmd = &cobra.Command{
Expand All @@ -24,9 +16,10 @@ var versionCmd = &cobra.Command{
}

func printBuildInfo(_ *cobra.Command, _ []string) {
fmt.Printf("Semantic version: %s\n", semanticVersion)
fmt.Printf("Commit: %s\n", lastCommit)
fmt.Printf("Build Date: %s\n", buildTime)
fmt.Printf("System version: %s\n", systemVersion)
fmt.Printf("Golang version: %s\n", golangVersion)
buildInfo := node.GetBuildInfo()
fmt.Printf("Semantic version: %s\n", buildInfo.SemanticVersion)
fmt.Printf("Commit: %s\n", buildInfo.LastCommit)
fmt.Printf("Build Date: %s\n", buildInfo.BuildTime)
fmt.Printf("System version: %s\n", buildInfo.SystemVersion)
fmt.Printf("Golang version: %s\n", buildInfo.GolangVersion)
}
11 changes: 0 additions & 11 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ func NodeConfig(ctx context.Context) nodebuilder.Config {
return cfg
}

// NodeInfo reads the node build inforamtion from the context.
func NodeInfo(ctx context.Context) node.BuildInfo {
return ctx.Value(buildInfo{}).(node.BuildInfo)
}

// WithNodeType sets the node type in the given context.
func WithNodeType(ctx context.Context, tp node.Type) context.Context {
return context.WithValue(ctx, nodeTypeKey{}, tp)
Expand Down Expand Up @@ -78,16 +73,10 @@ func WithNodeConfig(ctx context.Context, config *nodebuilder.Config) context.Con
return context.WithValue(ctx, configKey{}, *config)
}

// WithNodeConfig sets the node config build information.
func WithNodeBuildInfo(ctx context.Context, info *node.BuildInfo) context.Context {
return context.WithValue(ctx, buildInfo{}, *info)
}

type (
optionsKey struct{}
configKey struct{}
storePathKey struct{}
nodeTypeKey struct{}
networkKey struct{}
buildInfo struct{}
)
32 changes: 4 additions & 28 deletions cmd/flags_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ import (
otelpyroscope "github.com/pyroscope-io/otel-profiling-go"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.11.0"
"go.opentelemetry.io/otel/trace"

"github.com/celestiaorg/celestia-node/logs"
"github.com/celestiaorg/celestia-node/nodebuilder"
Expand Down Expand Up @@ -199,7 +194,6 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e
}

if ok {
var tp trace.TracerProvider
opts := []otlptracehttp.Option{
otlptracehttp.WithCompression(otlptracehttp.GzipCompression),
otlptracehttp.WithEndpoint(cmd.Flag(tracingEndpointFlag).Value.String()),
Expand All @@ -210,30 +204,13 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e
opts = append(opts, otlptracehttp.WithInsecure())
}

exp, err := otlptracehttp.New(cmd.Context(), opts...)
if err != nil {
return ctx, err
}

tp = tracesdk.NewTracerProvider(
tracesdk.WithSampler(tracesdk.AlwaysSample()),
// Always be sure to batch in production.
tracesdk.WithBatcher(exp),
// Record information about this application in a Resource.
tracesdk.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(fmt.Sprintf("Celestia-%s", NodeType(ctx).String())),
// TODO(@Wondertan): Versioning: semconv.ServiceVersionKey
)),
)

pyroOpts := make([]otelpyroscope.Option, 0)
ok, err = cmd.Flags().GetBool(pyroscopeTracing)
if err != nil {
panic(err)
}
if ok {
tp = otelpyroscope.NewTracerProvider(
tp,
pyroOpts = append(pyroOpts,
otelpyroscope.WithAppName("celestia.da-node"),
otelpyroscope.WithPyroscopeURL(cmd.Flag(pyroscopeEndpoint).Value.String()),
otelpyroscope.WithRootSpanOnly(true),
Expand All @@ -242,8 +219,7 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e
otelpyroscope.WithProfileBaselineURL(true),
)
}

otel.SetTracerProvider(tp)
ctx = WithNodeOptions(ctx, nodebuilder.WithTraces(opts, pyroOpts))
}

ok, err = cmd.Flags().GetBool(metricsFlag)
Expand All @@ -262,7 +238,7 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e
opts = append(opts, otlpmetrichttp.WithInsecure())
}

ctx = WithNodeOptions(ctx, nodebuilder.WithMetrics(opts, NodeType(ctx), NodeInfo(ctx)))
ctx = WithNodeOptions(ctx, nodebuilder.WithMetrics(opts, NodeType(ctx)))
}

ok, err = cmd.Flags().GetBool(p2pMetrics)
Expand Down
3 changes: 2 additions & 1 deletion core/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestEmptySquareWithZeroTxs(t *testing.T) {
eds, err = app.ExtendBlock(data, appconsts.LatestVersion)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(eds)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(t, err)
assert.Equal(t, share.EmptyRoot().Hash(), dah.Hash())
}
Loading

0 comments on commit 6abc2de

Please sign in to comment.