Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 73 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Pull-request actions

on:
push:
branches:
- "*"
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge tests in w1
run: forge test
working-directory: ./w1
id: test_w1

- name: Run Forge tests in w2
run: forge test
working-directory: ./w2
id: test_w2

- name: Run Forge tests in w3
run: forge test
working-directory: ./w3
id: test_w3

- name: Run Forge tests in w4
run: forge test
working-directory: ./w4
id: test_w4

- name: Run Forge tests in w5
run: forge test
working-directory: ./w5
id: test_w5

- name: Run Forge tests in w6
run: forge test
working-directory: ./w6
id: test_w6

- name: Run Forge tests in w7
run: forge test
working-directory: ./w7
id: test_w7

- name: Run Forge tests in w8
run: forge test
working-directory: ./w8
id: test_w8
24 changes: 24 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[submodule "w1/lib/openzeppelin-contracts"]
path = w1/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "w1/lib/forge-std"]
path = w1/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "w2/lib/openzeppelin-contracts"]
path = w2/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "w2/lib/forge-std"]
path = w2/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "w3/lib/forge-std"]
path = w3/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "w3/lib/openzeppelin-contracts"]
path = w3/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "w4/lib/forge-std"]
path = w4/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "w4/lib/openzeppelin-contracts"]
path = w4/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Web3-Security-Dev-Batch-1-HW
The Z Institute provides two month interactive Ethereum developer training course, bringing engineers from web 2.0 to web 3.0. The excellent homeworks of the students are all open sourced. Feel free to share this with interested developers or join our [Discord](https://discord.gg/MTTgzdnXpS) to give us feedback!
# Z24028002 for Web3-Security-Dev-Batch-1-HW

## Week 1:
```
Week 1:2024/2/20
Week 2:2024/3/5
Week 3:2024/3/12
```
72 changes: 72 additions & 0 deletions w1/ test_function_gas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[560726] TokenTest::setUp()
├─ [500301] → new Token@0xF2E246BB76DF876Cef8b38ae84130F4F55De395b
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf, value: 100000000000000000000 [1e20])
│ └─ ← 3320 bytes of code
└─ ← ()

[181848] TokenTest::test_TransferAcrossMultipleAccounts()
├─ [29967] Token::mint(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 10000000000000000000 [1e19])
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, value: 10000000000000000000 [1e19])
│ └─ ← ()
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 10000000000000000000 [1e19]
├─ [25167] Token::mint(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, 9000000000000000000 [9e18])
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, value: 9000000000000000000 [9e18])
│ └─ ← ()
├─ [562] Token::balanceOf(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 9000000000000000000 [9e18]
├─ [25167] Token::mint(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, 8000000000000000000 [8e18])
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: 0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, value: 8000000000000000000 [8e18])
│ └─ ← ()
├─ [562] Token::balanceOf(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718) [staticcall]
│ └─ ← 8000000000000000000 [8e18]
├─ [3288] Token::transfer(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, 5000000000000000000 [5e18])
│ ├─ emit Transfer(from: 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, to: 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, value: 5000000000000000000 [5e18])
│ └─ ← true
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 5000000000000000000 [5e18]
├─ [562] Token::balanceOf(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 14000000000000000000 [1.4e19]
├─ [3288] Token::transfer(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, 4000000000000000000 [4e18])
│ ├─ emit Transfer(from: 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, to: 0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, value: 4000000000000000000 [4e18])
│ └─ ← true
├─ [562] Token::balanceOf(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 10000000000000000000 [1e19]
├─ [562] Token::balanceOf(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718) [staticcall]
│ └─ ← 12000000000000000000 [1.2e19]
├─ [3288] Token::transfer(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 3000000000000000000 [3e18])
│ ├─ emit Transfer(from: 0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, to: 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, value: 3000000000000000000 [3e18])
│ └─ ← true
├─ [562] Token::balanceOf(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718) [staticcall]
│ └─ ← 9000000000000000000 [9e18]
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 8000000000000000000 [8e18]
├─ [24739] Token::approve(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, 3000000000000000000 [3e18])
│ ├─ emit Approval(owner: 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, spender: 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, value: 3000000000000000000 [3e18])
│ └─ ← true
├─ [814] Token::allowance(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 3000000000000000000 [3e18]
├─ [4162] Token::transferFrom(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, 2000000000000000000 [2e18])
│ ├─ emit Transfer(from: 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, to: 0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718, value: 2000000000000000000 [2e18])
│ └─ ← true
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 6000000000000000000 [6e18]
├─ [562] Token::balanceOf(0x1efF47bc3a10a45D4B230B5d10E37751FE6AA718) [staticcall]
│ └─ ← 11000000000000000000 [1.1e19]
├─ [814] Token::allowance(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 1000000000000000000 [1e18]
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 6000000000000000000 [6e18]
├─ [562] Token::balanceOf(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 10000000000000000000 [1e19]
├─ [814] Token::allowance(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 1000000000000000000 [1e18]
├─ [814] Token::allowance(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF, 0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69) [staticcall]
│ └─ ← 1000000000000000000 [1e18]
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 6000000000000000000 [6e18]
├─ [0] VM::expectRevert(ERC20InsufficientAllowance(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69, 1000000000000000000 [1e18], 6000000000000000000 [6e18]))
│ └─ ← ()
├─ [562] Token::balanceOf(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF) [staticcall]
│ └─ ← 6000000000000000000 [6e18]
└─ ← call did not revert as expected
Loading