Skip to content

Commit 0331e73

Browse files
Remove the next_message_index as it is not used. (#4251)
## Motivation An examination of the source code reveals that the variable `next_message_index` is never used. ## Proposal Eliminate it completely. ## Test Plan The CI. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links None.
1 parent 0e1281f commit 0331e73

File tree

6 files changed

+1
-29
lines changed

6 files changed

+1
-29
lines changed

linera-chain/src/block_tracker.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub struct BlockExecutionTracker<'resources, 'blobs> {
4040
local_time: Timestamp,
4141
#[debug(skip_if = Option::is_none)]
4242
pub replaying_oracle_responses: Option<Vec<Vec<OracleResponse>>>,
43-
pub next_message_index: u32,
4443
pub next_application_index: u32,
4544
pub next_chain_index: u32,
4645
#[debug(skip_if = Vec::is_empty)]
@@ -87,7 +86,6 @@ impl<'resources, 'blobs> BlockExecutionTracker<'resources, 'blobs> {
8786
resource_controller,
8887
local_time,
8988
replaying_oracle_responses,
90-
next_message_index: 0,
9189
next_application_index: 0,
9290
next_chain_index: 0,
9391
oracle_responses: Vec::new(),
@@ -177,7 +175,6 @@ impl<'resources, 'blobs> BlockExecutionTracker<'resources, 'blobs> {
177175
Ok(TransactionTracker::new(
178176
self.local_time,
179177
self.transaction_index,
180-
self.next_message_index,
181178
self.next_application_index,
182179
self.next_chain_index,
183180
self.oracle_responses()?,
@@ -288,7 +285,6 @@ impl<'resources, 'blobs> BlockExecutionTracker<'resources, 'blobs> {
288285
where
289286
C: Context + Clone + Send + Sync + 'static,
290287
{
291-
self.next_message_index = txn_outcome.next_message_index;
292288
self.next_application_index = txn_outcome.next_application_index;
293289
self.next_chain_index = txn_outcome.next_chain_index;
294290
self.oracle_responses

linera-core/src/unit_tests/wasm_worker_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ where
278278
0,
279279
0,
280280
0,
281-
0,
282281
Some(vec![OracleResponse::Blob(application_description_blob_id)]),
283282
),
284283
&mut controller,

linera-execution/src/execution.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ where
8484
};
8585

8686
let action = UserAction::Instantiate(context, instantiation_argument);
87-
let next_message_index = 0;
8887
let next_application_index = application_description.application_index + 1;
8988
let next_chain_index = 0;
9089

@@ -115,7 +114,6 @@ where
115114
let mut txn_tracker = TransactionTracker::new(
116115
local_time,
117116
0,
118-
next_message_index,
119117
next_application_index,
120118
next_chain_index,
121119
None,

linera-execution/src/transaction_tracker.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub struct TransactionTracker {
3131
local_time: Timestamp,
3232
/// The index of the current transaction in the block.
3333
transaction_index: u32,
34-
next_message_index: u32,
3534
next_application_index: u32,
3635
next_chain_index: u32,
3736
/// Events recorded by contracts' `emit` calls.
@@ -57,7 +56,6 @@ pub struct TransactionOutcome {
5756
pub oracle_responses: Vec<OracleResponse>,
5857
#[debug(skip_if = Vec::is_empty)]
5958
pub outgoing_messages: Vec<OutgoingMessage>,
60-
pub next_message_index: u32,
6159
pub next_application_index: u32,
6260
pub next_chain_index: u32,
6361
/// Events recorded by contracts' `emit` calls.
@@ -74,15 +72,13 @@ impl TransactionTracker {
7472
pub fn new(
7573
local_time: Timestamp,
7674
transaction_index: u32,
77-
next_message_index: u32,
7875
next_application_index: u32,
7976
next_chain_index: u32,
8077
oracle_responses: Option<Vec<OracleResponse>>,
8178
) -> Self {
8279
TransactionTracker {
8380
local_time,
8481
transaction_index,
85-
next_message_index,
8682
next_application_index,
8783
next_chain_index,
8884
replaying_oracle_responses: oracle_responses.map(Vec::into_iter),
@@ -107,10 +103,6 @@ impl TransactionTracker {
107103
self.transaction_index
108104
}
109105

110-
pub fn next_message_index(&self) -> u32 {
111-
self.next_message_index
112-
}
113-
114106
pub fn next_application_index(&mut self) -> u32 {
115107
let index = self.next_application_index;
116108
self.next_application_index += 1;
@@ -127,10 +119,6 @@ impl TransactionTracker {
127119
&mut self,
128120
message: OutgoingMessage,
129121
) -> Result<(), ArithmeticError> {
130-
self.next_message_index = self
131-
.next_message_index
132-
.checked_add(1)
133-
.ok_or(ArithmeticError::Overflow)?;
134122
self.outgoing_messages.push(message);
135123
Ok(())
136124
}
@@ -274,7 +262,6 @@ impl TransactionTracker {
274262
outgoing_messages,
275263
local_time: _,
276264
transaction_index: _,
277-
next_message_index,
278265
next_application_index,
279266
next_chain_index,
280267
events,
@@ -296,7 +283,6 @@ impl TransactionTracker {
296283
Ok(TransactionOutcome {
297284
outgoing_messages,
298285
oracle_responses,
299-
next_message_index,
300286
next_application_index,
301287
next_chain_index,
302288
events,
@@ -312,7 +298,7 @@ impl TransactionTracker {
312298
/// Creates a new [`TransactionTracker`] for testing, with default values and the given
313299
/// oracle responses.
314300
pub fn new_replaying(oracle_responses: Vec<OracleResponse>) -> Self {
315-
TransactionTracker::new(Timestamp::from(0), 0, 0, 0, 0, Some(oracle_responses))
301+
TransactionTracker::new(Timestamp::from(0), 0, 0, 0, Some(oracle_responses))
316302
}
317303

318304
/// Creates a new [`TransactionTracker`] for testing, with default values and oracle responses

linera-execution/tests/contract_runtime_apis.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ async fn test_transfer_system_api(
9898
let TransactionOutcome {
9999
outgoing_messages,
100100
oracle_responses,
101-
next_message_index,
102101
..
103102
} = tracker.into_outcome()?;
104103
assert_eq!(outgoing_messages.len(), 1);
105104
assert_eq!(oracle_responses.len(), 3);
106-
assert_eq!(next_message_index, 1);
107105
assert!(matches!(outgoing_messages[0].message, Message::System(_)));
108106

109107
view.execute_message(
@@ -274,12 +272,10 @@ async fn test_claim_system_api(
274272
let TransactionOutcome {
275273
outgoing_messages,
276274
oracle_responses,
277-
next_message_index,
278275
..
279276
} = tracker.into_outcome()?;
280277
assert_eq!(outgoing_messages.len(), 1);
281278
assert_eq!(oracle_responses.len(), 3);
282-
assert_eq!(next_message_index, 1);
283279
assert!(matches!(outgoing_messages[0].message, Message::System(_)));
284280

285281
let mut tracker = TransactionTracker::new_replaying(Vec::new());
@@ -308,12 +304,10 @@ async fn test_claim_system_api(
308304
let TransactionOutcome {
309305
outgoing_messages,
310306
oracle_responses,
311-
next_message_index,
312307
..
313308
} = tracker.into_outcome()?;
314309
assert_eq!(outgoing_messages.len(), 1);
315310
assert!(oracle_responses.is_empty());
316-
assert_eq!(next_message_index, 1);
317311
assert!(matches!(outgoing_messages[0].message, Message::System(_)));
318312

319313
let mut tracker = TransactionTracker::new_replaying(Vec::new());

linera-execution/tests/test_execution.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,6 @@ async fn test_open_chain() -> anyhow::Result<()> {
12261226
1,
12271227
first_message_index,
12281228
0,
1229-
0,
12301229
Some(blob_oracle_responses(blobs.iter())),
12311230
);
12321231
view.execute_operation(context, operation, &mut txn_tracker, &mut controller)

0 commit comments

Comments
 (0)