Skip to content

Commit

Permalink
Merge pull request #2 from gzanitti/hardfork_selection_docs
Browse files Browse the repository at this point in the history
Hardfork selection added to documentation
  • Loading branch information
gzanitti authored Apr 20, 2024
2 parents 1fb53b1 + d1f4ef8 commit 3ef9944
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/src/ch02-lang/ch04-macros/ch01-builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,28 @@ The fully expanded source would look like:
push32 0xa9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b
```

## Hardfork selection

### `%hardfork(...)`

The `%hardfork` macro is useful when you want to restrict the hardfork range in which the code can be compiled.

For example:

```rust
# extern crate etk_asm;
# extern crate etk_ops;
# let src = r#"
%hardfork(">london,<=cancun")
%push(0x08)
# "#;
# let mut output = Vec::new();
# let mut ingest = etk_asm::ingest::Ingest::new(&mut output, etk_ops::HardFork::Cancun);
# ingest.ingest(file!(), src).unwrap();
# assert_eq!(output, &[0x60, 0x08]);
```

can only be compiled by specifying a hardfork using the `--hardfork` flag (with the latest hardfork implemented as the default option) strictly after `London` and equal or older than `Cancun`. Non-closed ranges can also be used, as well as specific versions (e.g. `%hardfork(">london")`, `%hardfork("cancun")` and `%hardfork(">=cancun,<=cancun")` are all valids.`).

[abi]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector

0 comments on commit 3ef9944

Please sign in to comment.