Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Remove expiration buffer config and emit expiry events based on block timestamp #490

Merged
merged 17 commits into from
Nov 5, 2019

Conversation

fabioberger
Copy link
Contributor

@fabioberger fabioberger commented Nov 4, 2019

Fixed: #419 and #418

This PR:

  • Refactors Mesh to emit order expiration events when orders are expired according to the latest block timestamp. We no longer emit UTC-based expiration events.
  • An order can now become unexpired, if a block re-org causes the latest block timestamp to be earlier than it's predecessor. We therefore added the UNEXPIRED order event type.
  • Removes the expiration buffer config as it is no longer needed.

@fabioberger fabioberger force-pushed the refactor/removeBufferRenameExpiry branch from 5541352 to 783ac59 Compare November 5, 2019 07:23
@fabioberger fabioberger changed the title WIP: Remove expiration buffer config and rename expiry event Remove expiration buffer config and emit expiry events based on block timestamp Nov 5, 2019
Copy link
Contributor

@albrow albrow left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me. Just suggested a few small changes.

expirationwatch/expiration_watcher.go Outdated Show resolved Hide resolved
core/core.go Outdated
ChainID: config.EthereumChainID,
MaxOrders: config.MaxOrdersInStorage,
MaxExpirationTime: metadata.MaxExpirationTime,
LatestBlockTimestamp: latestBlockTimestamp,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does LatestBlockTimestamp really need to be passed in as part of Config on startup? It seems like:

  1. Unless there was a sudden unexpected shutdown, we will have already pruned any expired orders when the block watcher notified us of this block before Mesh was shutdown.
  2. The block watcher is going to notify us of the next latest block in a matter of seconds (or less) anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could potentially miss a block re-org caused Unexpired event emission since on restart the OrderWatcher would not know what the latestBlockTimestamp was before the shutdown. It's an edge-case for sure, I just wanted to make sure the implementation was bullet proof. If you don't want to handle this edge-case, I can get rid of it.

zeroex/orderwatch/order_watcher.go Outdated Show resolved Hide resolved
zeroex/orderwatch/order_watcher_test.go Outdated Show resolved Hide resolved
fabioberger and others added 5 commits November 5, 2019 19:49
Co-Authored-By: Alex Browne <stephenalexbrowne@gmail.com>
…ect/0x-mesh into refactor/removeBufferRenameExpiry
…ion since the logic behaves correctly with it being set by the first event received
@albrow albrow self-requested a review November 5, 2019 21:20
Copy link
Contributor

@albrow albrow left a comment

Choose a reason for hiding this comment

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

Approved after CI passes.

@fabioberger fabioberger merged commit fbe81c0 into development Nov 5, 2019
@fabioberger fabioberger deleted the refactor/removeBufferRenameExpiry branch November 5, 2019 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants