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

Nested case objects cannot use the "name" pragma field #10

Open
mratsim opened this issue Dec 12, 2019 · 0 comments
Open

Nested case objects cannot use the "name" pragma field #10

mratsim opened this issue Dec 12, 2019 · 0 comments

Comments

@mratsim
Copy link

mratsim commented Dec 12, 2019

Test case

import
  confutils/defs

# Nimbus Bench - Scenario configuration
# --------------------------------------------------

type
  StartupCommand* = enum
    noCommand
    cmdFullStateTransition
    cmdSlotProcessing
    cmdBlockProcessing
    cmdEpochProcessing

  BlockProcessingCat* = enum
    catBlockHeader
    catRANDAO
    catEth1Data
    catProposerSlashings
    catAttesterSlashings
    catAttestations
    catDeposits
    catVoluntaryExits

  ScenarioConf* = object
    scenarioDir* {.
      desc: "The directory of your benchmark scenario"
      name: "scenario-dir"
      abbr: "d"
      required .}: InputDir
    preState* {.
      desc: "The name of your pre-state (without .ssz)"
      name: "pre"
      abbr: "p"
      defaultValue: "pre".}: string
    blocksPrefix* {.
      desc: "The prefix of your blocks file, for exemple \"blocks_\" for blocks in the form \"blocks_XX.ssz\""
      name: "blocks-prefix"
      abbr: "b"
      defaultValue: "blocks_".}: string
    blocksQty* {.
      desc: "The number of blocks to process for this transition. Blocks should start at 0."
      name: "block-quantity"
      abbr: "q"
      defaultValue: 1.}: int
    skipBLS*{.
      desc: "Skip BLS public keys and signature verification"
      name: "skip-bls"
      defaultValue: true.}: bool
    case cmd*{.
      command
      defaultValue: noCommand }: StartupCommand
    of noCommand:
      discard
    of cmdFullStateTransition:
      discard
    of cmdSlotProcessing:
      numSlots* {.
        desc: "The number of slots the pre-state will be advanced by"
        name: "num-slots"
        abbr: "s"
        defaultValue: 1.}: uint64
    of cmdBlockProcessing:
      case blockProcessingCat* {.
        desc: "block transitions"
        name: "process-blocks" # Comment this to make it work
        implicitlySelectable
        required .}: BlockProcessingCat
      of catBlockHeader:
        discard
      of catRANDAO:
        discard
      of catEth1Data:
        discard
      of catProposerSlashings:
        discard
      of catAttesterSlashings:
        discard
      of catAttestations:
        # discard
        # Or comment out the attestation below
        attestation*{.
          desc: "Attestation filename (without .ssz)"
          name: "attestation".}: string
      of catDeposits:
        discard
      of catVoluntaryExits:
        discard
    of cmdEpochProcessing:
      discard

import confutils
let scenario = ScenarioConf.load()

I can't rename cmdBlockProcessing to --process-blocks otherwise the compiler returns Error: Unable to find blockProcessingCat.

Tracing findOpt gives the following:

(name: "cmd", abbr: "", desc: "", typename: "StartupCommand", idx: 5, hasDefault: true,
 kind: Discriminator, isCommand: true, isImplicitlySelectable: false, subCmds: [
    (name: "noCommand", opts: [], shortHelpString: ""),
    (name: "cmdFullStateTransition", opts: [], shortHelpString: ""),
    (name: "cmdSlotProcessing", opts: [], shortHelpString: ""),
    (name: "cmdBlockProcessing", opts: [], shortHelpString: ""),
    (name: "cmdEpochProcessing", opts: [], shortHelpString: "")], defaultSubCmd: 0)
(name: "cmd", abbr: "", desc: "", typename: "StartupCommand", idx: 5, hasDefault: true,
 kind: Discriminator, isCommand: true, isImplicitlySelectable: false, subCmds: [
    (name: "noCommand", opts: [], shortHelpString: ""),
    (name: "cmdFullStateTransition", opts: [], shortHelpString: ""), (
    name: "cmdSlotProcessing", opts: [(name: "num-slots", abbr: "s", desc: "The number of slots the pre-state will be advanced by",
                                    typename: "uint64", idx: 6, hasDefault: true,
                                    kind: CliSwitch, isCommand: false,
                                    isImplicitlySelectable: false, subCmds: [],
                                    defaultSubCmd: 0)], shortHelpString: ""),
    (name: "cmdBlockProcessing", opts: [], shortHelpString: ""),
    (name: "cmdEpochProcessing", opts: [], shortHelpString: "")], defaultSubCmd: 0)
