Skip to content

Commit

Permalink
Merge branch 'main' into hlib/share/namespace-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Jun 22, 2023
2 parents 6d52077 + f32c903 commit 09dd716
Show file tree
Hide file tree
Showing 22 changed files with 319 additions and 173 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: CI and Release
on:
merge_group:
push:
branches:
- main
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Docker Build & Publish

# Trigger on all push events, new semantic version tags, and all PRs
on:
merge_group:
push:
branches:
- "**"
Expand Down
8 changes: 8 additions & 0 deletions api/gateway/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ func (h *Handler) RegisterMiddleware(srv *Server) {
setContentType,
checkPostDisabled(h.state),
wrapRequestContext,
enableCors,
)
}

func enableCors(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
next.ServeHTTP(w, r)
})
}

func setContentType(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
Expand Down
31 changes: 29 additions & 2 deletions api/gateway/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import (
"github.com/stretchr/testify/require"
)

const (
address = "localhost"
port = "0"
)

func TestServer(t *testing.T) {
address, port := "localhost", "0"
server := NewServer(address, port)

ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -42,10 +46,33 @@ func TestServer(t *testing.T) {
require.NoError(t, err)
}

func TestCorsEnabled(t *testing.T) {
server := NewServer(address, port)
server.RegisterMiddleware(enableCors)

ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

err := server.Start(ctx)
require.NoError(t, err)

// register ping handler
ping := new(ping)
server.RegisterHandlerFunc("/ping", ping.ServeHTTP, http.MethodGet)

url := fmt.Sprintf("http://%s/ping", server.ListenAddr())

resp, err := http.Get(url)
require.NoError(t, err)
defer resp.Body.Close()

require.NoError(t, err)
require.Equal(t, resp.Header.Get("Access-Control-Allow-Origin"), "*")
}

// TestServer_contextLeakProtection tests to ensure a context
// deadline was added by the context wrapper middleware server-side.
func TestServer_contextLeakProtection(t *testing.T) {
address, port := "localhost", "0"
server := NewServer(address, port)
server.RegisterMiddleware(wrapRequestContext)

Expand Down
3 changes: 1 addition & 2 deletions blob/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ func (s *Service) getByCommitment(

namespacedShares, err := s.shareGetter.GetSharesByNamespace(ctx, header.DAH, namespace)
if err != nil {
if errors.Is(err, share.ErrNamespaceNotFound) ||
errors.Is(err, share.ErrNotFound) {
if errors.Is(err, share.ErrNotFound) {
err = ErrBlobNotFound
}
return nil, nil, err
Expand Down
54 changes: 28 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ replace github.com/ipfs/go-verifcid => github.com/celestiaorg/go-verifcid v0.0.1

require (
cosmossdk.io/errors v1.0.0-beta.7
cosmossdk.io/math v1.0.0-beta.3
cosmossdk.io/math v1.0.0-rc.0
github.com/BurntSushi/toml v1.3.0
github.com/alecthomas/jsonschema v0.0.0-20200530073317-71f438968921
github.com/benbjohnson/clock v1.3.5
github.com/celestiaorg/celestia-app v1.0.0-rc2
github.com/celestiaorg/celestia-app v1.0.0-rc4
github.com/celestiaorg/go-fraud v0.1.0
github.com/celestiaorg/go-header v0.2.7
github.com/celestiaorg/go-libp2p-messenger v0.2.0
github.com/celestiaorg/nmt v0.16.0
github.com/celestiaorg/rsmt2d v0.9.0
github.com/cosmos/cosmos-sdk v0.46.11
github.com/cosmos/cosmos-sdk v0.46.13
github.com/cosmos/cosmos-sdk/api v0.1.0
github.com/cristalhq/jwt v1.2.0
github.com/dgraph-io/badger/v2 v2.2007.4
Expand Down Expand Up @@ -62,7 +62,7 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tendermint v0.34.28
go.opentelemetry.io/otel v1.13.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.34.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2
Expand All @@ -77,20 +77,20 @@ require (
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/sync v0.2.0
golang.org/x/text v0.9.0
google.golang.org/grpc v1.53.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
)

require (
cloud.google.com/go v0.107.0 // indirect
cloud.google.com/go/compute v1.15.1 // indirect
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
cloud.google.com/go/iam v0.12.0 // indirect
cloud.google.com/go/storage v1.28.1 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
Expand All @@ -116,10 +116,10 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.2 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ibc-go/v6 v6.1.1 // indirect
github.com/cosmos/iavl v0.19.6 // indirect
github.com/cosmos/ibc-go/v6 v6.2.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/cskr/pubsub v1.0.2 // indirect
Expand Down Expand Up @@ -158,7 +158,7 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
Expand All @@ -168,7 +168,7 @@ require (
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand Down Expand Up @@ -221,7 +221,7 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/klauspost/reedsolomon v1.11.1 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
Expand Down Expand Up @@ -259,14 +259,14 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/pyroscope-io/godeltaprof v0.1.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
Expand All @@ -280,7 +280,7 @@ require (
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.6+incompatible // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
Expand All @@ -289,7 +289,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.14.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
Expand All @@ -312,14 +312,14 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/tools v0.9.1 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.103.0 // indirect
google.golang.org/api v0.110.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -330,8 +330,10 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.13.0-sdk-v0.46.11
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.15.0-sdk-v0.46.13
github.com/filecoin-project/dagstore => github.com/celestiaorg/dagstore v0.0.0-20230413141458-735ab09a15d6
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.21.2-tm-v0.34.27
// broken goleveldb needs to be replaced for the cosmos-sdk and celestia-app
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.22.0-tm-v0.34.28
)
Loading

0 comments on commit 09dd716

Please sign in to comment.