parallelchain-io / parallelchain-protocol

Specification for the ParallelChain (and ParallelChain Mainnet) blockchain protocols.
https://parallelchain.io
1 stars 1 forks source link

Blockchain v0.5 changelog #20

Closed lyulka closed 10 months ago

lyulka commented 10 months ago

Blockchain v0.5 changelog

Types

TransactionV2

"Signature" is now computed over the tuple: (2u8, Signer, Nonce, Commands, Gas Limit, Max Base Fee per Gas, Priority Fee Per Gas) instead of an “intermediate transaction” (in the tuple, 2u8 corresponds to the fact that TransactionV2 is the second version of transaction)

BlockHeaderV2

  1. The position of the "Hash" and "Height" fields are reversed.
  2. "Transactions Hash" is now the root of the binary merkle tree over the block's transactions' hashes, instead of full transactions.

Base Fee Formula

Block Base Fee Per Gas is now allowed to fall to 7 by removing $B{minbasefee}$. The Base Fee formula is now simply $B{basefee}(pbf,pgu) = pbf + B{basefeedelta}(pbf,pgu)$. $B{basefeedelta}$ is unchanged.

BlockV2

  1. "Header" is now of type BlockHeaderV2.
  2. "Transactions" is now of type Vec<TransactionV2>.

BlockDataV2

BlockDataV2 refers to the fields of protocol block that are “packed” into hotstuff_rs::Data.

  1. The order of fields is now: "Chain ID", "Proposer", "Timestamp", "Base Fee Per Gas", "Gas Used", "Transactions Hash", "Receipts Hash", "State Hash", "Logs Bloom", and then transactions and receipts. The bolded fields have been re-ordered to match the order of fields in protocol blocks.
  2. The order of fields in the Data Hash pre-image is also changed to match the new order of fields.

ReceiptV2

Receipt is now a struct type with fields:

Field Type Additional info.
Gas Used u64 The transaction's inclusion cost + the sum of the "Gas Used"s of each of the command's Command Receipts.
Exit Code ExitCodeV2 The exit code of the last command in the transaction that was executed.
Command Receipts Vec<CommandReceiptV2> Describes the execution of each command in the transaction. receipt.command_receipts.len() is always equal to transaction.commands.len(). If execution exits before a command begins executing (e.g., because of gas exhaustion), the command receipts of the non-executed commands have exit code NotExecuted.

CommandReceiptV2

Command Receipt is now an enum type. Its variants come in the same order as Command (which is unchanged), and are all structs with a common set of two fields, as well as additional fields for call, withdraw deposit, stake deposit, and unstake deposit that come after the common fields.

Common fields

Field Type Additional info.
Exit Code ExitCodeV2 Next section.
Gas Used u64 Unchanged.

Call: additional fields

Field Type
Return Value Vec<u8>
Log Vec<Log>

Withdraw Deposit: additional fields

Field Type
Amount Withdrawn u64

Stake Deposit: additional fields

Field Type
Amount Staked u64

Unstake Deposit: additional fields

Field Type
Amount Unstaked u64

ExitCodeV2

“Operation Successful” is now called “Ok”, and “Operation Failed” is now called “Error”. There is also a new “Not Executed” variant:

Variant Additional info.
Ok Rename of Operation Successful in v0.4.
Error Rename of Operation Failed in v0.4.
Gas Exhausted Unchanged.
Not Executed Transaction execution exited before the command was executed, for example due to gas exhaustion.

Timing

validate_block_for_sync

HotStuff-rs v0.3 adds a special variant of validate_block that is exclusively used in sync mode that is called validate_block_for_sync. Unlike validate_block, this function has no timing requirements and can exit as soon as possible, speeding up block sync.

Gas

Constant New value
$G_{txincl}(txn)$ TODO.
lyulka commented 10 months ago

Merged into #8.