Skip to content
This repository was archived by the owner on Oct 25, 2025. It is now read-only.

feat: add crate sdk-prover, and add functionality to get self_prog_id within #1701

Open
codeblooded1729 wants to merge 11 commits intomainfrom
kapil/prog_id_bytes
Open

feat: add crate sdk-prover, and add functionality to get self_prog_id within #1701
codeblooded1729 wants to merge 11 commits intomainfrom
kapil/prog_id_bytes

Conversation

@codeblooded1729
Copy link
Contributor

@codeblooded1729 codeblooded1729 commented May 13, 2024

The PR introduces the crate sdk-prover. The need for this crate arose from native programs requiring access to the self_prog_id of their guest programs. sdk was insufficient in this regard, since it was hard to have it depend on circuits and runner (since they themselves depend on sdk). Also, a need for a version of sdk was felt, which would have access to proving system (in the case of self_prog_id, we need to have a dry run of Program, and tools to compute merkle caps of certain tables). Hence the crate, and its first module, prog_id_bytes.
Since an impl of Programidentifier, which creates self_prog_id out of its ELF, would create a cyclic dependency, we implement the above for a similar struct ProgId inside sdk-prover instead, and further implement trait From<ProgId> for ProgramIdentifier. Now, a native program, for say token example, can get ProgramIdentifier of its guest program by the following line of code

let token_program: ProgramIdentifier = ProgId::from_elf(&format!("{}{}", ELF_DIR, "tokenbin")).unwrap().into();

This PR also introduces a new CLI command self-prog-id which dumps the the same for given ELF. We also update the example_prog_id for core examples, with their correct version.
First part of tracking issue #1703

Comment on lines +7 to +12
cd examples/token && \
cargo build --bin tokenbin --release && \
cargo run --release \
--features="native" \
--bin token-native \
--target "$(rustc --verbose --version | grep host | awk '{ print $2; }')" &&
cargo build --bin tokenbin --release
--target "$(rustc --verbose --version | grep host | awk '{ print $2; }')"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to build the ELF first, since we require their ProgramIdenitifier in native execution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant