Skip to content

Commit 6295674

Browse files
Dev Kalram30m
andauthored
feat(fortuna-v2): implement a keeper service for entropy v2 (#1366)
* extract code to run api * save * some changes * add exit checks * retry for sub threads and fetch events * handle events * remove unused * compiling * add logs to keeper * add simulation and some fixed * refactoring keeper * backlog refactoring works * extract handle event * extract watch blocks in a method * handle events extracted * remove res block from backlog method * remove res block from watch_blocks * remove res block from process events * load private key from file * add gas limit to blockchain config * remove unused imports * remove a log * gas param u256 * spell simulate * rename keeper private keeper file * wait for only api to exit * remove exit check from keeper * remove is valid request method as simulate will cover things * remove some parameters * remove exit check from keeper * use saturating sub * correct condition * update logging statement * combine logs * use nonce manager to send transaction * poll instead of stream and add nonce middleware * remove unused * fix tests * add ws support to streaming * Refactor and improve error handling * replace simulation with gas estimation * add polling support for when no wss url * version update * test check * update comment * update key comment * rename chain_config to chain_state * update version * pad gas estimate * add comments --------- Co-authored-by: Amin Moghaddam <[email protected]>
1 parent 050b827 commit 6295674

File tree

10 files changed

+710
-75
lines changed

10 files changed

+710
-75
lines changed

fortuna/Cargo.lock

Lines changed: 68 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fortuna/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "3.3.4"
3+
version = "4.0.0"
44
edition = "2021"
55

66
[dependencies]
@@ -12,7 +12,8 @@ bincode = "1.3.3"
1212
byteorder = "1.5.0"
1313
clap = { version = "4.4.6", features = ["derive", "cargo", "env"] }
1414
ethabi = "18.0.0"
15-
ethers = "2.0.10"
15+
ethers = { version = "2.0.14", features = ["ws"] }
16+
futures = { version = "0.3.28" }
1617
hex = "0.4.3"
1718
prometheus-client = { version = "0.21.2" }
1819
pythnet-sdk = { path = "../pythnet/pythnet_sdk", features = ["strum"] }
@@ -34,5 +35,6 @@ once_cell = "1.18.0"
3435
lazy_static = "1.4.0"
3536
url = "2.5.0"
3637

38+
3739
[dev-dependencies]
3840
axum-test = "13.1.1"

fortuna/src/api.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ impl ApiState {
7373
/// The state of the randomness service for a single blockchain.
7474
#[derive(Clone)]
7575
pub struct BlockchainState {
76+
/// The chain id for this blockchain, useful for logging
77+
pub id: ChainId,
7678
/// The hash chain(s) required to serve random numbers for this blockchain
7779
pub state: Arc<HashChainState>,
7880
/// The contract that the server is fulfilling requests for.
@@ -245,6 +247,7 @@ mod test {
245247
let eth_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
246248

247249
let eth_state = BlockchainState {
250+
id: "ethereum".into(),
248251
state: ETH_CHAIN.clone(),
249252
contract: eth_read.clone(),
250253
provider_address: PROVIDER,
@@ -255,6 +258,7 @@ mod test {
255258
let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
256259

257260
let avax_state = BlockchainState {
261+
id: "avalanche".into(),
258262
state: AVAX_CHAIN.clone(),
259263
contract: avax_read.clone(),
260264
provider_address: PROVIDER,

0 commit comments

Comments
 (0)