(name: "cmd", abbr: "", desc: "", typename: "StartupCommand", idx: 5, hasDefault: true,
 kind: Discriminator, isCommand: true, isImplicitlySelectable: false, subCmds: [
    (name: "noCommand", opts: [], shortHelpString: ""),
    (name: "cmdFullStateTransition", opts: [], shortHelpString: ""), (
    name: "cmdSlotProcessing", opts: [(name: "num-slots", abbr: "s", desc: "The number of slots the pre-state will be advanced by",
                                    typename: "uint64", idx: 6, hasDefault: true,
                                    kind: CliSwitch, isCommand: false,
                                    isImplicitlySelectable: false, subCmds: [],
                                    defaultSubCmd: 0)], shortHelpString: ""), (
    name: "cmdBlockProcessing", opts: [(name: "process-blocks", abbr: "",
                                     desc: "block transitions",
                                     typename: "BlockProcessingCat", idx: 7,
                                     hasDefault: false, kind: Discriminator,
                                     isCommand: false,
                                     isImplicitlySelectable: true, subCmds: [
    (name: "catBlockHeader", opts: [], shortHelpString: ""),
    (name: "catRANDAO", opts: [], shortHelpString: ""),
    (name: "catEth1Data", opts: [], shortHelpString: ""),
    (name: "catProposerSlashings", opts: [], shortHelpString: ""),
    (name: "catAttesterSlashings", opts: [], shortHelpString: ""),
    (name: "catAttestations", opts: [], shortHelpString: ""),
    (name: "catDeposits", opts: [], shortHelpString: ""),
    (name: "catVoluntaryExits", opts: [], shortHelpString: "")], defaultSubCmd: -1)],
    shortHelpString: ""),
    (name: "cmdEpochProcessing", opts: [], shortHelpString: "")], defaultSubCmd: 0)
(name: "process-blocks", abbr: "", desc: "block transitions",
 typename: "BlockProcessingCat", idx: 7, hasDefault: false, kind: Discriminator,
 isCommand: false, isImplicitlySelectable: true, subCmds: [
    (name: "catBlockHeader", opts: [], shortHelpString: ""),
    (name: "catRANDAO", opts: [], shortHelpString: ""),
    (name: "catEth1Data", opts: [], shortHelpString: ""),
    (name: "catProposerSlashings", opts: [], shortHelpString: ""),
    (name: "catAttesterSlashings", opts: [], shortHelpString: ""),
    (name: "catAttestations", opts: [], shortHelpString: ""),
    (name: "catDeposits", opts: [], shortHelpString: ""),
    (name: "catVoluntaryExits", opts: [], shortHelpString: "")], defaultSubCmd: -1)

So maybe a fieldName or originalName need to be kept around.

mratsim added a commit to status-im/nimbus-eth2 that referenced this issue Dec 20, 2019
* nbench PoC

* Remove the yaml files from the example scenarios

* update README with current status

* Add an alternative implementation that uses defer

* Forgot to add the old proc body

* slots-processing

* allow benching state_transition failures

* Add Attestations processing (workaround confutils bug:
- status-im/nim-confutils#10
- status-im/nim-confutils#11
- status-im/nim-confutils#12

* Add CLI command in the readme

* Filter report and add notes about CPU cycles

* Report averages

* Add debugecho style time/cycle print

* Report when we skip BLS and state root verification

* Update to 0.9.3

* Generalize scenario parsing

* Support all block processing scenarios

* parallel bench runner PoC

* gitBetter load issues reporting (the load issues were invalid signature and expected to fail)
zah pushed a commit to status-im/nimbus-eth2 that referenced this issue Jan 6, 2020
* nbench PoC

* Remove the yaml files from the example scenarios

* update README with current status

* Add an alternative implementation that uses defer

* Forgot to add the old proc body

* slots-processing

* allow benching state_transition failures

* Add Attestations processing (workaround confutils bug:
- status-im/nim-confutils#10
- status-im/nim-confutils#11
- status-im/nim-confutils#12

* Add CLI command in the readme

* Filter report and add notes about CPU cycles

* Report averages

* Add debugecho style time/cycle print

* Report when we skip BLS and state root verification

* Update to 0.9.3

* Generalize scenario parsing

* Support all block processing scenarios

* parallel bench runner PoC

* gitBetter load issues reporting (the load issues were invalid signature and expected to fail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant