Metapunk Community

Cover image for Q&A with Self-built Blockchain and Dapps (1)
Yongchang He
Yongchang He

Posted on

Q&A with Self-built Blockchain and Dapps (1)

The purpose of building this blog is to write down my memo for learning the dApps.

Q1: Is there any way to unlock the geth account permanently?

I have created a dapp where the user can sign a contract using metamask. However, the account that gets the money sent to keeps getting locked. Sure, I can manually unlock it, but this is really annoying. Is there any way to automate this, that it remains unlocked?

A1: You can unlock it for as long as the geth instance is running using a 0 as the duration parameter:

web3.personal.unlockAccount("address", "pass", 0);

Q2: What does block reached canonical chain mean?

In my geth node I see sometimes on the output the message: block reached canonical chain. I tried googling for the answer but could not find one. Does anyone know what this means?

Image description

A2: Without knowing why geth decides to write it like that I can give you a generic answer.

Canonical chain is the chain that is agreed to be the 'main' chain and not one of the side-chains which end. In theory it is never 100% sure which chain is the canonical chain. In theory you could still revert block number 1 (or is it block 2 which is after the genesis block) by continuing its side-chains with enough hashing power.

In practise different parties decide for themselves how many blocks they require on top of the block they're interested in for it to be considered part of the canonical chain. The more blocks there are mined on top of it, the more likely the block is to be part of the canonical chain. That is also what exchanges are referring to when they "require X confirmations" for transfers before accepting them. Typically this number is something like 5-10 for Ethereum.

So, I assume geth has decided on an internal X for the number of confirmations it requires for a block to be considered part of the canonical chain. And when a block has reached that amount of confirmations (blocks on top of it) geth tells you a block has reached canonical chain.


Top comments (0)