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

Adding Boottime Feature #439

Merged

Conversation

Web-Dev-Manoj
Copy link
Contributor

@Web-Dev-Manoj Web-Dev-Manoj commented Sep 4, 2023

What this PR does / why we need it:

Load only the blocks and transactions as per the configuration. Currently the configuration defines to archive or delete old data from the database. But at the bootstrap time, the Explorer tries to read every data from block 0. This can be configured to load only the data from certain point in time that is as expected by the Explorer's configuration.

This will help in speeding up the bootstrap time of Explorer, the tool and the UI will be ready in shorter period.

Which issue(s) this PR fixes:

Fixes #393

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NO

Additional documentation, usage docs, etc.:


@Web-Dev-Manoj Web-Dev-Manoj requested a review from a team as a code owner September 4, 2023 05:35
@Web-Dev-Manoj Web-Dev-Manoj force-pushed the BE-393-BootTimeFunctionality branch 2 times, most recently from 8871e56 to 4dde9e4 Compare September 4, 2023 10:40
}
}

const missingBlocks = await this.persistence
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check whether data is flowing through the missingBlocks section. since when we have new blocks added, latest blocks are also synced and added into db in the above section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, data is flowing through the missingBlocks section as expected. As new blocks are added, the latest blocks are being synced and added into the database in the above section without any issues. Everything seems to be working as expected.


// Syncing Details
logger.info(
`Syncing blocks from ${startingBlockHeight} to ${latestBlockHeight}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please see the condition when number of blocks in config.json is greater than the number of blocks in ledger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been handled. if the blocks that are mentioned in the config.json file, is greater than the blocks available, it will sync the blocks that are available at that point of time.

blockHeight
);
if (block) {
await this.processBlockEvent(client, block, noDiscovery);
Copy link
Contributor

Choose a reason for hiding this comment

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

Before calling processBlockEvent, can you please check block is available in db. If not you can add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed this by adding a conditional check in the code. Now, before calling processBlockEvent, we verify whether the block is available in the database. If the block is not present, we add it as needed. This check ensures that processBlockEvent is only executed when the required data is available in the database, helping to maintain the integrity as expected.

@ArchanaArige
Copy link
Contributor

ArchanaArige commented Sep 11, 2023

hi @Web-Dev-Manoj ,
With the above made changes w.r.t this PR,
1.can you also please check the entire application ,dashboard in the display, the total no. of blocks, transactions count is correct or not etc. Perform clean check whether this code changes are not affecting the other modules.
3.Please test the code with the mutiple channels and multiple chaincodes installed . (test with two versions of Chaincode).
Example:
channel1 - chaincode1 -v1
post some txns
channel1 - chaincode1 - v2(upgrade the chaincode)
post some txns
channel2- chaincode2
4.Modify the test-cases accordingly.
5.Read-me also undergoes the changes. Make a section for this in ReadMe and document the steps.
Thanks.

"name": "Test Network",
"profile": "./connection-profile/test-network.json",
"enableAuthentication": false,
"bootMode": "ALL",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the "noOfBlocks" as "0" in ALL mode as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, noOfBlocks parameter as "0" below "ALL" mode also.

@@ -540,6 +564,22 @@ export class CRUDService {
}
// Orderer BE-303

/**
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add what this function returns here for better understanding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added what the function is returning as mentioned.

* @memberof CRUDService
*/
async isBlockAvailableInDB(channel_genesis_hash: string, blockHeight: any) {
const count: any = await this.sql.getRowsBySQlCase(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please give specific datatype instead of 'any'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the type to 'number' replacing 'any'.

`SELECT COUNT(*) FROM blocks WHERE channel_genesis_hash= $1 AND blocknum = $2`,
[channel_genesis_hash, blockHeight]
);
console.log(count.count);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please remove the console log here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed.

Copy link
Contributor

@ArchanaArige ArchanaArige left a comment

Choose a reason for hiding this comment

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

As discussed, in the channels tab, the complete no. of txns needs to be displayed. Please fix that issue.
2.As suggested in the Readme, make a note saying that if the noOfBlocks in Custom mode is selected 0, there is still the latest block is available in postgres db.
3.In the Readme, please add the noOfBlocks in ALL mode.

@Web-Dev-Manoj
Copy link
Contributor Author

hi @Web-Dev-Manoj , With the above made changes w.r.t this PR, 1.can you also please check the entire application ,dashboard in the display, the total no. of blocks, transactions count is correct or not etc. Perform clean check whether this code changes are not affecting the other modules. 3.Please test the code with the mutiple channels and multiple chaincodes installed . (test with two versions of Chaincode). Example: channel1 - chaincode1 -v1 post some txns channel1 - chaincode1 - v2(upgrade the chaincode) post some txns channel2- chaincode2 4.Modify the test-cases accordingly. 5.Read-me also undergoes the changes. Make a section for this in ReadMe and document the steps. Thanks.

Screenshot 2023-10-16 at 11 40 16 PM

@Web-Dev-Manoj Web-Dev-Manoj force-pushed the BE-393-BootTimeFunctionality branch 2 times, most recently from d2439b3 to 0d1d899 Compare November 19, 2023 17:47
Copy link
Contributor

@ArchanaArige ArchanaArige left a comment

Choose a reason for hiding this comment

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

Please add the test-case file to the same PR. Please also squash the commits.

Signed-off-by: Web-Dev-Manoj <manojbhargav.mv@gmail.com>
Copy link
Contributor

@ArchanaArige ArchanaArige left a comment

Choose a reason for hiding this comment

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

looks good.

@ArchanaArige ArchanaArige merged commit 718e476 into hyperledger-labs:main Dec 13, 2023
8 checks passed
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.

Boot time and block/transaction loading for Explorer
4 participants