Skip to content

Instantly share code, notes, and snippets.

[buildout]
eggs-directory = /home/ralf/.buildout/cache/eggs
download-cache = /home/ralf/.buildout/cache/download
extends-cache = /home/ralf/.buildout/extends
index = http://pypi/simple/
.DS_Store
*.log
Gemfile.lock
def int_to_big_endian(integer):
'''convert a integer to big endian binary string'''
if integer == 0:
return ''
s = '%x' % integer
if len(s) & 1:
s = '0' + s
return s.decode('hex')
def big_endian_to_int(string):
@heikoheiko
heikoheiko / alarm.draft
Last active August 29, 2015 14:07
ALARM Proposal
==== ALARM ====
Description:
- contracts can schedule future calls to themself, by specifying:
- block height
- gas
- msgdata
- scheduled calls are sorted by (gas, hash(account, msgdata)) # prevent DOS
and executed in this stable sorted order before any other tx
- on OOG: # includes no more existent account, balance
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Requirements:
- I/O bound: cycles spent on I/O ≫ cycles spent in cpu
- no sharding: impossible to implement data locality strategy
- easy verification
Thoughts:
{
"comment": "\n 'node_ids': hex encoded ids in order in which they were added to the routing table\n 'buckets' : buckets sorted asc by range\n ",
"buckets": [
{
"start": "0x0",
"end": "0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffL",
"node_ids": [
"0x1d7425638602ab696a402f23ae8cc938dcdcd03969b666205628059568cc69b1064005c3985c3cf3f76be1d1efa21977394988f847fd9b4e64d1bcb702753a1L",
"0x1825bc5430beb45f683514f2ceb81f9d7914c120c8dcd19f3e3511287900f7f993829b43922fe15ae1e3db63ef7ddc76b92da22b21df306f8a0b3c3336d8393aL",
"0xf844fef1931e9eea56c0941fbf24050a748dbcfac619e630dde29a6baa4b71add2467ac778eedb3693dffbc6c6fa6115ab33edf6e595ed3a8b317fa18d0752bL",
@heikoheiko
heikoheiko / gist:a7b5d173e5bfc1ab9db0
Created May 15, 2015 06:47
ecdsa recover in cython with gmp
"""
cython + gmp implementation of ecdsa recover
based on:
https://github.com/vbuterin/pybitcointools
"""
import sys
from ethereum import trie
from ethereum.securetrie import SecureTrie
from ethereum import blocks
import ethereum.chain
from pyethapp.leveldb_service import LevelDB
from ethereum.utils import big_endian_to_int
db = LevelDB(sys.argv[1])
# after entering the console of pyethapp
# https://github.com/ethereum/pyethapp/wiki/The_Console
from devp2p import kademlia
import gevent
def crawl():
delay = 0.1
lookups = 0
kademlia_proto = eth.app.services.discovery.protocol.kademlia
import trie
import rlp
import db
import time
trie.rlp_encode = rlp.codec.encode_raw
def int_to_big_endian(value):
cs = []