Some notes on dev mode
Dev mode is a boolean that can be set in the genesis file.
This is read into the Genesis struct in data/bookkeeping/genesis.go.
This is also recorded to the full node config AlgorandFullNode.
When in dev mode, the node factory MakeFull in node/node.go will initialize a frozen clock for the dev mode node.
The node will also create empty voting keys (don't need agreement) and turn off broadcasting txns to the network.
In dev mode, each transaction group is written to a block immediately.
- In
BroadcastSignedTxGroup, instead of broadcasting, we write to the block. This is only callable through thev2/transactions/sendalgod API. - There is some pre-processing done in
broadcastSignedTxGroupto remember the tx group in the pool. Then it writes the block inwriteDevModeBlock/AssembleDevModeBlock. - In
AssembleDevModeBlock, it callspool.recomputeBlockEvaluator(nil, 0)which pregenerates the block, and callsAssembleBlock.
There is a BroadcastInternalSignedTxGroup that also exits early for a dev mode block, that is called in stateproof/builder.go.
bookkeeping.Block has a BlockHeader struct that can be modified. But ValidatedBlock cannot edit the contents of the block header.
node does not have direct write access to the block header.
We can change the timestamp in pools.recomputeBlockEvaluator which is called in AssembleDevModeBlock.
In order to do so, we need to set the timestamp offset in the TransactionPool object as well, either by a direct setter or passing in params through AssembleDevModeBlock.
We may also want to pass in a "devmodeConfig" instead, if we want to change the block header in dev mode in more than one ways (e.g. set a block seed).