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

Proposal: Hardfork selection via flag #135

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
e723a65
WIP
gzanitti Sep 12, 2023
d8da052
Trying some ideas
gzanitti Sep 12, 2023
027154c
Still WIP. Need to call finish() at the end.
gzanitti Sep 13, 2023
27321ce
Issue with internal labels (macros)
gzanitti Sep 13, 2023
95a2fd4
Some tests passing. Issue with includes
gzanitti Sep 14, 2023
ea5a590
All ASM test passing
gzanitti Sep 15, 2023
ea1668b
Fixing delayed Macros by insertion. Issue with misplaced internal lab…
gzanitti Sep 15, 2023
53e12a3
Progress in Macro delayed, 3/34 tests failing
gzanitti Sep 15, 2023
4df5199
Tests: 39 passed; 2 failed; Need to find a way to compute the size of…
gzanitti Sep 18, 2023
2be1ee3
ingest_import_in_include failing. Need to check concrete_len during i…
gzanitti Sep 18, 2023
b6b23ba
cargo test: all tests passing :tada:. Code needs to be cleaned before…
gzanitti Sep 19, 2023
03a4990
Issue 124 has been fixed. A new test has been added to ensure that it…
gzanitti Sep 19, 2023
93c66c9
Code cleaning
gzanitti Sep 19, 2023
a7c1d96
push_ready renamed to push_rawop
gzanitti Sep 19, 2023
6f0634a
Rustfmt
gzanitti Sep 19, 2023
da7afe0
Rustfmt in dasm (not related but fixed)
gzanitti Sep 19, 2023
5530125
Rustfmt in ecfg (not related but fixed)
gzanitti Sep 20, 2023
2114ffe
Output cleaning
gzanitti Sep 27, 2023
f1bb884
Several changes to simplify the compiler. It's still a PoC: the code …
gzanitti Oct 2, 2023
b72d608
Rewriting and Simplification. Some tests still need to be solved and …
gzanitti Oct 2, 2023
6319fc2
Code reorganization. Still work in progress.
gzanitti Oct 3, 2023
be7c9f0
Label insertion with built-in operation, fixed
gzanitti Oct 4, 2023
5ac947e
Label insertion with built-in operation (minor fix) & Rustfmt modific…
gzanitti Oct 4, 2023
ce47057
Path resolution. More testing is needed
gzanitti Oct 4, 2023
e6ff678
Test, code cleaning, etc
gzanitti Oct 5, 2023
1f46965
Test with short-circuit evaluation
gzanitti Oct 5, 2023
2c68611
Undoing of the modifications to the expected values of the tests. Add…
gzanitti Oct 6, 2023
ee04157
Code restructuring. push_all replaced by assemble
gzanitti Oct 6, 2023
859e85b
Minor changes in docs
gzanitti Oct 6, 2023
7bbfe8e
Added tests mentioned in issue #108
gzanitti Oct 6, 2023
6a25d9d
Better error during parsing. Issue #82
gzanitti Oct 10, 2023
5ad5da0
Hardfork selection minimal backbone
gzanitti Oct 12, 2023
f3da1c6
Hardfork selection: firsts ideas
gzanitti Oct 18, 2023
1bf12c8
More progress towards Hardfork selection
gzanitti Oct 19, 2023
25c28bb
More progress towards Hardfork selection
gzanitti Oct 19, 2023
7f7d593
Fixed import
gzanitti Oct 20, 2023
25e69b6
etk_ops added to etk_analyze
gzanitti Oct 20, 2023
0acdf8c
etk_ops added to etk_analyze
gzanitti Oct 20, 2023
57e8df5
Test moved from Default (Prague) to Cancun due to jumpdest deprecation
gzanitti Oct 20, 2023
0743a79
Hardfork Prague removed until needed
gzanitti Oct 20, 2023
1771e88
Better error reporting
gzanitti Oct 20, 2023
2020229
Various fixes
gzanitti Oct 20, 2023
f2a32ab
Updated doc
gzanitti Oct 23, 2023
6dcd471
Missing ;
gzanitti Oct 23, 2023
265aa0a
Progress with new macro %hardfork("...")
gzanitti Oct 25, 2023
4e472c9
Better error reporting. More tests
gzanitti Oct 26, 2023
3fecdd1
Limit hardforks to ASCII_ALPHA
gzanitti Oct 26, 2023
12c609c
Assembler simplification
gzanitti Sep 12, 2023
b872b50
Rustfmt: Into to From
gzanitti Oct 27, 2023
73c3060
Unused vars removed
gzanitti Oct 27, 2023
dbb2bc8
More tests. Better ranges
gzanitti Oct 27, 2023
eb36696
addressing comments
gzanitti Oct 30, 2023
c355aa2
addressing comments
gzanitti Oct 30, 2023
27fc550
Dynamic push: new test
gzanitti Oct 31, 2023
a549703
Dynamic push: new test
gzanitti Oct 31, 2023
91a797e
Minor fix and new test
gzanitti Nov 8, 2023
26ff19d
Fix issue with labels + expressions in dynamic push
gzanitti Nov 9, 2023
e904798
Fix issue with labels + expressions in dynamic push (rustfmt)
gzanitti Nov 9, 2023
8cc1b5f
Minor changes
gzanitti Nov 9, 2023
62b3510
PendingLabel removed
gzanitti Nov 9, 2023
02492b2
Into -> From for &AbstractOp
gzanitti Nov 9, 2023
4dcfd94
Better naming. Code reorg.
gzanitti Nov 9, 2023
9fd54c9
Better naming. Code reorg.
gzanitti Nov 9, 2023
8296d16
Better naming.
gzanitti Nov 9, 2023
f9bc8cc
Code reorg.
gzanitti Nov 9, 2023
0d2a2a7
Minor changes to merge backend simplification
gzanitti Nov 10, 2023
e8ffd1f
Minor changes to merge backend simplification
gzanitti Nov 10, 2023
00fcdca
Updated to backend simplification (last version)
gzanitti Nov 10, 2023
91f318b
Updated to backend simplification (last version)
gzanitti Nov 10, 2023
9a5ff95
Updated to backend simplification (last version)
gzanitti Nov 10, 2023
9c6297d
Updated to backend simplification (last version)
gzanitti Nov 10, 2023
445171f
Minor fix test
gzanitti Nov 10, 2023
f0c26cc
Merged with master
gzanitti Jan 29, 2024
531c77a
clippy
gzanitti Jan 29, 2024
e563f51
directives.first()
gzanitti Jan 29, 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
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion doc/src/ch02-lang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This example should increment a value from 0 to 255 on the stack, then halt exec

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push1 0x00

