diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -30,19 +30,22 @@ return HexStr(g_avalanche->getSessionPubKey()); } -static UniValue addavalanchepeer(const Config &config, +static UniValue addavalanchenode(const Config &config, const JSONRPCRequest &request) { RPCHelpMan{ - "addavalanchepeer", - "\nAdd a peer to the set of peer to poll for avalanche.\n", + "addavalanchenode", + "\nAdd a node in the set of peers to poll for avalanche.\n", { {"nodeid", RPCArg::Type::NUM, RPCArg::Optional::NO, "Node to be added to avalanche."}, {"publickey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The public key of the node."}, + {"proof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, + "Proof that the node is not a sybil."}, }, RPCResults{}, - RPCExamples{HelpExampleRpc("addavalanchepeer", "5")}, + RPCExamples{ + HelpExampleRpc("addavalanchenode", "5, \"<pubkey>\", \"<proof>\"")}, } .Check(request); @@ -57,7 +60,7 @@ std::string("Invalid parameter, nodeid must be an integer")); } - NodeId nodeid = request.params[0].get_int64(); + const NodeId nodeid = request.params[0].get_int64(); // Parse the pubkey const std::string keyHex = request.params[1].get_str(); @@ -68,9 +71,12 @@ strprintf("Invalid public key: %s\n", keyHex)); } - CPubKey pubkey{HexToPubKey(keyHex)}; + CDataStream ss(ParseHexV(request.params[2], "proof"), SER_NETWORK, + PROTOCOL_VERSION); + avalanche::Proof proof; + ss >> proof; - g_avalanche->addPeer(nodeid, avalanche::Proof::makeRandom(100), pubkey); + g_avalanche->addPeer(nodeid, proof, {HexToPubKey(keyHex)}); return {}; } @@ -79,7 +85,7 @@ // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- { "avalanche", "getavalanchekey", getavalanchekey, {}}, - { "avalanche", "addavalanchepeer", addavalanchepeer, {"nodeid"}}, + { "avalanche", "addavalanchenode", addavalanchenode, {"nodeid"}}, }; // clang-format on diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -156,7 +156,7 @@ {"getnodeaddresses", 0, "count"}, {"stop", 0, "wait"}, // Avalanche - {"addavalanchepeer", 0, "nodeid"}, + {"addavalanchenode", 0, "nodeid"}, // ABC specific RPC {"setexcessiveblock", 0, "blockSize"}, }; diff --git a/test/functional/abc_p2p_avalanche.py b/test/functional/abc_p2p_avalanche.py --- a/test/functional/abc_p2p_avalanche.py +++ b/test/functional/abc_p2p_avalanche.py @@ -22,6 +22,16 @@ from test_framework import schnorr +AVA_HEX_PROOF = ( + "d97587e6c882615796011ec8f9a7b1c64104e556ba887297fd6a655bc2579d26814e8" + "54c902448ec3ce3c6fe965e3420aa3f0e9611d3c0b8a73b6329741e2e726fd17f5e8a" + "bd546a614b0e05433528b195870169a79ff23e1d58c64afad42ad81cffe53967e16be" + "b692fc5776bb442c79c5d91de00cf21804712806594010038e168a34104d9d84ebf65" + "22cf24c6fd4addedd068632a4db06c3cd6e40031c72d416e9eefbd90037383d8da9e9" + "213a4818a02f108ac1656141ecfbfdde0aeb8620eb210c08b2ce587d9fec0799f9725" + "5d2bc5a077c7b4e8ca8a68d6a0377abf0aa2473f97b37779431062dad50ef5fd21cf1" + "7c0276a293ee5b3f5a130fc5f9b217585cae23e") + BLOCK_ACCEPTED = 0 BLOCK_REJECTED = 1 BLOCK_UNKNOWN = -1 @@ -183,7 +193,7 @@ # Activate the quorum. for n in quorum: - node.addavalanchepeer(n.nodeid, pubkey.hex()) + node.addavalanchenode(n.nodeid, pubkey.hex(), AVA_HEX_PROOF) def can_find_block_in_poll(hash, resp=BLOCK_ACCEPTED): found_hash = False