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

get_fee_rate_statistics should aware block_ext.txs_sizes length is block_ext.txs_fees length + 1 #4655

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

eval-exec
Copy link
Collaborator

@eval-exec eval-exec commented Sep 21, 2024

backport #4654

What problem does this PR solve?

#4647 didn't do the right fix.

What is changed and how it works?

We should take aware:

/// TODO(doc): @quake
#[derive(Clone, PartialEq, Default, Debug, Eq)]
pub struct BlockExt {
/// TODO(doc): @quake
pub received_at: u64,
/// TODO(doc): @quake
pub total_difficulty: U256,
/// TODO(doc): @quake
pub total_uncles_count: u64,
/// TODO(doc): @quake
pub verified: Option<bool>,
/// TODO(doc): @quake
pub txs_fees: Vec<Capacity>,
/// block txs consumed cycles
pub cycles: Option<Vec<Cycle>>,
/// block txs serialized sizes
pub txs_sizes: Option<Vec<u64>>,
}

  1. BlockExt.cycles's length is equal to BlockExt.txs_fees's length.
  2. BlockExt.cycles's length + 1 is equal to BlockExt.txs_sizes's length.

Because BlockTxsVerifier::verify skipped cellbase transaction:


But when insert BlockExt, txs_sizes have included cellbase transaction:

ckb/chain/src/verify.rs

Lines 652 to 669 in 44afc93

Ok((cycles, cache_entries)) => {
let txs_sizes = resolved
.iter()
.map(|rtx| {
rtx.transaction.data().serialized_size_in_block() as u64
})
.collect();
txn.attach_block(b)?;
attach_block_cell(&txn, b)?;
mmr.push(b.digest())
.map_err(|e| InternalErrorKind::MMR.other(e))?;
self.insert_ok_ext(
&txn,
&b.header().hash(),
ext.clone(),
Some(&cache_entries),
Some(txs_sizes),

Related changes

  • get_fee_rate_statistics should aware block_ext.txs_sizes's length is block_ext.cycles's length + 1

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Side effects

  • None

Release note

Title Only: Include only the PR title in the release note.

…s `block_ext.txs_fees` length + 1

Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec requested a review from a team as a code owner September 21, 2024 17:55
@eval-exec eval-exec changed the title Exec/backport/4654 get_fee_rate_statistics should aware block_ext.txs_sizes length is block_ext.txs_fees length + 1 Sep 21, 2024
@zhangsoledad zhangsoledad merged commit 942cb3d into nervosnetwork:rc/v0.118.x Sep 26, 2024
28 of 31 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.

2 participants