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

Add StorageKeys derive macro #926

Merged
merged 22 commits into from
Jan 10, 2023
Merged

Conversation

sug0
Copy link
Contributor

@sug0 sug0 commented Dec 19, 2022

Allows us to derive storage key helpers from a struct comprised solely of &'static str fields.

For instance:

#[derive(StorageKeys)]
struct Keys {
  param1: &'static str,
  param2: &'static str,
}

Would generate a VALUES field with param1 set to "param1" and param2 set to "param2". It would also generate a sorted slice ALL, whose contents are "param1" and "param2", which can be used to efficiently match a storage key, with a binary search over ALL.

@juped juped force-pushed the tiago+tomas/main/storage-keys-procmacro branch from 6b1695c to 028924e Compare December 19, 2022 16:46
@juped
Copy link
Member

juped commented Dec 19, 2022

rebased forward because of CI docs pushing issue

macros/src/lib.rs Outdated Show resolved Hide resolved
macros/src/lib.rs Outdated Show resolved Hide resolved
tzemanovic
tzemanovic previously approved these changes Dec 19, 2022
Co-authored-by: Tomas Zemanovic <tomas@heliax.dev>
Co-authored-by: Tomas Zemanovic <tomas@heliax.dev>
@sug0 sug0 requested a review from tzemanovic December 20, 2022 09:21
Copy link
Member

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

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

You need to add unit tests. I made a PR with a happy flow unit test. But obviously many unhappy flows should be checked. Parameters with the same name, types other than &'static string, etc.

macros/src/lib.rs Show resolved Hide resolved
macros/src/lib.rs Outdated Show resolved Hide resolved
macros/src/lib.rs Outdated Show resolved Hide resolved
@sug0 sug0 marked this pull request as draft December 20, 2022 11:21
@sug0
Copy link
Contributor Author

sug0 commented Dec 20, 2022

For reference, added changes from #937

macros/src/lib.rs Outdated Show resolved Hide resolved
@sug0 sug0 force-pushed the tiago+tomas/main/storage-keys-procmacro branch from 3ea7feb to fe53976 Compare December 20, 2022 14:27
tzemanovic
tzemanovic previously approved these changes Dec 20, 2022
batconjurer
batconjurer previously approved these changes Dec 20, 2022
tzemanovic
tzemanovic previously approved these changes Dec 20, 2022
@juped
Copy link
Member

juped commented Dec 21, 2022

pls update wasm

@juped juped dismissed stale reviews from tzemanovic and batconjurer via 73c686d December 21, 2022 14:08
@tzemanovic
Copy link
Member

@brentstone there's some test_tx_change_validator_commissions case failing in https://github.com/anoma/namada/actions/runs/3750000986/jobs/6369272997#step:8:37077, it's got the seed there

@tzemanovic tzemanovic mentioned this pull request Dec 23, 2022
8 tasks
@brentstone
Copy link
Contributor

brentstone commented Dec 26, 2022

@brentstone there's some test_tx_change_validator_commissions case failing in https://github.com/anoma/namada/actions/runs/3750000986/jobs/6369272997#step:8:37077, it's got the seed there

See #965

@tzemanovic
Copy link
Member

@brentstone there's some test_tx_change_validator_commissions case failing in https://github.com/anoma/namada/actions/runs/3750000986/jobs/6369272997#step:8:37077, it's got the seed there

fixed in #965

tzemanovic
tzemanovic previously approved these changes Dec 27, 2022
@tzemanovic tzemanovic mentioned this pull request Dec 30, 2022
@juped juped force-pushed the tiago+tomas/main/storage-keys-procmacro branch from c5cc2f5 to 704b175 Compare January 10, 2023 07:13
…tomas/main/storage-keys-procmacro

This branch surfaced a bug in a wasm test. Merge the fix to pass tests
on this branch.

* brent/fix-validator-commission-change-test:
  wasm: update checksums.json
  changelog: add #965
  remove `ChangeIsZero` error
  remove dbg statements
  fix arb rate: prevent same rate and ensure proper bounds
