Skip to content

Commit 0974d96

Browse files
committed
Fix CI foundry tests and align EVM asm
1 parent 2f19972 commit 0974d96

7 files changed

Lines changed: 90 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,26 @@ jobs:
101101
env:
102102
RPC_URL: http://127.0.0.1:8545
103103
run: ./scripts/deploy_example.sh
104+
105+
foundry-legacy:
106+
name: Foundry legacy contract tests
107+
runs-on: ubuntu-latest
108+
permissions:
109+
contents: read
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
persist-credentials: false
114+
submodules: recursive
115+
116+
- name: Install Foundry
117+
working-directory: research/lean_only_proto
118+
run: ./scripts/install_foundry.sh
119+
120+
- name: Install solc
121+
working-directory: research/lean_only_proto
122+
run: ./scripts/install_solc.sh
123+
124+
- name: Run legacy Foundry tests
125+
working-directory: legacy/foundry
126+
run: forge test

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "legacy/foundry/lib/forge-std"]
2+
path = legacy/foundry/lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

legacy/foundry/foundry.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"lib/forge-std": {
3+
"tag": {
4+
"name": "v1.14.0",
5+
"rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6"
6+
}
7+
}
8+
}

legacy/foundry/lib/forge-std

Submodule forge-std added at 1801b05

research/lean_only_proto/DumbContracts/Compiler.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def exampleEntry5 : EntryPoint :=
131131
selector := 0xb61d4088
132132
returns := false }
133133

134+
def exampleEntries : List EntryPoint :=
135+
[exampleEntry, exampleEntry2, exampleEntry3, exampleEntry4, exampleEntry5]
136+
134137
def healthEntrySet : EntryPoint :=
135138
{ name := "setRisk"
136139
args := ["collateral", "debt", "minHF"]
@@ -154,4 +157,7 @@ def healthEntryCheck : EntryPoint :=
154157
selector := 0x1753bbd7
155158
returns := false }
156159

160+
def healthEntries : List EntryPoint :=
161+
[healthEntrySet, healthEntryCheck]
162+
157163
end DumbContracts.Compiler

research/lean_only_proto/DumbContracts/EvmAsm.lean

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,30 @@ def directProgramAsm : List String :=
2323
, "EQ"
2424
, "PUSH tag_addSlot"
2525
, "JUMPI"
26+
, "DUP1"
2627
, "PUSH4 0x49f583e3"
2728
, "EQ"
2829
, "PUSH tag_guardedAddSlot"
2930
, "JUMPI"
31+
, "PUSH4 0xb61d4088"
32+
, "EQ"
33+
, "PUSH tag_maxStore"
34+
, "JUMPI"
3035
, "PUSH0"
3136
, "DUP1"
3237
, "REVERT"
38+
, "tag_maxStore:"
39+
, "PUSH ret_maxStore"
40+
, "PUSH1 0x44"
41+
, "CALLDATALOAD"
42+
, "PUSH1 0x24"
43+
, "CALLDATALOAD"
44+
, "PUSH1 0x04"
45+
, "CALLDATALOAD"
46+
, "PUSH fn_maxStore"
47+
, "JUMP"
48+
, "ret_maxStore:"
49+
, "STOP"
3350
, "tag_guardedAddSlot:"
3451
, "PUSH ret_guardedAddSlot"
3552
, "PUSH1 0x24"
@@ -110,6 +127,36 @@ def directProgramAsm : List String :=
110127
, "PUSH0"
111128
, "PUSH guardedAddSlot_check"
112129
, "JUMP"
130+
, "fn_maxStore:"
131+
, "SWAP1"
132+
, "DUP3"
133+
, "SWAP1"
134+
, "DUP2"
135+
, "DUP2"
136+
, "GT"
137+
, "PUSH maxStore_then"
138+
, "JUMPI"
139+
, "maxStore_check:"
140+
, "GT"
141+
, "ISZERO"
142+
, "PUSH maxStore_else"
143+
, "JUMPI"
144+
, "maxStore_join:"
145+
, "POP"
146+
, "POP"
147+
, "JUMP"
148+
, "maxStore_else:"
149+
, "SSTORE"
150+
, "PUSH0"
151+
, "DUP1"
152+
, "PUSH maxStore_join"
153+
, "JUMP"
154+
, "maxStore_then:"
155+
, "DUP1"
156+
, "DUP4"
157+
, "SSTORE"
158+
, "PUSH maxStore_check"
159+
, "JUMP"
113160
]
114161

115162
def pretty (lines : List String) : String :=

research/lean_only_proto/Main.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ open DumbContracts.Yul
88

99
-- Emit Yul/EVM artifacts.
1010
def main : IO Unit := do
11-
let exampleProg := compileProgram [exampleEntry, exampleEntry2, exampleEntry3, exampleEntry4, exampleEntry5]
11+
let exampleProg := compileProgram exampleEntries
1212
let exampleYul := Yul.Pretty.program exampleProg
1313
IO.FS.writeFile "out/example.yul" exampleYul
14-
let healthProg := compileProgram [healthEntrySet, healthEntryCheck]
14+
let healthProg := compileProgram healthEntries
1515
let healthYul := Yul.Pretty.program healthProg
1616
IO.FS.writeFile "out/health.yul" healthYul
1717
let evmAsm := DumbContracts.EvmAsm.pretty DumbContracts.EvmAsm.directProgramAsm

0 commit comments

Comments
 (0)