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

Implement hashing and proofs for multistacks #201

Merged
merged 15 commits into from
Feb 7, 2024
Merged

Conversation

anodar
Copy link
Contributor

@anodar anodar commented Jan 23, 2024

That accepts prover so that we can use it both for values and stack frames.

@cla-bot cla-bot bot added the s label Jan 23, 2024
@anodar anodar requested a review from tsahee January 23, 2024 15:23
@anodar anodar changed the title Implement prove_stacks for stack of stacks Implement proofs for stack of stacks Jan 23, 2024
@anodar anodar requested a review from tsahee January 24, 2024 18:26
Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

got better definitions working on solidity code. Could still change, but seems right.

arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Show resolved Hide resolved
@anodar anodar requested a review from tsahee January 29, 2024 16:40
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Show resolved Hide resolved
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
arbitrator/prover/src/machine.rs Outdated Show resolved Hide resolved
@anodar anodar requested a review from tsahee January 31, 2024 15:01
Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

some minor comments.
This looks great and I can certainly start integration with this version.

@@ -972,6 +1027,7 @@ pub fn get_empty_preimage_resolver() -> PreimageResolver {

impl Machine {
pub const MAX_STEPS: u64 = 1 << 43;
pub const NO_STACK_HASH: Bytes32 = Bytes32::new([255_u8; 32]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you should need that.
Something like 'Bytes32([255_u8;32])' and/or something like '[255_u8;32].into()' should work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bytes32([255_u8;32]) works!

Tried .into()/from() before but that complained about non-static fn used in static initialization.

@@ -13,6 +13,14 @@ use std::{
#[repr(C)]
pub struct Bytes32(pub [u8; 32]);


impl Bytes32 {
pub const fn new(bytes: [u8; 32]) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need that.. see comment where you use it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -13,6 +13,14 @@ use std::{
#[repr(C)]
pub struct Bytes32(pub [u8; 32]);


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

hash_stack(multistack.iter().map(|v| stack_hasher(v)), "cothread:")
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

{
let mut data = Vec::with_capacity(33);


Copy link
Contributor

Choose a reason for hiding this comment

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

2 blank lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

data
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@tsahee
Copy link
Contributor

tsahee commented Jan 31, 2024

I got some new warnings during rust compilation

warning: unused variable: `a`
   --> prover/src/machine.rs:938:13
    |
938 |     let mut a = Machine::NO_STACK_HASH;
    |             ^ help: if this is intentional, prefix it with an underscore: `_a`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
   --> prover/src/machine.rs:938:9
    |
938 |     let mut a = Machine::NO_STACK_HASH;
    |         ----^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> prover/src/machine.rs:945:13
    |
945 |         let mut last_hash = match items.len() > 1{
    |             ----^^^^^^^^^
    |             |
    |             help: remove this `mut`

warning: variable does not need to be mutable
   --> prover/src/machine.rs:951:9
    |
951 |     let mut hash: Bytes32 = match items.len() > 2 {
    |         ----^^^^
    |         |
    |         help: remove this `mut`

// "multistack: "
// + hash_stack(first_stack)
// + hash_stack(last_stack)
// + Keccak("cothread: " + 2nd_stack+Keccak("cothread" + 3drd_stack + ...)
Copy link
Contributor

Choose a reason for hiding this comment

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

code does "cothread:" (no space)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Dropped it from multistack for consistency as well.

}
let mut hash: Bytes32 = match items.len() > 2 {
true => Machine::NO_STACK_HASH,
_ => {
Copy link
Contributor

Choose a reason for hiding this comment

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

these two are switched

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


let mut last_hash = match items.len() > 1{
true => {Machine::NO_STACK_HASH},
_ => stack_hasher(items.last().unwrap()),
Copy link
Contributor

Choose a reason for hiding this comment

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

these two are switched

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@anodar anodar requested a review from tsahee February 1, 2024 12:38
@anodar
Copy link
Contributor Author

anodar commented Feb 1, 2024

Addressed comments, PTAL.

@anodar anodar changed the title Implement proofs for stack of stacks Implement hashing and proofs for multistacks Feb 2, 2024
@tsahee tsahee merged commit 933046e into go_wasi Feb 7, 2024
1 of 7 checks passed
@tsahee tsahee deleted the multiple_stacks branch February 7, 2024 02:19
@tsahee
Copy link
Contributor

tsahee commented Feb 7, 2024

added some small fixes and merged into go_wasi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants