-
Notifications
You must be signed in to change notification settings - Fork 111
Compare chain id env variable with rpc on startup #733
Compare chain id env variable with rpc on startup #733
Conversation
core/core.go
Outdated
@@ -711,6 +745,14 @@ func (app *App) Start(ctx context.Context) error { | |||
} | |||
} | |||
|
|||
// Need to wait for the async ETH RPC call to finish before we know if the chain id is correctly configured | |||
chainIdCheckerWg.Wait() | |||
if err := <-chainIdMismatchErrChan; err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this into a case
statement in the above select block.
core/core.go
Outdated
go func() { | ||
defer wg.Done() | ||
defer chainIdCheckerWg.Done() | ||
ctx, cancel := context.WithTimeout(context.Background(), ethereumRPCRequestTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the actual logic in this go routine into a helper method with a good name? Having it in-lined here feels like the wrong level of abstraction when compared with the rest of it's parent's function logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use innerCtx
instead of context.Background()
here.
8c7b292
to
0eed7bb
Compare
@kimpers @fabioberger do you mind if I take over this PR to push it over the finish line? This check would actually be really useful and solve a common problem, especially in the browser. |
Feel free 👍 Beware that there seems to be a strange race condition with the test, locally on my machine it passes some times and fails other times. When you figure out what the underlying issue is I'd be very interested to know what causes it. |
688fcc3
to
a913f61
Compare
@kimpers the race condition here was definitely a tricky one. It doesn't directly stem from the code you added, moreso this new code made an existing bug more apparent. Inside of select {
case err := <-p2pErrChan:
if err != nil {
log.WithError(err).Error("p2p node exited with error")
cancel()
return err
}
case err := <-orderWatcherErrChan:
if err != nil {
log.WithError(err).Error("order watcher exited with error")
cancel()
return err
}
// etc...
} There was an implicit assumption here that if one of the goroutines sent an error through their respective channels, it was time to shut the app down. But that assumption was wrong. There are some cases where a goroutine may send I fixed this by wrapping the |
@fabio This PR is now ready for review. I changed it to no longer be a draft. |
a47cd81
to
2f04a4f
Compare
* Periodically rerun ordersync instead of running it only once on startup (#764) * Periodically rerun ordersync instead of running it only once on startup * Add a random jitter to ordersync delay * Change ordersyncApproxDelay to 1 hour * Add log message when starting ordersync service * Improve comment clarity * Update ganache addresses (#765) * Update Ganache DevUtils address * Update Ganache snapshot version * Update Dummy ERC1155 contract address * Fix typo * Add a polyfill for WebAssembly.instantateStreaming (#770) * Add a polyfill for WebAssembly.instantateStreaming * Fix linter error * Update changelog * Compare chain id env variable with rpc on startup (#733) * ADDS check that configured chain id matches RPC WIP * FIXES async error channel race condition and clean up code * FIXES remove unnecessary wait group, move chain id fetch into helper * FIXES use ParseBig256 for parsing chain id response from eth_chainId * Fix race condition in core.App.Start * Update changelog Co-authored-by: Alex Browne <stephenalexbrowne@gmail.com> * Add custom order filters documentation (#768) * Add custom order filters docs * Fix nits * Add doc to menu * Improve limitations description * Add example filters * Merge the two example sections * Fully Automate Document Generation (#771) * Automated the documentation update step * Ignored exported fields that shouldn't be documented * Addressed @albrow's review feedback * Revert "Addressed @albrow's review feedback" This reverts commit 75f48c0. * [expirationwatch] Fixes consistency bug (#773) * Fix small bug in expirationwatcher * Add a test to ensure that a "barely expired" order will be pruned * Update CHANGELOG with PR number * Fixes race condition in orderwatcher test (#774) * Improve scenario package (#779) * WIP Improve scenario package * Create orderopts package. Update scenario and ordervalidator to use it * Fix remaining ordervalidator tests * Update most orderwatcher tests * Support setting taker state and enable remaining orderwatcher tests * Fix remaining tests (only MultiAsset disabled) * Uncomment test that depends on on-chain state for a StaticCall order * Fix browser integration test * Remove unneeded ethClient parameter in a few places * Move sleep statement in order_watcher_test.go * Address Alex Towle's feedback * Remove old comment * Revalidate affected orders regardless of ERC721 approval operator (#782) * Increase sleep duration in TestPingPong (#785) * scenario: Add ability to create multiple orders in a single batch (#784) * scenario: Add ability to create multiple orders in a single batch * Fix some typos * Update changelog for PR #782 (#786) * p2p: Don't call HandleMessages if there are no messages to handle (#787) * Add missing regression test for ordersync pagination subprotocol (#788) * Add missing regression test for ordersync pagination subprotocol Also fixes a minor bug where the exponential backoff for ordersync was too long in some circumstances. * Remove some duplicated code in core_test.go * Set versions to 9.3.0 Co-authored-by: Fabio B <me@fabioberger.com> Co-authored-by: Kim Persson <kimpers@users.noreply.github.com> Co-authored-by: Alex Towle <jalextowle@gmail.com>
Implements #171