Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp: add go.mod for 07-celestia #6056

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
/modules/light-clients/ @colin-axner @AdityaSripal @damiannolan @chatton
/proto/ibc/lightclients/ @colin-axner @AdityaSripal @damiannolan @chatton

# CODEOWNERS for 07-celestia light client module

/modules/light-clients/07-celestia/ @colin-axner @AdityaSripal @damiannolan

# CODEOWNERS for 08-wasm light client module

/modules/light-clients/08-wasm/ @colin-axner @AdityaSripal @damiannolan @charleenfei @chatton @DimitrisJim @srdtrk @crodriguezvega
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ updates:
labels:
- dependencies

- package-ecosystem: gomod
directory: "/modules/light-clients/07-celestia"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies

- package-ecosystem: gomod
directory: "/modules/light-clients/08-wasm"
schedule:
Expand Down
8 changes: 8 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ pull_request_rules:
backport:
branches:
- callbacks/release/v0.2.x+ibc-go-v8.0.x
- name: backport patches to v0.1.x celestia ibc-go v8.2.x branch
conditions:
- base=main
- label=backport-celestia-v0.1.x+ibc-go-v8.2.x
actions:
backport:
branches:
- 07-celestia/release/v0.1.x+ibc-go-v8.2.x
- name: backport patches to v0.1.x wasm ibc-go v7.3.x & wasmvm 1.5.x branch
conditions:
- base=main
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/build-celestia-simd-image-from-tag.yml
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}"
63 changes: 63 additions & 0 deletions .github/workflows/celestia-client.yml
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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ require (
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/bits-and-blooms/bitset v1.8.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/celestiaorg/nmt v0.20.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtyd
github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY=
github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/nmt v0.20.0 h1:9i7ultZ8Wv5ytt8ZRaxKQ5KOOMo4A2K2T/aPGjIlSas=
github.com/celestiaorg/nmt v0.20.0/go.mod h1:Oz15Ub6YPez9uJV0heoU4WpFctxazuIhKyUtaYNio7E=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down
1 change: 1 addition & 0 deletions go.work.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use (
./
./modules/capability
./modules/apps/callbacks
./modules/light-clients/07-celestia
./modules/light-clients/08-wasm
./e2e
)
27 changes: 27 additions & 0 deletions modules/light-clients/07-celestia/Dockerfile
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"]
68 changes: 34 additions & 34 deletions modules/light-clients/07-celestia/celestia.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions modules/light-clients/07-celestia/celestia_test.go
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))
}
4 changes: 2 additions & 2 deletions modules/light-clients/07-celestia/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (*ClientState) ClientType() string {

// GetLatestHeight implements exported.ClientState.
func (cs *ClientState) GetLatestHeight() exported.Height {
return cs.BaseClient.GetLatestHeight()
return cs.BaseClient.LatestHeight
}

// GetTimestampAtHeight implements exported.ClientState.
Expand All @@ -49,7 +49,7 @@ func (cs *ClientState) Validate() error {
// TODO: Revise and look into delay periods for this.
// TODO: Validate key path and value against the shareProof extracted from proof bytes.
func (cs *ClientState) VerifyMembership(ctx sdk.Context, clientStore storetypes.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error {
if cs.BaseClient.GetLatestHeight().LT(height) {
if cs.BaseClient.LatestHeight.LT(height) {
return errorsmod.Wrapf(
ibcerrors.ErrInvalidHeight,
"client state height < proof height (%d < %d), please ensure the client has been updated", cs.GetLatestHeight(), height,
Expand Down
10 changes: 10 additions & 0 deletions modules/light-clients/07-celestia/doc.go
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
Loading
Loading