snarkVM icon indicating copy to clipboard operation
snarkVM copied to clipboard

[Feature] Support program upgradability.

Open d0cd opened this issue 9 months ago • 0 comments

[NO NEW COMMITS ARE ALLOWED AS OF 5/27/25]

DO NOT MERGE UNTIL BASE IS UPDATED TO staging

Motivation

This PR

  • supports program upgradability, by allowing programs with constructors to be updated. Constructors are immutable, allowing developers to implement custom update logic for their applications.
  • modifies the program checksum to use SHA256 and changes its type from field to a [u8; 32u32]
  • strictly defines program equality to also include order
  • adds an optional program_checksum field to Deployment, which implicitly versions the object.
  • updates the deployment ID calculation to use the program checksum. Benchmarks for the checksum calculation are included below.

Test Plan

  • Process-level tests were added to verify the syntactic restrictions on upgrades.
  • VM/Ledger-level tests were added to verify upgrade semantics.

Benchmarks

Run on a 2021 MBP w/ an M1 Max & 32GB RAM

  • SHA3_256 Hash - input size 1000 bytes - [3.4339 µs 3.4435 µs 3.4539 µs]
  • SHA3_256 Hash - input size 10000 bytes - [28.346 µs 28.500 µs 28.747 µs]
  • SHA3_256 Hash - input size 100000 bytes - [280.97 µs 282.03 µs 283.11 µs] (max program size)
  • SHA3_256 Hash - input size 1000000 bytes - [2.7798 ms 2.7846 ms 2.7907 ms]

d0cd avatar Mar 19 '25 01:03 d0cd