Skip to content

[testnet] Remove the handling of the sizes.#5446

Merged
MathieuDutSik merged 5 commits intolinera-io:testnet_conwayfrom
MathieuDutSik:drop_size_computation
Feb 16, 2026
Merged

[testnet] Remove the handling of the sizes.#5446
MathieuDutSik merged 5 commits intolinera-io:testnet_conwayfrom
MathieuDutSik:drop_size_computation

Conversation

@MathieuDutSik
Copy link
Copy Markdown
Contributor

Motivation

We are tracking the size of the keys in the smart contract. This is quite an expensive operation. This is
especially bad because we are not using this information.

Potentially, there are two usages:

Proposal

Remove the code that accesses the storages so as to get the speed increase.
However, the entries are kept in the KeyValueStoreView and KeyTag so as to ensure backward compatibility with already deployed contracts.

Test Plan

CI.

Release Plan

There will be other issues to resolve

Links

Comment on lines 274 to 277
Copy link
Copy Markdown
Contributor

@ma2bd ma2bd Feb 14, 2026

Choose a reason for hiding this comment

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

It would be nice to avoid loading the old size maps over and over: we could stop loading them (and remove the fields in the View) or we could load them but clear the data for next time (if non-empty) in post_save.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, in that case the post_load of `ByteMapView is just:

        Ok(Self {
            context,
            updates: BTreeMap::new(),
            deletion_set: DeletionSet::new(),
        })

So good news, nothing to load but bad news, we need a context, so we need a clone of it even if not used.

About deleting the data on storage. This can be done by adding a DeleteByPrefix in the code. However, we cannot test if what we delete is non-trivial without doing some expensive find_keys_by_prefix. So two realistic possibilities:

  • Add a delete_by_prefix that may slow a little every operations.
  • Make our mind with it and keep data that we do not need.

I left the code in Option 2, let me know if you want Option 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for verifying. Yes we can leave the data around in storage. Can we delete the unused field from the view in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was wrong. No need for those entries.

Copy link
Copy Markdown
Contributor

@ma2bd ma2bd Feb 15, 2026

Choose a reason for hiding this comment

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

nit: I wonder if we could remove #[allow(dead_code)] and write Hash = MIN_VIEW_TAG + 3 here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can though that does not impact the generated code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for sure

@ma2bd ma2bd marked this pull request as ready for review February 15, 2026 21:29
@ma2bd ma2bd self-requested a review February 15, 2026 21:29
Copy link
Copy Markdown
Contributor

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

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

LGTM

@ma2bd ma2bd linked an issue Feb 15, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

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

Not sure why CI is not green

@MathieuDutSik MathieuDutSik merged commit 50fdf7b into linera-io:testnet_conway Feb 16, 2026
35 checks passed
MathieuDutSik added a commit that referenced this pull request Mar 12, 2026
…ue store view (#5671)

## Motivation

Following PR #5446 the `write_batch` function has become sync but we
have kept its status as async.
This is incorrect,

## Proposal

Remove the async property of `write_batch`and of other functions that
should are in fact sync.

## Test Plan

CI

## Release Plan

On testnet_conway is the point here.

## Links

None.
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.

[testnet conway] Remove size computations in KeyValueStoreView

2 participants