Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ static RPCArg GetRpcArg(const std::string& strParamName)
{"coreP2PAddrs",
{"coreP2PAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\". Must be unique on the network.\n"
"A legacy (MnNetInfo / version-2) ProTx accepts only a single entry; multiple entries\n"
"require an Extended addresses (ExtNetInfo) ProTx.\n"
"Can be set to an empty string, which will require a ProUpServTx afterwards.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
}}
},
{"coreP2PAddrs_update",
{"coreP2PAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\". Must be unique on the network.",
"Array of addresses in the form \"ADDR:PORT\". Must be unique on the network.\n"
"A legacy (MnNetInfo / version-2) ProTx accepts only a single entry; multiple entries\n"
"require an Extended addresses (ExtNetInfo) ProTx.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
}}
Expand Down Expand Up @@ -184,6 +188,8 @@ static RPCArg GetRpcArg(const std::string& strParamName)
{"platformP2PAddrs",
{"platformP2PAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\" used by Platform for peer-to-peer connection.\n"
"For a legacy (MnNetInfo / version-2) ProTx, pass a bare port number instead (e.g. 26656);\n"
"the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx.\n"
"Must be unique on the network. Can be set to an empty string, which will require a ProUpServTx afterwards.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
Expand All @@ -192,6 +198,8 @@ static RPCArg GetRpcArg(const std::string& strParamName)
{"platformP2PAddrs_update",
{"platformP2PAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\" used by Platform for peer-to-peer connection.\n"
"For a legacy (MnNetInfo / version-2) ProTx, pass a bare port number instead (e.g. 26656);\n"
"the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx.\n"
"Must be unique on the network.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
Expand All @@ -200,6 +208,8 @@ static RPCArg GetRpcArg(const std::string& strParamName)
{"platformHTTPSAddrs",
{"platformHTTPSAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\" used by Platform for their HTTPS API.\n"
"For a legacy (MnNetInfo / version-2) ProTx, pass a bare port number instead (e.g. 443);\n"
"the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx.\n"
"Must be unique on the network. Can be set to an empty string, which will require a ProUpServTx afterwards.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
Expand All @@ -208,6 +218,8 @@ static RPCArg GetRpcArg(const std::string& strParamName)
{"platformHTTPSAddrs_update",
{"platformHTTPSAddrs", RPCArg::Type::ARR, RPCArg::Optional::NO,
"Array of addresses in the form \"ADDR:PORT\" used by Platform for their HTTPS API.\n"
"For a legacy (MnNetInfo / version-2) ProTx, pass a bare port number instead (e.g. 443);\n"
"the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx.\n"
"Must be unique on the network.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
Expand Down
9 changes: 7 additions & 2 deletions src/rpc/evo_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ void ProcessNetInfoPlatform(ProTx& ptx, const UniValue& input_p2p, const UniValu
// Empty Input: We can tolerate blank values if netInfo can store platform fields, if it cannot, we are relying
// on platform{HTTP,P2P}Port, where it is mandatory even if their netInfo counterpart is optional.
// String: If not parsable as port and relying on platform{HTTP,P2P}Port, bail out.
throw JSONRPCError(RPC_INVALID_PARAMETER,
strprintf("Invalid param for %s, ProTx version only supports ports", field_name));
const char* example_port{purpose == NetInfoPurpose::PLATFORM_HTTPS ? "443" : "26656"};
throw JSONRPCError(
RPC_INVALID_PARAMETER,
strprintf("Invalid param for %s, this ProTx version only accepts a bare port number "
"(e.g. %s); the \"ADDR:PORT\" / address-array form requires an Extended "
"addresses (ExtNetInfo) ProTx",
field_name, example_port));
}
if (input.isArray()) {
const UniValue& entries = input.get_array();
Expand Down
25 changes: 13 additions & 12 deletions test/functional/rpc_netinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,37 +270,38 @@ def test_validation_legacy(self):
DEFAULT_PORT_PLATFORM_P2P, DEFAULT_PORT_PLATFORM_HTTP,
-8, f"Error setting coreP2PAddrs[1] to '127.0.0.2:{self.node_evo.mn.nodePort}' (too many entries)")

# platformP2PAddrs and platformHTTPSAddrs don't accept non-numeric inputs
# platformP2PAddrs and platformHTTPSAddrs don't accept non-numeric inputs; the rejection should
# also tell users that the "ADDR:PORT" / array form needs an Extended addresses (ExtNetInfo) ProTx.
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", f"127.0.0.1:{DEFAULT_PORT_PLATFORM_P2P}", DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "this ProTx version only accepts a bare port number (e.g. 26656); the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", [f"127.0.0.1:{DEFAULT_PORT_PLATFORM_P2P}"], DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "Invalid param for platformP2PAddrs, this ProTx version only accepts a bare port number")
Comment on lines 275 to +278

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Refresh the first legacy P2P rejection string.

Line 276 is missing the Invalid param for platformP2PAddrs, prefix, and Line 278 still checks the old truncated text. Update both to the full validator message so this case actually covers the new wording.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/functional/rpc_netinfo.py` around lines 275 - 278, The error message
validation in the first register_mn call on line 276 is missing the "Invalid
param for platformP2PAddrs," prefix that the validator actually returns.
Additionally, the second register_mn call on line 278 contains an outdated
truncated error message text. Update both error message strings in these two
register_mn calls to match the complete and current validator error messages,
ensuring that the first one includes the "Invalid param for platformP2PAddrs,"
prefix and the second one uses the full validator message text instead of the
truncated version.

self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", DEFAULT_PORT_PLATFORM_P2P, f"127.0.0.1:{DEFAULT_PORT_PLATFORM_HTTP}",
-8, "Invalid param for platformHTTPSAddrs, ProTx version only supports ports")
-8, "Invalid param for platformHTTPSAddrs, this ProTx version only accepts a bare port number (e.g. 443); the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", DEFAULT_PORT_PLATFORM_P2P, [f"127.0.0.1:{DEFAULT_PORT_PLATFORM_HTTP}"],
-8, "Invalid param for platformHTTPSAddrs, ProTx version only supports ports")
-8, "Invalid param for platformHTTPSAddrs, this ProTx version only accepts a bare port number (e.g. 443); the \"ADDR:PORT\" / address-array form requires an Extended addresses (ExtNetInfo) ProTx")

# Port numbers may not be wrapped in arrays, either as integers or strings
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", [DEFAULT_PORT_PLATFORM_P2P], DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "Invalid param for platformP2PAddrs, this ProTx version only accepts a bare port number")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", [f"{DEFAULT_PORT_PLATFORM_P2P}"], DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "Invalid param for platformP2PAddrs, this ProTx version only accepts a bare port number")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", DEFAULT_PORT_PLATFORM_P2P, [DEFAULT_PORT_PLATFORM_HTTP],
-8, "Invalid param for platformHTTPSAddrs, ProTx version only supports ports")
-8, "Invalid param for platformHTTPSAddrs, this ProTx version only accepts a bare port number")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", DEFAULT_PORT_PLATFORM_P2P, [f"{DEFAULT_PORT_PLATFORM_HTTP}"],
-8, "Invalid param for platformHTTPSAddrs, ProTx version only supports ports")
-8, "Invalid param for platformHTTPSAddrs, this ProTx version only accepts a bare port number")

Comment on lines 284 to 293

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the array-wrapped port expectations.

These four assertions still only match the old prefix. They should include the new example-port and ExtNetInfo wording emitted by ProcessNetInfoPlatform, otherwise these cases won’t verify the new behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/functional/rpc_netinfo.py` around lines 284 - 293, The error message
expectations in all four register_mn function calls need to be updated to match
the new error message format. The current error messages only contain the old
prefix text, but they should be updated to include the new example-port and
ExtNetInfo wording that is now emitted by ProcessNetInfoPlatform. Update each of
the four error message strings (passed as the last argument to each register_mn
call) to include the additional new wording that ProcessNetInfoPlatform now
generates for invalid array-wrapped port parameters in platformP2PAddrs and
platformHTTPSAddrs.

# coreP2PAddrs cannot be empty when registering a masternode without specifying platform fields
self.node_evo.register_mn(self, False, "", "", "",
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "Invalid param for platformP2PAddrs, this ProTx version only accepts a bare port number")
self.node_evo.register_mn(self, False, "", "", DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, ProTx version only supports ports")
-8, "Invalid param for platformP2PAddrs, this ProTx version only accepts a bare port number")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", "", "",
-8, "Invalid param for platformP2PAddrs, cannot be empty if other fields populated")
self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", "", DEFAULT_PORT_PLATFORM_HTTP,
-8, "Invalid param for platformP2PAddrs, cannot be empty if other fields populated")
self.node_evo.register_mn(self, False, "", DEFAULT_PORT_PLATFORM_P2P, "",
-8, "Invalid param for platformHTTPSAddrs, ProTx version only supports ports")
-8, "Invalid param for platformHTTPSAddrs, this ProTx version only accepts a bare port number")
Comment on lines 294 to +304

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Bring the empty-core/partial-platform cases up to date.

These assertions still expect the short legacy text. Use the full Invalid param for ... message, including the bare-port example, so the updated validator output is actually checked here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/functional/rpc_netinfo.py` around lines 294 - 304, The test assertions
for the empty-core and partial-platform registration cases in the register_mn
calls are using outdated error message formats. Update all error message strings
in the register_mn method calls within this test section to use the full updated
error message format that includes the bare-port example (e.g., "Invalid param
for platformP2PAddrs, this ProTx version only accepts a bare port number"),
ensuring they match the current validator output being checked in the test.

self.node_evo.register_mn(self, False, f"127.0.0.1:{self.node_evo.mn.nodePort}", DEFAULT_PORT_PLATFORM_P2P, "",
-8, "Invalid param for platformHTTPSAddrs, cannot be empty if other fields populated")

Expand Down
Loading