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

Implement TrustSet on the XRPL bridge account for the registered XRPL tokens. #41

Merged
merged 8 commits into from
Nov 7, 2023

Conversation

dzmitryhil
Copy link
Contributor

@dzmitryhil dzmitryhil commented Nov 6, 2023

Implement TrustSet on the XRPL bridge account for the registered XRPL tokens.

Description

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@dzmitryhil dzmitryhil requested a review from a team as a code owner November 6, 2023 12:59
@dzmitryhil dzmitryhil requested review from miladz68, ysv and wojtek-coreum and removed request for a team November 6, 2023 12:59
Copy link
Collaborator

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewed 23 of 23 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @dzmitryhil, @miladz68, and @wojtek-coreum)


integration-tests/coreum/contract_client_test.go line 367 at r1 (raw file):

	require.NotNil(t, operation.OperationType.TrustSet)

	rejectTxEvidenceTrustSet := coreum.XRPLTransactionResultTrustSetEvidence{

nit: rejectedTxEvidenceTrustSet


integration-tests/coreum/contract_client_test.go line 428 at r1 (raw file):

	require.True(t, coreum.IsXRPLTokenNotEnabledError(err), err)

	_ = activeCurrency

do we need this ?


integration-tests/processes/send_from_xrpl_to_coreum_test.go line 159 at r1 (raw file):

	require.NoError(t, err)

	// fund owner to cover registration fees

nit: cover issuance fee ?


relayer/coreum/contract.go line 648 at r1 (raw file):

// GetXRPLToken returns an XRPL registered token or nil.
func (c *ContractClient) GetXRPLToken(ctx context.Context, issuer, currency string) (*XRPLToken, error) {
	tokens, err := c.GetXRPLTokens(ctx)

question:
Does this query return all tokens or enabled only?


relayer/processes/amount.go line 18 at r1 (raw file):

	// XRPLIssuedCurrencyDecimals is XRPL decimals used the on coreum.
	XRPLIssuedCurrencyDecimals = 15
	// XRPIssuer is XRP issuer name used the on coreum.

nit: WDYM used the on coreum ?

on the coreum probably ?

Also we don't use this amount and currency on coreum these values are used in XRPL, no ?


relayer/processes/amount.go line 54 at r1 (raw file):

		xrplValue, err := rippledata.NewValue(amountString, true)
		if err != nil {
			return rippledata.Amount{}, errors.Wrapf(err, "failed to convert amount stringy to ripple.Value, amount stirng: %s", amountString)

nit: amount stirng:

-> string


relayer/processes/xrpl_tx_observer.go line 171 at r1 (raw file):

// IsExpectedSendEvidenceError returns true is error is cause of the re-submitting of the transaction.
func IsExpectedSendEvidenceError(err error) bool {

more clear name would be: IsEvidenceErrorCausedByResubmition


relayer/processes/xrpl_tx_submitter_test.go line 383 at r1 (raw file):

}

func multiSignTrustSetsOperation(

nit: multiSignTrustSetOperation ?

* Add tickets re-allocation tests by the XRPL tokens registration
Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 16 of 24 files reviewed, 4 unresolved discussions (waiting on @miladz68, @wojtek-coreum, and @ysv)


integration-tests/coreum/contract_client_test.go line 367 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: rejectedTxEvidenceTrustSet

Done


integration-tests/coreum/contract_client_test.go line 428 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

do we need this ?

Removed.


integration-tests/processes/send_from_xrpl_to_coreum_test.go line 159 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: cover issuance fee ?

Done


relayer/coreum/contract.go line 648 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

question:
Does this query return all tokens or enabled only?

All.


relayer/processes/amount.go line 18 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: WDYM used the on coreum ?

on the coreum probably ?

Also we don't use this amount and currency on coreum these values are used in XRPL, no ?

Updated comment. Did't get last question.


relayer/processes/amount.go line 54 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: amount stirng:

-> string

Done


relayer/processes/xrpl_tx_observer.go line 171 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

more clear name would be: IsEvidenceErrorCausedByResubmition

Agree, updated.


relayer/processes/xrpl_tx_submitter_test.go line 383 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: multiSignTrustSetOperation ?

Done

@keyleu keyleu requested a review from ysv November 7, 2023 09:06
Copy link
Collaborator

@keyleu keyleu left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68, @wojtek-coreum, and @ysv)


integration-tests/coreum/contract_client_test.go line 297 at r2 (raw file):

	issuerAcc := chains.XRPL.GenAccount(ctx, t, 0)
	issuer := issuerAcc.String()
	invactiveCurrency := "INA"

should be inactive not invactive


integration-tests/processes/ticket_allocation_test.go line 201 at r2 (raw file):

	// register more than threshold to activate tickets re-allocation
	numberOfXRPLTokensToRegister := int(numberOfTicketsToAllocate) - 1

maybe change this to UsedTicketsThreshold+1 to be more accurate with comment


relayer/coreum/contract.go line 658 at r2 (raw file):

	}

	return nil, nil //nolint:nilnil // is token not found we return nil instead of an error

if token is not found


relayer/coreum/contract.go line 902 at r2 (raw file):

}

// IsXRPLTokenNotEnabledError returns true if error is `XRPLTokenNotEnabled` error.

you can remove the last error from comment.


relayer/processes/amount.go line 35 at r2 (raw file):

		return sdkmath.NewIntFromBigInt(xrplRatAmount.Num()), nil
	}
	// not XRP value is repressed as value multiplied by 10^15

