Skip to content

Commit

Permalink
Fix versioning of massa event cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Besancon committed Dec 19, 2024
1 parent 47aee0c commit 27ca46c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions massa-event-cache/src/event_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ mod tests {
use tempfile::TempDir;
// internal
use massa_models::config::{
MAX_EVENT_DATA_SIZE_V0, MAX_EVENT_PER_OPERATION, MAX_OPERATIONS_PER_BLOCK,
MAX_EVENT_DATA_SIZE_V1, MAX_EVENT_PER_OPERATION, MAX_OPERATIONS_PER_BLOCK,
MAX_RECURSIVE_CALLS_DEPTH, THREAD_COUNT,
};
use massa_models::operation::OperationId;
Expand All @@ -957,7 +957,7 @@ mod tests {
300,
THREAD_COUNT,
MAX_RECURSIVE_CALLS_DEPTH,
MAX_EVENT_DATA_SIZE_V0 as u64,
MAX_EVENT_DATA_SIZE_V1 as u64,
MAX_EVENT_PER_OPERATION as u64,
MAX_OPERATIONS_PER_BLOCK as u64,
5000, // MAX_EVENTS_PER_QUERY,
Expand Down
2 changes: 1 addition & 1 deletion massa-execution-worker/src/active_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ mod test {
// Expect updates to be empty (or default) here
{
let current_updates = AsyncMessageUpdate::default();
let fetched = active_history.fetch_message(&message_id_3_2, current_updates);
let fetched = active_history.fetch_message(&message_id_3_2, current_updates, 1);
if let HistorySearchResult::Present(SetUpdateOrDelete::Update(updates)) = fetched {
assert_eq!(updates, AsyncMessageUpdate::default());
} else {
Expand Down
24 changes: 24 additions & 0 deletions massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,30 @@ impl ExecutionState {

// append generated events to the final event store
exec_out.events.finalize();

let ts = get_block_slot_timestamp(
self.config.thread_count,
self.config.t0,
self.config.genesis_timestamp,
exec_out.slot,
)
.expect("Time overflow");

let cur_version = self
.final_state
.read()
.get_mip_store()
.get_network_version_active_at(ts);

if cur_version == 0 {
// Truncate the events before saving them to the event store
// Note: this is only needed during the MIP transition period
// When it becomes active, we will refuse such events so no need to truncate them
for event in exec_out.events.0.iter_mut() {
event.data.truncate(self.config.max_event_size_v1);
}
}

self.final_events_cache.save_events(exec_out.events.0);

// update the prometheus metrics
Expand Down

0 comments on commit 27ca46c

Please sign in to comment.