The rpc fuzz target constructs a vector of string args and passes that to RPCConvertValues.
This has many issues:
- Each of those strings could represent an array itself. E.g. via
range argumentor viaConsumeArrayRPCArgument. However, those strings may not be converted to an array viaRPCConvertValuesand just be passed on as string argument. Having a call toConsumeArrayRPCArgumentthat ends up with a plain json string is confusing. - The strings could only represent an object or json null, when a raw string represented such a serialized json and was also converted to one via
RPCConvertValues. Having a call toConsumeScalarRPCArgumentthat was intended to give a raw string but ends up with a arbitrary json object is confusing.
Fix those "stringly-typed" issues by making the fuzz target "type safe":
- Rename
ConsumeScalarRPCArgumenttoConsumeBasicRPCArgumentand return a properUniValuefrom it. - The "consume string" case inside that function, which had a "double meaning" is turned into two type-safe cases: One that returns a json string and one that reads an arbitrary json from a string.
- A new case for json null is added.
ConsumeRPCArgumentis changed to cover both json arrays and json dicts properly.- Pass the resulting positional UniValue array directly to the RPC method, avoiding the need for
RPCConvertValues.
Making the fuzz target "type safe" is also the first step in making it schema-aware.