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

client/asset: clarify eth and token versioning #2094

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented Jan 31, 2023

This is needed for #2054. The tokens supported versions were not exposed because tokens without wallets don't expose WalletInfo (no Driver).

Changing tacts on this a bit. Instead, we'll just have the tokens share the parent asset's versioning, and the server will maintain with a single protocol version.

Just a reminder that server protocol version != contract version. A server's version does map to a contract version, but it's not one-to-one. i.e. you cannot add a new contract version without incrementing the server version, but a server version could be incremented for other reasons too. I've fixed versioning ambiguity in a couple places in this effort, but there is much more work done in #2038. I could potentially pull that out into a separate PR.

@@ -138,6 +138,8 @@ var (
},
}

SupportedTokenVersions = []uint32{0} // Server versions that we can handle.
Copy link
Member

Choose a reason for hiding this comment

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

Won't each token have it's own list of versions?

Copy link
Member Author

@buck54321 buck54321 Jan 31, 2023

Choose a reason for hiding this comment

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

Server protocol version != contract version. We've been sloppy with this concept. The client knows how to handle a range of server versions. Those server versions certainly correspond to a range of contract versions, but not necessarily one-to-one.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right. Say there's a new v1 swap contract version for USDC, server protocol version 1 (up from 0) could support contract versions 0 and 1. Server advertises whichever single protocol version it supports, while client can manage multiple. Right, ok. I think this works out but is definitely a bit hard to keep straight.

Copy link
Member Author

Choose a reason for hiding this comment

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

We've never really pinned down the versioning scheme. Lemme come up with a comprehensive plan and document it. This PR may not be the best way, now that I think about it.

@@ -53,7 +53,7 @@ func registerToken(tokenID uint32, desc string, nets ...dex.Network) {
asset.RegisterToken(tokenID, token.Token, &asset.WalletDefinition{
Type: "token",
Description: desc,
}, nets...)
}, SupportedTokenVersions, nets...)
Copy link
Member

Choose a reason for hiding this comment

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

I may not be seeing the problem clearly, but above we do token, found := dexeth.Tokens[tokenID], and it looks like here in registerToken is the right place to get the supported versions out of NetTokens.
Also doesn't this mean that each net will have a different list of versions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same answer here, really. From NetTokens, we would get the versioned contracts that have been deployed for a specific token. What we're interested in is which server protocol versions we can communicate with.

@chappjc
Copy link
Member

chappjc commented Jan 31, 2023

Keeping open for discussion. I think we're a little uncertain at present if the parent asset version is good for it's tokens or we need multiple sets.

@buck54321 buck54321 force-pushed the token-supported-vers branch from 5d2dd39 to ce6cce5 Compare February 3, 2023 15:30
@buck54321 buck54321 changed the title client/asset: add supported assets to token info client/asset: clarify eth and token versioning Feb 3, 2023
@chappjc chappjc added this to the 0.6 milestone Feb 6, 2023
Copy link
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

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

I think it makes sense share the version for ETH and all tokens. I don't think a server would want to not support the latest of all contracts.

@chappjc chappjc merged commit be1ff9c into decred:master Feb 7, 2023
@chappjc chappjc added the ETH label Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants