Skip to content

Instantly share code, notes, and snippets.

@cameel
cameel / erc20.sol-ERC20.xiDslifaCrDLLujnxmIuVsetcuTjersOvjmn.yul
Last active March 13, 2020 11:41
erc20.sol-ERC20.yul optimised with xiDslifaCrDLLujnxmIuVsetcuTjersOvjmn
Chromosome: xiDslifaCrDLLujnxmIuVsetcuTjersOvjmnu
Program: erc20.sol-ERC20.yul
{
mstore(64, 128)
if iszero(lt(calldatasize(), 4))
{
switch shr(224, calldataload(0))
case 0x095ea7b3 {
if callvalue() { revert(0, 0) }
let param_0, param_1 := abi_decode_tuple_t_addresst_uint256(4, calldatasize())
@cameel
cameel / Prolog.sol
Last active August 3, 2020 11:08
Proposal of the prolog contract interface v1.3
pragma solidity ^0.7.0;
// SPDX-License-Identifier: GPLv3
contract PrologContract {
struct Term {
string value; // If empty, term is a list, otherwise it's a predicate.
// value can represent an atom, variable, | or _.
Term[] children;
}
@cameel
cameel / solidity-enums-with-data.md
Last active December 16, 2023 12:59
Enums with data in Solidity

Use cases

  • Optional/nullable data types.
  • Variant data types.
  • Flag with extra information needed only in some cases (or different in different cases).
  • Modeling states in a state machine where each state can have some data associated with it.
  • List of operations for batch processing, where each operation can have its own arguments.
  • Alternative to function overloading that allows avoiding combinatorial explosion when there are multiple parameters that need variants.
  • Nested data structures with heterogenous nodes.

Syntax and semantics

@cameel
cameel / default.txt
Created February 21, 2024 13:47
solc-seqbench default/deposit_contract/soltest-inputm solc 0.8.25-seqbench.2024.2.14+commit.a2cabcb9
# Default sequence from solc 0.8.24
dhfoDgvulfnTUtnIf # None of these can make stack problems worse
[
xa[r]EscLM # Turn into SSA and simplify
cCTUtTOntnfDIul # Perform structural simplification
Lcul # Simplify again
Vcul [j] # Reverse SSA
# should have good "compilability" property here.
@cameel
cameel / always-ssa-min.txt
Created February 21, 2024 13:50
solc-seqbench always-ssa-min/deposit_contract/soltest-input solc 0.8.25-seqbench.2024.2.14+commit.a2cabcb9
# Default sequence from solc 0.8.24 adjusted to stay in SSA form instead of reversing it in each cycle.
# Minimal version - only removes the `Vcul [j]` bit.
dhfoDgvulfnTUtnIf # None of these can make stack problems worse
[
xa[r]EscLM # Turn into SSA and simplify
cCTUtTOntnfDIul # Perform structural simplification
Lcul # Simplify again
# should have good "compilability" property here.
@cameel
cameel / table.md
Created February 21, 2024 14:11
solc-seqbench default/ramanujan_pi/soltest-input solc 0.8.25-seqbench.2024.2.14+commit.a2cabcb9

default/ramanujan_pi/soltest-input

runtime-gas runtime-gas-vs-optimization-time bytecode-size bytecode-size-vs-optimization-time creation-gas creation-gas-vs-optimization-time step-duration optimization-time

@cameel
cameel / table.md
Created February 21, 2024 14:12
solc-seqbench single-pass/ramanujan_pi/soltest-input 0.8.25-seqbench.2024.2.14+commit.a2cabcb9

single-pass/ramanujan_pi/soltest-input

runtime-gas runtime-gas-vs-optimization-time bytecode-size bytecode-size-vs-optimization-time creation-gas creation-gas-vs-optimization-time step-duration optimization-time

@cameel
cameel / table.md
Created February 21, 2024 14:14
solc-seqbench always-ssa-min/ramanujan_pi/soltest-input 0.8.25-seqbench.2024.2.14+commit.a2cabcb9

always-ssa-min/ramanujan_pi/soltest-input

runtime-gas runtime-gas-vs-optimization-time bytecode-size bytecode-size-vs-optimization-time creation-gas creation-gas-vs-optimization-time step-duration optimization-time

@cameel
cameel / solc-seqbench-intro-and-initial-results.md
Last active February 21, 2024 14:16
solc-seqbench intro and initial results
@cameel
cameel / single-pass.txt
Last active February 21, 2024 14:18
solc-seqbench single-pass/deposit_contract/soltest-input 0.8.25-seqbench.2024.2.14+commit.a2cabcb9
# Default sequence from solc 0.8.24 with only a single iteration of the main loop
dhfoDgvulfnTUtnIf # None of these can make stack problems worse
xa[r]EscLM # Turn into SSA and simplify
cCTUtTOntnfDIul # Perform structural simplification
Lcul # Simplify again
Vcul [j] # Reverse SSA
# should have good "compilability" property here.