Skip to content

Remove CreateAccount from State implementations#417

Merged
ihtefyw merged 5 commits into
mainfrom
luigi/remove-create-account
Jun 3, 2026
Merged

Remove CreateAccount from State implementations#417
ihtefyw merged 5 commits into
mainfrom
luigi/remove-create-account

Conversation

@ihtefyw

@ihtefyw ihtefyw commented May 20, 2026

Copy link
Copy Markdown
Contributor

This PR removes the CreateAccount function from the UpdateTarget interface, and therefore from each State implementation.
On his own, CreateAccount could never be called, and was always followed by a state-changing operation (balance, nonce, code).

This also removes the empty code hash set by the state implementations when creating an account: this was complicating the implementation, adding an unexpected side effect to the update functions.
A note: the geth-leveldb VK implementation uses the leveldb geth implementation, which sets all the fields in the account update, including the code hash, in each update. Therefore, it is not possible not to set the empty code hash in this implementation. For such reason, tests changing only one value and then checking the resulting hash are skipped for this implementation.

Note that the CreateAccount function is still available in the VMStateDB interface, where it's called from the EVM.

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
go/common/update.go 99.17% <100.00%> (-0.83%) ⬇️
go/database/flat/flat.go 100.00% <ø> (ø)
go/database/mpt/state.go 100.00% <ø> (ø)
go/database/vt/geth/state.go 58.62% <100.00%> (+1.52%) ⬆️
go/database/vt/reference/state.go 100.00% <ø> (ø)
go/state/state_db.go 98.43% <ø> (-0.01%) ⬇️
go/state/tool/benchmark.go 93.05% <ø> (-0.10%) ⬇️
rust/src/database/verkle/keyed_update.rs 98.71% <100.00%> (ø)
rust/src/database/verkle/state.rs 92.37% <ø> (ø)
rust/src/ffi/exported.rs 97.35% <100.00%> (ø)
... and 1 more

... and 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ihtefyw
ihtefyw force-pushed the luigi/remove-create-account branch 6 times, most recently from a80ecb8 to b32ccef Compare May 21, 2026 08:32
@ihtefyw
ihtefyw requested a review from Copilot May 21, 2026 08:45
@ihtefyw
ihtefyw marked this pull request as ready for review May 21, 2026 08:45
@ihtefyw ihtefyw changed the title Wip remove create accout Remove CreateAccount from State implementations May 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the CreateAccount method from common.UpdateTarget and deletes corresponding CreateAccount implementations/tests, shifting account creation semantics toward “implicit creation” via state-changing operations (balance/nonce/code/storage). It also adds a regression test to ensure implicitly created accounts get the expected empty-code hash.

Changes:

  • Removed CreateAccount from common.UpdateTarget and stopped applying Update.CreatedAccounts via Update.ApplyTo.
  • Deleted CreateAccount implementations in state backends and adjusted MPT tests/benchmarks to create accounts via nonce/balance updates.
  • Added a StateDB test asserting implicitly created accounts have the empty-code Keccak hash.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
go/common/update.go Removes CreateAccount from UpdateTarget and drops CreatedAccounts handling in ApplyTo.
go/state/state_test.go Removes tests tied to explicit account recreation/creation clearing storage.
go/state/state_db_and_state_test.go Adds test ensuring implicitly created accounts have the empty-code hash; adds sha3 import.
go/state/gostate/go_state_test.go Removes account recreation test that depended on explicit creation semantics.
go/state/externalstate/external_state.go Removes ExternalState.CreateAccount.
go/database/mpt/state.go Removes MptState.CreateAccount.
go/database/mpt/state_test.go Updates benchmark setup to create accounts via SetNonce.
go/database/mpt/io/parallel_visit_test.go Removes CreateAccount usage and relies on SetNonce for setup.
go/database/mpt/archive_trie_test.go Removes CreateAccount usage and relies on SetBalance for setup.
Comments suppressed due to low confidence (2)

go/database/mpt/io/parallel_visit_test.go:181

  • errors.Join is now called with a single argument, which is redundant and makes the surrounding code noisier. Consider replacing it with a direct err = live.SetNonce(...) call, and update the following fatal message (currently "failed to create account") to match what’s actually happening.
	addr := common.Address{}
	err = errors.Join(
		live.SetNonce(addr, common.Nonce{1}),
	)
	if err != nil {
		t.Fatalf("failed to create account: %v", err)
	}

