-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Morse->Shannon Migration] state export/import - collect accounts #1039
base: scaffold/migration-module
Are you sure you want to change the base?
[Morse->Shannon Migration] state export/import - collect accounts #1039
Conversation
f648aa5
to
e35ca54
Compare
12a072c
to
900c66b
Compare
(gogoproto.jsontag) = "jailed", | ||
(gogoproto.moretags) = "yaml:\"jailed\""]; | ||
int32 status = 4 [ | ||
(gogoproto.jsontag) = "status", | ||
(gogoproto.moretags) = "yaml:\"status\""]; | ||
string staked_tokens = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Reviewer do we need to consider these fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but add the same qualifiers you have elsewhere. E.g. [(gogoproto.jsontag) = "tokens"];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my highlighting was off, I meant to call out jailed
and status
. If we do need these, what role should they play in the migration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the json option, will add. 👍 It needs to be staked_tokens
though as this structure is derived from the Morse export data structure (Morse proto types).
3515058
to
20aa71d
Compare
cmd/poktrolld/cmd/migrate/migrate.go
Outdated
// transformMorseState consolidates the Morse account balance, application stake, | ||
// and supplier stake for each account as an entry in the resulting MorseAccountState. | ||
// | ||
// TODO_IN_THIS_COMMIT: benchmark and consider at what point (i.e. number of accounts) does asynchronous import processing matter? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subsequent observations seem to indicate that performance actually seems to degrade with concurrency.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at the number of accounts, apps, and suppliers on Morse mainnet; based on this information I don't think it's worthwhile to spend any effort on optimization/parallization here:
object | count |
---|---|
accounts | 56808 |
apps | 2298 |
suppliers | 13269 |
$ curl -X POST https://pocket-rpc.liquify.com/v1/query/accounts -d '{"page":1,"per_page":100000}' -o ./morse_accounts.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6671k 0 6671k 100 28 2788k 11 0:00:02 0:00:02 --:--:-- 2790k
$ jq ".result|length" ./morse_accounts.json
56808
# curl -X POST https://pocket-rpc.liquify.com/v1/query/apps -d '{"opts": {"page":1,"per_page":100000}}' -o ./morse_apps.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600k 0 600k 100 38 1331k 84 --:--:-- --:--:-- --:--:-- 1333k
$ jq ".result|length" ./morse_apps.json
2298
$ curl -X POST https://pocket-rpc.liquify.com/v1/query/nodes -d '{"opts": {"page":1,"per_page":100000}}' -o ./morse_suppliers.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6172k 0 6172k 100 38 5039k 31 0:00:01 0:00:01 --:--:-- 5043k
$ jq ".result|length" ./morse_suppliers.json
13269
08b72b7
to
b19a003
Compare
b19a003
to
890d5b5
Compare
@@ -0,0 +1,191 @@ | |||
package migrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is all new code, let's use autocli instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AutoCLI does not apply here because there is not gRPC service, message, or query.
The purpose of this command is to facilitate the deterministic (i.e. reproducible) transformation from the Morse export data structure (MorseStateExport
) into the Shannon import data structure (MorseAccountState
). It does not interact with the network directly.
@@ -0,0 +1,42 @@ | |||
syntax = "proto3"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to morse.proto
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale here was that we depend on multiple types from Morse that can be divided into two categories:
- Those which MUST be persisted on-chain in Shannon
- Those which are only required for the export/import state transform CLI command.
Given these categories, both of which I would characterize as "morse". I chose to go with "types.proto" for the on-chain types, for consistency with other modules, and then chose "legacy" for the other types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further reflection, I've realized that the ONLY types that are needed on-chain in Shannon are MorseAccountState
, MorseAccount
, and MorsePublicKey
. I've moved MorseApplication
and MorseValidator
to legacy.proto reflect this.
message MorseStateExport { | ||
string app_hash = 1 [(gogoproto.jsontag) = "app_hash"]; | ||
MorseAppState app_state = 2 [(gogoproto.jsontag) = "app_state"]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message MorseStateExport { | |
string app_hash = 1 [(gogoproto.jsontag) = "app_hash"]; | |
MorseAppState app_state = 2 [(gogoproto.jsontag) = "app_state"]; | |
} | |
// < Provide a description > | |
// < Prove an example command > | |
message MorseStateExport { | |
// app_hash is a hash of ??? | |
string app_hash = 1 [(gogoproto.jsontag) = "app_hash"]; | |
// app_state is < ... > | |
// It can be retrieved via < ... > | |
MorseAppState app_state = 2 [(gogoproto.jsontag) = "app_state"]; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types need a lot more comments because of how important it is.
E.g. I don't know if app_hash
is a hash of app_state
or the entire app_hash
directly from pocket-core
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MorseStateExport
is not a data structure which I designed, it is the result of the pocket util export-genesis-for-reset
command.
I will #PUC, but after thinking about it, I think the purpose of app_hash
here (which is the Morse tendermint state hash - at the time of export) is to be included in the MorseAccountState#state_hash
hash result (i.e. app_state
is part of the input), which is used to verify it.
message MorseAppState { | ||
MorseApplications application = 1 [(gogoproto.jsontag) = "application"]; | ||
MorseAuth auth = 2 [(gogoproto.jsontag) = "auth"]; | ||
MorsePos pos = 3 [(gogoproto.jsontag) = "pos"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#PUC
- Is this for
validators
? - Why not rename to `validators?
- Provide examples of how to query it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this structure a a result of tendermint convention, I'm assuming that pos
is an acronym for "proof of stake".
MorseStateExport is not a data structure which I designed, it is the result of the pocket util export-genesis-for-reset command.
(see: #1039 (comment))
|
||
coins := exportAccount.Value.Coins | ||
if len(coins) == 0 { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log on this error. Should it ever actually happen?
continue | ||
} | ||
|
||
addr := exportAccount.Value.Address.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/addr/morseAddr
} | ||
|
||
// DEV_NOTE: SHOULD ONLY be one denom (upokt). | ||
coin := coins[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you assert that it's exactly one?
for _, exportApplication := range inputState.AppState.Application.Applications { | ||
addr := exportApplication.Address.String() | ||
|
||
// DEV_NOTE: An account SHOULD exist for each actor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log if not
|
||
// DEV_NOTE: An account SHOULD exist for each actor. | ||
if !morseWorkspace.hasAccount(addr) { | ||
// TODO_IN_THIS_COMMIT: consolidate error types... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it
Summary
Add
poktrolld migrate collect-morse-accounts
command to convert Morse state export into aMorseAccountState
for import into Shannon.Issue
Type of change
Select one or more from the following:
consensus-breaking
label if so. See [Infra] Automatically add theconsensus-breaking
label #791 for detailsTesting
make docusaurus_start
; only needed if you make doc changesmake go_develop_and_test
make test_e2e
devnet-test-e2e
label to the PR.Sanity Checklist