Skip to content

Commit

Permalink
Pacaya (#18506)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Nov 29, 2024
1 parent baf6cfa commit 5665274
Show file tree
Hide file tree
Showing 80 changed files with 14,358 additions and 22,367 deletions.
23 changes: 11 additions & 12 deletions packages/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,39 @@ To install dependencies:
foundryup && pnpm install
```

## Compilation and Testing
## Compilation

Taiko’s protocol is split between Layer 1 (L1) and Layer 2 (L2). The smart contracts need to be compiled and tested separately for each layer:

### Layer 1 (Ethereum, Duncan Hardfork)

To compile, run tests, and generate the storage layout for L1:
To compile and generate the storage layout for L1:

```bash
pnpm compile:l1
pnpm test:l1
pnpm layout:l1
```

### Layer 2 (Taiko, Shanghai Hardfork)

Similarly, for L2:

```bash
pnpm compile:l2
pnpm test:l2
pnpm layout:l2
```

### Compile and Test for Both Layers

To compile and test contracts for both L1 and L2 at once:
To compile and generate the storage layout for both layers:

```bash
pnpm compile
pnpm test
pnpm layout
```

## Testing

```bash
pnpm test:l1
pnpm test:l2
pnpm test
```

## Layer 2 Genesis Block

### Generating a Dummy Genesis Block
Expand Down
65 changes: 65 additions & 0 deletions packages/protocol/TEST_TREE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Test tree definitions

Below is the graphical definition of the contract tests implemented on [the test folder](./test)

```
TaikoL1Test
└── When a new TaikoL1 with 10 block slots and a sync interval of 5
β”œβ”€β”€ When test1
β”‚ └── When case-1
β”‚ β”œβ”€β”€ It initializes the genesis block
β”‚ β”œβ”€β”€ It initializes the first transition
β”‚ β”œβ”€β”€ It finalizes the genesis block
β”‚ β”œβ”€β”€ It counts total blocks as 1
β”‚ β”œβ”€β”€ It retrieves correct data for the genesis block
β”‚ β”œβ”€β”€ It retrieves correct data for the genesis block's first transition
β”‚ β”œβ”€β”€ It fails to retrieve block 1, indicating block not found
β”‚ β”œβ”€β”€ It returns the genesis block and its first transition for getLastVerifiedTransitionV3
β”‚ └── It returns empty data for getLastSyncedTransitionV3 but does not revert
β”œβ”€β”€ When proposing one more block with custom parameters
β”‚ └── When case-2
β”‚ β”œβ”€β”€ It places the block in the first slot
β”‚ β”œβ”€β”€ It sets the block's next transition id to 1
β”‚ β”œβ”€β”€ It the returned metahash should match the block's metahash
β”‚ β”œβ”€β”€ It matches the block's timestamp and anchor block id with the parameters
β”‚ β”œβ”€β”€ It total block count is 2
β”‚ └── It retrieves correct data for block 1
β”œβ”€β”€ When proposing one more block with default parameters
β”‚ └── When case-3
β”‚ β”œβ”€β”€ It places the block in the first slot
β”‚ β”œβ”€β”€ It sets the block's next transition id to 1
β”‚ β”œβ”€β”€ It the returned metahash should match the block's metahash
β”‚ β”œβ”€β”€ It sets the block's timestamp to the current timestamp
β”‚ β”œβ”€β”€ It sets the block's anchor block id to block.number - 1
β”‚ β”œβ”€β”€ It total block count is 2
β”‚ └── It retrieves correct data for block 1
β”œβ”€β”€ When proposing one more block with default parameters but nonzero parentMetaHash
β”‚ └── When case-4
β”‚ β”œβ”€β”€ It does not revert when the first block's parentMetaHash matches the genesis block's metahash
β”‚ └── It reverts when proposing a second block with a random parentMetaHash
└── When proposing 9 blocks as a batch to fill all slots
β”œβ”€β”€ When propose the 11th block before previous blocks are verified
β”‚ └── When case-5
β”‚ └── It reverts indicating no more slots available
β”œβ”€β”€ When prove all existing blocks with correct first transitions
β”‚ β”œβ”€β”€ When proposing the 11th block after previous blocks are verified
β”‚ β”‚ └── When case-6
β”‚ β”‚ β”œβ”€β”€ It total block count is 12
β”‚ β”‚ └── It getBlockV3(0) reverts indicating block not found
β”‚ └── When case-7
β”‚ β”œβ”€β”€ It total block count is 10
β”‚ β”œβ”€β”€ It returns the block 9 and its first transition for getLastVerifiedTransitionV3
β”‚ └── It returns the block 5 and its first transition for getLastSyncedTransitionV3
β”œβ”€β”€ When prove all existing blocks with wrong first transitions
β”‚ β”œβ”€β”€ When prove all existing blocks with correct first transitions2
β”‚ β”‚ └── When case-8
β”‚ β”‚ β”œβ”€β”€ It total block count is 10
β”‚ β”‚ β”œβ”€β”€ It returns the block 9 and its first transition for getLastVerifiedTransitionV3
β”‚ β”‚ └── It returns the block 5 and its first transition for getLastSyncedTransitionV3
β”‚ └── When case-9
β”‚ β”œβ”€β”€ It total block count is 10
β”‚ β”œβ”€β”€ It returns the genesis block and its first transition for getLastVerifiedTransitionV3
β”‚ └── It returns empty data for getLastSyncedTransitionV3 but does not revert
└── When case-10
└── It total block count is 10
```
Loading

0 comments on commit 5665274

Please sign in to comment.