Fix the proxy’s handling of WebSocket connections when subscribing to contract events and node data using the `eth_subscribe` RPC request.
Previously, the client connection that the subscription data was sent to was often in a closed state. It was determined that this connection was the wrong connection to forward the data in the first place. The connection was in fact generally the connection created for the Ethereum service check which was then (correctly and subsequently) closed after it had finished its operation.
The flow of a proxy request handling a WebSocket “eth_subscribe” RPC request is now as follows:
1. A WebSocket RPC request `”eth_subscribe”` is sent from a client to the proxy.
2. Proxy forwards the request to the node by way of a new instance of `RequestManager`.
3. When the node receives an event matching the subscription, it sends the event data back to same socket connection it received the request on (ie the specific instance of `RequestManager`).
4. The `RequestManager` fires the `”data”` event containing the subscription data, and this event is picked up in the proxy.
5. The proxy then forwards the subscription data on to the originating WS client connection.
All other requests (ie non-WS or WS RPC requests that are not `eth_subscribe`) will be serviced to/from the node using a single `RequestManager` instance.
Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
* Revert "fix(@embark/core): set loglevel back to info"
This reverts commit a03ffd56e5.
* Revert "fix(@embark/proxy): Fix contract event subscriptions"
This reverts commit 173d53de2f.
Fix the proxy’s handling of WebSocket connections when subscribing to contract events and node data using the `eth_subscribe` RPC request.
Previously, the client connection that the subscription data was sent to was often in a closed state. It was determined that this connection was the wrong connection to forward the data in the first place. The connection was in fact generally the connection created for the Ethereum service check which was then (correctly and subsequently) closed after it had finished its operation.
The flow of a proxy request handling a WebSocket “eth_subscribe” RPC request is now as follows:
1. A WebSocket RPC request `”eth_subscribe”` is sent from a client to the proxy.
2. Proxy forwards the request to the node by way of a new instance of `RequestManager`.
3. When the node receives an event matching the subscription, it sends the event data back to same socket connection it received the request on (ie the specific instance of `RequestManager`).
4. The `RequestManager` fires the `”data”` event containing the subscription data, and this event is picked up in the proxy.
5. The proxy then forwards the subscription data on to the originating WS client connection.
All other requests (ie non-WS or WS RPC requests that are not `eth_subscribe`) will be serviced to/from the node using a single `RequestManager` instance.
Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
Running embark's `blockchain` command resulted in a runtime error where the `blockchain`
module couldn't be found. This is a bug introduced in ed0d3afb4f where
we forgot to update `blockchainStackComponents` in Embark's engine accordingly.
Fixing this results in `embark blockchain` hanging. This is because there's a similar bug
in `blockchainStackCopmnonents` introduced in 3b8f8f9ea7.
This commit fixes both bugs by ensuring `embark-blockchain` and `embark-blockchain-client`
packages are loaded using the correct APIs.
If the version in the embark package's own `package.json` has a prerelease
identifier then appending `.x` to the major version isn't viable for resolving
the latest version of the template package that's in the same prerelease line;
a more complex semver range must be used:
```
"${pkg}@^${major}.${minor}.${patch}- <${major}.${minor}.${patch}"
```
When making use of the `useBuiltIns: 'usage'` option for @babel/preset-env
(which is the case for all transpiled packages in Embark's monorepo) a package
needs to have both @babel/runtime-corejs3 and core-js@3 specified as
dependencies.
Embark relies on certain specific plugin properties, e.g. registered compilers,
and retrieves them using `plugins.getPluginProperties('compilers', 'compilers')`.
In order to make this work in the testing environment, we need those same APIs
in the `embark-testing` package as well.
This commit adds necessary APIs to `Plugins` and `Plugin` to make registering and
loading compiler plugins work.
* build(deps): move deps needed by embark-basic-pipeline from packages/embark
Introduce additional refactors to ensure the packages can be resolved by the
basic pipeline's webpack child process.
* build(deps): move @types/os-locale from packages/embark to packages/core/i18n
* build(deps) move @types/globule from packages/embark to packages/plugins/coverage
* build(deps): refactor stack/{api,proxy,webserver} deps relative to packages/embark
* build(deps): remove unneeded @types/async dep from packages/stack/test-runner
* build(deps): remove unneeded deps from packages/embark
* build(deps): upgrade create-react-app for cockpit by bumping react-scripts to latest
Also get rid of a peer dependency warning related to storybook. After some
investigation it seems that storybook can't practically (at present) be made
aware of CRA in the same project satisfying storybook's peer deps, so it's best
to just satisfy all of them explicitly, which in any case won't interfere with
CRA (react-scripts).
* build(deps): move @types/os-locale from packages/embark to packages/core/i18n
* build(deps) move @types/globule from packages/embark to packages/plugins/coverage
* build(deps): refactor stack/{api,proxy,webserver} deps relative to packages/embark
* build(deps): remove unneeded @types/async dep from packages/stack/test-runner
* build(deps): remove unneeded deps from packages/embark
Introduce some light refactoring related to embark-testing facilities, and also
a configurable stdout option so the output of the reporter implemented in this
package isn't confusingly mixed into unit test reporting for this package.
BREAKING CHANGE:
node: >=10.17.0 <12.0.0
npm: >=6.11.3
yarn: >=1.19.1
node v10.17.0 is the latest in the 10.x series and is still in the Active LTS
lifecycle. Embark is still not compatible with node's 12.x and 13.x
series (because of some dependencies), otherwise it would probably make sense
to bump our minimum supported node version all the way to the most recent 12.x
release.
npm v6.11.3 is the version that's bundled with node v10.17.0.
yarn v1.19.1 is the most recent version as of the time node v10.17.0 was
released.
* refactor(@embark/dapps/tests/app): use function syntax
These changes don't fix the race conditions related to the test dapp's tests
but are a step in the right direction.
* refactor(@embark/dapps/tests/contracts): adjustments to get tests passing
Further refactoring is needed re: potentially duplicated or overlapping logic
in `packages/plugins/solidity-tests` and
`packages/core/utils/src/solidity/remapImports.ts`, as well in disabled test
dapp tests
* test(dapps/tests/app): temporarily disable intermittently failing tests
They are failing because of a race condition; once that race condition has been
fixed these tests should be reenabled.
* fix(@embark/solidity-tests): fix importing the library for the tests
* build(@embark/stack/blockchain-client): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(embark): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/ethereum-blockchain-client): remove unneeded typescript related scripts, deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/ganache): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/geth): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* fix(@embark/plugins/transaction-logger): require 'web3' not 'Web3'
* fix(@embark/utils/solo): spawn npm(.cmd) instead of npx(.cmd)
* test(@embark/plugins/basic-pipeline): add test stub
* test(@embark/stack/blockchain): add test stub
Fix a lot of bugs and reenable a couple of modules
Some tests were kept disabled, mostly the ENS and EmbarkJS tests
Those need to add back a fairly significant feature to work
Add back missing solidity contracts
In d6bf5c24b9 we've ensured that certain modules of
embark only executed if their functionality is actually enabled.
This broke one of our tests in the communication module.
This commit fixes the test by explicitly enabling the module's functionality.
* fix: fix tests hanging because the console is not started
* fix(@embark/proxy): send back errors correctly to the client
Code originally by @emizzle and fixed by me
* feat(@embark/test-runner): add assert.reverts to test reverts
* fix: make test app actually run its test and not hang
* fix(@embark/proxy): fix listening to contract event in the proxy
* feat(@embark/test-runner): add assertion for events being triggered
* docs(@embark/site): add docs for the new assert functions
* feat(@embark/test-runner): add increaseTime util function to globals
* docs(@embark/site): add docs for increaseTime
Contains bug fixes to get parity to work as a blockchain client.
**NOTE:** Please merge https://github.com/embark-framework/embark/pull/1950 first before merging this PR, as this PR contains removal of dependencies from `packages/embark` that are needed for geth. So if this is merged first, and the geth PR (https://github.com/embark-framework/embark/pull/1950) is not merged, then geth will not have some of the dependencies it needs.
**NOTE:** Running a dapp with `client: “vm”` does not work, however I am not sure if that is intentional in v5 or not.
**NOTE:** Running `embark test` in the demo DApp does work, although there is an error that I am assuming does actually pertain to this PR:
```
made request without listener: whisper:node:register
Trace:
at EmbarkEmitter.trace [as request] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/events.js:142:13)
at new request (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/modules/geth/index.js:49:17)
at Plugin.loadInternalPlugin (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/plugin.js:117:10)
at Plugins.loadInternalPlugin (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/plugins.js:96:40)
at Engine.loadInternalPlugin [as registerModule] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:69:18)
at Engine.registerModule [as blockchainComponents] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:183:10)
at Engine.apply [as registerModuleGroup] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:104:18)
at registerModuleGroup (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/cmd/cmd_controller.js:740:16)
at nextTask (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:5324:14)
at next (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:5331:9)
at /Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:969:16
at callback (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:47:9)
at Client.done (/Users/emizzle/Code/__Github/embk-fw/embark/packages/core/core/src/ipc.js:46:11)
at Client.emit (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/event-pubsub/es5.js:74:21)
at Socket.connectionClosed (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/node-ipc/dao/client.js:201:20)
at Socket.emit (events.js:198:13)
```
**TODO:** The `embark eject-webpack` command needs to be updated. @michaelsbradleyjr - do you have suggestions as to how we could port this over? We could **assume** that the `basic-pipeline` plugin will be installed, and then read the embark config and overrides from the file system, however this feels like we are sort adding a dependency to a plugin, which is not right. Any suggestions?
* bugfix(@embark/embark): fix default values so choosing different environment doesn't cause hang
* bugfix(@embark/stack/watcher): add callback so initializating watcher does not hang cmd controller
Change components/TexEditor re: how monaco-editor is loaded, since difficulties
with monaco-editor were the original motivation for "ejecting" the CRA setup.
Specify "nohoist" for `embark-ui/react-scripts` and all its dependencies to
avoid potential headaches when upgrading the react-scripts, i.e. upgrading to
newer versions of create-react-app.
It's principal use was in `stack/compiler`, but that package was refactored
in #1878 to use async/await. There was a replica in
`packages/embark/src/lib/utils/async_extend.js` but it wasn't being used to do
async operations and could be replaced with `Object.entries().forEach()`. It
was required by `plugins/vyper` but the wrapper's custom `eachObject` method
wasn't being used. `stack/api` had it as a dependency but wasn't using it.