Skip to content

Commit

Permalink
Merge branch 'main' into adr/bootstrap-from-previous-peers
Browse files Browse the repository at this point in the history
  • Loading branch information
derrandz authored Apr 12, 2023
2 parents 93c76ff + 952a93e commit fd3501b
Show file tree
Hide file tree
Showing 71 changed files with 670 additions and 779 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ on:
jobs:
# Dockerfile Linting
hadolint:
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@main # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.1.0 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: celestiaorg/.github/.github/actions/yamllint@main
- uses: celestiaorg/.github/.github/actions/yamllint@v0.1.0

markdown-lint:
name: Markdown Lint
Expand All @@ -58,7 +58,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Version Release
uses: celestiaorg/.github/.github/actions/version-release@main
uses: celestiaorg/.github/.github/actions/version-release@v0.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
version-bump: ${{inputs.version}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@main # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.1.0 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
12 changes: 6 additions & 6 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:

env:
GO_VERSION: 1.19
GO_VERSION: '1.20'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -84,7 +84,7 @@ jobs:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/golang:1.19.7-alpine3.17 as builder
FROM docker.io/golang:1.20-alpine3.17 as builder

# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Continue reading [here](https://blog.celestia.org/celestia-mvp-release-data-avai
## Minimum requirements

| Requirement | Notes |
| ----------- | -------------- |
| Go version | 1.19 or higher |
| ----------- |----------------|
| Go version | 1.20 or higher |

## System Requirements

Expand Down
28 changes: 28 additions & 0 deletions cmd/celestia/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,39 @@ import (
"bytes"
"context"
"os"
"reflect"
"testing"

"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-node/header"
)

func TestCompletionHelpString(t *testing.T) {
type TestFields struct {
NoInputOneOutput func(context.Context) (*header.ExtendedHeader, error)
TwoInputsOneOutputArray func(
context.Context,
*header.ExtendedHeader,
uint64,
) ([]*header.ExtendedHeader, error)
OneInputOneOutput func(context.Context, uint64) (*header.ExtendedHeader, error)
NoInputsNoOutputs func(ctx context.Context) error
NoInputsChanOutput func(ctx context.Context) (<-chan *header.ExtendedHeader, error)
}
testOutputs := []string{
"() -> (*header.ExtendedHeader)",
"(*header.ExtendedHeader, uint64) -> ([]*header.ExtendedHeader)",
"(uint64) -> (*header.ExtendedHeader)",
"() -> ()",
"() -> (<-chan *header.ExtendedHeader)",
}
methods := reflect.VisibleFields(reflect.TypeOf(TestFields{}))
for i, method := range methods {
require.Equal(t, testOutputs[i], parseSignatureForHelpstring(method))
}
}

func TestLight(t *testing.T) {
// Run the tests in a temporary directory
tmpDir := t.TempDir()
Expand Down
4 changes: 0 additions & 4 deletions cmd/celestia/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package main

import (
"context"
"math/rand"
"os"
"time"

"github.com/spf13/cobra"
)
Expand All @@ -27,8 +25,6 @@ func main() {
}

func run() error {
rand.Seed(time.Now().Unix())

return rootCmd.ExecuteContext(context.Background())
}

Expand Down
37 changes: 36 additions & 1 deletion cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var rpcCmd = &cobra.Command{
methods := reflect.VisibleFields(reflect.TypeOf(module).Elem())
var methodNames []string
for _, m := range methods {
methodNames = append(methodNames, m.Name)
methodNames = append(methodNames, m.Name+"\t"+parseSignatureForHelpstring(m))
}
return methodNames, cobra.ShellCompDirectiveNoFileComp
}
Expand All @@ -90,6 +90,21 @@ func parseParams(method string, params []string) []interface{} {
parsedParams := make([]interface{}, len(params))

switch method {
case "GetSharesByNamespace":
// 1. Share Root
parsedParams[0] = params[0]
// 2. NamespaceID
if strings.HasPrefix(params[1], "0x") {
decoded, err := hex.DecodeString(params[1][2:])
if err != nil {
panic("Error decoding namespace ID: hex string could not be decoded.")
}
parsedParams[1] = decoded
} else {
// otherwise, it's just a base64 string
parsedParams[1] = params[1]
}
return parsedParams
case "SubmitPayForBlob":
// 1. NamespaceID
if strings.HasPrefix(params[0], "0x") {
Expand Down Expand Up @@ -282,3 +297,23 @@ func parseAddressFromString(addrStr string) (state.Address, error) {

return addr, nil
}

func parseSignatureForHelpstring(methodSig reflect.StructField) string {
simplifiedSignature := "("
in, out := methodSig.Type.NumIn(), methodSig.Type.NumOut()
for i := 1; i < in; i++ {
simplifiedSignature += methodSig.Type.In(i).String()
if i != in-1 {
simplifiedSignature += ", "
}
}
simplifiedSignature += ") -> ("
for i := 0; i < out-1; i++ {
simplifiedSignature += methodSig.Type.Out(i).String()
if i != out-2 {
simplifiedSignature += ", "
}
}
simplifiedSignature += ")"
return simplifiedSignature
}
2 changes: 1 addition & 1 deletion cmd/flags_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e
tp,
otelpyroscope.WithAppName("celestia.da-node"),
otelpyroscope.WithPyroscopeURL(cmd.Flag(pyroscopeEndpoint).Value.String()),
otelpyroscope.WithRootSpanOnly(false),
otelpyroscope.WithRootSpanOnly(true),
otelpyroscope.WithAddSpanName(true),
otelpyroscope.WithProfileURL(true),
otelpyroscope.WithProfileBaselineURL(true),
Expand Down
7 changes: 4 additions & 3 deletions cmd/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"os"
"os/signal"
"path/filepath"
Expand All @@ -9,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"go.uber.org/multierr"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
Expand Down Expand Up @@ -48,8 +48,9 @@ Options passed on start override configuration options only on start and are not
if err != nil {
return err
}
// TODO(@Wondertan): Use join errors instead in go1.21
defer multierr.AppendInvoke(&err, multierr.Invoke(store.Close))
defer func() {
err = errors.Join(err, store.Close())
}()

nd, err := nodebuilder.NewWithConfig(NodeType(ctx), Network(ctx), store, &cfg, NodeOptions(ctx)...)
if err != nil {
Expand Down
19 changes: 10 additions & 9 deletions das/daser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/header/headertest"
"github.com/celestiaorg/celestia-node/libs/fraud"
"github.com/celestiaorg/celestia-node/libs/fraud/fraudserv"
"github.com/celestiaorg/celestia-node/libs/fraud/fraudtest"
"github.com/celestiaorg/celestia-node/share"
"github.com/celestiaorg/celestia-node/share/availability/full"
"github.com/celestiaorg/celestia-node/share/availability/light"
Expand Down Expand Up @@ -160,7 +162,7 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
getter := func(ctx context.Context, height uint64) (libhead.Header, error) {
return mockGet.GetByHeight(ctx, height)
}
f := fraud.NewProofService(ps, net.Hosts()[0], getter, ds, false, "private")
f := fraudserv.NewProofService(ps, net.Hosts()[0], getter, ds, false, "private")
require.NoError(t, f.Start(ctx))
mockGet.headers[1], _ = headertest.CreateFraudExtHeader(t, mockGet.headers[1], bServ)
newCtx := context.Background()
Expand Down Expand Up @@ -205,8 +207,8 @@ func TestDASerSampleTimeout(t *testing.T) {
})

ds := ds_sync.MutexWrap(datastore.NewMapDatastore())
sub := new(headertest.DummySubscriber)
f := new(fraud.DummyService)
sub := new(headertest.Subscriber)
f := new(fraudtest.DummyService)

// create and start DASer
daser, err := NewDASer(avail, sub, getter, ds, f, newBroadcastMock(1), WithSampleTimeout(1))
Expand All @@ -231,9 +233,9 @@ func createDASerSubcomponents(
bServ blockservice.BlockService,
numGetter,
numSub int,
) (*mockGetter, *headertest.DummySubscriber, *fraud.DummyService) {
) (*mockGetter, *headertest.Subscriber, *fraudtest.DummyService) {
mockGet, sub := createMockGetterAndSub(t, bServ, numGetter, numSub)
fraud := new(fraud.DummyService)
fraud := new(fraudtest.DummyService)
return mockGet, sub, fraud
}

Expand All @@ -242,7 +244,7 @@ func createMockGetterAndSub(
bServ blockservice.BlockService,
numGetter,
numSub int,
) (*mockGetter, *headertest.DummySubscriber) {
) (*mockGetter, *headertest.Subscriber) {
mockGet := &mockGetter{
headers: make(map[int64]*header.ExtendedHeader),
doneCh: make(chan struct{}),
Expand All @@ -251,16 +253,15 @@ func createMockGetterAndSub(

mockGet.generateHeaders(t, bServ, 0, numGetter)

sub := new(headertest.DummySubscriber)
sub := new(headertest.Subscriber)
mockGet.fillSubWithHeaders(t, sub, bServ, numGetter, numGetter+numSub)

return mockGet, sub
}

// fillSubWithHeaders generates `num` headers from the future for p2pSub to pipe through to DASer.
func (m *mockGetter) fillSubWithHeaders(
t *testing.T,
sub *headertest.DummySubscriber,
sub *headertest.Subscriber,
bServ blockservice.BlockService,
startHeight,
endHeight int,
Expand Down
5 changes: 2 additions & 3 deletions das/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/multierr"
)

func Test_coordinatorStats(t *testing.T) {
Expand Down Expand Up @@ -38,7 +37,7 @@ func Test_coordinatorStats(t *testing.T) {
},
Curr: 15,
failed: []uint64{12, 13},
Err: multierr.Append(errors.New("12: failed"), errors.New("13: failed")),
Err: errors.Join(errors.New("12: failed"), errors.New("13: failed")),
}
},
},
Expand All @@ -63,7 +62,7 @@ func Test_coordinatorStats(t *testing.T) {
Curr: 15,
From: 11,
To: 20,
ErrMsg: "12: failed; 13: failed",
ErrMsg: "12: failed\n13: failed",
},
},
Concurrency: 2,
Expand Down
10 changes: 4 additions & 6 deletions das/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"sync"
"time"

"go.uber.org/multierr"

libhead "github.com/celestiaorg/go-header"

"github.com/celestiaorg/celestia-node/header"
Expand Down Expand Up @@ -114,7 +112,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"err", err,
"finished (s)", time.Since(start),
)
Expand All @@ -127,7 +125,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)

Expand Down Expand Up @@ -168,7 +166,7 @@ func (w *worker) getHeader(ctx context.Context, height uint64) (*header.Extended
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)
return h, nil
Expand All @@ -179,7 +177,7 @@ func (w *worker) setResult(curr uint64, err error) {
defer w.lock.Unlock()
if err != nil {
w.state.failed = append(w.state.failed, curr)
w.state.Err = multierr.Append(w.state.Err, fmt.Errorf("height: %v, err: %w", curr, err))
w.state.Err = errors.Join(w.state.Err, fmt.Errorf("height: %v, err: %w", curr, err))
}
w.state.Curr = curr
}
Expand Down
Loading

0 comments on commit fd3501b

Please sign in to comment.