forked from stellar/stellar-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soroban-cli: Fix
--cost
flag (stellar#911)
* WIP -- log SorobanResources instead * Log resources as cost if `--verbose` set or `--cost` * Simpler solution, log budget for sandbox, and resources for real * Only log the final events&auth when invoking on a real network, not every time you simulate * make fmt * clippy * Update test for assemble to be a passthrough * make fmt * feedback * fix formatting
- Loading branch information
Paul Bellamy
authored
Sep 1, 2023
1 parent
5f78b67
commit f1f9fa8
Showing
13 changed files
with
154 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,7 @@ impl Cmd { | |
&[], | ||
&network.network_passphrase, | ||
None, | ||
None, | ||
) | ||
.await? | ||
{ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
pub mod auth; | ||
pub mod budget; | ||
pub mod cost; | ||
pub mod diagnostic_event; | ||
pub mod footprint; | ||
pub mod host_event; | ||
|
||
pub use auth::*; | ||
pub use budget::*; | ||
pub use cost::*; | ||
pub use diagnostic_event::*; | ||
pub use footprint::*; | ||
pub use host_event::*; |
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,27 @@ | ||
use soroban_env_host::xdr::SorobanResources; | ||
use std::fmt::{Debug, Display}; | ||
|
||
struct Cost<'a>(&'a SorobanResources); | ||
|
||
impl Debug for Cost<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
// TODO: Should we output the footprint here? | ||
writeln!(f, "==================== Cost ====================")?; | ||
writeln!(f, "CPU used: {}", self.0.instructions,)?; | ||
writeln!(f, "Bytes read: {}", self.0.read_bytes,)?; | ||
writeln!(f, "Bytes written: {}", self.0.write_bytes,)?; | ||
writeln!(f, "==============================================")?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Display for Cost<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
Debug::fmt(self, f) | ||
} | ||
} | ||
|
||
pub fn cost(resources: &SorobanResources) { | ||
let cost = Cost(resources); | ||
tracing::debug!(?cost); | ||
} |
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.