ExocoreNetwork / exocore

5 stars 9 forks source link

feat(dogfood): implement `ExportGenesis` #95

Closed MaxMustermann2 closed 2 weeks ago

MaxMustermann2 commented 3 weeks ago

GenesisState defines the dogfood module's genesis state. Note that, as always, genesis is a misnomer. Ideally, this state can be exported at any point in time (or height), and reimported elsewhere where it will be the new genesis potentially at a non-zero height. In other words, it is the entire, current, state of the module.

The state consists of the following items.

For convenience:

Other changes:

Summary by CodeRabbit

coderabbitai[bot] commented 3 weeks ago

Walkthrough

This update predominantly involves upgrading the Go version from 1.21.9 to 1.21.11 across multiple configurations including GitHub workflows, Dockerfiles, and Go modules. Additionally, significant changes were made to the dogfood package to update the genesis state handling and validation mechanisms, introduce new fields, and improve logic for handling validator sets and epochs.

Changes

File(s) Change Summary
.github/workflows/... Updated Go version from 1.21.9 to 1.21.11. Modified conditional logic in several workflows to disable certain jobs.
.golangci.yml, Dockerfile, Makefile, go.mod Updated Go version to 1.21.11 in various configuration files.
app/ethtest_helper.go, app/test_helpers.go, cmd/exocored/testnet.go Added cosmossdk.io/math import and initialized new slices for epoch-related data.
app/export.go Replaced variable validators with an empty slice of tmtypes.GenesisValidator.
local_node.sh Updated JSON object manipulation keys using jq for dogfood app state.
proto/exocore/dogfood/v1/genesis.proto Renamed fields, added new ones for epoch information. Introduced new messages for storing epoch-related data.
testutil/utils.go Included initialization for additional empty slices and new integer value using math.NewInt(2).
x/delegation/types/keys.go Updated to use sdk.AccAddress instead of string for OperatorAddr. Added comment for TxHash validation.
x/dogfood/keeper/... Introduced new functions, updated validation logic, modified how validator and epoch-related data are handled. Added imports for new types.
x/dogfood/types/genesis.go, x/dogfood/types/genesis_test.go Modified NewGenesis and Validate methods to handle new fields and updated validation logic. Added imports and new entities.

Poem

> O, the code it changes, ebb and flow,
> Upgrading Go to help it grow.
> From `.yml` files to Docker too,
> Renewed in pieces, fresh and new.
> Epochs, validators, slices neat,
> All things aligned, a bug’s defeat.
> With syntax crisp, and logic clear,
> Forward we go, no fear, no tear.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
cloud8little commented 3 weeks ago

Trying to export the latest height, query the validator information before stopping the node, there are two active validators with power 5000,1001. after exporting, there is only one validator in the val_set.

exocored q tendermint-validator-set
block_height: "159864"
total: "2"
validators:
- address: exovalcons18z3p42xn8pjk338upvzp794h02wh7p4t7jj9jx
  proposer_priority: "1268"
  pub_key:
    type: tendermint/PubKeyEd25519
    value: 8PaRnlIsW5fbLIJVv/dD+d/d162fw3ywwWcLSA0PmRQ=
  voting_power: "5000"
- address: exovalcons1fllfq6nj5tc9wu8a82dtqd8axfxva48wzna4pa
  proposer_priority: "-1267"
  pub_key:
    type: tendermint/PubKeyEd25519
    value: XLtFCK0/nB1xExSXEhH5kaxRte3aIXSGaBfWSeNOtpE=
  voting_power: "1001"
    "dogfood": {
      "consensus_addrs_to_prune": [],
      "last_total_power": "6001",
      "opt_out_expiries": [],
      "params": {
        "asset_ids": [
          "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"
        ],
        "epoch_identifier": "hour",
        "epochs_until_unbonded": 7,
        "historical_entries": 10000,
        "max_validators": 100
      },
      "undelegation_maturities": [],
      "val_set": [
        {
          "power": "5000",
          "public_key": "0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914"
        }
      ]
    }
MaxMustermann2 commented 3 weeks ago

Trying to export the latest height, query the validator information before stopping the node, there are two active validators with power 5000,1001. after exporting, there is only one validator in the val_set.

Yes, my bad. I only tested with one operator via ./local_node.sh. Fixed in the latest commit 97723ed by continuing the loop after the first iteration.

MaxMustermann2 commented 2 weeks ago

~The exported genesis is erroneous. I am checking.~

This has now been fixed.

{
  "consensus_addrs_to_prune": [
    {
      "cons_addrs": [
        "exovalcons1vwjcr2h5tfz0nxqnf0aw8dfslzz6nn7m00fjls"
      ],
      "epoch": "12"
    }
  ],
  "last_total_power": "5000",
  "opt_out_expiries": [
    {
      "epoch": "12",
      "operator_acc_addrs": [
        "exo1vwjcr2h5tfz0nxqnf0aw8dfslzz6nn7m4qg6kt"
      ]
    }
  ],
  "params": {
    "asset_ids": [
      "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"
    ],
    "epoch_identifier": "minute",
    "epochs_until_unbonded": 2,
    "historical_entries": 10000,
    "max_validators": 100
  },
  "undelegation_maturities": [
    {
      "epoch": "12",
      "undelegation_record_keys": [
        "0x63a581aaf45a44f998134bfae3b530f885a9cfdb"
      ]
    }
  ],
  "val_set": [
    {
      "power": "5000",
      "public_key": "0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914"
    }
  ]
}
cloud8little commented 2 weeks ago

Test passed (https://github.com/ExocoreNetwork/exocore/pull/95/commits/add0753ede5df98839ddbc9b8f3938093eedc8cf), set epoch as minute and epochs_until_unbonded as 5, after sending opt-out-avs transaction at epoch 176. and export genesis file like:

    "dogfood": {
      "consensus_addrs_to_prune": [
        {
          "cons_addrs": [
            "exovalcons1u8yx7e02wr2yvs5zk3zhvehhekh4vzxde43yra"
          ],
          "epoch": "180"
        }
      ],
      "last_total_power": "5500",
      "opt_out_expiries": [
        {
          "epoch": "180",
          "operator_acc_addrs": [
            "exo1u8yx7e02wr2yvs5zk3zhvehhekh4vzxdr6sv2x"
          ]
        }
      ],
      "params": {
        "asset_ids": [
          "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"
        ],
        "epoch_identifier": "minute",
        "epochs_until_unbonded": 5,
        "historical_entries": 10000,
        "max_validators": 100
      },
      "undelegation_maturities": [
        {
          "epoch": "180",
          "undelegation_record_keys": [
            "0xe1c86f65ea70d4464282b4457666f7cdaf5608cd"
          ]
        }
      ],
      "val_set": [
        {
          "power": "5000",
          "public_key": "0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914"
        },
        {
          "power": "500",
          "public_key": "0x5cbb4508ad3f9c1d711314971211f991ac51b5edda2174866817d649e34eb691"
        }
      ]
    },

after epoch 180, export genesis file like:

  "dogfood": {
      "consensus_addrs_to_prune": [],
      "last_total_power": "5000",
      "opt_out_expiries": [],
      "params": {
        "asset_ids": [
          "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"
        ],
        "epoch_identifier": "minute",
        "epochs_until_unbonded": 5,
        "historical_entries": 10000,
        "max_validators": 100
      },
      "undelegation_maturities": [],
      "val_set": [
        {
          "power": "5000",
          "public_key": "0xf0f6919e522c5b97db2c8255bff743f9dfddd7ad9fc37cb0c1670b480d0f9914"
        }
      ]
    },