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: prototype versioned app module upgrades #3729

Draft
wants to merge 142 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
43dedfa
wip: multiplexer
rootulp Jul 19, 2024
3e23254
feat: delegate to current app
rootulp Jul 22, 2024
26eb806
refactor: rename var
rootulp Jul 22, 2024
ecb8d3e
refactor: rename
rootulp Jul 22, 2024
6f191ca
chore: add compile-time checks
rootulp Jul 24, 2024
6b08045
error
rootulp Jul 24, 2024
d96731f
make cmd to build binary
rootulp Jul 24, 2024
44661b3
try to use testnode start node
rootulp Jul 24, 2024
9e09257
go mod tidy
rootulp Jul 24, 2024
c6f0672
use fork of errors package
rootulp Jul 24, 2024
ee9c442
use error version with newlines
rootulp Jul 24, 2024
3242f20
fix make command
rootulp Jul 24, 2024
80a0653
workaround for init()
rootulp Jul 24, 2024
03519a9
feat: go mod for x/blob
rootulp Jul 31, 2024
d70cdeb
fix: use rootulp
rootulp Jul 31, 2024
c8e2b97
fix: imports
rootulp Jul 31, 2024
1b38c5b
feat: new go mod for x/blob
rootulp Jul 31, 2024
162a591
wip: error because ambiguous import
rootulp Aug 1, 2024
34fdad5
comments
rootulp Aug 2, 2024
c8abd64
feat: remove x/blob in favor of rootulp/blob
rootulp Aug 2, 2024
bf454e9
Revert "feat: remove x/blob in favor of rootulp/blob"
rootulp Aug 2, 2024
835a92b
Revert "comments"
rootulp Aug 2, 2024
f0c3b61
Revert "wip: error because ambiguous import"
rootulp Aug 2, 2024
8639f23
Revert "feat: new go mod for x/blob"
rootulp Aug 2, 2024
0afbc2a
Revert "fix: imports"
rootulp Aug 2, 2024
dd23cb9
Revert "fix: use rootulp"
rootulp Aug 2, 2024
c8171b8
Revert "feat: go mod for x/blob"
rootulp Aug 2, 2024
537b1e3
test passes if only 1 app is initialized
rootulp Aug 2, 2024
f6e0157
fix: passing unit test by bumping proto package version
rootulp Aug 2, 2024
73871d0
test: can initialize 2 apps at the same time
rootulp Aug 2, 2024
f94e56f
fails b/c context cancelled
rootulp Aug 3, 2024
a2f5a23
wip: context still cancelled prematurely
rootulp Aug 4, 2024
7e6032b
refactor: newCometNode
rootulp Aug 4, 2024
09b872e
refactor: node interaction api
rootulp Aug 4, 2024
140c8ab
fix: client context cancelled
rootulp Aug 4, 2024
23d590f
panic: leveldb: closed
rootulp Aug 4, 2024
f9cfb87
wip: try to create node from scratch
rootulp Aug 4, 2024
02fe6e1
Revert "wip: try to create node from scratch"
rootulp Aug 4, 2024
084d0e5
add comments
rootulp Aug 6, 2024
d089207
enable debug logs
rootulp Aug 6, 2024
393698c
refactor: use temp dir
rootulp Aug 7, 2024
4e758c2
debug: attempt to bind to specific ports
rootulp Aug 7, 2024
6cdc4f5
wip: refactor testnode package
rootulp Aug 7, 2024
fc37118
fix: stop filtering to just errors
rootulp Aug 7, 2024
ca6dd0d
issue is with multiplexer app
rootulp Aug 7, 2024
fbe9a2e
error: panic: leveldb: closed
rootulp Aug 7, 2024
2becb82
still: panic: leveldb: closed
rootulp Aug 7, 2024
3ef359e
still panic
rootulp Aug 7, 2024
f842f17
fix: stop cleaning up node
rootulp Aug 7, 2024
3ed4310
refactor: remove unnecessary rootDir
rootulp Aug 7, 2024
af59529
bug: not progressing past block height 0
rootulp Aug 7, 2024
f67284b
Revert "bug: not progressing past block height 0"
rootulp Aug 7, 2024
057ebcd
Revert "refactor: remove unnecessary rootDir"
rootulp Aug 7, 2024
f087316
fix: logger
rootulp Aug 7, 2024
d9bf079
refactor: clean up
rootulp Aug 7, 2024
f4cb007
wip
rootulp Aug 8, 2024
2fc392c
refactor: remove API server
rootulp Aug 9, 2024
a253034
HACKHACK: passing test
rootulp Aug 9, 2024
fbca2b5
fix: test by waiting for block height > 0
rootulp Aug 9, 2024
b063614
feat: pair w/ Callum
rootulp Aug 9, 2024
3fb927f
refactor: multiplexer nextAppVersion
rootulp Aug 9, 2024
75714fa
refactor: GetApplications
rootulp Aug 9, 2024
b64af99
refactor: unexport const
rootulp Aug 9, 2024
6438131
refactor: move test
rootulp Aug 9, 2024
5a5d496
wip: attempt to use v1 app with hard-coded upgrade height
rootulp Aug 9, 2024
94b1220
failing test
rootulp Aug 9, 2024
90bc71f
chore: upgrade to fork that prints more logs
rootulp Aug 9, 2024
95d06c7
refactor: clean up rootDir
rootulp Aug 9, 2024
6a2ed91
premature upgrade
rootulp Aug 9, 2024
dad7391
these logs helped
rootulp Aug 9, 2024
094c8e2
check for nil
rootulp Aug 9, 2024
8dd8259
more logs
rootulp Aug 9, 2024
fab168b
implement failing check
rootulp Aug 9, 2024
92be05c
v1 state machine is initChained with v2
rootulp Aug 9, 2024
55a4c3d
fix: start v1 state machine with v1 consensus param
rootulp Aug 9, 2024
139bde4
wip: cosmos-sdk is overwriting the consensus param updates
rootulp Aug 10, 2024
548d412
v2 state machine does not have params
rootulp Aug 10, 2024
53e5592
wip: RunMigrations interface
rootulp Aug 10, 2024
3fbef6a
wip: RunMigrations
rootulp Aug 10, 2024
9917b0a
bump to latest v1.x celestia-app that uses cosmos-sdk fork with RunMi…
rootulp Aug 10, 2024
6c9fbcc
crazy error for go imports
rootulp Aug 10, 2024
61480ad
wip: try again with interface
rootulp Aug 10, 2024
8ebabb7
feat: RunMigrations
rootulp Aug 10, 2024
9a7c0fa
attempt to fix nil panic
rootulp Aug 10, 2024
3cc0417
add log
rootulp Aug 12, 2024
e710924
bump to v1.33.0 with more logs
rootulp Aug 12, 2024
87e9e81
clean up method order
rootulp Aug 13, 2024
fca5307
emit logs for apps
rootulp Aug 13, 2024
4c450e6
wip: get/set commit multi store
rootulp Aug 13, 2024
8b7a64b
new error
rootulp Aug 13, 2024
ede5f3e
let v2 state machine handle v1 -> v2
rootulp Aug 13, 2024
e6a3c90
let v2 upgrade to v3 based on hard-coded flag
rootulp Aug 13, 2024
f3bb95d
cleanup
rootulp Aug 13, 2024
bef55d2
import app v3
rootulp Aug 13, 2024
80408d9
make modules support v3
rootulp Aug 13, 2024
bf5d067
attempt to create v3 app only when needed
rootulp Aug 13, 2024
9a576a0
remove unneeded RunMigrations
rootulp Aug 13, 2024
5ea48de
feat: share DB for all state machines
rootulp Aug 14, 2024
3f787ce
store does not exist for key: capability
rootulp Aug 14, 2024
3627aff
refactor: remove rootDir
rootulp Aug 14, 2024
d5495cb
auth key does not exist either
rootulp Aug 14, 2024
cc56704
explicitly setting rootDir does not resolve
rootulp Aug 14, 2024
55e74b0
enable debug logs for CometBFT
rootulp Aug 14, 2024
df47ab0
"kv store with key KVStoreKey{0x1400466f4b0, capability} has not been…
rootulp Aug 14, 2024
f71d1a2
delete root dir
rootulp Aug 14, 2024
8bf36bf
working prototype!
rootulp Aug 15, 2024
da51aea
move comment
rootulp Aug 15, 2024
8380d0e
prevent accidental downgrade from v3 -> v2
rootulp Aug 15, 2024
88f7fa5
no need to call info b/c v3 does not need to support v1 and v2
rootulp Aug 15, 2024
c8fb333
improve logs
rootulp Aug 15, 2024
3fe3996
chore: remove log
rootulp Aug 15, 2024
e30354e
revert go.mod changes
rootulp Aug 15, 2024
2f94921
feat: remove things from AppWithMigrations interface
rootulp Aug 15, 2024
3f81028
revert: remove v3 upgrade height
rootulp Aug 15, 2024
31d326a
revert: remove cms
rootulp Aug 15, 2024
94e1076
revert: variable rename
rootulp Aug 15, 2024
09950e4
add TODO
rootulp Aug 15, 2024
310e522
revert: variable rename
rootulp Aug 15, 2024
31f2e6f
refactor: remove unnecessary function
rootulp Aug 15, 2024
af3eda9
remove comments for me
rootulp Aug 15, 2024
acfdf66
refactor: inline func
rootulp Aug 15, 2024
0463d31
revert: remove logs
rootulp Aug 15, 2024
3469eb1
remove log
rootulp Aug 15, 2024
9224788
revert: extract testnode refactors to separate PR
rootulp Aug 15, 2024
0705a50
Merge branch 'main' into rp/prototype-multi-app
rootulp Aug 15, 2024
ea5ae42
fix: app
rootulp Aug 15, 2024
5cd7c24
fix: node
rootulp Aug 15, 2024
374df1e
feat: make app.go do v3 stuff
rootulp Aug 15, 2024
3a0c498
fix: make signal protos not conflict
rootulp Aug 16, 2024
6b47f0e
revert unnecessary replace
rootulp Aug 16, 2024
9e14799
refactor: multiplexer logger
rootulp Aug 16, 2024
e720578
resolve: config.Seal() conflict by conditionally sealing
rootulp Aug 16, 2024
28c8edd
avoid duplicate proto registry for signal types
rootulp Aug 16, 2024
9c53da1
Merge branch 'main' into rp/prototype-multi-app
rootulp Oct 21, 2024
e628774
revert: unnecessary changes
rootulp Oct 21, 2024
19e8d9c
fix: able to run scripts/single-node.sh
rootulp Oct 21, 2024
1686899
address merge conflicts
rootulp Oct 21, 2024
3eb9d88
refactor: rename node to multiplexer
rootulp Oct 22, 2024
bcb8b4f
run multiplexer too
rootulp Oct 22, 2024
6bbd3d0
debug: override multiplexer cosmos-sdk to local
rootulp Oct 22, 2024
913c676
revert: unneccesary changes
rootulp Oct 22, 2024
2d5af56
feat(x/minfee): extract go module
rootulp Oct 22, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ square/testdata
**/*.DS_Store
vendor
go.work
go.work.sum
go.work.sum
multiplexer/multiplexer
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,16 @@ debug-version:
@echo "GIT_TAG: $(GIT_TAG)"
@echo "VERSION: $(VERSION)"
.PHONY: debug-version

## build-multiplexer: Build the multiplexer binary.
build-multiplexer:
@echo "--> Building celestia-app/multiplexer and outputting binary to build/multiplexer"
@mkdir -p build/
@cd ./multiplexer && go build -o ../build/multiplexer .
@echo "--> Running multiplexer binary"
@./build/multiplexer
.PHONY: build-multiplexer

## Alias for build-multiplexer
multiplexer: build-multiplexer
.PHONY: multiplexer
20 changes: 15 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ type App struct {
MsgGateKeeper *ante.MsgVersioningGateKeeper
}

// New returns a reference to an uninitialized app. Callers must subsequently
// call app.Info or app.InitChain to initialize the baseapp.
// New returns a reference to an initialized app.
//
// NOTE: upgradeHeightV2 refers specifically to the height that a node will
// upgrade from v1 to v2. It will be deprecated in v3 in place for a dynamically
Expand All @@ -187,7 +186,7 @@ func New(
traceStore io.Writer,
invCheckPeriod uint,
encodingConfig encoding.Config,
upgradeHeightV2 int64,
upgradeHeightV2 int64, // TODO: remove this param
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
Expand Down Expand Up @@ -440,6 +439,14 @@ func New(
tmos.Exit(err.Error())
}

// height := app.LastBlockHeight()
// ctx, err := app.CreateQueryContext(height, false)
// if err != nil {
// panic(err)
// }
// app.SetAppVersion(ctx, v3)
// app.mountKeysAndInit(3)

return app
}

Expand Down Expand Up @@ -516,8 +523,6 @@ func (app *App) migrateModules(ctx sdk.Context, fromVersion, toVersion uint64) e
// Info implements the ABCI interface. This method is a wrapper around baseapp's
// Info command so that it can take the app version and setup the multicommit
// store.
//
// Side-effect: calls baseapp.Init()
func (app *App) Info(req abci.RequestInfo) abci.ResponseInfo {
if height := app.LastBlockHeight(); height > 0 {
ctx, err := app.CreateQueryContext(height, false)
Expand Down Expand Up @@ -549,6 +554,7 @@ func (app *App) Info(req abci.RequestInfo) abci.ResponseInfo {
// store.
//
// Side-effect: calls baseapp.Init()
// TODO: refactor this method because it no longer needs to support initializing a chain with an app version that isn't 3.
func (app *App) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) {
req = setDefaultAppVersion(req)
appVersion := req.ConsensusParams.Version.AppVersion
Expand Down Expand Up @@ -804,6 +810,10 @@ func (app *App) InitializeAppVersion(ctx sdk.Context) {
}
}

func (app *App) RunMigrations() []byte {
return []byte{}
}

// OfferSnapshot is a wrapper around the baseapp's OfferSnapshot method. It is
// needed to mount stores for the appropriate app version.
func (app *App) OfferSnapshot(req abci.RequestOfferSnapshot) abci.ResponseOfferSnapshot {
Expand Down
14 changes: 8 additions & 6 deletions app/sdk_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package app
import sdk "github.com/cosmos/cosmos-sdk/types"

func init() {
setCosmosSDKConfig()
maybeSetCosmosSDKConfig()
}

func setCosmosSDKConfig() {
func maybeSetCosmosSDKConfig() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
config.Seal()
if !config.IsSealed() {
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
config.Seal()
}
}
2 changes: 1 addition & 1 deletion app/sdk_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)

func Test_setCosmosSDKConfig(t *testing.T) {
func Test_maybeSetCosmosSDKConfig(t *testing.T) {
config := sdk.GetConfig()
assert.Equal(t, Bech32PrefixAccAddr, config.GetBech32AccountAddrPrefix())
assert.Equal(t, Bech32PrefixAccPub, config.GetBech32AccountPubPrefix())
Expand Down
5 changes: 2 additions & 3 deletions x/minfee/grpc_query_test.go → app/test/query_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package minfee_test
package app_test

import (
"testing"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
testutil "github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -24,5 +23,5 @@ func TestQueryNetworkMinGasPrice(t *testing.T) {
require.NoError(t, err)

// Check the response
require.Equal(t, appconsts.DefaultNetworkMinGasPrice, resp.NetworkMinGasPrice.MustFloat64())
require.Equal(t, minfee.DefaultNetworkMinGasPriceAsDec(), resp.NetworkMinGasPrice)
}
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/celestiaorg/blobstream-contracts/v3 v3.1.0
github.com/celestiaorg/celestia-app/v3/x/minfee v0.0.0
github.com/celestiaorg/go-square v1.1.1
github.com/celestiaorg/go-square/v2 v2.0.0
github.com/celestiaorg/knuu v0.16.1
Expand All @@ -32,7 +33,7 @@ require (
github.com/tendermint/tendermint v0.34.29
github.com/tendermint/tm-db v0.6.7
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -183,7 +184,7 @@ require (
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
Expand Down Expand Up @@ -237,7 +238,7 @@ require (
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -254,6 +255,8 @@ require (
)

replace (
// Replace this import until there's an official release of x/minfee
github.com/celestiaorg/celestia-app/v3/x/minfee => ./x/minfee
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.25.0-sdk-v0.46.16
// Pin to ledger-cosmos-go v0.12.4 to avoid a breaking change introduced in v0.13.0
// The following replace statement can be removed when we upgrade to cosmos-sdk >= v0.50.0
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,6 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
Expand Down Expand Up @@ -1622,7 +1620,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -1756,7 +1753,6 @@ golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
Expand Down Expand Up @@ -1953,10 +1949,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
98 changes: 98 additions & 0 deletions multiplexer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package cmd

import (
"context"
"fmt"
"os"
"path/filepath"

"github.com/celestiaorg/celestia-app/multiplexer/utils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/log"
tmdb "github.com/tendermint/tm-db"
)

var cfgFile string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "node",
RunE: func(cmd *cobra.Command, args []string) error {
config := utils.GetConfig()
fmt.Printf("Deleting root dir: %v\n", config.TmConfig.RootDir)
os.RemoveAll(config.TmConfig.RootDir)

logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
dbPath := filepath.Join(config.TmConfig.RootDir, "data")
fmt.Printf("dbPath: %v\n", dbPath)
db, err := tmdb.NewGoLevelDB("application", dbPath)
if err != nil {
return err
}
multiplexer := utils.NewMultiplexer(logger, db)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

cctx, cleanup, err := utils.StartNode(ctx, config, multiplexer)
defer cleanup()
if err != nil {
fmt.Printf("failed to start node: %v\n", err)
return err
}
err = cctx.WaitForNextBlock()
if err != nil {
fmt.Printf("waiting for next block failed: %v\n", err)
}
cctx.WaitForHeight(15)
return nil
},
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
cobra.OnInitialize(initConfig)

// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.node.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory with name ".node" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".node")
}

viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}
Loading
Loading