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

Apply Two Layer Trie and Refactor WorkingSet #1892

Closed
wants to merge 4 commits into from

Conversation

CoderZhi
Copy link
Collaborator

This is based on #1881

  1. Using two layer trie in factory to store archive data
  2. Refactor workingset, and delete statetx

@CoderZhi CoderZhi requested a review from a team as a code owner February 14, 2020 03:05
@codecov
Copy link

codecov bot commented Feb 14, 2020

Codecov Report

Merging #1892 into master will increase coverage by 0.03%.
The diff coverage is 68.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1892      +/-   ##
==========================================
+ Coverage   61.53%   61.57%   +0.03%     
==========================================
  Files         164      164              
  Lines       13504    13462      -42     
==========================================
- Hits         8310     8289      -21     
+ Misses       4142     4129      -13     
+ Partials     1052     1044       -8
Impacted Files Coverage Δ
action/protocol/execution/evm/evmstatedbadapter.go 52.09% <ø> (ø) ⬆️
db/trie/trie.go 66.66% <ø> (ø) ⬆️
action/protocol/managers.go 0% <ø> (ø) ⬆️
action/protocol/execution/evm/contract.go 88.75% <ø> (ø) ⬆️
db/trie/branchroottrie.go 66.66% <0%> (-1.2%) ⬇️
state/factory/util.go 53.84% <50%> (-0.18%) ⬇️
state/factory/workingset.go 57.54% <51.21%> (-5.04%) ⬇️
state/factory/twolayertrie.go 61.7% <61.7%> (ø)
state/factory/factory.go 64.84% <71.42%> (+1.87%) ⬆️
state/factory/statedb.go 61.5% <85.71%> (+2.23%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cea4aa4...c6e4b49. Read the comment docs.

default:
return nil, err
}
dbForTrie, err := db.NewKVStoreForTrie(ArchiveTrieNamespace, dao)
Copy link
Contributor

Choose a reason for hiding this comment

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

so if the kvstore exist already, this NewKVStoreForTrie doesn't have any side effect?

Comment on lines +278 to +301
getStateFunc: func(ns string, key []byte, s interface{}) error {
return readState(tlt, ns, key, s)
},
putStateFunc: func(ns string, key []byte, s interface{}) error {
ss, err := state.Serialize(s)
if err != nil {
return errors.Wrapf(err, "failed to convert account %v to bytes", s)
}
flusher.KVStoreWithBuffer().MustPut(ns, key, ss)
nsHash := hash.Hash160b([]byte(ns))

return tlt.Upsert(nsHash[:], key, ss)
},
delStateFunc: func(ns string, key []byte) error {
flusher.KVStoreWithBuffer().MustDelete(ns, key)
nsHash := hash.Hash160b([]byte(ns))

return tlt.Delete(nsHash[:], key)
},
digestFunc: func() hash.Hash256 {
return hash.Hash256b(flusher.SerializeQueue())
},
finalizeFunc: func(h uint64) error {
if finalized {
Copy link
Contributor

Choose a reason for hiding this comment

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

imo define all these callback/closure is not as clear as defining methods on a given struct.

@@ -28,6 +28,18 @@ import (
"github.com/iotexproject/iotex-core/pkg/log"
)

func processOptions(opts ...protocol.StateOption) (bool, uint64, string, []byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think just return cfg, make this function simpler to read and use

@CoderZhi CoderZhi closed this Feb 21, 2020
@CoderZhi CoderZhi deleted the apply_two_layer_trie branch February 21, 2020 06:13
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

2 participants