mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 23:27:56 -05:00
added proposed block broadcast missing signature
This commit is contained in:
453
.vscode/launch.json
vendored
Normal file
453
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in library 'cashierd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--lib",
|
||||
"--package=cashierd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "cashierd",
|
||||
"kind": "lib"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'cashierd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=cashierd",
|
||||
"--package=cashierd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "cashierd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'cashierd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=cashierd",
|
||||
"--package=cashierd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "cashierd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in library 'darkfi'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--lib",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "darkfi",
|
||||
"kind": "lib"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'net'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=net",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "net",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'net'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=net",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "net",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'tui'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=tui",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tui",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'tui'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=tui",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tui",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'vm'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=vm",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "vm",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'vm'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=vm",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "vm",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'vm_burn'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=vm_burn",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "vm_burn",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'vm_burn'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=vm_burn",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "vm_burn",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'tx'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=tx",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tx",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'tx'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=tx",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tx",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug example 'tree'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--example=tree",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tree",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in example 'tree'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--example=tree",
|
||||
"--package=darkfi"
|
||||
],
|
||||
"filter": {
|
||||
"name": "tree",
|
||||
"kind": "example"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'darkfid'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=darkfid",
|
||||
"--package=darkfid"
|
||||
],
|
||||
"filter": {
|
||||
"name": "darkfid",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'darkfid'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=darkfid",
|
||||
"--package=darkfid"
|
||||
],
|
||||
"filter": {
|
||||
"name": "darkfid",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'drk'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=drk",
|
||||
"--package=drk"
|
||||
],
|
||||
"filter": {
|
||||
"name": "drk",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'drk'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=drk",
|
||||
"--package=drk"
|
||||
],
|
||||
"filter": {
|
||||
"name": "drk",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'gatewayd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=gatewayd",
|
||||
"--package=gatewayd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "gatewayd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'gatewayd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=gatewayd",
|
||||
"--package=gatewayd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "gatewayd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'ircd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=ircd",
|
||||
"--package=ircd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "ircd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'ircd'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=ircd",
|
||||
"--package=ircd"
|
||||
],
|
||||
"filter": {
|
||||
"name": "ircd",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -75,4 +75,5 @@ assert(node0.output() == node1.output() == node2.output() == node3.output() == n
|
||||
|
||||
# Since node6 joined later, node0 output is a prefix or equal to node6 output.
|
||||
# Based on that, node6 output is a suffix of node0 output.
|
||||
assert(node0.output().blocks[-len(node6.output()):] == node6.output().blocks)
|
||||
assert(node0.output().blocks[-len(node6.output()):] == node6.output().blocks)
|
||||
print('finished...')
|
||||
10
script/research/streamlet/logger.py
Normal file
10
script/research/streamlet/logger.py
Normal file
@@ -0,0 +1,10 @@
|
||||
class Logger(object):
|
||||
def __init__(self, obj):
|
||||
self.obj = obj
|
||||
def info(self, payload):
|
||||
print(f"[{self.obj}]: {payload}")
|
||||
def warn(self, payload):
|
||||
print(f"[{self.obj}]: {payload}")
|
||||
def error(self, pyaload):
|
||||
print(f"[{self.obj}]: {payload}")
|
||||
exit()
|
||||
@@ -2,6 +2,7 @@ import copy, utils
|
||||
from block import Block
|
||||
from blockchain import Blockchain
|
||||
from vote import Vote
|
||||
from logger import Logger
|
||||
|
||||
class Node:
|
||||
''' This class represents a protocol node.
|
||||
@@ -16,6 +17,7 @@ class Node:
|
||||
self.private_key, self.public_key = utils.generate_keys(self.password)
|
||||
self.blockchain = Blockchain(init_block)
|
||||
self.unconfirmed_transactions = []
|
||||
self.log = Logger(self)
|
||||
|
||||
def __repr__(self):
|
||||
return "Node=[id={0}, clock={1}, password={2}, private_key={3}, public_key={4}, blockchain={5}, unconfirmed_transactions={6}".format(self.id, self.clock, self.password, self.private_key, self.public_key, self.blockchain, self.unconfirmed_transactions)
|
||||
@@ -32,11 +34,15 @@ class Node:
|
||||
node.receive_transaction(transaction)
|
||||
|
||||
def propose_block(self, epoch, nodes):
|
||||
propozed_block = Block(hash(self.blockchain.blocks[-1]), epoch, self.unconfirmed_transactions)
|
||||
proposed_block = Block(hash(self.blockchain.blocks[-1]), epoch, self.unconfirmed_transactions)
|
||||
signed_proposed_block = utils.sign_message(self.password, self.private_key, proposed_block)
|
||||
for node in nodes:
|
||||
node.receive_proposed_block(copy.deepcopy(propozed_block))
|
||||
node.receive_proposed_block(self.public_key, copy.deepcopy(proposed_block), copy.deepcopy(signed_proposed_block))
|
||||
|
||||
def receive_proposed_block(self, round_block):
|
||||
def receive_proposed_block(self, leader_pubkey, round_block, signed_round_block):
|
||||
if not utils.verify_signature(leader_pubkey, round_block, signed_round_block):
|
||||
self.warn("the signature of the proposed block dosn't match")
|
||||
return
|
||||
self.round_block = round_block
|
||||
|
||||
def vote_on_round_block(self, nodes):
|
||||
@@ -44,6 +50,7 @@ class Node:
|
||||
# Already notarized check.
|
||||
if (self.round_block != self.blockchain.blocks[-1]):
|
||||
self.blockchain.check_block_validity(self.round_block, self.blockchain.blocks[-1])
|
||||
#TODO implement: at this point we need to verify the unconfirmed transactions
|
||||
signed_block = utils.sign_message(self.password, self.private_key, self.round_block)
|
||||
vote = Vote(signed_block, self.round_block, self.id)
|
||||
for node in nodes:
|
||||
@@ -63,7 +70,7 @@ class Node:
|
||||
notarized_block.notarized = True
|
||||
self.blockchain.add_block(notarized_block)
|
||||
# Node removes block transactions from unconfirmed_transactions array
|
||||
for transaction in notarized_block.txs:
|
||||
self.unconfirmed_transactions.remove(transaction)
|
||||
#for transaction in notarized_block.txs:
|
||||
# self.unconfirmed_transactions.remove(transaction)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user