-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: add go.mod for 07-celestia (#6056)
* add go.mod for 07-celestia * lint * fix 07-celestia codeowners
- Loading branch information
Carlos Rodriguez
authored
Mar 26, 2024
1 parent
2d08560
commit fbadc24
Showing
34 changed files
with
4,330 additions
and
52 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Build Celestia Simd Image | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'The tag of the image to build' | ||
required: true | ||
type: string | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
ORG: cosmos | ||
IMAGE_NAME: ibc-go-celestia-simd | ||
GIT_TAG: "${{ inputs.tag }}" | ||
|
||
jobs: | ||
build-image-at-tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ env.GIT_TAG }}" | ||
fetch-depth: 0 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build image | ||
run: | | ||
# remove any `/` characters from the docker tag and replace them with a - | ||
docker_tag="$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" | ||
docker build . -t "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}" -f modules/light-clients/07-celestia/Dockerfile | ||
docker push "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Celestia Light-Client | ||
# This workflow runs when a PR is opened that targets code that is part of the 07-celestia module. | ||
on: | ||
pull_request: | ||
paths: | ||
- '.github/workflows/celestia-client.yml' | ||
- 'modules/light-clients/07-celestia/**' | ||
- 'proto/ibc/lightclients/celestia/**' | ||
push: | ||
branches: | ||
- main | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
- uses: actions/checkout@v4 | ||
- uses: golangci/[email protected] | ||
with: | ||
version: v1.54.2 | ||
args: --timeout 10m | ||
working-directory: modules/light-clients/07-celestia | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-arch: ['amd64', 'arm', 'arm64'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
- name: Build celestia-client | ||
run: | | ||
cd modules/light-clients/07-celestia | ||
GOARCH=${{ matrix.go-arch }} go build ./... | ||
tests: | ||
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
- name: Go Test | ||
run: | | ||
cd modules/light-clients/07-celestia | ||
go test -v -mod=readonly ./... | ||
- name: sonarcloud | ||
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} | ||
uses: SonarSource/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
projectBaseDir: modules/light-clients/07-celestia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM golang:1.21-alpine3.18 as builder | ||
|
||
RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make; | ||
|
||
ENV GOPATH="" | ||
|
||
# Copy relevant files before go mod download. Replace directives to local paths break if local | ||
# files are not copied before go mod download. | ||
ADD internal internal | ||
ADD testing testing | ||
ADD modules modules | ||
ADD LICENSE LICENSE | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
WORKDIR modules/light-clients/07-celestia | ||
|
||
RUN go mod download | ||
|
||
RUN GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false go build -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger," -w -s' -trimpath -o /go/build/ ./... | ||
|
||
FROM alpine:3.18 | ||
|
||
COPY --from=builder /go/build/simd /bin/simd | ||
|
||
ENTRYPOINT ["simd"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package celestia_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
dbm "github.com/cosmos/cosmos-db" | ||
"github.com/stretchr/testify/require" | ||
testifysuite "github.com/stretchr/testify/suite" | ||
|
||
"cosmossdk.io/log" | ||
|
||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
|
||
ibccelestia "github.com/cosmos/ibc-go/modules/light-clients/07-celestia" | ||
"github.com/cosmos/ibc-go/modules/light-clients/07-celestia/testing/simapp" | ||
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" | ||
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" | ||
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" | ||
ibctesting "github.com/cosmos/ibc-go/v8/testing" | ||
) | ||
|
||
func init() { | ||
ibctesting.DefaultTestingAppInit = SetupTestingApp | ||
} | ||
|
||
// SetupTestingApp provides the duplicated simapp which is specific to the callbacks module on chain creation. | ||
func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) { | ||
db := dbm.NewMemDB() | ||
app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, simtestutil.EmptyAppOptions{}) | ||
return app, app.DefaultGenesis() | ||
} | ||
|
||
type CelestiaTestSuite struct { | ||
testifysuite.Suite | ||
|
||
coordinator *ibctesting.Coordinator | ||
|
||
// testing chains used for convenience and readability | ||
chainA *ibctesting.TestChain | ||
chainB *ibctesting.TestChain | ||
} | ||
|
||
func (suite *CelestiaTestSuite) SetupTest() { | ||
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) | ||
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) | ||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) | ||
|
||
// commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) | ||
suite.coordinator.CommitNBlocks(suite.chainA, 2) | ||
suite.coordinator.CommitNBlocks(suite.chainB, 2) | ||
} | ||
|
||
// CreateClient creates an 07-celestia client on a mock cometbft chain. | ||
func (suite *CelestiaTestSuite) CreateClient(endpoint *ibctesting.Endpoint) string { | ||
tmConfig, ok := endpoint.ClientConfig.(*ibctesting.TendermintConfig) | ||
suite.Require().True(ok) | ||
|
||
height := endpoint.Counterparty.Chain.LatestCommittedHeader.GetHeight().(clienttypes.Height) | ||
tmClientState := ibctm.NewClientState( | ||
endpoint.Counterparty.Chain.ChainID, | ||
tmConfig.TrustLevel, | ||
tmConfig.TrustingPeriod, | ||
tmConfig.UnbondingPeriod, | ||
tmConfig.MaxClockDrift, | ||
height, | ||
commitmenttypes.GetSDKSpecs(), | ||
ibctesting.UpgradePath, | ||
) | ||
clientState := &ibccelestia.ClientState{ | ||
BaseClient: tmClientState, | ||
} | ||
tmConsensusState := endpoint.Counterparty.Chain.LatestCommittedHeader.ConsensusState() | ||
|
||
msg, err := clienttypes.NewMsgCreateClient(clientState, tmConsensusState, endpoint.Chain.SenderAccount.GetAddress().String()) | ||
suite.Require().NoError(err) | ||
|
||
res, err := suite.chainA.SendMsgs(msg) | ||
suite.Require().NoError(err) | ||
suite.Require().NotNil(res) | ||
|
||
clientID, err := ibctesting.ParseClientIDFromEvents(res.Events) | ||
require.NoError(endpoint.Chain.TB, err) | ||
endpoint.ClientID = clientID | ||
|
||
return clientID | ||
} | ||
|
||
func TestTendermintTestSuite(t *testing.T) { | ||
testifysuite.Run(t, new(CelestiaTestSuite)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Package celestia implements a concrete LightClientModule and ClientState for | ||
the Celestia light client. The Celestia light client tracks the latest header | ||
consensus state from a Tendermint chain, but the consensus state that it | ||
stores uses the data hash as the commitment root, instead of the app hash, as | ||
done in vanilla Tendermint light clients. This light client is meant to be used | ||
as a light client to verify proof of inclusion of header and block data of Rollkit | ||
rollups in the Celestia data availability layer. | ||
*/ | ||
package celestia |
Oops, something went wrong.