This script contains a Javascript-embedable EVM assembler and a generic deployer written in assembly.
This script demostrates how to deploy different code at the same address.
- Repo: https://github.com/LCamel/ethereum-snippets/tree/main/medium_init_create2
- Article: to be published
- Article gist: https://gist.github.com/LCamel/97b7be1e36da9c5e914886b135d6769b
Replacing code with CREATE2 and CREATE.
- Repo: https://github.com/LCamel/ethereum-snippets/tree/main/medium_init_create2
- Article: to be published
- Article gist: https://gist.github.com/LCamel/bf0f173f06c6651c192b01bd48c4de74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| import { poseidon } from "circomlibjs"; // for off-line computing | |
| //import { groth16 } from "snarkjs"; | |
| //import { ethers } from "ethers"; | |
| const MAX_LEVELS = 32; | |
| class HashTower { | |
| constructor(hashInputCount) { | |
| this.hashInputCount = hashInputCount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Simulation of add() 10,000,000 items: | |
| For each add() call: | |
| average storage read = 2.33 slots | |
| average storage write = 2.33 slots | |
| average hash call = 0.33 times (PoseidonT5) | |
| lv 19 _ _ _ _ | |
| lv 18 _ _ _ _ | |
| lv 17 _ _ _ _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.18; | |
| // HACK: PROTOTYPING ONLY: use "contract" with a fixed address to avoid compiler library settings | |
| contract Poseidon4 { | |
| function poseidon(uint256[4] memory) public pure returns (uint256) {} | |
| } | |
| // goerli: after block 8166444 | |
| Poseidon4 constant P = Poseidon4(0x3b44AA63Ac599170357dC587880fC30E506612e7); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma circom 2.1.2; | |
| include "circomlib/multiplexer.circom"; | |
| // get in[row][column] | |
| template Mux2D(ROWS, COLS) { | |
| signal input in[ROWS][COLS]; | |
| signal input row; | |
| signal input column; | |
| signal output out; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma circom 2.1.2; | |
| include "circomlib/multiplexer.circom"; | |
| template PickOneFromEachRow(ROWS, COLS) { | |
| signal input in[ROWS][COLS]; | |
| signal input whichCol[ROWS]; | |
| signal output out[ROWS]; | |
| component selCol[ROWS]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma circom 2.1.2; | |
| include "circomlib/multiplexer.circom"; | |
| template PickOne(N) { | |
| signal input in[N]; | |
| signal input sel; | |
| signal output out; | |
| component mux = Multiplexer(1, N); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template instances: 88 | |
| non-linear constraints: 5128 | |
| linear constraints: 0 | |
| public inputs: 65 | |
| public outputs: 1 | |
| private inputs: 81 | |
| private outputs: 0 | |
| wires: 5238 | |
| labels: 20290 |