Removes a bunch of epee garbage and replaces it with std::chrono.
In particular:
- TIME_MEASURE_* macros are gone because they are garbage.
- epee::get_tick_count() is gone because it is garbage.
- epee::get_ns_count() is gone because it is garbage.
- TIME_MEASURE_NS_* macros are gone because they are unused and garbage.
- PROFILE_FUNC_* macros are gone because they are unused and garbage.
- profile_tools::local_call_account is gone because it is unused and
garbage.
- various places passing around ints (which could be seconds,
milliseconds, or nanoseconds) changed to pass std::chrono duration
types.
- Make it compile/work
- Take outputs as a list of output indices. We never need "amount" in
Oxen (it will always be 0).
- Add backwards compatibility to still take outputs as
[{"amount":0,"index":n},...] when making a json request.
- Add an "as_tuple" bool parameter: if specified then you get results in
a much denser tuple form rather than a dict, which can make a huge
difference in the response size when requesting many outputs.
- Supports loading into tuples, std::arrays, std::pairs from a list of
the correct size.
- Supports loading into vectors of arbitrary types (include vector,
tuples, binary types, etc.)
- Removes system_clock type as we aren't using it (and because it won't
be recursively handled nicely when nested, especially for json).
Use `- \p paramname Description` rather than `\arg \c paramname
Description`.
\arg is for compatibility with some particular doc format and is
equivalent to - except that - can be nested while \arg cannot.
\c and \p are equivalent, but \p is explicitly intended for parameters.
Updates the internal callers of get_service_nodes to properly deal with
the new request format/fields.
Note that this also introduces some significant changes to the
`print_sn` output:
- contributor formats are more compact (one line per contributor), show
reserved amounts (if != contributed amouont), and show the stake %.
- reworded "Operator Cut (% of Fee Reward)" to "Operator Fee"
- checkpoint/pulse vote format is completely overhauled to list voted
and missed heights separately.
- pulse votes now show the pulse round for non-zero round results.
- timestamp checks renamed to Quorumnet tests
- qnet & timesync results now just print the number of successes/fails
rather than a list of true/false values.
Converts request parsing and result generation for get_service_nodes and
get_service_node_status.
Note that there are some significant changes here (due to no longer
having to be under epee's output constraints) that significantly reduce
the size of an all-service-nodes request by nearly half, most notably in
a significantly more compact representation of vote/participation
results.
- added a "decomm_reasons" which decomposes the reason codes into string
values such as:
"decomm_reasons": {
"all": ["uptime"],
"some": ["pulse", "lokinet"]
}
- reworded/fixed/expanded various field descriptions
- Various Loki currency references changed to OXEN
- added "operator_fee" which is a rounded operator fee expressed as
thousanths of a percent (e.g. 100000 means 100%, 4567 means 4.567%).
This is inaccurate but much easier to deal with than the raw
portions_for_operator value (especially because the value *usually*
exceeds what can be stored in a double, and thus is not safe with
various JSON parsers).
- added "swarm" which is a hex string representation of the swarm_id,
because swarm_id also isn't double-storage safe.
- reserved and total_reserved fields are now only included if they are
actually different from the amount/total_contributed values.
- various uptime-proof-dependent values (like versions, public ip,
ports) are now omitted if we haven't received an uptime proof yet.
- Flipped inverted descriptions of timestamp participation / synced
values in the RPC documentation.
- checkpoint/pulse/timecheck/timesync participations data is completely
redesigned to be less bloated; the names are now changed to
"checkpoint_votes" and "pulse_votes" and information is returned much
more compactly using lists of lists and/or plain values rather than
lists of dicts that repeat a ton of fields.
- Renamed timestamp_participation in the RPC to quorumnet_tests since,
although we're doing the test for time checking, the main purpose of
the participation is to see that we can reach them. As above, the
result value is significantly more compact: [SUCCESS,FAILS] instead of
an array of dicts.
- Similarly renamed timesync_status to timesync_tests ("status" was
fine, but changing the value completely to [SUCCESS,FAILS] warrants a
name change).
- dropped the "as_json" field because it is asking oxend to
double-encode json, and that is retarded.
- also applies all the same refactoring to get_service_node_status
(which is really just a shortcut for getting the current node's status
out of get_service_nodes).
- overhauled how "fields" works to take a list of field names (the dict
is name: bool values is still supported for backwards compatibility).
Also extended fields to handle "locked_contributions" as a supported
field (so that you can easily omit it, since it often isn't cared
about).
At MERROR they don't print at the default --log-level=0, so you get
output such as:
2021-08-06 18:04:08.073 I Starting up oxend services...
2021-08-06 18:04:08.073 I Starting core
2021-08-06 18:04:08.073 F Failed to start core
2021-08-06 18:04:08.173 I Deinitializing daemon objects...
with no actual error displayed as to why it failed to start. With this
change you get:
2021-08-06 18:04:14.004 F Please specify an IPv4 public address which the service node & storage server is accessible from with: '--service-node-public-ip <ip address>'
2021-08-06 18:04:14.004 F IMPORTANT: One or more required service node-related configuration settings/options were omitted or invalid; please fix them and restart oxend.
2021-08-06 18:04:14.004 F Failed to start core
- Moves the json binary handling code into new rpc_binary.h
- Adds support for storing/loading vectors of binary types
(crypto::hash, etc.), and vectors of strings.
- Make curve://HOST/PUBKEY URLs work (equivalent to specifying two
arguments, tcp://HOST PUBKEY, on the command line).
- When we get a response that looks bt-encoded (starts with d/l/i and
ends with e) then write it as binary rather than having Python display
the bytes representation. This allows piping it to lokinet's
`contrib/bencode-dump.py` to dump the contents.
*Nothing* calls `print_money()` with a decimal place value, for good
reason: it's a stupid thing to want to do. Similarly nothing gives a
decimal places argument to `get_unit()`.
This removes the dumb unused decimal place argument.
- make checkpoint and pulse participation distinct types
- make the container act a little more like an stl container
- replace check_participation() with a failures() method that just
returns the number of failures (so the caller can decide whether that
is bad or not).
- As a consequence of the above, failures now trigger on N+1 failures,
while previously they required N+1 failures *and* 8 total responses.
There is no need to wait for all 8 as far as I can see since we will
be failing no matter what the next 3 responses are.
- Removed the serialization code (hopefully this doesn't break
everything outside the RPC code).
- Simplify/DRY the code that records participation
The bt-encoding, in particular, is aimed at more efficient wallet3 rpc
interactions with a daemon.
This removes the rigidity from RPC request responses, making it easier
to return useful constructs that the current epee code doesn't support
(like lists of lists), and also adds support for bt-encoded RPC requests
(intended to eventually replace the ".bin" endpoints with Monero NIH
binary encoding).
Instead endpoints now set a nlohmann::json response object with whatever
arbitrary values they want without having to add a bunch of limited epee
serialization macro hell.
So, for example, to set the value "foo" to 20, you use:
rpc.response["height"] = 20;
Binary values (for things like hashes) are handled by going through a proxy object:
rpc.response_hex["hash"] = hash; // hash is a crypto::hash
which, for json, is equivalent to:
rpc.response["hash"] = tools::type_to_hex(hash);
but when the response is to be bt-encoded it leaves it as binary for
more efficient transfers.
There is also a `response_b64` that converts json-destined values to
base64 instead of hex (and again leaves bt-destined values as binary).
Parsing of incoming requests now moves to a new
core_rpc_server_command_parser file, which does free-form parsing from a
nlohmann::json or bt_dict_consumer, and has various templated helper
functions to make this easier.
This is preliminary: this builds the basic infrastucture for handling
requests, and converts three endpoints:
- get_info
- get_height
- ons_resolve
Currently only `make daemon` builds (there is code in the wallet that
hasn't been updated yet), and the other RPC interfaces are disabled by
this commit (until they get converted to the new style).
It doesn't compiler and I can't be arsed to fix it; if someone really
needs 32-bit they probably don't care about performance of turtle
hashing in oxend anyway, so the portable one is fine.
The cn_turtle_hash code makes GCC misoptimization in multiple ways under
LTO, so just force it off for GCC-11 (Hopefully the bugginess gets fixed
by GCC-12).