Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved consistency of external APIs #918

Merged
merged 15 commits into from Sep 22, 2020

Conversation

jalextowle
Copy link
Contributor

@jalextowle jalextowle commented Sep 4, 2020

  • Implements an ApolloLink subclass that allows browser nodes to support most GraphQL endpoints. Subscriptions and raw queries are excluded from this PR.
  • Change GetOrders to FindOrders in several files.

Small Changes

  • Fixed a bug in the integration tests that would cause us not to fail tests due to browser errors.

@jalextowle jalextowle force-pushed the feature/improve-consistency-of-external-apis branch 2 times, most recently from 49b22d9 to 9d60e4b Compare September 4, 2020 21:31
@jalextowle jalextowle force-pushed the feature/improve-consistency-of-external-apis branch from 3463c37 to 60a24fc Compare September 17, 2020 16:41
@jalextowle jalextowle marked this pull request as ready for review September 17, 2020 17:09
@jalextowle jalextowle changed the title [WIP] Improved consistency of external APIs Improved consistency of external APIs Sep 17, 2020
Copy link
Contributor

@z2trillion z2trillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this usage predates this PR, but on file lines that you touch, can you use the ? operator instead of if x !== undefined ...?

packages/mesh-browser-lite/src/mesh.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@recmo recmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}
res := resTmp.([]string)
fc.Result = res
return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange unicode characters here, but the same happens in some other functions, so not caused by this PR. Still, what's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's part of graphql generation. I'm not completely sure what these replacements mean and why unicode is being used, but I did find an instance where they are using these unicode characters during codegen: https://github.com/99designs/gqlgen/blob/f4669ba9b54cdda6340c6e0c16d05eff2ee4fa21/codegen/templates/templates.go#L232.

@jalextowle jalextowle merged commit cf7e6fe into development Sep 22, 2020
jalextowle added a commit that referenced this pull request Sep 23, 2020
* Addressed minor comments from the last release PR (#817)

* Upgrade Mesh to Go 1.14 (#815)

* Made changes necessary for native binaries to build

* Document go-ethereum dependecy

* Got go tests to pass

* Updated geth fork to get some wasm tests to pass

* Fixed some build errors and tests

* Documented the `goleveldb` dependency

* Updated goleveldb and go-ws-transport

* All WebAssembly tests are now passing -- with the wrong `wasm_exec.ts`

* Update CI and dockerfiles

* Fix go linting errors

* Fix linting in CI

* Remove vendor step in CI to try to fix linting issues

* Documented the change in vendoring in CI

* Updated goleveldb dep after switching to `IsUndefined` and `IsNull`

* Updated go-ws-transport after switching to `IsUndefined`

* Switched to `IsUndefined` and `IsNull`

* Updated changelog

* Reverted some unnecessary changes

* Moved `allowJs` into `@0x/mesh-browser-lite`'s `tsconfig.json`

* Update to typescript `3.9.3`

* Update geth dependency

* Update `parseTopics` to use the new version from geth

* Addressed review feedback from @albrow

* Updated geth again

* Updated geth another time

* Fixed `wasm_exec.js` after rebase

* Changes to deps after rebuilding

* Updated the contributing guide

* Updated webpack-example dependendencies

* Fixed small inconsistency in contributing guide

* Improves the DevEx of working on Typescript (#818)

* Adjust the way that local dependencies are linked

* Improved `yarn clean`

* Added `prettier` to Mesh

* Updated cut-release script

* Build dependencies automatically when building a single package

* Make browser integration tests more effecient

* Update CONTRIBUTING.md

* Add some files to .prettierignore

* Change tsconfig for two examples to output to lib

* Add note to CONTRIBUTING.md about TSLint configuration

* Remove  from package.json

* Fixed nits

* Remove `$PKG`

* Fix tsc -b at the root of the project

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* Big database upgrade (#793)

* Strip out all existing database code

* rename meshdb package to db

* Implement first db tests for adding/finding orders

* Add basic support for Orders and MiniHeaders

* Implement and test UpdateOrder

* Implement sorting orders

* Imlpement and test limit and offset

* Implement and test filters for finding orders

* Add fields for parsed MakerAssetData and MakerFeeAssetData

* Add test cases for filtering based on parsed maker asset data

* Implement and test helper methods for filtering based on parsed asset data

* Rename some FilterOpts fields

* Remove unneeded quotes

* Add OF prefix to OrderField constants

* Implement and test MiniHeaders query options

* Implement and test deleting orders with a filter

* Implement and test DeleteOrder

* Refactor db package to use common/types

* Implement and test deleting miniHeaders. Adjust implementation of DeleteOrders

* Update all types. Fix build

* Automatically remove miniHeaders above retention limit

* Add new options for database to configure max mini headers

* Get all blockwatch tests passing 😄

* Add new db options

* Implement and test CountOrders

* Begin fixing some bugs in order watcher tests

* Uncomment all remaining orderwatcher tests (except max expiration)

* Implement and test metadata methods

* Fix bug in sqltypes.BigInt. Get ratelimit tests passing

* Fix some additional tests and unimplemented methods in core

* Implement core.GetStats. Move data dir for most integration tests to /tmp

* Implement new getOrders RPC endpoint

* Re-enable ordersync tests

* Remove expirationwatch package

* Return db.ErrNotFound where appropriate. Remove old TODOs

* Set up basic skeleton for Dexie.js implementation

* Implement most order methods in Dexie.js

Not implemented:

- Query filters
- Multiple sort parameters

* Fix bugs and add support for order queries with one filter

* Add support for multiple filters

* Use checkOrderQuery function for both Dexie and SQL

* Fix bug in SQL implementation involving big numbers

* Add support for multiple sort values in Dexie

* Implement AddMiniHeaders in Dexie

* Implement remaining MiniHeaders methods in Dexie

* Implement Metadata methods in Dexie

* Fix failing TypeScript and Wasm tests

* Fix some build issues

* Fix bug in OrderWatcher

* Fix failing conversion tests

* Fix any remaining failing tests

* Fix linter errors

* Fix build errors

* Update yarn.lock

* Add backwards compatibility layer for FilteredPaginationSubprotocol

* Re-use existing asset data decoder from orderwatcher

* Remove remaining uses of goleveldb

* Improve handling of db closed error

* Rename some identifiers

* Address some low hanging TODOs

* De-dupe and refactor DB test cases

* Change how context is passed in to core.App

* Add missing exit 0 to some clean commands

* Address remaining TODOs in sql_implementation

* Address remaining TODOs in database.ts

* Address remaining TODOs in order_watcher.go

* Minor changes and cleanup

* Fix yarn.lock

* Respond to PR feedback

* Fix bug in database.ts

* Address remaining PR feedback

* Address third round PR feedback

* Address review feedback part 4

* Fix linter

* Add benchmark for ValidateOrder (#819)

* Optimize InefficientlyConvertToJS (#820)

* Optmimize jsutil.InefficientlyConvertToJS

* Add missing build tag

* Update go.mod and go.sum

* Updated `prettier` to include all markdown files (#830)

* Updated `prettier` to ignore all markdown files

* Start running `prettier` on markdown

* Removed `RELEASE_CHANGELOG.md` generation

* Updated logrus dependency (#834)

* Add workaround for Dexie transaction-related errors (#835)

* Increased the `ratelimiter` tolerance (#836)

* Re-implement dynamic max expiration time (#832)

* Implement removing orders with longest expiration time in SQL

* Implement removing orders with longest expiration time in Dexie

* Implement first pass of setting max expiration time in orderwatcher

* Consider pinned orders correctly regarding max expiration time

* Tweak max expiration time behavior

* Add test for GetCurrentMaxExpirationTime

* Simplify implementation by removing slowCounter and calculating max exp time as needed

* Add clarifying comment

* Account for pinned orders in meshSpecificOrderValidation

* Slightly simplify orderwatch.Watcher.add based on PR feedback

* Include pinned order in TestOrderWatcherDecreaseExpirationTime

* Optimize FindMiniHeaders by using gob encoding for event logs (#840)

* Optimize FindMiniHeaders by using gob encoding for event logs

* Add test for MiniHeaderToCommonType and MiniHeaderFromCommonType

* Rename a variable

* Update mesh.ts (#842)

Fix issue where initial query for orderInfos can come back empty.

* Add prettier step to `make cut-release` (#845)

* Fixed small bug in the ws rpc client (#847)

* Directly compute packed length of RPC call (#846)

* Add computeOptimalChunkSizes benchmark

* computeABIEncodedSignedOrderByteLength without ABI encoding

* Move unused code to tests

* fmt

* Requested changes

* More requested changes

Co-authored-by: Mason Liang <mason@0x.org>

* Update TypeScript compiler target to es2016 (#850)

* Cleanup TypeScript packages (#851)

* Rename all packages/ directories to match package name

* Audit all dependencies vs. devDependencies

* Fix doc generation for browser and browser-lite

* Update removedChecker to use countInterval (#839)

* Update removedChecker to use countInterval

* gofmt

* Requested changes

* Revert using errgroup

Co-authored-by: Mason Liang <mason@0x.org>

* Parallelize requesting from peers in `ordersync` (#848)

* Parallelized part of `GetOrders`

* Added an inner context to cut `getOrdersFromPeer` short

* Refactored ordersync to request from a new peer as soon as possible

* Improved ordersync `GetOrders` slightly

* Adjusted `maxPeersInParallel`

* Addressed review feedback from @albrow

* Switched to `sync.RWMutex`

* Addressed lingering review feedback from @albrow

* Store order validation block (#853)

* Add support for storing block metadata for orders in db package

* Set block metadata for orders in order_watcher

* Improve tests for setting last validated block

* Add new fields to Order in database.ts

* Use errgroup (#852)

* Use errgroup

* Fixed data race

* SyncToLatestBlock to prevent race at cleanup

* Re-add logging for errors

* gofmt

* Remove now unneeded SyncToLatestBlock

* Add loop name to logging output

* Use correct names

* Add pointer to golang faq

Co-authored-by: Mason Liang <mason@0x.org>
Co-authored-by: Alex Towle <jalextowle@gmail.com>

* Simplify unexpiration logic in convertValidationResultsIntoOrderEvents (#856)

* Name and use isOrderUnexpired

* Use newFillableAmount

* Replace nil with newFillableAmount

* Consolidate checks for rewatchOrder

* Remove checks that are always true

* Move database updates into unexpiration check

* Rename to timeStampIsValid and remove unneeded check

* typos

* time stamp -> timestamp and correct comment

* Clarify comment

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* fix typo

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* Remove unused private function

* Remove nil check for non-nil argument

* Rename function

* Re-add comments

* Rename to expirationTimeIsValid

* Expand comment

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

Co-authored-by: Mason Liang <mason@0x.org>
Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* In-Memory Blockwatcher Syncing (#857)

* Added simplestack back to Mesh

* Use an in-memory stack for blockwatcher syncing

* Addressed review feedback from @albrow

* Simplified `getSubBlockRanges` in `ethereum/blockwatcher`

* Light refactors of the blockwatcher

* Addressed review feedback from @z2trillion

* Addressed review feedback from @albrow

* Revert "Light refactors of the blockwatcher"

This reverts commit 63caae9.

* Addressed lingering review feedback from @albrow

* Fix database is locked error (#873)

* Fix database is locked error

* Fix typo

* fix: Wait for high quality peers to fully respond during ordersync (#874)

* Added logs to ordersync

* Added more debugging logic

* Implemented fix to ordersync

* Removed logs and clarified some logic

* Addressed offline review feedback from @albrow

* Addressed review feedback from @z2trillion and @albrow

* fix: Mark an ordersync that yields zero orders unsuccessful (#875)

* Fixed an issue with `getOrdersFromPeer`

* Addressed review feedback from @albrow

* Address the missing order events edge case (#863)

* Added test for missing order events edge case

* Refactored `handleBlockEvents` in anticipation of the fix

* Attempted to fix the missing order events bug

* Minor refactors

* Got the test to pass

* Added another test for the missing block events fix

* Cleaned up the orderwatcher tests

* Added checks for missing events on startup

* Placate the linter

* Addressed review feedback from @albrow and @z2trillion

* Remove unnecessary `RLock` in `ValidateAndStoreValidOrders`

* Fixed a bug with order unexpiry

* Added the ability to track the progress of ordersyncing with peers (#877)

* Added the ability to track the progress of ordersyncing with peers

* Addressed review feedback from @albrow

* Check for already stored orders in a single batch (#878)

* Check for already stored orders in a single batch

* Use new method in orderwatcher

* Change return value for GetOrderStatuses to include fillable amount

* Implement GetOrderStatuses in SQL; Update log levels

* Made `MaxBytesPerSecond` configurable for standalone nodes (#879)

* Made `MaxBytesPerSecond` configurable for standalone nodes

* Made `MaxBytesPerSecond` configurable for browser nodes

* Fixed browser conversion tests for config with `MaxBytesPerSecond`

* Bump default of `MAX_BYTES_PER_SECOND` to 5MiB throughout the codebase

* Fix outdated comments

* Don't log about missing events if 0 blocks have elapsed (#880)

* Don't emit STOPPED_WATCHING events for orders that were already stored (#881)

* update drone configuration (#876)

* Optimize GetOrderStatuses by using getBulk (#883)

* Fixed bug in ordersync that caused nodes to use the wrong orderfilter (#882)

* Fixed bug in ordersync that caused nodes to use the wrong orderfilter

* Added changelog entry

* Addressed review feedback from @albrow

* Refactored first request generation in ordersync

* Fixed backwards compatability issue

* Addressed lingering review feedback from @albrow

* update deployment with telemetry doc with log opts (#887)

Co-authored-by: Oskar Paolini <oskar@paolini.pl>

* Fixed issue that crashed Mesh node (#888)

* Fixed issue that crashed Mesh node

* Addressed review feedback from @albrow

* Fixed a regression in `FilteredPaginationSubprotocolV0`

* Fixed bug that caused ordersync subprotocols to be selected at random

* Remove debugging logic

* Addressed review feedback from @albrow

* Fix bug when saving ordersync progress (#889)

* test: Added more tests for ordersync (#890)

* Added a test for orderfilter json encoding

* Added ordersync test for nodes with different filters

* Added ordersync test for receiving first request from old peer

* Fixed ordersync tests with distinct orderfilters

* Added another test case

* Cleaned up in anticipation of review

* Refactored orderfilter tests

* Addressed some review feedback from @albrow

* Apply suggestions from @albrow

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* Fixed issues caused by suggestions

* Fixed naming

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* Removed coordinator support (#895)

* Removed coordinator support

* Prettified the db syncing docs

* Unexported `batchOnchainValidation`

* fix: Prevent blockwatcher from missing contract events on startup (#894)

* Add existing miniheaders to simplestack during initialization

* Added a regression test for `blockwatch.New`

* Improved regression test

* Update ethereum/blockwatch/block_watcher_test.go

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>

* feature: Reject taker addresses that are nonzero and not on the whitelist (#896)

* Reject taker addresses that are nonzero and not on the whitelist

* Addressed review feedback

* Implement GraphQL API (#858)

* Create basic GraphQL server; implement stats query

* Implement order query

* Implement orders query

* Remove JSON-RPC API

* Fix CI

* Change types for some stats fields

* Remove references to JSON-RPC API from cut-release script

* Add GraphQL configuration options

* Update version of GraphiQL

* Use server.Shutdown for GraphQL server

* Use go-bindata to embed schema from text file

* Add graphql config file

* Install go-bindata in deps-no-lockfile

* Stub out remaining types and resolvers

* Switch to using gqlgen

* Set up new gqlgen server

* Re-implement resolvers

* Implement AddOrders

* Implement OrderEvents

* Implement AddOrders in client

* Implement and test Go client GetOrders without options

* Add test for more complicated GetOrders call

* Remove WIP TypeScript client code

* Implement and test Go client GetOrder

* Implement and test Go client GetStats

* Clean up GraphQL integration tests

* Implement basic working client with graphql-codegen

* Switch to using apollo client

* WIP subscriptions support

* Implement and test TypeScript client addOrdersAsync

* Implement and test TypeScript client getOrderAsync

* Implement and test TypeScript client onOrderEvents

* Remove ad hoc subscription test code

* Fix linter errors

* Implement and test TypeScript client getOrdersAsync

* Fix build error

* Remove old code related to typescript tests

* Implement and test TypeScript client rawQueryAsync

* Change env vars used for GraphQL integration tests

* Basic cleanup; remove old code and deps

* Cleanup types and file structure for TypeScript client

* Re-enable browser integration tests

* Add missing TSDoc comments

* Tweak environment variables.

* Remove old Go examples

* Add comment about mesh-bridge

* Update Dockerfiles

* Update documentation and comments

* Remove lingering references to coordinator error codes

* Improve error handling for TypeScript client subscriptions

* Address review feedback

* Fix failing TypeScript GraphQL client tests

* Update links in db_syncing.md

* Address PR feedback

* Throw all GraphQL errors in TypeScript client

* Use strings instead of custom scalars in GraphQL schema when possible (#906)

* Use strings instead of custom scalars in GraphQL schema when possible

* Add additional documentation to GraphQL schema

* Fix TypeScript GraphQL client

* Upgrade to go 1.15 (#911)

* Persistent DHT and Peerstore (#907)

* Implemented persistent datastore for peer and dht information in golang

* Implemented persistent key value store for the browser environment

* Finished the persistent storage solution

* Fixed all outstanding discrepancies between the dexie ds implementation and the tests

* Finalized new key store implementation

* Addressed issues uncovered during a personal review

* Addressed review feedback from @recmo

* Changed comment to prompt `ci/circleci:build`

* Added context as a parameter in `ethereum/blockwatch.Client` (#862)

* Added context to `ethereum/blockwatch.Client`

* Started changing approach

* Enable more linters (#861)

* Enable all default linters and fixed all errors

* Enable two more linters

* Added linter for `gofmt`

* Enables the `unparam` linter

* Added `make check`

* Fixed `deadcode` errors after rebase

* Fixed `misspell` errors after rebase

* Fixed `ineffassign` errors after rebase

* Fixed `unparam` errors after rebase

* Fixed `gosimple` errors after rebase

* Fixed `staticcheck` errors after rebase

* Addressed review feedback from @recmo

* Bump acorn from 6.3.0 to 6.4.1 in /packages/webpack-example-lite (#769)

Bumps [acorn](https://github.com/acornjs/acorn) from 6.3.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@6.3.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated some out of date references to Go 1.14 (#912)

* Bump jquery from 3.4.1 to 3.5.0 in /packages/browser-lite (#915)

Bumps [jquery](https://github.com/jquery/jquery) from 3.4.1 to 3.5.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](jquery/jquery@3.4.1...3.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Added missing entries to the changelog (#922)

* Updates yarn.lock files and adds dependabot configuration (#925)

* Remove unused yarn.lock files

* Added dependabot config that targets the development branch

* Converted dependabot configuration to v2 config

* Remove dependabot v1 config

* Re-generated yarn.lock file (#926)

* Upgraded Dockerfiles to go 1.15.2 (#927)

* Update `libp2p` dependencies (#921)

* Updated deps

* Got standalone nodes to be somewhat functional again

* Fixed "TestPeerDiscovery" for standalone nodes

* Fixed lingering networking issues

* Addressed linter errors

* Updated "go-libp2p" to fix the filters option

* Improved consistency of external APIs (#918)

* GetOrders => FindOrders

* Added graphql endpoints to MeshWrapper type in Typescript

* Expose dummy endpoints on the Go side of MeshWrapper

* Added testing for the browser GraphQL API

* Squashed some bugs throughout the plumbing pipeline

* DRYed a few things up

* Fixed the browser graphql integration test

* Cleaned up a bit

* Add missing "secondaryRendezvous" to GraphQL schema

* Addressed outstanding "FIXME" comments

* Altered the way that BrowserLink accesses the Mesh wrapper

* Updated "cut-release" make target

* Fixed compiler error after rebase

* Added changelog entry for GraphQL in the browser and fixed style of other v10 entries

* Addressed review feedback from @z2trillion

* Updated an integration test to be version agnostic (#928)

* Updated an integration test to be version agnostic

* Made the Typescript integration tests version agnostic

* Cut release v10.0.0

Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com>
Co-authored-by: Paul Gebheim <pgebheim@users.noreply.github.com>
Co-authored-by: z2trillion <z2trillion@users.noreply.github.com>
Co-authored-by: Mason Liang <mason@0x.org>
Co-authored-by: Oskar Paolini <oskar@paolini.pl>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants