Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove slow updates tree #5954

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ On this page you will learn how to use the `popCapsule` oracle. To see what othe

In a new file on the same level as your `main.nr`, implement an unconstrained function that calls the pop_capsule oracle:

#include_code pop_capsule noir-projects/noir-contracts/contracts/slow_tree_contract/src/capsule.nr rust
#include_code pop_capsule noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr rust

### 2. Import this into your smart contract

If it lies in the same directory as your smart contract, you can import it like this:

#include_code import_pop_capsule noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr rust
#include_code import_pop_capsule noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr rust

### 3. Use it as any other oracle

Now it becomes a regular oracle you can call like this:

#include_code pop_capsule noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr rust
#include_code pop_capsule noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr rust
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ PriceFeedContractArtifact
SchnorrAccountContractArtifact
SchnorrHardcodedAccountContractArtifact
SchnorrSingleKeyAccountContractArtifact
SlowTreeContractArtifact
StatefulTestContractArtifact
TestContractArtifact
TokenBlacklistContractArtifact
Expand Down
22 changes: 22 additions & 0 deletions docs/docs/misc/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ Aztec is in full-speed development. Literally every version breaks compatibility

## 0.36.0

## `SlowUpdatesTree` replaced for `SharedMutable`

The old `SlowUpdatesTree` contract and libraries have been removed from the codebase, use the new `SharedMutable` library instead. This will require that you add a global variable specifying a delay in blocks for updates, and replace the slow updates tree state variable with `SharedMutable` variables.

```diff
+ global CHANGE_ROLES_DELAY_BLOCKS = 5;

struct Storage {
- slow_update: SharedImmutable<AztecAddress>,
+ roles: Map<AztecAddress, SharedMutable<UserFlags, CHANGE_ROLES_DELAY_BLOCKS>>,
}
```

Reading from `SharedMutable` is much simpler, all that's required is to call `get_current_value_in_public` or `get_current_value_in_private`, depending on the domain.

```diff
- let caller_roles = UserFlags::new(U128::from_integer(slow.read_at_pub(context.msg_sender().to_field()).call(&mut context)));
+ let caller_roles = storage.roles.at(context.msg_sender()).get_current_value_in_public();
```

Finally, you can remove all capsule usage on the client code or tests, since those are no longer required when working with `SharedMutable`.

## [Aztec.nr & js] Portal addresses

Deployments have been modified. No longer are portal addresses treated as a special class, being immutably set on creation of a contract. They are no longer passed in differently compared to the other variables and instead should be implemented using usual storage by those who require it. One should use the storage that matches the usecase - likely shared storage to support private and public.
Expand Down
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ members = [
"compressed-string",
"easy-private-state",
"field-note",
"slow-updates-tree",
"value-note",
"tests",
]
8 changes: 0 additions & 8 deletions noir-projects/aztec-nr/slow-updates-tree/Nargo.toml

This file was deleted.

20 changes: 0 additions & 20 deletions noir-projects/aztec-nr/slow-updates-tree/src/leaf.nr

This file was deleted.

8 changes: 0 additions & 8 deletions noir-projects/aztec-nr/slow-updates-tree/src/lib.nr

This file was deleted.

188 changes: 0 additions & 188 deletions noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr

This file was deleted.

52 changes: 0 additions & 52 deletions noir-projects/aztec-nr/slow-updates-tree/src/slow_update_proof.nr

This file was deleted.

1 change: 0 additions & 1 deletion noir-projects/noir-contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ members = [
"contracts/schnorr_account_contract",
"contracts/schnorr_hardcoded_account_contract",
"contracts/schnorr_single_key_account_contract",
"contracts/slow_tree_contract",
"contracts/stateful_test_contract",
"contracts/test_contract",
"contracts/token_contract",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copied from noir-contracts/contracts/slow_tree_contract/src/capsule.nr
// We should extract this to a shared lib in aztec-nr once we settle on a design for capsules

// docs:start:pop_capsule
#[oracle(popCapsule)]
fn pop_capsule_oracle<N>() -> [Field; N] {}

// A capsule is a "blob" of data that is passed to the contract through an oracle.
unconstrained pub fn pop_capsule<N>() -> [Field; N] {
pop_capsule_oracle()
}
// docs:end:pop_capsule
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ contract ContractClassRegisterer {
unconstrained_function_broadcasted::{ClassUnconstrainedFunctionBroadcasted, UnconstrainedFunction}
};

// docs:start:import_pop_capsule
use crate::capsule::pop_capsule;
// docs:end:import_pop_capsule

#[aztec(private)]
fn register(artifact_hash: Field, private_functions_root: Field, public_bytecode_commitment: Field) {
// TODO: Validate public_bytecode_commitment is the correct commitment of packed_public_bytecode
// TODO: Validate packed_public_bytecode is legit public bytecode

// docs:start:pop_capsule
let packed_public_bytecode: [Field; MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS] = pop_capsule();
// docs:end:pop_capsule

// Compute contract class id from preimage
let contract_class_id = ContractClassId::compute(
Expand Down

This file was deleted.

Loading
Loading