-
Notifications
You must be signed in to change notification settings - Fork 117
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
chore(dot/state/pruner): refactoring and fixes #2831
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## development #2831 +/- ##
===============================================
+ Coverage 51.57% 52.17% +0.59%
===============================================
Files 219 223 +4
Lines 27984 28124 +140
===============================================
+ Hits 14434 14674 +240
+ Misses 12267 12204 -63
+ Partials 1283 1246 -37 |
85c570d
to
329da6a
Compare
725533d
to
667cd1f
Compare
6f17141
to
adec1e3
Compare
adec1e3
to
e524268
Compare
a1819b1
to
6d61bd8
Compare
260cc25
to
ce064cf
Compare
// DefaultPruningMode is the default pruning mode | ||
DefaultPruningMode = "archive" | ||
// DefaultPruningEnabled describes if online pruning should be enabled by default. | ||
DefaultPruningEnabled = false |
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.
Let me know if you prefer to keep it as a string (might be needed for more pruning options later), but I changed it to a boolean to keep it simpler for now.
ce064cf
to
194f1f2
Compare
// storePruningData stores the pruner configuration. | ||
func (s *BaseState) storePruningData(mode pruner.Config) error { |
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.
That was persisting the pruning mode, whereas really it should be given at start from the toml config or flags, and be able to change from one mode to the other.
// Temporary work-around until we drop merkle values for node hashes in another PR (already opened). | ||
insertedNodeHashes := make(map[common.Hash]struct{}, len(insertedMerkleValues)) | ||
for k := range insertedMerkleValues { |
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.
Conversion will be removed once #2915 gets merged.
if dstv.IsNil() { | ||
keyType := dstv.Type().Key() | ||
valueType := dstv.Type().Elem() | ||
aMapType := reflect.MapOf(keyType, valueType) | ||
dstv.Set(reflect.MakeMapWithSize(aMapType, int(numberOfTuples))) | ||
} |
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.
this is so it can be decoded to a nil typed destination map. I don't think it's needed so much anymore but it was when I had a struct with map fields (and it sucks to init all maps)
194f1f2
to
ad3101e
Compare
logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", | ||
uint32(1), "0x66000000...00000000") | ||
err = pruner.RecordAndPrune( | ||
map[common.Hash]struct{}{{3}: {}}, // deleted node hashes |
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.
Should we prune 3? How should we handle forks??
EDIT: we should handle forks, this is WIP
@@ -176,9 +175,9 @@ func TestService_StorageTriePruning(t *testing.T) { | |||
config := Config{ |
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.
The test TestService_StorageTriePruning
which was modified in #3063 should now be unskipped.
- Move dot/state/pruner to internal/pruner/archive and internal/pruner/full - Define pruner as dot/state local interface - Inject pruner in NewStorageState - Unexport newStorageState - `NewArchiveNode` constructor - Change pruner config from `Mode` to bool - It's either on or off really - Change `--pruning` to be a boolean flag - Change pruning toml field to be a boolean - Pruner config changes - Do not store and load pruning config from base state - Move Config struct definition in `dot/state` - Set pruning state service config from user config in `dot` - Database batches for storing journal records - Unit and integration tests - Rename `StoreJournalRecord` to `RecordAndPrune` - Genesis block: no journal data and no pruning
ad3101e
to
ed2de43
Compare
Changes
internal/pruner/full
andinternal/pruner/archive
node hash
+common.Hash
instead ofmerkle value
+string
, since it's only 32B node hashesNewIterator
database method from production codeStoreJournalRecord
toRecordAndPrune
Tests
Issues
Fixes #2835
Primary Reviewer
@EclesioMeloJunior