kwilteam / kwil-db

Kwil DB, the database for web3
https://www.kwil.com/
Other
36 stars 12 forks source link

Preview block timing #1088

Closed brennanjl closed 1 day ago

brennanjl commented 6 days ago

Sets the current block and block timestamp to the most recently seen block if in a call.

brennanjl commented 6 days ago

Once this is good to go, I will cherry-pick to main and v0.9. I did it here first because it's at the request of @sapience who is still on preview (v0.8+)

Yaiba commented 2 days ago

I'm not familiar with this part of the code, just a question since @charithabandi told me before we already have height/timestamp already in the block header, why don't we just use what's already in the block header?

jchappelow commented 2 days ago

I'm not familiar with this part of the code, just a question since @charithabandi told me before we already have height/timestamp already in the block header, why don't we just use what's already in the block header?

This is sorta doing just that, although a little roundabout. svc.engine.Procedure could set internally if these fields are -1 or unset, as an alternative. I don't know if that's better or easier though.

jchappelow commented 2 days ago

Only alternative that comes to mind is that usersvc.(*Service).Call could do:

stat, _ := svc.chainClient.Status(ctx)
height, stamp := stat.Sync.BestBlockHeight, stat.Sync.BestBlockTime

Does that work? I haven't digested the need for the committed vs uncommitted in the current approach.

brennanjl commented 1 day ago

Closed in favor of https://github.com/kwilteam/kwil-db/pull/1094