go/database/mpt/archive_trie_test.go:723

  • errors.Join is now invoked with a single error (live.SetBalance(...)), which is redundant. Simplifying this to a direct assignment would improve readability without changing behavior.
				err = errors.Join(
					live.SetBalance(addr, blc1),
				)
				if err != nil {
					t.Fatalf("failed to update live db: %v", err)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go/state/state_db_and_state_test.go Outdated
Comment thread go/common/update.go
@ihtefyw
ihtefyw force-pushed the luigi/remove-create-account branch from b32ccef to b9c2620 Compare May 21, 2026 09:39
@ihtefyw
ihtefyw marked this pull request as draft May 26, 2026 08:47
@ihtefyw
ihtefyw force-pushed the luigi/remove-create-account branch from b9c2620 to 2a829c6 Compare May 26, 2026 08:52
@ihtefyw
ihtefyw requested a review from Copilot May 26, 2026 08:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 8 comments.

Files not reviewed (2)
  • go/common/update_mocks.go: Language not supported
  • go/database/mpt/state_mocks.go: Language not supported
Comments suppressed due to low confidence (2)

go/common/update.go:48

  • PR description notes that the Update field for created accounts still exists, but in this PR CreatedAccounts is removed from the Go common.Update struct. If this field is intentionally being removed from Go as well, the PR description should be updated; otherwise the field removal here is a discrepancy.
// Valid instances can then be forwarded to the State as a block update.
type Update struct {
	DeletedAccounts []Address
	Balances        []BalanceUpdate
	Nonces          []NonceUpdate
	Codes           []CodeUpdate
	Slots           []SlotUpdate
}

rust/src/types/update.rs:90

  • The encoded update format changed (removed the created-accounts length/section) but the decoder still accepts VERSION_0 and the version number is unchanged. Since this encoding is used for cross-language/FI updates (see comment refs to go/common/update.go:ToBytes), consider bumping the version and/or supporting decoding of the previous version to avoid hard-to-diagnose mismatches between components built from different commits.

Comment thread go/common/update.go
Comment thread go/common/update.go
Comment thread go/common/update.go
Comment thread go/state/state_db.go
Comment thread go/state/state_db_and_state_test.go Outdated
Comment thread go/state/state_db_and_state_test.go
Comment thread go/state/state_test.go Outdated
Comment thread rust/src/database/verkle/keyed_update.rs
@ihtefyw
ihtefyw force-pushed the luigi/remove-create-account branch 4 times, most recently from ad925fb to c3a6f4b Compare May 26, 2026 11:40
@ihtefyw
ihtefyw marked this pull request as ready for review May 26, 2026 11:40
LorenzSchueler
LorenzSchueler previously approved these changes May 27, 2026

@LorenzSchueler LorenzSchueler left a comment

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.

Looks good.

Comment thread go/common/update_test.go
Comment thread go/state/state_test.go
Comment thread go/state/state_test.go
Comment thread go/state/state_db_and_state_test.go Outdated
LorenzSchueler
LorenzSchueler previously approved these changes May 27, 2026
Comment thread go/common/update_test.go Outdated
LorenzSchueler
LorenzSchueler previously approved these changes May 27, 2026
HerbertJordan
HerbertJordan previously approved these changes May 27, 2026
Comment thread go/common/update.go Outdated
@ihtefyw
ihtefyw dismissed stale reviews from HerbertJordan and LorenzSchueler via c9f9a5f May 28, 2026 08:00
@ihtefyw
ihtefyw requested a review from LorenzSchueler May 28, 2026 08:01
LorenzSchueler
LorenzSchueler previously approved these changes May 28, 2026
@ihtefyw
ihtefyw force-pushed the luigi/remove-create-account branch from 622472e to 26d07a5 Compare June 1, 2026 14:59
LorenzSchueler
LorenzSchueler previously approved these changes Jun 2, 2026
@ihtefyw
ihtefyw merged commit 0bc3727 into main Jun 3, 2026
13 checks passed
@ihtefyw
ihtefyw deleted the luigi/remove-create-account branch June 3, 2026 11:44
ihtefyw added a commit that referenced this pull request Jul 9, 2026
ihtefyw added a commit that referenced this pull request Jul 9, 2026
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.

4 participants