Expand All @@ -28,7 +29,7 @@ loop:
pop
stop # This halts execution
# "#;
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new());
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new(), etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
```

Expand Down
12 changes: 8 additions & 4 deletions doc/src/ch02-lang/ch02-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ While an assembled `push` must have a concrete value, it is often useful when de

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push1 1+(2*3)/4
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x02]);
```
Expand Down Expand Up @@ -50,12 +51,13 @@ A [label](ch03-labels.md) may be used as a term in an expression.

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
start:
push1 start + 1
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x01]);
```
Expand All @@ -66,11 +68,12 @@ start:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push4 selector("transfer(uint256,uint256)")
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x63, 12, 247, 158, 10]);
```
Expand All @@ -83,6 +86,7 @@ Expressions support the following binary operators:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push1 1+2 # addition
push1 1*2 # multiplication
Expand All @@ -91,7 +95,7 @@ push1 2/2 # division

# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x03, 0x60, 0x02, 0x60, 0x01, 0x60, 0x01]);
```
6 changes: 4 additions & 2 deletions doc/src/ch02-lang/ch03-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Manually counting out jump destination addresses would be a monumentally pointle

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
label0: # <- This is a label called "label0",
## and it has the value 0, since it is
Expand All @@ -16,7 +17,7 @@ label0: # <- This is a label called "label0",
jump # Now we jump to zero, which is a
## `jumpdest` instruction, looping forever.
# "#;
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new());
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new(), etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
```

