Esempio n. 1
0
 def fromJSON(sendDiff: bytes, dataDiff: bytes,
              json: Dict[str, List[Dict[str, Any]]]) -> Any:
     result = Consensus(sendDiff, dataDiff)
     for mh in json:
         for elem in json[mh]:
             if "signed" in elem:
                 if elem["descendant"] == "Verification":
                     result.add(SignedVerification.fromJSON(elem))
                 elif elem["descendant"] == "MeritRemoval":
                     if elem["partial"]:
                         result.add(
                             PartiallySignedMeritRemoval.fromJSON(elem))
                     else:
                         result.add(SignedMeritRemoval.fromJSON(elem))
                 else:
                     raise Exception(
                         "JSON has an unsupported Element type: " +
                         elem["descendant"])
             else:
                 if elem["descendant"] == "Verification":
                     result.add(Verification.fromJSON(elem))
                 elif elem["descendant"] == "MeritRemoval":
                     result.add(MeritRemoval.fromJSON(elem))
                 else:
                     raise Exception(
                         "JSON has an unsupported Element type: " +
                         elem["descendant"])
     return result
Esempio n. 2
0
             bytes()))
    datas[-1].sign(edPrivKey)
    datas[-1].beat(consensus.dataFilter)

#Create 1 Verification per Data.
verifs: List[SignedVerification] = []
for d in range(len(datas)):
    verifs.append(SignedVerification(datas[d].hash))
    verifs[-1].sign(privKey, d)
    if d < 3:
        consensus.add(verifs[-1])

#Create a MeritRemoval off the last one.
sv: SignedVerification = SignedVerification(b'\0' * 48)
sv.sign(privKey, 5)
removal: SignedMeritRemoval = SignedMeritRemoval(
    SignedElement.fromElement(verifs[5]), SignedElement.fromElement(sv))
consensus.add(removal)

#Generate a Block with the first 3 Elements.
block: Block = Block(
    BlockHeader(2, blockchain.last(), int(time()),
                consensus.getAggregate([(pubKey, 0, 2)])),
    BlockBody([(pubKey, 2, consensus.getMerkle(pubKey, 0, 2))]))
#Mine it.
block.mine(blockchain.difficulty)

#Add it.
blockchain.add(block)
print("Generated Pending Actions Block " + str(block.header.nonce) + ".")

