Skip to content

Commit d932f43

Browse files
authored
Stabilize service as oracles (#3608)
## Motivation Running services as oracles is required for executing most HTTP requests due to non-deterministic answers. Now that running services as oracles is charged for and limited, it's possible to mark it as stable. ## Proposal Remove the `unstable-oracles` feature. ## Test Plan CI should catch any regressions. ## Release Plan - These changes follow the usual release cycle, since it adds a new feature to be included in the next testnet. ## Links - Closes #3524 - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 1a09224 commit d932f43

File tree

12 files changed

+21
-58
lines changed

12 files changed

+21
-58
lines changed

.github/workflows/rust.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ jobs:
121121
- name: Compile Wasm test modules for Witty integration tests
122122
run: |
123123
cargo build -p linera-witty-test-modules --target wasm32-unknown-unknown
124-
- name: Run all tests using the default features (plus unstable-oracles, except storage-service)
124+
- name: Run all tests using the default features (except storage-service)
125125
run: |
126126
# TODO(#2764): Actually link this to the default features
127-
cargo test --no-default-features --features fs,macros,wasmer,rocksdb,unstable-oracles --locked
127+
cargo test --no-default-features --features fs,macros,wasmer,rocksdb --locked
128128
- name: Run Witty integration tests
129129
run: |
130130
cargo test -p linera-witty --features wasmer,wasmtime
@@ -208,7 +208,7 @@ jobs:
208208
- name: Run Ethereum tests
209209
run: |
210210
cargo test -p linera-ethereum --features ethereum
211-
cargo test test_wasm_end_to_end_ethereum_tracker --features ethereum,storage-service,unstable-oracles
211+
cargo test test_wasm_end_to_end_ethereum_tracker --features ethereum,storage-service
212212
- name: Run REVM test
213213
run: |
214214
cargo test -p linera-execution test_fuel_for_counter_revm_application --features revm
@@ -231,7 +231,7 @@ jobs:
231231
- name: Run the storage-service instance and the storage-service tests
232232
run: |
233233
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
234-
cargo test --features storage-service,unstable-oracles -- storage_service --nocapture
234+
cargo test --features storage-service -- storage_service --nocapture
235235
236236
web:
237237
runs-on: ubuntu-latest

linera-chain/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ test = [
2121
"linera-base/test",
2222
"linera-execution/test",
2323
]
24-
unstable-oracles = ["linera-execution/unstable-oracles"]
2524
web = ["linera-base/web", "linera-views/web", "linera-execution/web"]
2625

2726
[dependencies]

linera-chain/src/unit_tests/chain_tests.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
use std::{
77
collections::{BTreeMap, BTreeSet},
8-
iter,
9-
};
10-
#[cfg(feature = "unstable-oracles")]
11-
use std::{
12-
thread,
8+
iter, thread,
139
time::{Duration, Instant},
1410
};
1511

@@ -31,12 +27,10 @@ use linera_execution::{
3127
committee::{Committee, Epoch, ValidatorState},
3228
system::{OpenChainConfig, Recipient},
3329
test_utils::{ExpectedCall, MockApplication},
34-
BaseRuntime, ExecutionError, ExecutionRuntimeConfig, ExecutionRuntimeContext, Message,
35-
MessageKind, Operation, ResourceControlPolicy, SystemMessage, SystemOperation,
36-
TestExecutionRuntimeContext,
30+
BaseRuntime, ContractRuntime, ExecutionError, ExecutionRuntimeConfig, ExecutionRuntimeContext,
31+
Message, MessageKind, Operation, ResourceControlPolicy, ServiceRuntime, SystemMessage,
32+
SystemOperation, TestExecutionRuntimeContext,
3733
};
38-
#[cfg(feature = "unstable-oracles")]
39-
use linera_execution::{ContractRuntime, ServiceRuntime};
4034
use linera_views::{
4135
context::{Context as _, MemoryContext, ViewContext},
4236
memory::MemoryStore,
@@ -306,7 +300,6 @@ async fn test_application_permissions() -> anyhow::Result<()> {
306300
}
307301

308302
/// Tests if services can execute as oracles if the total execution time is less than the limit.
309-
#[cfg(feature = "unstable-oracles")]
310303
#[test_case(&[100]; "single service as oracle call")]
311304
#[test_case(&[50, 50]; "two service as oracle calls")]
312305
#[test_case(&[90, 10]; "long and short service as oracle calls")]
@@ -349,7 +342,6 @@ async fn test_service_as_oracles(service_oracle_execution_times_ms: &[u64]) -> a
349342
}
350343

351344
/// Tests if execution fails if services executing as oracles exceed the time limit.
352-
#[cfg(feature = "unstable-oracles")]
353345
#[test_case(&[120]; "single service as oracle call")]
354346
#[test_case(&[60, 60]; "two service as oracle calls")]
355347
#[test_case(&[105, 15]; "long and short service as oracle calls")]
@@ -406,7 +398,6 @@ async fn test_service_as_oracle_exceeding_time_limit(
406398
}
407399

408400
/// Tests if execution fails early if services call `check_execution_time`.
409-
#[cfg(feature = "unstable-oracles")]
410401
#[test_case(&[120]; "single service as oracle call")]
411402
#[test_case(&[60, 60]; "two service as oracle calls")]
412403
#[test_case(&[105, 15]; "long and short service as oracle calls")]
@@ -475,7 +466,6 @@ async fn test_service_as_oracle_timeout_early_stop(
475466
}
476467

477468
/// Tests service-as-oracle response size limit.
478-
#[cfg(feature = "unstable-oracles")]
479469
#[test_case(50, 49 => matches Ok(_); "smaller than limit")]
480470
#[test_case(
481471
50, 51
@@ -567,7 +557,6 @@ async fn test_contract_http_response_size_limit(
567557
}
568558

569559
/// Tests service HTTP response size limit.
570-
#[cfg(feature = "unstable-oracles")]
571560
#[test_case(150, 140, 139 => matches Ok(_); "smaller than both limits")]
572561
#[test_case(140, 150, 142 => matches Ok(_); "larger than oracle limit")]
573562
#[test_case(

linera-core/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ rocksdb = ["linera-views/rocksdb"]
3131
dynamodb = ["linera-views/dynamodb"]
3232
scylladb = ["linera-views/scylladb"]
3333
storage-service = ["linera-storage-service"]
34-
unstable-oracles = [
35-
"linera-chain/unstable-oracles",
36-
"linera-execution/unstable-oracles",
37-
]
3834
metrics = [
3935
"prometheus",
4036
"linera-base/metrics",

linera-core/src/unit_tests/wasm_client_tests.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ where
354354
}]]
355355
);
356356

357-
let query_service = cfg!(feature = "unstable-oracles");
358-
let mut operation = meta_counter::Operation::increment(receiver_id, 5, query_service);
357+
let mut operation = meta_counter::Operation::increment(receiver_id, 5, true);
359358
operation.fuel_grant = 1000000;
360359
let cert = creator
361360
.execute_operation(Operation::user(application_id2, &operation)?)
@@ -367,16 +366,12 @@ where
367366
let [_, responses] = &responses[..] else {
368367
panic!("Unexpected oracle responses: {:?}", responses);
369368
};
370-
if cfg!(feature = "unstable-oracles") {
371-
let [OracleResponse::Service(json)] = &responses[..] else {
372-
assert_eq!(&responses[..], &[]);
373-
panic!("Unexpected oracle responses: {:?}", responses);
374-
};
375-
let response_json = serde_json::from_slice::<serde_json::Value>(json).unwrap();
376-
assert_eq!(response_json["data"], json!({"value": 10}));
377-
} else {
378-
assert!(responses.is_empty());
379-
}
369+
let [OracleResponse::Service(json)] = &responses[..] else {
370+
assert_eq!(&responses[..], &[]);
371+
panic!("Unexpected oracle responses: {:?}", responses);
372+
};
373+
let response_json = serde_json::from_slice::<serde_json::Value>(json).unwrap();
374+
assert_eq!(response_json["data"], json!({"value": 10}));
380375

