Skip to content

Conversation

@usagi32
Copy link

@usagi32 usagi32 commented Oct 2, 2025

Motivation

closes #2706

Tx root derivation takes some time during block generation, but these can be cached when computed for the first time.

Test Plan

No critical or logic changes. CI should catch any regressions

Copy link
Collaborator

@vicsn vicsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution

/// Reads the deployment from a buffer.
fn read_le<R: Read>(mut reader: R) -> IoResult<Self> {
// Read the id variant.
let id_variant = u8::read_le(&mut reader)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made backwards compatible?

let mut deployment =
serializer.serialize_struct("Deployment", len + self.id.get().is_some() as usize)?;
if let Some(id) = self.id.get() {
deployment.serialize_field("id", id)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not backwards compatible.

mod string;

use crate::{Transaction, Transition};
use std::sync::OnceLock;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move down to line 26 so external dependencies are in the same place

#[derive(Clone)]
pub struct Deployment<N: Network> {
/// The deployment id
id: OnceLock<DeploymentID<N>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a design be possible where this is just an Option<...> like we did for the previous similar caching specified in the issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require mutable constructs to deployment all over the code base as when we call to_deployment_id it's probably best to cache the id if not computed yet once, this also implies a redundant recursive chain of callers that will have to take an &mut. We could probably do a RefCell though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Avoid tx root derivation

2 participants