Skip to content

Commit ad2fec6

Browse files
authored
Restore old behavior: Don't record oracle if blob known from same block. (#4510)
## Motivation #4413 introduced a bug where we record redundant oracle responses: * `blob_used` itself already records the response, so there is no need to call `replay_oracle_response`. * If the blob was published or created by this block, there is no reason to record an oracle response either. ## Proposal Restore the old behavior. ## Test Plan This caused the remote tests against Testnet Conway to break, and with this fix on the `testnet_conway` branch, they work again. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 47dc3f1 commit ad2fec6

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

examples/publish-read-data-blob/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Publish and read a data blob
22

33
This example shows how to create a blob and how to read it.
4-
This example should be read in conjunction with the end-to-end
5-
test `test_wasm_end_to_end_publish_read_data_blob`.
4+
This example should be read in conjunction with the client
5+
test `run_test_publish_read_data_blob`.
66

77
It shows 3 scenarios:
88
* Publishing and reading blobs with the publishing and reading in different

linera-core/src/unit_tests/wasm_client_tests.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ where
10661066

10671067
// publishing the data.
10681068
let publish_op = publish_read_data_blob::Operation::CreateDataBlob(test_data.clone());
1069-
client
1069+
let certificate = client
10701070
.execute_operation(Operation::user(application_id, &publish_op)?)
10711071
.await
10721072
.unwrap_ok_committed();
@@ -1081,14 +1081,18 @@ where
10811081
.execute_operation(Operation::user(application_id, &read_op)?)
10821082
.await
10831083
.unwrap_ok_committed();
1084+
// None of the following blocks should have oracle responses: all read blobs were created
1085+
// on the same chain, so no oracle is needed.
1086+
assert_eq!(certificate.block().body.oracle_responses[0].len(), 0);
10841087

10851088
// Method 2: Publishing and reading in the same transaction
10861089
let test_data = b"This is test data for method 2.".to_vec();
10871090
let combined_op = publish_read_data_blob::Operation::CreateAndReadDataBlob(test_data);
1088-
client
1091+
let certificate = client
10891092
.execute_operation(Operation::user(application_id, &combined_op)?)
10901093
.await
10911094
.unwrap_ok_committed();
1095+
assert_eq!(certificate.block().body.oracle_responses[0].len(), 0);
10921096

10931097
// Method 3: Publishing and reading in the same block but different transactions
10941098
let test_data = b"This is test data for method 3.".to_vec();
@@ -1098,10 +1102,12 @@ where
10981102
let read_op = publish_read_data_blob::Operation::ReadDataBlob(hash, test_data);
10991103
let op1 = Operation::user(application_id, &publish_op)?;
11001104
let op2 = Operation::user(application_id, &read_op)?;
1101-
client
1105+
let certificate = client
11021106
.execute_operations(vec![op1, op2], vec![])
11031107
.await
11041108
.unwrap_ok_committed();
1109+
assert_eq!(certificate.block().body.oracle_responses[0].len(), 0);
1110+
assert_eq!(certificate.block().body.oracle_responses[1].len(), 0);
11051111

11061112
Ok(())
11071113
}

linera-execution/src/execution_state_actor.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,17 +452,12 @@ where
452452
.await?
453453
.track_blob_read(content.bytes().len() as u64)?;
454454
}
455+
self.state
456+
.system
457+
.blob_used(self.txn_tracker, blob_id)
458+
.await?;
455459
content
456460
};
457-
let is_new = self
458-
.state
459-
.system
460-
.blob_used(self.txn_tracker, blob_id)
461-
.await?;
462-
if is_new {
463-
self.txn_tracker
464-
.replay_oracle_response(OracleResponse::Blob(blob_id))?;
465-
}
466461
callback.respond(content)
467462
}
468463

0 commit comments

Comments
 (0)