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

Transactions root of genesis block is incorrect #1305

Closed
6 of 20 tasks
chaoticlonghair opened this issue Aug 4, 2023 · 4 comments · Fixed by #1332, #1402, #1443, #1450 or #1468
Closed
6 of 20 tasks

Transactions root of genesis block is incorrect #1305

chaoticlonghair opened this issue Aug 4, 2023 · 4 comments · Fixed by #1332, #1402, #1443, #1450 or #1468
Assignees
Labels
t:bug Something isn't working

Comments

@chaoticlonghair
Copy link
Contributor

chaoticlonghair commented Aug 4, 2023

Current Behavior

When calculating the genesis hash as previous hash of block 1, the transactions root is not set.

I'm not sure whether there is any transactions in genesis block.

But, even there is no transactions, the transactions root still could NOT be zeros, since there is a default value RLP_NULL.

let txs_root = if !txs.hashes.is_empty() {
TrieMerkle::from_iter(txs.hashes.iter().enumerate())
.root_hash()
.unwrap_or_default()
} else {
RLP_NULL
};

pub const RLP_NULL: H256 = H256([
0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e,
0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21,
]);

Expected Behavior

Transactions root in genesis block should follow the consensus rules.

As a comparison, the receipts root and state root are refreshed before saved.

axon/core/run/src/lib.rs

Lines 168 to 172 in 8f3eded

self.apply_genesis_data(resp.state_root, resp.receipt_root)?;
log::info!("The genesis block is created {:?}", self.genesis.block);
save_block(storage, &self.genesis).await?;

OS

Not Associated

Axon version

v0.1.0-beta.5

Kernel

Not Associated

Relevant log output

No response

Anything else?

Sadly, if it has a fix, the fix will be a break change.

And, please check all of the following fields again:

"prev_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"proposer": "0x0000000000000000000000000000000000000000",
"state_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactions_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
"signed_txs_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receipts_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
"log_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"timestamp": 1679656015,
"number": 0,
"gas_used": "0x0",
"gas_limit": "0x0",
"extra_data": [],
"mixed_hash": null,
"nonce": "0x0000000000000000",
"base_fee_per_gas": "0x539",
"proof": {
"number": 0,
"round": 0,
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"signature": [],
"bitmap": []
},
"call_system_script_count": 0,
"chain_id": 2022
},

Which fields should be reset after the genesis block executed?

Select them in the following list:

  • version
  • prev_hash
  • proposer
  • state_root
  • transactions_root
  • signed_txs_hash
  • receipts_root
  • log_bloom
  • difficulty
  • timestamp
  • number
  • gas_used
  • gas_limit
  • extra_data
  • mixed_hash
  • nonce
  • base_fee_per_gas
  • proof
  • call_system_script_count
  • chain_id
@chaoticlonghair chaoticlonghair added the t:bug Something isn't working label Aug 4, 2023
@KaoImin
Copy link
Contributor

KaoImin commented Aug 4, 2023

This is a bug, the transactions root in genesis file is empty, however, Axon does not calculate the transactions root when execute genesis block.

@chaoticlonghair
Copy link
Contributor Author

chaoticlonghair commented Aug 4, 2023

How about other similar fields?

For example, signed_txs_hash, log_bloom, gas_used and so on.

p.s. I updated the description of this issue, please select the fields at there.

@Flouse
Copy link
Contributor

Flouse commented Aug 17, 2023

@KaoImin : Missing the signed_txs_hash and gas_used fields.

@KaoImin
Copy link
Contributor

KaoImin commented Aug 30, 2023

This issue is fixed in #1302 #1332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment