diff --git a/fortuna/src/api.rs b/fortuna/src/api.rs index e607fcae4..3c478e205 100644 --- a/fortuna/src/api.rs +++ b/fortuna/src/api.rs @@ -83,7 +83,7 @@ pub struct BlockchainState { pub reveal_delay_blocks: u64, /// The BlockNumber of the block that includes the random number request. /// For eg., Finalized, Safe - pub request_block_status: BlockNumber, + pub confirmed_block_status: BlockNumber, } pub struct Metrics { @@ -245,7 +245,7 @@ mod test { contract: eth_read.clone(), provider_address: PROVIDER, reveal_delay_blocks: 1, - request_block_status: BlockStatus::Latest, + confirmed_block_status: BlockStatus::Latest, }; let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[])); @@ -255,7 +255,7 @@ mod test { contract: avax_read.clone(), provider_address: PROVIDER, reveal_delay_blocks: 2, - request_block_status: BlockStatus::Latest, + confirmed_block_status: BlockStatus::Latest, }; let api_state = ApiState::new(&[ diff --git a/fortuna/src/api/revelation.rs b/fortuna/src/api/revelation.rs index 8ca771032..1d378e895 100644 --- a/fortuna/src/api/revelation.rs +++ b/fortuna/src/api/revelation.rs @@ -62,7 +62,7 @@ pub async fn revelation( let maybe_request_fut = state.contract.get_request(state.provider_address, sequence); - let current_block_number_fut = state.contract.get_block_number(state.request_block_status); + let current_block_number_fut = state.contract.get_block_number(state.confirmed_block_status); let (maybe_request, current_block_number) = try_join!(maybe_request_fut, current_block_number_fut).map_err(|e| { diff --git a/fortuna/src/chain/ethereum.rs b/fortuna/src/chain/ethereum.rs index 01ad141be..812b94c18 100644 --- a/fortuna/src/chain/ethereum.rs +++ b/fortuna/src/chain/ethereum.rs @@ -210,10 +210,10 @@ impl EntropyReader for PythContract { } } - async fn get_block_number(&self, request_block_status: BlockNumber) -> Result { + async fn get_block_number(&self, confirmed_block_status: BlockNumber) -> Result { let block = self .client() - .get_block(request_block_status) + .get_block(confirmed_block_status) .await? .ok_or_else(|| Error::msg("pending block confirmation"))?; diff --git a/fortuna/src/chain/reader.rs b/fortuna/src/chain/reader.rs index ad1a1fd40..25818494c 100644 --- a/fortuna/src/chain/reader.rs +++ b/fortuna/src/chain/reader.rs @@ -16,7 +16,7 @@ pub trait EntropyReader: Send + Sync { async fn get_request(&self, provider: Address, sequence_number: u64) -> Result>; - async fn get_block_number(&self, request_block_status: BlockNumber) -> Result; + async fn get_block_number(&self, confirmed_block_status: BlockNumber) -> Result; } /// An in-flight request stored in the contract. diff --git a/fortuna/src/command/run.rs b/fortuna/src/command/run.rs index 7f2dee186..bdc53b2c1 100644 --- a/fortuna/src/command/run.rs +++ b/fortuna/src/command/run.rs @@ -93,7 +93,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> { contract, provider_address: opts.provider, reveal_delay_blocks: chain_config.reveal_delay_blocks, - request_block_status: chain_config.request_block_status, + confirmed_block_status: chain_config.confirmed_block_status, }; chains.insert(chain_id.clone(), state); diff --git a/fortuna/src/config.rs b/fortuna/src/config.rs index 210ea4297..a92633f55 100644 --- a/fortuna/src/config.rs +++ b/fortuna/src/config.rs @@ -132,14 +132,15 @@ pub struct EthereumConfig { pub contract_addr: Address, /// How many blocks to wait before revealing the random number. + #[serde(default=0)] pub reveal_delay_blocks: u64, /// Use the legacy transaction format (for networks without EIP 1559) #[serde(default)] pub legacy_tx: bool, - /// The BlockNumber of the block that includes the random number request. + /// The BlockNumber of the block that is considered confirmed. /// For eg., Finalized, Safe #[serde(default)] - pub request_block_status: BlockNumber, + pub confirmed_block_status: BlockNumber, }