Skip to content

Conversation

@tzemanovic
Copy link
Collaborator

@tzemanovic tzemanovic commented Dec 30, 2022

This is alternative approach to #961, re-using most of the logic from faucet_pow module, but instead of adding a special tx for faucet withdrawal (the inner tx) to be executed and checked as an inner tx, we add an option PoW field to the WrapperTx (#[cfg(not(feature = "mainnet"))] pow_solution: Option<crate::ledger::testnet_pow::Solution>). This is needed because the fee needs to be checked in the mempool at which point we don't have access to the inner tx.

  • added "mainnet" feature (with make check-mainnet, make clippy-mainnet and make test-unit-mainnet) - for the "mainnet" build, the WrapperTx doesn't contain the pow_solution field)
  • added a check to client/signing sign_wrapper that the address derived from wrapper tx PK has enough balance to pay the minimum tx fee (100 namnam)
  • only in cfg!(not(feature = "mainnet")):
    • added faucet_pow_difficulty (optional, defaults 0 PoW difficulty if not set) and faucet_withdrawal_limit (optional, defaults 1000 NAM) fields to genesis
    • when a tx is withdrawal from faucet, the client automatically requests PoW challenge, attempts to find a solution and attach it to the wrapper tx
    • when an address derived from wrapper tx PK doesn't have enough balance to pay for the tx fee (100 namnam), it will also automatically request PoW challenge, attempt to find a solution and attach it to the wrapper tx
    • added faucet_account to ledger::Parameters - this is set in init_chain when a faucet account is detected in genesis

closes #959

depends on #926 for storage keys macro, #966 for avoiding lifetime issues and #962 for tx fees

first commit from this PR: f7b6378

This is a breaking change for client - to be able to withdraw tokens from faucet without having enough balance in the signing key to cover the minimum tx fee (set in #962 to 100 namnam), client must request PoW challenge from the faucet, solve it and attach it to the wrapper tx (@memasdeligeorgakis - not sure if we want to support faucet withdrawal in the interface, but it will need to do this if so).

This is non-breaking change for genesis as the added faucet_pow_difficulty is optional (defaults to 0 - no challenge), and faucet_withdrawal_limit.

@tzemanovic tzemanovic mentioned this pull request Dec 30, 2022
8 tasks
@tzemanovic tzemanovic added the breaking:client Namada client breaking change label Dec 30, 2022
tzemanovic added a commit that referenced this pull request Dec 30, 2022
@tzemanovic
Copy link
Collaborator Author

pls update wasm

tzemanovic added a commit that referenced this pull request Dec 30, 2022
tzemanovic added a commit to heliaxdev/anoma-network-config that referenced this pull request Dec 30, 2022
@tzemanovic
Copy link
Collaborator Author

pls update wasm

@tzemanovic tzemanovic marked this pull request as ready for review December 30, 2022 15:54
@tzemanovic
Copy link
Collaborator Author

pls spawn devnet [anoma-devnet-faucet-and-fees,3,heliaxdev@1be9883,ON]

@tzemanovic
Copy link
Collaborator Author

pls spawn devnet [anoma-devnet-faucet-and-fees,3,heliaxdev@1be9883,ON]

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2023

Devnet with chain id namada-c5cd6e0.fae2113ec8a6c78 spawned succesfully!

@adrianbrink adrianbrink mentioned this pull request Jan 9, 2023
sug0 and others added 8 commits January 10, 2023 02:55
…s-param' (#975) into main

* namada/tiago/main/max-block-size-genesis-param:
  changelog: add #975
  wasm: update checksums.json
  Fix consensus params config for ABCI++
  Add `max_proposal_bytes` ledger param
* namada/grarco/basic-fee:
  Adds  const and default token to basic fee
  changelog: add #962
  Fixes unit tests
  Fixes process proposal fee token
  Fixes fee value in tx contruction
  Adds fee burning and checks
@juped juped force-pushed the tomas/testnet-pow branch from c5cd6e0 to 5e26b4d Compare January 10, 2023 08:39
@juped juped merged commit 30c2841 into main Jan 10, 2023
@juped juped deleted the tomas/testnet-pow branch January 10, 2023 08:54
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

breaking:client Namada client breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PoW based faucet

5 participants