diff --git a/fortuna/src/api.rs b/fortuna/src/api.rs index 723626ec3..e607fcae4 100644 --- a/fortuna/src/api.rs +++ b/fortuna/src/api.rs @@ -81,7 +81,9 @@ pub struct BlockchainState { /// The server will wait for this many block confirmations of a request before revealing /// the random number. pub reveal_delay_blocks: u64, - pub recent_block_status: BlockNumber, + /// The BlockNumber of the block that includes the random number request. + /// For eg., Finalized, Safe + pub request_block_status: BlockNumber, } pub struct Metrics { @@ -243,7 +245,7 @@ mod test { contract: eth_read.clone(), provider_address: PROVIDER, reveal_delay_blocks: 1, - recent_block_status: BlockStatus::Latest, + request_block_status: BlockStatus::Latest, }; let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[])); @@ -253,7 +255,7 @@ mod test { contract: avax_read.clone(), provider_address: PROVIDER, reveal_delay_blocks: 2, - recent_block_status: BlockStatus::Latest, + request_block_status: BlockStatus::Latest, }; let api_state = ApiState::new(&[ diff --git a/fortuna/src/api/revelation.rs b/fortuna/src/api/revelation.rs index ecd1b7d1d..8ca771032 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.recent_block_status); + let current_block_number_fut = state.contract.get_block_number(state.request_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 75ad1dec7..01ad141be 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, recent_block_status: BlockNumber) -> Result { + async fn get_block_number(&self, request_block_status: BlockNumber) -> Result { let block = self .client() - .get_block(recent_block_status) + .get_block(request_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 6e051ead6..ad1a1fd40 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, recent_block_status: BlockNumber) -> Result; + async fn get_block_number(&self, request_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 a6061e440..7f2dee186 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, - recent_block_status: chain_config.block_status, + request_block_status: chain_config.request_block_status, }; chains.insert(chain_id.clone(), state); diff --git a/fortuna/src/config.rs b/fortuna/src/config.rs index c3bf30b7c..210ea4297 100644 --- a/fortuna/src/config.rs +++ b/fortuna/src/config.rs @@ -138,7 +138,8 @@ pub struct EthereumConfig { #[serde(default)] pub legacy_tx: bool, - /// Use the legacy transaction format (for networks without EIP 1559) + /// The BlockNumber of the block that includes the random number request. + /// For eg., Finalized, Safe #[serde(default)] - pub block_status: BlockNumber, + pub request_block_status: BlockNumber, }