Skip to content

Conversation

@rjl493456442
Copy link
Member

In this PR, the codeDB implementation is introduced and integrated into the blockchain
as a long-term object shared between chain processing and RPC queries.

This serves as a prerequisite for the upcoming StateDB refactoring.

@rjl493456442 rjl493456442 added this to the 1.16.8 milestone Nov 13, 2025
@fjl fjl removed the status:triage label Dec 2, 2025
@fjl fjl assigned fjl and unassigned gballet Dec 2, 2025
Copy link
Contributor

@weiihann weiihann left a comment

Choose a reason for hiding this comment

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

LGTM. Added few nitpicks but they don't matter too much.

Comment on lines +246 to +253
codeFlag := make(map[common.Hash]bool)
for _, code := range update.codes {
if code.exists || codeFlag[code.hash] {
continue
}
stats.ContractCodes += 1
stats.ContractCodeBytes += codeKeySize + int64(len(code.blob))
codeFlag[code.hash] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
codeFlag := make(map[common.Hash]bool)
for _, code := range update.codes {
if code.exists || codeFlag[code.hash] {
continue
}
stats.ContractCodes += 1
stats.ContractCodeBytes += codeKeySize + int64(len(code.blob))
codeFlag[code.hash] = true
codeFlag := make(map[common.Hash]struct{})
for _, code := range update.codes {
if _, ok := codeFlag[code.hash]; ok || !code.exists {
continue
}
stats.ContractCodes += 1
stats.ContractCodeBytes += codeKeySize + int64(len(code.blob))
codeFlag[code.hash] = struct{}{}
}

Comment on lines +188 to +197
cache := make(map[common.Hash]bool)
for addr, code := range sc.codes {
if exists, ok := cache[code.hash]; ok {
code.exists = exists
continue
}
res := reader.Has(addr, code.hash)
cache[code.hash] = res
code.exists = res
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah no I was wrong

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.

6 participants