Skip to content

Hermes migration consumer - #5013

Merged
n10ty merged 8 commits into
hermes-v3from
hermes-migration-consumer
Apr 15, 2022
Merged

Hermes migration consumer#5013
n10ty merged 8 commits into
hermes-v3from
hermes-migration-consumer

Conversation

@n10ty

@n10ty n10ty commented Apr 13, 2022

Copy link
Copy Markdown
Contributor

No description provided.

AndreyM added 6 commits April 12, 2022 11:55
Signed-off-by: AndreyM <andrey@mysterium.network>
Signed-off-by: AndreyM <andrey@mysterium.network>
Signed-off-by: AndreyM <andrey@mysterium.network>
Signed-off-by: AndreyM <andrey@mysterium.network>
New tequilla API endpoints
1. /:id/migrate-hermes/status: check if there is money on non-active Hermes and payment channel for new Hermes is empty or new channel does not exists
2. /:id/migrate-hermes: starts migration. Opens a new channel for new Hermes. Than withdraw money from old to new channel

Signed-off-by: AndreyM <andrey@mysterium.network>
# Conflicts:
#	tequilapi/endpoints/assets/docs.go
#	tequilapi/endpoints/identities.go
@n10ty
n10ty marked this pull request as ready for review April 13, 2022 14:09
@n10ty
n10ty requested review from Guillembonet and tomasmik and removed request for Snawoot, Waldz, mdomasevicius, soffokl, tadaskay and tomasmik April 13, 2022 14:09

@Guillembonet Guillembonet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

overall its looking nice

Comment thread consumer/migration/hermes_migrator.go
if err != nil {
return fmt.Errorf("error during getting balance: %w", err)
}
if crypto.FloatToBigMyst(oldBalanceMigrationMinimumMyst).Cmp(oldBalance) > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should also open channel if there is no balance (and then don't withdraw)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree on this. If there is a channel open on any old hermes (or we're registered would probably be the check to run) and channel open operation is free, we should open a channel, just dont withdraw.

Comment thread consumer/migration/hermes_migrator.go
Comment thread consumer/migration/hermes_migrator.go

@tomasmik tomasmik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks pretty good, but it's missing mobile bindings: https://github.com/mysteriumnetwork/node/tree/master/mobile/mysterium

Also about old hermes enumeration. It's a bit tricky imo.. But maybe we should actually enumerate all hermeses for balance checks etc. Another thing we could do is call blockchain to get hermes version and assume something like:

If our current hermes version is v3 we should only check/migrate hermes v2 and ignore all previous hermeses. That makes sense in my head at least.

if err != nil {
return fmt.Errorf("error during getting balance: %w", err)
}
if crypto.FloatToBigMyst(oldBalanceMigrationMinimumMyst).Cmp(oldBalance) > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree on this. If there is a channel open on any old hermes (or we're registered would probably be the check to run) and channel open operation is free, we should open a channel, just dont withdraw.

Comment thread consumer/migration/hermes_migrator.go
Comment thread consumer/migration/hermes_migrator.go
if err != nil {
log.Debug().Msgf("Hermes migration error: open channel failed %s", err.Error())
return err
} else if statusResponse.Status == registry.ChannelStatusFail || statusResponse.Status == registry.ChannelStatusOpen {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We print debug log as success even if this status is failed and then continue to do a withdrawal to the new channel that was never opened. Whats the idea behind that?

@n10ty n10ty Apr 14, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, idea is Transactor only fails to open a channel if there is someone else, sent this transaction before (to take reward). Correct me if I wrong here, I remember Depot Delivery works in this way

Comment thread tequilapi/endpoints/identities.go
AndreyM added 2 commits April 14, 2022 14:52
Signed-off-by: AndreyM <andrey@mysterium.network>
Fix mobile bindings
During migration check whether identity is registered
Open new channel even if lack of balance

Signed-off-by: AndreyM <andrey@mysterium.network>
@n10ty
n10ty merged commit 3775923 into hermes-v3 Apr 15, 2022
@n10ty
n10ty deleted the hermes-migration-consumer branch April 15, 2022 11:12
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.

3 participants