This file contains 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
// https://twitter.com/p_misirov/status/1704555126365548553 | |
// Haven't done a logic formulation exercise in a while, please let me know if I'm wrong somewhere! | |
// Formulation may not be the best, bear with me | |
X : " A did it " ; XL : " A is lying " | |
Y : " B did it " ; YL : " B is lying " | |
Z : " C did it " ; ZL : " C is lying " | |
// The following formulations express that : |
This file contains 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
setProposalThreshold(uint256) |
This file contains 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
import random | |
from Crypto.Hash import keccak | |
############################################################################################################ | |
# | |
# To find a selector collision I need to find a hash of a string with selected first 4 bytes = 32 bits | |
# hence, the chances of finding a collision is 1 / 2 ** 32 ~= 1 / 4B | |
# | |
# This script runs at ~ 65k attempts/sec on my machine. | |
# |
This file contains 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 solidity ^0.8.0; | |
contract Proxy { | |
uint256 public initializer; | |
mapping(address => uint256) private _balances; | |
uint256 private _totalSupply; | |
string public name; | |
string public symbol; |
This file contains 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
GASPRICE [gasPrice] | |
CALLDATASIZE [gasPrice, calldataSize] | |
CALLVALUE [gasPrice, calldataSize, callValue] | |
PUSH2 0x3E8 [gasPrice, calldataSize, callValue, 0x03e8] | |
PUSH0 [gasPrice, calldataSize, callValue, 0x03e8, 0x00] | |
CALLDATALOAD [gasPrice, calldataSize, callValue, 0x03e8, *first 32 bytes of calldata*] | |
PUSH1 0xf4 [gasPrice, calldataSize, callValue, 0x03e8, *first 32 bytes of calldata*, 0xf4] | |
SHR [gasPrice, calldataSize, callValue, 0x03e8, *first 12 bits of calldata*] | |
MUL [gasPrice, calldataSize, callValue, 0x03e8 * *first 12 bits of calldata*] | |
PUSH0 [gasPrice, calldataSize, callValue, 0x03e8 * *first 12 bits of calldata*, 0x00] |
This file contains 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: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-std/Test.sol"; | |
contract RetdatasizeCheck is Test { | |
Reverter reverter; | |
function setUp() public { |
This file contains 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: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-std/Test.sol"; | |
contract PackedCalldata is Test { | |
function testPackedCalldata() external { | |
bytes memory array1 = ""; | |
bytes memory array2 = array1; |
This file contains 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
function bundleToRLP(bundle) { | |
if (bundle.signedBundledTransactions === undefined) throw Error('Bundle has no transactions!'); | |
if (bundle.options === undefined) bundle.options = []; | |
const fields = [ | |
bundle.signedBundledTransactions, | |
formatNumber(bundle.blockTarget || 0), | |
formatNumber(bundle.options.minTimestamp || 0), | |
formatNumber(bundle.options.maxTimestamp || 0), |
This file contains 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
import { providers, Wallet, utils } from "ethers"; | |
import { FlashbotsBundleProvider } from "@flashbots/ethers-provider-bundle"; | |
import { encrypt, decrypt } from "eciesjs"; | |
import { encode, decode } from "@ethersproject/rlp" | |
import dotenv from "dotenv"; | |
dotenv.config(); | |
const provider = new providers.InfuraProvider("goerli", process.env.INFURA_PROJECT_ID); |