Skip to content

Commit

Permalink
fix(faucet): resume after restart (#517)
Browse files Browse the repository at this point in the history
* feat: improve node errors

* docs: update `CHANGELOG.md`

* feat: save/restore faucet state and keypair to/from files

* feat: make faucet account public, request account state on submission error

* feat: introduce `ClientError`

* fix: update config

* fix: save new faucet state to in-memory store after getting from the server

* fix: remove `macros` feature from axum dependency

* docs: update `CHANGELOG.md`

* docs: add comment for `seed` field

Co-authored-by: Mirko <[email protected]>

* fix: log message

Co-authored-by: Mirko <[email protected]>

* refactor: address review comments

* refactor: initial changes

* refactor: impl Send and Sync for FaucetDataStore

* chore: update changelog

* refactor: remove unnecessary async, add warning ignore to makefile

* refactor: update genesis generation, read faucet account from `faucet.mac`, request faucet state on initialization

* feat: faucet account creation

* fix: handling of account not found error

* refactor: use Arc and Mutex

* chore: removed unneeded cast

* fix: lint

* docs: update CHANGELOG.md

* fix: compilation errors

* docs: add `TODO` for incorrect and unsafe `Send` implementation

* refactor: small refactoring

* refactor: address review comments

* docs: update `README.md` for faucet

* docs: improve instructions and clarifications in faucet's `README.md`

---------

Co-authored-by: Mirko <[email protected]>
Co-authored-by: Andrey <[email protected]>
Co-authored-by: Bobbin Threadbare <[email protected]>
  • Loading branch information
4 people authored Oct 30, 2024
1 parent 17a5ca1 commit f541610
Show file tree
Hide file tree
Showing 22 changed files with 437 additions and 310 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
sudo chown -R miden /opt/miden; \
sudo /usr/bin/miden-node init -c /etc/miden/miden-node.toml -g /opt/miden/miden-node/genesis.toml; \
sudo /usr/bin/miden-node make-genesis -i /opt/miden/miden-node/genesis.toml -o /opt/miden/miden-node/genesis.dat --force; \
sudo /usr/bin/miden-faucet init -c /opt/miden/miden-faucet/miden-faucet.toml
sudo /usr/bin/miden-faucet init -c /opt/miden/miden-faucet/miden-faucet.toml -f /opt/miden/miden-node/accounts/faucet.mac
- name: Start miden node service
uses: ./.github/actions/ssm_execute
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [BREAKING] Improved store API errors (return "not found" instead of "internal error" status if requested account(s) not found) (#518).
- [BREAKING] Migrated to v0.11 version of Miden VM (#528).
- Reduce cloning in the store's `apply_block` (#532).
- [BREAKING] Changed faucet storage type in the genesis to public. Using faucet from the genesis for faucet web app. Added support for faucet restarting without blockchain restarting (#517).

## 0.5.1 (2024-09-12)

Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ miden-processor = { git = "https://github.com/0xPolygonMiden/miden-vm.git", bran
miden-stdlib = { git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "next", default-features = false }
miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" }
prost = { version = "0.13" }
rand = { version = "0.8" }
thiserror = { version = "1.0" }
tokio = { version = "1.40", features = ["rt-multi-thread"] }
tokio-stream = { version = "0.1" }
Expand Down
5 changes: 3 additions & 2 deletions bin/faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repository.workspace = true
testing = ["miden-objects/testing", "miden-lib/testing"]

[dependencies]
anyhow = "1.0"
axum = { version = "0.7", features = ["tokio"] }
clap = { version = "4.5", features = ["derive", "string"] }
figment = { version = "0.10", features = ["toml", "env"] }
Expand All @@ -28,12 +29,12 @@ miden-node-utils = { workspace = true }
miden-objects = { workspace = true , features = ["concurrent"] }
miden-tx = { workspace = true, features = ["concurrent"] }
mime = "0.3"
rand = { version = "0.8" }
rand = { workspace = true }
rand_chacha = "0.3"
serde = { version = "1.0", features = ["derive"] }
static-files = "0.2"
thiserror = { workspace = true }
tokio = { workspace = true }
tokio = { workspace = true, features = ["fs"] }
toml = { version = "0.8" }
tonic = { workspace = true }
tower = "0.5"
Expand Down
26 changes: 21 additions & 5 deletions bin/faucet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

This crate contains a binary for running a Miden rollup faucet.

## Running the faucet
1. Run a local node, for example using the docker image. From the "miden-node" repo root run the following commands:
## Running the faucet in testing mode

> [!TIP]
> Miden account generation uses a proof-of-work puzzle to prevent DoS attacks. These puzzles can be quite expensive, especially for test purposes. You can lower the difficulty of the puzzle by appending `--features testing` to the `cargo install ..` invocation.
1. Run a local node with the "testing" feature, for example using the docker image. From the "miden-node" repo root run the following commands:
```bash
make docker-build-node
make docker-run-node
Expand All @@ -14,12 +18,24 @@ make docker-run-node
make install-faucet-testing
```

3. Create the default faucet configuration file:
3. [Optional] Create faucet account (skip this step if you want to use an account from the genesis). This will generate authentication keypair and generate and write public faucet account data with its keypair into the file specified in `output-path`:

```bash
miden-faucet create-faucet-account \
--output-path <path to faucet.mac> \
--token-symbol POL \
--decimals 9 \
--max-supply 1000000000
```
> [!TIP]
> This account will not be created on chain yet, creation on chain will happen on the first minting transaction.
4. Create the default faucet configuration file. Specify the path to the faucet account file created on the previous step in the `-f` flag (if you want to use an account from the genesis, specify the path to the `faucet.mac` file generated by the [make-genesis](../../README.md#setup) command of the Miden node):
```bash
miden-faucet init
miden-faucet init -f <path to faucet.mac>
```

4. Start the faucet server:
5. Start the faucet server:
```bash
miden-faucet start
```
Expand Down
Loading

0 comments on commit f541610

Please sign in to comment.