-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Beacon chain block processing #1156
Conversation
PR is ready for merge now. Tests and docs have been added. |
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.
Looks good!
try { | ||
MessageDigest digest = MessageDigest.getInstance("BLAKE2B-512"); | ||
digest.update(data); | ||
return Arrays.copyOf(digest.digest(), 32); |
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.
512 = 64 bytes, so you are getting only first half?
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.
yes, exactly. That was a Vitalik's suggestion, cause not every lib supports configurable lengths for BLAKE2b
. This suggestion was agreed among implementors.
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.
Could you, please, add comment about it so it will not confuse
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
return commonConfig.keyValueDataSource("beaconchain", settings); | ||
} | ||
|
||
private DbFlushManager beaconDbFlusher; |
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.
Maybe make it non-primary Bean instead?
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.
What do you mean?
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.
@Bean("beaconDbFlusher")
public DbFlushManager beaconDbFlusher() {
beaconDbFlusher = new DbFlushManager(systemProperties, Collections.emptySet(), beaconChainDbCache());
shardingWorldManager.setBeaconDbFlusher(beaconDbFlusher);
return beaconDbFlusher;
}
and mark original dbflushmanager with @Primary
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.
Trying to keep it distant from ethereumj-core
module and do not add changes in the code of it. Actually, beaconDbFlusher
is not a fully functioning flush manager, it doesn't close databases for example, this is still lays on original flush manager. That is why it's created in such a dirty way.
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.
I got it!
} | ||
|
||
public boolean isParentOf(Beacon other) { | ||
return FastByteComparisons.equal(this.getHash(), other.getHash()); |
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.
Looks like equals
, not parent of
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.
Good catch 👍
|
||
public static final long SLOT = 0; | ||
|
||
private static final byte[] NULL = new byte[32]; |
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.
Name looks weird!
|
||
/** | ||
* Returns max block number that is presented in the store. | ||
* @return max number or -1 is store is empty |
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.
if
* Saves block to the storage. | ||
* | ||
* @param block the block | ||
* @param chainScore total score of the chain that is calculated after given block has been improted |
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.
imported
byte[] shortList = RLP.encodeList(shortItem, shortItem, shortItem); | ||
byte[] longList = RLP.encodeList(longItem, longItem, longItem); | ||
|
||
byte[] encoded = RLP.wrapList(nullArray, singleZero, singleByte, shortItem, longItem, shortList, longList); |
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.
I don't understand this
You have encodeElement
for each data piece inside wrapList
but prepared everything above with encodeElement
too
I think you should put raw data instead
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.
Not each element of wrapping list is encoded with encodeElement
. Basically, this test checks that applying wrapList
and then unwrapList
results in data items that equal to original data.
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.
I mean that you test it on safe already encoded data, while it could be used with unsafe notencoded data.
These changes are not ready for merge. PR is created in purpose of getting a feedback on general design of Beacon chain block processing part.
ToDo:
Resolves #1145