I suggest keeping scientific notation everywhere as a standard (like in spec). Use 1e15 (instead of 10^15) notation everywhere. I will double check the contract for this as well.

Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68, @wojtek-coreum, and @ysv)


integration-tests/coreum/contract_client_test.go line 297 at r2 (raw file):

Previously, keyleu (Keyne) wrote…

should be inactive not invactive

Done


integration-tests/processes/ticket_allocation_test.go line 201 at r2 (raw file):

Previously, keyleu (Keyne) wrote…

maybe change this to UsedTicketsThreshold+1 to be more accurate with comment

Agree, done.


relayer/coreum/contract.go line 658 at r2 (raw file):

Previously, keyleu (Keyne) wrote…

if token is not found

Done


relayer/coreum/contract.go line 902 at r2 (raw file):

Previously, keyleu (Keyne) wrote…

you can remove the last error from comment.

Done.


relayer/processes/amount.go line 35 at r2 (raw file):

Previously, keyleu (Keyne) wrote…

I suggest keeping scientific notation everywhere as a standard (like in spec). Use 1e15 (instead of 10^15) notation everywhere. I will double check the contract for this as well.

Done

ysv
ysv previously approved these changes Nov 7, 2023
Copy link
Collaborator

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 8 files at r2, 8 of 8 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dzmitryhil, @miladz68, and @wojtek-coreum)


integration-tests/processes/ticket_allocation_test.go line 214 at r3 (raw file):

	runnerEnv.AwaitNoPendingOperations(ctx, t)

	availableTicketsAfterReAllocation, err := runnerEnv.ContractClient.GetAvailableTickets(ctx)

nit: Reallocation single word


relayer/processes/amount.go line 18 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Updated comment. Did't get last question.

// XRPIssuer is XRP issuer name used on the coreum.
XRPIssuer = "rrrrrrrrrrrrrrrrrrrrrho"

but this it is XRP issuer address used on XRPL ?

Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)


integration-tests/processes/ticket_allocation_test.go line 214 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: Reallocation single word

Done


relayer/processes/amount.go line 18 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

// XRPIssuer is XRP issuer name used on the coreum.
XRPIssuer = "rrrrrrrrrrrrrrrrrrrrrho"

but this it is XRP issuer address used on XRPL ?

Clear now, updated.

@dzmitryhil dzmitryhil requested review from keyleu and ysv November 7, 2023 13:20
keyleu
keyleu previously approved these changes Nov 7, 2023
Copy link
Collaborator

@keyleu keyleu left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)

Copy link
Collaborator

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dzmitryhil, @miladz68, and @wojtek-coreum)


relayer/processes/amount.go line 18 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Clear now, updated.

For simplicity we consider that issuer for XRP on XRPL is rrrrrrrrrrrrrrrrrrrrrho and use this value to generate corresponding token on Coreum side. This is done to unify representation & flows for all XRPL originated tokens (XRP and issued tokens) on bridge side.

Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 30 of 31 files reviewed, 1 unresolved discussion (waiting on @keyleu, @miladz68, @wojtek-coreum, and @ysv)


relayer/processes/amount.go line 18 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

For simplicity we consider that issuer for XRP on XRPL is rrrrrrrrrrrrrrrrrrrrrho and use this value to generate corresponding token on Coreum side. This is done to unify representation & flows for all XRPL originated tokens (XRP and issued tokens) on bridge side.

Updated taken your example.

Copy link
Collaborator

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 6 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @miladz68 and @wojtek-coreum)

Copy link
Collaborator

@keyleu keyleu left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @miladz68 and @wojtek-coreum)

@dzmitryhil dzmitryhil merged commit 7886e7a into master Nov 7, 2023
5 checks passed
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