Commit graph

337 commits

Author SHA1 Message Date
Ignotus Peverell
a42d66efff
Merge branch 'master' into unitdiff 2018-10-25 14:20:41 -07:00
Quentin Le Sceller
c343c65051
Remove fluff in SendTXArgs (#1825) 2018-10-24 12:10:40 +02:00
Yeastplume
029450a5ce
remove file wallet (#1824) 2018-10-24 11:03:50 +01:00
Quentin Le Sceller
d11088c987
Fix build error (#1803)
* Fix build error

* Cargo Lock
2018-10-21 23:56:42 +02: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
Quentin Le Sceller
0852b0c4cf Expose post_tx in OwnerAPI Post (#1795)
* Add POST post_tx in wallet_owner_api
* Add docs for post_tx
2018-10-21 13:26:35 -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
e1b5d7f3c2 revert secondary scaling default in HeaderInfo; rename scaling_difficulty; refactor difficulty_data_to_vector 2018-10-19 21:39:54 +02:00
eupn
a11778bf68 fix: mark potential coinbase outputs as mining instead of unconfirmed in wallet (#1787)
* Mark unconfirmed coinbase outputs as "Mining" instead of "Unconfirmed"

* Fix formatting
2018-10-18 15:42:31 +02:00
yeastplume
6980278b95 merge T4 into master - rustfmt 2018-10-18 11:23:22 +01:00
John Tromp
8540e4f723 [T4] tweaks and fixes (#1766)
* refactor consensus.rs, tweaking some values
* move scale() there
* fix set_header_nonce bug
* remove maturity soft-fork code
* increase diff target precision
* fix weight comments and try resolve PR conflict
2018-10-16 16:14:22 -07:00
John Tromp
34646ddf51 [T4] Rename all shiftsize / cuckoo_size to edge_bits and change value for T4 (#1752)
* replace all size_shift / cuckoo_size by edge_bits and change some constants for T4
* replace remaining occurrences of sizeshift
2018-10-15 16:14:23 -07:00
Ignotus Peverell
a41022f1e3
Fix last tests broken by secondary PoW factor adjustment 2018-10-15 22:53:28 +00:00
yeastplume
9423865f92 update cargo versioning 2018-10-15 10:34:33 +00:00
Yeastplume
13facfac4b
pre-testnet4 genesis values (#1744) 2018-10-15 11:14:49 +01:00
Ignotus Peverell
43f4f92730
[T4] Secondary proof of work difficulty adjustments (#1709)
* First pass at secondary proof of work difficulty adjustments
* Core and chain test fixes
* Next difficulty calc now needs a height. Scaling calculation fixes. Setting scaling on mined block.
* Change factor to u32 instead of u64.
* Cleanup structs used by next_difficulty
* Fix header size calc with u32 scaling
2018-10-13 13:57:01 -07: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
hashmap
28b0acc0e6
Support pem TLS certificates
Mostly to support let's encrypt. It requires to switch from native-tls and friends to rustls and friends, which perhap is a good thing per se, rustls looks more modern and for sure more Rusty.
Alternative would be manually convert pkcs12 certificates to pem, which requires openssl tools to be installed and make transparent integration whith let's encrypt much harder (this is out of the scope for now, perhaps in near future)
2018-10-05 17:09:19 +02:00
hashmap
4a6cae0fe6
Allow TLS for Wallet APIs (#1626)
* Allow TLS for Wallet APIs

This PR adds an optional support of TLS for wallet APIs. Only PKCS12 format is supported, will address .pem support in next PR and provide some documentation.
Address #1425
2018-10-02 09:49:36 +02:00
Quentin Le Sceller
a13c20ceb2 Fix API wallets calls (#1597)
* Add API Secret in wallet calls

* File node api secret default to same api secret and directly in http parameter
2018-09-27 21:45:48 +02:00
Quentin Le Sceller
62fd8f2124 Implement Basic Auth for API and Owner API (#1566)
* Add api_secret

* Add to base64 method

* Add basic auth in API

* Add Basic Auth to owner API

* Add flag to enable disable basic auth

* Add .api_secret file
2018-09-26 22:38:44 +02:00
hashmap
274df3b8bb
Fix wallet APIs launch command (#1574)
We used to launch a thread for API server inside the wallet crate, now we do it inside api crate, so the cmd tool launches API and exit. This fix makes sure that command will wait for API thread.
2018-09-22 09:34:28 +02:00
hashmap
3a3ba4d636
Improve middleware support in web layer (#1572)
* Middleware and handler (mw implements the same trait) could be attached to multiple nodes inside the router
* Middleware could be attached to the router (syntactic sugar, it is attached to the root node) as well as to any node
* Handler's call method receives an iterator of handlers and responsible for calling the next handler if needed
2018-09-21 19:57:59 +02:00
hashmap
972c2e5aa9
Support TLS in ApiServer (#1565)
* Support TLS in ApiServer

This is ground work to support TLS in Grin APIs (like wallet ot node). Particular API implemention needs to decide if TLS is used or not and pass certificate data etc.

* P12 format support
* New method to start TLS server
* Transparent TLS support in API client (depends on URL scheme http/https)
* Refactoring
* Initial support for graceful shutdown (commentred out int this PR, unstable for now)
* API server tests (TLS server test is disabled by default, hyper client rejects self-signed certificates, so extra step is needed to install local CA (I used mkcert)
* Add a cert file to make test complile
2018-09-21 13:33:23 +02:00
hashmap
521ce901e4
Merge pull request #1557 from yourowncrypto/api-refactor
Refactor hyper router
2018-09-19 19:33:48 +02:00
Roy Blankman
febe9076f0 fixes #1507 - proper tx confirmation calculation (#1552)
when self.height == current_height, # of confirmations should be 1 not 0
2018-09-19 16:55:03 +01:00
hashmap
d5ef3d9d12
Refactor hyper router
* Make it simpler to implement middleware
* Switch from the current thread runtime to the default one. It enables us to inject TLS support later one and potentially more scalable, unfortunately it involves some additonal cloning of the router, because we can't rely on thread local vars anymore
* Introduce `call` entrypoint for Handler, so it's possible to handle any HTTP method in one place, handy for middleware
* Implement example of middleware
2018-09-19 17:10:52 +02:00
hashmap
7db8e5e2dd Improve API errors (#1543)
Address ##1525 in particular and improve error messages in general.
Instead of `Request Error: Error { inner:` a client would get:
`Generic error: Invalid request body: missing field `method` at line 1 column 162`
2018-09-18 15:11:58 -07: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
dca0d52dcd
Cleanup transaction with offset (#1514)
* cleanup build::transaction_with_offset

* rustfmt
2018-09-12 12:17:36 +01:00
Quentin Le Sceller
dd1cef2148 Add file based transaction in owner API (#1484)
* Add file based transaction in owner API
* Add finalize tx in owner API
* Code cleanup and placed file_receive in correct API
* Output an explicit error when http dest seems incorrect
* Add doc on send method
* Add cancel tx endpoint in owner API
* Add dump stored tx endpoint in owner API
*  Add missing parameters
2018-09-10 19:18:10 -07:00
Antioch Peverell
dbe53f63c8
disable chain compaction on archive nodes (#1498)
* disable chain compaction when in archive mode

* rustfmt
2018-09-10 15:59:42 +01:00
Yeastplume
974feaf07f
Add chaintype to wallet config (#1480)
* Add chain type to grin-wallet.toml

* rustfmt
2018-09-05 14:37:37 +01:00
Yeastplume
75f0ea6dd3
Save transaction as part of TxLogEntry after transaction completion (#1473)
* save wallet transaction on transaction completion

* rustfmt

* add resend command

* rustfmt

* added unit tests + fixes for grin wallet repost

* add ability to dump transaction file contents

* rustfmt

* wallet doc update
2018-09-05 12:12:29 +01:00
John Tromp
c359c8aaf2 one day coinbase maturity (#1457)
* one day coinbase maturity

* make one day maturity a soft fork
2018-09-04 10:59:55 +01:00
Quentin Le Sceller
544a296f77
Fix typos and unused imports (#1466)
* Fix typos and unused imports
2018-09-03 13:09:28 +02: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
Yeastplume
11d24fe0c1
update docs to reflect new file layout (#1444) 2018-08-30 11:47:04 +01:00
Yeastplume
1ded3f3972
Config + Default directories (#1433)
* config file can now be generated by executable

* rustfmt

* remove now-unnecessary config defaults test

* set up paths and config file creation in user's home directory

* rustfmt

* remove default grin.toml

* add grin configuration command to spit out config file

* Split configuration into wallet and server

* rustfmt

* Restore logging to wallet configurations

* rustfmt
2018-08-30 10:10:40 +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
Ignotus Peverell
4048a3011a
Improve file-based tx send to not use private file (#1421)
Instead of generating a private file on send that needs to be
provided again in finalize, the private context information is
saved in the wallet db.

Also move internal Context to bona fide libwallet type
2018-08-27 20:57:33 -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
Yeastplume
ccc9c0db90
Wallet Restore fixes and updates (#1399)
* add wallet restore tests

* rustfmt

* begin to add tests for wallet restore

* rustfmt

* complete wallet restore automated tests, correct wallet restore heights and ensure TX log is repopulated on restore
2018-08-21 18:05:28 +01:00
Yeastplume
b74e0fbc1f
Ensure wallet output heights are always correct (#1395)
* ensure block heights are always returned from API and updated within wallet

* fix api test
2018-08-21 14:04:14 +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
Gary Yu
743c845259 fix: deriv_idx is not updated after wallet restore (#1306) (#1374)
* fix: deriv_idx is not updated after wallet restore (#1306)

* rustfmt check
2018-08-19 19:27:04 +01:00
Antioch Peverell
25e03aadef
Tx (change) output splitter (#1369)
* wip - split change into many outputs for testing

* rustfmt

* add change_outputs param to wallet send
default to 1

* commit

* rustfmt

* cleanup

* fixup servers tests
2018-08-18 22:38:48 +01:00
Gary Yu
4da92c5d75 minor fix: prefix code conflict between 'COMMITMENT_PREFIX' and 'CONFIRMED_HEIGHT_PREFIX' (#1375) 2018-08-18 13:23:31 +01:00
Quentin Le Sceller
59f4806a2c Update wallet restore error message (#1368) 2018-08-17 14:04:23 -04:00
Mike Dallas
adeaea4622 Truncate trailing zeroes in coin amounts (#1366)
* truncate coin amounts
* truncate datetimes
* fixed formatting
2018-08-17 13:05:35 -04:00
Antioch Peverell
a10557c756
grin wallet outputs now displays output commitments (#1365)
* commit - wip

* rustfmt

* save output commitment when saving output in wallet

* rustfmt

* fixup wallet tests with commitments in the wallet db

* rustfmt
2018-08-17 12:15:06 +01: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
Michalis Kargakis
dda88f193b Fix typo + git ignore wallet data (#1350)
* Ignore wallet data

* Fix typo
2018-08-13 23:28:01 +01: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
Ignotus Peverell
f0bdb2c8fa
File-based transaction building (#1317)
* First implementation of file-based transaction send, receive and finalize in libwallet
* Switch from TOML to JSON (needless complication). Plug in send, receive and finalize wallet commands.
* Pretty JSON for response is too large (all whitespace)
2018-08-07 11:17:33 -07:00
hashmap
414a30224e Fix get outputs call in wallet (#1319)
* Fix get outputs call in wallet. It generates an invalid url if there are 1000+ outputs.
* Also switched to async http client for performance reasons
* Couple unrelated cleanups
* fixup! Fix get outputs call in wallet
2018-08-06 12:48:05 -07:00
Quentin Le Sceller
3ee01055ed Fixes #1299 - Fails to send transaction when not enough funds for fee (#1311) 2018-08-02 09:05:38 -07:00
hashmap
06883e94e9 Remove all iron traces (#1309)
Fixes [#1307]. It seems my ripgrep ignores Cargo.lock files, had to grep manually.
2018-08-01 13:58:22 -04:00
e-max
25e3d9e7d3 Remove Iron dependency and update hyper to version 0.12 (#1241)
* Remove Iron dependecy and update hyper to version 0.12 #876

* REMOVE ME

* Revert "REMOVE ME"

This reverts commit e9a976eee98a2d5a4dfae5d9e1e4f5ed640c05d3.

* Rebase and start updating libwallet

Libwallet doesn't compile yet.

* Wallet compiles

* Grin compiles

* No compilation errors in tests

* All tests pass

* Reeturn future from handler

* Refactoring

* Fix lifetime issue one more time

I have to force push to rollback all the work done in last 2 days

* Fix wallet send issue

* Clean up
2018-08-01 10:44:07 +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
Gary Yu
61506a8064 clean some build warnings (#1288)
* clean some build warnings

* undo the warning suppress for aggsig
2018-07-27 15:16:14 +01:00
Yeastplume
a053790ee6
filter outputs by tx_id (#1298) 2018-07-27 09:39:01 +01:00
Yeastplume
70b97b0a06
add tx retrieval function (#1295)
Web-Wallet support updates
2018-07-24 20:49:29 +01:00
Yeastplume
80f82eecc1
added transaction cancellation feature (#1280) 2018-07-20 15:13:37 +01:00
Yeastplume
4a5a41fb30
LMDB Wallet Transaction Log + LMDB Migration for all (#1268)
* beginnings of transaction log for db

* add migrate utility for file-wallet to db wallet

* rustfmt + missing file

* update transaction log entry status on confirmed txs, add basic tests for transaction log
2018-07-19 10:35:36 +01:00
Yeastplume
41e20056d4
db wallet now working identically to file wallet (#1259) 2018-07-13 15:27:16 +01:00
Yeastplume
bacadfb5ab
Wallet API Test Client (#1242)
* beginnings to testclient implementation for more complete wallet API testing

* rework TestWalletClient to be message-based proxy

* test fix

* wallet tests now exercising the API directly as much as possible, capable of instantiating multiple wallets

* test in place to run both file and db wallets

* ensure all wallet api functions lock wallet as needed. Split up transaction creation from posting to chain
2018-07-12 16:49:37 +01:00
Yeastplume
49cbab90f6
WalletClient trait refactor (#1238)
* refactor WalletClient

* revert chain changes

* missing files
2018-07-10 09:18:24 +01:00
Yeastplume
d5a6992be9
Wallet implementation dynamic dispatch (#1235)
* add ability to instantiate wallets with different backend implementations

* test fix
2018-07-09 18:01:19 +01:00
Quentin Le Sceller
dd90aaedbc
Remove unused import and code (#1224)
* Remove unused import and code
2018-07-06 13:40:43 -04:00
Quentin Le Sceller
b5fe22dbd5 Bump to 0.3 (#1225) 2018-07-06 18:29:39 +01:00
Ignotus Peverell
1a410f115c
Cleanup a bunch of build warnings 2018-07-02 00:25:20 +01:00
Yeastplume
d2a84b7600
Error handling improvements (particularly in chain) (#1208)
* update error handling in chain and other modules to use error/errorkind

* sizeshift errorkind
2018-06-30 23:36:38 +01:00
Ignotus Peverell
1398e0bf85
Accept multiple Cuckoo graph sizes (#1193)
* Added sizeshift to proof of work and encoding as VLQ
* Fix some loose ends to get things to compile
* Rename sizehift to min_sizeshift
  * Pipeline checks for PoW Cuckoo Cycle size shift and adjustment
factor before difficulty comparison.
  * Working delta+VLQ encoding of u64 PoW, unfortunately still a
little larger than u32, at least for Cuckoo30.
* Changed binary encoding of proof of work to a sequence of exact
compact bit representation of each nonce. Somewhat simpler,
shorter and matches the data to be hashed.
* Few fixes based on @tromp feedback:
* Max nonce is 2^(N-1)
* Need a separate constant for reference sizeshift
* Cuckoo implementation now conserves sizeshift. Test providing a
block at higher sizeshift.
* Last small overflow protection
2018-06-29 18:41:28 +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
Yeastplume
5ac61b0bc8
fixes to wallet based on testing, ensure details file is being written properly for file wallet (#1204) 2018-06-27 16:57:40 +01:00
Yeastplume
ccf862f76b
T3 Wallet Restore fix and refactor (#1202)
* clean up wallet restore and underlying functions

* rustfmt

* refactor restore
2018-06-26 18:24:40 +01:00
Yeastplume
38a7936521
Use updated bulletproof API (#1194) 2018-06-25 12:28:56 +01:00
yeastplume
a5553ebba5 rustfmt 2018-06-22 14:05:03 +01:00
yeastplume
836d5441e6 fix wallet tests, chain test output 2018-06-22 14:04:51 +01:00
yeastplume
e7c380836b rustfmt 2018-06-22 09:44:38 +01:00
yeastplume
f058b14aea Merge: Compiling at least 2018-06-22 09:33:42 +01: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
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
Yeastplume
9e0b3b6862
Store additional wallet detail and WalletInfo cleanup (#1167)
* adding wallet detail file, clean up wallet info output

* rustfmt

* ensure change outputs aren't written early

* rustfmt

* travis problems AGAIN

* file wallet explicit types
2018-06-14 17:02:05 +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
Yeastplume
05073c5c02
Web wallet api updates (#1155)
* CORS for webwallet

* rustfmt

* automatically start up wallet web api (owner) listener
2018-06-11 18:19:38 +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
Yeastplume
ebee05591b
Factor out wallet communications (#1142)
* move http calls out from libwallet internal

* rustfmt

* start to think about wallet communication traits

* rustfmt

* start of factoring out wallet client trait

* rustfmt

* move node_url trait fn into walletclient

* rustfmt

* comms factored out (with exception of wallet restore)

* rustfmt

* fix test

* rustfmt

* further test fix
2018-06-07 15:04:21 +01:00
Yeastplume
8f66016557
[WIP] Wallet API Structure (#1133)
Wallet API Structure
2018-06-06 15:36:29 +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
Antioch Peverell
0ecadd3486
move verify_kernel_sums into committed trait (#1131) 2018-06-02 19:00:44 +01:00
hashmap
2fa32d15ce Rustify core/src/core (#1122)
Small refactoring of one folder, if it makes sense I could extend the scope.
* Remove some cloning (real and just verbosity in the code)
* Naming conventions like to/into*
* Some Clippy's suggestions

I found that we don't use field init shorthand syntax, so I didn't touch this part, was it discussed before?
2018-06-01 20:41:26 +01:00
Yeastplume
7812a02233
Libwallet refactoring - Library functions + ErrorTypes (#1113)
* move checker and rename to updater

* rustfmt

* complete checker/updater move

* rustfmt

* move libwallet error into separate file

* rustfmt

* starting to sort our error types

* updating errors in libtx and libwallet

* rustfmt

* factor out error type

* rustfmt

* compiling, errors split into libwallet and wallet errors

* rustfmt

* changing user error reporting to new format

* rustfmt

* clean up error types

* clean up error types

* move restore into libwallet

* rustfmt
2018-06-01 15:06:59 +01: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
Yeastplume
1f94bfc038
libwallet refactor context, aggsig, error handling (#1087)
* remove context object from aggsig and transaction libs

* fix to aggsig, and remove unnecessary warnings

* put tx_fee function into libwallet::transaction

* Error cleanup, and creating libwallet error type

* remove some unwraps

* checker bug

* ensure transaction tests checks sender's wallet
2018-05-24 16:27:26 +01:00
Ignotus Peverell
ff5d651b6f
Wallet checker cleanup, remove old unconfirmed outputs (#1084)
Use the standard Rust `chunks` function instead of hand coded
cursors. Add a cleanup function to get rid of old unconfirmed
outputs.
2018-05-24 01:14:34 +01:00
Ignotus Peverell
257b6bf05a
Minor refactor of OutputData mark_* functions 2018-05-22 21:43:41 +01:00
Yeastplume
85285473bd
[WIP] Wallet refactor - part 3 (#1072)
* Beginning to rework aggsig library workflow

* more refactoring of transaction api

* whoever does round 1 first creates offset

* slate finalisation now context-free, so anyone can do it

* remove concept of transaction phase

* remove slate phase enum

* update actual send/receive code with new transaction lib workflow
2018-05-21 16:28:11 +01:00
Yeastplume
4bbaa8d05f
Move aggsig transaction building functions into separate lib (#1061)
* refactoring transaction building code

* serialise return transaction

* move shared functions into transactions, ensure wallet manipulation is only done outside of aggsig transaction lib

* remove unneeded wallet config from fn

* adding test functions to facilitate libwallet transaction testing

* rustfmt

* refactoring checker somewhat, adding ability to create and transactions against local copy of chain for simpler testing

* finish transaction testing functionality which verifies transactions work properly

* Remove wallet output manipulation from transaction building lib

* ensure sender expects full transaction back on last phase

* ensure sender expects full transaction back on last phase
2018-05-16 13:18:09 +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
Antioch Peverell
f90506d869
txhashset extension now implements Committed (#1049)
* txhashset now implements committed for consistency

* rustfmt and cleanup
2018-05-08 10:23:33 -04:00
Antioch Peverell
4dd94ff39e
[testnet2] Store output sum (#1043)
* block sums and reworked block validation
read and write block_sums
refactor validate on both block and txhashset
write block_sum on fast sync
we store the kernel_sum (need to account for the offset)

* block_sums

* rustfmt

* cleanup
2018-05-07 09:21:41 -04:00
Quentin Le Sceller
aa984ed550
Handle locked funds (#1016)
* Handle locked coins
2018-05-01 09:49:00 -04:00
Quentin Le Sceller
f8732d7621
Prioritize and allow no change transaction (#1009)
Prioritize and allow no change transaction
2018-04-27 10:26:40 -04:00
Yeastplume
93b648fbc0
Split wallet server queries into multiple queries + restore performance (#1013)
* mods to speed up restore a bit

* mods to speed up restore a bit

* performance improvements to wallet restore and split large server queries into multiple
2018-04-27 14:16:30 +01:00
Yeastplume
59664181e4
update wallet restore, generate new merkle proof for coinbase outputs (#1008) 2018-04-26 14:01:01 +01:00
Yeastplume
820d55a532
Change wallet retry strategy (and address stratum panic) (#1004)
* remove complex retry from wallet client

* remove complex retry from wallet client

* move retry code to stratum
2018-04-25 16:48:19 +01:00
Severus Sneep
8227ce941a Use a lock-directory- instead of a lock-file- and backup prev wallet.dat. (#982)
It looks like lockfile implementation did still suffer from a race
condition. Only when creating the file with O_EXCL, file creation fails
if the file does already exist. One could use O_EXCL, but Windows
might use another flag to achieve the same. Moreover, O_EXCL doesn't
work as expected if the files are accessed over NFS.
In contrast, mkdir() is atomic in every of the mentioned cases.
Aside from using a lockdirectory, this patch also backups the current
wallet.dat contents to wallet.bck in case writing a possibly hefty
amount of JSON to the new wallet.dat fails. It is hoped that at least
one of the .bck and .dat files has usable contents in case failure.
2018-04-24 20:03:01 +00: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
Quentin Le Sceller
cc9ffcc1ab Remove unused imports (#965) 2018-04-16 21:18:28 +00: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
Yeastplume
dcdf654bc9
[WIP] Core PMMR and API updates to support wallet restore (#950)
* update pmmr to get batch of elements by insertion position

* update pmmr to get batch of elements by insertion position

* add api + chain calls to get traversed outputs back out

* add api + chain calls to get traversed outputs back out

* first pass getting wallet restore to work again with updated utxo-walking api
2018-04-11 10:02:07 +01:00
Simon B
98efaf88df mixed small stuff (#934)
* documentation and spelling
* unused values in tests; just .unwrap()
* unneeded macro_use (router)
* unneeded macro_use and use-imports
* unused value -> .unwrap
* unused variables
* clarify that " is required (see 107ea3c4dd)
* first steps to dig into #933 test_p2p issues
* less simulnet build warnings
2018-04-05 23:31:34 +00:00
Quentin Le Sceller
b4308e9075 Cleans the wallet awaiting confirmation when destination is incorrect. Fix #900 (#902) 2018-03-28 16:36:10 +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
Simon B
a8fc82d8c1 Console debug fixes (#861)
* move some debug! to trace!

* more informative debugs

* standardising on always showing chain tips as "cumulative difficulty @ height [hash]"

* make 2 debug outputs into a single

* "no peers" as warning (not info) to let it stand out more clearly

* move fn param (used only in this one debug line)

* clarify difficulty "units"
2018-03-25 12:41:12 -04: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
675faec05d Change wallet api_listen_port format (#815)
* Change wallet api_listen_port format
* Fix tests
2018-03-22 16:49:27 +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
c02309ce87
Wallet listener and server startup ambiguity fix (#774)
* unify code path for server run and create wallet seed if it doesn't exist

* rustfmt
2018-03-14 18:21:48 +00:00
Antioch Peverell
65633c7611
check_compact retains leaves and roots until parents are pruned (#753)
* wip

* failing test for being too eager when pruning a sibling

* commit

* rustfmt

* [WIP] modified get_shift and get_leaf_shift to account for leaving "pruned but not compacted" leaves in place
Note: this currently breaks check_compact as nothing else is aware of the modified behavior

* rustfmt

* commit

* rustfmt

* basic prune/compact/shift working

* rustfmt

* commit

* rustfmt

* next_pruned_idx working (I think)

* commit

* horizon test uncovered some subtle issues - wip

* rustfmt

* cleanup

* rustfmt

* commit

* cleanup

* cleanup

* commit

* rustfmt

* contains -> binary_search

* rustfmt

* no need for height==0 special case

* wip - works for single compact, 2nd one breaks the mmr hashes

* commit

* rustfmt

* fixed it (needs a lot of cleanup)
we were not traversing all the way up to the peak if we pruned an entire tree
so rm_log and prune list were inconsistent

* multiple compact steps are working
data file not being copmacted currently (still to investigate)

* cleanup store tests

* cleanup

* cleanup up debug

* rustfmt

* take kernel offsets into account when summing kernels and outputs for full txhashset validation
validate chain state pre and post compaction

* rustfmt

* fix wallet refresh (we need block height to be refreshed on non-coinbase outputs)
otherwise we cannot spend them...

* rustfmt
2018-03-13 14:22:34 -04: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
Alexey Miroshkin
9e11afe8a2 Error handling with failure (using Error and ErrorKind) (#713)
* Initial version

* store failure parameters inside ErrorKind variants

* continue failure transformation

* 4 errors left

* still two errors

* return old code back

* finally compiling

* Fix compilation and test errors after merge
2018-02-28 12:56:09 -05:00
Antioch Peverell
4022b82817
cleanup various build warnings (#714)
* cleanup various build warnings

* use serde_json in tests only
2018-02-17 12:56:22 -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
Quentin Le Sceller
06bd78faed Sender pays the fee. Fix #274 (#694) 2018-02-09 05:33:24 +00:00
Yeastplume
92a23ec26d
Allow multiple Aggsig contexts (#685)
* update mean cuda miner to latest trompcode, and added tweakable parameters to grin configuration file

* Added UUID for transactions, and store aggsig contexts indexed by transaction ID

* updating test framework to allow checking of wallet contents during test
2018-02-06 11:42:26 +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
Dean Ancajas
94bba20488 Added INFO when reconnecting to wallet (#662) 2018-01-30 19:44:08 +00:00
Matthew Slipper
d754b8d1e4 Fix #566: serialize commit to hex (#574)
* Fix #566: Use serdes to serialize commit to hex

* Add printable UTXO
2018-01-29 09:36:09 -05: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