Skip to content

Instantly share code, notes, and snippets.

View djrtwo's full-sized avatar

danny djrtwo

  • Ctrl^T
  • New Orleans
View GitHub Profile

Keybase proof

I hereby claim:

  • I am djrtwo on github.
  • I am djrtwo (https://keybase.io/djrtwo) on keybase.
  • I have a public key whose fingerprint is BC36 0E10 F260 190A ED4C A920 7171 EB67 5087 B817

To claim this, I am signing this object:

0xa4be607be0a6cceff581ef35c0cdc47a7532ff54
@djrtwo
djrtwo / million_adds.py
Last active March 1, 2022 02:37
Time adding 1 million integers together. Run 1000 times and output average time.
import time
def exp():
adder = 0
start = time.time()
for i in range(1000000):
adder += 1
end = time.time()
return (end - start)
@djrtwo
djrtwo / count_bytes.py
Created August 9, 2017 18:47
Count zero and non-zero bytes in hex string
txdata = "606060405260405160808061067283398101604090815281516020830151918301516060909301519092905b42811161003457fe5b60008054600181016100468382610100565b916000526020600020900160005b8154600160a060020a038089166101009390930a928302920219161790555060008054600181016100858382610100565b916000526020600020900160005b8154600160a060020a038088166101009390930a928302920219161790555060008054600181016100c48382610100565b916000526020600020900160005b8154600160a060020a038087166101009390930a928302920219161790555060028190555b5050505061014b565b8154818355818115116101245760008381526020902061012491810190830161012a565b5b505050565b61014891905b808211156101445760008155600101610130565b5090565b90565b6105188061015a6000396000f300606060405236156100a15763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663120b205381146100a35780634ecb35c4146100c557806366d003ac146100f557806367e404ce146101215780636cc6cde11461014d5780637022b58e1461017957806393c0e83a1461018b578063a79a3cee146101ba578063ac4c25b2146101de578063c7fe23a3146101f057
@djrtwo
djrtwo / casper_rewards.py
Last active April 12, 2018 02:22
script used to model rewards in casper FFG
import argparse
import math
from copy import copy
def sqrt_of_total_deposits(deposits):
return math.sqrt(deposits)
def reward_vote(deposit, reward_factor):
@djrtwo
djrtwo / reward-reduction.md
Created April 24, 2018 02:18
Analysis of Casper PoW Reward Reduction

Analysis of Casper PoW Reward Reduction

EIP 1011 - Hybrid Casper FFG proposes further reducing PoW block reward from 3 ETH to 0.6 ETH. The EIP briefly mentions that this is "because the security of the chain is greatly shifted from PoW difficulty to PoS finality and because rewards are now issued to both validators and miners." This document is to serve as an addendum to that statement, providing additional data, analysis, and arguments.

We aim to show that in Hybrid Casper FFG with an 80% reduction in block reward:

  • a PoW attack on the finality enabled chain cannot do much in comparison to a pure PoW attack
  • a pure PoW attack just as costly as other prominent PoW chains
  • there are options in the event of an attack
  • all of the above is a strong discouragement for an attack to be conducted in the meantime before full pos
@djrtwo
djrtwo / casper_abi.json
Last active May 7, 2018 10:05
current casper abi
[{'name': 'Deposit', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'address', 'name': '_validation_address', 'indexed': False}, {'type': 'int128', 'name': '_start_dyn', 'indexed': False}, {'type': 'int128', 'name': '_amount', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Vote', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'bytes32', 'name': '_target_hash', 'indexed': True}, {'type': 'int128', 'name': '_target_epoch', 'indexed': False}, {'type': 'int128', 'name': '_source_epoch', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Logout', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'int128', 'name': '_end_dyn', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Withdraw', 'in
@djrtwo
djrtwo / casper_abi_v0.1.0.json
Last active July 31, 2020 17:51
Casper Contract ABI for release v0.1.0
[{'name': 'Deposit', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'address', 'name': '_validation_address', 'indexed': False}, {'type': 'int128', 'name': '_start_dyn', 'indexed': False}, {'type': 'int128', 'name': '_amount', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Vote', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'bytes32', 'name': '_target_hash', 'indexed': True}, {'type': 'int128', 'name': '_target_epoch', 'indexed': False}, {'type': 'int128', 'name': '_source_epoch', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Logout', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'int128', 'name': '_end_dyn', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Withdraw', 'in
@djrtwo
djrtwo / casper_abi_v0.2.0.json
Created May 16, 2018 03:19
Casper Contract ABI for release v0.2.0
[{'name': 'Deposit', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'address', 'name': '_validation_address', 'indexed': False}, {'type': 'int128', 'name': '_start_dyn', 'indexed': False}, {'type': 'int128', 'name': '_amount', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Vote', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'bytes32', 'name': '_target_hash', 'indexed': True}, {'type': 'int128', 'name': '_target_epoch', 'indexed': False}, {'type': 'int128', 'name': '_source_epoch', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Logout', 'inputs': [{'type': 'address', 'name': '_from', 'indexed': True}, {'type': 'int128', 'name': '_validator_index', 'indexed': True}, {'type': 'int128', 'name': '_end_dyn', 'indexed': False}], 'anonymous': False, 'type': 'event'}, {'name': 'Withdraw', 'in
@djrtwo
djrtwo / casper_runtime_bytecode_v0.2.0.hex
Created May 16, 2018 03:22
Casper Runtime Byte code for v0.2.0 release. `CASPER_CODE` in EIP 1011
0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526316d5c53d60005114156103105761010060046101403734156100b557600080fd5b606051600435806040519013585780919012156100d157600080fd5b50606051602435806040519013585780919012156100ee57600080fd5b506060516044358060405190135857809190121561010b57600080fd5b50606435602051811061011d57600080fd5b50608435602051811061012f57600080fd5b5060605160e4358060405190135857809190121561014c57600080fd5b506015541561015a57600080fd5b6101006101405112600061014051131661017357600080fd5b600061016051121561018457600080fd5b600261018051121561019557600080fd5b60006101e05112156101a657600080fd5b60006102005112156101b757600080fd5b600061022051136101c757600080fd5b60016015556101405160165561016051601755610180516018556101e051601b5561020051601c5561022051601d55600060a051601654