You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fortuna is a webservice that serves random numbers according to the Entropy protocol.
4
+
The webservice generates a hash chain of random numbers and reveals them to callers when permitted by the protocol.
5
+
The hash chain is generated from a secret key that is provided to the server on startup.
6
+
7
+
A single instance of this webservice can simultaneously serve random numbers for several different blockchains.
8
+
Each blockchain is configured in `config.yaml`.
9
+
10
+
## Build & Test
11
+
12
+
Fortuna uses Cargo for building and dependency management.
13
+
Simply run `cargo build` and `cargo test` to build and test the project.
14
+
15
+
## Command-Line Interface
16
+
17
+
The Fortuna binary has a command-line interface to perform useful operations on the contract, such as
18
+
registering a new randomness provider, or drawing a random value. To see the available commands, simply run `cargo run`.
19
+
20
+
## Local Development
21
+
22
+
To start an instance of the webserver for local testing, you first need to perform a few setup steps:
23
+
24
+
1. Edit `config.yaml` to point to the desired blockchains and Entropy contracts.
25
+
1. Generate a secret key. The secret key is a 32-byte random value used to construct the hash chains.
26
+
You can generate this value using the `openssl` command:
27
+
`openssl rand -hex 32`
28
+
1. Generate an ethereum wallet for the provider. You can do this in foundry using `cast wallet new`.
29
+
Note both the private key and the address; you will need both for subsequent steps.
30
+
1. Register a randomness provider for this service: `cargo run -- register-provider --chain-id <chain id> --secret <secret> --private-key <private-key>`.
31
+
The chain id is the key of the blockchain in `config.yaml`, the secret is from step (2), and the private key is from step (3).
32
+
Note that you need to run this command once per blockchain configured in `config.yaml`.
33
+
34
+
Once you've completed the setup, simply run the following command, using the secret from step (2) and the wallet address from step (3) as the provider:
35
+
36
+
```bash
37
+
cargo run -- run --secret <secret> --provider <provider>
38
+
```
39
+
40
+
This command will start the webservice on `localhost:34000`.
Copy file name to clipboardExpand all lines: target_chains/ethereum/contracts/README.md
+14-15Lines changed: 14 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,30 +4,29 @@ This directory contains The Pyth contract on Ethereum and utilities to deploy it
4
4
5
5
## Installation
6
6
7
-
Run the following command on the repo root to install required dependencies for the contract:
7
+
The contracts are built and tested using Foundry. Follow the [Foundry installation instructions](https://book.getfoundry.sh/getting-started/installation) to install it if you do not already have it.
8
+
9
+
Next, run the following command from the repo root to install required dependencies for the contract:
8
10
9
11
```
10
12
npm ci
11
13
npx lerna run build --scope="@pythnetwork/pyth-evm-contract" --include-dependencies
12
14
```
13
15
14
-
## Foundry
15
-
16
-
Foundry can be installed by the official installer, or by running our helper script which will automatically pull the correct installation script individually for Foundry and the Solidity compiler for your current OS. This may work better if you are running into networking/firewall issues using Foundry's Solidity installer. To use helper script, run the command below from this directory:
You can use foundry to run benchmark tests written in [`forge-test/GasBenchmark.t.sol`](./forge-test/GasBenchmark.t.sol). To run the tests with gas report
61
+
You can use foundry to run gas benchmark tests (which can be found in the `forge-test` directory). To run the tests with gas report
63
62
you can run `forge test --gas-report --match-contract GasBenchmark`. However, as there are multiple benchmarks, this might not be useful. You can run a
64
63
specific benchmark test by passing the test name using `--match-test`. A full command to run `testBenchmarkUpdatePriceFeedsFresh` benchmark test is like this:
0 commit comments