Skip to content

Instantly share code, notes, and snippets.

# Lists all contracts that return stack too deep
while IFS= read -r -d '' file; do
solc $(forge re) "$file" --bin 2>&1 | grep -q "Stack too deep"
if [ $? -eq 0 ]; then
echo "Stack too deep error found in $file"
fi
done < <(find . -type f -name "*.sol" -print0)
@mds1
mds1 / output.txt
Last active May 9, 2023 01:08
`abi.encodePacked` vs. `string.concat` (optimizer on, 200 runs, no via-ir) — bytecode of test files was also identical
$ forge test -vvv
[⠢] Compiling...
[⠒] Compiling 1 files with 0.8.19
[⠆] Solc 0.8.19 finished in 887.23ms
Compiler run successful!
Running 1 test for test/Counter.t.sol:TestShort_EncodePacked
[PASS] test1() (gas: 4373)
Logs:
462
@mds1
mds1 / attestation.txt
Created April 8, 2022 01:19
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 213
Hash: e151caa0 f68c45c9 521936ac 72ea45fa
d5f81a81 5635dbc8 0aadb257 b497cdc2
7aca4e2f 41a80f82 0d6166dc 05c855be
71f22e19 5f8f7b91 af9fde2e cbe91833
@mds1
mds1 / trace-compound-proposal-43.json
Created November 11, 2021 22:33
Output of running `debug_traceTransaction` on transaction 0xbd7e9da57c31931f54c05679a31bb51232b0f2ee3f5fbde53f3c7c7f02b2a480 in Hardhat. That transaction executes Compound governance proposal #43
This file has been truncated, but you can view the full file.
{
"gas": 122835,
"failed": false,
"returnValue": "",
"structLogs": [
{ "pc": 0, "op": "PUSH1", "gas": 170816, "gasCost": 3, "depth": 1, "stack": [], "memory": [], "storage": {} },
{
"pc": 2,
"op": "PUSH1",
"gas": 170813,
@mds1
mds1 / slot.ts
Created September 8, 2021 12:36
Solidity and Vyper storage slot calcuations
import { defaultAbiCoder } from '@ethersproject/abi';
import { hexZeroPad, hexStripZeros } from '@ethersproject/bytes';
import { keccak256 } from '@ethersproject/keccak256';
// `defaultAbiCoder.encode` is equivalent to Solidity's `abi.encode()`, and we strip leading zeros from the hashed
// value to conform to the JSON-RPC spec: https://ethereum.org/en/developers/docs/apis/json-rpc/#hex-value-encoding
// Returns the storage slot for a Solidity mapping from an `address` to a value, given the slot of the mapping itself,
// `mappingSlot`. Read more at https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#mappings-and-dynamic-arrays
const getSolidityStorageSlot = (mappingSlot: string, address: string) => {
@mds1
mds1 / attestation.txt
Created September 3, 2021 00:11
Attestation
I contributed to the clr.fund Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: qvt32
Contributor # 20
Hash: undefined
Circuit: batchUst 32
Contributor # 18
Hash: 95e28af0 665f15ed 58d9b69c bece457e
a6d318a4 8227d43c 3757a7e1 6a6a77ca
# Ethereum helper methods
# source this in your .bashrc or .zshrc file with `. ~/.ethrc`
# --- Solidity sandbox ---
# https://github.com/maurelian/solidity-sandbox
scratch() {
dir=$(pwd)
cd ~/Documents/projects/solidity-sandbox || exit
bash newTest.sh $1
cd "$dir" || exit
const ethers = require('ethers');
const { BigNumber } = ethers;
(async function () {
const provider = ethers.providers.getDefaultProvider();
const multicallAbi = [ { constant: false, inputs: [ { components: [ { internalType: 'address', name: 'target', type: 'address' }, { internalType: 'bytes', name: 'callData', type: 'bytes' }, ], internalType: 'struct Multicall.Call[]', name: 'calls', type: 'tuple[]', }, ], name: 'aggregate', outputs: [ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' }, { internalType: 'bytes[]', name: 'returnData', type: 'bytes[]' }, ], payable: false, stateMutability: 'nonpayable', type: 'function', }, { constant: true, inputs: [{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }], name: 'getBlockHash', outputs: [{ internalType: 'bytes32', name: 'blockHash', type: 'bytes32' }], payable: false, stateMutability: 'view', type: 'function', }, { constant: true, inputs: [], name: 'getCurrentBlockCoinbase', outputs: [{ internalType: 'address', name: 'coinbase',
// Get current block from ganache-cli
let block = await web3.eth.getBlock('latest');
// Log initial timestamp -- logs 1535296387
console.log(block.timestamp);
// Increase time by a huge amount simply to make it easier to distinguish
// between the logged 10-digit numbers (this changes leading digit from a
// 1 to a 2)
await increaseTime(533868440);
/**
* Increase EVM time in ganache-cli to simulate calls in the future
* @param integer Number of seconds to increase time by
*/
async function increaseTime(integer) {
// First we increase the time
await web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [integer],