Skip to content

Instantly share code, notes, and snippets.

View ChihChengLiang's full-sized avatar

Chih Cheng Liang ChihChengLiang

View GitHub Profile
INFO:Detectors:
BatchManager.rollback() (contracts/rollup/BatchManager.sol#79-109) sends eth to arbitrary user
Dangerous calls:
- msg.sender.transfer(reward) (contracts/rollup/BatchManager.sol#105)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#functions-that-send-ether-to-arbitrary-destinations
INFO:Detectors:
RollupCore.checkPreviousCommitment(uint256,Types.CommitmentInclusionProof,uint256) (contracts/rollup/Rollup.sol#58-83) uses a dangerous strict equality:
- require(bool,string)(previous.path == previousPath,previous commitment has wrong path) (contracts/rollup/Rollup.sol#74-77)
BatchManager.withdrawStake(uint256) (contracts/rollup/BatchManager.sol#137-154) uses a dangerous strict equality:
- require(bool,string)(msg.sender == batches[batchID].committer(),You are not the correct committer for this batch) (contracts/rollup/BatchManager.sol#138-141)
@ChihChengLiang
ChihChengLiang / abi.json
Last active September 5, 2020 16:15
pow(x, n - 2, n)
[{"constant": true, "inputs": [{"name": "input", "type": "uint256"}], "name": "modexp", "outputs": [{"name": "", "type": "uint256"}], "payable": false, "stateMutability": "pure", "type": "function"}]
{
"pending": {
"0x000000145187b712DF7F60597D13c7908c615DfD": {
"8045": "0x000000000000006F6502B7F2bbaC8C30A3f67E9a: 0 wei + 400000 gas × 164000000000 wei"
},
"0x00000017494C2353DFcfC88d7668E0499aF1619B": {
"22874": "0x000000000000006F6502B7F2bbaC8C30A3f67E9a: 0 wei + 400000 gas × 178000000000 wei"
},
"0x00000017bCc1Ac06Df3Cc77789c6074B425549AC": {
"5168": "0x000000000000006F6502B7F2bbaC8C30A3f67E9a: 0 wei + 400000 gas × 177000000000 wei"
from misc_crypto.utils.assembly import Contract
def code_gen_stack_magic():
# VERY experimental, untested. Just a code-golf idea. By @protolambda
# needs some work to utilize in solidity. DUP opcodes are great, but a problem to embed
# TLDR from telegram:
# - push n and x on stack to get started
# - lots of DUPN operations, preparing a stack of 472 copies (within max stack size, I think), ordered exactly to repeatedly call mulmod on.
# Since there are only two cases: (xx x n) and (xx xx n), with trailing stack items that can be prepared.
pragma solidity ^0.5.15;
contract ModExp {
// 38880 execution cost
function modexp(uint256 x) public pure returns (uint256){
uint256 sq = x;
uint256 xx = 1;
uint256 n = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47;
for(uint256 i = 0; i<252; i ++){
>>> from py_ecc.optimized_bls12_381 import (
... pairing as py_ecc_pairing,
... G1,
... G2,
... multiply,
... neg,
... curve_order,
... )
>>> result = py_ecc_pairing(G2, multiply(G1, 5), False)
>>> result
[[[000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000],[000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000],[000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000],[0000000000000000000000000000000000000
paramManager 0xed0c77bd9d0c4A52e25ce63448d004Abb0F0D854
rollupUtils 0x9B28dB89d0100585A356a2797aD72FF0CF242B42
nameRegistry 0xf788ed7758612d0E17b3453666b06120Da6d81D2
governance 0x32973a6DF9187Fb2ec8CbC2BC17f4981985f25f4
logger 0x06b418d9c6ce52edCb7aCBb498dee88eC3F8165a
merkleTreeUtils 0xE19A08D306e595e13a2B2F98739374B721f0da32
blsAccountRegistry 0x097a915DcdE8663500213D1589b18F834A71639b
tokenRegistry 0x1a6C94269BfED8Fe2F8079d8c4d44742238EF38F
createAccount 0x635c5a5177ac59Ba7c9198570151Cb0dd2472434
airdrop 0xb9222ACA3974E34B1008E72922150B24E2911cA5
{
"AccountTree": "0x6127EDbf7AFB1B02eef59618cE5F11acEB885f43",
"ParamManager": "0x726B649263C5268aac81672a103678f33409Ff05",
"DepositManager": "0x06E8Fa7D1c6aC2bde12f4E4f76901A4594459E59",
"RollupContract": "0x9f47873bb239570daAD53c9C6a029Afe48bC361D",
"ProofOfBurnContract": "0x1Ba6f00ED888Bc784dEf5c0f20C0Cf1AEb5702B4",
"RollupUtilities": "0xC67D4d415bee8b2734514B68cd52181AA594fc69",
"NameRegistry": "0xC73A57D8A06863f5DC0DeF43115cf16BBBe0C0DF",
"Logger": "0x21cc370c0Bc9be4da1616331249Fcfa8e2eEA21a",
"MerkleTreeUtils": "0x8341B470c039E98f69f7e3be18AB02508ab5685D",
pragma solidity ^0.5.15;
pragma experimental ABIEncoderV2;
contract Tx {
// transaction_type: create
// [receiver_account_id<4>|receiver_state_id<4>|token<2>]
uint256 public constant TX_LEN_1 = 10;
uint256 public constant MASK_TX_1 = 0xffffffffffffffffffff;
// positions in bytes
uint256 public constant POSITION_ACCOUNT_1 = 4;