Skip to content
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

limit the number of instructions that can be evaluated #2459

Merged
merged 2 commits into from
May 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sqlx-sqlite/src/connection/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,21 @@ pub(super) fn explain(

let mut visited_branch_state: HashSet<BranchStateHash> = HashSet::new();

let mut gas = 500_000;
tyrelr marked this conversation as resolved.
Show resolved Hide resolved
let mut result_states = Vec::new();

while let Some(mut state) = states.pop() {
while state.program_i < program_size {
let (_, ref opcode, p1, p2, p3, ref p4) = program[state.program_i];
state.history.push(state.program_i);

//limit the number of 'instructions' that can be evaluated
if gas > 0 {
gas -= 1;
} else if gas == 0 {
tyrelr marked this conversation as resolved.
Show resolved Hide resolved
break;
}

if state.visited[state.program_i] > MAX_LOOP_COUNT {
if logger.log_enabled() {
let program_history: Vec<&(i64, String, i64, i64, i64, Vec<u8>)> =
Expand Down