Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
69 changes: 38 additions & 31 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
# This workflow pushes new Bitsong docker images on every new tag.
# This workflow pushes new Bitsong docker images on every new tag or branch push.
#
# On every new `vX.Y.Z` tag the following images are pushed:
#
# bitsongofficial/go-bitsong:vX.Y.Z # is pushed
# bitsongofficial/go-bitsong:X.Y.Z # is pushed
# bitsongofficial/go-bitsong:X.Y # is updated to X.Y.Z
# bitsongofficial/go-bitsong:X # is updated to X.Y.Z
# bitsongofficial/go-bitsong:latest # is updated to X.Y.Z
#
# bitsongofficial/go-bitsong-e2e:vX.Y.Z # is pushed
# bitsongofficial/go-bitsong-e2e:X.Y.Z # is pushed
# bitsongofficial/go-bitsong-e2e:X.Y # is updated to X.Y.Z
# bitsongofficial/go-bitsong-e2e:X # is updated to X.Y.Z
# bitsongofficial/go-bitsong-e2e:latest # is updated to X.Y.Z
# On branch pushes (e.g. feat-hyperlane) the following images are pushed:
#
# bitsongofficial/go-bitsong:feat-hyperlane # latest for that branch
# bitsongofficial/go-bitsong:feat-hyperlane-abc1234 # pinned to commit
#
# All the images above have support for linux/amd64 and linux/arm64.

name: Push Docker Images

env:
DOCKER_REPOSITORY: bitsongofficial/go-bitsong
RUNNER_BASE_IMAGE_DISTROLESS: gcr.io/distroless/static-debian12
RUNNER_BASE_IMAGE_NONROOT: gcr.io/distroless/static-debian12:nonroot
RUNNER_BASE_IMAGE_ALPINE: alpine:3.21

on:
release:
types: [published, created, edited]
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc
branches:
- 'feat-hyperlane'
Comment thread
angelorc marked this conversation as resolved.

jobs:
bitsong-images:
runs-on: ubuntu-latest
steps:
-
-
name: Check out the repo
uses: actions/checkout@v4
-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
Expand All @@ -51,28 +48,38 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Parse tag
id: tag
name: Determine image tags
id: tags
run: |
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f 1)
MINOR_VERSION=$(echo $VERSION | cut -d '.' -f 2)
PATCH_VERSION=$(echo $VERSION | cut -d '.' -f 3)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
echo "MINOR_VERSION=$MINOR_VERSION" >> $GITHUB_ENV
echo "PATCH_VERSION=$PATCH_VERSION" >> $GITHUB_ENV
-
name: Build and push
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)

