-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into john/reintegrate-globalfee
- Loading branch information
Showing
29 changed files
with
812 additions
and
315 deletions.
There are no files selected for viewing
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,14 @@ | ||
header: | | ||
// Copyright 2024 NASD Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. |
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 |
---|---|---|
@@ -1,60 +1,94 @@ | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
COMMIT := $(shell git log -1 --format='%H') | ||
VERSION := $(shell echo $(shell git describe --tags --always --dirty --match "v*") | sed 's/^v//') | ||
LEDGER_ENABLED ?= true | ||
|
||
ifeq (,$(VERSION)) | ||
VERSION := $(shell git describe --exact-match 2>/dev/null) | ||
ifeq (,$(VERSION)) | ||
ifeq ($(shell git status --porcelain),) | ||
VERSION := $(BRANCH) | ||
else | ||
VERSION := $(BRANCH)-dirty | ||
endif | ||
endif | ||
# process build tags | ||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
GCCEXE = $(shell where gcc.exe 2> NUL) | ||
ifeq ($(GCCEXE),) | ||
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S),OpenBSD) | ||
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) | ||
else | ||
GCC = $(shell command -v gcc 2> /dev/null) | ||
ifeq ($(GCC),) | ||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ldflags := $(LDFLAGS) | ||
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=Noble \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=nobled \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) | ||
ldflags := $(strip $(ldflags)) | ||
whitespace := | ||
whitespace += $(whitespace) | ||
comma := , | ||
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) | ||
|
||
BUILD_FLAGS := -ldflags '$(ldflags)' | ||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=Noble \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=nobled \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ | ||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" | ||
ldflags += $(LDFLAGS) | ||
ldflags := $(strip $(ldflags)) | ||
|
||
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' | ||
|
||
############################################################################### | ||
### Building / Install ### | ||
### Build ### | ||
############################################################################### | ||
|
||
install: go.sum | ||
build: | ||
@echo "🤖 Building nobled..." | ||
@go build -mod=readonly $(BUILD_FLAGS) -o "$(PWD)/build" ./cmd/nobled | ||
@echo "✅ Completed build!" | ||
|
||
install: | ||
@echo "🤖 Installing nobled..." | ||
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/nobled | ||
@echo "✅ Completed install!" | ||
|
||
build: | ||
@echo "🤖 Building nobled..." | ||
@go build -mod=readonly $(BUILD_FLAGS) -o "$(PWD)/build/" ./... | ||
@echo "✅ Completed build!" | ||
############################################################################### | ||
### Tooling ### | ||
############################################################################### | ||
|
||
gofumpt_cmd=mvdan.cc/gofumpt | ||
golangci_lint_cmd=github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
FILES := $(shell find $(shell go list -f '{{.Dir}}' ./...) -name "*.go" -a -not -name "*.pb.go" -a -not -name "*.pb.gw.go" -a -not -name "*.pulsar.go" | sed "s|$(shell pwd)/||g") | ||
license: | ||
@go-license --config .github/license.yml $(FILES) | ||
|
||
format: | ||
@echo "🤖 Running formatter..." | ||
@go run $(gofumpt_cmd) -l -w . | ||
@echo "✅ Completed formatting!" | ||
|
||
lint: | ||
@echo "🤖 Running linter..." | ||
@go run $(golangci_lint_cmd) run --timeout=10m | ||
@echo "✅ Completed linting!" | ||
|
||
############################################################################### | ||
### Testing ### | ||
############################################################################### | ||
|
||
local-image: | ||
ifeq (,$(shell which heighliner)) | ||
echo 'heighliner' binary not found. Please install: https://github.com/strangelove-ventures/heighliner | ||
@echo heighliner not found. https://github.com/strangelove-ventures/heighliner | ||
else | ||
heighliner build -c noble --local | ||
@echo "🤖 Building image..." | ||
@heighliner build --chain noble --local 1> /dev/null | ||
@echo "✅ Completed build!" | ||
endif | ||
|
||
|
||
############################################################################### | ||
### Linting ### | ||
############################################################################### | ||
|
||
lint: | ||
@echo "--> Running linter" | ||
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m | ||
|
||
|
||
.PHONY: install build local-image lint | ||
.PHONY: license format lint build install local-image |
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,129 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"cosmossdk.io/client/v2/autocli" | ||
clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" | ||
"cosmossdk.io/core/address" | ||
"cosmossdk.io/core/appmodule" | ||
"cosmossdk.io/depinject" | ||
"cosmossdk.io/log" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/config" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
"github.com/cosmos/cosmos-sdk/x/auth/types" | ||
pfm "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward" | ||
pfmtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types" | ||
"github.com/cosmos/ibc-go/modules/capability" | ||
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" | ||
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" | ||
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/transfer" | ||
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
ibc "github.com/cosmos/ibc-go/v8/modules/core" | ||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" | ||
soloclient "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" | ||
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" | ||
"github.com/noble-assets/noble/v8" | ||
) | ||
|
||
var ( | ||
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address. | ||
Bech32PrefixAccAddr = "noble" | ||
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. | ||
Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" | ||
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. | ||
Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper" | ||
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. | ||
Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub" | ||
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. | ||
Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons" | ||
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. | ||
Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub" | ||
|
||
txConfigOpts tx.ConfigOptions | ||
autoCliOpts autocli.AppOptions | ||
ModuleBasicManager module.BasicManager | ||
ClientCtx client.Context | ||
) | ||
|
||
func Initialize() { | ||
cfg := sdk.GetConfig() | ||
cfg.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) | ||
cfg.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) | ||
cfg.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) | ||
cfg.Seal() | ||
|
||
if err := depinject.Inject( | ||
depinject.Configs(noble.AppConfig(), | ||
depinject.Supply( | ||
log.NewNopLogger(), | ||
), | ||
depinject.Provide( | ||
ProvideClientContext, | ||
ProvideKeyring, | ||
), | ||
), | ||
&txConfigOpts, | ||
&autoCliOpts, | ||
&ModuleBasicManager, | ||
&ClientCtx, | ||
); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Since the IBC modules don't support dependency injection, we need to | ||
// manually register the modules on the client side. | ||
// This needs to be removed after IBC supports App Wiring. | ||
modules := map[string]appmodule.AppModule{ | ||
capabilitytypes.ModuleName: capability.AppModule{}, | ||
ibcexported.ModuleName: ibc.AppModule{}, | ||
icatypes.ModuleName: ica.AppModule{}, | ||
pfmtypes.ModuleName: pfm.AppModule{}, | ||
transfertypes.ModuleName: transfer.AppModule{}, | ||
tmclient.ModuleName: tmclient.AppModule{}, | ||
soloclient.ModuleName: soloclient.AppModule{}, | ||
} | ||
for name, mod := range modules { | ||
ModuleBasicManager[name] = module.CoreAppModuleBasicAdaptor(name, mod) | ||
ModuleBasicManager[name].RegisterInterfaces(ClientCtx.InterfaceRegistry) | ||
autoCliOpts.Modules[name] = mod | ||
} | ||
} | ||
|
||
func ProvideClientContext( | ||
appCodec codec.Codec, | ||
interfaceRegistry codectypes.InterfaceRegistry, | ||
txConfig client.TxConfig, | ||
legacyAmino *codec.LegacyAmino, | ||
) client.Context { | ||
clientCtx := client.Context{}. | ||
WithCodec(appCodec). | ||
WithInterfaceRegistry(interfaceRegistry). | ||
WithTxConfig(txConfig). | ||
WithLegacyAmino(legacyAmino). | ||
WithInput(os.Stdin). | ||
WithAccountRetriever(types.AccountRetriever{}). | ||
WithHomeDir(noble.DefaultNodeHome). | ||
WithViper("") // env variable prefix | ||
|
||
// Read the config again to overwrite the default values with the values from the config file | ||
clientCtx, _ = config.ReadFromClientConfig(clientCtx) | ||
|
||
return clientCtx | ||
} | ||
|
||
func ProvideKeyring(clientCtx client.Context, addressCodec address.Codec) (clientv2keyring.Keyring, error) { | ||
kb, err := client.NewKeyringFromBackend(clientCtx, clientCtx.Keyring.Backend()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return keyring.NewAutoCLIKeyring(kb) | ||
} |
Oops, something went wrong.