Skip to content

feat: add gas limit #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 27, 2025
Merged

feat: add gas limit #57

merged 5 commits into from
Mar 27, 2025

Conversation

indirection42
Copy link
Contributor

No description provided.

@@ -44,7 +44,8 @@ pub mod extensions {

pub fn execute_query(query: &[u8], input: &[u8]) -> PvqResult {
Copy link
Member

@xlc xlc Mar 26, 2025

Choose a reason for hiding this comment

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

should take an optional gas limit as input to and max to like 2s of execution to prevent for people calling infinite loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the max execution time related to gas_limit or they are separately specified like execute_query(query: &[u8], input: &[u8], gas_limit: Option<i64>, ref_time_limit: u64)? I supposed they should be related.

Copy link
Member

Choose a reason for hiding this comment

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

the input is gas limit. by 2s I mean estimate how much gas can be consumed to execute a code that takes 2s to complete

impl pvq_runtime_api::PvqApi<Block> for Runtime {
fn execute_query(program: Vec<u8>, args: Vec<u8>, gas_limit: Option<i64>) -> pvq_primitives::PvqResult {
// Set a default gas limit of 2 seconds
pvq::execute_query(&program, &args, gas_limit.unwrap_or(ONE_SECOND_IN_GAS * 2))
Copy link
Member

Choose a reason for hiding this comment

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

if user did pass a gas limit, it should still not be greater than 2s

@indirection42 indirection42 merged commit de6ef9f into master Mar 27, 2025
2 checks passed
@indirection42 indirection42 deleted the feat-gas-limit branch March 27, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants