|
|
6 bulan lalu | |
|---|---|---|
| .. | ||
| .sqlx | 58a72833f2 feat(fortuna): Explorer apis (#2649) | 6 bulan lalu |
| migrations | 58a72833f2 feat(fortuna): Explorer apis (#2649) | 6 bulan lalu |
| src | 0b1a59f63f feat(fortuna): extract RETRY_PREVIOUS_BLOCKS into EthereumConfig (#2713) | 6 bulan lalu |
| .gitignore | cf90bff236 feat(fortuna): support multiple hashchains (#1509) | 1 tahun lalu |
| Cargo.lock | 19e8abbd11 feat(fortuna): better logging + avoid unnecessary fee syncs (#2708) | 6 bulan lalu |
| Cargo.toml | 19e8abbd11 feat(fortuna): better logging + avoid unnecessary fee syncs (#2708) | 6 bulan lalu |
| Dockerfile | ed0f273dcb chore: switch to stable rust versions (#2093) | 1 tahun lalu |
| README.md | 58a72833f2 feat(fortuna): Explorer apis (#2649) | 6 bulan lalu |
| check-sqlx.sh | 58a72833f2 feat(fortuna): Explorer apis (#2649) | 6 bulan lalu |
| config.sample.yaml | 19e8abbd11 feat(fortuna): better logging + avoid unnecessary fee syncs (#2708) | 6 bulan lalu |
| rust-toolchain | ed0f273dcb chore: switch to stable rust versions (#2093) | 1 tahun lalu |
Fortuna is a webservice that serves random numbers according to the Entropy protocol. The webservice generates a hash chain of random numbers and reveals them to callers when permitted by the protocol. The hash chain is generated from a secret key that is provided to the server on startup. The service also operates a keeper task that performs callback transactions for user requests.
A single instance of this service can simultaneously serve random numbers for several different blockchains.
Each blockchain is configured in config.yaml.
We use sqlx query macros to check the SQL queries at compile time. This requires
a database to be available at build time. Create a .env file in the root of the project with the following content:
DATABASE_URL="sqlite:fortuna.db?mode=rwc"
Next, you need to create the database and apply the schema migrations. You can do this by running:
cargo sqlx migrate run # automatically picks up the .env file
This will create a SQLite database file called fortuna.db in the root of the project and apply the schema migrations to it.
This will allow cargo check to check the queries against the existing database.
Fortuna uses Cargo for building and dependency management.
Simply run cargo build and cargo test to build and test the project.
If you have changed any queries in the code, you need to update the .sqlx folder with the new queries:
cargo sqlx prepare
Please add the changed files in the .sqlx folder to your git commit.
The Fortuna binary has a command-line interface to perform useful operations on the contract, such as
registering a new randomness provider, or drawing a random value. To see the available commands, simply run cargo run.
To start an instance of the webserver for local testing, you first need to perform a few setup steps:
config.yaml file to point to the desired blockchains and Entropy contracts. Copy the content in config.sample.yaml and follow the directions inside to generate the necessary private keys and secrets.cargo run -- setup-provider to register a randomness provider for this service. This command
will update the on-chain contracts such that the configured provider key is a randomness provider,
and its on-chain configuration matches config.yaml.Once you've completed the setup, simply run the following command to start the service:
RUST_LOG=INFO cargo run -- run
This command will start the webservice on localhost:34000.