Expand All @@ -34,6 +35,7 @@ That's not all! You can also use labels to calculate lengths:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push1 start
push1 end
Expand All @@ -46,7 +48,7 @@ start:
pc
end:
# "#;
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new());
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new(), etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
```

Expand Down
6 changes: 4 additions & 2 deletions doc/src/ch02-lang/ch04-macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ An instruction macro looks like this:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%macro push_sum(a, b)
push1 $a + $b
Expand All @@ -20,7 +21,7 @@ An instruction macro looks like this:
%push_sum(4, 2)
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x06]);
```
Expand All @@ -37,6 +38,7 @@ Expression macros _do not_ begin with `%`, and cannot replace instructions. Inst

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%def add_one(num)
$num+1
Expand All @@ -45,7 +47,7 @@ Expression macros _do not_ begin with `%`, and cannot replace instructions. Inst
push1 add_one(41)
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x2a]);
```
Expand Down
9 changes: 6 additions & 3 deletions doc/src/ch02-lang/ch04-macros/ch01-builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ For example:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%push(hello)

hello:
jumpdest
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x02, 0x5b]);
```
Expand All @@ -108,11 +109,12 @@ For example:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push4 selector("transfer(address,uint256)") # <- expands to 0x63a9059cbb
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x63, 0xa9, 0x05, 0x9c, 0xbb]);
```
Expand All @@ -131,11 +133,12 @@ For example:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
push32 topic("transfer(address,uint256)")
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x7f, 169, 5, 156, 187, 42, 176, 158, 178, 25, 88, 63, 74, 89, 165, 208, 98, 58, 222, 52, 109, 150, 43, 205, 78, 70, 177, 29, 160, 71, 201, 4, 155]);
```
Expand Down
6 changes: 4 additions & 2 deletions doc/src/ch02-lang/ch04-macros/ch02-expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Expression macros can accept an arbitrary number of parameters. Parameters are r

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%def my_macro()
42
Expand All @@ -17,7 +18,7 @@ Expression macros can accept an arbitrary number of parameters. Parameters are r
$x+$y+$z
%end
# "#;
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new());
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new(), etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
```

Expand All @@ -27,6 +28,7 @@ Expression macros can be invoked anywhere an expression is expected.

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
# %def my_macro()
# 42
Expand All @@ -38,7 +40,7 @@ push1 my_macro()
push1 sum(1, 2, my_macro())
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x2a, 0x60, 0x2d]);
```
6 changes: 4 additions & 2 deletions doc/src/ch02-lang/ch04-macros/ch03-instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Instruction macros can accept an arbitrary number of parameters. Parameters are

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%macro my_macro()
push1 42
Expand All @@ -17,7 +18,7 @@ Instruction macros can accept an arbitrary number of parameters. Parameters are
push1 $x+$y+$z
%end
# "#;
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new());
# let mut ingest = etk_asm::ingest::Ingest::new(Vec::new(), etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
```

Expand All @@ -27,6 +28,7 @@ Expression macros can be invoked anywhere an instruction is expected.

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
# %macro my_macro()
# push1 42
Expand All @@ -38,7 +40,7 @@ Expression macros can be invoked anywhere an instruction is expected.
%sum(1, 2, 3)
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output);
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x2a, 0x60, 0x06]);
```
12 changes: 10 additions & 2 deletions etk-analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
name = "etk-analyze"
version = "0.4.0-dev"
edition = "2018"
authors = ["Sam Wilson <[email protected]>", "lightclient <[email protected]>"]
authors = [
"Sam Wilson <[email protected]>",
"lightclient <[email protected]>",
]
license = "MIT OR Apache-2.0"
description = "EVM Toolkit analysis tools"
homepage = "https://quilt.github.io/etk"
repository = "https://github.com/quilt/etk"
readme = "README.md"
keywords = ["etk", "ethereum"]
categories = ["cryptography::cryptocurrencies", "command-line-utilities", "development-tools"]
categories = [
"cryptography::cryptocurrencies",
"command-line-utilities",
"development-tools",
]

[features]
cli = ["etk-cli", "etk-asm", "clap", "snafu"]
Expand All @@ -20,6 +27,7 @@ clap = { optional = true, version = "3.1", features = ["derive"] }
etk-cli = { optional = true, path = "../etk-cli", version = "0.4.0-dev" }
etk-asm = { optional = true, path = "../etk-asm", version = "0.4.0-dev" }
etk-dasm = { path = "../etk-dasm", version = "0.4.0-dev" }
etk-ops = { path = "../etk-ops", version = "0.4.0-dev" }
z3 = { version = "0.11.2", features = ["static-link-z3"] }

[dependencies.petgraph]
Expand Down
3 changes: 2 additions & 1 deletion etk-analyze/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ mod tests {

use etk_asm::disasm::Disassembler;
use etk_asm::ingest::Ingest;
use etk_ops::HardFork;

use etk_dasm::blocks::basic::Separator;

Expand Down Expand Up @@ -328,7 +329,7 @@ mod tests {
{
fn compile(&self) -> Disassembler {
let mut output = Disassembler::new();
Ingest::new(&mut output)
Ingest::new(&mut output, HardFork::Cancun)
.ingest("./test", self.source)
.unwrap();
output
Expand Down
Loading
Loading