@juped juped merged commit 4d3440a into main Jan 10, 2023
@juped juped deleted the tiago+tomas/main/storage-keys-procmacro branch January 10, 2023 07:43
juped added a commit that referenced this pull request Jan 11, 2023
Namada 0.13.0

* tag 'v0.13.0': (166 commits)
  Namada 0.13.0
  finalize_block: remove unused import
  misc: change log level
  misc: change log level
  chore: missing file
  ledger: add some blocks statistics logs
  changelog: add #972
  chore: clippy/fmt
  ledger: remove/changed some logs
  ledger: use genesis fees
  genesis: added parameter to control wrapper tx fees amount
  wasm: update checksums.json
  changelog: add #969
  test/e2e: add a case to withdraw from PoW faucet
  client/tx and signing: add wrapper signer balance check and add PoW
  ledger/queries/vp: add testnet pow and faucet methods
  wasm/vp_testnet_faucet: check PoW, use withdrawal_limit set in storage
  expose the `has_valid_pow` result via VP wasm host env
  validate PoW in mempool, proposal and finalize and keep the result
  shell/init_chain: init faucet storage, if used
  add `faucet_account` parameter and set it from `init_chain` if found
  genesis: add faucet_pow_difficulty and faucet_withdrawal_limit
  add "mainnet" feature flag, off by default for now
  storage_api/lazy_map: export `get_data_key` fn for client
  core/ledger: add testnet_pow module
  re-export `namada` from `namada_tests` for `namada_core` dev-deps
  changelog: add #903
  changelog: add #975
  wasm: update checksums.json
  Fix consensus params config for ABCI++
  wasm: update checksums.json
  Remove boilerplate code in favor of StorageKeys macro
  Update Cargo deps
  Define Keys struct with all ledger param key types
  Fix #882
  changelog: add #926
  changelog: add #974
  changelog: add #973
  wasm: update checksums.json
  Update documentation/docs/src/user-guide/ibc.md
  added ibc docs and new favicon
  Update README.md
  Update README.md
  changelog: add #965
  remove `ChangeIsZero` error
  remove dbg statements
  fix arb rate: prevent same rate and ensure proper bounds
  Revert "Merge pull request #965 from anoma/brent/fix-validator-commission-change-test"
  ci: fix e2e test script
  Reduces block size to 5 MiB
  Add `max_proposal_bytes` ledger param
  Moves ledger sleep
  Refactors ledger sleep
  Adds start time argument to namada ledger
  Update README.md
  Adds  const and default token to basic fee
  changelog: add #968
  add `NAMADA_LOG_FMT` env var with one of: full (default), json or pretty
  [ci] wasm checksums update
  core/storage: remove redundant `StorageWrite` impl for mut ref
  changelog: #966
  core/storage_api: use GATs to hide lifetime in StorageRead trait
  changelog: add #962
  changelog: add #965
  remove `ChangeIsZero` error
  remove dbg statements
  fix arb rate: prevent same rate and ensure proper bounds
  Fixes unit tests
  Fixes process proposal fee token
  Fixes fee value in tx contruction
  Adds fee burning and checks
  core/storage/mockDB: remove unused `reverse_order` flag
  Add JSON as an option for logging by env var
  changed to 0.12.2
  ci: install cargo-about after sccache server up
  Namada 0.12.2
  release: cherry-pick release improvements
  changelog: add #952
  prepare_proposal: update comment to reflect hotfix
  prepare_proposal: use TxRecord struct on ABCI++ build
  missed a chain-id addition
  Prioritize wrapper txs during proposal construction
  Hot fix PrepareProposal
  added chain id and fixed install docs
  update pseudocode
  General housekeeping
  Reward distribution: general improvements
  Cubic slashing: general writing improvements
  Cubic slashing: add new improved pseudocode blurb (Rust-style)
  Cubic slashing: clarify slash iteration procedure and equation
  Cubic slashing: fix and improve plot
  quick fix to cubic slash
  wasm: update checksums.json
  changelog: add #911
  changelog: add #876
  test/core: run less cases on `update_epoch_after_its_duration` test
  Update link to install section
  changelog: add #945
  ci: install cargo-about on release step
  make-package.sh: include license information in tarball
  ...
