diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ea84439 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: ci + +on: + push: + branches: + - '**' + +jobs: + test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + integration-tests-command: | + make test-e2e + + docker_pipeline: + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + needs: ["test"] + secrets: inherit + with: + publish: false + dockerfile: ./Dockerfile + repoName: babylon-sdk \ No newline at end of file diff --git a/.github/workflows/codeql-analizer.yml b/.github/workflows/codeql-analizer.yml deleted file mode 100644 index f0de614..0000000 --- a/.github/workflows/codeql-analizer.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: "Code Scanning - Action" - -on: - pull_request: - paths: - - "**.go" - push: - branches: [ main ] - paths: - - "**.go" - -jobs: - CodeQL-Build: - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3.5.2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: 'go' - queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality - - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index f7b7da0..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Docker - -on: - push: - branches: - - main - tags: - - "v*.*.*" - pull_request: - branches: - - main - workflow_dispatch: - inputs: - tags: - description: "Tags to build and push" - required: true - type: string - -permissions: - contents: read - packages: write - -jobs: - build-push: - runs-on: ubuntu-latest - - env: - DOCKER_REGISTRY: ghcr.io - DOCKER_IMAGE: babylonchain/bcd - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: "1.20" - check-latest: true - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }} - tags: | - type=ref,event=branch - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern={{version}},value=v${{ inputs.tags }},enable=${{ inputs.tags != '' }} - flavor: | - latest=false - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Run go vendor - run: | - cd demo/ && go mod vendor - - - name: Publish to GitHub Packages - uses: docker/build-push-action@v4 - with: - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1e10a37 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: docker_publish + +on: + push: + branches: + - 'main' + - 'dev' + tags: + - '*' + +jobs: + test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + integration-tests-command: | + make test-e2e + + docker_pipeline: + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + needs: ["test"] + secrets: inherit + with: + publish: true + dockerfile: ./Dockerfile + repoName: babylon-sdk \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index baf92d6..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Release babylon-sdk - -on: - push: - tags: - - "v*.*.*" -permissions: - contents: read - -jobs: - release: - permissions: - contents: write # for goreleaser/goreleaser-action to create a GitHub release - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: "1.20" - check-latest: true - - name: Build demo app artifact - run: make build-linux-static - - - name: Create release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - id: create_release - with: - draft: false - prerelease: false - body_path: RELEASE_NOTES.md - files: | - demo/build/* - tests/e2e/build/* diff --git a/.github/workflows/starship-e2e-tests.yml b/.github/workflows/starship-e2e-tests.yml deleted file mode 100644 index 92043e2..0000000 --- a/.github/workflows/starship-e2e-tests.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Starship E2E tests - -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: {} - -jobs: - e2e-test: - runs-on: ubuntu-latest - timeout-minutes: 30 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.20 - id: go - - - name: Deps - run: | - cd tests/starship/ - go mod tidy - - # Starship Infra setup - # - Connects to k8s cluster with kubeconfig (digital ocean) - # - Creates a new namespace based on the name (deleted in next step) - # - Spins up the infra with the given config file - # - Waits till all nodes are running (timeout 30m) - # - Port forward all ports to localhost for next steps to connect - - name: Setup Test infra - id: starship-action - uses: cosmology-tech/starship-action@0.2.15 - with: - values: tests/starship/configs/ci.yaml - port-forward: true - version: 0.1.48-rc0 - - - name: Run Tests - id: run-tests - continue-on-error: true - run: | - cd tests/starship/ - make test - - - name: Run Tests (retry on failure) - if: failure() && steps.run-tests.outcome == 'failure' - run: | - cd tests/starship/ - make test - - # Starship resource cleanup on cluster - - name: Cleanup cluster - if: always() - run: | - helm delete $DEVNET_NAME --debug --namespace $DEVNET_NAMESPACE --wait || true - kubectl delete namespace $DEVNET_NAMESPACE --wait=true || true - env: - DEVNET_NAME: ${{ steps.starship-action.outputs.name }} - DEVNET_NAMESPACE: ${{ steps.starship-action.outputs.namespace }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index dc353de..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and test -on: - pull_request: - branches: - - "**" - push: - branches: - - "main" - - "release/v[0-9]**" - workflow_dispatch: -permissions: - contents: read - -concurrency: - group: ci-${{ github.ref }}-build - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Setup Golang - uses: actions/setup-go@v4 - with: - go-version: "^1.20" - - name: Display go version - run: go version - - name: Run all tests - run: make test-all - - uses: technote-space/get-diff-action@v6.1.2 - id: git_diff - with: - PATTERNS: | - **/*.go - go.mod - go.sum - **/go.mod - **/go.sum - **/Makefile - Makefile - ################### - #### Build App #### - ################### - - name: Build demo app # to ensure everything compiles - if: env.GIT_DIFF - run: make build diff --git a/demo/app/app.go b/demo/app/app.go index c672519..156b232 100644 --- a/demo/app/app.go +++ b/demo/app/app.go @@ -19,14 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/std" simsutils "github.com/cosmos/cosmos-sdk/testutil/sims" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" - ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" - icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller" - icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" - icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" - icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" @@ -148,7 +140,6 @@ var maccPerms = map[string][]string{ govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibcfeetypes.ModuleName: nil, - icatypes.ModuleName: nil, wasmtypes.ModuleName: {authtypes.Burner}, bbntypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } @@ -188,20 +179,16 @@ type ConsumerApp struct { FeeGrantKeeper feegrantkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCFeeKeeper ibcfeekeeper.Keeper - ICAControllerKeeper icacontrollerkeeper.Keeper - ICAHostKeeper icahostkeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - WasmKeeper wasmkeeper.Keeper - BabylonKeeper *bbnkeeper.Keeper - - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper - ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper - ScopedWasmKeeper capabilitykeeper.ScopedKeeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCFeeKeeper ibcfeekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + WasmKeeper wasmkeeper.Keeper + BabylonKeeper *bbnkeeper.Keeper + + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper // the module manager ModuleManager *module.Manager @@ -240,8 +227,7 @@ func NewConsumerApp( authzkeeper.StoreKey, // non sdk store keys ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, - wasmtypes.StoreKey, icahosttypes.StoreKey, - icacontrollertypes.StoreKey, + wasmtypes.StoreKey, bbntypes.StoreKey, ) @@ -294,8 +280,6 @@ func NewConsumerApp( ) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) app.CapabilityKeeper.Seal() @@ -489,30 +473,6 @@ func NewConsumerApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, - keys[icahosttypes.StoreKey], - app.GetSubspace(icahosttypes.SubModuleName), - app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - app.AccountKeeper, - scopedICAHostKeeper, - app.MsgServiceRouter(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( - appCodec, - keys[icacontrollertypes.StoreKey], - app.GetSubspace(icacontrollertypes.SubModuleName), - app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - scopedICAControllerKeeper, - app.MsgServiceRouter(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - wasmDir := filepath.Join(homePath, "wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) if err != nil { @@ -564,22 +524,6 @@ func NewConsumerApp( transferStack = transfer.NewIBCModule(app.TransferKeeper) transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) - // Create Interchain Accounts Stack - // SendPacket, since it is originating from the application to core IBC: - // icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket - var icaControllerStack porttypes.IBCModule - // integration point for custom authentication modules - // see https://medium.com/the-interchain-foundation/ibc-go-v6-changes-to-interchain-accounts-and-how-it-impacts-your-chain-806c185300d7 - var noAuthzModule porttypes.IBCModule - icaControllerStack = icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper) - icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) - - // RecvPacket, message that originates from core IBC and goes down to app, the flow is: - // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket - var icaHostStack porttypes.IBCModule - icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper) - icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper) - // Create fee enabled wasm ibc Stack var wasmStack porttypes.IBCModule wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper) @@ -588,9 +532,7 @@ func NewConsumerApp( // Create static IBC router, add app routes, then set and seal it ibcRouter := porttypes.NewRouter(). AddRoute(ibctransfertypes.ModuleName, transferStack). - AddRoute(wasmtypes.ModuleName, wasmStack). - AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). - AddRoute(icahosttypes.SubModuleName, icaHostStack) + AddRoute(wasmtypes.ModuleName, wasmStack) app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -628,7 +570,6 @@ func NewConsumerApp( transfer.NewAppModule(app.TransferKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), ibctm.AppModule{}, - ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), babylon.NewAppModule(appCodec, app.BabylonKeeper), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them ) @@ -669,7 +610,6 @@ func NewConsumerApp( // additional non simd modules ibctransfertypes.ModuleName, ibcexported.ModuleName, - icatypes.ModuleName, ibcfeetypes.ModuleName, wasmtypes.ModuleName, bbntypes.ModuleName, @@ -685,7 +625,6 @@ func NewConsumerApp( // additional non simd modules ibctransfertypes.ModuleName, ibcexported.ModuleName, - icatypes.ModuleName, ibcfeetypes.ModuleName, wasmtypes.ModuleName, bbntypes.ModuleName, // last to capture all chain events @@ -708,7 +647,6 @@ func NewConsumerApp( // additional non simd modules ibctransfertypes.ModuleName, ibcexported.ModuleName, - icatypes.ModuleName, ibcfeetypes.ModuleName, // wasm after ibc transfer wasmtypes.ModuleName, @@ -775,8 +713,6 @@ func NewConsumerApp( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedWasmKeeper = scopedWasmKeeper - app.ScopedICAHostKeeper = scopedICAHostKeeper - app.ScopedICAControllerKeeper = scopedICAControllerKeeper // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like // antehandlers, but are run _after_ the `runMsgs` execution. They are also