Commit graph

254 commits

Author SHA1 Message Date
Antioch Peverell
19ce9cc28e
bump for v1.0.1 (#2511) 2019-02-01 14:43:18 +00:00
Antioch Peverell
a82e2a0126
Rework "bucket transactions" logic (buckets are now weight limited) (#2487)
* rework bucket txs

* introduce max_block_weight to global (based on chain_type)
not yet in use anywhere...

* now using global::max_block_weight() everywhere

* testing max_block_weight needs to be big enough to cover existing chain tests...

* add some test coverage for prepare mineable transactions at the block weight limit
introduce AsLimitedTx{max_weight} so we can build artifically small blocks (per mining config)

* cleanup

* default_mineable_max_weight is just the default max_block_weight
we do not need to account for coinbase reward here (tx vs block)

* 75 change outputs in a test is not valid now that we have a low block weight limit...
2019-02-01 10:44:04 +00:00
Antioch Peverell
c8fd0575ed Pool tx weight verification (#2466) 2019-01-25 12:48:15 -08:00
Ignotus Peverell
e7485ab5f1
Version bump to 1.0.0 2019-01-15 16:24:29 +00:00
Ignotus Peverell
60d3ee3c44
Bump version to 0.5.2 for release 2019-01-11 01:26:30 +00:00
Antioch Peverell
a02c44080a Dandelion cycle fix (#2185)
* modify stempool behavior - fluff if tx seen before (any kernels)

* rustfmt
2019-01-07 18:09:04 -05:00
Ignotus Peverell
2c5ba853f7
Version bump to 0.5.1 2019-01-07 19:41:07 +00:00
Ignotus Peverell
9234e3c251
Re-launch floonet (#2249)
*  Fix secondary scaling bugs;  rename is_testnet -> is_floonet (#2215)
* add global::is_mainnet()
* use it to change pre-genesis pow type
* rename is_testnet -> is_floonet
* Support multiple chain configurations (#2217)
* Support multiple chain configurations
Supports generating the proper configuration for each chain type
(mainnet, floonet, usernet). Will run them by default under
their respective root directory (~/.grin/main, ~/.grin/floo, etc).
Assigned default ports for mainnet, overriding them to keep Floonet
ports unchanged.
For now, starting on mainnet will abort.
* Fixed usernet command line help message. Fixes #2217
* Differing magic numbers for each chain type (#2208)
* stick to e=H(R|P|m) when use schnorr signature (#2200)
* stick to e=H(R|P|m) when use schnorr signature
* (1)add verify_slate_messages for wallet receive (2)log the message content
* remove debug log on verify_slate_messages
* verify the sender's message signature when receive_tx in wallet listen
* Revert "remove debug log on verify_slate_messages"

This reverts commit 65ea32a407.

* Revert "rustfmt"

This reverts commit c380ab9185.

* Revert "(1)add verify_slate_messages for wallet receive (2)log the message content"

This reverts commit 9584ca7a89.

* [re-floonet] Keychain Floonet BIP32 version/network option (#2235)

* add 'is_floonet' property to keychain
* fix hex encoding and tests

* Fix couple floonet loose ends (#2230)

* Fix couple floonet loose ends. Fixes #2216
* Doc fix for sig message

* Refuse unkown kernel features (#2244)

* Minor: magic number change for re-floonet

* Set pre genesis is_secondary to true (#2247)

* Minor: tx validation error display underlying

* New floonet genesis

* genesis rustfmt

* Use chain-specific config for wallet toml gen

* Fix default wallet_listener_url

* New more reasonable genesis block, bumped version

* genesis rustfmt

* Couple minor fixes to genesis generation script
2018-12-28 14:46:21 -08:00
John Tromp
f43df5f601 [Floonet] add feature for height locked kernels (#2168)
* add feature for height locked kernels

* add function to compute kernel features appropriate for lock height, and use it

* only sign kernel-features relevant fields; refactor Features

* simplify invalid kernel logic

* remove unused height arg to reward::output and run some rustfmt

* replace nested if/else by match
2018-12-18 18:26:34 +00:00
Antioch Peverell
16641fe149
Cleanup compact block logging (#2126)
* cleanup logging, error logging around compact blocks

* rustfmt
2018-12-11 14:11:58 +00:00
Antioch Peverell
2d4538c428
Clean shutdown via stop_state (#2117)
* clean shutdown wip

* rustfmt

* introduce StopState that we can lock on

* rustfmt

* take lock on stop_state during critical processing (process_block_single etc.)

* rustfmt

* take lock on stop_state during chain::init()

* cleanup

* cleanup

* rustfmt

* docs/comments

* fixup servers tests

* cleanup p2p tests
2018-12-11 11:07:41 +00:00
hashmap
aedac483f5
Convert to Rust 2018 edition (#2084)
* Convert to Rust 2018 edition

* Update gitignore
2018-12-08 00:59:40 +01:00
Ignotus Peverell
b06b4507c1
Tests in chain and pool crates don't depend on wallet anymore (#2092) 2018-12-07 09:38:01 -08:00
Ignotus Peverell
87bfd9aaa4
Mark all crates as publishable 2018-12-07 00:08:15 +00:00
Yeastplume
b8c8840cec
Refactor wallet commands (#2067)
* start wallet command refactoring

* another re-structuring attempt

* rustfmt

* begin splitting up wallet commands

* rustfmt

* clean up wallet arg checking

* rustfmt

* macro for arg parsing

* rustfmt

* factor out init commands

* rustfmt

* move recover to new format

* rustfmt

* add listen command to new format

* rustfmt

* Finish moving commands to new format

* rustfmt

* rustfmt

* propogate errors more cleanly

* rustfmt

* error handling cleanup
2018-12-06 12:04:02 +00:00
Ignotus Peverell
54a034c40a
Fix txpool double spend edge case (#2081)
Sorting validation on inputs, outputs and kernels now also checks for uniqueness.
2018-12-05 09:44:32 -08:00
Dobby the House Elf
b8124676c7 Move libtx to core 2018-12-05 09:41:26 -08:00
antiochp
bd771ecbc5
fix txpool double spend edge case 2018-12-05 10:27:46 +00:00
Antioch Peverell
7b07fe99a7
bump 0.4.1 -> 0.4.2 so we can watch the HF (#2057) 2018-11-30 11:20:12 +00:00
Antioch Peverell
66f2545186
Block accepted reorg aware (#2003)
* block_accepted via adapter is now reorg aware
we skip reconciling the txpool is block is not most work
we skip reconciling the reorg_cache is not a reorg

* rustfmt

* logging tweaks

* rework block_accepted interface

* rustfmt

* rework reorg determination

* introduce BlockStatus to represent next vs reorg vs fork

* rustfmt

* cleanup logging

* log from adapter, even during sync
2018-11-21 14:35:38 +00:00
Antioch Peverell
61f1f6103b
Reorg cache time based (cache 30mins of txs) (#2002)
* cache 30 mins of txs for reorg handling
hard limit set the same as the txpool size limit

* rustfmt
2018-11-20 21:47:59 +00:00
Ignotus Peverell
e4be820671
Configurable max block weight for mining (aka soft limit) (#1976) 2018-11-14 10:22:08 -08:00
Antioch Peverell
39ebb33ba1
bump 0.4.0 -> 0.4.1 (tx kernel broadcast support) (#1950) 2018-11-09 14:57:25 +00:00
Antioch Peverell
d97a6c2189
[DNM] broadcast tx kernel hash (if supported by peer) (#1929)
broadcast tx kernel hash (if supported by peer)
2018-11-07 09:28:17 +00:00
Quentin Le Sceller
24ed4b787a
Add a maximum size to stempool (#1895)
* Add a maximum size to stempool

* Simplify logic
2018-11-05 13:51:52 +01:00
Antioch Peverell
12be191ecd
validate root of header MMR when processing headers (during sync and full blocks) (#1836)
validate root of header MMR when processing headers (during sync and full blocks) (#1836)
2018-11-01 09:51:32 +00:00
Ignotus Peverell
46051ee174
improve minimum difficulty handling (#1791)
* rename MIN_DIFFICULTY to UNIT_DIFFICULTY; define Difficulty::unit, fix INITIAL_DIFFICULTY
* improve minimum difficulty handling
* replace all Difficulty::one by ::min
* revert secondary scaling default in HeaderInfo; rename scaling_difficulty; refactor difficulty_data_to_vector
2018-10-27 10:37:44 -07:00
Ignotus Peverell
c083312ad4
Improve crate descriptors to be more cargo-friendly (#1844)
* Update secp dependency to use crates.io version
* Add more details to various Cargo.toml
* Remove use of env variables that aren't reliably provided by cargo
2018-10-25 17:44:50 -07:00
Ignotus Peverell
a42d66efff
Merge branch 'master' into unitdiff 2018-10-25 14:20:41 -07:00
hashmap
ab7a59b1c2
Pool crate cleanup (#1835)
* Refactor retrieve_transaction
* Cleanup transaction_pool
2018-10-25 14:21:36 +02:00
Antioch Peverell
4050f7fccb
handle re-orgs in transaction_pool (#1829)
* use reorg_cache in transaction_pool to safely handle txs during a re-org

* rustfmt

* comments
2018-10-24 17:57:31 +01:00
Antioch Peverell
3d59cce7c5
rework pool tx validation logic a bit (#1826) 2018-10-24 10:55:42 +01:00
eupn
1195071f5b Replace logging backend to log4rs and add log rotation (#1789)
* Replace logging backend to flexi-logger and add log rotation
* Changed flexi_logger to log4rs
* Disable logging level filtering in Root logger
* Support different logging levels for file and stdout
* Don't log messages from modules other than Grin-related
* Fix formatting
* Place backed up compressed log copies into log file directory
* Increase default log file size to 16 MiB
* Add comment to config file on log_max_size option
2018-10-21 13:30:56 -07:00
Gary Yu
0d06561a91
replace stdlib RwLock and Mutex with parking_lot (#1793)
* replace all stdlib RwLock with parking_lot RwLock

* replace stdlib Mutex with parking_lot Mutex

* rustfmt
2018-10-20 08:13:07 +08:00
John Tromp
846b38308c replace all Difficulty::one by ::min 2018-10-18 21:18:16 +02:00
yeastplume
545d9d6116 t4 merge - rustfmt on entire tree 2018-10-18 11:40:58 +01:00
yeastplume
9423865f92 update cargo versioning 2018-10-15 10:34:33 +00:00
Yeastplume
d756da062a [T4] warning cleanup (#1713)
* clean up warnings
* rustfmt
2018-10-10 08:56:15 -07:00
Yeastplume
6c8c483172
[T4 ONLY] BIP32 Wallet Compliance - Aggsig Updates - Bulletproof Updates (#1501)
* change keychain to use bip32 paths

* convert keychain to use bip32

* change identifier to be serialisation of 4-level bip32 path

* wallet changes compiling, pass parent key into all wallet functions

* rustfmt

* fix tests in chain

* rustfmt

* core tests passing

* rustfmt

* pool tests

* rustfmt

* fixing wallet tests

* rustfmt

* remove file wallet

* wallet tests compiling

* rustfmt

* remove db_migrate

* successful tx exchange test using BIP32 paths

* rustfmt

* fix wallet derivation paths to m/0/0/0

* wallet test fixed again, working with default path

* rustfmt

* fix server tests

* rustfmt

* make parent_id a trait on walletbackend

* rustfmt

* add ability for wallet to switch between multiple named accounts, and tests (not complete)

* rustfmt

* account switching tests in place and passing

* rustfmt

* compile and test with latest libsecp changes

* added public key sum to calculated e for aggsig

* rustfmt

* Update secp to 26

* bulletproof bip32 path integration

* rustfmt

* wallet restore updated with bip32 paths, also restores accounts

* rustfmt

* rustfmt

* remove old extkey

* remove old extkey

* rustfmt

* add wallet account commands

* rustfmt

* update wallet documentation

* rustfmt

* merge from master

* update libsecp tag

* merge from upstream and fix server test

* rustfmt

* rustfmt

* merge from master

* update latest libsecp merge

* fix commitment to zero value generation
2018-10-10 10:11:01 +01:00
Antioch Peverell
a676eb1b39
Replace RefCell with RwLock in OneTime (and cleanup Weak usage) (#1694)
* rustfmt

* use RwLock in OneTime (and not RefCell)

* rustfmt

* put weak refs back and cleanup

* rustfmt

* revert weak in adapters
2018-10-09 16:53:57 +01:00
Antioch Peverell
11f2d7b6d4
UTXOView (readonly, minimal, output only txhashset extension) (#1584)
* make the utxo view explicit

* introduce utxo_view (readonly, minimal txhashset extension)

* rustfmt

* cleanup

* cleanup

* rustfmt

* cleanup build warnings, comments etc.

* rustfmt

* utxo_view even more readonly now

* cleanup

* refactor pmmr, split out readonly_pmmr and backend

* rustfmt
2018-09-25 11:01:19 +01:00
Antioch Peverell
e72d8b58e4
[WIP] txpool (tx validation) using block sums for full validation (#1567)
tx validation (txpool) rework/simplify
2018-09-24 09:24:10 +01:00
Ignotus Peverell
9cc7aed713
Dual proof of work, first step (#1534)
* Move Proof and Difficulty types to pow module. Difficulty scaling calculation.
* Diffculty scaling and size shift for 2nd PoW
* Backport e7eb26ee
* Test compilation fixes
* Scaling only need to go one way, as @tromp pointed out
2018-09-18 15:12:57 -07:00
Antioch Peverell
a4476443bb
Compact transactions (initial prep work) (#1548)
* introduce CompactTransaction (unused currently)

* rustfmt

* fix comments
2018-09-18 15:25:26 +01:00
Quentin Le Sceller
345a6cb53e Update rand crate to 0.5 (#1542)
* Update rand crate to 0.5

* Rustfmt

* Misplaced import
2018-09-18 09:39:45 +01:00
Gary Yu
a0deb18e77
Update version of some crates (#1536)
Update version of some crates
2018-09-17 10:47:48 +08:00
Antioch Peverell
0cbfeaab94
Faster tx known check (#1468)
* fast check for known tx when adding to pool

* rustfmt
2018-09-03 12:35:37 +01:00
Antioch Peverell
939d391e0e
cache rangeproof and kernel signature verification results (#1419)
* wip - cache rangeproof verification

* rustfmt

* rustfmt

* rename to ok_verifier

* rustfmt

* wire in caching verifier in more places
skip rangeproof and kernel signature verification during deserialization

* rustfmt

* actually cache verification results via ok verifier

* rustfmt

* cleanup

* pass a cache around, not a verifier

* rustfmt

* cleanup trait shenanigans

* rustfmt

* core tests passing

* rustfmt

* rustfmt

* tests passing

* rustfmt

* verifier cache now takes vecs of data in and out

* rustfmt

* logging + rustfmt

* add docs and comments
2018-08-30 15:44:34 +01:00
Antioch Peverell
c334c557aa
Simplify tx.validate() and transaction::aggregate() (#1436)
* simplify tx validation and aggregation
we *only* need to account for reward when building a block from txs

* rustfmt

* cleanup and tests passing

* rustfmt

* better comments in with_reward()

* fix wallet tests
2018-08-28 20:00:25 +01:00
Antioch Peverell
a6bd81fdb3 Cleanup generics (where not needed) (#1429)
BlockChain does not need to be generic
2018-08-27 17:22:48 -04:00
Antioch Peverell
7dfca6077c
Refactor compact block body (#1394)
* introduce CompactBlockBody

* rustfmt

* implement From<Block> for CompactBlock

* rustfmt

* remove debug logging

* wip

* rustfmt
2018-08-22 20:19:37 +01:00
Antioch Peverell
8c820a8929 Fast check for duplicate tx in the pool (#1392) 2018-08-20 18:02:28 -04:00
Antioch Peverell
bb7bc2c4f2
Refactor rewind single header (#1390)
* refactor txhashset to only take a single header
no need to pass in current head_header each time

* rustfmt

* fix bug introduced in rewind with LMDB

* rustfmt

* add some comments
2018-08-20 20:34:12 +01:00
Antioch Peverell
82a467ac3c
Fix txpool race condition (#1385)
* fix txpool race condition

* rustfmt

* fixup pool tests

* rustfmt

* rebase against master, pool tests passing
2018-08-20 14:48:05 +01:00
Ignotus Peverell
ef4f426474
Sort pool tx by fee over weight for mining (#1346)
* Sort pool tx by fee over weight for mining. Fixes #1105
* Bucketing dependent transactions before weighing. Minor tx weight fixes.
* Limit length of tx chain, cleanup and test fixes
* Cleanup all mining references to a hardcoded tx count
* Small test improvement, cleanup
2018-08-19 18:50:43 -04:00
Antioch Peverell
5abefbff33
improve logging when receiving blocks and txs (msg_len) (#1383)
* better logging for msg_len and # kernels

* rustfmt
2018-08-19 18:15:42 +01:00
Ignotus Peverell
6775112f61
Introduce cut_through method to avoid code duplication (#1355)
* Introduce cut_through method to avoid code duplication
* Improve error handling, fix sorting.
2018-08-15 16:20:33 -07:00
hashmap
99a66c1960
Consolidate validation in Block and Transaction (#1354)
* Consolidate validation in Block and Transaction

Introduce TransactionBody which is included into block and tx.
Fixes #1333
2018-08-15 23:14:48 +02:00
Ignotus Peverell
e9c987c075
Consolidate and cleanup tx aggregation (#1332)
* Include commitments non-duplicate checks in aggregate
* Remove said check from the pool
* Block building now uses tx aggregation to reduce duplication
2018-08-12 19:08:08 -07:00
Antioch Peverell
ed88ad8bbc
cannot use unstable rustfmt features outside nightly toolchain (#1338)
* cannot use unstable rustfmt features outside nightly toolchain

* cleanup redundant rustfmt.toml files
2018-08-10 14:54:09 +01:00
Gary Yu
76f4915bf9 improve: time crate flagged as deprecated, switch to actively maintained chrono crate (#1297)
* improve: time crate flagged as deprecated, switch to actively maintained chrono crate

* improve: complete the switching from deprecated time crate to chrono crate, for all the tests part

* improve: complete switching to chrono crate, for the left tests in 'chain' and 'wallet'
2018-07-30 09:33:28 +01:00
Ivan Sorokin
5c029e3f87 Make grin.toml config optional (#1278)
* Make grin.toml config optional. Mirror exisiting config parameters in grin.toml to source code, so binary can run without a config file. Add test for it.
* fixup! Make grin.toml config optional
2018-07-29 17:48:24 -07:00
Quentin Le Sceller
b5fe22dbd5 Bump to 0.3 (#1225) 2018-07-06 18:29:39 +01:00
Antioch Peverell
1df409fa69
verify coinbase maturity via output_mmr_size (#1203)
* we do not need Merkle proofs to spend coinbase outputs
we only need the output_mmr_size from the block header

* tests working with no Merkle proofs in inputs
2018-06-28 21:56:07 -04:00
Ignotus Peverell
d189770080 Wallet LMDB backend (#1151)
* Migrate main node store to LMDB

In preparation to using LMDB as a wallet database, migrate the
node db. There's no point in having 2 key-value stores.
In addition LMDB provides a few advantages as a node db, namely a
much faster build (compared to RocksDb), lesser dependencies and
transactions.

* Migrated p2p store to lmdb, stuff compiles

* More fixes, chain tests starting to pass

* Fixed txhashset rollback messing with block save and general batch delimitation. Chain tests passing.

* rustfmt

* LMDB max map size of 10MB isn't really workable. Half TB seems reasonable.

* Fix wallet tests

* Rather crucial commit was missing

* rustfmt

* Fixing new merged tests following lmdb changes

* rustfmt

* * Make txhashset validation read-only on fast sync to avoid having
a really long open transaction.
* Fix deadlock in new block processing, batch should always be
created within a txhashset lock (when they interact).

* Comment about batch and txhashset interlacing

* Fix store tests to use batch

* Externalize wallet config and seed

* Converted direct read access to file outputs map to an iterator

* Cleaned up and simplified wallet Backend trait:

* No more direct mutable access to internal structures (HashMap)
* Batch interface for all writes
* Remove unneeded read wrapper (read_wallet)

* rustfmt

* First (incomplete) pass at wallet LMDB backend

* Progressing on lmdb backent iml

* Added batch impl for LMDB wallet backend. Pretty much done with it, but not sure how to deal with commit (owned).

* rustfmt

* Wrapping LMDB batch around a refcell to work around borrow rules

* Compilation up to grin chain
2018-06-22 09:08:06 +01:00
Ignotus Peverell
0967a5302b
Kernel sum and MMR sizes in block header (#1163)
* Add kernel commitments sum and kernel and output MMR sizes to block header
* Sum a block without including previous sums, cleanup. Blocks are now summed and validated based on their own totals and not the totals since genesis. This allows to get rid of BlockSum and simplified the setting of a new block's roots, kernel sum and MMR sizes. Fixes #116
* Additional kernel MMR validation to check all prior header roots successively
* Wallet tests fix
2018-06-21 02:30:22 +01:00
Antioch Peverell
8fee3b6922
[consensus breaking] use hash_with_index(pos - 1) when checking the hash in the MMR (#1114)
* use hash_with_index(pos - 1) when checking the hash in the MMR

* fix tests, get rid of todo related to duplicate commitments
2018-06-20 16:11:46 -04:00
Antioch Peverell
0ff6763ee6
[consensus breaking] New Improved Merkle Proofs (#1119)
* new improved Merkle proofs

* fix pool and chain tests

* fixup core tests after the merge
2018-06-20 15:18:52 -04:00
Antioch Peverell
028b14d9d9
Replace rm_log with leaf_set (compact bitmap) (#1147)
* only store leaves in rm_log

* cleanup

* commit

* add failing test to cover case where we compact
an already compacted data file

* fix the logic for pruning the data file

* rm_log only contains leaves
prunelist only contains non-leaf subtree roots

* cleanup

* commit

* bitmap impl running in parallel

* rustfmt

* this is better - rewind unremoves outpu pos spent by rewound inputs

* commit

* commit

* pass bitmap around when rewinding

* store and retrieve input bitmap per block from the db

* Replace the RemoveLog with the UTXO set.

* utxo set starting to pass tests

* stuff works...

* split store types out
added some tests to compare the performance of the rm_log and the proposed utxo_set

* pull prune_list out into standalone file

* cleanup, get rid of unused height param

* cleanup and add doc comments

* add support for migrating rm_log to utxo_set

* take snapshot of utxo file during fast sync
implement migration of rm_log -> utxo_set

* rename rewound_copy to snapshot

* fixup pmmr tests to reflect cutoff_pos

* cleanup unused import

* check_compact needs to rewind the utxo_set as appropriate

* fix pool tests

* fixup core tests

* cache block_input_bitmaps via LruCache in store

* cache block header on initial write to db

* rename utxo_set -> leaf_set
and remove references to "spent" in grin_store

* better document the rewind behavior
2018-06-18 11:18:38 -04:00
Quentin Le Sceller
c412bc6c60 Fix empty candidate txs (#1168) 2018-06-14 18:37:21 +01:00
Quentin Le Sceller
a30ee88236
Cleanup imports (#1161)
Reorganize imports
2018-06-14 08:16:14 -04:00
Yeastplume
88616fd341
[WIP] Updates to support web-wallet (#1160)
* updates to support web wallet workflow

* rustfmt

* functions to support wallet, error handling

* rustfmt

* rebase rustfmt

* test fix
2018-06-13 21:58:45 +01:00
Quentin Le Sceller
8f4dbfa540 Many typo fixes (#1158)
* Typo fix
* Parameterise
2018-06-13 17:03:34 +01:00
Ignotus Peverell
af178f82f8
Refactor the Keychain to be based on a trait (#1146)
* First pass at restructuring the keychain crate and introducing a Keychain trait
* Parameterized everything that had to. Stuff compiles.
* More stuff compiles, fix most tests
* Big merge, pushing down opening the keychain forced adding factory methods on trait
* Test fixes for pool and servers crate
2018-06-08 06:21:54 +01:00
Quentin Le Sceller
1255ea2224
Upgrade and uniformize dependencies (#1138)
* Remove unused DandelionConfig

* Cargo upgrade and cleanup
2018-06-05 13:26:32 -04:00
Quentin Le Sceller
d6b689bada
Simplify DandelionConfig (#1115)
* Simplify DandelionConfig and make fields optional
2018-06-01 18:41:39 -04:00
Antioch Peverell
68c7cff6db Fix the intermittent error in pool tests (#1123) 2018-06-01 23:18:58 +01:00
Antioch Peverell
279871e050
log # kernels so we can see tx aggregation (if any) (#1111) 2018-05-31 11:58:59 -04:00
Antioch Peverell
4fda7a6899
Minimal Transaction Pool (#1067)
* verify a tx like we verify a block (experimental)

* first minimal_pool test up and running but not testing what we need to

* rework tx_pool validation to use txhashset extension

* minimal tx pool wired up but rough

* works locally (rough statew though)
delete "legacy" pool and graph code

* rework the new pool into TransactionPool and Pool impls

* rework pool to store pool entries
with associated timer and source etc.

* all_transactions

* extra_txs so we can validate stempool against existing txpool

* rework reconcile_block

* txhashset apply_raw_tx can now rewind to a checkpoint (prev raw tx)

* wip - txhashset tx tests

* more flexible rewind on MMRs

* add tests to cover apply_raw_txs on txhashset extension

* add_to_stempool and add_to_txpool

* deaggregate multi kernel tx when adding to txpoool

* handle freshness in stempool
handle propagation of stempool txs via dandelion monitor

* patience timer and fluff if we cannot propagate
to next relay

* aggregate and fluff stempool is we have no relay

* refactor coinbase maturity

* rewrote basic tx pool tests to use a real txhashset via chain adapter

* rework dandelion monitor to reflect recent discussion
works locally but needs a cleanup

* refactor dandelion_monitor - split out phases

* more pool test coverage

* remove old test code from pool (still wip)

* block_building and block_reconciliation tests

* tracked down chain test failure...

* fix test_coinbase_maturity

* dandelion_monitor now runs...

* refactor dandelion config, shared across p2p and pool components

* fix pool tests with new config

* fix p2p tests

* rework tx pool to deal with duplicate commitments (testnet2 limitation)

* cleanup and address some PR feedback

* add big comment about pre_tx...
2018-05-30 16:57:13 -04:00
Yeastplume
82ed280625
[WIP] Factoring out wallet traits and continued wallet library work (#1096)
* rename wallet libs

* rename transaction.rs to slate.rs

* rename transaction.rs to slate.rs

* move some types into libwallet/types

* rustfmt

* rename libtransaction libtx

* rename libtransaction libtx

* change types.rs to file_wallet

* rustfmt

* rename WalletData to FileWallet

* refactoring WalletBackend types out

* rustfmt

* All compiling, at least

* rustfmt

* fix FileWallet paths to persist

* rustfmt

* re-ignore wallet integration test
2018-05-30 17:48:32 +01:00
hashmap
3026429b05 Do not wrap transactions into Box in pool (#1069)
It makes code more complex and may require more memory allocations than needed.
2018-05-16 00:21:33 +01:00
Yeastplume
4121ea1240
Wallet+Keychain refactoring (#1035)
* beginning to refactor keychain into wallet lib

* rustfmt

* more refactor of aggsig lib, simplify aggsig context manager, hold instance statically for now

* clean some warnings

* clean some warnings

* fix wallet send test a bit

* fix core tests, move wallet dependent tests into integration tests

* repair chain tests

* refactor/fix pool tests

* fix wallet tests, moved from keychain

* add wallet tests
2018-05-09 10:15:58 +01:00
Quentin Le Sceller
55f6e3e63f
Anti-aggregation mechanism for multi-kernel transaction (#984)
* Test multi kernel deaggregation

* Add aggregate without cut_through and deaggregate function

* Add deaggregate function in pool and test

* Rustfmt

* Add deaggregate_and_add_to_memory_pool

* Deaggregate regular multi kernel transaction by default

* Rustfmt

* Add error type faileddeaggregation

* Add find candidates function

* Rustfmt

* Use intersection of sets instead of for comparisons

* Rustfmt

* Removed unnecessary if

* Stricter verification with is_subset

* Rustfmt
2018-04-24 15:47:13 -04:00
Quentin Le Sceller
bd64c6099f Add aggregate function for multi-kernel transaction (#966)
* Add aggregate function

* Rustfmt

* Add multikernel tx test

* Rustfmt

* Add test bad multi-kernel transaction

* Add sorting

* Modified multikernel test
2018-04-17 21:40:51 +01:00
hashmap
7bad33d249 Merkle proofs fee (#898)
* Refactoring before new functionality

* Simplify and use just count of proofs
2018-04-17 18:09:29 +01:00
hashmap
b28de95da4 Error handling using failure in API (#949)
This PR adresses #166
Error handling in wallet was ported to failure in https://github.com/mimblewimble/grin/pull/713
Using the same error model makes wallet code simpler and may simplify migration to Hyper.
2018-04-16 10:00:32 +01:00
Quentin Le Sceller
68e2fa3915 Randomize Dandelion timer (#928) 2018-04-04 17:14:58 +00:00
Ignotus Peverell
327293d28e Genesis, version changes and doc for testnet2 (#865)
* Bump up crates versions

* Finally add a Cargo.lock to avoid dependency breakages

* Build doc update for testnet2

* Fix test framework not really using its mining config

* Testnet2 genesis, best so far at 128 difficulty (a nice number)

* Minor build doc update
2018-03-26 10:48:46 +01:00
Simon B
9285de2c24 Here is a case where ~ is needed, to allow cargo update to only touch the patch level version (third number). Anything else than ~ means that both first numbers can be raised, so "2.1" updaates to "2.2" (#866) 2018-03-25 20:08:38 +00:00
Ignotus Peverell
2bf656646c
Force slog version to 2.1 (2.2 broke some traits) 2018-03-25 19:54:41 +01:00
Simon B
f9b87164e7 Idiomatic cargo toml (#862)
* Specify versions SemVer-style
 - slog and serde
* Comments for not update-able pre-1.0 crates:
 - urlencoded at "0.5" since 0.6+ lacks trait `plugin::Plugin<iron::Request<'_, '_>>`
* alpha-sort deps
* Specify versions SemVer-style
 - backtrace, bitflags, blake2-rfc, bodyparser, built, byteorder
 - chrono, clap, demonize, enum_primitive, env_logger
 - failure, failure_derive, futures
 - hyper, iron, itertools, lazy_static, libc
 - memmap, mount, net2, num_bigint, prettytable-rs
 - rand, regex, rocksdb, router, siphasher
 - term, time, tokio-core, tokio-retry, urlencoded, uuid, walkdir, zip
2018-03-25 17:44:27 +00:00
Alexey Miroshkin
bb134758e7 Rename Hash::zero() to Hash::default() (#858)
It is more idiomatic, also `zero` is misleading in context of `+` operator.
2018-03-23 23:35:10 +00:00
Yeastplume
80887196a8
Restore wallet restore (#843)
* adding appropriate message to bulletproofs to allow for restore

* rustfmt

* should work, now test

* rustfmt

* fix to wallet restore, works now

* fix pool tests

* fix pool tests

* rustfmt
2018-03-23 10:13:57 +00:00
Quentin Le Sceller
836391cc53 Dandelion relay update (#825)
* Change error logger to debug logger
* Dandelion relay update after monitor peers
* Typo + kick off Travis build
2018-03-22 22:51:09 +00:00
Ignotus Peverell
ca8447f3bd
Removed all switch commitment usages, including restore (#841)
* Removed all switch commitment usages, including restore
* Fixed pool tests
* Fix keychain tests
* Get rid of the switch key in keychain
2018-03-22 00:10:11 +00:00
Simon B
4fa9ccc4f7 Cargo.toml (#818)
* Make sure no grin crates get published by mistake: https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish--field-optional
* add missing workspace = '..', [workspace docs for interested readers](https://doc.rust-lang.org/cargo/reference/manifest.html#the-workspace-section)
* dev- or dev_ works equally well, but dev- is what's typically used
* authors = Grin Developers <maillist>
* [dependencies] keep grin-* at the end + readability
2018-03-20 18:21:29 +00:00
Quentin Le Sceller
fcfe7bc6a4 Basic Dandelion transaction routing (#719)
* Initial Dandelion Commit
* Changed stem_tx_pool to tx_stempool
* Introduction of stem memory pool and stem pool config
* Pool push now send to stem memory pool
* Add stem transaction functions
* Add stem transaction pool
* Drastically simplified code structure
* Add monitor transactions
* Add Dandelion monitor and remove transactions from stempool
* Add peer relay monitor
* Reconcile block with stempool
* Fix total size bug
* Add fluff option for pool push
* Added details on dandelion monitor
* Fix issue with missing parent
* Child transaction with stempool parent are now forced stem
* Update Dandelion Relay from outgoing peers
* Fix missing pool reconciliation
* Add the ability to fluff a transaction directly
* Fix tests for Dandelion
* Missing send_stem_transaction method...
* Add fluff handler for wallet
* Add logger when successfully updated Dandelion relay
* Launch transaction monitor last
* Fix dandelion relay misplaced
* Add logging and updating for stempool
* Additionnal check for stem transaction
* Fix 2 Locks in a row
2018-03-20 03:18:54 +00:00
Yeastplume
b53b84b0c6 Move nonce/pow to end of block header, change post-pow hash (#794)
* move nonce/pow to end of block header, update call to cuckoo-miner
* change header hash to be pow only
* fix genesis block miner and tests
2018-03-16 19:04:31 +00:00
Antioch Peverell
449fabf24f
cannot use write_mode in rustfmt.toml in stable (get rid of the warnings) (#752) 2018-03-05 15:23:52 -05:00
Yeastplume
1143d84238
Remove Sumtree References and disambiguate some naming (#747)
* start of renamathon

* api renaming

* Rename UTXO-Output to lessen ambiguity

* compile warning

* compile error

* readme fix

* remove file commit in error
2018-03-05 19:33:44 +00:00
Ignotus Peverell
be8d9633e4
rustfmt all the things 2018-03-04 00:19:54 +00:00
Antioch Peverell
cc12798d7a
Merkle Proofs (#716)
* family_branch() to recursively call family() up the branch
todo
  - we hit a peak, then we need to get to the root somehow
  - actually get the hashes to build the proof

* wip

* some additional testing around merkle tree branches

* track left/right branch for each sibling as we build the merkle path up

* MerkleProof and basic (incomplete) verify fn

* I think a MerkleProof verifies correctly now
need to test on test case with multiple peaks

* basic pmmr merkle proof working

* MerkleProof now serializable/deserializable

* coinbase maturity via merkle proof basically working

* ser/deser merkle proof into hex in api and wallet.dat

* cleanup

* wip - temporarily saving merkle proofs to the commit index

* assert merkle proof in store matches the rewound version
there are cases where it does not...

* commit

* commit

* can successfully rewind the output PMMR and generate a Merkle proof
need to fix the tests up now
and cleanup the code
and add docs for functions etc.

* core tests passing

* fixup chain tests using merkle proofs

* pool tests working with merkle proofs

* api tests working with merkle proof

* fix the broken comapct block hashing behavior
made nonce for short_ids explicit to help with this

* cleanup and comment as necessary

* cleanup variety of TODOs
2018-03-02 15:47:27 -05:00
Antioch Peverell
a20ffc700b
fix the broken comapct block hashing behavior (#738)
made nonce for short_ids explicit to help with this
2018-03-01 13:25:33 -05:00
Yeastplume
5d1f1af892
Bulletproof messages (#730)
* beginning to add bullet proof messages

* Updated core transaction creation to embed the output's value and switch commit hash as part of the rangeproof message

* formatting issue

* more formatting issues

* Removing conditional feature compliation.. just bulletproofs from now on

* ensure MAX_PROOF_SIZE uses bulletproof sizing instead of earlier version

* updated with switch commit committed to in extra data

* accidentally commented out bullet-proof-size feature
2018-02-27 21:11:55 +00:00
Antioch Peverell
5572fa075e
tx pool lookup for kernel short ids (compact block hydration) (#710)
* wip - basic tx pool lookup for kernel short ids (compact block hydration)

* use the nonce in the compact_block to correctly generate short_ids for lookup

* query the tx pool based on kernel short_ids

* tests passing

* cleanup some logging

* cleanup logging
2018-02-16 10:42:27 -05:00
Antioch Peverell
ebd801f14e
Transaction contain kernels. Transactions and blocks maintain a kernel offset (split key). (#681)
* WIP - split the key in final tx step
store "offset" on transaction itself

* rebase

* commit

* tx with offset

* got a test tx validating successfully using a sig from a split key and the appropriate offset

* sum up the offset for the block_header

* fix size tests for blocks and compact blocks (header now includes offset)

* use txs with offsets in most of the core tests
some tests now failing

* build kernel from k1G (k2 stored on tx, sum stored on header)

* commit

* tx now has vec of kernels
rework tx and kernel validation

* add test for tx cut_through

* wip - working on splitting in aggsig

* split the key when creating the initial sender aggsig context

* cleanup

* cleanup

* code needs claning up but split keys working for sender/receiver aggsig flow

* cleanup debug logging

* fix tests

* fix merge and basic cleanup

* fix keychain tests to use new tx_id
2018-02-13 10:35:30 -05:00
Ignotus Peverell
22c521eec8
[WIP] Abridged sync (#440)
* Util to zip and unzip directories
* First pass at sumtree request/response. Add message types, implement the exchange in the protocol, zip up the sumtree directory and stream the file over, with necessary adapter hooks.
* Implement the sumtree archive receive logicGets the sumtree archive data stream from the network and write it to a file. Unzip the file, place it at the right spot and reconstruct the sumtree data structure, rewinding where to the right spot.
* Sumtree hash structure validation
* Simplify sumtree backend buffering logic. The backend for a sumtree has to implement some in-memory buffering logic to provide a commit/rollback interface. The backend itself is an aggregate of 3 underlying storages (an append only file, a remove log and a skip list). The buffering was previously implemented both by the backend and some of the underlying storages. Now pushing back all buffering logic to the storages to keep the backend simpler.
* Add kernel append only store file to sumtrees. The chain sumtrees structure now also saves all kernels to a dedicated file. As that storage is implemented by the append only file wrapper, it's also rewind-aware.
* Full state validation. Checks that:
    - MMRs are sane (hash and sum each node)
    - Tree roots match the corresponding header
    - Kernel signatures are valid
    - Sum of all kernel excesses equals the sum of UTXO commitments
minus the supply
* Fast sync handoff to body sync. Once the fast-sync state is fully setup, get bacj in body sync
mode to get the full bodies of the last blocks we're missing.
* First fully working fast sync
* Facility in p2p conn to deal with attachments (raw binary after message).
* Re-introduced sumtree send and receive message handling using the above.
* Fixed test and finished updating all required db state after sumtree validation.
* Massaged a little bit the pipeline orphan check to still work after the new sumtrees have been setup.
* Various cleanup. Consolidated fast sync and full sync into a single function as they're very similar. Proper conditions to trigger a sumtree request and some checks on receiving it.
2018-02-09 22:32:16 +00:00
Quentin Le Sceller
fb46fad0ac Remove unused import and uniformize crates (#686)
* Removed unused crates
* Add listconnectedpeers in grin client
* Removed unused import and uniformize crates
2018-02-05 19:46:56 +00:00
Quentin Le Sceller
8a7eb94759 Update bitflags to ^0.1 (#682)
* Removed unused crates
* Add listconnectedpeers in grin client
* Update bitflags to ^0.1 globally
2018-02-05 19:43:54 +00:00
Simon B
86ff4e5bd0 Fix 658 and compiler complaints (#661)
* Tried but failed to fix `cargo build` complaint about unused #[macro use]. See also 7a803a8dc1
* Compiler complaints be-gone
* Give sumtree tests method-tagged folder names so they don't overwrite each others' files
Fixes #658
2018-01-28 06:12:33 +00:00
Yeastplume
783e4c250d
[WIP] Difficulty Adjustment Updates (#651)
* large updates for mining, fix async mode, will list changes in PR

* reset config and build defaults

* change to difficulty calculations

* tweaking mining params and tests

* tweaking to tests

* including pre-genesis data for difficulty adjustments, adding adjustment scenario tests

* further clarifying next_difficulty function

* moving tests out of consensus.rs

* pow test fix

* changing pre-genesis generation
2018-01-27 07:48:53 +00:00
AntiochP
4be259e0de
hashed switch commitments - BLAKE2(bJ, r) (#648)
* wip

* derive switch commit hash key from extended key in wallet

* fix failing pool test
2018-01-23 07:14:06 -05:00
AntiochP
cbd3b2ff87
hash (features|commitment) in output mmr (#615)
* experiment with lock_heights on outputs

* playing around with lock_height as part of the switch commitment hash

* cleanup

* include features in the switch commit hash key

* commit

* rebase off master

* commit

* cleanup

* missing docs

* rework coinbase maturity test to build valid tx

* pool and chain tests passing (inputs have switch commitments)

* commit

* cleanup

* check inputs spending coinbase outputs have valid lock_heights

* wip - got it building (tests still failing)

* use zero key for non coinbase switch commit hash

* fees and height wrong order...

* send output lock_height over to wallet via api

* no more header by height index
workaround this for wallet refresh and wallet restore

* refresh heights for unspent wallet outputs where missing

* TODO - might be slow?

* simplify - do not pass around lock_height for non coinbase outputs

* commit

* fix tests after merge

* build input vs coinbase_input
switch commit hash key encodes lock_height
cleanup output by commit index (currently broken...)

* is_unspent and get_unspent cleanup - we have no outputs, only switch_commit_hashes

* separate concept of utxo vs output in the api
utxos come from the sumtrees (and only the sumtrees, limited info)
outputs come from blocks (and we need to look them up via block height)

* cleanup

* better api support for block outputs with range proofs

* basic wallet operations appear to work
restore is not working fully
refresh refreshes heights correctly (at least appears to)

* wallet refresh and wallet restore appear to be working now

* fix core tests

* fix some mine_simple_chain tests

* fixup chain tests

* rework so pool tests pass

* wallet restore now safely habndles duplicate commitments (reused wallet keys)
for coinbase outputs where lock_height is _very_ important

* wip

* validate_coinbase_maturity
got things building
tests are failing

* lite vs full versions of is_unspent

* builds and working locally
zero-conf - what to do here?

* handle zero-conf edge case (use latest block)

* introduce OutputIdentifier, avoid leaking SumCommit everywhere

* fix the bad merge

* pool verifies coinbase maturity via is_matured
this uses sumtree in a consistent way

* cleanup

* add docs, cleanup build warnings

* fix core tests

* fix chain tests

* fix pool tests

* cleanup debug logging that we no longer need

* make out_block optional on an input (only care about it for spending coinbase outputs)

* cleanup

* bump the build
2018-01-16 22:03:40 -05:00
Simon B
8b2f9503c9 Make total_difficulty the sum of network difficulty [testnet2] (#523)
* Make total_difficulty the sum of network difficulty, not whatever the miner happened to mine.
  - Only for Testnet2 / Mainnet (hardforks Testnet1)
  - update chain::pipe validate_header to validate according to Testnet2 rules for cumulative difference

Fixes #280

* tests that should ignore (network) difficulty

* fn new_block is explained as "utility to create a block without worrying about the key or previous header" so it gets network difficulty := 0 too

* update tx pool tests (going with "minimum" for network difficulty for now)

* add ERR outputs about bannable offences
(#406 should know about these)

* whitespace fix

* mine_simple_chain: Probably DON'T overwrite difficulty (?)

* core/mod tests "reward_empty_block" and "reward_with_tx_block" tests set to use lowest network difficulty possible
2018-01-12 18:35:37 +00:00
Yeastplume
1199ed2cc1
[WIP] Aggsig Transactions (#530)
* First steps converting transaction workflow to be aggsig-enable

* integrating updated version of aggsig, which gives greater control over the contents of e

* added wallet transaction test to testing framework to enable testing the whole thing, completed interaction as far as inital response from recipient

* more aggsig work, final signature is produced now

* Construction of aggsig transaction now working to the point of the signature being built

* aggsig transactions working end-to-end in the nominal case

* refactor aggsig verify from commit and fix some tests

* more cleanup and test fixing

* cleaning up automated tests

* test+formatting fix
2018-01-10 19:36:27 +00:00
Simon B
17d5898677 Forgotten testnet1 cherries (#475)
* Very quick peer banning endpoint, helps with #406
* Ping heights (#407)
* add height to ping/ping
* reformat output
* fix p2p test
* Fix orphan handling, not related to current head. Fixes #412
* Check before borrow, fixes #267
* Not finding an output commit in pos is an AlreadySpent
* Fix race condition, sending before conn is ready
* Explicit error for unknown pos of a forked block
* Remove config outdated tests. Fix #333
* Check ref and try before borrow, fix #400
* We do not want to sync with old peers anyway
* Hide cargo compiler warning for unused NoopAdapter and unused test code. Add TODOs
2017-12-13 21:52:21 +00:00
Ignotus Peverell
91fdaa8320
Genesis block for known chains, mine dev chains (#269)
Renamed mining parameter mode to chain type, with existing types
of CI testing, user testing, testnet1 or mainnet. The public
chains (testnet1 and mainnet) come with their fully pre-defined
genesis block.

Still need to set the nonce and cycle for testnet1 genesis.
2017-11-15 16:49:15 -05:00
Ignotus Peverell
6ac2fe2a8c
Major fee bump to come to more reasonable values
Starting on the higher side for testnet to see how it goes in
practice. Introduced constants for each smaller unit.
2017-11-14 20:14:07 -05:00
AntiochP
c1656f7660
use the static secp instance everywhere (except the wallet) (#250) 2017-11-09 14:26:45 -05:00
Ignotus Peverell
e4ebb7c7cb
Cleanup HTTP APIs, update ports to avoid gap, rustfmt
Moved the HTTP APIs away from the REST endpoint abstraction and
to simpler Hyper handlers. Re-established all routes as v1.
Changed wallet receiver port to 13415 to avoid a gap in port
numbers.

Finally, rustfmt seems to have ignored specific files arguments,
running on everything.
2017-10-31 19:42:56 -04:00
Yeastplume
05d22cb632
changing secp import to tag, and consolidating Cargo.toml import (#220) 2017-10-31 23:20:55 +00:00
Ignotus Peverell
e2e24bc38e Transaction broadcast (#209)
* Add transaction broadcast to all known peers once they have been
accepted by our own transaction pool.
* Some debug log

Fixes #200
2017-10-25 21:06:24 +00:00
AntiochP
fa1f2f695b we now mine both txs so update test to reflect this (#189) 2017-10-18 23:23:37 +00:00
AntiochP
4d7b46b0b9 wallet can now optionally spend zero-confirmation txs (#188)
* wallet can now optionally spend zero-confirmation txs
* add rule to get_mineable_transactions based on total pool size
2017-10-18 20:47:37 +00:00
AntiochP
bab7bd7060 update_roots on pool to keep it consistent after reconciliation (#182)
* failing test case that exercises
prepare_mineable_transactions and reconcile_block
and highlights what appears to be unexpected behavior
* adjust the failing test - the failure state is where we have
a tx in the pool *but* it is not in the list of roots in the pool
* zero confirmation txs are now working
introduce update_roots to graph to ensure pool is consistent
after calling remove_pool_transaction
* move update_roots to sweep_transactions so we only call it once
rework update_roots to be more efficient
* use HashSet in reconcile_block to avoid marking txs multiple times
* use HashSet and not HashMap
return from mark_transaction early if already seen tx
2017-10-18 20:42:51 +00:00
Yeastplume
8f76746e84 Switch commitments (#179)
* Adding switch commit to grin outputs
* logging output fix
* adding switch commitment hash to sum tree node
* added hash_with to Hashed trait, to allow for hashing to include another writeable element
* adding hash_with as method in hashed trait
2017-10-16 21:23:10 +00:00
AntiochP
86420d4bca Shorter identifiers and call them key_id (not pubkey) (#175)
* rename pubkey -> key_id, these are key identifiers, not public keys
* reduce identifier seize to 10 bytes, get rid of fingerprints (identifiers are now small enough to use as-is)
* IDENTIFIER_SIZE const
* add FeeDispute error for when sender and recipient disagre on fee calculation (should never happen)
* does not need to be mut
* cleaned up some warnings
2017-10-13 04:45:07 +00:00
Yeastplume
8e382a7593 slog-rs logging (#171)
* added global slog instance, changed all logging macro formats to include logger instance
* adding configuration to logging, allowing for multiple log outputs
* updates to test, changes to build docs
* rustfmt
* moving logging functions into util crate
2017-10-12 16:56:44 +00:00
AntiochP
bf7c1fb44f add lock_height to Transaction and TxKernel (#167)
* add lock_height to Transaction and TxKernel, sign msg including both fee and lock_height in kernel
* make the order of the fields in tx and kernel more consistent
* rename to kernel_sig_msg
* add test to cover adding timelocked tx to pool, where tx is invalid based on current height of the blockchain
* add tests for adding timelocked txs to blocks (valid and otherwise)
2017-10-11 18:12:01 +00:00
AntiochP
dc0dbc62be Set approximate wallet fee to avoid LowFeeTransaction (#163)
Set approximate wallet fee when building a transaction so we avoid getting a LowFeeTransaction error from the pool

* rustfmt
2017-10-10 17:30:34 +00:00
Ignotus Peverell
0d26daadc5
Default values for pool config
Allows for deserializing config file without having to specify
all properties in it.
2017-10-08 17:45:31 +00:00
Ignotus Peverell
1e73e3aefc
Add a min fee to accept transactions in the pool
Configuration for a minum accept fee base for the transaction
pool. The base is multipled by a weight computed from the
transaction number of inputs, outputs and kernels. The transaction
fee is required to always be larger than the weight times the
base.

    min_fee = base * (-1*input_len + 4*output_len + kernel_len)

The weight is set to never be less than one.

Also added a configurable (and fairly naive for now) max pool
capacity in number of transactions.
2017-10-07 18:31:01 +00:00
AntiochP
3dd1dde00b Pass pubkey for coinbase (#159)
* store wallet output data in hashmap
* cleanup up commented out code
* pass pubkey/identifier and not derivation around to miner etc.
* fix failing tests
2017-10-07 17:38:41 +00:00
Yeastplume
da21388131 wee warning cleanup + build doc updates (#156)
* warning cleanup
* test compilation
* clarification on architecture in build doc, path export statement fix
2017-10-06 16:46:18 +00:00
Ignotus Peverell
ca7de0f42d
Painstakingly debugged pool test to avoid odd fees 2017-10-05 09:52:01 +00:00
AntiochP
e060b1953e rust-secp256k1-zkp breaking changes to support (#155)
Rewinding range proofs to recover transaction value from outputs
2017-10-05 21:40:46 +00:00
Yeastplume
e68a6a69bb Cuckoo miner fixes and configurable coinbase maturity (#154)
* cuckoo miner update+coinbase maturity
* set mining parameter mode on immature coinbase test
2017-10-04 17:44:22 +00:00
AntiochP
677d0a3a95 keychain crate (no more secretkeys in core) (#146)
* introduce grin_keychain, encapsulate derivation of secret_keys
* core compiles against keychain, tests don't run yet
* core tests are now passing against keychain
* wip - getting wallet working with keychain
* add util and keychain to travis test matrix
* basic test around key derivation
2017-10-03 00:02:31 +00:00
Ignotus Peverell
8504efb796
Cargo fmt all the things 2017-09-29 18:44:25 +00:00
Ignotus Peverell
36bcd3cc39 Integrate sum trees with the rest of the system (#116)
* Integrate PMMR and its persistent backend with the Chain
* Chain can set tree roots; PMMR backend discard
* Check spent and prune for each input in new block
* Handling of forks by rewinding the state
* More PMMR tests and fixes, mostly around rewind
* Rewrite get_unspent to use the sumtrees, fix remaining compilation issues
2017-09-27 23:46:32 +00:00
AntiochP
670aa11e5a expose "wallet info" on CLI (#132)
* expose "wallet info" on CLI
* add sleep and retry logic when obtaining wallet.lock
* fix pool test for immature coinbase
2017-09-24 04:40:31 +00:00
AntiochP
7c5b7d23e7 Replace secp256k1 directory with repository dependency (#126)
* workaround the "commitment is not a public key" problem by using to_two_keys() from rust-secp256k1-zkp
* remove secp256k1zkp, update the various Cargo.toml to use rust-secp256k1-zkp from external git repo, update code to not rely on to_pubkey (and use verify_from_commit)
* secp256k1zkp from git
* cleanup secp256k1 dependencies
* gitignore node1 and node2 dirs
2017-09-21 00:07:40 +00:00
AntiochP
44c8f9e22d fix the range_proof call (missing nonce param) (#125) 2017-09-13 20:00:48 +00:00
AntiochP
95a92eefc9 Cannot spend coinbase for N blocks (#111)
* use head_header in add_to_memory_pool
* add COINBASE_MATURITY const to consensus
* add coinbase maturity (wip) validaton rule to validate_block
* add coinbase maturity check to validate_block
* map errors in adapters - specific errors still wip
* reworked so adapter translates chain errors to pool errors (core errors not required)
* add test for spending immature coinbase in memory pool
* wip - add test to cover spending coinbase output in chain.process_block
* added test coverage around process_block - we have a problem with coinbase output commitments
* add a comment on the failing test
* process_block will now fail validation if we attempt to spend coinbase that has not yet matured
(remember to use a new reward_key for every block). test coverage in place to verify this
2017-09-12 17:24:24 +00:00
AntiochP
87cd0e5c58 added basic tests around range_proof (#121)
Pass nonce in to range_proof (we need it for rewind_range_proof, at least for testing)
2017-09-10 18:31:41 +00:00
Seamus Finnigan
9c649edfbf Use UTC in timestamps and fix broken header test (#105)
* Fix block header timestamp UTC and fix test
* Always use UTC for timestamp as time::Tm
2017-08-26 16:31:27 +00:00
AntiochP
3b4a48b2fd Cleanup build warnings (#87)
* minor cleanup - unused imports
* cleanup build warnings - unused vars
* make structs pub to get rid of the private_in_public lint warning
* missing docs on RangeProof
* add missing docs to store delete function
* cleaned up deprecation warning -
tokio_core -> tokio_io
complete() -> send()
2017-08-10 00:54:10 +00:00
Ignotus Peverell
40090fcdbc
Fix api & pool tests, add the crates to Travis 2017-07-18 17:33:49 +00:00
Ignotus Peverell
fbbd703e99
Protect wallet data file with a file lock
Operations on the wallet data file are now fenced by a lock to
avoid potentially messy concurrent modifications by multiple
processes (i.e. the wallet receiver and a send command). The lock
is done using a create-only lock file, which is an atomic
operation.
2017-06-14 21:42:58 -07:00
Ignotus Peverell
6523966f9e
Bug fixes in wallet and related API
Fixes a few loose ends in the full cycle of sending coins,
accepting them, pushing that transaction to the pool and having it
mined. More specifically:

* The API output endpoint needs to be a UTXO endpoint, as the
server can't make any guarantee about having a spent output.
* Bubbling up HTTP not found errors.
* Wallet output status checker now handles spent outputs.
* Transaction pool validates the transaction before accepting it.
* Fixed the operation API routes.
* Fixed too greedy wallet coin selection loop.
2017-06-12 16:41:27 -07:00