Skip to content

Conversation

@mise42
Copy link
Contributor

@mise42 mise42 commented Mar 26, 2025

No description provided.

}
}

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

@mise42 mise42 merged commit de6ef9f into master Mar 27, 2025
2 checks passed
@mise42 mise42 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.

3 participants