* first pass at allow/deny lists for hard-coded peers (not just seeds)
* commit
* add peers_allow and peers_deny examples and comments to grin.toml
* fix build issue with simulnet tests
* fix p2p tests
* [wip] header first propagation
successfully propagating headers (unless we mined the block itself)
not yet asking for the block if we receive a header
* call request_block after successful processing header
* cleanup and skip asking for block if header is an orphan
* comments around error handling in receive_header
* 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
* Making initial sync easier on the eyes:
- display "chain pointers" as: cumulative @ height [hash]
- clarify and line up to make the "pointers" easy to compare
- make every 100th block show info on debug level info, else as before
* Change name of get_peer to get_connected_peer and add a get_peer method with store
* Change to get_connected_peer
* Added handler for GET peers/a.b.c.d
* Add term and grin_p2p for grin client
* Setting msg as public for the client
* Specifying binary for cargo build
* Minimal client implementation
* Using server configuration for the client
* Display current chain height
* Display difficulty and last block pushed
* Remove unneeded secp256k1 dependency
* distinguish select (among futures) from select coins. Regex search in project for select\b shows we hardly use select, but maybe could use it to add timeouts more cleanly. ("Want to add a timeout to any future? Just do a select of that future and a timeout future!" from https://aturon.github.io/blog/2016/08/11/futures/)
* remove a trailing space
* FAQ.md - fix typo
* wallet: display problematic tx
* update FAQ build troubleshooting to cover #443
* stdout_log_level = Info
file_log_level = Debug
* sync: show total diff @ height when syncronization is completed
* better wallet send dest format error
* move INFO "Client conn ... lost" and "Connected to peer" down to Debug
* move some level=Info to Debug, add 1000-block outputs
* timeout connection already tracks "expected" responses
use this to deduplicate requests and do not ask a peer for the same thing again
(until either success or timeout)
* do not ask for orphan blocks repeatedly
allow more than preferred number of peers (clean if we exceed max number)
Moved handling to the peer map out of the p2p server and into
its own struct. Allowed factoring code from the net adapter and
simplification of some interactions. Also removes the need for
the adapter to reference the p2p server or peers.
Fixes#430, #453 and #456
* 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
* introduce cpu_pool to read_msg
* cleanup and less unwrap() in handler
* expose cpu_pool as part of net_adapter (reuse across all peer connections and handlers)
* fix DummyAdaptor for test usage
* add new() to DummyAdapter for convenience
* Alleviate slog-async channel overflow by shortening while clarifying some log lines.
* add debug logging to GetBlock handling
* make another log line less rendudantly chatty
* DRY up
* iterate 66% less
* clarify debug! outputs
* less verbose peer queuing
Rationale: debug outputs that happen _a lot_ is nice if they're short and distinct, making them easier to pattern match / willfully ignore while reading through logs
* update comment to mention last weeks' added usecases
* .push() less
* [WIP] aggressive peer connections (and logging)
* get peer list from each connected peer when low on peers
* cleanup the try_read() calls and log consistent warning messages
(will clean these up later)
* cleanup error logging (log at debug level)
* simplify sync process further - one thread, try_read on peer for robustness
* add most_work_peers() for convenience, add most_work_peers count to "monitoring peers" log msg
Added support for peer banning on the p2p server. The peer status
is changed and the peer is disconnected. A banned peer won't be
able to reconnect as well.
Tracking of chain errors due to a block that's intrinsically bad
and banning of the peer that sent it. If we're syncing, resetting
the header chain to the same as the main chain to force
backtracking.
* port across "simple_sync" changes from testnet1 branch
Cleanup direct refs to peer map or peer store
P2P server acts as a facade, handling the list of connected peers
and the storage of their information. Everything else goes through
the p2p server instead of having a peer map reference or going
straight to the store.
Fix p2p tests
* fix "monitoring peers" log msg (use connected_peers)
* add total_diff to ping/pong msgs
debug log for total_diff on each ping/pong
* expose peer addr to the handle_payload fn
so we know where it came from
* fix p2p tests for ping
* default to 0 if we cannot read total_difficulty
* updating a connected peer in place
* actually update peer info diff
* fixup p2p tests
* use a short timeout when opening the connection to possible peers
lots of peers in the db are unavailable and we do not want to wait 60s for these
* also randomize peers so we don't always try and connect to peers with low ip addresses
* bump timeout up to 5s for peering
Likely issue is the connection failed right after being
established, leading `peer_addr()` to fail and the `unwrap()`
crashes the process instead of failing gracefully. Fix#293.
* use HashMap internally for tracking connected peers (to avoid duplicates)
* reuse the handshake on the server so we can track our own nonce to avoid self connections correctly
* make sure we start up the clean_peers loop even in seedless mode
* logging in monitoring peers loop
* simplify monitoring for no seeds
* fixup and cleanup simulnet tests (real seeds in places)
* only start the sync if we have either seeds or peers that we know about, exit syncer safely if we have no connected peers
A receiving peer trusts the address advertised by a client.
However as we do not have external address detection (and there is
generally no very good way to do that), the address detected by
a peer is the loopback, which is useless. So we attempt to detect
these cases and use the IP detected by the TCP connection while
keeping the advertised port.
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.
* Do not send txs and blocks to senders. Keeps a ring buffer of transaction and blocks hashes that a peer has received. Do not send what we've already received.
* Test fix and fmt
* 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
* 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
* 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
* 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()
Introduce a new Chain struct that maintains the current head,
acts as facade to the store and the block processing pipeline
and handles all appropriate locking.
All higher level components, like the overall server, REST APIs
and miner have been update to only depend on Chain. Cleaned up
some duplication and tests now that there's a single entry point
to all blockchain operations.
Most of the logic to build a transaction that sends coin to
another party. Still requires more debugging and clean up.
Main changes and additions are:
* Update to serde 1.0
* API endpoint to retrieve an Output
* Output is now Serialize and Deserialize
* Wallet configuration
* Command line for the send operation
* Wallet data checker to update created outputs into confirmed
* Wallet-specific configuration
* Sample Signatures for put_enc and get_dec
* Implement put_enc and get_dec
* Implement ChainCodec in grin_chain
* Truncate src only on complete Blocks
* Truncate src only on complete Tip + Check Len
* Move BlockHeader Encoding to BlockHeaderCodec
* Define put_enc for store::Batch
* Replace BlockCodec and BlockHeaderCodec with generic BlockCodec<T>
* Implement Default for BlockCodec Manually
* Replace get_ser/put_ser with get_enc/get_dec for chain::ChainKVStore
* Remove Writeable/Readable for chain::Tip
* Add Tokio-io and Bytes to grin_p2p
* Additional Setup for Message enum + Msg{Encode,Decode} traits
* base msg ping pong encoding and test
* fill out msg-codec tests
* Implement Hand Encoding/Decoding
* msg-encode shake
* msg-encode getpeeraddr
* codec peer-addrs message, SockAddr struct wierdness
* header message codec
* msg encoding finished prelim
* Implement PeerCodec Encoding/Decoding
* Set PeerStore to use PeerCodec for Encoding/Decoding
* Add a DecIterator
* Prune PeerStore
* Replace Decoding and Encoding in handle_payload
* Prune Writeable/Readable methods in store::Store
* Remove Incomplete Frame Testing ( Not Nessesary right now )
* separate block and tx codec tests
* Refactor {Tx,Block}Codec Tests
Adds a couple utility function to p2p server to check whether
we're already connected to a peer before trying again. Other
very minor fixes and logging improvements.
Moved error and configuration types from server.rs to types.rs
where they should have been from the start. Configuration types
for the server and p2p modules now derive serde Serialize and
Deserialize so we can have a simple JSON configuration file.
* core: cleanup slicing impls for Hash
* core: clean up Readable trait, implement Readable/Writeable for various integers
* core: change Hash debug output to hex
* core: correct warnings in all modules
* Replace AsFixedBytes with Sized + AsRef<[u8]>
* Add AsRef<u8> to impl_array_newtype!
* Include AsFixedBytes as marker trait
* Related fixes
* Remove Deref
Block, Output and Kernel now have bitmasks to hold supported
features and eventually versioning. Will make adding features and
updates easier and open the possibility of soft forks.
First added feature for Output and Kernel is the marking of coinbase
related ones. Allows the validation of the coinbase part of a block.