Commit Graph

937 Commits

Author SHA1 Message Date
Jason Rhinelander 965e4f05eb
Documentation generation using docsify
- Adds script to extract markdown from the rpc comments to build a docs
  page suitable for docsify.
- Split up daemon rpc docs logically into sections
- Reformat (mostly rewrapping) various docs entries
- Add examples, many of which are live-fetched at documentation
  generation time.
- Mark various required options as `required{...}` so that they produce
  an error if not provided in a request.
2023-01-11 14:27:26 -04:00
Jason Rhinelander c64c1c329a
Fix get_accrued_batched_earnings missing "status": "OK"
Not having it broke wallet2.
2023-01-10 22:22:44 -04:00
Jason Rhinelander 883658fbda
Fix segfault in get_block
Only `.reserve()` was called here, so assigning into `.begin()` isn't
valid (we either need to `.resize()`, or use `std::back_inserter`).
2022-12-21 15:21:59 -04:00
Jason Rhinelander 165b545975
Remove json_archiver debugging 2022-12-21 15:14:32 -04:00
Jason Rhinelander eaf8bd39f2
Redo json_archiver in nlohmann::json
Manually creating json the way we were doing is dumb.  This redoes it
using nlohmann::json, which in turn lets us merge the serialized json
into rpc results.
2022-12-20 21:34:04 -04:00
Jason Rhinelander af37b44427
Reformatting/cleanup 2022-12-19 12:27:10 -04:00
Jason Rhinelander b128f373d3
More RPC fixes 2022-12-16 22:42:20 -04:00
Jason Rhinelander 3179a97b32
Make get_sn_state_changes admin-only
This call can make the node do a full tx scan for state change
transactions, which can be expensive.  It is currently only used in the
oxend CLI interface, so seems fine to make admin-restricted.
2022-12-16 19:22:21 -04:00
Jason Rhinelander 2c7a4ab841
Activate various RPC endpoints
These all appear to be converted, but weren't moved into the active
endpoint type list.

Includes a rename of SETBANS/GETBANS to SET_BANS/GET_BANS
2022-12-16 16:10:14 -04:00
Jason Rhinelander 5bd678010f
Fix binary local pubkey setting
The ed/x pubkeys were not being properly set via the json proxy, and so
were throwing when use.  (This only triggered when calling on a service
node as the non-service-node path did the wrong thing).
2022-12-16 14:51:46 -04:00
Sean Darcy 172093fbbf wallet3 cli
This introduces wallet3 cli to the codebase, build using python and
wraps the c++ wallet3 core using pybind.
2022-12-06 08:10:31 +11:00
Jason Rhinelander 6aa9db9538
Overhaul and fix crypto::{public_key,ec_point,etc.} types
- Remove implicit `operator bool` from ec_point/public_key/etc. which
  was causing all sorts of implicit conversion mess and bugs.
- Change ec_point/public_key/etc. to use a `std::array<unsigned char,
  32>` (via a base type) rather than a C-array of char that has to be
  reinterpret_cast<>'ed all over the place.
- Add methods to ec_point/public_key/etc. that make it work more like a
  container of bytes (`.data()`, `.size()`, `operator[]`, `begin()`,
  `end()`).
- Make a generic `crypto::null<T>` that is a constexpr all-0 `T`, rather
  than the mishmash `crypto::null_hash`, crypto::null_pkey,
  crypto:#️⃣:null(), and so on.
- Replace three metric tons of `crypto::hash blahblah =
  crypto::null_hash;` with the much simpler `crypto::hash blahblah{};`,
  because there's no need to make a copy of a null hash in all these
  cases.  (Likewise for a few other null_whatevers).
- Remove a whole bunch of `if (blahblah == crypto::null_hash)` and `if
  (blahblah != crypto::null_hash)` with the more concise `if
  (!blahblah)` and `if (blahblah)` (which are fine via the newly
  *explicit* bool conversion operators).
- `crypto::signature` becomes a 64-byte container (as above) but with
  `c()` and `r()` to get the c() and r() data pointers.  (Previously
  `.c` and `.r` were `ec_scalar`s).
- Delete with great prejudice CRYPTO_MAKE_COMPARABLE and
  CRYPTO_MAKE_HASHABLE and all the other utter trash in
  `crypto/generic-ops.h`.
- De-inline functions in very common crypto/*.h files so that they don't
  have to get compiled 300 times.
- Remove the disgusting include-a-C-header-inside-a-C++-namespace
  garbage from some crypto headers trying to be both a C and *different*
  C++ header at once.
- Remove the toxic, disgusting, shameful `operator&` on ec_scalar, etc.
  that replace `&x` with `reinterpret_cast x into an unsigned char*`.
  This was pure toxic waste.
- changed some `<<` outputs to fmt
- Random other small changes encountered while fixing everything that
  cascaded out of the above changes.
2022-10-17 22:20:54 -03:00
Jason Rhinelander 0cf55f3945
Add garbage to make it work on a garbage OS
- Don't touch <fmt/std.h> because it touches std::filesystem which makes
  macOS throw a hissy fit and refuse to compile.
- int_to_string is broken on macOS because it uses std::to_chars which
  makes macos throw a hissy fit like a cranky old female cat seeing a
  kitten if it sees it.
- wallet3 was using std::filesystem and std::visit, both of which make
  macos throw a hissy fit.  (There is a pattern here).  Apply the dumb
  fs::path and var::visit workarounds needed to appease this garbage OS.
- use var::get (from oxenc/variant.h) instead of std::get because, oh
  yeah, we need to support a garbage OS that Apple themselves don't even
  properly support.  Yay!
2022-10-17 13:45:24 -03:00
Sean Darcy 23dc129dc7
silence unused variable error for if constexpr 2022-10-17 13:45:22 -03:00
Jason Rhinelander 5806fd7825
Change simple fmt::format calls to new "..."_format(...) 2022-10-17 13:45:22 -03:00
Jason Rhinelander 085e9ba963
Unwrap fmt::format with a style argument
oxen::logging handles a style argument now (it is also safer e.g. if the
final formatted string itself intentionally contains {}).
2022-10-17 13:41:45 -03:00
Jason Rhinelander c9934b9f5f
Change most oxen::log::whatever to log::whatever
oxen::log::info(...), etc. are a bit too verbose; this simplifies them
to just `log::info(...)`, etc. by aliasing the `oxen::log` namespace
into most of the common namespaces we use in core.

This result is usage that is shorter but also reads better:

    oxen::log::info(logcat, "blah: {}", 42);

    log::info(logcat, "blah: {}", 42);
2022-10-17 13:41:43 -03:00
Sean Darcy d7992b5940
Logging Refactor
This replaces the current epee logging system with our oxen::log
library. It replaces the easylogging library with spdlog, removes the
macros and replaces with functions and standardises how we call the
logs.
2022-10-17 13:41:10 -03:00
Jason Rhinelander 7427fb051b
Merge pull request #1607 from jagerman/aux-ping-errors-dev
Allow lokinet/ss to send an error ping
2022-10-17 13:39:03 -03:00
Jason Rhinelander 46fd75fa90 Allow lokinet/ss to send an error ping
This lets lokinet or SS signal to oxend that something is known to be
wrong, and so oxend should not send a proof so that, hopefully, the
problem gets noticed and fixed.
2022-10-14 21:42:40 -03:00
Jason Rhinelander 06e3713dfc
Put current info for ourself in service node list
Currently we're putting the last-uptime-received data in the service
node list info, even when we have more updated info that hasn't yet been
accepted by the network.

This causes problems for lokinet, in particular, because it ignores any
SNs in the list without ed25519 pubkeys, including itself, which can
result in lokinet thinking it is deregistered for a while after the SN
becomes registered.

This updates `get_service_nodes` to always include current info (rather
than latest proof info) for itself when querying a service node.
2022-10-14 14:12:49 -03:00
Jason Rhinelander 2bd874e0b5
Merge remote-tracking branch 'tewinget/wallet3' into dev 2022-09-01 18:56:14 -03:00
Sean Darcy a9c83bd0b2 Atomic values for the get_service_node_registration_cmd endpoint 2022-08-31 09:58:15 +10:00
Thomas Winget d4b6f967fd Merge most recent dev and wallet3 branches
Fixes a few merge conflicts, several compilation errors, and
some behavioral incorrectness.  Still a few bugs with wallet3
but as far as I can tell wallet2 and daemon etc. should be working
correctly.
2022-08-22 19:25:49 -04:00
Thomas Winget 0b17bb9adb fix build after merge
still need to make tests build and fix up some behavior
correctness around RPC (and maybe other areas)
2022-07-25 22:22:49 -04:00
Thomas Winget 1311a20e9f merge dev branch with RPC/wallet3 changes
Incomplete, many things to fix, some annotated with
a comment MERGEFIX
2022-07-11 20:40:50 -04:00
Sean d77d791d7d
Merge branch 'dev' into batch1000 2022-05-27 11:14:55 +10:00
Sean a65c0c1dbc
Merge pull request #1544 from darcys22/batching-rpc-endpoints
Adds RPC endpoint for accrued batching balances
2022-05-27 11:10:07 +10:00
Sean 5175503098
Merge pull request #1552 from darcys22/coinbase-payouts
Rename miner_reward to coinbase_payouts and fix minor bug
2022-05-27 11:09:20 +10:00
Jason Rhinelander b9f3877ab3
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-26 15:08:08 -03:00
Sean Darcy 47a9802f83 Rename miner_reward to coinbase_payouts and fix minor bug
After the batching HF we now have a "reward" field in the block header
which is confusingly different to "miner_reward". This renames
miner_reward to coinbase_payouts to clarify that this amount is the
amount actually paid out in the coinbase vs the reward accumulated into
the batching DB.

Also fixes a minor bug where the reward would only show the reward of
the first vout instead of summing all the vouts.
2022-05-26 13:09:04 +10:00
Jason Rhinelander b6fdd9d90f
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-25 23:30:28 -03:00
Jason Rhinelander 1fa71bcc2c
Rename hf19 -> hf19_reward_batching 2022-05-24 18:54:32 -03:00
Jason Rhinelander 377cfecb09
Atomic staking amounts
This adds a new tx registration interpretation for HF19+ by repurposing
the fields of the registration:

- `expiration` becomes `hf_or_expiration`; for "new" registrations it
  contains the hardfork number (e.g. 19 for HF19), but the data layout
  on chain doesn't change: essentially we determine whether it's a new
  registration based on whether the field is <= 255 (interpret as HF) or
  not (interpret as expiration).

Changes in "new" registrations:
- stake amounts are atomic OXEN rather than portions.  This lets us skip
  a whole bunch of fiddling around with amounts that was necessary to
  deal with integer truncation when converting between amounts and
  portions.

- the fee in the registration data is now a value out of 10000 instead
  of a portion (i.e. value out of 2^64-4).  This limits fee precision to
  a percentage with two decimal places instead of ~17 decimal places.
  Internally we still convert this to a portion when processing the
  registration for service_node_states, but this makes the registration
  itself much simpler and easier to work with (as a human).

- HF19+ registrations no longer have an expiry timestamp (though they do
  depend on the hardfork, so they "expire" whenever the next hard fork).
  The expiry timestamp was really only there to avoid a registration
  amount decreasing too much from the dropping staking requirement.

- Both types are registration are still permitted for HF19, but because
  registrations with more than 4 contributors expose bugs in the portion
  transfer code (that results in registrations become invalid),
  old-style registrations are still limited to 4 contributors.

- HF19 will allow both old and new registrations, so that registrations
  generated before the HF will still work, and so that we don't break
  testnet which has various "old" registrations on it.
2022-05-24 17:36:24 -03:00
Jason Rhinelander 636ee3f622
Replace boost::endian conversion with oxenc 1.0.3
1.0.3 got some endian fixes that lets us avoid boost::endian everywhere.
2022-05-24 17:35:59 -03:00
Sean dce39ec8ee
Merge branch 'dev' into batching-rpc-endpoints 2022-05-24 11:29:49 +10:00
Thomas Winget 6ed5bba739 small status/error message change 2022-05-23 19:23:40 -04:00
Sean Darcy f45d0588ae Adds RPC endpoint for accrued batching balances
This allows a user to query the daemon and ask for the accrued balance
of oxen rewards that have been batched but not yet paid out.

The endpoint takes in an array of addresses (Strings) and returns an
array of atomic oxen amounts (integers) that reflect the current
database balances for those requested addresses.

For example an address has accrued 2x batch payments of 16.5 oxen but
has not yet been paid out will show 33000000000 being the atomic amount
in the database.
2022-05-23 08:47:18 +10:00
Jason Rhinelander 26869869aa
Remove stupid typedef 2022-05-20 18:30:55 -03:00
Jason Rhinelander dfe566480b
Remove cryptonote_config macros
- Replace all cryptonote_config macros with constexpr variables.  Some
  become integer types, some become chrono types.
  - generally this involved removing a "CRYPTONOTE_" prefix since the
    values are now in the `cryptonote` namespace
  - some constants are grouped into sub-namespaces (e.g.
    cryptonote::p2p)
  - deprecated constants (i.e. for old HFs) are in the `cryptonote::old`
    namespace.
  - all the magic hash key domain separating strings are now in
    cryptonote::hashkey::WHATEVER.
- Move some economy-related constants to oxen_economy.h instead
- Replaced the BLOCKS_EXPECTED_IN_DAYS constexpr functions with more
  straightforward `BLOCKS_PER_DAY` value (i.e.  old
  `BLOCKS_EXPECTED_IN_DAYS(10)` is now `BLOCKS_PER_DAY * 10`.
- Replaced `network_version` unscoped enum with a scoped enum
  `cryptonote::hf`, replacing all the raw uint8_t values where it was
  currently accepted with the new `hf` type.
- Made `network_type` a scoped enum so that it now has to be qualified
  (network_type::TESTNET) and can't be arbitrarily/unintentionally
  converted to/from an int.
- HARDFORK_WHATEVER macros have become cryptonote::feature::WHATEVER
  constexpr hf values.
- Add `revision` to rpc hard_fork_info response
- Don't build trezor code at all (previously we were pointlessly
  building an empty dummy lib).
2022-05-16 20:37:07 -03:00
Sean Darcy 866691d9d8 Batching of service node rewards
This updates the coinbase transactions to reward service nodes
periodically rather than every block. If you recieve a service node
reward this reward will be delayed x blocks, if you receive another
reward to the same wallet before those blocks have been completed it
will be added to your total and all will be paid out after those x
blocks has passed.

For example if our batching interval is 2 blocks:

Block 1 - Address A receives reward of 10 oxen - added to batch
Block 2 - Address A receives reward of 10 oxen - added to batch
Block 3 - Address A is paid out 20 oxen.

Batching accumulates a small reward for all nodes every block

The batching of service node rewards allows us to drip feed rewards
to service nodes. Rather than accruing each service node 16.5 oxen every
time they are pulse block leader we now reward every node the 16.5 /
num_service_nodes every block and pay each wallet the full amount that
has been accrued after a period of time (Likely 3.5 days).

To spread each payment evenly we now pay the rewards based on the
address of the recipient. This modulus of their address determines which
block the address should be paid and by setting the interval to our
service_node_batching interval we can guarantee they will be paid out
regularly and evenly distribute the payments for all wallets over this
2022-04-29 09:51:14 +10:00
Jason Rhinelander 50a41e63de
Add ed25519_pubkey field to SS & lokinet pings
Allows lokinet & storage server to feed the ed25519 key back to oxend so
that oxend makes sure everyone is on the same key.
2022-04-17 11:16:45 -03:00
Jason Rhinelander 4fa12395ef
More epee purging
Remove misc_language.h: Half of it is unused, half of it is crap doesn't
need to be used, and the two useful things (median calculator and a
scope exit caller) were poorly written.

Rewrote median from scratch and moved it out of epee.

Simplified the scope exit handler and moved it to its own small header
in epee.
2022-04-15 13:51:57 -03:00
Jason Rhinelander a66fc8ae61
Replace epee hex with oxen-encoding
- Aside from converting code, this commit also:

- Cleans out a bunch of epee garbage that this code touches.

- Removes some of the wipeable_string usage from wallet2 added by
  upstream Monero, because that usage was worse than useless: every
  instance removed uses a wipeable_string but then *copies the value
  into a std::string*, which makes the entire thing useless.

  It is, however, *worse* than useless because it is deceptive: a casual
  observer would think that the values are being wiped, when in
  actuality it only added an extra intermediate buffer that gets wiped
  while the final destination doesn't.  This deception is worse than
  nothing, and so I've removed it.

- Removes epee md5 code.  It is entirely unused, and was depending on
  the removed hex code.

- Removes a bunch of useless functions from
  epee/storages/parserse_base_utils.h: in particular the
  exception-to-bool wrappers were only being used in the test suite
  (which was dumb: the test suite is perfectly capable of a "does not
  throw" assertion).

- De-templatizes the parsing code in parserse_base_utils.h that was only
  ever called with a `const char*` "It" (except for one place in the
  test suite was which easily fixed), and moved the implementation into
  a .cpp file.
2022-04-14 14:34:50 -03:00
Jason Rhinelander 6fcfd0b8ba
Update oxenmq to latest oxen-mq+oxen-encoding
All the encoding parts move to oxen-encoding recently; this updates to
the latest version of oxen-mq, adds oxen-encoding, and converts
everything to use oxenc headers rather than the oxenmq compatibility
shims.
2022-04-14 14:32:01 -03:00
Thomas Winget 827cb3fe6c lots of minor wallet 3 fixes, rct signing still failing verification 2022-04-04 22:14:08 -04:00
Thomas Winget a6c88e3a18 move and refactor common RPC code 2022-03-28 22:24:29 -04:00
Sean Darcy 43489af3b5 ONS_OWNERS_TO_NAMES 2021-11-15 13:34:13 +11:00
Sean Darcy 8b3d2371bb GET_OUTPUT_HISTOGRAM 2021-11-15 10:38:37 +11:00
Sean Darcy 4013cb5115 GET_ALTERNATE_CHAINS 2021-11-12 15:59:40 +11:00