-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add 32 byte chainwork support #2884
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
private ByteBuffer serializeBlock(StoredBlock block) { | ||
if (shouldUseLegacy12ByteChainworkFormat()) { | ||
ByteBuffer byteBuffer = ByteBuffer.allocate(StoredBlock.COMPACT_SERIALIZED_SIZE_LEGACY); | ||
block.serializeCompactLegacy(byteBuffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
StoredBlock.serializeCompactLegacy
private StoredBlock byteArrayToStoredBlock(byte[] ba) { | ||
ByteBuffer byteBuffer = ByteBuffer.wrap(ba); | ||
return StoredBlock.deserializeCompact(btcNetworkParams, byteBuffer); | ||
if (ba.length == StoredBlock.COMPACT_SERIALIZED_SIZE_LEGACY) { | ||
return deserializeCompactLegacy(btcNetworkParams, byteBuffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
StoredBlock.deserializeCompactLegacy
BridgeConstants bridgeConstants) throws IOException { | ||
String checkpointToCreate = "/rskbitcoincheckpoints/" + bridgeConstants.getBtcParams().getId() + ".checkpoints"; | ||
|
||
Path target = Paths.get(getClass().getResource(checkpointToCreate).getPath()); |
Check warning
Code scanning / CodeQL
Unsafe use of getResource Warning test
|
||
Path target = Paths.get(getClass().getResource(checkpointToCreate).getPath()); | ||
|
||
Path source = Paths.get(getClass().getResource("/checkpoints/" + checkpointFileName).getPath()); |
Check warning
Code scanning / CodeQL
Unsafe use of getResource Warning test
for (BtcBlock block : checkpoints) { | ||
storedBlock = storedBlock.build(block); | ||
storedBlock.serializeCompact(buffer); | ||
storedBlock.serializeCompactLegacy(buffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
StoredBlock.serializeCompactLegacy
rskj-core/src/test/java/co/rsk/peg/RepositoryBtcBlockStoreWithCacheChainWorkTest.java
Fixed
Show fixed
Hide fixed
|
||
int expectedCompactSerializedSize = COMPACT_SERIALIZED_SIZE_LEGACY; | ||
ByteBuffer byteBufferForExpectedBlock = ByteBuffer.allocate(expectedCompactSerializedSize); | ||
storedBlock.serializeCompactLegacy(byteBufferForExpectedBlock); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
StoredBlock.serializeCompactLegacy
private void arrangeRepositoryWithExpectedStoredBlock(StoredBlock expectedStoreBlock) { | ||
Sha256Hash expectedHash = expectedStoreBlock.getHeader().getHash(); | ||
ByteBuffer byteBuffer = ByteBuffer.allocate(COMPACT_SERIALIZED_SIZE_LEGACY); | ||
expectedStoreBlock.serializeCompactLegacy(byteBuffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
StoredBlock.serializeCompactLegacy
|
||
private void arrangeRepositoryWithExpectedChainHead(StoredBlock expectedStoreBlock) { | ||
ByteBuffer byteBuffer = ByteBuffer.allocate(COMPACT_SERIALIZED_SIZE_LEGACY); | ||
expectedStoreBlock.serializeCompactLegacy(byteBuffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
StoredBlock.serializeCompactLegacy
|
||
// assert | ||
ByteBuffer byteBuffer = ByteBuffer.allocate(COMPACT_SERIALIZED_SIZE_LEGACY); | ||
expectedStoreBlock.serializeCompactLegacy(byteBuffer); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
StoredBlock.serializeCompactLegacy
- Add the use of deserializeCompactV2
…nce RSKIP454 is activated
- Put magical number into meaningful constant variable - Put assertion blocks into methods with meaningful names
85a9cba
to
b8aff0c
Compare
// Just an arbitrary block | ||
private static final String BLOCK_HEADER = "00e00820925b77c9ff4d0036aa29f3238cde12e9af9d55c34ed30200000000000000000032a9fa3e12ef87a2327b55db6a16a1227bb381db8b269d90aa3a6e38cf39665f91b47766255d0317c1b1575f"; | ||
private static final int BLOCK_HEIGHT = 849137; | ||
private static final BtcBlock BLOCK = new BtcBlock(mainneNetworkParameters, Hex.decode(BLOCK_HEADER)); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
BtcBlock.BtcBlock
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
Description
bitcoinjThinVer
version to 0.14.4-rsk-17-SNAPSHOTserializeCompactV2
method in RepositoryBtcBlockStoreWithCachedeserializeCompactV2
method in RepositoryBtcBlockStoreWithCacheHow Has This Been Tested?
Unit tests
Types of changes
Checklist: