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

367: Check if the statediff is already in progress or completed. #392

Merged
merged 3 commits into from
Jun 1, 2023

Conversation

telackey
Copy link

@telackey telackey commented Jun 1, 2023

Related to #367.

Add two checks:

  1. Only allow a single statediff of a block hash+number at a time.

  2. Do not state diff if that block hash+number already exists in the DB.

INFO [06-01|05:26:11.063] Not writing, statediff in progress.      number=605 hash=0x336e7cb623164e70dca3dc01c3dabf1a5e8af25f7c26db0e00eedc3e9c8c959d
INFO [06-01|05:26:11.083] Not writing, statediff already done.     number=600 hash=0x13399d30c79e8d32d00d6cb4ceb545a0467a61c58474986b6b74651d903a12ff

@telackey telackey self-assigned this Jun 1, 2023
@telackey telackey marked this pull request as ready for review June 1, 2023 05:28
Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

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

LGTM!

// Writes a state diff from the current block, parent state root, and provided params
func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, params Params) error {
if granted, relinquish := sds.claimExclusiveAccess(block); granted {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a cool pattern

statediff/indexer/database/sql/indexer.go Outdated Show resolved Hide resolved
@telackey telackey merged commit caa6853 into v1.11.6-statediff-v5 Jun 1, 2023
5 checks passed
@telackey telackey deleted the telackey/367b branch June 1, 2023 18:21
telackey added a commit that referenced this pull request Jun 1, 2023
telackey added a commit that referenced this pull request Jun 8, 2023
* Backport PR #391 to v4.

* Backport PR #392 to v4.
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.

None yet

3 participants