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

Feat/celestia #5

Merged
merged 38 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5cf3471
add default batch config
sh-cha Jul 30, 2024
8a69722
add gasprice to config
sh-cha Jul 30, 2024
e0aad69
add ctx done to internal process looper
sh-cha Jul 30, 2024
4fa14b5
generate codec in each node & make account string using bech32 prefix
sh-cha Jul 30, 2024
c3bcc09
add celestia batch submitter / celestia da node / custom BuildTxWithM…
sh-cha Jul 31, 2024
38a66b4
use stored key from os keyring
sh-cha Jul 31, 2024
817c206
add key add & list command
sh-cha Aug 1, 2024
50a0055
fix batch config
sh-cha Aug 1, 2024
0db65e0
add key list, show, delete command
sh-cha Aug 1, 2024
55a3123
chore err handling
sh-cha Aug 1, 2024
8d69d4d
use node keyname initialized at start
sh-cha Aug 1, 2024
00de1de
bug keyring & initialize
sh-cha Aug 1, 2024
8d2a351
add comments
beer-1 Jul 30, 2024
e3ecf84
cherry pick error addition & add da ctx
sh-cha Aug 2, 2024
99d119c
add bech32 hack before encode & decode tx
sh-cha Aug 2, 2024
da9c82f
add bech32 hack whem making codec
sh-cha Aug 2, 2024
397aa0c
change account sequence to expected if expected is larger than got
sh-cha Aug 2, 2024
3cceb17
add da event handler
sh-cha Aug 2, 2024
02f9487
register update batch info handler
sh-cha Aug 2, 2024
f12bc80
panic when batch info updated to stop app
sh-cha Aug 2, 2024
b43f6c3
recover panic in each node goroutine
sh-cha Aug 2, 2024
5b4a018
celestia incorrect broadcasting msg bug fix
sh-cha Aug 2, 2024
8c67da4
change errch to error group
sh-cha Aug 2, 2024
2aef5f8
bug fix not shutting down api
sh-cha Aug 5, 2024
faa7d8e
add delay when tx failed
sh-cha Aug 5, 2024
793a521
use os keyring
sh-cha Aug 5, 2024
513a15a
add timeout to txchecker
sh-cha Aug 5, 2024
477e39f
close txchannelstopped when tx broadcast looper end
sh-cha Aug 5, 2024
0b7ec12
bug fix calculating celestia tx hash
sh-cha Aug 5, 2024
6320e66
bug fix calculating batch info block number
sh-cha Aug 5, 2024
efcc1f5
empty data field of MsgUpdateOracle of oracle tx and send converted b…
sh-cha Aug 5, 2024
e05f318
split broadcaster from the node
beer-1 Aug 5, 2024
4698cbb
fix comments
beer-1 Aug 5, 2024
67daf8e
rename functions and fix lint
beer-1 Aug 6, 2024
1f5ca99
chore err handling & delete local dependencies
sh-cha Aug 6, 2024
004a89f
Merge branch 'feat/celestia' into feat/celestia-refactor
sh-cha Aug 6, 2024
5f74384
Merge pull request #6 from initia-labs/feat/celestia-refactor
sh-cha Aug 6, 2024
dc4457f
Merge branch 'feat/executor' into feat/celestia
sh-cha Aug 6, 2024
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
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