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

Add Warp Payload Types #2116

Merged
merged 11 commits into from
Oct 5, 2023
Merged

Conversation

nytzuga
Copy link
Contributor

@nytzuga nytzuga commented Sep 29, 2023

Why this should be merged

#2050 Integrating Warp Payload Types into AvalancheGo for Cross-VM Compatibility

How this works

How this was tested

@nytzuga nytzuga changed the base branch from master to dev September 29, 2023 06:09
@nytzuga nytzuga force-pushed the move-warp-payload-to-avalanchego branch from d621a43 to c67537f Compare September 29, 2023 06:29
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Sep 29, 2023
@nytzuga nytzuga self-assigned this Sep 29, 2023
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Sep 29, 2023
@nytzuga nytzuga marked this pull request as ready for review September 29, 2023 16:50
@aaronbuchwald
Copy link
Collaborator

Could we move this into vms/platformvm/warp/payload ?

Copy link
Contributor

@darioush darioush left a comment

Choose a reason for hiding this comment

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

lgtm, should update the doc.

vms/platformvm/warp/payload/README.md Outdated Show resolved Hide resolved
vms/platformvm/warp/payload/README.md Outdated Show resolved Hide resolved
@nytzuga nytzuga force-pushed the move-warp-payload-to-avalanchego branch from b1ab332 to 31125c9 Compare September 29, 2023 23:50
Move warp/payload types to this repo so it can be easily reused from other
subnets.
@nytzuga nytzuga force-pushed the move-warp-payload-to-avalanchego branch from 31125c9 to f13427e Compare September 29, 2023 23:53
vms/platformvm/warp/payload/README.md Outdated Show resolved Hide resolved
Comment on lines 27 to 29
## BlockHashPayload

BlockHashPayload:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this is BlockHashPayload rather than a Hash payload? Seems unnecessarily specific.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is meant to be specific to the BlockHash as opposed to an arbitrary hash. If we changed to an arbitrary hash, the caller would need to have a different way to differentiate between hash types 🤷 .

I don't think there's a need for an arbitrary hash payload at this time, so lmk if you'd prefer I change it anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Going to leave this as BlockHash after removing the Payload suffix.


// AddressedPayload defines the format for delivering a point to point message across VMs
// ie. (ChainA, AddressA) -> (ChainB, AddressB)
type AddressedPayload struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

These types seem to stutter payload.AddressedPayload, payload.BlockHashPayload. I think we could improve the naming here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could go with AddressedCaller and BlockHash. I'll think a bit more about it and push a change here today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Going with AddressedCall and BlockHash

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have some way to parse either payload? It seems a bit odd to me that we expect the user to know which payload format to expect

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is currently used in Subnet-EVM to serve two execution functions in the Warp precompile. In that case, the function returns an error if the warp message includes anything other than the expected payload and does not differentiate between an invalid signature and requesting the wrong type, so it was not needed.

Will add as a convenience function and so we can add a check when verifying warp messages that it matches a valid payload type rather than just checking the signature's validity.

vms/platformvm/warp/payload/payload_test.go Outdated Show resolved Hide resolved
nytzuga and others added 2 commits October 2, 2023 10:35
Co-authored-by: Stephen Buttolph <[email protected]>
Signed-off-by: Cesar <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
Signed-off-by: Cesar <[email protected]>
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 2, 2023
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 2, 2023
// AddressedPayload defines the format for delivering a point to point message across VMs
// ie. (ChainA, AddressA) -> (ChainB, AddressB)
type AddressedPayload struct {
SourceAddress []byte `serialize:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we want to make this generic for all possible chains? (EVM chains use 20 bytes addresses)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, the intent here is to generalize this so that other VMs can use the same format. This will require changing the unpacking in Subnet-EVM / Teleporter as well.

nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 3, 2023
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 3, 2023
@aaronbuchwald aaronbuchwald self-assigned this Oct 4, 2023
- `sourceAddress` is the address that sent this message from the source chain
- `payload` is an arbitrary byte array payload

## BlockHash
Copy link
Contributor

@patrick-ogrady patrick-ogrady Oct 5, 2023

Choose a reason for hiding this comment

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

Should we call this ProofHash or ProofRoot?

Copy link
Contributor

Choose a reason for hiding this comment

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

As we discussed, this may not be strictly a block hash

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is currently used as a BlockHash and making it more generic means that the caller would need to know what kind of hash it's referring to (some context is already needed ofc), so I opted to leave this as BlockHash for now.

If we want to change the name in the future, it is backwards compatible to do so, so I'd prefer to leave this until we actually use it as something other than a BlockHash.

Copy link
Contributor

Choose a reason for hiding this comment

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

As you alluded to, blocks aren't "universal" so the same problem applies to them.

I think locking this terminology in when we communicate it broadly will make us appear a little short-sighted, whereas using the Proof/ProofRoot moniker is forward-looking.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tbh I'd expect using a BlockHash and using that to prove out the rest of the header contents to be simpler.

Do you see this as a more targeted? If a VM would support multiple different types of proofs, how do you foresee them providing context as to what it's proving? Do you foresee them being registered under different typeIDs?

Copy link
Contributor

@patrick-ogrady patrick-ogrady Oct 5, 2023

Choose a reason for hiding this comment

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

I guess I was really excited by the generality/simplicity of using an arbitrary proof structure.

For example, it may be way easier to write a solidity contract to verify a trie of warp message IDs rather than a HyperSDK block. That approach also provides a generic interface that any VM can implement and use previously tested/implemented contracts (which I think will be a huge unlock).

We can enshrine "type 0" of the type to be "block hash" if you want to call that out.

Copy link
Contributor

Choose a reason for hiding this comment

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

In terms of using "hash" in the name, I'm not sure what it should be called. I'm not sure all "proof roots" are "hashes" (maybe they are)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok I guess the context will be up to the Solidity contracts to know what they are talking to based on the chainID, so that they know how it should be interpreted.

As for naming, I'm fine with Hash or Proof

@StephenButtolph StephenButtolph added this to the v1.10.12 milestone Oct 5, 2023
@StephenButtolph StephenButtolph changed the title Integrating Warp Payload Types into AvalancheGo for Cross-VM Compatibility Add Warp Payload Types Oct 5, 2023
@StephenButtolph StephenButtolph added this pull request to the merge queue Oct 5, 2023
@StephenButtolph StephenButtolph added sdk This involves SDK tooling or frameworks warp labels Oct 5, 2023
Merged via the queue into dev with commit 1eaf40b Oct 5, 2023
16 checks passed
@StephenButtolph StephenButtolph deleted the move-warp-payload-to-avalanchego branch October 5, 2023 19:56
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 11, 2023
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 11, 2023
ceyonur pushed a commit to ava-labs/subnet-evm that referenced this pull request Oct 12, 2023
* Integrating Warp Payload Types into AvalancheGo for Cross-VM Compatibility

This fixes ava-labs/avalanchego#2050 and ava-labs/avalanchego#2116

* Update types

* Do not update go.sum

* Fixed more type changes from the migration

* Drop the alias `avalancheWarpPayload`

The alias is not longer needed

---------

Co-authored-by: Aaron Buchwald <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk This involves SDK tooling or frameworks warp
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants