Skip to content

Commit

Permalink
added cachecoin new staging tree (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
donSchoe committed Feb 12, 2014
1 parent f45d682 commit 7c41158
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
27 changes: 25 additions & 2 deletions p2pool/bitcoin/networks.py
Expand Up @@ -58,7 +58,7 @@ def check_genesis_block(bitcoind, genesis_block_hash):
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
),

namecoin=math.Object(
P2P_PREFIX='f9beb4fe'.decode('hex'),
P2P_PORT=8334,
Expand Down Expand Up @@ -101,7 +101,7 @@ def check_genesis_block(bitcoind, genesis_block_hash):
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
),

litecoin=math.Object(
P2P_PREFIX='fbc0b6db'.decode('hex'),
P2P_PORT=9333,
Expand Down Expand Up @@ -209,6 +209,29 @@ def check_genesis_block(bitcoind, genesis_block_hash):
DUMB_SCRYPT_DIFF=2**16,
DUST_THRESHOLD=0.03e8,
),

cachecoin=math.Object(
P2P_PREFIX='5c394226'.decode('hex'),
P2P_PORT=2225,
ADDRESS_VERSION=28,
RPC_PORT=2224,
RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
'cachecoinaddress' in (yield bitcoind.rpc_help()) and
not (yield bitcoind.rpc_getinfo())['testnet']
)),
SUBSIDY_FUNC=lambda target: get_subsidy(6, 100, target),
BLOCKHASH_FUNC=lambda header: pack.IntType(256).unpack(__import__('yac_scrypt').getPoWHash(header, data.block_header_type.unpack(header)['timestamp'])),
POW_FUNC=lambda header: pack.IntType(256).unpack(__import__('yac_scrypt').getPoWHash(header, data.block_header_type.unpack(header)['timestamp'])),
BLOCK_PERIOD=900, # s
SYMBOL='CACH',
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'cachecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/cachecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.cachecoin'), 'cachecoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://explorer.cachecoin.org/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.cachecoin.org/address/',
TX_EXPLORER_URL_PREFIX='http://explorer.cachecoin.org/tx/',
SANE_TARGET_RANGE=(2**256//2**20//1000 - 1, 2**256//2**20 - 1),
DUMB_SCRYPT_DIFF=2**16,
DUST_THRESHOLD=0.03e8,
),
)
for net_name, net in nets.iteritems():
net.NAME = net_name
42 changes: 21 additions & 21 deletions p2pool/bitcoin/p2p.py
Expand Up @@ -15,7 +15,7 @@
class Protocol(p2protocol.Protocol):
def __init__(self, net):
p2protocol.Protocol.__init__(self, net.P2P_PREFIX, 1000000, ignore_trailing_payload=True)

def connectionMade(self):
self.send_version(
version=70002,
Expand All @@ -35,7 +35,7 @@ def connectionMade(self):
sub_version_num='/P2Pool:%s/' % (p2pool.__version__,),
start_height=0,
)

message_version = pack.ComposedType([
('version', pack.IntType(32)),
('services', pack.IntType(64)),
Expand All @@ -48,20 +48,20 @@ def connectionMade(self):
])
def handle_version(self, version, services, time, addr_to, addr_from, nonce, sub_version_num, start_height):
self.send_verack()

message_verack = pack.ComposedType([])
def handle_verack(self):
self.get_block = deferral.ReplyMatcher(lambda hash: self.send_getdata(requests=[dict(type='block', hash=hash)]))
self.get_block_header = deferral.ReplyMatcher(lambda hash: self.send_getheaders(version=1, have=[], last=hash))

if hasattr(self.factory, 'resetDelay'):
self.factory.resetDelay()
if hasattr(self.factory, 'gotConnection'):
self.factory.gotConnection(self)

self.pinger = deferral.RobustLoopingCall(self.send_ping, nonce=1234)
self.pinger.start(30)

message_inv = pack.ComposedType([
('invs', pack.ListType(pack.ComposedType([
('type', pack.EnumType(pack.IntType(32), {1: 'tx', 2: 'block'})),
Expand All @@ -76,7 +76,7 @@ def handle_inv(self, invs):
self.factory.new_block.happened(inv['hash'])
else:
print 'Unknown inv type', inv

message_getdata = pack.ComposedType([
('requests', pack.ListType(pack.ComposedType([
('type', pack.EnumType(pack.IntType(32), {1: 'tx', 2: 'block'})),
Expand All @@ -94,7 +94,7 @@ def handle_inv(self, invs):
('last', pack.PossiblyNoneType(0, pack.IntType(256))),
])
message_getaddr = pack.ComposedType([])

message_addr = pack.ComposedType([
('addrs', pack.ListType(pack.ComposedType([
('timestamp', pack.IntType(32)),
Expand All @@ -104,21 +104,21 @@ def handle_inv(self, invs):
def handle_addr(self, addrs):
for addr in addrs:
pass

message_tx = pack.ComposedType([
('tx', bitcoin_data.tx_type),
])
def handle_tx(self, tx):
self.factory.new_tx.happened(tx)

message_block = pack.ComposedType([
('block', bitcoin_data.block_type),
])
def handle_block(self, block):
block_hash = bitcoin_data.hash256(bitcoin_data.block_header_type.pack(block['header']))
self.get_block.got_response(block_hash, block)
self.get_block_header.got_response(block_hash, block['header'])

message_headers = pack.ComposedType([
('headers', pack.ListType(bitcoin_data.block_type)),
])
Expand All @@ -127,26 +127,26 @@ def handle_headers(self, headers):
header = header['header']
self.get_block_header.got_response(bitcoin_data.hash256(bitcoin_data.block_header_type.pack(header)), header)
self.factory.new_headers.happened([header['header'] for header in headers])

message_ping = pack.ComposedType([
('nonce', pack.IntType(64)),
])
def handle_ping(self, nonce):
self.send_pong(nonce=nonce)

message_pong = pack.ComposedType([
('nonce', pack.IntType(64)),
])
def handle_pong(self, nonce):
pass

message_alert = pack.ComposedType([
('message', pack.VarStrType()),
('signature', pack.VarStrType()),
])
def handle_alert(self, message, signature):
pass # print 'ALERT:', (message, signature)

def connectionLost(self, reason):
if hasattr(self.factory, 'gotConnection'):
self.factory.gotConnection(None)
Expand All @@ -157,24 +157,24 @@ def connectionLost(self, reason):

class ClientFactory(protocol.ReconnectingClientFactory):
protocol = Protocol

maxDelay = 1

def __init__(self, net):
self.net = net
self.conn = variable.Variable(None)

self.new_block = variable.Event()
self.new_tx = variable.Event()
self.new_headers = variable.Event()

def buildProtocol(self, addr):
p = self.protocol(self.net)
p.factory = self
return p

def gotConnection(self, conn):
self.conn.set(conn)

def getProtocol(self):
return self.conn.get_not_none()
33 changes: 26 additions & 7 deletions p2pool/networks.py
Expand Up @@ -18,7 +18,7 @@
IDENTIFIER='fc70035c7a81bc6f'.decode('hex'),
PREFIX='2472ef181efcd37b'.decode('hex'),
P2P_PORT=9333,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**32 - 1,
PERSIST=True,
WORKER_PORT=9332,
Expand All @@ -37,7 +37,7 @@
IDENTIFIER='5fc2be2d4f0d6bfb'.decode('hex'),
PREFIX='3f6057a15036f441'.decode('hex'),
P2P_PORT=19333,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**32 - 1,
PERSIST=False,
WORKER_PORT=19332,
Expand All @@ -56,7 +56,7 @@
IDENTIFIER='e037d5b8c6923410'.decode('hex'),
PREFIX='7208c1a53ef629b0'.decode('hex'),
P2P_PORT=9338,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**20 - 1,
PERSIST=True,
WORKER_PORT=9327,
Expand All @@ -75,7 +75,7 @@
IDENTIFIER='cca5e24ec6408b1e'.decode('hex'),
PREFIX='ad9614f6466a39cf'.decode('hex'),
P2P_PORT=19338,
MIN_TARGET=2**256//50 - 1,
MIN_TARGET=4,
MAX_TARGET=2**256//50 - 1,
PERSIST=False,
WORKER_PORT=19327,
Expand All @@ -94,7 +94,7 @@
IDENTIFIER='a41b2356a1b7d46e'.decode('hex'),
PREFIX='5623b62178d2b9b3'.decode('hex'),
P2P_PORT=9323,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**32 - 1,
PERSIST=True,
WORKER_PORT=9322,
Expand All @@ -113,7 +113,7 @@
IDENTIFIER='b41b2356a5b7d35d'.decode('hex'),
PREFIX='1623b92172d2b8a2'.decode('hex'),
P2P_PORT=19323,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**32 - 1,
PERSIST=False,
WORKER_PORT=19322,
Expand All @@ -133,14 +133,33 @@
IDENTIFIER='a06a81c827cab973'.decode('hex'),
PREFIX='7c3614a6bcdcf794'.decode('hex'),
P2P_PORT=9346,
MIN_TARGET=0,
MIN_TARGET=4,
MAX_TARGET=2**256//2**20 - 1,
PERSIST=False,
WORKER_PORT=9171,
BOOTSTRAP_ADDRS='q30.qhor.net seed.p2pool.etyd.org vtc.royalminingco.com'.split(' '),
ANNOUNCE_CHANNEL='#p2pool-vtc',
VERSION_CHECK=lambda v: True,
),

cachecoin=math.Object(
PARENT=networks.nets['cachecoin'],
SHARE_PERIOD=120, # seconds
CHAIN_LENGTH=12*60*60//120, # shares
REAL_CHAIN_LENGTH=12*60*60//120, # shares
TARGET_LOOKBEHIND=30, # shares
SPREAD=36, # blocks
IDENTIFIER='65375c4f7a4d584f'.decode('hex'),
PREFIX='642a2c6524364268'.decode('hex'),
P2P_PORT=2226,
MIN_TARGET=4,
MAX_TARGET=2**256//2**20 - 1,
PERSIST=False,
WORKER_PORT=8336,
BOOTSTRAP_ADDRS='207.30.158.106 p2cache.syware.de q39.qhor.net q30.qhor.net'.split(' '),
ANNOUNCE_CHANNEL='#cachecoin-bots',
VERSION_CHECK=lambda v: True,
),
)
for net_name, net in nets.iteritems():
net.NAME = net_name

5 comments on commit 7c41158

@roy7
Copy link
Contributor

@roy7 roy7 commented on 7c41158 Feb 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was MIN_TARGET changed for all of the coins? What effect will that have? On a scrypt coin like VTC does that mean minimum diff is 4 / 2^16 or 4 * 2^16?

@donSchoe
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 4 / 2^16 = 0.00006103515625. It's to avoid accepting any share submitted by the miners (0 = any share diff is ok). This should improve overall mining experience, even for low hash rates.

@roy7
Copy link
Contributor

@roy7 roy7 commented on 7c41158 Feb 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool thanks. One of the miners noticed he sometimes get served 0 diff work and gets error in his miner when that happens but it quickly goes away. I'm guessing maybe that is on a private node with no other traffic, and the pseudo share diff is serving 0 diff work? Does cgminer/etc not support 0 diff pseudo share target difficulties? I wonder if 1/2^16 should be a minimum pseudo share target for scrypt (1 for sha256).

@chaeplin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2pool/bitcoin/networks.py
chachecoin SUBSIDY_FUNC=lambda target: get_subsidy(6, 100, target),
where is get_subsidy ?

@donSchoe
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah get_subsidy is missing. Trying to merge the cachecoin tree into this one but it turns out to be a major puzzle 👎

Please sign in to comment.