Commit graph

7435 commits

Author SHA1 Message Date
Doyle
00befd0605 Remove constexpr on member functions due to gcc 5.* bug
/home/travis/build/loki-project/loki-core/src/cryptonote_basic/tx_extra.h:422:20: error: enclosing class of constexpr non-static member function ‘void cryptonote::tx_extra_loki_name_system::set_field(lns::extra_field)’ is not a literal type
     constexpr void set_field    (lns::extra_field bit)       { fields = static_cast<lns::extra_field>(static_cast<uint8_t>(fields) | static_cast<uint8_t>(bit)); }
2020-03-11 10:58:05 +11:00
Doyle
61ebda92c8 Rewrite reorgs to handle LNS TX updates
Updates are granular and can update individual fields of a LNS TX,
meaning when we reorg- restoring a record to its proper state can
potentially require searching further back than the detach height.

The following scenario, copied from a comment in loki_name_system.cpp
-----------------------------------------------------------------------------------------------
Detach Logic: Simple Case
-----------------------------------------------------------------------------------------------
LNS Buy    @ Height 100: LNS Record={field1=a1, field2=b1, field3=c1}
LNS Update @ Height 200: LNS Record={field1=a2                      }
LNS Update @ Height 300: LNS Record={           field2=b2           }
LNS Update @ Height 400: LNS Record={                      field3=c2}

Blockchain detaches to height 301, the target LNS record now looks like
                                    {field1=a2, field2=b2, field3=c1}

Our current LNS record looks like
                                    {field1=a2, field2=b2, field3=c3}

To rebuild our record, find the closest LNS Update that is earlier than the
detach height. If we run out of transactions to run back to, then the LNS
entry is just deleted.

-----------------------------------------------------------------------------------------------
Detach Logic: Advance Case
-----------------------------------------------------------------------------------------------
LNS Buy    @ Height 100: LNS Record={field1=a1, field2=b1, field3=c1}
LNS Update @ Height 200: LNS Record={field1=a2                      }
LNS Update @ Height 300: LNS Record={           field2=b2           }
LNS Update @ Height 400: LNS Record={                      field3=c2}
LNS Update @ Height 500: LNS Record={field1=a3, field2=b3, field3=c3}
LNS Update @ Height 600: LNS Record={                      field3=c4}

Blockchain detaches to height 401, the target LNS record now looks like
                                    {field1=a2, field2=b2, field3=c2}

Our current LNS record looks like
                                    {field1=a3, field2=b3, field3=c4}

To get all the fields back, we can't just replay the latest LNS update
transactions in reverse chronological order back to the detach height,
otherwise we miss the update to field1=a2 and field2=b2.

To rebuild our LNS record, we need to iterate back until we find all the
TX's that updated the LNS field(s) until all fields have been reverted to
a state representative of pre-detach height.

i.e. Go back to the closest LNS record to the detach height, at height 300.
Next, iterate back until all LNS fields have been updated at a point in
time before the detach height (i.e. height 200 with field=a2).
2020-03-11 10:58:05 +11:00
Doyle
81dff49468 Support updating individual fields via LNS update txs 2020-03-11 10:58:05 +11:00
Doyle
c3801abcc7 LNS s/row/column, was using row where column should be 2020-03-11 10:58:05 +11:00
Doyle
d54f117469 Owner is optional, if not specified it will use the current wallet 2020-03-11 10:58:05 +11:00
Doyle
9b3a25326a Move null checks to general validate section, use macro for error reporting 2020-03-11 10:58:05 +11:00
Doyle
aaf078d4f2 Rename data/entry -> lns_extra, bit_field_* -> field_* 2020-03-11 10:58:05 +11:00
Doyle
1bff385cac Add support for backup owners and allow updating LNS fields 2020-03-11 10:58:05 +11:00
Doyle
08ac9bb254 Update SQL commands to handle backup owner keys 2020-03-11 10:58:05 +11:00
Doyle
7819046b08 Make LNS take generic keys/sigs where it can for owner keys 2020-03-11 10:58:05 +11:00
Doyle
ee02eea89f SQL injection fix, index optimize, general code warts 2020-03-11 10:58:05 +11:00
Doyle
20e41ed74a Use prepare_tx_extra .. helper to gen signature 2020-03-11 10:58:05 +11:00
Doyle
d7507a65b5 Actually add make update signature to simplewallet interface 2020-03-11 10:58:05 +11:00
Doyle
68782a76df Add standalone LNS signature generator for CLI/RPC wallet 2020-03-11 10:58:05 +11:00
Doyle
5dd5723332 Prefix LNS commands with lns, instead of <verb> lns <action> 2020-03-11 10:58:05 +11:00
Doyle
91036eb2ad Revise LNS documenation to reflect actual implementation 2020-03-11 10:58:05 +11:00
Doyle
e1424c5c5d Check LNS record is loaded 2020-03-11 10:58:05 +11:00
Doyle
da8e448a27 Use helper function to verify LNS records in tests
So that when adding new fields to records, updating the helper will
trigger compile errors on pre-existing record checks. There have been
several updates to mapping records that weren't being tested over the
lifetime of implementing LNS.
2020-03-11 10:58:05 +11:00
Doyle
218af8ce8c Bake SQL arguments into get_mappings sql 2020-03-11 10:58:05 +11:00
Doyle
f743a5491f DRY combining mapping and owner table together 2020-03-11 10:58:05 +11:00
Doyle
aefdbbcae4 Update SQL commands to handle backup owner keys 2020-03-11 10:58:05 +11:00
Doyle
43f7119cb1 Make generic crypto be comparable 2020-03-11 10:58:05 +11:00
Doyle
33cfc7ab31 Verify owner/backup owner when validating LNS txs 2020-03-11 10:58:05 +11:00
Doyle
9071ecbc92 Make LNS take generic keys/sigs where it can for owner keys 2020-03-11 10:58:05 +11:00
Doyle
e905be5ebf Add generic_[key|signature] to handle monero/ed25519 keys 2020-03-11 10:58:05 +11:00
Doyle
2d79c1effe Update documentation for LNS commands 2020-03-11 10:58:05 +11:00
Doyle
4b0fdd6d39
Remove hardcoded checkpoint on testnet (#1059)
Hardcoded checkpoints are not expected after HF13. At some point during
the previous releases's testing period we added a hardcoded checkpoint
because we redid the hardforking blocks on testnet due to some
incompatible changes- but were tenable to reboot the network on a small
network like the testnet.

This commit deletes the checkpoint instead of adding an exception so as
to not require letting the service node list accept hardcoded
checkpoints after HF13, or worse, if somehow a corrupt checkpoint was
added to the DB somehow, and on retrieval we return a checkpoint with no
signatures, this could sneak through as it'd be detected as a hardcoded
checkpoint once loaded from the DB.

We could provide an exception if it was a checkpoint on height 127XXX
and it was testnet, but this is too intrusive change to the conditional
for an insignifcant testing change.
2020-03-10 12:22:51 +11:00
Doyle
3948e5bf14 Update hex usage to lokimq::hex 2020-03-06 16:37:33 +11:00
Doyle
0d4c446d69 Store base64 hashes into the LNS DB
Everywhere still uses crypto::hash for the name_hash due to being the
most compact storage form except for the LNS DB which uses base64 so
that it can be indexes in SQL for speed.

But at the boundary between requesting and accessing the DB entry, the
hash gets converted into a base64 representation of the hash.

We opt for base64 as it is more compact than storing the hex
representation.
2020-03-06 16:25:41 +11:00
Doyle
9c5058b72d Fix core tests and print out binary vals in hex 2020-03-06 16:25:41 +11:00
Doyle
1b22b5080b Add documentation for LNS prototypes 2020-03-06 16:25:41 +11:00
Doyle
1ba657d3b5 Encrypt mapping values via libsodium, using the name as secret 2020-03-06 16:25:41 +11:00
Doyle
79ad110ba7 Remove generic LNS support, it is still early days
This is feature creep that we haven't thought out properly about how to
flesh it out. Removing it reduces complexity.
2020-03-06 16:25:21 +11:00
Doyle
5f0c146e07 Mask the name by hashing using sodium's blake2b 2020-03-06 16:25:21 +11:00
Doyle
77cda2ad48
Merge pull request #1055 from jagerman/lokimq
Change quorumnet to use loki-mq
2020-03-06 15:57:47 +11:00
Jason Rhinelander
374807dc45 Fix NO_AES definition 2020-03-06 00:52:01 -04:00
Jason Rhinelander
c98688fd84 Convert quorumnet to loki-mq
This adds the loki-mq dependency and replaces SNNetwork with it (along
with some syntax updates for how loki-mq changed a bit from SNNetwork).

This also replaces common/hex.h and common/string_view.h with loki-mq's
faster (hex) and more complete and tested (string_view) implementations.
2020-03-06 00:36:57 -04:00
Jason Rhinelander
5b97ff6e9c cmake modernization
The archaic (i.e. decade old) cmake usage here really got in the way of
trying to properly use newer libraries (like lokimq), so this undertakes
overhauling it considerably to make it much more sane (and significantly
reduce the size).

I left more of the architecture-specific bits in the top-level
CMakeLists.txt intact; most of the efforts here are about properly
loading dependencies, specifying dependencies and avoiding a whole pile
of cmake antipatterns.

This bumps the required cmake version to 3.5, which is what xenial comes
with.

- extensive use of interface libraries to include libraries,
definitions, and include paths

- use Boost::whatever instead of ${Boost_WHATEVER_LIBRARY}.  The
interface targets are (again) much better as they also give you any
needed include or linking flags without needing to worry about them.

- don't list header files when building things.  This has *never* been
correct cmake usage (cmake has always known how to wallet_rpc_headers
the headers that .cpp files include to know about build changes).

- remove the loki_add_library monstrosity; it breaks target names and
makes compiling less efficient because the author couldn't figure out
how to link things together.

- make loki_add_executable take the output filename, and set the output
path to bin/ and install to bin because *every single usage* of
loki_add_executable was immediately followed by setting the output
filename and setting the output path to bin/ and installing to bin.

- move a bunch of crap that is only used in one particular
src/whatever/CMakeLists.txt into that particular CMakeLists.txt instead
of the top level CMakeLists.txt (or src/CMakeLists.txt).

- Remove a bunch of redundant dependencies; most of them look like they
were just copy-and-pasted in, and many more aren't needed (since they
are implied by the PUBLIC linking of other dependencies).

- Removed `die` since it just does a FATAL_ERROR, but adds color (which
is useless since CMake already makes FATAL_ERRORs perfectly visible).

- Change the way LOKI_DAEMON_AND_WALLET_ONLY works to just change the
make targets to daemon and simplewallet rather than changing the build
process (this should make it faster, too, since there are various other
things that will be excluded).
2020-03-06 00:36:57 -04:00
Doyle
e903ba2e48
Merge pull request #1037 from Doy-lee/LokiNameServiceMultiYearRego
Loki Name Service - Multi Year Rego
2020-03-05 15:47:51 +11:00
Doyle
7f4572cc1f Move out economic related constants/functions to loki_economy
Add TODO for staking requirement/block reward as they require giving
acccess to loki::exp2/loki::round, till post testnet cleanup.
2020-03-05 11:11:02 +11:00
Doyle
d6dc29bb5a LNS: Test all lokinet year expirations, take string by val in lowercase_string 2020-03-05 10:15:57 +11:00
Doyle
e95e8fc45b
Propagate error message to CLI wallet (#1047) 2020-03-05 09:39:11 +11:00
Jason Rhinelander
997ef13551
Merge pull request #1052 from Doy-lee/RevertDebugHFChanges
Revert debug testnet hardfork changes from LNS
2020-03-04 00:20:09 -04:00
Doyle
f0be1e0195 Revert debug testnet hardfork changes from LNS 2020-03-04 10:22:20 +11:00
Sean
973c260f07
Add get_service_node_status rpc endpoint (#1050)
* Adds GET_SERVICE_NODE_STATUS RPC endpoint to lokid

Previously the getting the service node status was only available in the
lokid console. This commit adds the endpoint to the RPC server

* removed unnecessary variable, allow for json in request
2020-03-04 09:11:57 +11:00
Doyle
df69008d07
Move simple string view out to common/string_view.h (#1049) 2020-02-28 12:00:54 +11:00
Doyle
cbc0740f43 LNS: Allow multi-year registration for lokinet entries 2020-02-25 12:56:42 +11:00
Doyle
8aacc33fb1
Rewrite the integration tests to use pipes (#1045) 2020-02-21 14:48:25 +11:00
Doyle
02a1f0741a
Merge pull request #1044 from Doy-lee/LokiNameServiceUpdateTX
Loki Name Service - Update Mappings TX
2020-02-21 11:06:01 +11:00
Doyle
7a584a45a0 Use libsodium to hash the contents for signatures
Prefer libsodium so that external libraries don't have to link against
Monero crypto and can instead opt for more standardized cryptography
libraries.
2020-02-21 09:32:45 +11:00