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

chore: epoch handle staking msg server #436

Merged
merged 133 commits into from
Jan 31, 2025

Conversation

RafilxTenfen
Copy link
Contributor

@RafilxTenfen RafilxTenfen commented Jan 22, 2025

  • Removed x/staking msgs from router
  • Add msg server from x/staking to epoch keeper to call the necessary functions directly instead of from the router
  • Add MsgWrappedEditValidator and MsgWrappedStakingUpdateParams to epoching txs so all the msgs from staking can be called even with the router removed
  • Removed x/staking tx subcommand

SebastianElvis and others added 30 commits July 4, 2024 15:42
* Add chain register struct
* Add chain registry
* Add chain registry test
* Add chain registry queries
* Add chain registry queries tests
* Add register chain msg
* Add register chain msg routing / impl
* Update proto/babylon/zoneconcierge/v1/tx.proto
* Flatten chain register proto
* Remove authority from register chain msg
* Add chain not registered check
* Add chain already registered check
* Update / fix comment
* Add registry related queries to rpc server
* Fix indentation
* Fix: Add signer field to register chain msg
* Fix: Own / unique query param / response for list registry
* Move btcstkconsumer proto files under v1/ for consistency
* Move register chain protos from zoneconcierge to btcstkconsumer
* Refactor chain registry into btcstkconsumer
* Fix: proto / code lints
* Pass chain register pointer

Co-authored-by: Runchao Han <[email protected]>
* Register zoneconcierge msg codecs
* Register btcstkconsumer msg codecs
* Add chain id to finality provider
* Add finality provider registry
* Update fps per chain id registry
* Remove commented line
* FP registers only non-canonical chains
* Add FP registry test
* Add registered chain check
* Add registration check to fp registry test
* Remove optional from chain id
* Add own CZ chains FPs store
* Store CZ chains FPs in their own store
* Adjust names / tests
* Refactor fp consumer registry
* Adapt tests
* Rename for clarity
* Add FP CZ chains registry queries
* Add FP consumer query tests
* Adapt test
* Add chain id to fp query response
* Remove useless slash condition check
* Improve error msg
* Move type builder to types package
* Add chains per FP BTC PubKey store
* Ensure CZ chains FP does not already exist
* Fix: Return err explicitly instead of nil
* Fix typos
* Add register chain cli tx
* Add chain id to btcstaking create-finality-provider
* Add get finality provider by chain queries
* Add registered chains cli queries
* Add FZ FP chain id query type
* Add get CZ FP chain getter / query
* Add grpc query. Adjust grpc query paths
* Add CZ FP registered chain cli query cmd
* Fix: Add tx flags for register chain cmd
* Turn consumer chain id into a flag instead of a param
* Fix params module import
* Add hook to query consumer fps through btcstaking
* Rename consumer keys for clarity
* Rename btc staking consumer methods
* Rename consumer delegation private methods
* Move consumer delegations to btcstaking
* Refactor BTC delegations into one store
* Simplify logic
* Improve comments
* Add needed (for babylon as Consumer) staking capability
* Upgrade contracts from latest babylon-contract
* Support Mac arm64 arch in passing for copy local wasm
* Fix: FP fields protobuf sequence numbers
* Update contracts to latest
* Fix: make proto-gen
* Trim unused fields from new finality provider IBC msg
* Update protobuf gens
* Update code refs
@@ -412,7 +412,7 @@ func (ak *AppKeepers) InitKeepers(
appparams.AccGov.String(),
)

wasmOpts = append(owasm.RegisterCustomPlugins(&ak.EpochingKeeper, &ak.CheckpointingKeeper, &ak.BTCLightClientKeeper, &ak.ZoneConciergeKeeper), wasmOpts...)
wasmOpts = append(owasm.RegisterCustomPlugins(&epochingKeeper, &ak.CheckpointingKeeper, &ak.BTCLightClientKeeper, &ak.ZoneConciergeKeeper), wasmOpts...)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ak.EpochingKeeper was not set yet

