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

warp: add "requirePrimaryNetworkSigners" precompile config #1232

Merged
merged 18 commits into from
Aug 22, 2024

Conversation

darioush
Copy link
Collaborator

@darioush darioush commented Jul 9, 2024

Why this should be merged

#1230

How this works

Adds a precompile config option where "requirePrimaryNetworkSigners" can be added at warp activation (or de-activated and then re-activated with this flag by existing networks).

Note we can't use a "per node" config, since when the optimization is applied the validator bitset is modified.
Basically the existing rules do not allow for the primary network's validators to sign for themselves but expects only the subnet validator set. Since the entire validator set is replaced, this includes expectations for the bitset, etc.

How this was tested

CI:

  1. Expands UT for TestWarpMessageFromPrimaryNetwork (in precompile/contracts/warp/predicate_test.go) to include both cases for requirePrimaryNetworkSigners,

  2. Modifies (expands) TestReceiveWarpMessage:

  • first asserting warp messages can be received as expected with the default config (no RequirePrimaryNetworkSigners) for messages from subnets, non-P chain primary and P-Chain primary, this ensures no regression for existing networks,
  • disabling then re-enabling the warp configuration with RequirePrimaryNetworkSigners (note disabling is required as it is not allowed allowed to update the precompile config)
  • next asserting its behavior again with the RequirePrimaryNetworkSigners (non P-Chain primary network chains should use primary network).

I also added a check the result of the predicate in the block since the previous test asserts behavior about whether the block is valid or not in a different height context, but the block would be considered valid (but failed warp message), then the assertion that does a trace comes later.

It seemed preferable to verify the predicate results are as expected instead of re-ordering the existing code.

How is this documented

Not yet

precompile/contracts/warp/config.go Outdated Show resolved Hide resolved
plugin/evm/vm.go Outdated Show resolved Hide resolved
@darioush darioush marked this pull request as ready for review August 19, 2024 14:53
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
Signed-off-by: Darioush Jalali <darioush.jalali@avalabs.org>
…bs/subnet-evm into warp-requirePrimaryNetworkSigners
plugin/evm/vm.go Outdated Show resolved Hide resolved
ceyonur
ceyonur previously approved these changes Aug 20, 2024
Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

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

overall LGTM, just a nit to convert the function to an interface

plugin/evm/vm.go Outdated Show resolved Hide resolved
plugin/evm/vm.go Outdated Show resolved Hide resolved
plugin/evm/vm.go Outdated Show resolved Hide resolved
precompile/contracts/warp/config.go Outdated Show resolved Hide resolved
precompile/contracts/warp/config.go Outdated Show resolved Hide resolved
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
plugin/evm/vm_warp_test.go Show resolved Hide resolved
@ARR4N
Copy link
Contributor

ARR4N commented Aug 20, 2024

How this was tested

CI

I think the intention of this block is an explanation of what tests are being performed. I see that you made changes to the unit tests but I don't have the context to understand why they are sufficient to prove that this works.

plugin/evm/vm_warp_test.go Show resolved Hide resolved
plugin/evm/vm_warp_test.go Outdated Show resolved Hide resolved
precompile/contracts/warp/config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the changes.

Caveat: I don't know enough about the specific test cases in the table nor the implication of mySubnetID in validators.NewState() to comment on them, but I think it's all now clear enough that I'm deferring to Cey's existing Approval.

Copy link
Contributor

@michaelkaplan13 michaelkaplan13 left a comment

Choose a reason for hiding this comment

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

Makes sense to me 🙏

@darioush darioush enabled auto-merge (squash) August 22, 2024 17:10
@darioush darioush merged commit b0abb3b into master Aug 22, 2024
13 checks passed
@darioush darioush deleted the warp-requirePrimaryNetworkSigners branch August 22, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants