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 #4654

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

eval-exec
Copy link
Collaborator

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

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.

@eval-exec eval-exec requested a review from a team as a code owner September 21, 2024 17:29
@eval-exec eval-exec requested review from quake and removed request for a team September 21, 2024 17:29
@eval-exec eval-exec force-pushed the exec/fix-get_fee_rate_statistics branch from 1c03ef2 to 4b852e4 Compare September 21, 2024 17:32
…s `block_ext.txs_fees` length + 1

Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec force-pushed the exec/fix-get_fee_rate_statistics branch from 4b852e4 to cdb1fe1 Compare September 21, 2024 17:34
@eval-exec eval-exec added the hotfix Fixing that must be submit to RC branch. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotfix Fixing that must be submit to RC branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant