Skip to content

Commit

Permalink
fix: pr feedback - default cli prover version to whatever is onchain
Browse files Browse the repository at this point in the history
  • Loading branch information
jac18281828 committed Nov 5, 2024
1 parent 09ca041 commit 424e66c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
4 changes: 1 addition & 3 deletions cli/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::common::*;
use anyhow::Result;
use bonsol_interface::prover_version::ProverVersion;
use bonsol_prover::input_resolver::{DefaultInputResolver, InputResolver, ProgramInput};
use bonsol_sdk::instructions::{ExecutionConfig, InputRef};
use bonsol_sdk::{BonsolClient, ExecutionAccountStatus, InputType};
Expand Down Expand Up @@ -172,7 +171,6 @@ pub async fn execute(
println!("Execution expiry {}", expiry);
println!("current block {}", current_block);
indicator.set_message("Building transaction");
let prover_version = ProverVersion::default();
let ixs = sdk
.execute_v1(
&signer,
Expand All @@ -191,7 +189,7 @@ pub async fn execute(
expiry,
execution_config,
callback_config.map(|c| c.into()),
Some(prover_version),
None, // A future cli change can implement prover version selection
)
.await?;
indicator.finish_with_message("Sending transaction");
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/contributing/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cargo run -p bonsol-cli build -z images/simple
```
5. Use the bonsol cli to deploy a zkprogram (here is a example already uploaded for you)
```bash
cargo run -p bonsol-cli deploy -m images/simple/manifest.json -t url --url https://bonsol-public-images.s3.us-east-1.amazonaws.com/simple-058530737d1b86e43ed2529f114b85195c27290fcf0844623b1ccb14934e8218
cargo run -p bonsol-cli deploy -m images/simple/manifest.json -t url --url https://bonsol-public-images.s3.us-east-1.amazonaws.com/simple-68f4b0c5f9ce034aa60ceb264a18d6c410a3af68fafd931bcfd9ebe7c1e42960
```
6. Use the bonsol cli to execute a zkprogram
```bash
Expand Down
5 changes: 3 additions & 2 deletions onchain/interface/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ pub fn execute_v1_with_accounts<'a>(
None
};

// typically cli will pass None for the optional prover_version indicating bonsol should handle
// the default case here
let prover_version = prover_version.unwrap_or(ProverVersion::default());

let fbb_execute = ExecutionRequestV1::create(
&mut fbb,
&ExecutionRequestV1Args {
Expand All @@ -338,7 +339,7 @@ pub fn execute_v1_with_accounts<'a>(
max_block_height: expiration,
input_digest,
callback_extra_accounts: extra_accounts,
prover_version,
prover_version: prover_version,
},
);
fbb.finish(fbb_execute, None);
Expand Down
10 changes: 9 additions & 1 deletion onchain/interface/src/prover_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl TryFrom<FBSProverVersion> for ProverVersion {

fn try_from(prover_version: FBSProverVersion) -> Result<Self, Self::Error> {
match prover_version {
FBSProverVersion::V1_0_1 => Ok(VERSION_V1_0_1),
FBSProverVersion::V1_0_1 | FBSProverVersion::DEFAULT => Ok(VERSION_V1_0_1),
_ => Err(ProverVersionError::UnsupportedVersion),
}
}
Expand Down Expand Up @@ -105,4 +105,12 @@ mod tests {
ProverVersionError::UnsupportedVersion
);
}

#[test]
fn test_default_into_current_version() {
let default_version = FBSProverVersion::DEFAULT;
let version = ProverVersion::try_from(default_version);
assert!(version.is_ok());
assert_eq!(version.unwrap(), VERSION_V1_0_1);
}
}
19 changes: 10 additions & 9 deletions schemas/execution_request_v1.fbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
include "./input_type.fbs";

enum ProverVersion: uint16 {
V1_0_1 = 0,
V1_0_2 = 1,
V1_0_3 = 2,
V1_0_4 = 3,
V1_0_5 = 4,
V1_1_0 = 5,
V1_1_1 = 6,
V1_1_2 = 7,
DEFAULT = 0,
V1_0_1 = 1,
V1_0_2 = 2,
V1_0_3 = 3,
V1_0_4 = 4,
V1_0_5 = 5,
V1_1_0 = 6,
V1_1_1 = 7,
V1_1_2 = 8,
}

struct Account (force_align: 8) {
Expand All @@ -28,7 +29,7 @@ table ExecutionRequestV1{
input_digest: [uint8]; // sha256 of the input data, checked against journal digest
max_block_height: uint64; // max block height to accept prover commitment
callback_extra_accounts: [Account] (force_align: 8); // extra accounts to pass to callback program
prover_version: ProverVersion = V1_0_1;
prover_version: ProverVersion = DEFAULT;
}

root_type ExecutionRequestV1;
2 changes: 1 addition & 1 deletion testing-examples/example-execution-request.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imageId": "058530737d1b86e43ed2529f114b85195c27290fcf0844623b1ccb14934e8218",
"imageId": "68f4b0c5f9ce034aa60ceb264a18d6c410a3af68fafd931bcfd9ebe7c1e42960",
"executionConfig": {
"verifyInputHash": false,
"forwardOutput": true
Expand Down

0 comments on commit 424e66c

Please sign in to comment.