Commit graph

643 commits

Author SHA1 Message Date
Eugene P
29fc3e61de Implement fmt::Display for core::Hash 2019-01-10 12:30:10 +03:00
Ignotus Peverell
1806ee34f5
Off by one 2019-01-08 22:43:33 +00:00
Ignotus Peverell
5caddc01db
Enforce zeroing of serialized proof excess bits 2019-01-08 19:18:44 +00:00
Antioch Peverell
27801f6a93
Implement kernel and output features as enums (#2312)
* use enums for kernel and output features

* rustfmt

* add test coverage around deserializing kernel features
2019-01-08 16:07:38 +00:00
Ignotus Peverell
2c5ba853f7
Version bump to 0.5.1 2019-01-07 19:41:07 +00:00
hashmap
3b4492495f
Check if message in slate comes with signature (#2284)
Fixes #2281
2019-01-03 13:05:23 +01:00
Elichai Turkel
f2a29ce37a Optimizing the code and making it more idiomatic (#2269) 2019-01-01 15:29:16 -08:00
Gary Yu
dbf8e97b3f
fix 2 minor build warning (#2260) 2018-12-30 20:03:36 +08:00
Ignotus Peverell
9bf2c7fb5e
Test cleanup 2018-12-29 02:00:44 +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
Gary Yu
45ca7cff79
verify message signature on wallet (#2203)
* add verify_slate_messages for wallet receive

* log the message content

* rustfmt

* verify the sender's message signature when receive_tx in wallet listen

* verify the sender's message signature when send by keybase
2018-12-23 07:25:02 +08:00
Ignotus Peverell
7a52c0ecd5
Revert "Verify features in one place; comment on needed Features enum type (#2191)"
This reverts commit 151aa1c842.
2018-12-22 19:42:07 +00:00
John Tromp
151aa1c842 Verify features in one place; comment on needed Features enum type (#2191) 2018-12-22 10:27:54 -08:00
John Tromp
976bf1dbae Fix secondary scaling bugs; add global::is_mainnet(); use it to change pre-genesis pow type (#2205) 2018-12-22 10:22:36 -08:00
Ignotus Peverell
ecf736d78a
Merge pull request #2196 from mimblewimble/floonet
* Get last bitcon block hash, setup genesis header without PoW (for now)
* More a few properties to mainnet genesis. Don't get too excited, several are placeholders.
* Mine a valid Cuckaroo solution for genesis block
* Use miner as library to get a solution for genesis. Replace final values in genesis.rs before committing it.
* Complete genesis replacement
* Fixed various replacements to obtain a compilable, well-formed genesis
* Check plugin errors, uncomment PoW validation
* Fixes to nonce handling in genesis mining
* Also produce full block hashes
* Fix genesis hash test
* Switch commitments (#2157)
* [Floonet] Use switch commits for all blinding factors (#2178)
* move wallet mods back into dirs
* use switched keys for blinding factor in all cases
* re-implement flag to turn off switch commit derivation
* rename tx log entry field tx_hex -> stored_tx (#2181)
* [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
* Floonet chain type and genesis, testnets cleanup (#2182)
* [Floonet] Encrypt private slate data upon storage in DB (#2189)
* xor encrypt stored nonce and blind sum in transaction data
* stop doc tests splatting wallet files throughout
* Remove bzip2 dependency
* Changed magic number and seeds for Floonet (#2188)
* Genesis generator now loads a local wallet seed to build coinbase.
* Floonet genesis block
* Add floonet to generated grin-server.toml comments
* Test with final Floonet genesis hashes
* Fix get_header_for_output for genesis (#2192)
* start search with min height 0 (#2195)
2018-12-20 18:12:08 -08:00
Ignotus Peverell
5faeeedf65
Test with final Floonet genesis hashes 2018-12-20 21:07:53 +00:00
Ignotus Peverell
84d4777545
Add floonet to generated grin-server.toml comments 2018-12-20 21:04:57 +00:00
Ignotus Peverell
439a3915f6
Floonet genesis block 2018-12-20 20:34:25 +00:00
Ignotus Peverell
a42250445d
Floonet chain type and genesis, testnets cleanup (#2182) 2018-12-18 14:03:55 -08:00
Ignotus Peverell
87d256a318
Utility to automatically generate mainnet genesis block (#2122)
* Get last bitcon block hash, setup genesis header without PoW (for now)

* More a few properties to mainnet genesis. Don't get too excited, several are placeholders.

* Mine a valid Cuckaroo solution for genesis block

* Use miner as library to get a solution for genesis. Replace final values in genesis.rs before committing it.

* Complete genesis replacement

* Fixed various replacements to obtain a compilable, well-formed genesis

* Check plugin errors, uncomment PoW validation

* Fixes to nonce handling in genesis mining

* Also produce full block hashes

* Fix genesis hash test
2018-12-18 11:26:29 -08:00
hashmap
0d44c5405f Make tx weight safer (#2180)
Currently it fails on fuzz tests. Also type conversion to i32 is
dangerous per se
2018-12-18 11:19:19 -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
Yeastplume
230fe191e0
[Floonet] Use switch commits for all blinding factors (#2178)
* move wallet mods back into dirs

* move wallet mod files

* use switched keys for blinding factor in all cases

* rustfmt

* test fix

* test fix

* test fix

* rustfmt

* re-implement flag to turn off switch commit derivation

* rustfmt
2018-12-18 15:44:55 +00:00
jaspervdm
75d2c1cc56 Switch commitments (#2157) 2018-12-18 11:51:44 +00:00
Ignotus Peverell
b2178f5665
Merge branch 'master' into gen_gen 2018-12-16 19:48:05 +00:00
Ignotus Peverell
cb0d09c492
Fix genesis hash test 2018-12-14 22:35:59 +00:00
Ignotus Peverell
052981d596
rustfmt 2018-12-14 22:13:05 +00:00
Ignotus Peverell
a71af7adae
Also produce full block hashes 2018-12-14 22:12:54 +00:00
Ignotus Peverell
80726c7f8f
Fixed various replacements to obtain a compilable, well-formed genesis 2018-12-14 02:56:45 +00:00
Ignotus Peverell
2386ce3b8a
Complete genesis replacement 2018-12-14 00:46:41 +00:00
Antioch Peverell
793e3843f0
HeaderEntry for storing subset of header info in the header MMR (#2137)
* HeaderEntry for storing subset of header info in the header MMR

* cleanup

* cleanup
2018-12-13 09:57:24 +00:00
Ignotus Peverell
18416e8528
Use miner as library to get a solution for genesis. Replace final values in genesis.rs before committing it. 2018-12-13 01:54:25 +00:00
Antioch Peverell
305b36dcce
replace is_mainnet() with !is_testnet() (#2125)
* replace is_mainnet() with !is_testnet()
makes testing "mainnet" code significantly easier (its the default)

* fix next_target_adjustment test based on tromp analysis

* rustfmt

* cleanup wallet db files and add to gitignore

* fix
2018-12-12 16:49:35 +00:00
Antioch Peverell
a0b9aa5967
Sign kernel features (#2104)
* include kernel features in msg being signed
hash the msg before signing it (for consistent 32 bytes)

* rustfmt

* fix various tests

* no HF for this (mainnet only)
2018-12-12 09:19:36 +00:00
Ignotus Peverell
e4ecc30884
Merged upstream 2018-12-11 18:54:44 +00:00
Ignotus Peverell
934b11d06f
More a few properties to mainnet genesis. Don't get too excited, several are placeholders. 2018-12-11 01:07:17 +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
3fdfa0b607
Fixed missing versioned dependency in core 2018-12-07 00:17:35 +00:00
Ignotus Peverell
87bfd9aaa4
Mark all crates as publishable 2018-12-07 00:08:15 +00:00
Ignotus Peverell
ef55b35416
Support for genesis block that includes a coinbase (#2079)
* Chain init now handles genesis body properly, related unit test creating the genesis with reward
* Avoid making block body public by adding a with_reward method
* apply_block in all genesis cases works
2018-12-06 15:38:15 -08: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
Antioch Peverell
bf815aa5cd
Readonly pmmr cleanup (#2083)
* avoid locking txhashset by using a readonly PMMR

* rustfmt
2018-12-05 14:52:53 +00:00
Antioch Peverell
8d8f533b8e
store pmmr cleanup (#2075)
* introduce DataFile<T> to hide the LEN handling
use slices rather than vec<u8> where possible

* cleanup

* use DataFile<Hash> and not HashFile

* fix core tests
2018-12-05 13:02:24 +00:00
antiochp
6a4278c67e
fix 2018-12-05 12:10:27 +00:00
antiochp
fd41b4918e
rustfmt 2018-12-05 10:28:21 +00:00
antiochp
bd771ecbc5
fix txpool double spend edge case 2018-12-05 10:27:46 +00:00
Antioch Peverell
a24d613b05
no need for write lock on txhashset for chain.is_unspent() (#2066)
* no need for write lock on txhashset

* commit
2018-12-03 09:35:40 +00:00
Antioch Peverell
8bad93c8c9
Reduce amount of clone() going on when applying data to MMRs (#2046)
* less cloning when pushing to PMMR

* pass a ref to data when applying to the MMR and appending to the backend

* cleanup

* rustfmt

* fixup tests
2018-12-02 19:59:24 +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
1dffd4df1e
Fix secondary pow scaling bug (#2051)
* fix(es) for #1980

* rustfmt

* skip(1) is height dependent on testnet4
rename for clarity

* rustfmt
2018-11-30 11:19:55 +00:00
Antioch Peverell
f05d3dd920
decouple outputs from output MMR (#2044) 2018-11-29 10:17:44 +00:00
Antioch Peverell
8e62130a7a
decouple kernels from the kernel MMR (#2043) 2018-11-29 10:01:59 +00:00
Ignotus Peverell
e356280841
Quick fix for graph_weight used with AR PoW (#2042) 2018-11-28 20:33:46 -08:00
Ignotus Peverell
28e0d97e64
Cuckatoo size shift upgrade schedule (#2024)
* Cuckatoo size shift upgrade schedule
* Move the schedule into graph_weight instead of messing with min edge bits
* Cleanup and fixes now that we have an agreed upon schedule
2018-11-28 14:05:55 -08:00
Antioch Peverell
7dee490962 Two year secondary pow ratio fix (#2037)
* Tweak (consensus breaking) secondary_pow_ratio
* Look at chain type for sec pow ratio calc (hardfork is t4 only)
2018-11-28 14:05:13 -08:00
Antioch Peverell
79d540cf86
Header MMR Refactor (#2028)
* refactor header MMR to use regular backend
this lets us store header hashes in the mmr data file
the hashes in the hash file are "hash with index"

* rustfmt

* get_header_hash(pos) on header extension

* rustfmt

* cleanup

* cleanup

* comments

* cleanup

* fixup testelem so tests work
2018-11-27 12:32:39 +00:00
Juan Leni
92ac80f0d3 Fixing disabled unit test pow::test::genesis_pow (#1984) 2018-11-27 18:33:58 +08:00
Ignotus Peverell
af595fa0fc
Fix T4 genesis after #1997 2018-11-24 22:50:50 +00:00
Ignotus Peverell
c5b9d867ae
Cuckaroo Testnet4 hard fork (#1997)
* PoW context is now properly picked depending on the chain type,
edge bits and block height. Height const for T4 hard fork leaving
a couple weeks to have miners in place. Removed now unused Cuckoo context.
* Simplified block siphash
* Fix servers crate compilation
* Tiny bit cleaner block siphash. Maybe.
* Cuckatoo min edge bits update for T4 and mainnet
* Fix header size tests, Cuckatoo31 default means one more bit per edge
* Remove redundant param from verify_size
2018-11-24 12:33:17 -08:00
Antioch Peverell
71342d11b1 Tweak input/output/kernel weights (1/21/3) (#2006) 2018-11-24 12:32:08 -08:00
Ignotus Peverell
66acee8f71
Cuckaroo validation implementation (#1911)
* First pass at iterative siphash
* Generalizing our siphash24 implementation slightly to make it friendlier to repeated hashing
* Block siphash algorithm, Cuckaroo placeholder
* Cuckaroo validator, still needs to be tested with vectors from the @tromp implementation
* Working cuckaroo validation with test vectors for cuckaroo19, will add cuckaroo29 vectors when a lean or mean implementation can find some solutions
2018-11-19 11:03:58 -08:00
Antioch Peverell
f0fa410273
Streaming headers (#1989)
* headers msg is now "streamed" off the tcp stream

* rustfmt

* cleanup

* move StreamingReader into ser.rs
extract read_exact out into util crate

* rustfmt
2018-11-16 11:00:39 +00:00
Antioch Peverell
2e421191e2
implement read_multi with an internal iterating reader (#1981)
* rework read_multi to use an "iterating reader" internally
we are going to use this for reading headers in batches

* rustfmt
2018-11-14 14:52:43 +00:00
Yeastplume
5a06f5dac7
Split wallet client trait (#1970)
* complete trait split

* rustfmt
2018-11-13 13:18:33 +01:00
Antioch Peverell
c631b45ab6
cleanup how we deal with flexible rproof size in ser/deser (#1965) 2018-11-13 09:30:40 +00:00
Antioch Peverell
a3c1c6d603
Do not use mem::size_of() when calculating serialized size of data (#1967)
* use FixedLength to define serialized size in bytes of various structs
replace usages of mem::size_of() with ::LEN so we correctly calculate serialized sizes in bytes

* rustfmt
2018-11-13 09:30:02 +00:00
Antioch Peverell
207621b545
Tx kernel entry (#1957)
* Wrap tx kernels in tx kernel entries when storing them in the MMR.
Decouples the storage impl of kernels.

* rustfmt
2018-11-11 16:03:03 +01:00
Antioch Peverell
d0d8d14ac2
cleanup unused compact_transaction code (#1958)
we use a simplified "kernel first" impl
2018-11-11 15:59:05 +01:00
Antioch Peverell
183d9c9f3e
Refactor kernel sig msg creation (#1954)
* refactor kernel msg creation

* rustfmt

* Error not secp::Error

* fix tests for refactored errors
2018-11-10 16:24:11 +01:00
Antioch Peverell
29b2c3384c
refactor secp errors in transaction (#1955)
* cleanup secp errors in transaction

* rustfmt
2018-11-10 15:48:45 +01:00
Gary Yu
9af9ca9518
refactor the state_sync to handle the long fork (#1902)
* split horizon into two explicit values for cut through and txhashset request

* let node which has 2-7 days of history be able to handle forks larger than 2 days

* add test simulate_long_fork

* add pause/resume feature on p2p for tests

* refactor the state_sync

* ignore the test case simulate_long_fork for normal Travis-CI

* refactor function check_txhashset_needed to be shared with body_sync

* fix: state TxHashsetDone should allow header sync
2018-11-10 11:27:52 +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
hashmap
0af1f13bf9 Fix IPV6 address deserialization (#1932)
Fuzz test found that we don't read IPV6 addr (as part of p2p message)
properly. The code is supposed to read 8 dwords, but [0..8] is not a
slice of 8 ints, but a slice of one Range, so we always read just one
dword
2018-11-05 20:38:41 -08:00
Antioch Peverell
d23dec73d0
PMMRable cleanup (#1910)
* cleanup pmmrable and len()
introduce FixedLength trait with a const LEN
make Hash impl FixedLength for consistency

* rustfmt

* store tests cleanup

* rustfmt

* whats going on with those comments and rustfmt?
2018-11-01 20:14:46 +00: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
Antioch Peverell
d51522a9cd Genesis is height 0 (not height 1) (#1896) 2018-10-31 13:24:21 -07:00
Ignotus Peverell
385b385456
Minor block.rs cleanup (#1889) 2018-10-31 13:18:59 -07:00
Ignotus Peverell
0b22789865
Cleanup and minor fixes to core after transaction.rs review (#1854) 2018-10-30 14:09:56 -07: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
bb5392548f
Take 2 2018-10-26 16:28:15 -07:00
Ignotus Peverell
6f3ae4563a
Small test fix 2018-10-26 16:07:12 -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
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
hashmap
3efa7bdac9
Small style changes in core crate (#1816) 2018-10-23 21:09:16 +02:00
Antioch Peverell
38cbd6eafb
full node == fast sync (no full archival guarantees) (#1809)
* wip - fast sync only

* wip

* cleanup

* cleanup

* cleanup comments in default config file around capabilities

* fixup p2p tests
2018-10-23 13:01:19 +01:00
eupn
8f42f7306c feat: remove expired peers from the storage (#1794)
* Initial expired peers removal
* Stop expired peers
* Simplify peer removal and remove only Defunct peers
* Make seed to check for expired peers every hour
* Get rid of unused vector of peers to remove
* Make peer deletion predicate closure immutable
2018-10-22 13:59:40 -07:00
Quentin Le Sceller
5f2e8db092 Fix shift by 1 block in TUI (#1780) (#1810)
* Fix shift by 1 block in TUI (#1780)
* Only use graph_weight
* Fix shift by 1 in block
* Remove debug logging
2018-10-22 10:44:14 -07: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
1cfc474817 forgot to take out assert 2018-10-19 22:21:13 +02: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
John Tromp
b1ebfe1c73 found last few instrances of Difficulty::one 2018-10-18 23:29:32 +02:00
John Tromp
846b38308c replace all Difficulty::one by ::min 2018-10-18 21:18:16 +02:00
John Tromp
41293e9ef7 improve minimum difficulty handling 2018-10-18 20:37:33 +02:00
John Tromp
e24e65399b rename MIN_DIFFICULTY to UNIT_DIFFICULTY; define Difficulty::unit, fix INITIAL_DIFFICULTY 2018-10-18 14:20:00 +02:00
yeastplume
6980278b95 merge T4 into master - rustfmt 2018-10-18 11:23:22 +01:00
Gary Yu
53b10a083c
kick stuck peer out of connected peers. (#1782)
* cherry-picking commit 7754adb8 from master for #1746
2018-10-18 10:04:05 +08:00
Ignotus Peverell
b5cb227322
Last genesis for T4, unless I messed up something 2018-10-17 19:36:12 +00:00
Ignotus Peverell
6db0bcefa5
Minor warning removal 2018-10-17 18:16:20 +00:00
Antioch Peverell
2c5469568f cleanup build warnings (#1773) (#1775)
add docs/comments
2018-10-17 16:53:52 +01:00
Yeastplume
b43d6e4326
[T4] Set genesis block data + initial secondary scaling correctly (#1776)
* ensure genesis block+pre genesis is populated correctly with secondary scaling

* rustfmt
2018-10-17 16:53:31 +01:00
John Tromp
e9dcc143bf refactor and change difficulty calcs; use sum instead of median (#1774) 2018-10-17 16:21:59 +01:00
Yeastplume
5cec885ef5
[T4] diff change (#1769)
* pre-t4 again

* rustfmt
2018-10-17 13:48:18 +01:00
Yeastplume
404165a8fd
[T4] Add sec pow info to TUI, change magic number, genesis diff to 1 (temporarily) (#1768)
* add sec scaling stats to tui

* rustfmt
2018-10-17 10:37:28 +01:00
Antioch Peverell
fbf955dd11
Commit to prev_root in block headers (#1764)
* commit to prev_root in block headers

* prev_root ready to go, mergeable onto testnet4
2018-10-17 10:06:38 +01:00
Ignotus Peverell
fffe5154d2
Secondary PoW scaling factor dampening, cleanup (#1765)
* Remove useless time median window
* Secondary PoW factor dampening
* Fix off-by-one in time window, cleanup dampening, fix tests
2018-10-16 16:55:40 -07: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
Yeastplume
01df981a1d
[t4] fix header test sizes (#1756) 2018-10-16 14:39:51 +01:00
yeastplume
11bed215c1 rustfmt 2018-10-16 13:19:28 +01:00
yeastplume
f38d62287f use secondary pow size for min header size calc 2018-10-16 13:19:09 +01:00
yeastplume
4bb31dbdb4 update new genesis block, change p2p msg magic number 2018-10-16 10:16:54 +01:00
Ignotus Peverell
d0ed5cd4a3
Minor boundary adjustments for 2nd PoW scaling 2018-10-16 00:42:32 +00: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
Ignotus Peverell
3c6b5a0a9c
Fix chain tests missing difficulty scaling 2018-10-15 22:24:13 +00:00
Ignotus Peverell
eeb7680981
Secondary PoW factor adjustment adjustments 2018-10-15 21:18:00 +00:00
John Tromp
45a5655cec obsolete easiness et.al (#1750) 2018-10-15 20:24:36 +01:00
Antioch Peverell
86c1d7683b
The Header MMR (One MMR To Rule Them All) (#1716) (#1747)
* header MMR in use within txhashset itself
works with fast sync
not yet in place for initial header sync

* add the (currently unused) sync_head mmr

* use sync MMR during fast sync
rebuild header MMR after we validate full txhashset after download

* support missing header MMR (rebuild as necessary) for legacy nodes

* rename to HashOnly

* cleanup backend.append()

* simplify vec_backend to match simpler append api
2018-10-15 19:24:01 +01: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
Gary Yu
e9f62b74d5 [T4] change compaction check trigger to 1 day and cut_through_horizon to 1 week (#1721)
* change chain compaction trigger from 2000 to 10080
* change CUT_THROUGH_HORIZON from 2 days to 1 week
* roll the dice to trigger the compaction
2018-10-13 09:34:16 -07:00
Antioch Peverell
4dff68ab61 Remove kernel sum header (#1723)
We maintain this locally in block_sums in the db (sums can be rebuilt from local data)
2018-10-12 18:15:29 -07:00
Ignotus Peverell
805cc24e73
Removed kernel sum from header. Fixes #1568 2018-10-13 00:57:08 +00: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
Yeastplume
92f826a917
[T4 ONLY] T4 PoW changes (#1663)
* T4 PoW changes

* rustfmt

* adjust sizeshift depending on pow type during ser/deser

* update block size tests for cuckatoo sizeshift
2018-10-10 10:09:44 +01:00
Gary Yu
296e912a1f
fix: a missed crate in pow lean test (#1677)
fix: a missed crate in pow lean test
2018-10-07 11:27:35 +08:00
Antioch Peverell
48f9ec61f4
cleanup some build warnings (#1661) 2018-10-05 09:17:57 +01:00
Ignotus Peverell
2259c18dd6 Demo lean miner, minor PoW improvements (#1630) 2018-10-03 11:39:16 +01:00
Yeastplume
e64f4fbcd1
Rust Cuckatoo for verifier and test-miner (#1558)
* cuck placeholder

* rustfmt

* cuckatoo, early days

* rustfmt

* data structures are in place, siphash key creation is consistent with @tromp

* solver in place, (not yet working)

* cuckatoo test solver working with test nonce

* rustfmt

* update solver to remove adjacency list removals

* verifier functioning

* rustfmt

* Proper error handing in Cuckatoo module, couple of tests

* modify cuckoo/cuckatoo solvers and verifiers to function identically, in advance of trait refactoring

* rustfmt

* refactor PoW context into trait, default to using cuckoo context

* rustfmt

* create macros for integer casting/unwraps

* don't instantiate structs when just verifying, add test validation vector for cuckatoo 29

* rustfmt

* don't init cuckoo structs if just validating

* test fix

* ensure BH hashing for POW is only done within miner/validators
2018-09-28 11:53:14 +01:00
Antioch Peverell
acec59e249
introduce rewindable_kernel_view (readonly but rewindable kernel MMR view) (#1587)
* introduce rewindable_kernel_view
cleanup header in extension

* cleanup and docs/comments

* txhashset does not need to be mutable here

* pull validate_kernel_history out into fn
2018-09-26 09:59:00 +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
Gary Yu
8d62247c99 Small cleanup of rand usage (#1576)
Clean 3 build warning of deprecated item 'rand::Rand::rand'
2018-09-24 15:15:55 -07: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
Antioch Peverell
f042f67fcd
Reintroduce block sums, verify full kernel sums per block (#1559)
* block_sums and full kernel sum verification

* rustfmt

* add docs/comments

* docs

* rustfmt

* comment on fact total_kernel_sum is redundant now

* make sure we setup block_sums correctly on a fork

* rustfmt

* replace those asserts with errors

* rustfmt
2018-09-20 09:19:32 +01:00
Ignotus Peverell
7b6e219b5b
Minor: move raw_difficulty to Proof 2018-09-19 18:31:03 +00:00
Ignotus Peverell
9a15859b81
Scaling multiplier fix and slightly clearer structure 2018-09-19 16:25:44 +00:00
Ignotus Peverell
ba72e6e29e
Last fixes that should have been part of #1534 2018-09-19 00:39:56 +00: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
Gary Yu
2c712fefff Small cleanup and perf improvement for peak_sizes_height and peaks (#1526)
* Small cleanup and perf improvement for  and

* rustfmt

* define a const 'ALL_ONES' for u64::MAX
2018-09-15 08:28:41 +01:00
yeastplume
e7eb26eed4 rustfmt 2018-09-14 15:25:07 +01:00
Gary Yu
3c1d8c3f8b Small cleanup and perf improvement for peak_map_height (#1521) 2018-09-13 09:59:49 -07:00
Antioch Peverell
dca0d52dcd
Cleanup transaction with offset (#1514)
* cleanup build::transaction_with_offset

* rustfmt
2018-09-12 12:17:36 +01:00
Antioch Peverell
07eefc4d6b
cache get_shift() and get_leaf_shift() in prune_list (#1495)
* cache shift and leaf_shift values in prune_list for fast lookup later

* rustfmt

* fixup core tests
2018-09-12 08:19:05 +01:00
Ignotus Peverell
a83404b22e
Simplify mining header serialization (#1509) 2018-09-11 20:31:05 -07:00
Antioch Peverell
77c2408c4e
Prevent duplicate output commitments (#1500)
* apply_output checks for duplicate commitment
not just a matching hash

* rustfmt
2018-09-11 19:36:00 +01:00
Ignotus Peverell
ecf20602d5
Hard fork tryout: better PoW encapsulation in block header (#1478)
* Improve encapsulation with ProofOfWork struct
* Add dual pow scaling factor, fix test
* Fix pre_pow serialization, chain tests
* Adjust header serialized size calc
* Hard fork handling, version-based serialization
2018-09-10 15:36:57 -07:00
Antioch Peverell
77765796ab
improve "check known" steps during process_block() (#1475)
* document what we do during pipe::apply_block()

* rustfmt

* wip

* rustfmt

* wip

* additional check_known_store and check_known_mmr checks in process_block

* rustfmt

* cleanup coinbase maturity check in process_block

* consolidate the "check in store" logic
add TODOs around the 50 block OldBlock logic

* rustfmt

* cleanup
2018-09-05 10:51: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
hashmap
0172a3e020 Fix amount parsing (from string) (#1458)
* Fix amount parsing (from string). Fixes #1384
* Add conversion with string padding
* Use string padding
2018-09-03 15:55:04 -04:00
Quentin Le Sceller
544a296f77
Fix typos and unused imports (#1466)
* Fix typos and unused imports
2018-09-03 13:09:28 +02:00
Gary Yu
60d62bfb97 add a test case for transaction deserialize (#1356) (#1381)
* add a test case for transaction deserialize (#1356)
* update rust-secp256k1-zkp to grin_integration_23
* add transaction explicit validation
2018-09-01 15:14:10 -04:00
Gary Yu
d719493483 HeaderSync optimization (#1372) (#1400)
* improve: HeaderSync optimization (#1372)
* remove get_locator() optimization, which should be an independent pr for security review
* refactoring: move 'headers_streaming_body()' from Message to Protocol
* move 2 headers utils functions out of Protocol, and remove 'pub'
* support reading variable size of BlockHeader, from Cuckoo30 to Cuckoo36
* fix: use global::min_sizeshift() instead of hardcoded 30, because Cuckoo10 will be used for AutomatedTesting chain
* fix: should use global::proofsize() instead of hardcoded 42 when calculate serialized_size_of_header
* replace another 42 with global::proofsize()
2018-08-30 19:50:55 -04:00
Antioch Peverell
6d992e61d6 Add test coverage for verifier_cache 2018-08-30 15:08:16 -04: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
bd03528d33
lightweight validation during deserialization (#1422)
* introduce validate_read (for lightweight validation when reading)

* rustfmt
2018-08-26 11:43:44 +01:00
Yeastplume
2251a82404
batch verify proofs during validation (#1412)
* batch verify proofs during validation

* don't attempt to batch verify proofs with empty vec
2018-08-23 18:53:42 +01: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
105bfacaa6
use chrono for timestamp in with_reward (#1406) 2018-08-22 15:40:24 +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
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
Gary Yu
54d3fc0af2 improve: use batch verification for txhashset rangeproof validation (#1321) (#1363)
* improve: use bullet rangeproof batch verification for txhashset validation (#1321)

* update rust-secp256k1-zkp to tag 'grin_integration_22'
2018-08-17 16:18:48 +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
hashmap
37fa413329 Fix small issues found by fuzzing (#1360)
Overage and fee come from the network and may cause overflow if a message was corrupted or crafted to attack a server.
2018-08-15 11:55:25 -07:00
Quentin Le Sceller
6b74cf5098
Unpin croaring to version 0.3.2 (#1352) 2018-08-14 08:28:58 -04:00
Ignotus Peverell
6f590b3f88
Halve max block weight (#1347) 2018-08-13 14:06:53 -07: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
Ignotus Peverell
4be97abbbb
Cleanup max sizes (#1345)
* Transaction max weight expressed in terms of block weight
* Cleaned up max block sizes, so everything is in therms of weight
* Cleanup block max constants
* Rename verify_size -> verify_weight
2018-08-12 13:02:30 -07:00
John Tromp
0d94d35a9d Simplify and optimize MMR routines (#1301)
* add new core mmr routine upon which others should be built more efficiently
* tons of pmmr optimizations and simplifications
* fix typo and extend docs
* change initial spaces to tab to fix indentation
2018-08-11 10:44:56 -07:00
antiochp
fb30b02f99
cleanup verify_weight code 2018-08-10 15:12:53 +01:00
antiochp
5ee11046a5
rework block validation to check input|output|kernel sizes consistently
with tx validation
2018-08-10 15:12:48 +01:00
antiochp
0ff1d86b22
rustfmt on core crate (not run for a while) 2018-08-10 15:00:18 +01: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
Antioch Peverell
983a25248b
call tx.validate() as part of tx.read() (#1334)
and move some validation out of read() and into validate()
2018-08-10 13:57:47 +01:00
Antioch Peverell
9c05471979 Validate resulting tx after aggregation (and deaggregation) (#1331) 2018-08-09 16:37:31 -07:00
hashmap
ae3b1da18b Fix issues found by fuzz test (#1330)
Fuzz test found the folowing issues with reading block header:
* Unbounded cuckou_sizeshift field in Proof
* Different timestamp range after migration to chrono crate
2018-08-09 16:35:46 -07:00
hashmap
32662a0a16 Update fuzz in core crate
Fix compilation error in fuzz code after the wallet refactoring
2018-08-09 11:37:11 +02:00
Antioch Peverell
328d832bd6
cleanup verify_coinbase on block (#1326) 2018-08-08 09:47:30 +01:00
Quentin Le Sceller
3df050cc93 Check content before zip/unzip the txhashset (#1174)
* Check txhashset content before zip/unzip
* Add header in txhashset verification
* Add copy function and test
* Add file util
* Now check and remove unexpected files instead of just crashing
2018-08-02 19:16:16 -07:00
Gary Yu
b040aaa434 Fix: old time crate use 0..11 as the month, make mistake when switching to chrono Utc.ymd (#1304) (#1305) 2018-07-31 09:35:57 -07: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
Antioch Peverell
a6dc48deae
add validation to tx to ensure we have no coinbase outputs or kernels in there (#1266)
* add validation to tx to ensure we have no coinbase outputs or kernels in there

* add some comments
2018-07-16 22:46:36 +01:00
yuntai
ad69dae9e5 Avoid potential 'attempt to add with overflow' panic (#1213) 2018-07-10 22:23:15 +01:00
Ignotus Peverell
34cf6ee3db
Genesis block and new seeds 2018-07-08 18:31:06 +01:00
Antioch Peverell
980378eb65
fix misbehaving simulnet fastsync test (#1227)
* fix misbehaving simulnet fastsync test
cleanup redundant cutoff vs bitmap params is rewind and check_compact

* make sure we do not verify full kernel history on a writeable txhashset extension
rework simulnet simulate_fast_sync test to be more robust

* fixup store tests

* sleep for a bit longer to give nodes time to update
their sync_state correctly

* tweak timing of simulate_block_propagation
2018-07-08 17:37:09 +01:00
Ignotus Peverell
567baa479f
Minor globals cleanup 2018-07-07 22:17:11 +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
Yeastplume
721a22b1c4
Simulnet test fix (#1222)
* remove lower time bound

* simulnet test issue

* re-introduce lower bound

* re-introduce lower bound
2018-07-06 11:42:54 +01:00
Yeastplume
f8cd5cf2a4
Initial block difficulty adjustment + difficulty adjustment scenario modification (#1217)
* Handle SIGINT and SIGTERM (#1180)

* Handle SIGINT and SIGTERM

* pin croaring to version 0.3.2 until we get the clang conflict sorted out (#1183)

* document proposals for - (#1190)

* conditional timelocked outputs, and
* conditional relative timelocked outputs

* problem with validation on rewind

* update difficulty scenarios to display much more data

* correct average sum output

* update pre-genesis block padding to just use previous block's data
2018-07-05 13:18:09 +01:00
Ignotus Peverell
6898b64628
Typo fix in T3 initial difficulty 2018-07-03 22:25:57 +01:00