Skip to content

Commit

Permalink
Feature-gate the http_post and query_service oracles. (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
afck authored Aug 21, 2024
1 parent ab7c408 commit 74a534f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ jobs:
run: |
cargo build --release -p linera-storage-service
target/release/linera-storage-server memory --endpoint $LINERA_STORAGE_SERVICE &
cargo test --features storage-service -- storage_service --nocapture
cargo test --features storage-service,unstable-oracles -- storage_service --nocapture
- name: Run Ethereum tests
run: |
cargo test -p linera-ethereum --features ethereum
cargo test test_wasm_end_to_end_ethereum_tracker --features ethereum,storage-service
cargo test test_wasm_end_to_end_ethereum_tracker --features ethereum,storage-service,unstable-oracles
- name: Compile Wasm test modules for Witty integration tests
run: |
cargo build -p linera-witty-test-modules --target wasm32-unknown-unknown
Expand All @@ -82,7 +82,7 @@ jobs:
cargo run --bin wit-generator -- -c
- name: Run all tests using the default features
run: |
cargo test --locked
cargo test --features unstable-oracles --locked
- name: Run some extra execution tests with wasmtime
run: |
cargo test --locked -p linera-execution --features wasmtime
Expand Down
1 change: 1 addition & 0 deletions linera-execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ version.workspace = true
test = ["tokio/macros", "linera-views/test"]
fs = ["tokio/fs"]
metrics = ["prometheus", "linera-views/metrics"]
unstable-oracles = []
wasmer = [
"bytes",
"dep:wasmer",
Expand Down
4 changes: 4 additions & 0 deletions linera-execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ pub enum ExecutionError {
EventKeyTooLong,
#[error("Stream names can be at most {MAX_STREAM_NAME_LEN} bytes.")]
StreamNameTooLong,
// TODO(#2127): Remove this error and the unstable-oracles feature once there are fees
// and enforced limits for all oracles.
#[error("Unstable oracles are disabled on this network.")]
UnstableOracle,
}

/// The public entry points provided by the contract part of an application.
Expand Down
8 changes: 8 additions & 0 deletions linera-execution/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,10 @@ impl<UserInstance> BaseRuntime for SyncRuntimeInternal<UserInstance> {
application_id: ApplicationId,
query: Vec<u8>,
) -> Result<Vec<u8>, ExecutionError> {
ensure!(
cfg!(feature = "unstable-oracles"),
ExecutionError::UnstableOracle
);
let response =
if let Some(response) = self.transaction_tracker.next_replayed_oracle_response()? {
match response {
Expand All @@ -945,6 +949,10 @@ impl<UserInstance> BaseRuntime for SyncRuntimeInternal<UserInstance> {
content_type: String,
payload: Vec<u8>,
) -> Result<Vec<u8>, ExecutionError> {
ensure!(
cfg!(feature = "unstable-oracles"),
ExecutionError::UnstableOracle
);
let bytes =
if let Some(response) = self.transaction_tracker.next_replayed_oracle_response()? {
match response {
Expand Down

0 comments on commit 74a534f

Please sign in to comment.