mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-20 16:08:51 +03:00
Fix error in VDF server
This commit is contained in:
parent
672234a105
commit
893e2198fd
1
.github/workflows/pythonpackage.yml
vendored
1
.github/workflows/pythonpackage.yml
vendored
@ -22,6 +22,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
brew update && brew install gmp boost || echo ""
|
brew update && brew install gmp boost || echo ""
|
||||||
sh install.sh
|
sh install.sh
|
||||||
|
sh install_timelord.sh
|
||||||
- name: Test proof of space
|
- name: Test proof of space
|
||||||
run: |
|
run: |
|
||||||
cd lib/chiapos
|
cd lib/chiapos
|
||||||
|
@ -16,9 +16,6 @@ void CreateAndWriteProof(integer D, form x, int64_t num_iterations, WesolowskiCa
|
|||||||
PrintInfo("Got stop signal before completing the proof!");
|
PrintInfo("Got stop signal before completing the proof!");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
// Write "WESO" marker
|
|
||||||
boost::asio::write(sock, boost::asio::buffer("WESO", 4));
|
|
||||||
|
|
||||||
// Writes the number of iterations
|
// Writes the number of iterations
|
||||||
std::vector<unsigned char> bytes = ConvertIntegerToBytes(integer(num_iterations), 8);
|
std::vector<unsigned char> bytes = ConvertIntegerToBytes(integer(num_iterations), 8);
|
||||||
|
|
||||||
@ -32,9 +29,11 @@ void CreateAndWriteProof(integer D, form x, int64_t num_iterations, WesolowskiCa
|
|||||||
bytes.insert(bytes.end(), proof_size.begin(), proof_size.end());
|
bytes.insert(bytes.end(), proof_size.begin(), proof_size.end());
|
||||||
bytes.insert(bytes.end(), result.proof.begin(), result.proof.end());
|
bytes.insert(bytes.end(), result.proof.begin(), result.proof.end());
|
||||||
|
|
||||||
std::string str_result = BytesToStr(bytes);
|
std::string str_result = "WESO" + BytesToStr(bytes);
|
||||||
std::lock_guard<std::mutex> lock(socket_mutex);
|
std::lock_guard<std::mutex> lock(socket_mutex);
|
||||||
PrintInfo("Generated proof = " + str_result);;
|
PrintInfo("Generated proof = " + str_result);;
|
||||||
|
// Write "WESO" marker
|
||||||
|
// boost::asio::write(sock, boost::asio::buffer("WESO", 4));
|
||||||
boost::asio::write(sock, boost::asio::buffer(str_result.c_str(), str_result.size()));
|
boost::asio::write(sock, boost::asio::buffer(str_result.c_str(), str_result.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@ def create_puzzlehash_for_pk(pub_key: BLSPublicKey) -> bytes32:
|
|||||||
|
|
||||||
def signature_for_coinbase(coin: Coin, pool_private_key: blspy.PrivateKey):
|
def signature_for_coinbase(coin: Coin, pool_private_key: blspy.PrivateKey):
|
||||||
message_hash = blspy.Util.hash256(bytes(coin))
|
message_hash = blspy.Util.hash256(bytes(coin))
|
||||||
return BLSSignature(
|
return BLSSignature(bytes(pool_private_key.sign_prepend_prehashed(message_hash)))
|
||||||
bytes(pool_private_key.sign_prepend_prehashed(message_hash))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def sign_coinbase_coin(coin: Coin, private_key: blspy.PrivateKey):
|
def sign_coinbase_coin(coin: Coin, private_key: blspy.PrivateKey):
|
||||||
|
@ -264,7 +264,7 @@ class ChiaServer:
|
|||||||
try:
|
try:
|
||||||
await connection.send(message)
|
await connection.send(message)
|
||||||
except (RuntimeError, TimeoutError, OSError,) as e:
|
except (RuntimeError, TimeoutError, OSError,) as e:
|
||||||
self.log.error(
|
self.log.warning(
|
||||||
f"Cannot write to {connection}, already closed. Error {e}."
|
f"Cannot write to {connection}, already closed. Error {e}."
|
||||||
)
|
)
|
||||||
self.global_connections.close(connection, True)
|
self.global_connections.close(connection, True)
|
||||||
|
@ -268,12 +268,14 @@ class Timelord:
|
|||||||
# TODO: change protocol to use bytes and same ProofOfTime format (instead of hex)
|
# TODO: change protocol to use bytes and same ProofOfTime format (instead of hex)
|
||||||
# Reads 16 bytes of hex, for the 8 byte iterations
|
# Reads 16 bytes of hex, for the 8 byte iterations
|
||||||
bytes_read = await reader.readexactly(16)
|
bytes_read = await reader.readexactly(16)
|
||||||
|
print("bytes read:", bytes_read)
|
||||||
iterations_needed = uint64(
|
iterations_needed = uint64(
|
||||||
int.from_bytes(
|
int.from_bytes(
|
||||||
bytes.fromhex(bytes_read.decode()), "big", signed=True
|
bytes.fromhex(bytes_read.decode()), "big", signed=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
bytes_read = await reader.readexactly(16)
|
bytes_read = await reader.readexactly(16)
|
||||||
|
print("bytes read2:", bytes_read)
|
||||||
# Reads 16 bytes of hex, for the 8 byte y_size
|
# Reads 16 bytes of hex, for the 8 byte y_size
|
||||||
y_size = uint64(
|
y_size = uint64(
|
||||||
int.from_bytes(
|
int.from_bytes(
|
||||||
|
@ -43,16 +43,19 @@ test_constants["GENESIS_BLOCK"] = bytes(
|
|||||||
|
|
||||||
async def setup_full_node(db_name, port, introducer_port=None, dic={}):
|
async def setup_full_node(db_name, port, introducer_port=None, dic={}):
|
||||||
# SETUP
|
# SETUP
|
||||||
|
test_constants_copy = test_constants.copy()
|
||||||
for k in dic.keys():
|
for k in dic.keys():
|
||||||
test_constants[k] = dic[k]
|
test_constants_copy[k] = dic[k]
|
||||||
|
|
||||||
store_1 = await FullNodeStore.create(Path(db_name))
|
store_1 = await FullNodeStore.create(Path(db_name))
|
||||||
await store_1._clear_database()
|
await store_1._clear_database()
|
||||||
unspent_store_1 = await UnspentStore.create(Path(db_name))
|
unspent_store_1 = await UnspentStore.create(Path(db_name))
|
||||||
await unspent_store_1._clear_database()
|
await unspent_store_1._clear_database()
|
||||||
mempool_1 = Mempool(unspent_store_1, dic)
|
mempool_1 = Mempool(unspent_store_1, dic)
|
||||||
b_1: Blockchain = await Blockchain.create(unspent_store_1, store_1, test_constants)
|
b_1: Blockchain = await Blockchain.create(
|
||||||
await store_1.add_block(FullBlock.from_bytes(test_constants["GENESIS_BLOCK"]))
|
unspent_store_1, store_1, test_constants_copy
|
||||||
|
)
|
||||||
|
await store_1.add_block(FullBlock.from_bytes(test_constants_copy["GENESIS_BLOCK"]))
|
||||||
|
|
||||||
config = load_config("config.yaml", "full_node")
|
config = load_config("config.yaml", "full_node")
|
||||||
if introducer_port is not None:
|
if introducer_port is not None:
|
||||||
@ -158,8 +161,8 @@ async def setup_two_nodes(dic={}):
|
|||||||
Setup and teardown of two full nodes, with blockchains and separate DBs.
|
Setup and teardown of two full nodes, with blockchains and separate DBs.
|
||||||
"""
|
"""
|
||||||
node_iters = [
|
node_iters = [
|
||||||
setup_full_node("blockchain_test.db", 21234, dic={}),
|
setup_full_node("blockchain_test.db", 21234, dic=dic),
|
||||||
setup_full_node("blockchain_test_2.db", 21235, dic={}),
|
setup_full_node("blockchain_test_2.db", 21235, dic=dic),
|
||||||
]
|
]
|
||||||
|
|
||||||
fn1, s1 = await node_iters[0].__anext__()
|
fn1, s1 = await node_iters[0].__anext__()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import pytest
|
import pytest
|
||||||
|
import time
|
||||||
from tests.setup_nodes import setup_full_system
|
from tests.setup_nodes import setup_full_system
|
||||||
|
|
||||||
|
|
||||||
@ -12,12 +13,16 @@ def event_loop():
|
|||||||
class TestSimulation:
|
class TestSimulation:
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
async def simulation(self):
|
async def simulation(self):
|
||||||
async for _ in setup_full_system({"DIFFICULTY_STARTING": 1}):
|
async for _ in setup_full_system():
|
||||||
yield _
|
yield _
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_simulation_1(self, simulation):
|
async def test_simulation_1(self, simulation):
|
||||||
node1, node2 = simulation
|
node1, node2 = simulation
|
||||||
await asyncio.sleep(60)
|
start = time.time()
|
||||||
tip_heights = [t.height for t in node1.blockchain.get_tips()]
|
while time.time() - start < 100:
|
||||||
|
if max([h.height for h in node1.blockchain.get_current_tips()]) > 10:
|
||||||
|
return
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
tip_heights = [t.height for t in node1.blockchain.get_current_tips()]
|
||||||
assert max(tip_heights) > 5
|
assert max(tip_heights) > 5
|
||||||
|
@ -59,10 +59,10 @@ class WalletTool:
|
|||||||
map(
|
map(
|
||||||
lambda child: hash
|
lambda child: hash
|
||||||
== puzzle_for_pk(
|
== puzzle_for_pk(
|
||||||
self.extended_secret_key.public_child(child)
|
self.extended_secret_key.public_child(child)
|
||||||
.get_public_key()
|
.get_public_key()
|
||||||
.serialize()
|
.serialize()
|
||||||
).get_hash(),
|
).get_hash(),
|
||||||
reversed(range(self.next_address)),
|
reversed(range(self.next_address)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user