381376
receiver.synchronize_from_validators().await.unwrap();
382377
receiver

linera-execution/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ revm = [
2323
]
2424
fs = ["tokio/fs"]
2525
metrics = ["prometheus", "linera-views/metrics"]
26-
unstable-oracles = []
2726
wasmer = [
2827
"dep:wasmer",
2928
"wasmer/enable-serde",

linera-execution/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ pub enum ExecutionError {
275275
UnauthorizedHttpRequest(reqwest::Url),
276276
#[error("Attempt to perform an HTTP request to an invalid URL")]
277277
InvalidUrlForHttpRequest(#[from] url::ParseError),
278-
// TODO(#2127): Remove this error and the unstable-oracles feature once there are fees
279-
// and enforced limits for all oracles.
280-
#[error("Unstable oracles are disabled on this network.")]
281-
UnstableOracle,
282278
#[error("Failed to send contract code to worker thread: {0:?}")]
283279
ContractModuleSend(#[from] linera_base::task::SendError<UserContractCode>),
284280
#[error("Failed to send service code to worker thread: {0:?}")]

linera-execution/src/runtime.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,11 +1318,6 @@ impl ContractRuntime for ContractSyncRuntimeHandle {
13181318
application_id: ApplicationId,
13191319
query: Vec<u8>,
13201320
) -> Result<Vec<u8>, ExecutionError> {
1321-
ensure!(
1322-
cfg!(feature = "unstable-oracles"),
1323-
ExecutionError::UnstableOracle
1324-
);
1325-
13261321
let mut this = self.inner();
13271322

13281323
let app_permissions = this

linera-execution/tests/contract_runtime_apis.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ impl TransferTestEndpoint {
861861
}
862862

863863
/// Tests the contract system API to query an application service.
864-
#[cfg(feature = "unstable-oracles")] // # TODO: Remove once #3524 lands
865864
#[test_case(None => matches Ok(_); "when all authorized")]
866865
#[test_case(Some(vec![()]) => matches Ok(_); "when single app authorized")]
867866
#[test_case(Some(vec![]) => matches Err(ExecutionError::UnauthorizedApplication(_)); "when unauthorized")]

linera-execution/tests/fee_consumption.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ use test_case::test_case;
112112
Some(Amount::from_tokens(1_000));
113113
"with execution and an empty read and with owner account and grant"
114114
)]
115-
#[cfg_attr(feature = "unstable-oracles", test_case(
115+
#[test_case(
116116
vec![
117117
FeeSpend::QueryServiceOracle,
118118
],
119119
Amount::from_tokens(2),
120120
Some(Amount::from_tokens(1)),
121121
Some(Amount::from_tokens(1_000));
122122
"with only a service oracle call"
123-
))]
124-
#[cfg_attr(feature = "unstable-oracles", test_case(
123+
)]
124+
#[test_case(
125125
vec![
126126
FeeSpend::QueryServiceOracle,
127127
FeeSpend::QueryServiceOracle,
@@ -131,8 +131,8 @@ use test_case::test_case;
131131
Some(Amount::from_tokens(1)),
132132
Some(Amount::from_tokens(1_000));
133133
"with three service oracle calls"
134-
))]
135-
#[cfg_attr(feature = "unstable-oracles", test_case(
134+
)]
135+
#[test_case(
136136
vec![
137137
FeeSpend::Fuel(91),
138138
FeeSpend::QueryServiceOracle,
@@ -146,7 +146,7 @@ use test_case::test_case;
146146
Some(Amount::from_tokens(1_000)),
147147
None;
148148
"with service oracle calls, fuel consumption and a read operation"
149-
))]
149+
)]
150150
#[test_case(
151151
vec![FeeSpend::HttpRequest],
152152
Amount::from_tokens(2),

0 commit comments

Comments
 (0)