Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
121 changes: 61 additions & 60 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ default-features = false
[workspace.dependencies.snarkvm] # If this is updated, the rev in `node/rest/Cargo.toml` must be updated as well.
#path = "../snarkVM"
git = "https://github.com/ProvableHQ/snarkVM.git"
rev = "0face8c"
rev = "e376a16"
#version = "=1.5.0"
features = [ "circuit", "console", "rocks" ]
features = [ "circuit", "console", "rocks"]

[[bin]]
name = "snarkos"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/developer/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Deploy {
let vm = VM::from(store)?;

// Compute the minimum deployment cost.
let (minimum_deployment_cost, (_, _, _)) = deployment_cost(&deployment)?;
let (minimum_deployment_cost, (_, _, _, _)) = deployment_cost(&vm.process().read(), &deployment)?;

// Prepare the fees.
let fee = match &self.record {
Expand Down
8 changes: 6 additions & 2 deletions node/bft/ledger-service/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,14 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
match &transaction {
// Include the synthesis cost and storage cost for deployments.
Transaction::Deploy(_, _, _, deployment, _) => {
let (_, (storage_cost, synthesis_cost, _)) = deployment_cost(deployment)?;
let (_, (storage_cost, synthesis_cost, constructor_cost, _)) =
deployment_cost(&self.ledger.vm().process().read(), deployment)?;
storage_cost
.checked_add(synthesis_cost)
.ok_or(anyhow!("The storage and synthesis cost computation overflowed for a deployment"))
.and_then(|synthesis_cost| synthesis_cost.checked_add(constructor_cost))
.ok_or(anyhow!(
"The storage, synthesis, and constructor cost computation overflowed for a deployment"
))
}
// Include the finalize cost and storage cost for executions.
Transaction::Execute(_, _, execution, _) => {
Expand Down
2 changes: 1 addition & 1 deletion node/rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ version = "=3.5.0"
[dependencies.snarkvm-synthesizer]
#path = "../../../snarkVM/synthesizer"
git = "https://github.com/ProvableHQ/snarkVM.git"
rev = "0face8c"
rev = "e376a16"
#version = "=1.5.0"
default-features = false
optional = true
Expand Down
5 changes: 4 additions & 1 deletion node/rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
// GET ../find/..
.route(&format!("/{network}/find/blockHash/:tx_id"), get(Self::find_block_hash))
.route(&format!("/{network}/find/blockHeight/:state_root"), get(Self::find_block_height_from_state_root))
.route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_transaction_id_from_program_id))
.route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_latest_transaction_id_from_program_id))
.route(&format!("/{network}/find/transactionID/deployment/:program_id/:edition"), get(Self::find_transaction_id_from_program_id_and_edition))
.route(&format!("/{network}/find/transactionID/:transition_id"), get(Self::find_transaction_id_from_transition_id))
.route(&format!("/{network}/find/transitionID/:input_or_output_id"), get(Self::find_transition_id))

Expand All @@ -181,6 +182,8 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {

// GET ../program/..
.route(&format!("/{network}/program/:id"), get(Self::get_program))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a way to return the edition from the original get_program endpoint? If not, we may want to consider adding an optional Metadata to the query that surfaces it, and potentially other info like owner, tx_id, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure you can without breaking the API.
The Metadata option seems reasonable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the option for metadata, returning the edition and TX ID.
I did not add ProgramOwner, since it is not used for anything.

.route(&format!("/{network}/program/:id/latest_edition"), get(Self::get_latest_program_edition))
.route(&format!("/{network}/program/:id/:edition"), get(Self::get_program_for_edition))
.route(&format!("/{network}/program/:id/mappings"), get(Self::get_mapping_names))
.route(&format!("/{network}/program/:id/mapping/:name/:key"), get(Self::get_mapping_value))

Expand Down
28 changes: 26 additions & 2 deletions node/rest/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
Ok(ErasedJson::pretty(rest.ledger.get_program(id)?))
}

// GET /<network>/program/{programID}/latest_edition
pub(crate) async fn get_latest_program_edition(
State(rest): State<Self>,
Path(id): Path<ProgramID<N>>,
) -> Result<ErasedJson, RestError> {
Ok(ErasedJson::pretty(rest.ledger.get_latest_edition_for_program(&id)?))
}

// GET /<network>/program/{programID}/{edition}
pub(crate) async fn get_program_for_edition(
State(rest): State<Self>,
Path((id, edition)): Path<(ProgramID<N>, u16)>,
) -> Result<ErasedJson, RestError> {
Ok(ErasedJson::pretty(rest.ledger.get_program_for_edition(id, edition)?))
}

// GET /<network>/program/{programID}/mappings
pub(crate) async fn get_mapping_names(
State(rest): State<Self>,
Expand Down Expand Up @@ -345,11 +361,19 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
}

// GET /<network>/find/transactionID/deployment/{programID}
pub(crate) async fn find_transaction_id_from_program_id(
pub(crate) async fn find_latest_transaction_id_from_program_id(
State(rest): State<Self>,
Path(program_id): Path<ProgramID<N>>,
) -> Result<ErasedJson, RestError> {
Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_program_id(&program_id)?))
Ok(ErasedJson::pretty(rest.ledger.find_latest_transaction_id_from_program_id(&program_id)?))
}

// GET /<network>/find/transactionID/deployment/{programID}/{edition}
pub(crate) async fn find_transaction_id_from_program_id_and_edition(
State(rest): State<Self>,
Path((program_id, edition)): Path<(ProgramID<N>, u16)>,
) -> Result<ErasedJson, RestError> {
Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_program_id_and_edition(&program_id, edition)?))
}

// GET /<network>/find/transactionID/{transitionID}
Expand Down