Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pacaya #18506

Draft
wants to merge 103 commits into
base: address_resolver2
Choose a base branch
from
Draft

Pacaya #18506

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
6d7b751
remove based/** tests
dantaik Nov 22, 2024
6faaab4
remove guardian prover
dantaik Nov 22, 2024
cfcd49d
rename fields (breaking ABI)
dantaik Nov 22, 2024
8c95a57
remove functions to propose/prove single block
dantaik Nov 22, 2024
7d92724
more
dantaik Nov 22, 2024
df21e18
Update SP1Verifier.t.sol
dantaik Nov 22, 2024
8e2777a
remove unused code
dantaik Nov 22, 2024
bd9be5a
Update LibProposing.sol
dantaik Nov 22, 2024
7f64bb0
remove calldata support, now blobs only!
dantaik Nov 22, 2024
e16b5b8
more
dantaik Nov 23, 2024
5a1348f
Update ITaikoL1v2.sol
dantaik Nov 23, 2024
fe697ee
more
dantaik Nov 23, 2024
5cf5986
remove code related to previous fork
dantaik Nov 24, 2024
516a7f0
Update TaikoData.sol
dantaik Nov 24, 2024
d817703
more
dantaik Nov 24, 2024
63398bf
Update TaikoData.sol
dantaik Nov 24, 2024
8d1952e
in verification, ignore tier and cooldown window
dantaik Nov 24, 2024
31d1ebe
more
dantaik Nov 24, 2024
7101960
more
dantaik Nov 24, 2024
c59f53a
more
dantaik Nov 24, 2024
5594f31
Update TaikoL1B.sol
dantaik Nov 24, 2024
d28cecb
more
dantaik Nov 24, 2024
2b49b8e
more
dantaik Nov 24, 2024
696c7e5
more
dantaik Nov 24, 2024
fc6a132
Update TaikoL1B.sol
dantaik Nov 24, 2024
88e6784
Update TaikoL1B.sol
dantaik Nov 24, 2024
2a18e50
Update TaikoL1B.sol
dantaik Nov 24, 2024
c51e2da
Update TaikoL1B.sol
dantaik Nov 24, 2024
fe3089c
Update TaikoL1B.sol
dantaik Nov 24, 2024
50ac6fa
more
dantaik Nov 24, 2024
2c07d1c
more
dantaik Nov 24, 2024
bc8afa3
Update TaikoL1.sol
dantaik Nov 24, 2024
3a47ab7
more
dantaik Nov 24, 2024
28f0c07
Update TaikoL1.sol
dantaik Nov 24, 2024
dc5f9ca
more
dantaik Nov 24, 2024
154dad8
more
dantaik Nov 24, 2024
633c593
Update TaikoL1.sol
dantaik Nov 24, 2024
6a5038e
a
dantaik Nov 24, 2024
096aea8
more
dantaik Nov 24, 2024
f821291
Update TaikoL1.sol
dantaik Nov 24, 2024
8dd531c
Update TaikoL1.sol
dantaik Nov 24, 2024
ca5afcb
Update TaikoL1.sol
dantaik Nov 24, 2024
f9e98bc
Update TaikoL1.sol
dantaik Nov 24, 2024
f628323
fmt
dantaik Nov 24, 2024
c9c4d13
Update TaikoL1.sol
dantaik Nov 24, 2024
69241e0
Update TaikoL1.sol
dantaik Nov 24, 2024
90d7fb9
more
dantaik Nov 24, 2024
0f8fc46
more
dantaik Nov 24, 2024
82cbb59
more
dantaik Nov 24, 2024
8452eed
more
dantaik Nov 24, 2024
2720f0b
Update TaikoL1.sol
dantaik Nov 24, 2024
c2f4273
Update TaikoL1.sol
dantaik Nov 24, 2024
681a6d9
more
dantaik Nov 24, 2024
640af0d
more
dantaik Nov 24, 2024
29b998c
more
dantaik Nov 25, 2024
ba76e75
Revert "more"
dantaik Nov 25, 2024
c308dde
more
dantaik Nov 25, 2024
a93f0d7
Update TaikoL1.sol
dantaik Nov 25, 2024
1cd0dc5
Update TaikoL1.sol
dantaik Nov 25, 2024
d845575
Update TaikoL1.sol
dantaik Nov 25, 2024
eb27991
Update TaikoL1.sol
dantaik Nov 25, 2024
0176d1a
Update TaikoL1.sol
dantaik Nov 25, 2024
eb19536
fmt
dantaik Nov 25, 2024
39bee55
more
dantaik Nov 25, 2024
1c42144
more
dantaik Nov 25, 2024
08cde97
more
dantaik Nov 25, 2024
d9682a8
more
dantaik Nov 25, 2024
ade51ce
Update TaikoL1.sol
dantaik Nov 25, 2024
aff3e55
more
dantaik Nov 25, 2024
6cde7ae
TaikoL1 -> Taiko
dantaik Nov 25, 2024
df440cf
x
dantaik Nov 25, 2024
925ea0a
more
dantaik Nov 26, 2024
613ae88
more
dantaik Nov 26, 2024
940af4c
Update Taiko.sol
dantaik Nov 26, 2024
db8c046
Update Taiko.sol
dantaik Nov 26, 2024
c148730
more
dantaik Nov 26, 2024
dcfcf83
more
dantaik Nov 27, 2024
0cc6052
Update Taiko.sol
dantaik Nov 27, 2024
05cf4e4
more
dantaik Nov 27, 2024
e50b6ad
Update Taiko.sol
dantaik Nov 27, 2024
f182a49
Update Taiko.sol
dantaik Nov 27, 2024
de02f26
Update Taiko.sol
dantaik Nov 27, 2024
759bbd6
Update Taiko.sol
dantaik Nov 27, 2024
7956d24
Update Taiko.sol
dantaik Nov 27, 2024
4fde9b4
Update Taiko.sol
dantaik Nov 27, 2024
040a3a6
Update Taiko.sol
dantaik Nov 27, 2024
472adac
Update Taiko.sol
dantaik Nov 27, 2024
c4c0ba4
Update Taiko.sol
dantaik Nov 27, 2024
4fd3fee
Revert "Update Taiko.sol"
dantaik Nov 27, 2024
bc414ab
Update Taiko.sol
dantaik Nov 27, 2024
1d33149
more
dantaik Nov 27, 2024
4d74cdc
more
dantaik Nov 27, 2024
6da4052
add Makefile
dantaik Nov 28, 2024
c6cdfa7
rename
dantaik Nov 28, 2024
29353f4
more
dantaik Nov 28, 2024
c73c1bf
Update README.md
dantaik Nov 28, 2024
e821f5d
more
dantaik Nov 28, 2024
3703c39
more
dantaik Nov 28, 2024
7113d03
more
dantaik Nov 28, 2024
090f295
more
dantaik Nov 28, 2024
17747bd
more
dantaik Nov 28, 2024
de6ecdc
resolve conflicts
dantaik Nov 28, 2024
4a7a726
more
dantaik Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions packages/protocol/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.DEFAULT_TARGET: help

SOLIDITY_VERSION=^0.8.24
TEST_TREE_MARKDOWN=TEST_TREE.md
SOURCE_FILES=$(shell find test -type f -name '*.t.yaml')
TREE_FILES = $(SOURCE_FILES:.t.yaml=.tree)
TARGET_TEST_FILES = $(SOURCE_FILES:.tree=.t.sol)
MAKE_TEST_TREE=deno run ./script/make-test-tree.ts
MAKEFILE=Makefile

.PHONY: help
help:
@echo "Available targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE) \
| sed -n 's/^\(.*\): \(.*\)##\(.*\)/- make \1 \3/p'

all: sync markdown ## Builds all tree files and updates the test tree markdown

sync: $(TREE_FILES) ## Scaffold or sync tree files into solidity tests
@for file in $^; do \
if [ ! -f $${file%.tree}.t.sol ]; then \
echo "[Scaffold] $${file%.tree}.t.sol" ; \
bulloak scaffold -s $(SOLIDITY_VERSION) --vm-skip -w $$file ; \
else \
echo "[Sync file] $${file%.tree}.t.sol" ; \
bulloak check --fix $$file ; \
fi \
done

check: $(TREE_FILES) ## Checks if solidity files are out of sync
bulloak check $^

markdown: $(TEST_TREE_MARKDOWN) ## Generates a markdown file with the test definitions rendered as a tree

# Internal targets

# Generate a markdown file with the test trees
$(TEST_TREE_MARKDOWN): $(TREE_FILES)
@echo "[Markdown] TEST_TREE.md"
@echo "# Test tree definitions" > $@
@echo "" >> $@
@echo "Below is the graphical definition of the contract tests implemented on [the test folder](./test)" >> $@
@echo "" >> $@

@for file in $^; do \
echo "\`\`\`" >> $@ ; \
cat $$file >> $@ ; \
echo "\`\`\`" >> $@ ; \
echo "" >> $@ ; \
done

# Internal dependencies and transformations

$(TREE_FILES): $(SOURCE_FILES)

%.tree: %.t.yaml
@for file in $^; do \
echo "[Convert] $$file -> $${file%.t.yaml}.tree" ; \
cat $$file | $(MAKE_TEST_TREE) > $${file%.t.yaml}.tree ; \
done

# Global

.PHONY: init
init: ## Check the dependencies and prompt to install if needed
@which deno > /dev/null && echo "Deno is available" || echo "Install Deno: curl -fsSL https://deno.land/install.sh | sh"
@which bulloak > /dev/null && echo "bulloak is available" || echo "Install bulloak: cargo install bulloak"

.PHONY: clean
clean: ## Clean the intermediary tree files
rm -f $(TREE_FILES)
rm -f $(TEST_TREE_MARKDOWN)
95 changes: 83 additions & 12 deletions packages/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,111 @@ 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

Tests can be described using yaml files. They will be automatically transformed into solidity test files with [bulloak](https://github.com/alexfertel/bulloak).

Create a file with `.t.yaml` extension within the `test` folder and describe a hierarchy of test cases:

```yaml
# MyTest.t.yaml

MultisigTest:
- given: proposal exists
comment: Comment here
and:
- given: proposal is in the last stage
and:
- when: proposal can advance
then:
- it: Should return true

- when: proposal cannot advance
then:
- it: Should return false

- when: proposal is not in the last stage
then:
- it: should do A
comment: This is an important remark
- it: should do B
- it: should do C

- when: proposal doesn't exist
comment: Testing edge cases here
then:
- it: should revert
```

Then install bullok with`cargo install bulloak` and use `make` to automatically sync the described branches into solidity test files.

```sh
$ make
Available targets:
Available targets:
- make all Builds all tree files and updates the test tree markdown
- make sync Scaffold or sync tree files into solidity tests
- make check Checks if solidity files are out of sync
- make markdown Generates a markdown file with the test definitions rendered as a tree
- make init Check the dependencies and prompt to install if needed
- make clean Clean the intermediary tree files

$ make sync
```

The final output will look like a human readable tree:

```
# MyTest.tree

EmergencyMultisigTest
├── Given proposal exists // Comment here
│ ├── Given proposal is in the last stage
│ │ ├── When proposal can advance
│ │ │ └── It Should return true
│ │ └── When proposal cannot advance
│ │ └── It Should return false
│ └── When proposal is not in the last stage
│ ├── It should do A // Careful here
│ ├── It should do B
│ └── It should do C
└── When proposal doesn't exist // Testing edge cases here
└── It should revert
```

### Run tests

```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