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

The genesis transactions are opaque with poor readability #1408

Closed
yangby-cryptape opened this issue Sep 6, 2023 · 1 comment · Fixed by #1443 or #1450
Closed

The genesis transactions are opaque with poor readability #1408

yangby-cryptape opened this issue Sep 6, 2023 · 1 comment · Fixed by #1443 or #1450
Assignees
Labels

Comments

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Sep 6, 2023

What happened

At present, the genesis transactions are generated from previous genesis transactions.

for (idx, tx) in genesis.txs.iter_mut().enumerate() {
let mut utx = tx.transaction.unsigned.clone();
if idx == 1 {
utx.set_data(data_0.clone().into());
} else if idx == 2 {
utx.set_data(data_1.clone().into())
}
let new_tx = build_axon_txs(&priv_key, utx, chain_id);
*tx = new_tx;
}

  • So, what are the first genesis transactions?

    How to generate the first genesis transactions?

  • Since the previous genesis transactions are binary data, how to prove they are safety and trusted, and there are no malicious behaviors in them.

Should the genesis transactions be generated from configurations?

@Flouse
Copy link
Contributor

Flouse commented Sep 12, 2023

  • So, what are the first genesis transactions?
    How to generate the first genesis transactions?

I think we should try to use genesis-generator to generate the first genesis transaction too.
@KaoImin said it is a bit complicated and needs to be carefully designed.

TODO

  • Add a document to explain how to use genesis-generator
    fn generate_genesis_block(&self, genesis_key: Secp256k1RecoverablePrivateKey) -> RichBlock {
    let metadata_0 = self.params.clone();
    let metadata_1 = {
    let mut tmp = metadata_0.clone();
    tmp.epoch = metadata_0.epoch + 1;
    tmp.version.start = metadata_0.version.end + 1;
    tmp.version.end = tmp.version.start + metadata_0.version.end - 1;
    tmp
    };
    let data_0 = encode_metadata(metadata_0);
    let data_1 = encode_metadata(metadata_1);
    let chain_id = self.genesis.chain_id;
    let txs: Vec<_> = [data_0, data_1]
    .into_iter()
    .enumerate()
    .map(|(index, data)| {
    let nonce = index as u64;
    let action = TransactionAction::Call(METADATA_CONTRACT_ADDRESS);
    let utx = build_unverified_transaction(nonce, action, data);
    build_transaction(&genesis_key, utx, chain_id)
    })
    .collect();
    let header = self.genesis.build_header();
    let tx_hashes = txs.iter().map(|tx| tx.transaction.hash).collect::<Vec<_>>();
    let block = Block { header, tx_hashes };
    RichBlock { block, txs }
    }
    }
  • In the test workflows, generate the genesis transactions from readable configurations and double check them against the genesis_xxx.json file

    In this way, the genesis-generator will be well tested too.
    => refactor: initialize chain without user-provided genesis transactions file #1450

@Flouse Flouse changed the title The genesis transactions are opaque for users, maybe malicious. The genesis transactions are opaque with poor readability Sep 12, 2023
@Flouse Flouse linked a pull request Sep 21, 2023 that will close this issue
7 tasks
@Flouse Flouse reopened this Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants