Skip to content

add header hash support to block proposal state management - #7962

Merged
AdoAdoAdo merged 6 commits into
fix-state-accesses-root-hash-overwritefrom
state-accesses-collection-edge-cases
Aug 18, 2026
Merged

add header hash support to block proposal state management#7962
AdoAdoAdo merged 6 commits into
fix-state-accesses-root-hash-overwritefrom
state-accesses-collection-edge-cases

Conversation

@AdoAdoAdo

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

Proposed changes

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Comment thread outport/process/outportDataProvider.go Outdated
if headerHandler.IsHeaderV3() {
// skip intra-shard miniblocks.
// they are returned later when this block’s execution result is included in a future block.
// they are returned later when this block\u2019s execution result is included in a future block.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change the unicode back to `

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

c.retainedMut.Unlock()
return nil, nil
}
delete(c.stateAccessesForHeader, string(headerHash))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it ok to delete here, even if it is not equal to expected? Is it possible that expected is wrong, and this will be needed in the future?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

there should be no production path where the roothash does not match for the given hash, when reaching commit. Also the clean up here is safe, as there is no retrial if we reached this point, and a potential mismatch has already been logged.

Comment thread state/stateAccesses/collector.go
Comment thread state/errors.go Outdated
} else {
log.Debug("state accesses already collected for root hash, keeping previous accesses", "rootHash", rootHash)
c.headerScopeMut.RLock()
headerHash := append([]byte(nil), c.headerHash...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

c.headerHash could be replaced by BeginExecution while the commit is running.
maybe pass the headerHash explicitly to CommitCollectedAccesses alongside the rootHash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There should be only synchronous calls for this, valid as a robustness against future changes, but currently there is no path that would call it asynchronously/in parallel.

I would postpone a robustness change, as it would touch multiple places.

Comment thread state/errors.go Outdated

// Error returns the root mismatch message
func (e *StateAccessesRootMismatchError) Error() string {
return ErrStateAccessesRootMismatch.Error()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could add HeaderHash, ExpectedRoot, ActualRoot to the error for debugging purposes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

func (ert *executionResultsTracker) unlockAndNotifyDismissed() {
notifications := ert.dismissedNotifications
ert.dismissedNotifications = nil
ert.mutex.Unlock()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think it's better to keep them separated, Unlock and the NotifyDismissed, to keep Lock/Unlock in the same context func

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


c.retainedMut.Lock()
c.stateAccessesForHeader[string(headerHash)] = &committedStateAccesses{
rootHash: append([]byte(nil), rootHash...),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this needed? we should not end up with a nil rootHash at this point, maybe early return?

@AdoAdoAdo AdoAdoAdo Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the roothash is not nil at this point, as the only caller is AccountsDB.commit, and it does an error check before (and RootHash() never returns nil without an error).
the append is used here to copy the roothash and not use the trie internal one.

Comment thread state/stateAccesses/collector.go Outdated
// EndExecution clears the identity when the generation is still current
func (c *collector) EndExecution(generation uint64) {
c.headerScopeMut.Lock()
if c.headerGeneration == generation {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is headerGeneration needed? add a header hash check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, the header check is the better protection, especially since we don't allow overlapping collections.

@AdoAdoAdo
AdoAdoAdo merged commit e157263 into fix-state-accesses-root-hash-overwrite Aug 18, 2026
7 checks passed
@AdoAdoAdo
AdoAdoAdo deleted the state-accesses-collection-edge-cases branch August 18, 2026 14:19
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.

5 participants