Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(all): changes base on protocol's tokenomics_implementation (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 4, 2023
1 parent 1047ddd commit 42cbe97
Show file tree
Hide file tree
Showing 34 changed files with 317 additions and 970 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38
191eb110990d60b49883eb3f3d7841c33421d067
6 changes: 3 additions & 3 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func init() {
}

// EncodeBlockMetadata performs the solidity `abi.encode` for the given blockMetadata.
func EncodeBlockMetadata(meta *bindings.LibDataBlockMetadata) ([]byte, error) {
func EncodeBlockMetadata(meta *bindings.TaikoDataBlockMetadata) ([]byte, error) {
b, err := blockMetadataArgs.Pack(meta)
if err != nil {
return nil, fmt.Errorf("failed to abi.encode block metadata, %w", err)
Expand All @@ -204,7 +204,7 @@ func EncodeCommitHash(beneficiary common.Address, txListHash [32]byte) []byte {
}

// EncodeProposeBlockInput encodes the input params for TaikoL1.proposeBlock.
func EncodeProposeBlockInput(meta *bindings.LibDataBlockMetadata, txListBytes []byte) ([][]byte, error) {
func EncodeProposeBlockInput(meta *bindings.TaikoDataBlockMetadata, txListBytes []byte) ([][]byte, error) {
metaBytes, err := EncodeBlockMetadata(meta)
if err != nil {
return nil, err
Expand Down Expand Up @@ -239,7 +239,7 @@ func EncodeProveBlockInput(
// EncodeProveBlockInvalidInput encodes the input params for TaikoL1.proveBlockInvalid.
func EncodeProveBlockInvalidInput(
evidence *TaikoL1Evidence,
target *bindings.LibDataBlockMetadata,
target *bindings.TaikoDataBlockMetadata,
receipt *types.Receipt,
) ([][]byte, error) {
evidenceBytes, err := EncodeEvidence(evidence)
Expand Down
2 changes: 1 addition & 1 deletion bindings/encoding/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestDecodeEvidenceHeader(t *testing.T) {
require.NotNil(t, err)

b, err := EncodeEvidence(&TaikoL1Evidence{
Meta: bindings.LibDataBlockMetadata{
Meta: bindings.TaikoDataBlockMetadata{
Id: new(big.Int).SetUint64(rand.Uint64()),
L1Height: new(big.Int).SetUint64(rand.Uint64()),
L1Hash: testutils.RandomHash(),
Expand Down
2 changes: 1 addition & 1 deletion bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type BlockHeader struct {
}

type TaikoL1Evidence struct {
Meta bindings.LibDataBlockMetadata
Meta bindings.TaikoDataBlockMetadata
Header BlockHeader
Prover common.Address
Proofs [][]byte
Expand Down
2 changes: 1 addition & 1 deletion bindings/encoding/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
Nonce: types.EncodeNonce(rand.Uint64()),
BaseFee: new(big.Int).SetUint64(rand.Uint64()),
}
testMeta = bindings.LibDataBlockMetadata{
testMeta = bindings.TaikoDataBlockMetadata{
Id: new(big.Int).SetUint64(rand.Uint64()),
L1Height: new(big.Int).SetUint64(rand.Uint64()),
L1Hash: testutils.RandomHash(),
Expand Down
807 changes: 138 additions & 669 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

72 changes: 46 additions & 26 deletions bindings/gen_taiko_l2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 7 additions & 18 deletions bindings/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,18 @@ import (
"math/big"
)

// ProtocolConstants contains some constants used by Taiko protocol, defined in protocol's LibConstants.
// NOTE: this struct *MUST* match the return values of TaikoL1.getConstants method.
// ref: https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/contracts/libs/LibConstants.sol
type ProtocolConstants struct {
ZKProofsPerBlock *big.Int // uint256 K_ZKPROOFS_PER_BLOCK
ChainID *big.Int // uint256 K_CHAIN_ID
MaxNumBlocks *big.Int // uint256 K_MAX_NUM_BLOCKS
MaxVerificationsPerTx *big.Int // uint256 K_MAX_VERIFICATIONS_PER_TX
CommitDelayConfirmations *big.Int // uint256 K_COMMIT_DELAY_CONFIRMS
MaxProofsPerForkChoice *big.Int // uint256 K_MAX_PROOFS_PER_FORK_CHOICE
BlockMaxGasLimit *big.Int // uint256 K_BLOCK_MAX_GAS_LIMIT
BlockMaxTxs *big.Int // uint256 K_BLOCK_MAX_TXS
TxListMaxBytes *big.Int // uint256 K_TXLIST_MAX_BYTES
TxMinGasLimit *big.Int // uint256 K_TX_MIN_GAS_LIMIT
AnchorTxGasLimit *big.Int // uint256 K_ANCHOR_TX_GAS_LIMIT
}

// ProtocolStateVariables contains some state variables used by Taiko protocol, defined in protocol's LibData.
// NOTE: this struct *MUST* match the return values of TaikoL1.getStateVariables method.
// ref: https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/contracts/L1/LibData.sol
type ProtocolStateVariables struct {
GenesisHeight uint64
GenesisTimestamp uint64
StatusBits uint64
FeeBase *big.Int
NextBlockID uint64
LastProposedAt uint64
AvgBlockTime uint64
LatestVerifiedHeight uint64
LatestVerifiedID uint64
NextBlockID uint64
AvgProofTime uint64
}
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Proposing a block involves a few steps:
1. Fetch the pending transactions from the L2 execution engine through the `txpool_content` RPC method.
2. If there are too many pending transactions in the L2 execution engine, split them into several smaller txLists. This is because the Taiko protocol restricts the max size of each proposed txList.
3. Commit hashes of the txLists by sending `TaikoL1.commitBlock` transactions to L1.
4. Wait for `LibConstants.TAIKO_COMMIT_DELAY_CONFIRMATIONS` (currently `4`) L1 blocks confirmations.
4. Wait for `TaikoData.Config.commitConfirmations` (currently `0`) L1 blocks confirmations.
5. Propose all splitted txLists by sending `TaikoL1.proposeBlock` transactions.

## Prover
Expand Down
Loading

0 comments on commit 42cbe97

Please sign in to comment.