Commit Graph

269 Commits

Author SHA1 Message Date
Jason Rhinelander 441c21b40d
Add overstaking prevention (#1210)
This prevents staking transactions from being accepted if they overstake
the available contribution room by more than 1%.  This is to prevent a
case that has happened a few times where there are competing partial
stakes submitted for the same SN at the same time (i.e. before a block
gets mined with the stakes).  For example:

- Operator registers service node with 30% contribution
- Staker 1 submits stake with 40% contribution
- Staker 2 submits stake with 60% contribution

The wallet avoids stake 2 if the 40% has been accepted into a block, but
doesn't if it is still in the mempool.  Later, when the contributions
get mined, both stakes are admitted because whichever one goes first
doesn't complete the stake, and the second one is still valid (since
there is a spot, and since it contributes >= the required amount).

Whichever stake gets added to a block second, however, will only be
counted as a contribution of the available amount.  So, for example, if
stake 1 gets added first and then stake 2 gets added you'll end up with
an active service node of:

- operator has 30% contributed and locked
- staker 1 has 40% contributed and locked
- staker 2 has 30% contributed but 60% locked.

This commit adds an upper bound for an acceptable stake that is 101% of
the available contribution room so that, in the above situation,
whichever stake gets added first will be a contribution and the second
one will fall through as an ordinary transaction back to the staker's
wallet so that the staker the re-contribute the proper amount.
2020-08-03 10:10:40 +10:00
Jason Rhinelander b6520c48b4 Update blockchain height estimate parameters
The parameters for estimating the mainnet height have drifted slightly
over the past two years -- there is now only about 2 days grace time (of
the 7 days added).

Testnet height estimates were already invalid (producing estimates a
little more than 3 weeks into the future because of some testnet stalls
and rollbacks), which means a newly generated testnet wallet created
without a daemon connection wouldn't work for ~3 weeks.

Updated them to values from the current mainnet and testnet chains.

This also moves the height and timestamp estimate parameters to
constexpr's in cryptonote_config as that seems a much better place for
them than line 13120 of wallet2.cpp.
2020-07-21 21:53:27 -03:00
Jason Rhinelander 06f5f3ee82 cryptonote_config.h: use inline constexpr
Currently all the variables in here need to be added into every
compilation unit; C++17 inline constexpr avoids that by throwing away
the duplicates at link time, plus lets the compiler optimize things
away.

Also eliminates a side effect in `get_config()` that mutated the
variable (so that one `get_config()` would end up changing the data of a
previous `get_config()`).  Instead `get_config()` is now always constant
and doesn't care about the hard fork version; instead there is a
convenience method to get the governance wallet_address which takes the
hf version.
2020-07-21 21:53:27 -03:00
Jason Rhinelander 29b18f6cc3 DNS: async multi-address lookup
Add a multi-address lookup mode to the unbound lookup code and remove
the gross code in net_node.inl that creates one thread per address.
(And worse, tries to use boost thread interruption which cannot work at
all since any such interruption is voluntary and won't do anything to a
thread that is stalled waiting for a synchronous libunbound lookup).

The replacement has unbound create and manage a single thread for async
lookups then waits up to the given timeout for results.

Currently this code isn't actually used because our seed node DNS list
is empty, but this lets us eliminate a boost::thread dependency while
not removing the feature (also includes a test case).
2020-07-02 12:52:13 -03:00
Doyle abb8dfc48e Merge commit 'c4f75fe' into MergeUpstream3 2020-05-28 15:29:00 +10:00
Doyle d703d14d56 Merge commit 'c038cc8b791ffb4bcd5f13e47de1ea98815059fe' into MergeUpstream3 2020-05-28 12:23:19 +10:00
Doyle dbdc5556e8 Merge commit '8bb3c6a8e6861925e59240acb311811f0792f3eb' into MergeUpstream3 2020-05-25 11:27:25 +10:00
Doyle 6b9c9de85f Merge commit '44aa7d543941c0e79e59046591d7ca0cd3b4383a' into MergeUpstream3 2020-05-22 11:36:34 +10:00
Doyle 56645e98a0 Manual merge "v12" consensus changes github.com/monero-project/monero/pull/5823
Manual merge because Loki already applied some of the changes regarding
 - Locking in the mixin (we enforced this at the beginning of the chain)
 - Enforcing miner TX version (enforced in HF12, we're now at HF15).

Lastly we manually merge restricting miner transactions from having
a RCT Signature, to be effective as of HF16.
2020-05-21 14:54:01 +10:00
Doyle 34ca917511 Merge commit '98af2e954b78dc7607d0236a9db84b2143a33a90' into MergeUpstream3 2020-05-19 11:04:48 +10:00
Doyle 184183f309 Merge branch 'dev' into MergeUpstream2 2020-05-18 12:58:59 +10:00
Doyle f1f37fd8fc Revert "Bans for RPC connections"
This reverts commit a182df21d0.
2020-05-18 12:06:11 +10:00
Jason Rhinelander 0e3f173c7f RPC overhaul
High-level details:

This redesigns the RPC layer to make it much easier to work with,
decouples it from an embedded HTTP server, and gets the vast majority of
the RPC serialization and dispatch code out of a very commonly included
header.

There is unfortunately rather a lot of interconnected code here that
cannot be easily separated out into separate commits.  The full details
of what happens here are as follows:

Major details:
- All of the RPC code is now in a `cryptonote::rpc` namespace; this
  renames quite a bit to be less verbose: e.g. CORE_RPC_STATUS_OK
  becomes `rpc::STATUS_OK`, and `cryptonote::COMMAND_RPC_SOME_LONG_NAME`
  becomes `rpc::SOME_LONG_NAME` (or just SOME_LONG_NAME for code already
  working in the `rpc` namespace).
- `core_rpc_server` is now completely decoupled from providing any
  request protocol: it is now *just* the core RPC call handler.
- The HTTP RPC interface now lives in a new rpc/http_server.h; this code
  handles listening for HTTP requests and dispatching them to
  core_rpc_server, then sending the results back to the caller.
- There is similarly a rpc/lmq_server.h for LMQ RPC code; more details
  on this (and other LMQ specifics) below.
- RPC implementing code now returns the response object and throws when
  things go wrong which simplifies much of the rpc error handling.  They
  can throw anything; generic exceptions get logged and a generic
  "internal error" message gets returned to the caller, but there is
  also an `rpc_error` class to return an error code and message used by
  some json-rpc commands.
- RPC implementing functions now overload `core_rpc_server::invoke`
  following the pattern:

    RPC_BLAH_BLAH::response core_rpc_server::invoke(RPC_BLAH_BLAH::request&& req, rpc_context context);

  This overloading makes the code vastly simpler: all instantiations are
  now done with a small amount of generic instantiation code in a single
  .cpp rather than needing to go to hell and back with a nest of epee
  macros in a core header.
- each RPC endpoint is now defined by the RPC types themselves,
  including its accessible names and permissions, in
  core_rpc_server_commands_defs.h:
  - every RPC structure now has a static `names()` function that returns
    the names by which the end point is accessible.  (The first one is
    the primary, the others are for deprecated aliases).
  - RPC command wrappers define their permissions and type by inheriting
    from special tag classes:
    - rpc::RPC_COMMAND is a basic, admin-only, JSON command, available
      via JSON RPC.  *All* JSON commands are now available via JSON RPC,
      instead of the previous mix of some being at /foo and others at
      /json_rpc.  (Ones that were previously at /foo are still there for
      backwards compatibility; see `rpc::LEGACY` below).
    - rpc::PUBLIC specifies that the command should be available via a
      restricted RPC connection.
    - rpc::BINARY specifies that the command is not JSON, but rather is
      accessible as /name and takes and returns values in the magic epee
      binary "portable storage" (lol) data format.
    - rpc::LEGACY specifies that the command should be available via the
      non-json-rpc interface at `/name` for backwards compatibility (in
      addition to the JSON-RPC interface).
- some epee serialization got unwrapped and de-templatized so that it
  can be moved into a .cpp file with just declarations in the .h.  (This
  makes a *huge* difference for core_rpc_server_commands_defs.h and for
  every compilation unit that includes it which previously had to
  compile all the serialization code and then throw all by one copy away
  at link time).  This required some new macros so as to not break a ton
  of places that will use the old way putting everything in the headers;
  The RPC code uses this as does a few other places; there are comments
  in contrib/epee/include/serialization/keyvalue_serialization.h as to
  how to use it.
- Detemplatized a bunch of epee/storages code.  Most of it should have
  have been using templates at all (because it can only ever be called
  with one type!), and now it isn't.  This broke some things that didn't
  properly compile because of missing headers or (in one case) a messed
  up circular dependency.
- Significantly simplified a bunch of over-templatized serialization
  code.
- All RPC serialization definitions is now out of
  core_rpc_server_commands_defs.h and into a single .cpp file
  (core_rpc_server_commands_defs.cpp).
- core RPC no longer uses the disgusting
  BEGIN_URI_MAP2/MAP_URI_BLAH_BLAH macros.  This was a terrible design
  that forced slamming tons of code into a common header that didn't
  need to be there.
- epee::struct_init is gone.  It was a horrible hack that instiated
  multiple templates just so the coder could be so lazy and write
  `some_type var;` instead of properly value initializing with
  `some_type var{};`.
- Removed a bunch of useless crap from epee.  In particular, forcing
  extra template instantiations all over the place in order to nest
  return objects inside JSON RPC values is no longer needed, as are a
  bunch of stuff related to the above de-macroization of the code.
- get_all_service_nodes, get_service_nodes, and get_n_service_nodes are
  now combined into a single `get_service_nodes` (with deprecated
  aliases for the others), which eliminates a fair amount of
  duplication.  The biggest obstacle here was getting the requested
  fields reference passed through: this is now done by a new ability to
  stash a context in the serialization object that can be retrieved by a
  sub-serialized type.

LMQ-specifics:

- The LokiMQ instance moves into `cryptonote::core` rather than being
  inside cryptonote_protocol.  Currently the instance is used both for
  qnet and rpc calls (and so needs to be in a common place), but I also
  intend future PRs to use the batching code for job processing
  (replacing the current threaded job queue).
- rpc/lmq_server.h handles the actual LMQ-request-to-core-RPC glue.
  Unlike http_server it isn't technically running the whole LMQ stack
  from here, but the parallel name with http_server seemed appropriate.
- All RPC endpoints are supported by LMQ under the same names as defined
  generically, but prefixed with `rpc.` for public commands and `admin.`
  for restricted ones.
- service node keys are now always available, even when not running in
  `--service-node` mode: this is because we want the x25519 key for
  being able to offer CURVE encryption for lmq RPC end-points, and
  because it doesn't hurt to have them available all the time.  In the
  RPC layer this is now called "get_service_keys" (with
  "get_service_node_key" as an alias) since they aren't strictly only
  for service nodes.  This also means code needs to check
  m_service_node, and not m_service_node_keys, to tell if it is running
  as a service node.  (This is also easier to notice because
  m_service_node_keys got renamed to `m_service_keys`).
- Added block and mempool monitoring LMQ RPC endpoints: `sub.block` and
  `sub.mempool` subscribes the connection for new block and new mempool
  TX notifications.  The latter can notify on just blink txes, or all
  new mempool txes (but only new ones -- txes dumped from a block don't
  trigger it).  The client gets pushed a [`notify.block`, `height`,
  `hash`] or [`notify.tx`, `txhash`, `blob`] message when something
  arrives.

Minor details:
- rpc::version_t is now a {major,minor} pair.  Forcing everyone to pack
  and unpack a uint32_t was gross.
- Changed some macros to constexprs (e.g. CORE_RPC_ERROR_CODE_...).
  (This immediately revealed a couple of bugs in the RPC code that was
  assigning CORE_RPC_ERROR_CODE_... to a string, and it worked because
  the macro allows implicit conversion to a char).
- De-templatizing useless templates in epee (i.e. a bunch of templated
  types that were never invoked with different types) revealed a painful
  circular dependency between epee and non-epee code for tor_address and
  i2p_address.  This crap is now handled in a suitably named
  `net/epee_network_address_hack.cpp` hack because it really isn't
  trivial to extricate this mess.
- Removed `epee/include/serialization/serialize_base.h`.  Amazingly the
  code somehow still all works perfectly with this previously vital
  header removed.
- Removed bitrotted, unused epee "crypted_storage" and
  "gzipped_inmemstorage" code.
- Replaced a bunch of epee::misc_utils::auto_scope_leave_caller with
  LOKI_DEFERs.  The epee version involves quite a bit more instantiation
  and is ugly as sin.  Also made the `loki::defer` class invokable for
  some edge cases that need calling before destruction in particular
  conditions.
- Moved the systemd code around; it makes much more sense to do the
  systemd started notification as in daemon.cpp as late as possible
  rather than in core (when we can still have startup failures, e.g. if
  the RPC layer can't start).
- Made the systemd short status string available in the get_info RPC
  (and no longer require building with systemd).
- during startup, print (only) the x25519 when not in SN mode, and
  continue to print all three when in SN mode.
- DRYed out some RPC implementation code (such as set_limit)
- Made wallet_rpc stop using a raw m_wallet pointer
2020-05-11 18:44:45 -03:00
Doyle ca9ce15103 Merge commit 'c5e9266' into MergeUpstream2 2020-04-20 17:07:14 +10:00
Doyle 9fcd1f9300 Merge commit 'df83ed74e487d6f828164bb9652681801abb439e' into MergeUpstream2 2020-04-20 16:28:18 +10:00
Sarang Noether 80d5320fff Hash domain separation 2020-04-01 08:31:00 -04:00
Aaron Hook aa93e38862 p2p: remove old debug commands 2020-03-20 22:09:44 -07:00
Jason Rhinelander b73c6f1585 Change block reward for HF15 & 16 as per LRC-6
This changes the formula for HF15 to 66% service nodes, 24% miner, 10%
foundation, and changes the block reward from the current 28 and a bit
to a fixed 25 LOKI per block.  SN reward and LF reward both increase,
miner reward gets cut substantially.  This change is reflecting that
with checkpoints and blink the security provided by miners is
substantially reduced.

In HF16 (with pulse) we plan to become mining-free, with final rewards
also included here for that fork of 21 LOKI per block with 90% to SNs
and 10% to foundation.  (This is tentative assuming pulse is implemented
in HF16).
2020-03-10 16:40:21 -03: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
Jason Rhinelander 0b0e909d8f Lower blink fees, remove higher priorities and backlog checking
This reduces blink fees by half (from 5x to 2.5x base fee) at HF15, and
makes anything other than "unimportant" priority map to blink for
ordinary transactions.

For non-blink txes priorities are still accepted (so that, if the
mempool is clogged, you can still get a registration or stake through by
upping the priority).

It also updates the wallets default priority for transactions to blink
(that is, "default" now becomes blink).

With the priorities gone and default set to blink, the backlog-checking
code and automatic priority bumping code don't serve any useful purpose,
so this rips them out, along with a few other related code
simplifications.
2020-02-19 12:52:28 -04:00
Jason Rhinelander 94bb266d75 Simplify static_asserts
Divisible by 2, 3 and 4 is the same as divisible by 12.
2020-02-19 12:52:28 -04:00
Doyle 632f6a6e83 Rebase fix, blink_lns -> blink, v15 and reserve types for protocol 2020-02-13 11:07:46 +11:00
Doyle 1eb45e523e Build/core test fixes, incoporate staking changes from LNS
- Fix assert to use version_t::_count in service_node_list.cpp
- Incoporate staking changes from LNS which revamp construct tx to
  derive more of the parameters from hf_version and type. This removes
  extraneous parameters that can be derived elsewhere.

  Also delegate setting loki_construct_tx_params into wallet2 atleast,
  so that callers into the wallet logic, like rpc server, simplewallet
  don't need bend backwards to get the HF version whereas the wallet has
  dedicated functions for determining the HF.
2019-12-04 15:17:55 +11:00
Jason Rhinelander 9b624e6853 Properly support fee burning in the wallet
This revamps the `loki_construct_tx_params` a bit to be able to carry
fixed and %-based burn amounts (in addition to the staking tx flag) and
modifies it to set the hf version from within wallet2 rather than at
construction.

This is then used to implement proper fee burning in the wallet
(replacing the uncommitted hack I was using up until now to test it) by
changing wallet2 to understand the burn amount: initially it adds a
placeholder amount so that an appropriate amount of space in tx extra is
taken up, then once the transaction has been built and final fees
calculated it replaces the placeholder with the final burn amount before
tx finalization.
2019-11-27 14:38:00 -04:00
Jason Rhinelander c1d2c00c98 Fix constant name in comment 2019-11-27 14:23:56 -04:00
Jason Rhinelander 6a886b69ea Generic burn fee checking + blink burn fee checking
This adds the ability for check_fee() to also check the burn amount.
This requires passing extra info through `add_tx()` (and the various
things that call it), so I took the:

    bool keeped_by_block, bool relayed, bool do_not_relay

argument triplet, moved it into a struct in tx_pool.h, then added the other fee
options there (along with some static factory functions for generating the
typical sets of option).

The majority of this commit is chasing that change through the codebase and
test suite.

This is used by blink but should also help LNS and other future burn
transactions to verify a burn amount simply when adding the transation to the
mempool.  It supports a fixed burn amount, a burn amount as a multiple of the
minimum tx fee, and also allows you to increase the minimum tx fee (so that,
for example, we could require blink txes to pay miners 250% of the usual
minimum (unimportant) priority tx fee.

- Removed a useless core::add_new_tx() overload that wasn't used anywhere.

Blink-specific changes:

(I'd normally separate these into a separate commit, but they got interwoven
fairly heavily with the above change).

- changed the way blink burning is specified so that we have three knobs for
fee adjustment (fixed burn fee; base fee multiple; and required miner tx fee).
The fixed amount is currently 0, base fee is 400%, and require miner tx fee is
simply 100% (i.e. no different than a normal transaction).  This is the same as
before this commit, but is changing how they are being specified in
cryptonote_config.h.

- blink tx fee, burn amount, and miner tx fee (if > 100%) now get checked
before signing a blink tx.  (These fee checks don't apply to anyone else --
when propagating over the network only the miner tx fee is checked).

- Added a couple of checks for blink quorums: 1) make sure they have reached
the blink hf; 2) make sure the submitted tx version conforms to the current hf
min/max tx version.

- print blink fee information in simplewallet's `fee` output

- add "typical" fee calculations in the `fee` output:

    [wallet T6SCwL (has locked stakes)]: fee
    Current fee is 0.000000850 loki per byte + 0.020000000 loki per output
    No backlog at priority 1
    No backlog at priority 2
    No backlog at priority 3
    No backlog at priority 4
    Current blink fee is 0.000004250 loki per byte + 0.100000000 loki per output
    Estimated typical small transaction fees: 0.042125000 (unimportant), 0.210625000 (normal), 1.053125000 (elevated), 5.265625000 (priority), 0.210625000 (blink)

where "small" here is the same tx size (2500 bytes + 2 outputs) used to
estimate backlogs.
2019-11-27 14:23:56 -04:00
Jason Rhinelander eb1d7b5288 Add fee burning
This adds a tx extra field that specifies an amount of the tx fee that
must be burned; the miner can claim only (txnFee - burnFee) when
including the block.

This will be used for the extra, burned part of blink fees and LNS fees
and any other transaction that requires fee burning in the future.
2019-11-27 14:07:52 -04:00
Jason Rhinelander dd7a4104b5 Blink
This is the bulk of the work for blink.  There is two pieces yet to come
which will follow shortly, which are: the p2p communication of blink
transactions (which needs to be fully synchronized, not just shared,
unlike regular mempool txes); and an implementation of fee burning.

Blink approval, multi-quorum signing, cli wallet and node support for
submission denial are all implemented here.

This overhauls and fixes various parts of the SNNetwork interface to fix
some issues (particularly around non-SN communication with SNs, which
wasn't working).

There are also a few sundry FIXME's and TODO's of other minor details
that will follow shortly under cleanup/testing/etc.
2019-11-27 14:07:52 -04:00
Jason Rhinelander dd230491db Uptime proof timer tweak + debug option
This tweaks uptime proofs to go out on the first timer tick in the
58.5-62.5 interval (rather than 60-65) which should result in proofs
usually being very close to the 60 minute mark.  (Currently a fair
percentage end up at the 65m mark because the timer fires just before
the 60m mark).

It also tweaks the first uptime proof to go out after 2 minutes instead
of 5 minutes, and uses separate constants
(UPTIME_PROOF_INITIAL_DELAY_SECONDS, UPTIME_PROOF_TIMER_SECONDS) for
times that were previously overloading the
UPTIME_PROOF_BUFFER_IN_SECONDS constant.

For debugging this also adds a cmake option LOKI_DEBUG_SHORT_PROOFS
that, when enabled, makes the whole proof cycle (sending and acceptance)
20x faster, which is very useful for local testnet debugging.
2019-11-27 14:07:52 -04:00
Jason Rhinelander 57e64b7d1c Add quorumnet comms
This adds vote relaying via quorumnet.

- The main glue between existing code and quorumnet code is in
  cryptonote_protocol/quorumnet.{h,cpp}
- Uses function pointers assigned at initialization to call into the
  glue without making cn_core depend on p2p
- Adds ed25519 and quorumnet port to uptime proofs and serialization.
- Added a second uptime proof signature using the ed25519 key to that
  SNs are proving they actually have it (otherwise they could spoof
  someone else's pubkey).
- Adds quorumnet port, defaulting to zmq rpc port + 1.  quorumnet
  listens on the p2p IPv4 address (but broadcasts the `public_ip` to the
  network).
- Derives x25519 when received or deserialized.
- Converted service_info_info::version_t into a scoped enum (with the
  same underlying type).
- Added contribution_t::version_t scoped enum.  It was using
  service_info_info::version for a 0 value which seemed rather wrong.

Random small details:
- Renamed internal `arg_sn_bind_port` for consistency
- Moved default stagenet ports from 38153-38155 to 38056-38058, and add the default stagenet
  quorumnet port at 38059 (this keeps the range contiguous; otherwise the next stagenet default port
  would collide with the testnet p2p port).
2019-11-27 14:07:45 -04:00
Jason Rhinelander b64097a47e Add lokinet ping rpc endpoint
This abstracts much of the storage server ping code to work for both
storage server and lokinet.
2019-11-26 18:49:37 -04:00
Lee Clagett 70c9cd3c9c Change to Tx diffusion (Dandelion++ fluff) instead of flooding 2019-11-04 09:23:20 +00:00
Jason Rhinelander 1e496975b3 Add fee burning
This adds a tx extra field that specifies an amount of the tx fee that
must be burned; the miner can claim only (txnFee - burnFee) when
including the block.

This will be used for the extra, burned part of blink fees and LNS fees
and any other transaction that requires fee burning in the future.
2019-10-30 18:47:22 -03:00
moneromooo-monero 2899379791
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.

This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo

This has some advantages:
 - incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
 - incentive to run your own node instead of using a third party's, thereby promoting decentralization
 - decentralized: payment is done between a client and server, with no third party needed
 - private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
 - no payment occurs on the blockchain, so there is no extra transactional load
 - one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
 - no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
 - Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
 - no large credit balance maintained on servers, so they have no incentive to exit scam
 - you can use any/many node(s), since there's little cost in switching servers
 - market based prices: competition between servers to lower costs
 - incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
 - increases network security
 - helps counteract mining pools' share of the network hash rate
 - zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner

And some disadvantages:
 - low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
 - payment is "random", so a server might go a long time without a block before getting one
 - a public node's overall expected payment may be small

Public nodes are expected to compete to find a suitable level for
cost of service.

The daemon can be set up this way to require payment for RPC services:

  monerod --rpc-payment-address 4xxxxxx \
    --rpc-payment-credits 250 --rpc-payment-difficulty 1000

These values are an example only.

The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.

The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).

There are three new settings in the wallet:

 - credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.

 - auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25

 - persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.

To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.

The wallet has a few new commands too:

 - start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
 - stop_mining_for_rpc: stop mining to acquire more credits
 - rpc_payments: display information about current credits with
the currently selected daemon

The node has an extra command:

 - rpc_payments: display information about clients and their
balances

The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2019-10-25 09:34:38 +00:00
moneromooo-monero ab96181e91
blockchain: use effective median block weight for penalty from v12
It was using the raw block weight median, which was not what was
intended in ArticMine's design
2019-10-11 14:16:09 +00:00
luigi1111 bf525793c7
Merge pull request #5915
8330e77 monerod can now sync from pruned blocks (moneromooo-monero)
2019-10-08 15:55:03 -05:00
Jason Rhinelander c00e8221cc Add SN ed25519/x25519 pubkeys + quorumnet port in proofs
This generates a ed25519 keypair (and from it derives a x25519 keypair)
and broadcasts the ed25519 pubkey in HF13 uptime proofs.

This auxiliary key will be used both inside lokid (starting in HF14) in
places like the upcoming quorumnet code where we need a standard
pub/priv keypair that is usable in external tools (e.g. sodium) without
having to reimplement the incompatible (though still 25519-based) Monero
pubkey format.

This pulls it back into HF13 from the quorumnet code because the
generation code is ready now, and because there may be opportunities to
use this outside of lokid (e.g. in the storage server and in lokinet)
before HF14.  Broadcasting it earlier also allows us to be ready to go
as soon as HF14 hits rather than having to wait for every node to have
sent a post-HF14 block uptime proof.

For a similar reason this adds a placeholder for the quorumnet port in
the uptime proof: currently the value is just set to 0 and ignored, but
allowing it to be passed will allow upgraded loki 6.x nodes to start
sending it to each other without having to wait for the fork height so
that they can start using it immediately when HF14 begins.
2019-10-07 22:09:17 -03:00
moneromooo-monero 8330e772f1
monerod can now sync from pruned blocks
If the peer (whether pruned or not itself) supports sending pruned blocks
to syncing nodes, the pruned version will be sent along with the hash
of the pruned data and the block weight. The original tx hashes can be
reconstructed from the pruned txes and theur prunable data hash. Those
hashes and the block weights are hashes and checked against the set of
precompiled hashes, ensuring the data we received is the original data.
It is currently not possible to use this system when not using the set
of precompiled hashes, since block weights can not otherwise be checked
for validity.

This is off by default for now, and is enabled by --sync-pruned-blocks
2019-09-27 00:10:37 +00:00
Howard Chu 81c2ad6d5b
RandomX integration
Support RandomX PoW algorithm
2019-09-25 21:29:42 +01:00
moneromooo-monero a444f06e53
blockchain: enforce 10 block age for spending outputs
Some custom wallet code apparently ignores this, which causes users
of that code to be fingerprinted
2019-09-17 11:39:25 +00:00
luigi1111 29e0f11305
Merge pull request #5823
26072f1 blockchain: forbid v1 coinbase from v12 (moneromooo-monero)
555dc7c core: from v12, require consistent ring size for mixable txes (moneromooo-monero)
d22dfb7 blockchain: reject rct signatures in coinbase txes from v12 (moneromooo-monero)
2019-09-14 13:04:41 -05:00
Doyle 39987729ab
Update soft-forking checks to be effective HF13 (#825)
Code review

m_oldest_allowable_alternative_block -> m_immutable_height
2019-09-10 10:04:44 +10:00
Jason Rhinelander 0350ccfc9a Switch to per-byte + per-output fees, reduce max multiplier
This switches loki 5.x to use a fee formula of

    SIZE * PER_BYTE + OUTPUTS * PER_OUTPUT

where we reduce the PER_BYTE fee back to what it was in 3.x; and with
the PER_OUTPUT fee set to 0.02 LOKI.  This compares to the 4.x fee of:

    SIZE * PER_BYTE * 80

(the *80 multiple was introduced in 4.x).

It also reduces the multiplier for the maximum priority level to 125
instead of 1000 because 1000 produced uselessly high tx fees.  The new
multipliers go up 5x at each level: {1, 5, 25, 125} while previously
they went {1, 5, 25, 1000}.

As for the base change: we added the *80 multiplier in 4.x because we
wanted to make a theoretical de-anonymizing tx spam attack more costly.
The unanticipated consequence was that we also made *large* transactions
(such as sweeps) considerably more costly despite the fact that these
transactions typically only create 2 outputs.

This better captures what we meant to do in 4.x (making output creation
relatively more expensive) without making large txes (e.g. sweeps
required for staking) highly expensive.

The end effect is that the fee for a minimum-sized, 1-input/2-output
transaction should stay roughly the same (slightly over 0.04 LOKI),
while a 100-input/2-output transction (a typical spend or sweep from a
wallet with lots of smaller rewards) will drop in fee by somewhere
around 95%.

The most efficient theoretical deanonymizing tx spamming of this sort
was a 1-input/16-output transaction which will become about 2.5x as
expensive as currently the case in v4.x.
2019-08-26 17:42:30 -03:00
Jason Rhinelander d5f234477e Removed unused/always-obsolete macros
This removes a bunch of macros from cryptonote_config.h that either
aren't used at all, or have never applied to Loki, along with
removing/simplifying some of the dead code touching these macros.

A few of these are still used only in the test suite, so I moved them
there instead.

One of these sounds sort of scary -- ALLOW_DEBUG_COMMANDS -- but this
has *always* been forcibly enabled with no way to disable it going back
to the very first monero git commit.

DYNAMIC_FEE_PER_KB_BASE_FEE_V5 was defined in a very strange way that
doesn't make a lot of sense (including using a constant that is not
otherwise applied in loki), so I just replaced it with the expanded
value.
2019-08-22 21:42:10 -03:00
moneromooo-monero d22dfb7594
blockchain: reject rct signatures in coinbase txes from v12 2019-08-19 16:43:53 +00:00
moneromooo-monero 555dc7c394
core: from v12, require consistent ring size for mixable txes
We're supposed to have a fixed ring size now

Already checked by MLSAG verification, but here seems more intuitive
2019-08-19 16:43:53 +00:00
moneromooo-monero 26072f1393
blockchain: forbid v1 coinbase from v12 2019-08-19 16:43:52 +00:00
luigi1111 df064eaa36
Merge pull request #5649
a182df2 Bans for RPC connections (hyc)
2019-08-15 17:10:49 -05:00
Jason Rhinelander 5543cb9bd7 Limit default p2p in-peers to 32
epee's p2p connection code is garbage and scales terribly with more
peers; work around it by setting a default cap of 32 incoming peers.
2019-08-13 02:45:56 -03:00
Doyle a0c327bcdf
Handle multi state changes in the pool (#781)
* Update state transition check to account for height and universally set timestamp on recommission

Reject invalidated state changes by their height after HF13

* Prune invalidated state changes on blockchain increment

Simplify check_tx_inputs for state_changes by using service node list

Instead of querying the last 60 historical blocks for every transaction,
use the service node list and determine the state of the service node
and if it can transition to its new state.

We also now enforce at hardfork 13, that the network cannot commit
transactions to the network if they would have been invalidated by
a newer state change that already is already on the blockchain.

This is backwards compatible all the way back to hardfork 9.

Greatly simplify state change tx pruning on block added

Use the new stricter rules for pruning state changes in the txpool

We can do so because pruning the TX pool won't cause issues at the
protocol level, but the more people we can upgrade the better network
behaviour we get in terms of propagating more intrinsically correct
ordering of state changes to other peers.

* Don't generate state changes if not valid, disallow voting if node is non-votable
2019-08-12 09:48:47 +10:00
Lee Clagett 3b24b1d082 Added support for "noise" over I1P/Tor to mask Tx transmission. 2019-07-17 14:22:37 +00:00
Doyle 8dca820ed7
Service node checkpointing soft fork for mainnet (#719)
* Add soft forking for checkpointing on mainnet

* Clear checkpoints on softfork on mainnet

* Move softfork date until we're ready, fix test results and modulo addition

* Only round up delete_height if it's not a multiple of CHECKPOINT_INTERVAL

* Remove unused variable soft fork in service_node_rules (replaced by cryptonote_config)
2019-07-11 16:16:16 +10:00
Doyle 823627a5ad
Improve print quorum state + rpc update (#709)
* print_quorum_state displays checkpointing quorums, remove batched call

* Update the help text for quorum commands

* <= for the max_quorum_type not <

* Handle heights greater than the latest

* Don't repeatedly add partially filled quorums

* Revert get_quorum_state to take a range (common case)

* Update the help text from print_quorum_state
2019-07-09 13:02:10 +10:00
Doyle d0fb04db46
Improved print_checkpoints + json_rpc get_checkpoints call (#708)
* Improved print_checkpoints

* Flesh out print checkpoints and associated RPC call

* Remove debug print checkpoints

* Update help text for print_checkpoints

* Rewrite to fix num_checkpoints != heights as a unit of measurement

* Use GET_ALL_CHECKPOINTS defined value in get_checkpoints_range

* Let T be deduced in parse_if_present, json_rpc_request not rpc_request
2019-07-05 09:34:51 +10:00
Doyle e6b5ef558a
Service node checkpointing deregistration (#672)
* Add deregistration of checkpoints by checking how many votes are missed

Move uptime proofs and add checkpoint counts in the service_node_list
because we typically prune uptime proofs by time, but it seems we want
to switch to a model where we persist proof data until the node expires
otherwise currently we would prune uptime entries and potentially our
checkpoint vote counts which would cause premature deregistration as the
expected vote counts start mismatching with the number of received
votes.

* Revise deregistration

* Fix test breakages

* uint16_t for port, remove debug false, min votes to 2 in integration mode

* Fix integration build
2019-06-27 17:05:44 +10:00
Jason Rhinelander 94b5857a84 Merge remote-tracking branch 'LMDB/randomx' into randomx 2019-06-26 21:50:51 -03:00
Jason Rhinelander 36b06c52e7 Increase fee by 80x at Heimdall fork (#663)
* Increase fee by 80x at Heimdall fork

Loki's current fees are far too cheap, which makes a potential
deanonymization attack (whereby someone floods the network with
transactions that they later use to identify decoys) very cheap.

This commit increases the tx fee by 80x.  Transactions will still be
cheap (a typical tx will go from around 0.00052 LOKI to 0.04 LOKI, which
is around half a US cent at the time of this commit.

This also provides a better estimate for the FEE_PER_BYTE value (both
before and after the fork), which was using a wrong estimate from Monero
(which has 3 extra decimal places!)

Finally this commit removes some related constants from
cryptonode_config.h that have never applied to Loki.

* Remove Loki-impossible values from wallet code
2019-06-25 19:22:43 +10:00
Howard Chu a182df21d0
Bans for RPC connections
Make bans control RPC sessions too. And auto-ban some bad requests.
Drops HTTP connections whenever response code is 500.
2019-06-16 11:38:08 +01:00
Maxim Shishmarev e53922faa8 Require storage server running for uptime proofs (v.2) (#631)
* Require storage server running for uptime proofs (v.2)

* use atomic time_t; reset ping on startup
2019-06-07 17:03:11 +10:00
Doyle cdde63b6ce
Remove non-fluffy blockchain syncing path (#618)
Obsolete since forever, fluffy blocks is by default- it's more space
efficient when syncing the blockchain.
2019-06-04 12:28:56 +10:00
Howard Chu cfe0e9c7c5
RandomX integration
Support RandomX PoW algorithm
2019-06-01 21:40:55 +01:00
Doyle cc0d51078c Merge dev into upstream 2019-05-01 16:01:17 +10:00
moneromooo-monero df83ed74e4
consensus: from v12, enforce >= 2 outputs 2019-04-23 22:09:35 +00:00
Doyle 4778d862c9 Merge commit 'bd42903' into LokiMergeUpstream 2019-04-12 18:37:56 +10:00
Doyle 2fe5ddb2ca Merge commit 'f2f725d8db3535055d1c7e102c0bba75b22a3409' into LokiMergeUpstream 2019-04-12 15:23:01 +10:00
Doyle 892469ded1 Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
Doyle 4f0a729533 Merge commit '4466f4504e8bc41d353a6becce0526df8272bc1d' into LokiMergeUpstream 2019-04-10 09:59:38 +10:00
Doyle 47566c63df Merge commit '973403bc9f54ab0722b67a3c76ab6e7bafbfeedc' 2019-04-09 18:07:13 +10:00
moneromooo-monero 089c7637a6
cryptonote: rework block blob size sanity check
Use the actual block weight limit, assuming that weight is always
greater or equal to size
2019-04-05 09:35:19 +00:00
Doyle 18fe96a054
Fix print_sn displaying all nodes to be staking infinitely (#521)
* Fix print_sn displaying all nodes to be staking infinitely

* Use define for key image unlock height and std array

* Remove unused code
2019-03-27 20:13:22 +11:00
Riccardo Spagni acc7211b5b
Merge pull request #5199
eef164f7 cryptonote_protocol_handler: search for syncing peers in "cruise mode" (moneromooo-monero)
2019-03-19 10:58:38 +02:00
binaryFate 1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
Doyle cc648f4e04 Update governance address for HF11 2019-03-05 13:32:55 +11:00
Riccardo Spagni 4466f4504e
Merge pull request #5091
123fc2a2 i2p: initial support (Jethro Grassie)
2019-03-04 21:20:34 +02:00
moneromooo-monero b8787f4302
ArticMine's new block weight algorithm
This curbs runaway growth while still allowing substantial
spikes in block weight

Original specification from ArticMine:

here is the scaling proposal
Define: LongTermBlockWeight
Before fork:
LongTermBlockWeight = BlockWeight
At or after fork:
LongTermBlockWeight = min(BlockWeight, 1.4*LongTermEffectiveMedianBlockWeight)
Note: To avoid possible consensus issues over rounding the LongTermBlockWeight for a given block should be calculated to the nearest byte, and stored as a integer in the block itself. The stored LongTermBlockWeight is then used for future calculations of the LongTermEffectiveMedianBlockWeight and not recalculated each time.
Define:   LongTermEffectiveMedianBlockWeight
LongTermEffectiveMedianBlockWeight = max(300000, MedianOverPrevious100000Blocks(LongTermBlockWeight))
Change Definition of EffectiveMedianBlockWeight
From (current definition)
EffectiveMedianBlockWeight  = max(300000, MedianOverPrevious100Blocks(BlockWeight))
To (proposed definition)
EffectiveMedianBlockWeight  = min(max(300000, MedianOverPrevious100Blocks(BlockWeight)), 50*LongTermEffectiveMedianBlockWeight)
Notes:
1) There are no other changes to the existing penalty formula, median calculation, fees etc.
2) There is the requirement to store the LongTermBlockWeight of a block unencrypted in the block itself. This  is to avoid possible consensus issues over rounding and also to prevent the calculations from becoming unwieldy as we move away from the fork.
3) When the  EffectiveMedianBlockWeight cap is reached it is still possible to mine blocks up to 2x the EffectiveMedianBlockWeight by paying the corresponding penalty.

Note: the long term block weight is stored in the database, but not in the actual block itself,
since it requires recalculating anyway for verification.
2019-03-04 09:33:58 +00:00
moneromooo-monero eef164f7cc
cryptonote_protocol_handler: search for syncing peers in "cruise mode"
When all our outgoing peer slots are filled, we cycle one peer at
a time looking for syncing peers until we have at least two such
peers. This brings two advantages:

- Peers without incoming connections will find more syncing peers
that before, thereby strengthening network decentralization

- Peers will have more resistance to isolation attacks, as they
are more likely to find a "good" peer than they were before
2019-02-26 12:45:28 +00:00
Doyle bc47ecf05b Update version naming for infinite staking 2019-02-25 18:05:20 +11:00
moneromooo-monero 6cc35100f9 ArticMine's new block weight algorithm
This curbs runaway growth while still allowing substantial
spikes in block weight

Original specification from ArticMine:

here is the scaling proposal
Define: LongTermBlockWeight
Before fork:
LongTermBlockWeight = BlockWeight
At or after fork:
LongTermBlockWeight = min(BlockWeight, 1.4*LongTermEffectiveMedianBlockWeight)
Note: To avoid possible consensus issues over rounding the LongTermBlockWeight for a given block should be calculated to the nearest byte, and stored as a integer in the block itself. The stored LongTermBlockWeight is then used for future calculations of the LongTermEffectiveMedianBlockWeight and not recalculated each time.
Define:   LongTermEffectiveMedianBlockWeight
LongTermEffectiveMedianBlockWeight = max(300000, MedianOverPrevious100000Blocks(LongTermBlockWeight))
Change Definition of EffectiveMedianBlockWeight
From (current definition)
EffectiveMedianBlockWeight  = max(300000, MedianOverPrevious100Blocks(BlockWeight))
To (proposed definition)
EffectiveMedianBlockWeight  = min(max(300000, MedianOverPrevious100Blocks(BlockWeight)), 50*LongTermEffectiveMedianBlockWeight)
Notes:
1) There are no other changes to the existing penalty formula, median calculation, fees etc.
2) There is the requirement to store the LongTermBlockWeight of a block unencrypted in the block itself. This  is to avoid possible consensus issues over rounding and also to prevent the calculations from becoming unwieldy as we move away from the fork.
3) When the  EffectiveMedianBlockWeight cap is reached it is still possible to mine blocks up to 2x the EffectiveMedianBlockWeight by paying the corresponding penalty.
2019-02-20 18:57:58 +11:00
Doyle 43436b081d
Infinite Staking Part 2 (#406)
* Cleanup and undoing some protocol breakages

* Simplify expiration of nodes

* Request unlock schedules entire node for expiration

* Fix off by one in expiring nodes

* Undo expiring code for pre v10 nodes

* Fix RPC returning register as unlock height and not checking 0

* Rename key image unlock height const

* Undo testnet hardfork debug changes

* Remove is_type for get_type, fix missing var rename

* Move serialisable data into public namespace

* Serialise tx types properly

* Fix typo in no service node known msg

* Code review

* Fix == to >= on serialising tx type

* Code review 2

* Fix tests and key image unlock

* Add command to print locked key images

* Update ui to display lock stakes, query in print cmd blacklist

* Modify print stakes to be less slow

* Remove autostaking code

* Refactor staking into sweep functions

It appears staking was derived off stake_main written separately at
implementation at the beginning. This merges them back into a common
code path, after removing autostake there's only some minor differences.

It also makes sure that any changes to sweeping upstream are going to be
considered in the staking process which we want.

* Display unlock height for stakes

* Begin creating output blacklist

* Make blacklist output a migration step

* Implement get_output_blacklist for lmdb

* In wallet output selection ignore blacklisted outputs

* Apply blacklisted outputs to output selection

* Fix broken tests, switch key image unlock

* Fix broken unit_tests

* Begin change to limit locked key images to 4 globally

* Revamp prepare registration for new min contribution rules

* Fix up old back case in prepare registration

* Remove debug code

* Cleanup debug code and some unecessary changes

* Fix migration step on mainnet db

* Fix blacklist outputs for pre-existing DB's

* Remove irrelevant note

* Tweak scanning addresses for locked stakes

Since we only now allow contributions from the primary address we can
skip checking all subaddress + lookahead to speed up wallet scanning

* Define macro for SCNu64 for Mingw

* Fix failure on empty DB

* Add missing error msg, remove contributor from stake

* Improve staking messages

* Flush prompt to always display

* Return the msg from stake failure and fix stake parsing error

* Tweak fork rules for smaller bulletproofs

* Tweak pooled nodes minimum amounts

* Fix crash on exit, there's no need to store on destructor

Since all information about service nodes is derived from the blockchain
and we store state every time we receive a block, storing in the
destructor is redundant as there is no new information to store.

* Make prompt be consistent with CLI

* Check max number of key images from per user to node

* Implement error message on get_output_blacklist failure

* Remove resolved TODO's/comments

* Handle infinite staking in print_sn

* Atoi->strtol, fix prepare_registration, virtual override, stale msgs
2019-02-14 12:12:57 +11:00
Jethro Grassie 123fc2a25a
i2p: initial support 2019-01-30 13:37:45 -05:00
doy-lee bebecbd0a6 Merge branch 'dev' into LokiMergeUpstream 2019-01-30 16:59:47 +11:00
doy-lee 6634d97e29 Merge commit '0daa00e' into LokiMergeUpstream 2019-01-30 13:05:20 +11:00
doy-lee ac4d0469bf Merge commit '4a0e4c7' into LokiMergeUpstream 2019-01-30 12:04:20 +11:00
Lee Clagett 973403bc9f Adding initial support for broadcasting transactions over Tor
- Support for ".onion" in --add-exclusive-node and --add-peer
  - Add --anonymizing-proxy for outbound Tor connections
  - Add --anonymous-inbounds for inbound Tor connections
  - Support for sharing ".onion" addresses over Tor connections
  - Support for broadcasting transactions received over RPC exclusively
    over Tor (else broadcast over public IP when Tor not enabled).
2019-01-28 23:56:33 +00:00
Riccardo Spagni 0daa00e035
Merge pull request #5052
b6534c40 ringct: remove unused senderPk from ecdhTuple (moneromooo-monero)
7d375981 ringct: the commitment mask is now deterministic (moneromooo-monero)
99d946e6 ringct: encode 8 byte amount, saving 24 bytes per output (moneromooo-monero)
cdc3ccec ringct: save 3 bytes on bulletproof size (moneromooo-monero)
f931e16c add a bulletproof version, new bulletproof type, and rct config (moneromooo-monero)
2019-01-28 21:24:55 +02:00
Doyle 3a7b6b59eb
Infinite Staking Part 1 (#387)
* Remove dead branches in hot-path check_tx_inputs

Also renames #define for mixins to better match naming convention

* Shuffle around some more code into common branches

* Fix min/max tx version rules, since there 1 tx v2 on v9 fork

* First draft infinite staking implementation

* Actually generate the right key image and expire appropriately

* Add framework to lock key images after expiry

* Return locked key images for nodes, add request unlock option

* Introduce transaction types for key image unlock

* Update validation steps to accept tx types, key_image_unlock

* Add mapping for lockable key images to amounts

* Change inconsistent naming scheme of contributors

* Create key image unlock transaction type and process it

* Update tx params to allow v4 types and as a result construct_tx*

* Fix some serialisation issues not sending all the information

* Fix dupe tx extra tag causing incorrect deserialisation

* Add warning comments

* Fix key image unlocks parsing error

* Simplify key image proof checks

* Fix rebase errors

* Correctly calculate the key image unlock times

* Blacklist key image on deregistration

* Serialise key image blacklist

* Rollback blacklisted key images

* Fix expiry logic error

* Disallow requesting stake unlock if already unlocked client side

* Add double spend checks for key image unlocks

* Rename get_staking_requirement_lock_blocks

To staking_initial_num_lock_blocks

* Begin modifying output selection to not use locked outputs

* Modify output selection to avoid locked/blacklisted key images

* Cleanup and undoing some protocol breakages

* Simplify expiration of nodes

* Request unlock schedules entire node for expiration

* Fix off by one in expiring nodes

* Undo expiring code for pre v10 nodes

* Fix RPC returning register as unlock height and not checking 0

* Rename key image unlock height const

* Undo testnet hardfork debug changes

* Remove is_type for get_type, fix missing var rename

* Move serialisable data into public namespace

* Serialise tx types properly

* Fix typo in no service node known msg

* Code review

* Fix == to >= on serialising tx type

* Code review 2

* Fix tests and key image unlock

* Add additional test, fix assert

* Remove debug code in wallet

* Fix merge dev problem
2019-01-25 14:15:52 +11:00
moneromooo-monero f931e16c6e
add a bulletproof version, new bulletproof type, and rct config
This makes it easier to modify the bulletproof format
2019-01-22 23:17:24 +00:00
moneromooo-monero b750fb27b0
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.

No other data is currently pruned.

There are three ways to prune a blockchain:

- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility

The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.

The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.

Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2019-01-22 20:30:51 +00:00
Doyle 0b070900d2
Check TX Inputs Refactor (#385)
* Remove dead branches in hot-path check_tx_inputs

Also renames #define for mixins to better match naming convention

* Shuffle around some more code into common branches

* Fix min/max tx version rules, since there 1 tx v2 on v9 fork

* Fix update_output_map incorrectly classifying miner tx

* Remove unused vector, c style for loop in check tx inputs
2019-01-10 10:35:54 +11:00
doy-lee 5c6a7eaa85 Merge commit '84dd674' into LokiMergeUpstream 2018-11-22 14:42:14 +11:00
doy-lee 3afbc0bceb Merge branch 'dev' into LokiMergeUpstream 2018-11-12 15:25:39 +11:00
Doyle fad67eee46
Rotating Governance Schedule (#303)
* Add multiple governance keys

* Batch governance payments to every interval blocks

* Batching of gov rewards and fix breakages in tests

* Add changes to api for working with core tests

* Clean up left over debug stuff

* more cleanup

* Fix uninitialised batched governance value

* Remove dependency on blockchain in tx utils

* Remove redundant vector reserve
2018-11-12 14:02:21 +11:00
RaskaRuby 2bd46065ae Expose limit-rate defaults from command line help 2018-10-31 14:47:20 -07:00
doy-lee 997c0a9991 Merge commit '8f9c381' into LokiMergeUpstream 2018-10-31 17:26:00 +11:00
doy-lee 7375725020 Add minor whitespace/delete dead code after diffing Monero and Loki
Mostly small whitespace changes that make comparing a diff of the
entirety of Loki and Monero less noisy.
2018-10-24 11:33:48 +11:00
xiphon fd62b6e79f blocks: use auto-generated .c files instead of 'LD -r -b binary' 2018-10-22 01:12:00 +03:00
doy-lee 2cd73361a5 Modify per byte fee hardfork to v10 bulletproofs 2018-10-09 20:11:37 +11:00
doy-lee 1e0c4bf4f1 Fix remaining bulletproofs failing core tests 2018-10-09 19:59:21 +11:00
doy-lee c1da4f690d Merge commit '5ffb2ff' into LokiMergeUpstreamUntil_20180911_e6d36c1 2018-10-09 12:31:08 +11:00
Riccardo Spagni ac5674524a
Revert "Merge pull request #4472"
This reverts commit 79d46c4d55, reversing
changes made to c9fc61dbb5.
2018-10-08 21:39:54 +02:00