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 teleporter messenger to genesis #474

Merged
merged 14 commits into from
Aug 9, 2024

Conversation

michaelkaplan13
Copy link
Collaborator

@michaelkaplan13 michaelkaplan13 commented Aug 1, 2024

Why this should be merged

Fixes #464

How this works

  • In the E2E tests, the TeleporterMessenger contract is directly inserted into the alloc section of the two Subnet chains genesis files. The contract is still deployed to the C-Chain using the Nick's method transaction.
  • Adds documentation to READMEs on include the contract in a chain's genesis.

@michaelkaplan13 michaelkaplan13 marked this pull request as ready for review August 5, 2024 19:18
@michaelkaplan13 michaelkaplan13 requested a review from a team as a code owner August 5, 2024 19:18

**Do not deploy the `TeleporterMessenger` contract using `forge create`**. The `TeleporterMessenger` contract must be deployed to the same contract address on every chain. To achieve this, the contract can be deployed using a static transaction that uses Nick's method as documented in [this guide](https://github.com/ava-labs/teleporter/blob/main/utils/contract-deployment/README.md). Alternatively, if creating a new Subnet, the contract can be pre-allocated with the proper address and state in the new chain's [genesis file](https://docs.avax.network/build/subnet/upgrade/customize-a-subnet#setting-the-genesis-allocation).

As an example, to include `TeleporterMessenger` `v1.0.0` in the genesis file, include the following values in the `alloc` settings, as documented at the link above.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to explain each of these fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Happy to add them, but found that the descriptions of balance/code/nonce/storage were all pretty trivial since they are relatively self-describing for an address in the context of the EVM. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Of those, the only nontrivial one is storage, since it's not obvious that this refers to the ReentrancyGuards

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah...yeah good call out, thanks. Added an explanation now 👍

tests/local/network.go Outdated Show resolved Hide resolved
@@ -40,51 +39,61 @@ func TestE2E(t *testing.T) {

// Define the Teleporter before and after suite functions.
var _ = ginkgo.BeforeSuite(func() {
// Generate the Teleporter deployment values
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be helpful in some debugging scenarios to provide an easy way to deploy Teleporter to all subnets via eth_sendRawTransaction versus genesis. Some ideas that come to mind:

  • An explicit command line flag. I'm not sure if being able to make this switch at runtime is worth the added complexity.
  • Add a bool param deployViaGenesis to NewLocalNetwork. Then the only changes required are true->false and DeployTeleporterContractToCChain -> DeployTeleporterContractToAllSubnets`
    • Can be further simplified if DeployTeleporterContractToAllSubnets can be made idempotent so that it can be called in all scenarios.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What are the benefits of having those two different options for the E2E test execution that you were thinking of?

For local E2E tests, I think this covers both deployment flows sufficiently.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just anticipating any issues arising from the different deployment methods. In such a scenario, being able to toggle between the two could be helpful. For instance, if a future change comes with state initialization in the same way as ReentrancyGuards, switching to Nick's method would help narrow down any differences.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can punt on this for now personally. Have the default E2E cover both possible deployment flows should hopefully ensure we keep them both up-to-date and compatible with any future changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Any test failures along these lines would require root cause analysis anyway, something the suggested change would likely not help much with.

)
LocalNetworkInstance.SetTeleporterContractAddress(teleporterContractAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously this was encapsulated in the call to DeployTeleporterContracts. Can we similarly do so in DeployTeleporterContractToCChain and/or NewLocalNetwork?

Copy link
Collaborator Author

@michaelkaplan13 michaelkaplan13 Aug 6, 2024

Choose a reason for hiding this comment

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

I think it was a little odd previously actually. There was a boolean parameter in one exported function for whether or not another exported function should be called from it. Since they are both exported, I think it's cleaner to make them independent and left up to the caller.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I had forgotten about that switch. Agreed, makes sense to keep them separate.

geoff-vball
geoff-vball previously approved these changes Aug 6, 2024
Copy link
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

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

👍

Co-authored-by: cam-schultz <[email protected]>
Signed-off-by: Michael Kaplan <[email protected]>
cam-schultz
cam-schultz previously approved these changes Aug 8, 2024
@michaelkaplan13 michaelkaplan13 merged commit 3dce2a8 into main Aug 9, 2024
14 checks passed
@michaelkaplan13 michaelkaplan13 deleted the add-teleporter-messenger-to-genesis branch August 9, 2024 14:05
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.

Investigate adding TeleporterMessenger to template genesis configuration
3 participants