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

SQL query for uncommited block seems buggy #81

Open
noel2004 opened this issue Nov 17, 2021 · 0 comments
Open

SQL query for uncommited block seems buggy #81

noel2004 opened this issue Nov 17, 2021 · 0 comments

Comments

@noel2004
Copy link
Member

In task_fetcher.rs, program try to fetch one block which has been proved but not been committed by following query:

select
  t.block_id as block_id,
  t.public_input as public_input,
  t.proof as proof,
  l2b.raw_public_data as public_data
from
  task t
  inner join l2block l2b on t.block_id = l2b.block_id
where
  t.block_id < coalesce(
    (
      select
        block_id
      from
        task
      where
        status <> 'proved'
      order by
        block_id
      limit
        1
    ), 0
  )
  and t.block_id > $1
  and t.status = 'proved' -- defense filter
  and l2b.status = 'uncommited'
order by
  t.block_id
limit
  1

Inside this query the coalesce function would return a block id which has not been proved yet, or 0. However, if all of the blocks have been proved while some of them are not committed yet, coalesce would just return 0 and no uncommitted block would be selected.

We should update the secondary item in coalesce from 0 to 9223372036854775807 (the max bigint), or consider just remove this constraint because the other condition seems enough for us to pick.

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

No branches or pull requests

1 participant