-
Notifications
You must be signed in to change notification settings - Fork 21.6k
all: introduce codedb and simplify cachingDB #33097
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
base: master
Are you sure you want to change the base?
Conversation
weiihann
left a comment
There was a problem hiding this 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.
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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{}{} | |
| } |
| 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 | ||
| } |
There was a problem hiding this comment.
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
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.