Skip to content

Commit

Permalink
update gas to u64, rust and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Nov 11, 2024
1 parent 071caea commit 6aeecd9
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 143 deletions.
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ version = "0.1.0"
edition = "2021"

[dependencies]
cairo-lang-compiler = "2.8.2"
cairo-lang-filesystem = "2.8.2"
cairo-lang-sierra = "2.8.0"
cairo-lang-sierra-ap-change = "2.8.0"
cairo-lang-sierra-gas = "2.8.0"
cairo-lang-utils = "2.8.0"
clap = { version = "4.5.16", features = ["derive"] }
k256 = "0.13.3"
cairo-lang-compiler = "2.8.4"
cairo-lang-filesystem = "2.8.4"
cairo-lang-sierra = "2.8.4"
cairo-lang-sierra-ap-change = "2.8.4"
cairo-lang-sierra-gas = "2.8.4"
cairo-lang-utils = "2.8.4"
clap = { version = "4.5.20", features = ["derive"] }
k256 = "0.13.4"
keccak = "0.1.5"
num-bigint = "0.4.6"
num-traits = "0.2.19"
p256 = "0.13.2"
rand = "0.8.5"
sec1 = { version = "0.7.3", features = ["std"] }
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.127"
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
sha2 = { version = "0.10.8", features = ["compress"] }
smallvec = "1.13.2"
starknet-crypto = "0.7.1"
starknet-curve = "0.5.0"
starknet-types-core = "0.1.2"
tempfile = "3.13.0"
thiserror = "1.0.63"
starknet-crypto = "0.7.3"
starknet-curve = "0.5.1"
starknet-types-core = "0.1.7"
tempfile = "3.14.0"
thiserror = "2.0.3"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[dev-dependencies]
cairo-lang-compiler = "2.8.0"
cairo-lang-starknet = "2.8.0"
cairo-lang-compiler = "2.8.4"
cairo-lang-starknet = "2.8.4"

# On dev optimize dependencies a bit so it's not as slow.
[profile.dev.package."*"]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.1"
channel = "1.82.0"
components = ["rustfmt", "clippy"]
profile = "minimal"
16 changes: 8 additions & 8 deletions src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum GasMetadataError {
#[error(transparent)]
CostError(#[from] CostError),
#[error("Not enough gas to run the operation. Required: {:?}, Available: {:?}.", gas.0, gas.1)]
NotEnoughGas { gas: Box<(u128, u128)> },
NotEnoughGas { gas: Box<(u64, u64)> },
}

impl GasMetadata {
Expand All @@ -66,8 +66,8 @@ impl GasMetadata {
pub fn get_initial_available_gas(
&self,
func: &FunctionId,
available_gas: Option<u128>,
) -> Result<u128, GasMetadataError> {
available_gas: Option<u64>,
) -> Result<u64, GasMetadataError> {
let Some(available_gas) = available_gas else {
return Ok(0);
};
Expand All @@ -86,25 +86,25 @@ impl GasMetadata {
})
}

pub fn initial_required_gas(&self, func: &FunctionId) -> Option<u128> {
pub fn initial_required_gas(&self, func: &FunctionId) -> Option<u64> {
if self.gas_info.function_costs.is_empty() {
return None;
}
Some(
self.gas_info.function_costs[func]
.iter()
.map(|(token_type, val)| val.into_or_panic::<usize>() * token_gas_cost(*token_type))
.sum::<usize>() as u128,
.sum::<usize>() as u64,
)
}

pub fn get_gas_cost_for_statement(&self, idx: StatementIdx) -> Option<u128> {
pub fn get_gas_cost_for_statement(&self, idx: StatementIdx) -> Option<u64> {
let mut cost = None;
for cost_type in CostTokenType::iter_casm_tokens() {
if let Some(amount) =
self.get_gas_cost_for_statement_and_cost_token_type(idx, *cost_type)
{
*cost.get_or_insert(0) += amount * token_gas_cost(*cost_type) as u128;
*cost.get_or_insert(0) += amount * token_gas_cost(*cost_type) as u64;
}
}
cost
Expand All @@ -114,7 +114,7 @@ impl GasMetadata {
&self,
idx: StatementIdx,
cost_type: CostTokenType,
) -> Option<u128> {
) -> Option<u64> {
self.gas_info
.variable_values
.get(&(idx, cost_type))
Expand Down
Loading

0 comments on commit 6aeecd9

Please sign in to comment.