#Generate a Block with the MeritRemoval.
Esempio n. 3
0
def MRPALiveTest(rpc: RPC) -> None:
    file: IO[Any] = open(
        "python_tests/Vectors/Consensus/MeritRemoval/PendingActions.json", "r")
    vectors: Dict[str, Any] = json.loads(file.read())
    #Datas.
    datas: List[Data] = []
    for data in vectors["datas"]:
        datas.append(Data.fromJSON(data))
    #SignedVerifications.
    verifs: List[SignedVerification] = []
    for verif in vectors["verifications"]:
        verifs.append(SignedVerification.fromJSON(verif))
    #Removal.
    removal: SignedMeritRemoval = SignedMeritRemoval.fromJSON(
        vectors["removal"])
    #Consensus.
    consensus: Consensus = Consensus(
        bytes.fromhex(
            "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        ),
        bytes.fromhex(
            "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
        ),
    )
    consensus.add(verifs[0])
    consensus.add(verifs[1])
    consensus.add(verifs[2])
    consensus.add(removal)
    #Blockchain.
    blockchain: Blockchain = Blockchain.fromJSON(
        b"MEROS_DEVELOPER_NETWORK", 60,
        int(
            "FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            16), vectors["blockchain"])
    file.close()

    #Handshake with the node.
    rpc.meros.connect(254, 254, len(blockchain.blocks) - 2)

    hash: bytes = bytes()
    msg: bytes = bytes()
    height: int = 0
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1:5], byteorder="big")
            if height == 0:
                rpc.meros.blockHash(blockchain.blocks[1].header.hash)
            else:
                if height >= len(blockchain.blocks):
                    raise TestError(
                        "Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Send the Datas.
    for data in datas:
        if rpc.meros.transaction(data) != rpc.meros.recv():
            raise TestError("Unexpected message sent.")

    #Send the Verifications.
    for verif in verifs:
        if rpc.meros.signedElement(verif) != rpc.meros.recv():
            raise TestError("Unexpected message sent.")

    #Verify every Data has 100 Merit.
    for data in datas:
        if rpc.call("transactions", "getMerit", [data.hash.hex()]) != {
                "merit": 100
        }:
            raise TestError(
                "Meros didn't verify Transactions with received Verifications."
            )

    #Send and verify the MeritRemoval.
    if rpc.meros.signedElement(removal) != rpc.meros.recv():
        raise TestError("Meros didn't send us the Merit Removal.")
    verifyMeritRemoval(rpc, 1, 100, removal, True)

    #Verify every Data has 100 Merit.
    for data in datas:
        if rpc.call("transactions", "getMerit", [data.hash.hex()]) != {
                "merit": 0
        }:
            raise TestError(
                "Meros didn't revert pending actions of a malicious MeritHolder."
            )

    #Send the next Block.
    rpc.meros.blockHeader(blockchain.blocks[-2].header)
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1:5], byteorder="big")
            if height == 0:
                rpc.meros.blockHash(blockchain.last())
            else:
                if height >= len(blockchain.blocks):
                    raise TestError(
                        "Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            pass

        elif MessageType(msg[0]) == MessageType.BlockHeader:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Update the MeritRemoval's nonce.
    removal.nonce = 3

    #Verify the Datas have the Merit they should.
    for d in range(len(datas)):
        if rpc.call("transactions", "getMerit", [datas[d].hash.hex()]) != {
                "merit": 100 if d < 3 else 0
        }:
            raise TestError(
                "Meros didn't apply reverted pending actions of a malicious MeritHolder."
            )

    #Verify the MeritRemoval is now accessible with a nonce of 3.
    verifyMeritRemoval(rpc, 4, 200, removal, True)

    #Archive the MeritRemoval.
    rpc.meros.blockHeader(blockchain.blocks[-1].header)
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1:5], byteorder="big")
            if height == 0:
                rpc.meros.blockHash(blockchain.last())
            else:
                if height >= len(blockchain.blocks):
                    raise TestError(
                        "Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Verify the Blockchain.
    verifyBlockchain(rpc, blockchain)

    #Verify the Consensus.
    verifyConsensus(rpc, consensus)

    #Verify the MeritRemoval again.
    verifyMeritRemoval(rpc, 4, 200, removal, False)
Esempio n. 4
0
def MRSNCauseTest(rpc: RPC) -> None:
    file: IO[Any] = open(
        "python_tests/Vectors/Consensus/MeritRemoval/SameNonce.json", "r")
    vectors: Dict[str, Any] = json.loads(file.read())
    #Data.
    data: Data = Data.fromJSON(vectors["data"])
    #MeritRemoval.
    removal: SignedMeritRemoval = SignedMeritRemoval.fromJSON(
        vectors["removal"])
    #Blockchain.
    blockchain: Blockchain = Blockchain.fromJSON(
        b"MEROS_DEVELOPER_NETWORK", 60,
        int(
            "FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            16), vectors["blockchain"])
    file.close()

    #Handshake with the node.
    rpc.meros.connect(254, 254, len(blockchain.blocks) - 1)

    hash: bytes = bytes()
    msg: bytes = bytes()
    height: int = 0
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1:5], byteorder="big")
            if height == 0:
                rpc.meros.blockHash(blockchain.blocks[1].header.hash)
            else:
                if height >= len(blockchain.blocks):
                    raise TestError(
                        "Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Send the Data/SignedVerifications.
    if rpc.meros.transaction(data) != rpc.meros.recv():
        raise TestError("Unexpected message sent.")

    if rpc.meros.signedElement(removal.se1) != rpc.meros.recv():
        raise TestError("Unexpected message sent.")
    rpc.meros.signedElement(removal.se2)

    #Verify the MeritRemoval.
    if rpc.meros.recv() != (MessageType.SignedMeritRemoval.toByte() +
                            removal.signedSerialize()):
        raise TestError("Meros didn't send us the Merit Removal.")
    verifyMeritRemoval(rpc, 1, 100, removal, True)

    #Send the final Block.
    rpc.meros.blockHeader(blockchain.blocks[-1].header)
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1:5], byteorder="big")
            if height == 0:
                rpc.meros.blockHash(blockchain.last())
            else:
                if height >= len(blockchain.blocks):
                    raise TestError(
                        "Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1:49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError(
                        "Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Verify the Blockchain.
    verifyBlockchain(rpc, blockchain)

    #Verify the MeritRemoval again.
    verifyMeritRemoval(rpc, 1, 100, removal, False)
Esempio n. 5
0
def MRMLiveTest(
    rpc: RPC
) -> None:
    file: IO[Any] = open("python_tests/Vectors/Consensus/MeritRemoval/Multiple.json", "r")
    vectors: Dict[str, Any] = json.loads(file.read())
    #MeritRemovals.
    removal1: SignedMeritRemoval = SignedMeritRemoval.fromJSON(vectors["removal1"])
    removal2: SignedMeritRemoval = SignedMeritRemoval.fromJSON(vectors["removal2"])
    #Blockchain.
    blockchain: Blockchain = Blockchain.fromJSON(
        b"MEROS_DEVELOPER_NETWORK",
        60,
        int("FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 16),
        vectors["blockchain"]
    )
    file.close()

    #Handshake with the node.
    rpc.meros.connect(
        254,
        254,
        len(blockchain.blocks) - 1
    )

    hash: bytes = bytes()
    msg: bytes = bytes()
    height: int = 0
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1 : 5], byteorder = "big")
            if height == 0:
                rpc.meros.blockHash(blockchain.blocks[1].header.hash)
            else:
                if height >= len(blockchain.blocks):
                    raise TestError("Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Send and verify the first MeritRemoval.
    msg = rpc.meros.signedElement(removal1)
    if msg != rpc.meros.recv():
        raise TestError("Meros didn't send us the Merit Removal.")
    verifyMeritRemoval(rpc, 1, 100, removal1, True)

    #Send the second MeritRemoval.
    rpc.meros.signedElement(removal2)
    #Meros should treat the first created MeritRemoval as the default.
    if msg != rpc.meros.recv():
        raise TestError("Meros didn't send us the Merit Removal.")
    verifyMeritRemoval(rpc, 1, 100, removal1, True)

    #Send the final Block.
    rpc.meros.blockHeader(blockchain.blocks[-1].header)
    while True:
        msg = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height = int.from_bytes(msg[1 : 5], byteorder = "big")
            if height == 0:
                rpc.meros.blockHash(blockchain.last())
            else:
                if height >= len(blockchain.blocks):
                    raise TestError("Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Verify the Blockchain.
    verifyBlockchain(rpc, blockchain)

    #Verify the MeritRemoval again.
    verifyMeritRemoval(rpc, 1, 100, removal2, False)
Esempio n. 6
0
def MRSNSyncTest(
    rpc: RPC
) -> None:
    file: IO[Any] = open("python_tests/Vectors/Consensus/MeritRemoval/SameNonce.json", "r")
    vectors: Dict[str, Any] = json.loads(file.read())
    #MeritRemoval..
    removal: SignedMeritRemoval = SignedMeritRemoval.fromJSON(vectors["removal"])
    #Blockchain.
    blockchain: Blockchain = Blockchain.fromJSON(
        b"MEROS_DEVELOPER_NETWORK",
        60,
        int("FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 16),
        vectors["blockchain"]
    )
    file.close()

    #Handshake with the node.
    rpc.meros.connect(
        254,
        254,
        len(blockchain.blocks)
    )

    sentLast: bool = False
    hash: bytes = bytes()
    while True:
        msg: bytes = rpc.meros.recv()

        if MessageType(msg[0]) == MessageType.Syncing:
            rpc.meros.acknowledgeSyncing()

        elif MessageType(msg[0]) == MessageType.GetBlockHash:
            height: int = int.from_bytes(msg[1 : 5], byteorder = "big")
            if height == 0:
                rpc.meros.blockHash(blockchain.last())
            else:
                if height >= len(blockchain.blocks):
                    raise TestError("Meros asked for a Block Hash we do not have.")

                rpc.meros.blockHash(blockchain.blocks[height].header.hash)

        elif MessageType(msg[0]) == MessageType.BlockHeaderRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockHeader(block.header)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Header we do not have.")

        elif MessageType(msg[0]) == MessageType.BlockBodyRequest:
            hash = msg[1 : 49]
            for block in blockchain.blocks:
                if block.header.hash == hash:
                    rpc.meros.blockBody(block.body)
                    break

                if block.header.hash == blockchain.last():
                    raise TestError("Meros asked for a Block Body we do not have.")

        elif MessageType(msg[0]) == MessageType.ElementRequest:
            sentLast = True
            rpc.meros.element(removal)

        elif MessageType(msg[0]) == MessageType.SyncingOver:
            if sentLast:
                break

        else:
            raise TestError("Unexpected message sent: " + msg.hex().upper())

    #Verify the Blockchain.
    verifyBlockchain(rpc, blockchain)

    #Verify the MeritRemoval again.
    verifyMeritRemoval(rpc, 1, 100, removal, False)

    #Playback their messages.
    rpc.meros.playback()
Esempio n. 7
0
blockchain.add(Block.fromJSON(blocks[0]))
bbFile.close()

#Create a Data to verify.
data: Data = Data(edPubKey.to_bytes().rjust(48, b'\0'), bytes())
data.sign(edPrivKey)
data.beat(consensus.dataFilter)

#Create two Verifications with the same nonce, yet for the different Datas.
sv1: SignedVerification = SignedVerification(data.hash)
sv1.sign(privKey, 0)

sv2: SignedVerification = SignedVerification(b'\0' * 48)
sv2.sign(privKey, 0)

removal: SignedMeritRemoval = SignedMeritRemoval(
    SignedElement.fromElement(sv1), SignedElement.fromElement(sv2))
consensus.add(removal)

#Generate another Block.
block: Block = Block(
    BlockHeader(2, blockchain.last(), int(time()),
                consensus.getAggregate([(pubKey, 0, -1)])),
    BlockBody([(pubKey, 0, consensus.getMerkle(pubKey, 0))]))
#Mine it.
block.mine(blockchain.difficulty)

#Add it.
blockchain.add(block)
print("Generated Same Nonce Block " + str(block.header.nonce) + ".")

result: Dict[str, Any] = {
Esempio n. 8
0
    int(
        "FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
        16))

#BLS Keys.
privKey: blspy.PrivateKey = blspy.PrivateKey.from_seed(b'\0')
pubKey: blspy.PublicKey = privKey.get_public_key()

#Load a Multiple Block and load their MeritRemoval.
snFile: IO[Any] = open(
    "python_tests/Vectors/Consensus/MeritRemoval/SameNonce.json", "r")
snVectors: Dict[str, Any] = json.loads(snFile.read())

blockchain.add(Block.fromJSON(snVectors["blockchain"][0]))

mr1: SignedMeritRemoval = SignedMeritRemoval.fromJSON(snVectors["removal"])

snFile.close()

#Create a second MeritRemoval.
sv: SignedVerification = SignedVerification(b'\1' * 48)
sv.sign(privKey, 0)
mr2: SignedMeritRemoval = SignedMeritRemoval(mr1.se1,
                                             SignedElement.fromElement(sv))

#Add the second MeritRemoval to Consensus.
consensus.add(mr2)

#Generate a Block with the second MeritRemoval.
block: Block = Block(
    BlockHeader(2, blockchain.last(), int(time()),