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

Store txs in block (write part) #4023

Open
wants to merge 13 commits into
base: feature-3.6.0
Choose a base branch
from

Conversation

BinLiu97
Copy link
Collaborator

@BinLiu97 BinLiu97 commented Nov 6, 2023

Add new tables to store txs:
SYS_NUMBER_2_BLOCK_TXS block number -> txs data (for storing txs in block)
SYS_TXHASH_2_NUMBER tx hash -> block number + index (for getTxByTxHash)

@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from 61357e6 to 3bbb960 Compare November 8, 2023 07:18
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 60 lines in your changes are missing coverage. Please review.

Comparison is base (ec31a2c) 0.00% compared to head (6890913) 63.05%.
Report is 19 commits behind head on feature-3.6.0.

❗ Current head 6890913 differs from pull request most recent head b484afa. Consider uploading reports for the commit b484afa to get more accurate results

Files Patch % Lines
bcos-ledger/src/libledger/Ledger.cpp 38.29% 56 Missing and 2 partials ⚠️
bcos-ledger/src/libledger/LedgerMethods.cpp 0.00% 1 Missing ⚠️
bcos-scheduler/src/BlockExecutive.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           feature-3.6.0    #4023       +/-   ##
==================================================
+ Coverage               0   63.05%   +63.05%     
==================================================
  Files                  0     1040     +1040     
  Lines                  0    88037    +88037     
  Branches               0    28378    +28378     
==================================================
+ Hits                   0    55516    +55516     
- Misses                 0    31455    +31455     
- Partials               0     1066     +1066     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

 into feature-3.6.0-store_txs_in_block_write
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from 36c64af to a2dfae7 Compare November 9, 2023 07:52
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch 2 times, most recently from 01a1477 to f31fa45 Compare November 10, 2023 02:30
 into feature-3.6.0-store_txs_in_block_write
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from f31fa45 to 2d05832 Compare November 10, 2023 03:08
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from 09420d8 to 9cec0ac Compare November 10, 2023 08:35
 into feature-3.6.0-store_txs_in_block_write
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from 44ce74d to 5a4fc58 Compare November 10, 2023 13:19
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch 3 times, most recently from 0f815f3 to 19675ad Compare November 14, 2023 03:10
@bxq2011hust
Copy link
Member

If this modification decreases the performance, we need a way to rollback fast, so add a switch of the feature

// if blockVersion >= 3.6, txs will be stored when commit block, not here
if (blockVersion >= uint32_t(bcos::protocol::BlockVersion::V3_6_VERSION))
{
--TOTAL_CALLBACK;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
--TOTAL_CALLBACK;
TOTAL_CALLBACK = 7;

Copy link
Member

Choose a reason for hiding this comment

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

why TOTAL_CALLBACK = 7, i think should be TOTAL_CALLBACK = 8

[txpool, block]() { txpool->storeVerifiedBlock(block); });
}

// Note: To avoid incomplete transactions in the block, the block is only stored once during commit
Copy link
Member

Choose a reason for hiding this comment

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

this should not be comment, is necessary for consensus

txHashes.push_back(concepts::bytebuffer::toView((*txsToStoreHash)[unstoredTxsCount]));

numberAndTxid[unstoredTxsCount] =
blockNumberStr + "+" + boost::lexical_cast<std::string>(unstoredTxsCount);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
blockNumberStr + "+" + boost::lexical_cast<std::string>(unstoredTxsCount);
blockNumberStr + "_" + boost::lexical_cast<std::string>(unstoredTxsCount);

bcos::protocol::Transaction::Ptr txData;
if (blockNumber == SYS_CONTRACT_DEPLOY_NUMBER)
{
txData = m_blockFactory->transactionFactory()->createTransaction(
Copy link
Member

Choose a reason for hiding this comment

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

the left doesn't have this logic? can you explain why we need this?

else
{
txData =
m_blockFactory->transactionFactory()->createTransaction(bcos::ref(encodeData));
Copy link
Member

Choose a reason for hiding this comment

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

tx is a transaction pointer, why encode and then decode?

 into feature-3.6.0-store_txs_in_block_write
@BinLiu97 BinLiu97 force-pushed the feature-3.6.0-store_txs_in_block_write branch from 1dd84db to b484afa Compare January 3, 2024 02:43
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.

None yet

3 participants