juped added a commit that referenced this pull request Jan 12, 2023
Namada 0.13.0

* tag 'v0.13.0': (166 commits)
  Namada 0.13.0
  finalize_block: remove unused import
  misc: change log level
  misc: change log level
  chore: missing file
  ledger: add some blocks statistics logs
  changelog: add #972
  chore: clippy/fmt
  ledger: remove/changed some logs
  ledger: use genesis fees
  genesis: added parameter to control wrapper tx fees amount
  wasm: update checksums.json
  changelog: add #969
  test/e2e: add a case to withdraw from PoW faucet
  client/tx and signing: add wrapper signer balance check and add PoW
  ledger/queries/vp: add testnet pow and faucet methods
  wasm/vp_testnet_faucet: check PoW, use withdrawal_limit set in storage
  expose the `has_valid_pow` result via VP wasm host env
  validate PoW in mempool, proposal and finalize and keep the result
  shell/init_chain: init faucet storage, if used
  add `faucet_account` parameter and set it from `init_chain` if found
  genesis: add faucet_pow_difficulty and faucet_withdrawal_limit
  add "mainnet" feature flag, off by default for now
  storage_api/lazy_map: export `get_data_key` fn for client
  core/ledger: add testnet_pow module
  re-export `namada` from `namada_tests` for `namada_core` dev-deps
  changelog: add #903
  changelog: add #975
  wasm: update checksums.json
  Fix consensus params config for ABCI++
  wasm: update checksums.json
  Remove boilerplate code in favor of StorageKeys macro
  Update Cargo deps
  Define Keys struct with all ledger param key types
  Fix #882
  changelog: add #926
  changelog: add #974
  changelog: add #973
  wasm: update checksums.json
  Update documentation/docs/src/user-guide/ibc.md
  added ibc docs and new favicon
  Update README.md
  Update README.md
  changelog: add #965
  remove `ChangeIsZero` error
  remove dbg statements
  fix arb rate: prevent same rate and ensure proper bounds
  Revert "Merge pull request #965 from anoma/brent/fix-validator-commission-change-test"
  ci: fix e2e test script
  Reduces block size to 5 MiB
  Add `max_proposal_bytes` ledger param
  Moves ledger sleep
  Refactors ledger sleep
  Adds start time argument to namada ledger
  Update README.md
  Adds  const and default token to basic fee
  changelog: add #968
  add `NAMADA_LOG_FMT` env var with one of: full (default), json or pretty
  [ci] wasm checksums update
  core/storage: remove redundant `StorageWrite` impl for mut ref
  changelog: #966
  core/storage_api: use GATs to hide lifetime in StorageRead trait
  changelog: add #962
  changelog: add #965
  remove `ChangeIsZero` error
  remove dbg statements
  fix arb rate: prevent same rate and ensure proper bounds
  Fixes unit tests
  Fixes process proposal fee token
  Fixes fee value in tx contruction
  Adds fee burning and checks
  core/storage/mockDB: remove unused `reverse_order` flag
  Add JSON as an option for logging by env var
  changed to 0.12.2
  ci: install cargo-about after sccache server up
  Namada 0.12.2
  release: cherry-pick release improvements
  changelog: add #952
  prepare_proposal: update comment to reflect hotfix
  prepare_proposal: use TxRecord struct on ABCI++ build
  missed a chain-id addition
  Prioritize wrapper txs during proposal construction
  Hot fix PrepareProposal
  added chain id and fixed install docs
  update pseudocode
  General housekeeping
  Reward distribution: general improvements
  Cubic slashing: general writing improvements
  Cubic slashing: add new improved pseudocode blurb (Rust-style)
  Cubic slashing: clarify slash iteration procedure and equation
  Cubic slashing: fix and improve plot
  quick fix to cubic slash
  wasm: update checksums.json
  changelog: add #911
  changelog: add #876
  test/core: run less cases on `update_epoch_after_its_duration` test
  Update link to install section
  changelog: add #945
  ci: install cargo-about on release step
  make-package.sh: include license information in tarball
  ...
bengtlofgren pushed a commit that referenced this pull request May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants