* Fix bugs
Fix remote connection fraction calculation (order of operations bug),
remove early return, allow all remote connections to be prohibited,
change disconnect reason to TOO_MANY_PEERS.
* Fix comment
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PAN-1683] Limit the fraction of wire connections initiated by peers
To protect against eclipse attacks, we should not allow all of our wire connections to be initiated from network peers. Some fraction of wire connections should be initiated by our node by connecting to peers in our discovery peer table. This PR ensures the fraction abides the limit.
* change fraction default value and add tests
* make fraction of remote wire connections configurable
- add a cli option to configure the fraction: `--fraction-remote-connections-allowed`
- introduce `Fraction` class to handle the conversion of the CLI option to a double and check if the value is between 0.0 and 1.0
- add tests
- fix broken tests
* remove unused local variable
* fix RunnerTest
* set fraction to 1.0 in PantheonFactoryConfigurationBuilder
* update test
* Introduce --limit-remote-wire-connections-enabled
* fix unused field
* fix conflict
* Update ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/RlpxAgent.java
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
* Update ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/RlpxAgent.java
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
* Update ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/RlpxAgent.java
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
* fix PR discussion and tests
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
EIP-1602 specifies a new validation step. Add hooks for those to occur.
Move contract size checking into the validation hooks.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Initial EIP-1702 versioning code. Version internally is an `int` for Java
reasons. In the future if the versions become sparse or large we will create a
"proxy" version index by putting the standardized indexes into an enum and
using the enum ordinal instead.
Reference tests all pass (hence the WorldStateMock if block) and
GenesisStateTest has an explicit version test now.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* add json rpc method to change the logs without restarting the client
* Update ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/AdminChangeLogLevel.java
change the log level from DEGUB to OFF
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
BlockDataGenerator (a testing util) uses the default key generation code, which
is set to a production grade SecureRandom seed by default. However this creates
non-deterministic results with the block data.
This changes the generator for test data to use a deterministic set of key
pairs.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Add tolerance delta in test. Generated transaction data sizes are sometimes differents, the number of transactions in each batch may vary a bit, the tolerance delta helps dealing with such cases.
The most important thing in this test is the assertion verifying that the union of all batches equals to the original list of messages to send.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Add privacy group id to private transaction
* Update enclave send methods to accept privacy group id
* Update eea sendRawTransaction endpoint
* extract privacy group id from private transaction if present
* extract privateFor/privateFrom if privacy group id is not present
* Fix tests
* Change abstract class invocation to concrete class.
* Utility method to load enclave public key
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Add support for working within Network Address Translation (NAT) environments.
This adds a CLI flag `--nat-method` with two options, `NONE` (the default and
current behavior) and `UPNP.` `--nat-method` will affect what IP address and
ports are advertised via the P2P discovery and other APIs that report the
address and port for P2P actions.
`UPNP` is intended for a typical home or small office environment where a
wireless router or modem provides NAT isolation.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Display World State Sync Progress in Logs
- compute estimated world state completion
- display estimated world state completion in the logs
- `CompleteTaskStep` now have access to a `LongSupplier` to retireve the number of pending requests
- use a `RunnableCounter` to trigger displaying every 1000 requests completed
- only show a new log when the estimation changes
- added test to check the estimation computation
* report using raw ratio rather than percentage
* resolve PR discussion
* rename getTotal to get
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* add dump sub command
* add getBlockHash method for the dump sub command
* Resolve review issues : Add the ability to export multiple blocks, Rename dump command to export command, Improve tests for the export command
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
- Update SyncStatusNodePermissioningProvider to use URI (without discovery port) instead of EnodeURI to allow optimised permission checking of static nodes
- Add EnodeURL.toURIWithoutDiscoveryPort
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Update the reference tests to where they are pre-Istanbul.
One small error in ExtCodeHash is fixed.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Currently when json-rpc and ws services are configured with a port value of 0, the "net_services" endpoint will display their ports as "0". A configured port of "0" actually means "choose a random port". We need to get the actual port that those services are using displayed in the "net_services" JSON-RPC response.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Add nonce too low unit tests to grahql and json-rpc
Also, add all the private transacton failures mappings to graphql
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PIE-1736] Implement incoming transaction messages CLI option as an unstable command.
`--tx-pool-keep-alive-seconds` should be a `-X` option.
- `tx-pool-keep-alive-seconds` is renamed to `incoming-tx-messages-keep-alive-seconds`
- `incoming-tx-messages-keep-alive-seconds` is an unstable command not visible for the user (`--Xincoming-tx-messages-keep-alive-seconds`)
* fix unit test & spotless apply
* use TransactionPoolConfiguration to hold unstable option.
* add tests
* remove unecessary mock stubbing
* spotless apply
* use real builder instead of mock
* remove commented code
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Updated TransactionValidationParams with checkLocalPermissioning flag
* Added TransactionValidationParam to TxProcessor
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Columnated storage to allow for iteration over world state
* change MetricsCategory to PantheonMetricsCategory
* consistency renaming of kvstores
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PAN-2850] Create a transaction pool configuration object
* fix unit test by adding equals and hash code methods
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Add eea_createPrivacyGroup endpoint
* Update orion version
* Fix the failing create privacy group test
* Add eea deletePrivacyGroup API in pantheon
* Update Orion to 1.1.0 release
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PIE-1710] Expose a CLI option to configure the life time of transaction messages.
- add a cli option `--tx-pool-message-keep-alive-seconds`
* rename cli option
* change cli option description
* spotless apply
* Update everything_config.toml
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* use MockitoJUnitRunner to run TransactionsMessageProcessor tests
* implement metrics counter and logging
* (format) replace statement by lambda expression
* (doc) fix javadoc
* spotless apply
* remove modulo and reset step counter to zero
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Add the needed Istanbul configuration options to the genesis file and needed
hooks in the protocol specs for Istanbul.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PIE-1707] Implement a timeout in TransactionMessageProcessor
- `processTransactionsMessage` now takes a `keepAlive` parameter
- don't process the message if expired
- add unit tests
- use a default timeout for transactions (1 minute)
* Update ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionsMessageProcessorTest.java
Co-Authored-By: Nicolas MASSART <NicolasMassart@users.noreply.github.com>
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PAN-2786] Stop Transaction Pool Queue from Growing Unbounded
- use a `ArrayBlockingQueue` with a fixed size to limit the transaction task queue
- expose a method in `MonitoredExecutors` to create a working queue with a maximum capacity
- update `EthScheduler` to use a limited working queue for the `txWorkerExecutor`
* [PAN-2786] Implement a bounded timed queue
- implement a custom bounded queue
- use a time based policy with keep alive configuration
- implement eviction process based on the policy
- add metrics
* use field instead of parameter
* fix PR pass 1
- use concrete class instead of interface
- change metric name to comply with global policy
- update unit test
- wrap `Runnable` into `scheduleTxWorkerTask`
* fix PR
- remove time based policy
- use raw `Runnable`
- make a room for a new element at full capacity
* Update BoundedQueueTest.java
invert condition
* fix PR comments
- remove Mock class
- make logic more thread safe, avoid race condition
- remove element until the new one is accepted
* Update ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthScheduler.java
Co-Authored-By: Adrian Sutton <adrian@symphonious.net>
* spotless apply
* fix nit comments
- use assertj assertions for better readability
- improve unit test
* spotless apply
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* [PAN-2630] Synchronizer should disconnect the sync target peer on invalid block data
- check if headers are sequential
- if sequential, check if they form a chain, if not, disconnect the peer
* update behaviour and add tests
- change checks order
- add log message
- write tests
* disconnect sync target when InvalidBlockException
* remove power mockito
- remove powermockito
- write tests in subclasses of the `AbstractGetHeadersFromPeerTaskTest`
* fix Exception check bug
* fix PR discussion first pass
- add assertion to check when the peer is disconnected
- add assertion to check the peer has not been disonnected
- undo remove final on class
- remove sync target field
* remove spy invocation
* spotlessApply
* shouldDisconnectPeerIfInvalidBlockException
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Add eea_getPrivacyPrecompileAddress API in pantheon
* Return error is privacy is not enabled
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
* Make MetricCategory an interface so it isn't locked into the pantheon specific categories.
* Split categories into StandardMetricCategory and PanteonMetricCategory to separate the common and Pantheon specific categories.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
Query params can be used to adjust the number of peers required and number of blocks tolerance to be considered in sync.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>