-
Notifications
You must be signed in to change notification settings - Fork 885
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
Fix some snap sync issues #6802
Conversation
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
99c9a1c
to
11405c2
Compare
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, a couple suggestions regarding doc and dedupe, 🚢 when ready
|
||
public static boolean isInRange( | ||
final Bytes location, final Bytes startKeyPath, final Bytes endKeyPath) { | ||
final MutableBytes path = MutableBytes.create(Bytes32.SIZE * 2); | ||
path.set(0, location); | ||
return !location.isEmpty() | ||
&& Arrays.compare(path.toArrayUnsafe(), startKeyPath.toArrayUnsafe()) >= 0 | ||
&& Arrays.compare(path.toArrayUnsafe(), endKeyPath.toArrayUnsafe()) <= 0; | ||
} | ||
|
||
public static Bytes createPath(final Bytes bytes) { | ||
final MutableBytes path = MutableBytes.create(bytes.size() * 2); | ||
int j = 0; | ||
for (int i = 0; i < bytes.size(); i += 1, j += 2) { | ||
final byte b = bytes.get(i); | ||
path.set(j, (byte) ((b >>> 4) & 0x0f)); | ||
path.set(j + 1, (byte) (b & 0x0f)); | ||
} | ||
return path; | ||
} |
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.
both of these could use javadoc
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.
done
public static boolean isInRange( | ||
final Bytes location, final Bytes startKeyPath, final Bytes endKeyPath) { | ||
final MutableBytes path = MutableBytes.create(Bytes32.SIZE * 2); | ||
path.set(0, location); | ||
return Arrays.compare(path.toArrayUnsafe(), startKeyPath.toArrayUnsafe()) >= 0 | ||
&& Arrays.compare(path.toArrayUnsafe(), endKeyPath.toArrayUnsafe()) <= 0; | ||
} |
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.
Can we not use the range manager implementation here?
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.
it's a modified version where location.isEmpty is removed in the check . I can create another PR to check if we can merge the two range methods
@Override | ||
public void visit(final Bytes location, final ExtensionNode<V> extensionNode) { | ||
if (!extensionNode.isDirty()) { | ||
return; | ||
} | ||
|
||
final Node<V> child = extensionNode.getChild(); | ||
if (child.isDirty()) { | ||
child.accept(Bytes.concatenate(location, extensionNode.getPath()), this); | ||
} | ||
if (child.isHealNeeded() | ||
|| !isInRange( | ||
Bytes.concatenate(location, extensionNode.getPath()), startKeyPath, endKeyPath)) { | ||
extensionNode.markHealNeeded(); // not save an incomplete node | ||
} | ||
|
||
maybeStoreNode(location, extensionNode); | ||
} | ||
|
||
@Override | ||
public void visit(final Bytes location, final BranchNode<V> branchNode) { | ||
if (!branchNode.isDirty()) { | ||
return; | ||
} | ||
|
||
for (int i = 0; i < branchNode.maxChild(); ++i) { | ||
Bytes index = Bytes.of(i); | ||
final Node<V> child = branchNode.child((byte) i); | ||
if (child.isDirty()) { | ||
child.accept(Bytes.concatenate(location, index), this); | ||
} | ||
if (child.isHealNeeded() | ||
|| !isInRange(Bytes.concatenate(location, index), startKeyPath, endKeyPath)) { | ||
branchNode.markHealNeeded(); // not save an incomplete node | ||
} |
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.
can we add javadoc on these too.
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.
added javadoc
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
The purpose of this commit is to fix some bugs detected in the snap sync. This should allow for greater stability with the snap sync and the healing of the flat DB. --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us>
The purpose of this commit is to fix some bugs detected in the snap sync. This should allow for greater stability with the snap sync and the healing of the flat DB. --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: amsmota <antonio.mota@citi.com>
The purpose of this commit is to fix some bugs detected in the snap sync. This should allow for greater stability with the snap sync and the healing of the flat DB. --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: amsmota <antonio.mota@citi.com>
The purpose of this commit is to fix some bugs detected in the snap sync. This should allow for greater stability with the snap sync and the healing of the flat DB. --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com>
PR description
The purpose of this PR is to fix some bugs detected in the snap sync. This should allow for greater stability with the snap sync and the healing of the flat DB.
Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
doc-change-required
label to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew build
./gradlew acceptanceTest
./gradlew integrationTest
./gradlew ethereum:referenceTests:referenceTests