Skip to content

Commit

Permalink
[gas] implement memory quota (aptos-labs#4757)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgao1996 authored Oct 5, 2022
1 parent 900b00d commit bf65f2c
Show file tree
Hide file tree
Showing 60 changed files with 909 additions and 276 deletions.
78 changes: 39 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ aptos-vm = { path = "../aptos-move/aptos-vm" }

storage-interface = { path = "../storage/storage-interface" }

move-core-types = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82", features = ["address32"] }
move-core-types = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426", features = ["address32"] }

[dev-dependencies]
aptos-api-test-context = { path = "./test-context", package = "aptos-api-test-context" }
Expand All @@ -56,7 +56,7 @@ regex = "1.5.5"
reqwest = { version = "0.11.10", features = ["blocking", "json"], default_features = false }
warp = { version = "0.3.2", features = ["default"] }

move-package = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-package = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }

[features]
failpoints = ["fail/failpoints"]
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -397,7 +397,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -675,7 +675,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -953,7 +953,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -1231,7 +1231,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -1509,7 +1509,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -1787,7 +1787,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down Expand Up @@ -2065,7 +2065,7 @@
"state_change_hash": "",
"event_root_hash": "",
"state_checkpoint_hash": null,
"gas_used": "265",
"gas_used": "264",
"success": true,
"vm_status": "Executed successfully",
"accumulator_root_hash": "",
Expand Down
4 changes: 2 additions & 2 deletions api/src/tests/transaction_vector_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ fn type_tag_strategy() -> impl Strategy<Value = TypeTag> {
identifier_strategy(),
identifier_strategy()).prop_map(|(t_vec, addr, module, name)| {

TypeTag::Struct(StructTag {
TypeTag::Struct(Box::new(StructTag {
address: addr,
module: Identifier::new(module).unwrap(),
name: Identifier::new(name).unwrap(),
type_params: t_vec,
})}),
}))}),
]
})
}
Expand Down
6 changes: 3 additions & 3 deletions api/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ aptos-vm = { path = "../../aptos-move/aptos-vm" }

storage-interface = { path = "../../storage/storage-interface" }

move-binary-format = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-core-types = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82", features = ["address32"] }
move-resource-viewer = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-core-types = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426", features = ["address32"] }
move-resource-viewer = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
16 changes: 8 additions & 8 deletions api/types/src/move_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ impl From<TypeTag> for MoveType {
TypeTag::Vector(v) => MoveType::Vector {
items: Box::new(MoveType::from(*v)),
},
TypeTag::Struct(v) => MoveType::Struct(v.into()),
TypeTag::Struct(v) => MoveType::Struct((*v).into()),
}
}
}
Expand All @@ -701,7 +701,7 @@ impl From<&TypeTag> for MoveType {
TypeTag::Vector(v) => MoveType::Vector {
items: Box::new(MoveType::from(v.as_ref())),
},
TypeTag::Struct(v) => MoveType::Struct(v.into()),
TypeTag::Struct(v) => MoveType::Struct((&**v).into()),
}
}
}
Expand All @@ -717,7 +717,7 @@ impl TryFrom<MoveType> for TypeTag {
MoveType::Address => TypeTag::Address,
MoveType::Signer => TypeTag::Signer,
MoveType::Vector { items } => TypeTag::Vector(Box::new((*items).try_into()?)),
MoveType::Struct(v) => TypeTag::Struct(v.try_into()?),
MoveType::Struct(v) => TypeTag::Struct(Box::new(v.try_into()?)),
_ => {
return Err(anyhow::anyhow!(
"Invalid move type for converting into `TypeTag`: {:?}",
Expand Down Expand Up @@ -1237,7 +1237,7 @@ mod tests {
assert_serialize(Vector(Box::new(U8)), json!("vector<u8>"));

assert_serialize(
Struct(create_nested_struct()),
Struct(Box::new(create_nested_struct())),
json!("0x1::Home::ABC<address, 0x1::account::Base<u128, vector<u64>, vector<0x1::type::String>, 0x1::type::String>>"),
);
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ mod tests {
vec![(
identifier("nested_vector"),
Vector(
TypeTag::Struct(type_struct("Host")),
TypeTag::Struct(Box::new(type_struct("Host"))),
vec![Struct(annotated_move_struct(
"String",
vec![
Expand Down Expand Up @@ -1474,7 +1474,7 @@ mod tests {
address: address("0x1"),
module: identifier("Home"),
name: identifier("ABC"),
type_params: vec![TypeTag::Address, TypeTag::Struct(account)],
type_params: vec![TypeTag::Address, TypeTag::Struct(Box::new(account))],
}
}

Expand All @@ -1486,8 +1486,8 @@ mod tests {
type_params: vec![
TypeTag::U128,
TypeTag::Vector(Box::new(TypeTag::U64)),
TypeTag::Vector(Box::new(TypeTag::Struct(type_struct("String")))),
TypeTag::Struct(type_struct("String")),
TypeTag::Vector(Box::new(TypeTag::Struct(Box::new(type_struct("String"))))),
TypeTag::Struct(Box::new(type_struct("String"))),
],
}
}
Expand Down
6 changes: 3 additions & 3 deletions aptos-move/aptos-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ smallvec = "1.8.0"
aptos-crypto = { path = "../../crates/aptos-crypto" }
aptos-state-view = { path = "../../storage/state-view" }
aptos-types = { path = "../../types" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }

move-core-types = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82", features = ["address32"] }
move-table-extension = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-core-types = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426", features = ["address32"] }
move-table-extension = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }

[dev-dependencies]
claims = "0.7"
Expand Down
12 changes: 6 additions & 6 deletions aptos-move/aptos-gas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ anyhow = "1.0.57"
bcs = { git = "https://github.com/aptos-labs/bcs", rev = "f94869cdfa1b5d2c9892016e8fb0c59fda1eea2d" }
clap = { version = "3.1.17", features = ["derive"] }

move-binary-format = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-core-types = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-model = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-table-extension = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "0155b47808de249f4030e84354fde154a1500a82" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-core-types = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-model = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-table-extension = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "ed592c619e87160eb226662581e268d11fbbb426" }

aptos-global-constants = { path = "../../config/global-constants" }
aptos-types = { path = "../../types" }
Expand Down
Loading

0 comments on commit bf65f2c

Please sign in to comment.