-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add oracle for slow updates (#2878)
Experimental, very much in progress. Fixes #2852, building on top of #2732. For the experimentation here needed a name for my "data-stack" as it could practically hold whatever you want to throw at it. Was listening to https://www.youtube.com/watch?v=DTrNwbemNK0 while building so its the pez dispenser. The PEZ dispenser is essentially a stack managed by the PXE that hold `mint`s (PEZ Dispenser = "PfeffErminZ"/peppermint dispenser). A `mint` is `Fr[]` which can hold whatever data really, here just used to feed membership proofs and update proofs into the slow updates map.
- Loading branch information
Showing
15 changed files
with
166 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
yarn-project/noir-contracts/src/contracts/slow_tree_contract/src/pez.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[oracle(popMint)] | ||
fn pop_mint_oracle<N>() -> [Field; N] {} | ||
|
||
unconstrained pub fn pop_mint<N>() -> [Field; N] { | ||
pop_mint_oracle() | ||
} |
36 changes: 36 additions & 0 deletions
36
yarn-project/noir-contracts/src/contracts/slow_tree_contract/src/types.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// A single inclusion proof. | ||
// M = N + 2 | ||
struct MembershipProof<N, M> { | ||
index: Field, | ||
value: Field, | ||
sibling_path: [Field; N], | ||
} | ||
|
||
pub fn deserialize_membership_proof<N, M>(serialized: [Field; M]) -> pub MembershipProof<N, M> { | ||
let mut sibling_path = [0; N]; | ||
for i in 0..N { | ||
sibling_path[i] = serialized[2 + i]; | ||
} | ||
MembershipProof { | ||
index: serialized[0], | ||
value: serialized[1], | ||
sibling_path, | ||
} | ||
} | ||
|
||
|
||
impl<N, M> MembershipProof<N, M> { | ||
pub fn serialize(self: Self) -> pub [Field; M] { | ||
let mut serialized = [0; M]; | ||
serialized[0] = self.index; | ||
serialized[1] = self.value; | ||
for i in 0..N { | ||
serialized[2 + i] = self.sibling_path[i]; | ||
} | ||
serialized | ||
} | ||
|
||
pub fn deserialize(serialized: [Field; M]) -> Self { | ||
deserialize_membership_proof(serialized) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.