Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
fix(operator): dummy operator (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani authored May 3, 2024
1 parent 4ffe174 commit 6586cd8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,6 @@ Example response:
}
```

### Range of blocks stored in the `VectorX` contract

Querying for the range of blocks stored in the VectorX contract deployed on Sepolia (chain ID: 11155111) at address 0x169e50f09A50F3509777cEf63EC59Eeb2aAcd201.

```
https://beaconapi.succinct.xyz/api/integrations/vectorx/range?contractChainId=11155111&contractAddress=0x169e50f09A50F3509777cEf63EC59Eeb2aAcd201
```

Example response:

```json
{ "data": { "rangeStart": 444840, "rangeEnd": 448140 } }
```

### Health of the `VectorX` contract

Querying for the health of the VectorX contract deployed on Sepolia (chain ID: 11155111) at address 0x169e50f09A50F3509777cEf63EC59Eeb2aAcd201.
Expand Down
13 changes: 13 additions & 0 deletions bin/vectorx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct VectorXOperator {
contract: VectorX<Provider<Http>>,
client: SuccinctClient,
data_fetcher: RpcDataFetcher,
is_dummy_operator: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -72,11 +73,18 @@ impl VectorXOperator {
let succinct_api_key = env::var("SUCCINCT_API_KEY").expect("SUCCINCT_API_KEY must be set");
let client = SuccinctClient::new(succinct_rpc_url, succinct_api_key, false, false);

// is_dummy_operator defaults to false.
let is_dummy_operator = env::var("IS_DUMMY_OPERATOR")
.unwrap_or("false".to_string())
.parse::<bool>()
.unwrap();

Self {
config,
contract,
client,
data_fetcher,
is_dummy_operator,
}
}

Expand Down Expand Up @@ -406,6 +414,11 @@ impl VectorXOperator {
return None;
}

// If dummy operator, return the block to step to.
if self.is_dummy_operator {
return Some(block_to_step_to);
}

// Check that block_to_step_to has a valid justification. If not, iterate up until the maximum_vectorx_target_block
// to find a valid justification. If we're unable to find a justification, something has gone
// deeply wrong with the jusitification indexer.
Expand Down
8 changes: 8 additions & 0 deletions circuits/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,14 @@ mod tests {
// assert_eq!(headers.len(), 181);
}

#[tokio::test]
#[cfg_attr(feature = "ci", ignore)]
async fn test_get_block_hash() {
let fetcher = RpcDataFetcher::new().await;
let block_hash = fetcher.get_block_hash(70440).await;
println!("block hash {:?}", hex::encode(block_hash.0));
}

#[tokio::test]
#[cfg_attr(feature = "ci", ignore)]
async fn test_get_header_hash() {
Expand Down

0 comments on commit 6586cd8

Please sign in to comment.