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

PoE state export #50

Closed
alpe opened this issue Jun 4, 2021 · 7 comments · Fixed by #348
Closed

PoE state export #50

alpe opened this issue Jun 4, 2021 · 7 comments · Fixed by #348
Labels
PoE Proof of Engagement

Comments

@alpe
Copy link
Contributor

alpe commented Jun 4, 2021

All modules cosmos-sdk support the state export/ import process where the persistent state data is converted into a json format and used in the (next) genesis file (for a new network) to setup the module again.
Note:

  • there may be in-flight data as unclaimed rewards
  • slashing and signed block data may be obsolete
  • the new validator set may not be the same as the original one
  • typically genesis validators are collected via gentx

What else do we need to export?
Contract state is persisted by wasm but not easy to read/maintain

@alpe alpe added the PoE Proof of Engagement label Aug 3, 2021
@alpe alpe added this to the Tgrade 0.5 milestone Sep 2, 2021
@ethanfrey
Copy link
Contributor

Is this the same as #95 ?

@ethanfrey
Copy link
Contributor

One thought I had was to provide a way to "decode" the state of a contract if we know it is using storage-plus.

We can look at the key to see if it is Item or Map. We can try to parse the keys out and leave the values as json.RawMessage. This could end up like:

[
  {
    "type": "item",
    "name": "config",
    "value": { "some": "value" }
  },
  {
    "type": "map",
    "name": "votes",
    "schema": ["string", "u64"],
    "values": [
       {
          "key": ["cosmos1ckjhefiuhweughewoughuewghekw", 3]
          "value": {"yes": 34}
       },
       {
          "key": ["cosmos1fuewhfiuepofkafjewoighfe", 5]
          "value": {"no": 45}
       }
     ]
  }
]

I'm sure the rust team could help with some tooling like this. And then it would let us introspect all contract state.

One issue is how to store the data for IndexedMaps and SnapshotMaps (although I think Snapshots will be fine to export directly, we would want to rebuild indexes somehow to avoid them being invalid)

@ethanfrey
Copy link
Contributor

@maurolacy curious as to your thoughts on the feasibility of this

@maurolacy
Copy link
Contributor

maurolacy commented Feb 22, 2022

@maurolacy curious as to your thoughts on the feasibility of this

I think that's possible. Our export query entry point will of course need to know about all the state in the contract. And compose the different structs into a big json. Something like a ExportResponse struct, that includes all the state present in the contract?

Also, would this require admin status / checks? I don't think so, as the contract info is public already. Perhaps for preventing denial of service / abuse?

@ethanfrey
Copy link
Contributor

I think having an export query message and a import sudo message could make sense.

When we dump state, we export a contract specific format. And do not export the raw state.
When we import, we instantiate a contract with no data (default x/wasm behavior). Then we call the sudo entry point with import and the previously exported data.

There should be some flag for which contracts have that behavior. It could be a subset (or all) of the contracts created in bootstrap.go

@maurolacy
Copy link
Contributor

@alpe
Copy link
Contributor Author

alpe commented Apr 11, 2022

SDK support an export for zero height: https://github.com/cosmos/cosmos-sdk/blob/v0.45.2/simapp/export.go#L50 . This is disabled in the spike. Let's discuss how we want to tackle this with the PoE contracts or if they do it themselfs

This was referenced Apr 28, 2022
@alpe alpe closed this as completed in #348 May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PoE Proof of Engagement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants