Commit graph

1036 commits

Author SHA1 Message Date
Jason Rhinelander
5f1bd2f1e4 Drop integration test code.
This code is bitrotting, doesn't compile, and isn't being maintained
anymore.

The integration test suite was an interesting idea, in early Loki days,
but is no longer being maintained and is quite cumbersome to run (for
instance, it is not possible to run it via CI because it depends on
xterm to actually run).  The code to actually run it (in doy-lee's
loki-integration-testing repository) is also a large burden of "janky"
code that isn't worth maintaining.

Remove this from the code; if someone wants to pick it back up in the
future reverting this commit shouldn't be too difficult (though I'd
suggest that a much better approach to integration testing would be to
run different daemons/wallets via rpc commands, as the network-tests do,
rather than trying to feed stdin and parse stdout from running
individual oxends/wallets).
2021-08-19 16:42:15 -03:00
Jason Rhinelander
ead4819fec Minor code simplification
Eliminates a pointless local variable and a pointless block.
2021-06-19 15:13:57 -03:00
Jason Rhinelander
7b00cb251b Add snode revision soft forks & drop hard fork voting code
Snode revisions are a secondary version that let us put out a mandatory
update for snodes that isn't a hardfork (and so isn't mandatory for
wallets/exchanges/etc.).

The main point of this is to let us make a 9.2.0 release that includes
new mandatory minimums of future versions of storage server (2.2.0) and
lokinet (0.9.4) to bring upgrades to the network.

This slightly changes the HF7 blocks to 0 (instead of 1) because,
apparently, we weren't properly checking the HF value of the
pre-first-hf genesis block at all before.  (In practice this changes
nothing because genesis blocks are v7 anyway).

This also changes (slightly) how we check for hard forks: now if we skip
some hard forks then we still want to know the height when a hard fork
triggers.  For example, if the hf tables contains {7,14} then we still
need to know that the HF14 block height also is the height that
activates HF9, 10, etc.
2021-06-19 15:13:57 -03:00
Jason Rhinelander
fd7c35801f Increase various potentially fatal error log levels
MERROR doesn't come through at default low-logging level so promote them
to MFATAL so it's more obvious where things are failing when they fail.
2021-04-20 00:16:20 -03:00
Sean Darcy
5041dd7726 reduce fees 2021-04-19 09:45:10 +10:00
Sean Darcy
8023b59867 rebrand lns -> ons 2021-04-12 10:27:57 +10:00
Sean Darcy
057711a026 Test suite fix for HF18
Governance reward calculations were hard-coded for == HF17 rather than
>= 17, so for HF18 it was falling back to the old "add up all the
values" method that we used to use.  Updated it to support HF18, and add
a static_assert that will fail to compile (without a fix) when we add
HF19.

Also some minor cleanups (mostly indent changes for unnecessary blocks
-- ignore whitespace when looking at the diff).
2021-03-28 22:04:45 -03:00
Sean Darcy
432dc319a9 executable names changed 2021-01-04 14:19:42 +11:00
Sean Darcy
0396698ee7 initial loki -> oxen pass 2021-01-04 11:09:45 +11:00
Jason Rhinelander
1f03bb41b7 Test suite: add tx version hack and remove broken tests
This adds a variable hack into loki-core that lets us disable the
transaction hard fork requirement so that the test suite can still
generate transactions under older tx rules even though the transactions
will be modern CLSAG txes.

These are sort of bastardized txes that can never occur on the proper
mainnet, but let us keep tests that apply to v2/v3 transactions even
though we can't actually generate proper v2/v3 transactions anymore.

A few tests got removed here because they are testing for old invalid
bulletproof formats that don't matter anymore because they will never be
accepted on the current chain anyway.
2020-12-13 21:42:10 -04:00
Jason Rhinelander
c49705dfdc Test fixes for old tx construction removal
- updates tests to work properly with current HF
- makes loki_generate_sequential_hard_fork_table jump 7->14....->15->16
rather than intermediate 8-9-10-11-12-13 blocks.  (The 14 sequence is
the generate block rewards before 15 lowers and 16 eliminates mining
rewards).
- remove test relying on the old 30-day expiry; that only worked on old
HFs, but also required old (pre-v4) txes which don't work anymore, so I
just removed the test.
2020-12-10 20:01:28 -04:00
Jason Rhinelander
62b88d4006 Add debugging to SN vote disallowing 2020-12-10 03:07:53 -04:00
Jason Rhinelander
d952a53691 Remove pre-HF16 CLSAG check and gen CLSAG txes in core test
Core tests were breaking because of the removal of pre-CLSAG
transaction generation support.  This fixes it by allowing and using
CLSAG transactions before HF16 (which is safe to do now that we are well
past the hard fork).
2020-12-08 22:34:30 -04:00
Jason Rhinelander
4f9f39c6ab Remove nonce (replace with 0) from stake unlock
There is no reason at all to sign a *different* message in every stake
unlock; signatures already have their own nonce.

Having something that serves no purpose is worse than not having it
(because it leads to questions about why such a thing is there), so this
commit removes it by always using 0 as a nonce and comments about it.

Removing this from the broadcast tx would require a new tx extra field
so that isn't worth doing for now (but can be done in the future if we
change the tx extra structure for unlocks).

This also simplifies the nonce-to-hash code and fixes an endian bug in
it.
2020-12-04 15:08:02 -04:00
Jason Rhinelander
67f4e990d2 Remove MLSAG generation
The blockchain only accepts CLSAG txes now, so no need to keep the MLSAG
generation code around.  (MLSAG verification stays, of course).
2020-11-30 00:47:12 -04:00
Jason Rhinelander
5f51c29646 Remove impossible code
This is dead code as the previous if is always entered for CLSAG.  The
body of this is applied later in the function, so this looks like code
that got moved but the original didn't get deleted?
2020-11-30 00:47:12 -04:00
Jason Rhinelander
e8a340e9be Make RingCT and RangeProof types type-safe enum classes 2020-11-30 00:47:12 -04:00
Jason Rhinelander
b627b3b4bb Move epee includes under "epee/..."
This ends epee's include pollution.
2020-10-24 12:46:27 -03:00
Jason Rhinelander
78833f9d69 Remove deprecated epee code 2020-10-24 12:46:26 -03:00
Jason Rhinelander
1dd98f3dae std::filesystem
Converts all use of boost::filesystem to std::filesystem.

For macos and potentially other exotic systems where std::filesystem
isn't available, we use ghc::filesystem instead (which is a drop-in
replacement for std::filesystem, unlike boost::filesystem).

This also greatly changes how we handle filenames internally by holding
them in filesystem::path objects as soon as possible (using
fs::u8path()), rather than strings, which avoids a ton of issues around
unicode filenames.  As a result this lets us drop the boost::locale
dependency on Windows along with a bunch of messy Windows ifdef code,
and avoids the need for doing gross boost locale codecvt calls.
2020-10-24 12:45:37 -03:00
Jason Rhinelander
b7dd5e8911 Target macos 10.12
When targetting macos <10.14 macos won't allow use of anything from
C++17 that throws, such as:
- std::get on a variant
- std::visit
- std::optional::value()
- std::any_cast

This avoids all of these.

For std::get, we either replace with std::get_if (where appropriate), or
else use a `var::get` implementation of std::get added to lokimq (also
updated here).  (This `var` namespace is just an `std` alias everywhere
*except* old target macos).

For std::visit, likewise lokimq adds an var::visit implementation for
old macos that we use.

std::optional::value() uses weren't useful anyway as everywhere it calls
them we've already checked that the option has a value, in which case we
can use `*opt` (which doesn't check for contents and throw).

std::any just has to be avoided as far as I can tell, but the one place
we used it is only ever a block, so I just replaced it with a `const
block*`.
2020-10-18 11:18:08 -03:00
Doyle
93950ca681
Merge pull request #1290 from Doy-lee/PrecomputedBlockHashUpdates
Precomputed block hash updates
2020-09-30 15:29:19 +10:00
Doyle
5dc7b01d9a blockchain: Fix non-checkpointed blocks skipping verification 2020-09-30 14:08:26 +10:00
Doyle
f8caed218d blockchain: Fix pre-computed block hash verification failure 2020-09-30 12:23:32 +10:00
Doyle
c8dd8e6152 blocks: Regenerate block hashes
- Change size_needed to expect 1 hash instead of 2. 2 hashes is when
Monero added tx pruning and they include a secondary hash for those
purposes. At Loki we don't quite support pruning yet as blocks are
needed for the Service Node network to operate.
2020-09-30 12:17:26 +10:00
Doyle
72700383ce rescan_diffic: Simplify params, update cli arg in blockchain_import 2020-09-30 11:17:12 +10:00
Doyle
ee19af8a42 Pulse: Add more logging for when quorum signatures fail 2020-09-27 18:21:45 +10:00
Doyle
18885e153c blockchain: Correctly report/assign PULSE difficulty on alt blocks 2020-09-27 16:59:46 +10:00
Doyle
0d82626743 Pulse: Restore the +1 atomic loki in validate_miner_tx
- This is needed for HF8->HF14 when floating point math is used for the
block reward
2020-09-26 13:52:39 +10:00
Doyle
ceff8d560c Pulse: Account for dust in portions payout >= HF16
- We also remove the distinction between service_node_total and
service_node_paid. Previously the portions payout may still have some
remainder dust loki that was not distributed, and or distributed to the
miner as the difference between the pay out and the base reward was
added to the miner.

This is still the case for backwards compatibility before HF16. After
HF16, dust is not allowed and everything is split with the remainder
dust going to the 1st contributor in the Service Node (the operator).
2020-09-26 13:52:39 +10:00
Doyle
103477ac20 block_reward_parts: base_miner_fee -> miner_fee 2020-09-26 13:52:39 +10:00
Doyle
c22ec7c893
Merge pull request #1282 from jagerman/cosmetic-updates
Cosmetic updates
2020-09-26 13:52:03 +10:00
Doyle
37e842fe86
Pulse: Record participation uniquely (#1283)
- Avoid situations where rescanning/syncing the chain pre records the
node participation when it may not be relevant anymore (i.e. someone
restarting their node would re-record historical non-participation in
blocks and prime them for re-voting off a particular node).
2020-09-26 13:51:50 +10:00
Jason Rhinelander
95869cf55f s/blockswap/chainflip/ in HF constants
https://loki.network/2020/09/25/chainflip-rebrand/
2020-09-25 18:50:16 -03:00
Doyle
197918dbab Pulse: Add testnet soft-fork for tx fee reward change 2020-09-23 16:17:18 +10:00
Doyle
04f8307af4 Pulse: Correctly display penalized fee in summary print 2020-09-23 13:45:08 +10:00
Doyle
ee6045b410 Pulse: Subtract block penalty from the miner fee
All block producers (Miner or Service Node) share in common the tx
fees as part of the reward they receive. The block penalty is applied on
this amount.
2020-09-23 12:48:46 +10:00
Doyle
36b1c44338 Pulse: Don't use clock for choosing pulse difficulty
Checking clocks doesn't work when syncing the chain. Syncing the chain
in retrospect will always perceive the chain was needing a miner
difficulty instead of Pulse fixed difficulty.

This is correctly done on the rescan because it checks if the block is
actually a Pulse or miner generated block.

Also remove the difficulty cookie/cache to keep difficulty logic
explicit. In the majority of cases after HF16 the hot path will always
hit the cheap branch (and return PULSE_FIXED_DIFFICULTY) instead of
pulling timestamps for difficulty.
2020-09-21 14:10:54 +10:00
Jason Rhinelander
928b4ac796 More efficient get-block-by-height lookups
Currently where we need to look up a block by height we do:

1. get block hash for the given height
2. look up block by hash

This hits the lmdb layer and does:

3. look up height from hash in hashes-to-height table
4. look up block from height in blocks table

which is pointless.  This commit adds a `get_block_by_height()` that
avoids the extra runaround, and converts code doing height lookups to
use the new method.
2020-09-18 20:25:48 -03:00
Jason Rhinelander
077ca0ff4e Update block rewards as per LRC-7 2020-09-18 19:03:58 -03:00
Jason Rhinelander
caf5e59984 Merge branch 'pulse' into dev 2020-09-18 17:40:25 -03:00
Jason Rhinelander
3f67de11df network_version_16 += _pulse 2020-09-18 16:39:50 -03:00
Jason Rhinelander
6791f2e3eb Avoid calculating chain weight when not needed
Small optimization: when the alt chain has more or fewer checkpoints we
don't need the chain weights, so skip the weight calculations.
2020-09-18 13:50:06 -03:00
Doyle
2687f6a44c Pulse: Solve ties in alt chains by weight
See: https://github.com/loki-project/loki-core/pull/1235#discussion_r490367785
2020-09-18 13:50:06 -03:00
Doyle
35817a7473 temp: Remove devnet resetting code 2020-09-18 13:50:06 -03:00
Doyle
6c4ab79977 Restart devnet from scratch 2
- We avoid generating outputs if the amount is 0 (0 miner rewards in
HF16, alternative rounds with no tx's have 0 fees awarded)

- Adjust the time catch/delay mechanism for Pulse from 15s to 30s.
2020-09-18 13:50:06 -03:00
Doyle
111fe26fa6 Pulse: get_round_timings needs to work with alt blocks
- Make it stop relying on the block and instead the user must pass in
the correct information
2020-09-18 13:50:05 -03:00
Doyle
268c0d5b63 Pulse: Fix off by one round timings, remove unused block timings fn
- Fix cached blocks using too old timestamps
2020-09-18 13:50:05 -03:00
Doyle
65cd0faaf2 Pulse: Handle alternative block reorg with Pulse blocks
- Alternative pulse blocks must be verified against the quorum they belong to.
  This updates alt_block_added hook in Service Node List to check the new Pulse
  invariants and on passing allow the alt block to be stored into the DB until
  enough blocks have been checkpointed.

- New reorganization behaviour for the Pulse hard fork. Currently reorganization
  rules work by preferring chains with greater cumulative difficulty and or
  a chain with more checkpoints. Pulse blocks introduces a 'fake' difficulty to
  allow falling back to PoW and continuing the chain with reasonable difficulty.

  If we fall into a position where we have an alt chain of mixed Pulse blocks
  and PoW blocks, difficulty is no longer a valid metric to compare blocks (a
  completely PoW chain could have much higher cumulative difficulty if hash
  power is thrown at it vs Pulse chain with fixed difficulty).

  So starting in HF16 we only reorganize when 2 consecutive checkpoints prevail
  on one chain. This aligns with the idea of a PoS network that is
  governed by the Service Nodes. The chain doesn't essentially recover until
  Pulse is re-enabled and Service Nodes on that chain checkpoint the chain
  again, causing the PoW chain to switch over.

- Generating Pulse Entropy no longer does a confusing +-1 to the height dance
  and always begins from the top block. It now takes a block instead of a height
  since the blocks may be on an alternative chain or the main chain. In the
  former case, we have to query the alternative DB table to grab the blocks to
  work.

- Removes the developer debug hashes in code for entropy.

- Adds core tests to check reorganization works
2020-09-18 13:50:05 -03:00
Doyle
20cb89679e Pulse: Verify alt blocks from pulse 2020-09-18 13:50:05 -03:00