if [[ "${{ github.ref_type }}" == "tag" ]]; then
# Tag push: produce semver tags (e.g. v0.21.0 -> 0, 0.21, 0.21.0, v0.21.0)
VERSION=$(echo "${{ github.ref_name }}" | sed "s/v//")
MAJOR_VERSION=$(echo "$VERSION" | cut -d '.' -f 1)
MINOR_VERSION=$(echo "$VERSION" | cut -d '.' -f 2)
PATCH_VERSION=$(echo "$VERSION" | cut -d '.' -f 3)
IMAGE_TAGS="ghcr.io/${{ env.DOCKER_REPOSITORY }}:${MAJOR_VERSION}
ghcr.io/${{ env.DOCKER_REPOSITORY }}:${MAJOR_VERSION}.${MINOR_VERSION}
ghcr.io/${{ env.DOCKER_REPOSITORY }}:${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}
ghcr.io/${{ env.DOCKER_REPOSITORY }}:v${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
else
# Branch push: produce branch + commit-pinned tags
BRANCH=$(echo "${{ github.ref_name }}" | sed 's/\//-/g')
IMAGE_TAGS="ghcr.io/${{ env.DOCKER_REPOSITORY }}:${BRANCH}
ghcr.io/${{ env.DOCKER_REPOSITORY }}:${BRANCH}-${SHORT_SHA}"
fi

echo "IMAGE_TAGS<<EOF" >> $GITHUB_OUTPUT
echo "$IMAGE_TAGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
-
name: Build and push
id: build_push_image
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/bitsongofficial/go-bitsong:${{ env.MAJOR_VERSION }}
ghcr.io/bitsongofficial/go-bitsong:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/bitsongofficial/go-bitsong:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/bitsongofficial/go-bitsong:v${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
tags: ${{ steps.tags.outputs.IMAGE_TAGS }}
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ state_export.json

github.com*
gogoproto*
target/
target/

.localbitsong-hyperlane/

evm/out/
evm/cache/
evm/broadcast/
evm/node_modules/

scripts/hyperlane/.env
infra/.env.secrets
.docs-to-agent/
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import (
v021 "github.com/bitsongofficial/go-bitsong/app/upgrades/v021"
v022 "github.com/bitsongofficial/go-bitsong/app/upgrades/v022"
v023 "github.com/bitsongofficial/go-bitsong/app/upgrades/v023"
v024 "github.com/bitsongofficial/go-bitsong/app/upgrades/v024"
// unnamed import of statik for swagger UI support
// _ "github.com/bitsongofficial/go-bitsong/swagger/statik"
)
Expand All @@ -97,7 +98,7 @@ var (
Upgrades = []upgrades.Upgrade{
// v010.Upgrade, v011.Upgrade, v013.Upgrade, v014.Upgrade,
// v015.Upgrade, v016.Upgrade, v018.Upgrade, v020.Upgrade,
v021.Upgrade, v022.Upgrade, v023.Upgrade,
v021.Upgrade, v022.Upgrade, v023.Upgrade, v024.Upgrade,
}
)

Expand Down
34 changes: 34 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ import (
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

hyperlanekeeper "github.com/bcp-innovations/hyperlane-cosmos/x/core/keeper"
hyperlanetypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/types"
warpkeeper "github.com/bcp-innovations/hyperlane-cosmos/x/warp/keeper"
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"
cadencekeeper "github.com/bitsongofficial/go-bitsong/x/cadence/keeper"
cadencetypes "github.com/bitsongofficial/go-bitsong/x/cadence/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
Expand Down Expand Up @@ -116,6 +120,8 @@ var maccPerms = map[string][]string{
wasmtypes.ModuleName: {authtypes.Burner},
protocolpooltypes.ModuleName: nil,
protocolpooltypes.ProtocolPoolEscrowAccount: nil,
hyperlanetypes.ModuleName: nil,
warptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Comment thread
angelorc marked this conversation as resolved.
}

type AppKeepers struct {
Expand Down Expand Up @@ -160,6 +166,10 @@ type AppKeepers struct {
AuthenticatorManager *authenticator.AuthenticatorManager
ProtocolPoolKeeper protocolpoolkeeper.Keeper

// Hyperlane keepers
HyperlaneKeeper *hyperlanekeeper.Keeper
WarpKeeper warpkeeper.Keeper

// Middleware wrapper
Ics20WasmHooks *ibchooks.WasmHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
Expand Down Expand Up @@ -245,6 +255,30 @@ func NewAppKeepers(
govModAddress, bApp.Logger(),
)

// Hyperlane Core Keeper
hyperlaneKeeper := hyperlanekeeper.NewKeeper(
appCodec,
appKeepers.AccountKeeper.AddressCodec(),
runtime.NewKVStoreService(keys[hyperlanetypes.ModuleName]),
govModAddress,
appKeepers.BankKeeper,
)
appKeepers.HyperlaneKeeper = &hyperlaneKeeper

// Hyperlane Warp Keeper
appKeepers.WarpKeeper = warpkeeper.NewKeeper(
appCodec,
appKeepers.AccountKeeper.AddressCodec(),
runtime.NewKVStoreService(keys[warptypes.ModuleName]),
govModAddress,
appKeepers.BankKeeper,
appKeepers.HyperlaneKeeper,
[]int32{
int32(warptypes.HYP_TOKEN_TYPE_COLLATERAL),
int32(warptypes.HYP_TOKEN_TYPE_SYNTHETIC),
},
)

// Initialize authenticators
appKeepers.AuthenticatorManager = authenticator.NewAuthenticatorManager()
appKeepers.AuthenticatorManager.InitializeAuthenticators([]authenticator.Authenticator{
Expand Down
4 changes: 4 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (

"cosmossdk.io/x/feegrant"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
hyperlanetypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/types"
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"
cadencetypes "github.com/bitsongofficial/go-bitsong/x/cadence/types"
smartaccounttypes "github.com/bitsongofficial/go-bitsong/x/smart-account/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
Expand Down Expand Up @@ -60,6 +62,8 @@ func (appKeepers *AppKeepers) GenerateKeys() {
cadencetypes.StoreKey,
smartaccounttypes.StoreKey,
protocolpooltypes.StoreKey,
hyperlanetypes.ModuleName, // "hyperlane" — no StoreKey constant exported, ModuleName is the store key
warptypes.ModuleName, // "warp" — no StoreKey constant exported, ModuleName is the store key
)

appKeepers.tkeys = storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down
18 changes: 14 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"cosmossdk.io/x/upgrade"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/CosmWasm/wasmd/x/wasm"
hyperlane "github.com/bcp-innovations/hyperlane-cosmos/x/core"
hyperlanetypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/types"
warp "github.com/bcp-innovations/hyperlane-cosmos/x/warp"
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"
encparams "github.com/bitsongofficial/go-bitsong/app/params"
"github.com/bitsongofficial/go-bitsong/x/cadence"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -109,6 +113,8 @@ var AppModuleBasics = module.NewBasicManager(
ibcwasm.AppModuleBasic{},
smartaccount.AppModuleBasic{},
protocolpool.AppModule{},
hyperlane.AppModule{},
warp.AppModule{},
)

func appModules(
Expand Down Expand Up @@ -149,6 +155,8 @@ func appModules(
cadence.NewAppModule(appCodec, app.CadenceKeeper),
protocolpool.NewAppModule(app.ProtocolPoolKeeper, app.AccountKeeper, app.BankKeeper),
smartaccount.NewAppModule(appCodec, *app.SmartAccountKeeper),
hyperlane.NewAppModule(appCodec, app.HyperlaneKeeper),
warp.NewAppModule(appCodec, app.WarpKeeper),
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
}
}
Expand All @@ -158,7 +166,8 @@ func orderBeginBlockers() []string {
capabilitytypes.ModuleName, minttypes.ModuleName, authtypes.ModuleName,
banktypes.ModuleName, distrtypes.ModuleName, protocolpooltypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName,
stakingtypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, packetforwardtypes.ModuleName,
icqtypes.ModuleName, authz.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, wasmtypes.ModuleName,
icqtypes.ModuleName, hyperlanetypes.ModuleName, warptypes.ModuleName,
authz.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, wasmtypes.ModuleName,
feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, cadencetypes.ModuleName,
ibchookstypes.ModuleName, ibcwasmtypes.ModuleName, fantokentypes.ModuleName,
}
Expand All @@ -167,7 +176,8 @@ func orderBeginBlockers() []string {
func orderEndBlockers() []string {
return []string{
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName,
packetforwardtypes.ModuleName, icqtypes.ModuleName, feegrant.ModuleName, authz.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName,
packetforwardtypes.ModuleName, icqtypes.ModuleName, hyperlanetypes.ModuleName, warptypes.ModuleName,
feegrant.ModuleName, authz.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName,
protocolpooltypes.ModuleName, // must be before bank
banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, wasmtypes.ModuleName,
evidencetypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, cadencetypes.ModuleName,
Expand All @@ -193,13 +203,13 @@ func orderInitBlockers() []string {
evidencetypes.ModuleName,
feegrant.ModuleName,
authz.ModuleName,
authtypes.ModuleName,
ibcwasmtypes.ModuleName,
smartaccounttypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
hyperlanetypes.ModuleName,
warptypes.ModuleName,
wasmtypes.ModuleName,
ibcwasmtypes.ModuleName,
ibchookstypes.ModuleName,
Expand Down
26 changes: 26 additions & 0 deletions app/upgrades/v024/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package v024

import (
store "cosmossdk.io/store/types"

hyperlanetypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/types"
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"

"github.com/bitsongofficial/go-bitsong/app/upgrades"
)

const (
UpgradeName = "v024"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV024UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
hyperlanetypes.ModuleName,
warptypes.ModuleName,
},
Deleted: []string{},
},
}
49 changes: 49 additions & 0 deletions app/upgrades/v024/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v024

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

hyperlanetypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/types"
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"

"github.com/bitsongofficial/go-bitsong/app/keepers"
"github.com/bitsongofficial/go-bitsong/app/upgrades"
)

func CreateV024UpgradeHandler(mm *module.Manager, configurator module.Configurator, bpm upgrades.BaseAppParamManager, k *keepers.AppKeepers) upgradetypes.UpgradeHandler {
return func(context context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(context)
logger := sdkCtx.Logger().With("upgrade", UpgradeName)

if _, found := vm[hyperlanetypes.ModuleName]; found {
return nil, fmt.Errorf("%s already present in version map; its InitGenesis would be skipped", hyperlanetypes.ModuleName)
}
if _, found := vm[warptypes.ModuleName]; found {
return nil, fmt.Errorf("%s already present in version map; its InitGenesis would be skipped", warptypes.ModuleName)
}

logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))

versionMap, err := mm.RunMigrations(sdkCtx, configurator, vm)
if err != nil {
return nil, err
}

// materialize the hyperlane and warp module accounts at
// the upgrade height. GetModuleAccount lazily creates and persists the account
// the first time it is read; warp would otherwise only get created on its first
// synthetic-token mint. Forcing creation here guarantees the accounts exist
// exactly at the upgrade block.
_ = k.AccountKeeper.GetModuleAccount(sdkCtx, hyperlanetypes.ModuleName)
_ = k.AccountKeeper.GetModuleAccount(sdkCtx, warptypes.ModuleName)

logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))
logger.Info("Hyperlane (core + warp) modules initialized")
return versionMap, nil
}
}
Loading
Loading