@@ -97,7 +97,7 @@ func FuzzHandleQueuedMsg_MsgWrappedDelegate(f *testing.F) {
require.Equal(t, uint64(0), lc.ValLife[0].BlockHeight)

// delegate a random amount of tokens to the validator
numNewDels := r.Int63n(1000) + 1
numNewDels := r.Int63n(15) + 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if left as 1k new dels it breaks the cosmos-sdk/types.TypedEventToEvent to parse the event, was not able to find the root of the issue

goroutine 41 [chan receive, 1 minutes]:
testing.(*F).Fuzz.func1({0x507ab20, 0xc0018a5c00}, {{0x0, 0x0}, {0xc0006d9420, 0x6}, {0x0, 0x0, 0x0}, {0xc000f98c20, ...}, ...})
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/testing/fuzz.go:337 +0x58a
testing.(*F).Fuzz(0xc0018a5c00, {0x316d8a0, 0x4bfe638})
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/testing/fuzz.go:402 +0xab7
github.com/babylonlabs-io/babylon/x/epoching/keeper_test.FuzzHandleQueuedMsg_MsgWrappedDelegate(0xc0018a5c00)
	/home/rafilx/projects/github.com/babylonlabs-io/babylon/x/epoching/keeper/epoch_msg_queue_test.go:67 +0x35
testing.fRunner(0xc0018a5c00, 0x4bfe490)
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/testing/fuzz.go:724 +0xb9
created by testing.runFuzzTests in goroutine 1
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/testing/fuzz.go:527 +0x838

goroutine 42 [runnable]:
encoding/json.stateInStringEsc(0xc06c9f4388, 0x5c?)
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/encoding/json/scanner.go:353 +0x1a5
encoding/json.checkValid({0xc1bb52a000, 0x7ef6, 0x8?}, 0xc06c9f4388)
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/encoding/json/scanner.go:35 +0x9d
encoding/json.Unmarshal({0xc1bb52a000, 0x7ef6, 0x8000}, {0x30eaae0, 0xc0017af498})
	/home/rafilx/go/pkg/mod/golang.org/[email protected]/src/encoding/json/decode.go:102 +0x54
github.com/cosmos/cosmos-sdk/types.TypedEventToEvent({0x5096970, 0xc06c1dd200})
	/home/rafilx/go/pkg/mod/github.com/cosmos/[email protected]/types/events.go:97 +0xc5
github.com/cosmos/cosmos-sdk/types.(*EventManager).EmitTypedEvent(0xc001eb51a0, {0x5096970?, 0xc06c1dd200?})
	/home/rafilx/go/pkg/mod/github.com/cosmos/[email protected]/types/events.go:64 +0x3d
github.com/babylonlabs-io/babylon/x/epoching.EndBlocker({0x50bed48, 0xc0021a7188}, {{0x50dd160, 0xc001200950}, {0x507b180, 0xc000fb01d8}, {0x50abcd0, 0xc000719878}, {0x5090f28, 0xc000778508}, ...})
	/home/rafilx/projects/github.com/babylonlabs-io/babylon/x/epoching/abci.go:116 +0x9ee

@RafilxTenfen RafilxTenfen added the consensus breaking change modifies `appHash` of the application label Jan 28, 2025

// RegisterStakingQueryAndMigrations registrates in the configurator
// the x/staking query server and its migrations
func (app *BabylonApp) RegisterStakingQueryAndMigrations() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to register the staking migrations, so every new migration in https://github.com/cosmos/cosmos-sdk/blob/32969cf7cc602bb380f78dee23f0f0a747728791/x/staking/module.go#L141 we need to apply here as well

Copy link
Member

@SebastianElvis SebastianElvis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still parsing the whole thing, some initial comments

x/epoching/keeper/msg_server.go Show resolved Hide resolved
x/epoching/keeper/msg_server.go Show resolved Hide resolved
x/epoching/keeper/keeper.go Show resolved Hide resolved
x/epoching/keeper/epoch_msg_queue.go Show resolved Hide resolved
x/epoching/types/msg.go Show resolved Hide resolved
Copy link
Member

@SebastianElvis SebastianElvis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

app/app_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@KonradStaniec KonradStaniec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! great job figuring it out

app/app.go Show resolved Hide resolved
@KonradStaniec KonradStaniec added the api breaking breaks grpc api in non-compatible way label Jan 31, 2025
@RafilxTenfen RafilxTenfen merged commit e067fc4 into feat/rmv-stk-msg-server Jan 31, 2025
23 checks passed
@RafilxTenfen RafilxTenfen deleted the rafilx/epoch-stk-msg-srvr branch January 31, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api breaking breaks grpc api in non-compatible way consensus breaking change modifies `appHash` of the application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants