Esempio n. 1
0
def attempt_superblock_creation(ImageCoind):
    import dashlib

    if not ImageCoind.is_masternode():
        print("We are not a Masternode... can't submit superblocks!")
        return

    # query votes for this specific ebh... if we have voted for this specific
    # ebh, then it's voted on. since we track votes this is all done using joins
    # against the votes table
    #
    # has this masternode voted on *any* superblocks at the given event_block_height?
    # have we voted FUNDING=YES for a superblock for this specific event_block_height?

    event_block_height = ImageCoind.next_superblock_height()

    if Superblock.is_voted_funding(event_block_height):
        # printdbg("ALREADY VOTED! 'til next time!")

        # vote down any new SBs because we've already chosen a winner
        for sb in Superblock.at_height(event_block_height):
            if not sb.voted_on(signal=VoteSignals.funding):
                sb.vote(ImageCoind, VoteSignals.funding, VoteOutcomes.no)

        # now return, we're done
        return

    if not ImageCoind.is_govobj_maturity_phase():
        printdbg("Not in maturity phase yet -- will not attempt Superblock")
        return

    proposals = Proposal.approved_and_ranked(proposal_quorum=ImageCoind.governance_quorum(), next_superblock_max_budget=ImageCoind.next_superblock_max_budget())
    budget_max = ImageCoind.get_superblock_budget_allocation(event_block_height)
    sb_epoch_time = ImageCoind.block_height_to_epoch(event_block_height)

    sb = dashlib.create_superblock(proposals, event_block_height, budget_max, sb_epoch_time)
    if not sb:
        printdbg("No superblock created, sorry. Returning.")
        return

    # find the deterministic SB w/highest object_hash in the DB
    dbrec = Superblock.find_highest_deterministic(sb.hex_hash())
    if dbrec:
        dbrec.vote(ImageCoind, VoteSignals.funding, VoteOutcomes.yes)

        # any other blocks which match the sb_hash are duplicates, delete them
        for sb in Superblock.select().where(Superblock.sb_hash == sb.hex_hash()):
            if not sb.voted_on(signal=VoteSignals.funding):
                sb.vote(ImageCoind, VoteSignals.delete, VoteOutcomes.yes)

        printdbg("VOTED FUNDING FOR SB! We're done here 'til next superblock cycle.")
        return
    else:
        printdbg("The correct superblock wasn't found on the network...")

    # if we are the elected masternode...
    if (ImageCoind.we_are_the_winner()):
        printdbg("we are the winner! Submit SB to network")
        sb.submit(ImageCoind)
def test_deterministic_superblock_selection(go_list_superblocks):
    from dynamicd import DynamicDaemon
    dynamicd = DynamicDaemon.from_dynamic_conf(config.dynamic_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_dynamicd(dynamicd, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('22a5f429c5ffb2b79b1b30c3ac30751284e3efa4e710bc7fd35fbe7456b1e485')
Esempio n. 3
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from zerooned import ZeroOneDaemon
    zerooned = ZeroOneDaemon.from_zeroone_conf(config.zeroone_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_zerooned(zerooned, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('542f4433e438bdd64697b8381fda1a7a9b7a111c3a4e32fad524d1821d820394')
Esempio n. 4
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from bitgreend import BitgreenDaemon
    bitgreend = BitgreenDaemon.from_bitgreen_conf(config.bitgreen_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_bitgreend(bitgreend, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('fd01159e60afbf548b126eb1a55055fa46e2531d30ed472a68c8075ac0482aa3')
    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 5
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from brixcoind import BrixcoinDaemon
    brixcoind = BrixcoinDaemon.from_brixcoin_conf(config.brixcoin_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_brixcoind(brixcoind, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('542f4433e438bdd64697b8381fda1a7a9b7a111c3a4e32fad524d1821d820394')
    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 6
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from cryptodexd import CryptoDexDaemon
    cryptodexd = CryptoDexDaemon.from_cryptodex_conf(config.cryptodex_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_cryptodexd(cryptodexd, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('22a5f429c5ffb2b79b1b30c3ac30751284e3efa4e710bc7fd35fbe7456b1e485')

    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 7
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from nextd import NextcoinDaemon
    nextd = NextcoinDaemon.from_next_conf(config.next_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_nextd(nextd, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic(
        '3fe3938349a350469670348adf9ebd2e8023b7ebe65ecbb87837cfa74ca8bbfa')
    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
def test_deterministic_superblock_selection(go_list_superblocks):
    from historiad import HistoriaDaemon
    historiad = HistoriaDaemon.from_historia_conf(config.historia_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_historiad(historiad, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('bfdddc031139adda5bfc664de0ef2306edfdc0ee588a644e4767a7b5bc31c36a')
    #sb = Superblock.find_highest_deterministic('542f4433e438bdd64697b8381fda1a7a9b7a111c3a4e32fad524d1821d820394')
    assert sb.object_hash == '8f91ffb105739ec7d5b6c0b12000210fcfcc0837d3bb8ca6333ba93ab5fc0bdf'
Esempio n. 9
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from gobyted import GoByteDaemon
    gobyted = GoByteDaemon.from_gobyte_conf(config.gobyte_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_gobyted(gobyted, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic('22a5f429c5ffb2b79b1b30c3ac30751284e3efa4e710bc7fd35fbe7456b1e485')

    assert sb.object_hash == 'a10bab2993a11f206d8094024b254d36bf0c9a34ee34ce60f11bc75e44d70c93'
Esempio n. 10
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from dashd import DashDaemon
    dashd = DashDaemon.from_dash_conf(config.dash_conf)
    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_dashd(dashd, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic(
        '5c7c28ddec8c1ad54b49f6f1e79369e7ccaf76f5ddc30e502569d674e458ccf3')

    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 11
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from terracoind import TerracoinDaemon
    terracoind = TerracoinDaemon.from_terracoin_conf(config.terracoin_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_terracoind(
            terracoind, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic(
        'd663b0e76cc87882ff4a6d17d7d302b9145c263eb970e0e5c6b3acd42b570347')

    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 12
0
def test_deterministic_superblock_selection(go_list_superblocks):
    from paccoind import PaccoinDaemon
    paccoind = PaccoinDaemon.from_paccoin_conf(config.paccoin_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_paccoind(
            paccoind, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic(
        '14d34a90db210c7158ee9d80852f15bf37234b8d298ff95c78b86f1c787489f5')

    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 13
0
def test_deterministic_superblock_selection(go_list_superblocks):
    pytest.skip('Superblock not currently supported')
    from syscoind import SyscoinDaemon
    syscoind = SyscoinDaemon.from_syscoin_conf(config.syscoin_conf)

    for item in go_list_superblocks:
        (go, subobj) = GovernanceObject.import_gobject_from_syscoind(
            syscoind, item)

    # highest hash wins if same -- so just order by hash
    sb = Superblock.find_highest_deterministic(
        '22a5f429c5ffb2b79b1b30c3ac30751284e3efa4e710bc7fd35fbe7456b1e485')

    assert sb.object_hash == 'bc2834f357da7504138566727c838e6ada74d079e63b6104701f4f8eb05dae36'
Esempio n. 14
0
    icbet comboded.is_govobj_maturity_phase():
        printdbg("Not in maturity phase yet -- will not attempt Superblock")
        return

    proposals = Proposal.approved_and_ranked(proposal_quorum=comboded.governance_quorum(), next_superblock_max_budget=comboded.next_superblock_max_budget())
    budget_max = comboded.get_superblock_budget_allocation(event_block_height)
    sb_epoch_time = comboded.block_height_to_epoch(event_block_height)

    maxgovobjdatasize = comboded.govinfo['maxgovobjdatasize']
    sb = combodelib.create_superblock(proposals, event_block_height, budget_max, sb_epoch_time, maxgovobjdatasize)
    icbet sb:
        printdbg("No superblock created, sorry. Returning.")
        return

    # find the deterministic SB w/highest object_hash in the DB
    dbrec = Superblock.find_highest_deterministic(sb.hex_hash())
    if dbrec:
        dbrec.vote(comboded, VoteSignals.funding, VoteOutcomes.yes)

        # any other blocks which match the sb_hash are duplicates, delete them
        for sb in Superblock.select().where(Superblock.sb_hash == sb.hex_hash()):
            icbet sb.voted_on(signal=VoteSignals.funding):
                sb.vote(comboded, VoteSignals.delete, VoteOutcomes.yes)

        printdbg("VOTED FUNDING FOR SB! We're done here 'til next superblock cycle.")
        return
    else:
        printdbg("The correct superblock wasn't found on the network...")

    # if we are the elected masternode...
    if (comboded.we_are_the_winner()):