Skip to content

Instantly share code, notes, and snippets.

View dmarzzz's full-sized avatar

dmarz dmarzzz

View GitHub Profile
@dmarzzz
dmarzzz / gist:21827db7b9303088577dc1cca0dd23b4
Last active February 2, 2024 16:42
Generate Access List Example
import requests
import json
def generate_access_list_from_statediff():
response = '''
{"jsonrpc": "2.0", "result": {"output": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000001f161421c8e0000000000000000000000000000000000000000000000000000057f864ee247d477", "stateDiff": {"0x9162accd2bf58dcf5f5d46e5818117e3f5cd8333": {"balance": {"*": {"from": "0x1e8b422a215aff2a", "to": "0x1c8a6a7b5aa9727a"}}, "code": "=", "nonce": {"*": {"from": "0x259", "to": "0x25a"}}, "storage": {}}, "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5": {"balance": {"*": {"from": "0xcbf2d42250f0eb19", "to": "0xcbf2e3a93cf93319"}}, "code": "=", "nonce": "=", "storage": {}}, "0xa65303cbe1186f58dda9cf96b29e1e89ae90b165": {"balance": "=", "code": "=", "nonce": "=", "storage": {"0x0000000000000000000000000000000000000000000000000000000000000008": {"*": {"from": "0x65bd127b000000000000b48e759d60c985d500000000000205fd
@dmarzzz
dmarzzz / committee_takeover.py
Created May 25, 2023 00:17
orobability of controlling >50% of an N-size committee
from decimal import Decimal
import math
def calculate_summation(N, p):
p = Decimal(p)
result = Decimal(0)
for k in range(math.floor(N/2), N+1):
term = Decimal(math.comb(N, k)) * (p**k) * ((1-p)**(N-k))
result += term
return float(result)