Skip to content

Commit

Permalink
Merge pull request #5 from initia-labs/feat/celestia
Browse files Browse the repository at this point in the history
Feat/celestia
  • Loading branch information
sh-cha authored Aug 6, 2024
2 parents d8df132 + dc4457f commit 747c4cb
Show file tree
Hide file tree
Showing 65 changed files with 4,543 additions and 1,704 deletions.
38 changes: 38 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
coverage:
precision: 2
round: down
range: 70...100

status:
project:
default:
threshold: 1% # allow this much decrease on project
changes: false

comment:
layout: "reach, diff, files"
behavior: default # update if exists else create new

ignore:
- "*.md"
- "*.rst"
- "api/"
- "cmd/"
- "contrib/"
- "docs/"
- "networks/"
- "proto/"
- "scripts/"
- "thrid_party/"
- "docker/"
- "client/"
- "custom/"
- "**/cli"
- "**/rest"
- "**/*.pulsar.go"
- "**/*.pb.go"
- "**/*.pb.gw.go"
- "**/test_utils.go"
- "**/module.go"
- "x/ibc/testing"
- "testing/"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build/

# Dependency directories
vendor/

test_key/
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,30 @@ benchmark:
@go test -timeout 20m -mod=readonly -bench=. ./...

.PHONY: test test-all test-cover test-unit test-race benchmark

###############################################################################
### Protobuf ###
###############################################################################
DOCKER := $(shell which docker)

protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh

proto-format:
@$(protoImage) find ./proto -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json ./proto

proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking

43 changes: 1 addition & 42 deletions bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ import (

"go.uber.org/zap"

"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"

"github.com/initia-labs/OPinit/x/opchild"
"github.com/initia-labs/OPinit/x/ophost"
initiaapp "github.com/initia-labs/initia/app"
"github.com/initia-labs/initia/app/params"
bottypes "github.com/initia-labs/opinit-bots-go/bot/types"
"github.com/initia-labs/opinit-bots-go/db"
"github.com/initia-labs/opinit-bots-go/executor"
Expand All @@ -44,22 +36,6 @@ func LoadJsonConfig(path string, config bottypes.Config) error {
}

func NewBot(name bottypes.BotType, logger *zap.Logger, homePath string, configName string) (bottypes.Bot, error) {
SetSDKConfig()

encodingConfig := params.MakeEncodingConfig()
appCodec := encodingConfig.Codec
txConfig := encodingConfig.TxConfig

std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
auth.AppModuleBasic{}.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ophost.AppModuleBasic{}.RegisterInterfaces(encodingConfig.InterfaceRegistry)
opchild.AppModuleBasic{}.RegisterInterfaces(encodingConfig.InterfaceRegistry)

auth.AppModuleBasic{}.RegisterLegacyAminoCodec(encodingConfig.Amino)
ophost.AppModuleBasic{}.RegisterLegacyAminoCodec(encodingConfig.Amino)
opchild.AppModuleBasic{}.RegisterLegacyAminoCodec(encodingConfig.Amino)

switch name {
case bottypes.BotTypeExecutor:
cfg := &executortypes.Config{}
Expand All @@ -74,29 +50,12 @@ func NewBot(name bottypes.BotType, logger *zap.Logger, homePath string, configNa
return nil, err
}
server := server.NewServer()
return executor.NewExecutor(cfg, db, server, logger, appCodec, txConfig, homePath), nil
return executor.NewExecutor(cfg, db, server, logger.Named("executor"), homePath), nil
}

return nil, errors.New("not providing bot name")
}

func SetSDKConfig() {
sdkConfig := sdk.GetConfig()
sdkConfig.SetCoinType(initiaapp.CoinType)

accountPubKeyPrefix := initiaapp.AccountAddressPrefix + "pub"
validatorAddressPrefix := initiaapp.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := initiaapp.AccountAddressPrefix + "valoperpub"
consNodeAddressPrefix := initiaapp.AccountAddressPrefix + "valcons"
consNodePubKeyPrefix := initiaapp.AccountAddressPrefix + "valconspub"

sdkConfig.SetBech32PrefixForAccount(initiaapp.AccountAddressPrefix, accountPubKeyPrefix)
sdkConfig.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
sdkConfig.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
sdkConfig.SetAddressVerifier(initiaapp.VerifyAddressLen())
sdkConfig.Seal()
}

func getDBPath(homePath string, botName bottypes.BotType) string {
return fmt.Sprintf(homePath+"/%s.db", botName)
}
1 change: 1 addition & 0 deletions bot/types/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import (

type Bot interface {
Start(context.Context) error
Close()
}
Loading

0 comments on commit 747c4cb

Please sign in to comment.