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

feature NetworkID #2216

Merged
merged 41 commits into from
Jun 14, 2023
Merged

feature NetworkID #2216

merged 41 commits into from
Jun 14, 2023

Conversation

dangell7
Copy link
Contributor

@dangell7 dangell7 commented Feb 17, 2023

High Level Overview of Change

XRPLF/rippled#4370

Context of Change

Added network id to the base transaction
Added network id to the server_info response
Added network id to the binary codec
Added network id to client and modify on client.connect()
Added network id to autofill when rippled_version is 1.11.0 or later or network is hooks testnet

Type of Change

  • New feature (non-breaking change which adds functionality)

Test Plan

No tests were written

@dangell7 dangell7 changed the title Add Network ID [DO NOT MERGE] feature NetworkID Feb 17, 2023
@dangell7 dangell7 changed the title [DO NOT MERGE] feature NetworkID feature NetworkID Feb 17, 2023
@dangell7 dangell7 changed the title feature NetworkID [DO NOT MERGE] feature NetworkID Feb 17, 2023
@ckniffen
Copy link
Collaborator

ckniffen commented Feb 17, 2023

This library will already need to be updated due to the addition of 1.10.0 amendment featureXRPFees and the changes it makes to server_info. I was thinking of the autofill changes before digging into your PR description. I think that is the best way to go. It will largely allow a peaceful upgrade.

#2219

@dangell7
Copy link
Contributor Author

This library will already need to be updated due to the addition of 1.10.0 amendment featureXRPFees and the changes it makes to server_info. I was thinking of the autofill changes before digging into your PR description. I think that is the best way to go. It will largely allow a peaceful upgrade.

#2219

Yeah I agree, using the auto fill seems like the best approach.

@mvadari
Copy link
Collaborator

mvadari commented Feb 22, 2023

@dangell7 are you planning on finishing this PR yourself or are you just updating the definitions.json?

@dangell7
Copy link
Contributor Author

@dangell7 are you planning on finishing this PR yourself or are you just updating the definitions.json?

I was waiting for XRPFees because I thought it would effect this. I will finish this now though

@mvadari
Copy link
Collaborator

mvadari commented Feb 22, 2023

@dangell7 are you planning on finishing this PR yourself or are you just updating the definitions.json?

I was waiting for XRPFees because I thought it would effect this. I will finish this now though

I think they can be implemented independently (especially since this change doesn't require an amendment).

@dangell7
Copy link
Contributor Author

dangell7 commented Feb 22, 2023

@mvadari I have some thoughts on this.

I added networkID to the autofill function. Technically in hooks amendment there is a fee endpoint that is different than server_info. I think the XRPFees is a prequel to that. That is why I chose to add an additional call instead of piggy back off of the server_infocall used for setFee.

However my thoughts are that the moment you are connected to the ws/rpc, you are connected with a NetworkID. The autofill adds fields to the transaction but those fields are constantly adjusting based on different inputs and the Network ID doesn't change.

So does it make sense to be in autofill or should we do a server_info call on connection of the api?

Also, is networkID a required field in the sdk? Making it optional like Fee and Sequence would allow users to use the sdk to connect to both versions of ripped. I also have that same question for the server_state model and test fixtures.

@dangell7
Copy link
Contributor Author

dangell7 commented Feb 23, 2023

@mvadari I made this as a second option. The sdk doesnt emit the connected message until after the server_info response is received.

EDIT: Didn't like the second option. So I went with a 3rd option. Now its a function called after connect

Ex: await client.getNetworkID() and then in the autofill it sets the NetworkID of the client.

fixup

add network id to server info fixture

fixup!

Revert "update tests and fixtures"

This reverts commit a5deee1.
@mvadari mvadari mentioned this pull request Feb 23, 2023
6 tasks
@dangell7
Copy link
Contributor Author

dangell7 commented Feb 23, 2023

Regardless of the option we choose, the integration/browser tests will fail because autofill is adding a field (NetworkID) to the transaction that does not exist on the standalone or on rippled servers without the amendment enabled.

@mvadari
Copy link
Collaborator

mvadari commented Feb 23, 2023

This PR should not be merged in until the rippled PR is in develop (ideally not until it's in a new rippled release).

@dangell7
Copy link
Contributor Author

This PR should not be merged in until the rippled PR is in develop (ideally not until it's in a new rippled release).

Wouldn't it still fail for mainnet until the amendment was passed and all servers upgraded?

I think we would need to check if the amendment is enabled before adding the NetworkID to the transaction in the autofill but that sounds overkill.

@mvadari
Copy link
Collaborator

mvadari commented Feb 23, 2023

This PR should not be merged in until the rippled PR is in develop (ideally not until it's in a new rippled release).

Wouldn't it still fail for mainnet until the amendment was passed and all servers upgraded?

I think we would need to check if the amendment is enabled before adding the NetworkID to the transaction in the autofill but that sounds overkill.

There's no amendment, there's no change for mainnet. The only change is in testnets, and the only testnet that has this feature right now is the hooks one. So if we merge this in now, then it screws over everyone working on the Testnet or Devnet.

@intelliot
Copy link
Collaborator

I think you can change this PR so that when xrpl.js connects to a server that doesn't use a NetworkID (including Mainnet, Testnet, Devnet, etc) it doesn't set the NetworkID field. That way, it wouldn't break anything, and also doesn't need to wait for anything.

@dangell7 dangell7 changed the title [DO NOT MERGE] feature NetworkID feature NetworkID Feb 24, 2023
@dangell7 dangell7 marked this pull request as ready for review February 24, 2023 21:40
@dangell7
Copy link
Contributor Author

Usage: https:/Transia-RnD/xls-playground/blob/main/ts/test/networkID.test.ts

client.networkID = await client.getNetworkID();

@pdp2121 pdp2121 requested a review from mvadari June 5, 2023 18:01
@pdp2121 pdp2121 requested a review from mvadari June 6, 2023 16:30
Copy link
Collaborator

@mvadari mvadari left a comment

Choose a reason for hiding this comment

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

lgtm but I think @justinr1234 should review the tests before this is merged

@pdp2121 pdp2121 requested a review from justinr1234 June 7, 2023 20:27
packages/xrpl/src/client/index.ts Outdated Show resolved Hide resolved
packages/xrpl/src/client/index.ts Outdated Show resolved Hide resolved
packages/xrpl/src/client/index.ts Show resolved Hide resolved
packages/xrpl/src/sugar/autofill.ts Show resolved Hide resolved
packages/xrpl/src/sugar/autofill.ts Outdated Show resolved Hide resolved
packages/xrpl/test/client/autofill.test.ts Show resolved Hide resolved
packages/xrpl/test/client/autofill.test.ts Show resolved Hide resolved
packages/xrpl/test/client/autofill.test.ts Outdated Show resolved Hide resolved
const Fee = '10'
const Sequence = 1432
const LastLedgerSequence = 2908734
const HOOKS_TESTNET_ID = 21338
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this ID set in stone and will never change?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mvadari What do you think? I can use the faucet to retrieve the ID for hooks testnet but it would make autofill a bit slower on the first call. I think the ID for each networks should remain unchanged but I might be wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it changes, but if they switch to a v4 or something at some point then it might change then.
Perhaps a better solution is some sort of force-network-id flag? Or just tell people that if they're using the hooks testnet they'll have to add the network ID in themselves.

client.disconnect().then(() => resolve())
})
client.connect()
client.on('connected', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@pdp2121 what error is caused? Can you give more information?

This leads me to believe your code needs to be enhanced to handle the case where the client is disconnected after you've already called server_info --- or that when your call to server_info is ready to be made, the client could already be disconnected.

I'm curious to know the error before we call this resolved

@pdp2121 pdp2121 requested a review from justinr1234 June 12, 2023 18:29
@justinr1234
Copy link
Collaborator

@pdp2121 can you update with main

@pdp2121 pdp2121 merged commit 5b0989d into XRPLF:main Jun 14, 2023
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.

8 participants