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

Arbitrum: replace block timeouts with timestamps #3034

Merged
merged 35 commits into from
Mar 7, 2022
Merged

Conversation

andrevmatos
Copy link
Contributor

Fixes #2916

Short description

Definition of Done

  • Steps to manually test the change have been documented
  • Acceptance criteria are met
  • Change has been manually tested by the reviewer (dApp)

Steps to manually test the change (dApp)

Copy link
Contributor

@weilbith weilbith left a comment

Choose a reason for hiding this comment

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

A bunch of comments and questions.

raiden-ts/src/channels/epics/block.ts Outdated Show resolved Hide resolved
raiden-ts/src/channels/epics/block.ts Show resolved Hide resolved
raiden-ts/src/channels/epics/block.ts Show resolved Hide resolved
raiden-ts/src/epics.ts Outdated Show resolved Hide resolved
raiden-ts/src/channels/epics/block.ts Show resolved Hide resolved
raiden-ts/src/transfers/epics/locked.ts Show resolved Hide resolved
raiden-ts/src/raiden.ts Show resolved Hide resolved
raiden-cli/src/routes/channels.ts Show resolved Hide resolved
raiden-cli/src/routes/userDeposit.ts Outdated Show resolved Hide resolved
raiden-ts/src/config.ts Outdated Show resolved Hide resolved
The former is a cached getter function to fetch the timestamp (in
millis) for a specific blockNumber, and the later is a cold cached
(shareReplay'd) observable to fetch the contract's constant
settleTimeout
fetches from Raiden.settleTimeout getter
Before, when using udcAddress as contract's entrypoint, the discovery
had to be performed every session, as it wasn't stored, and also because
this contract's discovery was needed to get TNR addr and find state.
Now, we use UDC address to index state, and persist the whole
discovered contractsInfo in it, so we reuse from state after first init.
andrevmatos and others added 16 commits March 7, 2022 07:57
We tried some logic with confirmationBlocks and blockTimes before, just
as a way to have a more relaxed upperbound so transfers would expire
before channel settlement window, but it was quite complex, and this is
already a stretched margin anyway (usually, revealTimeout * expiryFactor
is used), so we replace that by half settleTimeout.
And avoid additional block wait time of confirmConfirmation
(Raiden.openChannel and Raiden.depositChannel) in case
confirmationBlocks=0
We had already refactored the epics to check that the timestamp were
correct, but still reacted only upon newBlocks. Now, we use a
`timer` approach to actually trigger these actions on the
deadline/expiration, independently of newBlocks arriving or not
This was awaiting a negative value (secs - now_msecs), so no wait
Also, fix arbitrum-rinkeby network name, and try to read at runtime if
deployment not built-in.
In the past, channels had a settle timeout property. It was also possible to
configure the SDK with a settle timeout value for new channels. This has changed
with the latest version of the contracts and SDK. The settle timeout has moved
from individual channels to the token network itself. In result channel data
structure have no more this data field and the SDK doesn't accept this
configuration option anymore.
There is also a visual effect of this change. So far, if a channel got closed,
the button to settle the channel was showing a countdown until it becomes
possible. But not only was the settle timeout moved, it also changed its meaning
from a block number based value to an actual time value in seconds. The issue is
that this value can very from a few seconds to multiple days. In result is is
not easy to maintain a countdown on the settle button. Also because the
rendering of the Vue component would need to be force updated by an interval as
it is now purely time based. To maintain the raw functionality for the moment,
the button just remains disabled until the channel is settlable. This might
improve in future again.
In the past, a planned UDC withdrawal had the property of a target `withdrawBlock`
from which it is possible to withdraw the tokens. This has changed to a timestamp
value (in Unix format) called `withdrawableAfter`. Due to this change, a couple
of renaming where necessary.
Furthermore this also has visual effects. On the view to the user deposit
contract, if there was a planned withdraw pending (not yet withdrawable) it was
showing a countdown for the blocks remaining. As this is not the case anymore,
it has been changed to display the target date. Once this date has passed, the
UI changes as usual and displays the user that the plan is now ready.

There was also a tiny change in the translations, not only according block to
time change. Also a special unicode character got replaced with a simple ASCII
one, as the former one was not rendered properly for some users, depending on
their system font.
This means that basically all related components like contracts, services etc.
got updated. As the contracts are not released yet and thereby all dependent
components, all versions point to pre-release git tags.
There were a few adaption necessary despite exchanging the components which come
with changes of these updates.

As a side-effect we get a eat-your-own-dogs-food dilemma here. As there is no
Raiden client that supports the new contracts yet, we need to fetch the current
under-development branch of the Light Client. This must change once a release is
ready.

The end-to-end tests of the SDK and dApp do not succeed yet. They have not been
touched and are likely to fail by syntax and semantic issues.
Also, allow it to not only emit first best PFS, but instead prefer to
emit all of them sorted, so caller can take `first` only if desired.
This is intended in order to use this functions in other places of the
code, like the matrix server choice in transport.
When matrixServer isn't set, we are in `auto` mode. Previously, we'd
fetch the list from `matrixServerLookup`, but is easy to have this list
mismatched with current network/deployment. This change prefers the same
matrixServer from the PFSs, scanning first `config.additionalServices`
and then services fetched from ServicesRegistry, which are expected to
always be compatible with current deployment.
@codecov
Copy link

codecov bot commented Mar 7, 2022

Codecov Report

Merging #3034 (02ab856) into master (d28d98f) will decrease coverage by 0.06%.
The diff coverage is 92.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3034      +/-   ##
==========================================
- Coverage   93.16%   93.10%   -0.07%     
==========================================
  Files         213      213              
  Lines        8555     8596      +41     
  Branches     1428     1407      -21     
==========================================
+ Hits         7970     8003      +33     
- Misses        511      522      +11     
+ Partials       74       71       -3     
Flag Coverage Δ
dapp 88.68% <86.66%> (+0.06%) ⬆️
dapp.unit 88.68% <86.66%> (+0.06%) ⬆️
sdk 95.48% <92.51%> (-0.14%) ⬇️
sdk.e2e 72.03% <68.56%> (+0.07%) ⬆️
sdk.integration 79.98% <75.74%> (-0.19%) ⬇️
sdk.unit 49.07% <32.33%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...aiden-dapp/src/components/channels/ChannelList.vue 100.00% <ø> (ø)
raiden-dapp/src/services/raiden-service.ts 82.25% <ø> (+0.70%) ⬆️
raiden-dapp/src/views/account/UDC.vue 96.66% <ø> (ø)
raiden-ts/src/channels/state.ts 100.00% <ø> (ø)
raiden-ts/src/services/actions.ts 100.00% <ø> (ø)
raiden-ts/src/services/types.ts 100.00% <ø> (ø)
raiden-ts/src/transfers/actions.ts 100.00% <ø> (ø)
raiden-ts/src/transfers/state.ts 100.00% <ø> (ø)
raiden-ts/src/db/utils.ts 90.52% <50.00%> (ø)
raiden-ts/src/raiden.ts 93.70% <70.58%> (-0.75%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d28d98f...02ab856. Read the comment docs.

@weilbith weilbith marked this pull request as ready for review March 7, 2022 12:37
@weilbith weilbith self-requested a review March 7, 2022 12:37
Copy link
Contributor

@weilbith weilbith left a comment

Choose a reason for hiding this comment

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

Anything that is still open will be done on master now. Let's go.

@weilbith
Copy link
Contributor

weilbith commented Mar 7, 2022

@andrevmatos please update the CHANGELOG.

@andrevmatos andrevmatos merged commit 5ddc3a1 into master Mar 7, 2022
@andrevmatos andrevmatos deleted the arbitrum branch March 7, 2022 21:51
@andrevmatos andrevmatos restored the arbitrum branch March 7, 2022 21:51
@andrevmatos andrevmatos deleted the arbitrum branch March 9, 2022 09:06
@weilbith weilbith mentioned this pull request May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking 💔 For breaking changes in the protocol or services Rollups ⭕ sdk 🖥
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust timeouts to timestamps on Arbitrum
2 participants