-
Notifications
You must be signed in to change notification settings - Fork 220
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
x/warp: add predicate test for warp message from Primary Network #831
Conversation
snowCtx.SubnetID = ids.GenerateTestID() | ||
snowCtx.ChainID = ids.GenerateTestID() | ||
snowCtx.CChainID = cChainID | ||
snowCtx.NetworkID = networkID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we actually use constants.PrimaryNetworkID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the line below to return constants.PrimaryNetworkID
instead of ids.Empty
. The SubnetID
declared here is meant to be a non-PrimaryNetwork SubnetID since it's receiving from the PrimaryNetwork in this test.
x/warp/predicate_test.go
Outdated
snowCtx.NetworkID = networkID | ||
snowCtx.ValidatorState = &validators.TestState{ | ||
GetSubnetIDF: func(ctx context.Context, chainID ids.ID) (ids.ID, error) { | ||
if chainID != cChainID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the whole test to use require.New(t)
x/warp/predicate_test.go
Outdated
return ids.Empty, nil // Return Primary Network SubnetID | ||
}, | ||
GetValidatorSetF: func(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { | ||
if subnetID != snowCtx.SubnetID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again require.Equal
could be used here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating
snowCtx.ChainID = ids.GenerateTestID() | ||
snowCtx.CChainID = cChainID | ||
snowCtx.NetworkID = networkID | ||
snowCtx.ValidatorState = &validators.TestState{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some comments why this is a specific behavior for primary network and what do we expect? It's a bit unclear why the test name has primary network but there is actually no primary network being used in the tests. I
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test verifies a message that is sent by the primary network, so the name is FromPrimaryNetwork
. The behavior for C-Chain to Subnet message handling is documented here: https://github.com/ava-labs/subnet-evm/blob/warp-primary-network-unit-test/x/warp/README.md#performance-optimization-c-chain-to-subnet.
Is this sufficient or would you prefer a comment on the test itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sufficient, I was just expecting to see primary network ID.
979bc87
to
f2da93a
Compare
* Warp stapling block context (#823) * Add GetPredicateResults to BlockContext * Serve predicate results from blockContext * Allow extra data to extend past DynamicFeeWindow post DUpgrade * Get vm warp unit tests working * Bump ANR to intermediate version to fix incompatibility with AvalancheGo * Add kc to EthKeyChain * Bump avalanchego dep in scripts for CI * Add block hash payload support * Use gomocks for precompileconfig and predicater and re-write CheckPredicates with gomocks * Use gomock for mock accessible state and block context * Fix existing warp contract tests with mock block context * Remove unused mockPredicater impl * x/warp: add contract execution unit tests * Update NewEVMBlockContext * Add AppendExtra to syncervm to fix tests * x/warp: add unit test for multiple predicate results * core: add unit test for CheckPredicates insufficient gas * Update receive warp message test to trace block and assert the expected result * Fix lint * Update warp solidity contracts * Fix block context mocks for bench * Update precompile/precompileconfig/config.go Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org> Signed-off-by: aaronbuchwald <aaron.buchwald56@gmail.com> * Cleanup * precompile/results: Add predicate results tests + comments * nits * precompile/results: omit tx predicate results if empty * core: add invariant comment to predicate check * Address PR comments * Fix unpackWarpMessage and add unit tests * Rename OriginChainID -> SourceChainID to match ago warp message type * nits * x/warp: set public key in warp predicate unit tests * Update payload format * Clarify IWarpMessenger verified message return types * core/state: improve statedb warp specific comments * Update input param type to uint32 to avoid potential overflow on conversion * Update GetPredicateStorageSlots arg type to uint32 * warp/payload: add README for payload serialization (#835) * Fix merge * x/warp: add unit test for PrimaryNetwork to Subnet predicate verification (#831) * precompilebind: add ChainConfig with DUpgrade enabled to precompile chain config verify template
* update npm package * expand allowlist.configure * add activation func to precompile functions * move chainconfig to precompileconfig * use chainconfig in verification * trim unnecessary changes * add manager role * fix tests * add verify test * nits * add mocks * reviews * fix linter * fix benchmarks * nits * nits * fix alow list bind tests & ensure they're being tested (#841) * simplify can modify check * fix vm tests * Add manager allowlist role merge (#850) * Warp stapling block context (#823) * Add GetPredicateResults to BlockContext * Serve predicate results from blockContext * Allow extra data to extend past DynamicFeeWindow post DUpgrade * Get vm warp unit tests working * Bump ANR to intermediate version to fix incompatibility with AvalancheGo * Add kc to EthKeyChain * Bump avalanchego dep in scripts for CI * Add block hash payload support * Use gomocks for precompileconfig and predicater and re-write CheckPredicates with gomocks * Use gomock for mock accessible state and block context * Fix existing warp contract tests with mock block context * Remove unused mockPredicater impl * x/warp: add contract execution unit tests * Update NewEVMBlockContext * Add AppendExtra to syncervm to fix tests * x/warp: add unit test for multiple predicate results * core: add unit test for CheckPredicates insufficient gas * Update receive warp message test to trace block and assert the expected result * Fix lint * Update warp solidity contracts * Fix block context mocks for bench * Update precompile/precompileconfig/config.go Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org> Signed-off-by: aaronbuchwald <aaron.buchwald56@gmail.com> * Cleanup * precompile/results: Add predicate results tests + comments * nits * precompile/results: omit tx predicate results if empty * core: add invariant comment to predicate check * Address PR comments * Fix unpackWarpMessage and add unit tests * Rename OriginChainID -> SourceChainID to match ago warp message type * nits * x/warp: set public key in warp predicate unit tests * Update payload format * Clarify IWarpMessenger verified message return types * core/state: improve statedb warp specific comments * Update input param type to uint32 to avoid potential overflow on conversion * Update GetPredicateStorageSlots arg type to uint32 * warp/payload: add README for payload serialization (#835) * Fix merge * x/warp: add unit test for PrimaryNetwork to Subnet predicate verification (#831) * precompilebind: add ChainConfig with DUpgrade enabled to precompile chain config verify template
* update npm package * expand allowlist.configure * add activation func to precompile functions * move chainconfig to precompileconfig * use chainconfig in verification * trim unnecessary changes * add manager role * fix tests * add verify test * nits * add mocks * reviews * fix linter * fix benchmarks * nits * nits * fix alow list bind tests & ensure they're being tested (#841) * simplify can modify check * fix vm tests * Add manager allowlist role merge (#850) * Warp stapling block context (#823) * Add GetPredicateResults to BlockContext * Serve predicate results from blockContext * Allow extra data to extend past DynamicFeeWindow post DUpgrade * Get vm warp unit tests working * Bump ANR to intermediate version to fix incompatibility with AvalancheGo * Add kc to EthKeyChain * Bump avalanchego dep in scripts for CI * Add block hash payload support * Use gomocks for precompileconfig and predicater and re-write CheckPredicates with gomocks * Use gomock for mock accessible state and block context * Fix existing warp contract tests with mock block context * Remove unused mockPredicater impl * x/warp: add contract execution unit tests * Update NewEVMBlockContext * Add AppendExtra to syncervm to fix tests * x/warp: add unit test for multiple predicate results * core: add unit test for CheckPredicates insufficient gas * Update receive warp message test to trace block and assert the expected result * Fix lint * Update warp solidity contracts * Fix block context mocks for bench * Update precompile/precompileconfig/config.go Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org> Signed-off-by: aaronbuchwald <aaron.buchwald56@gmail.com> * Cleanup * precompile/results: Add predicate results tests + comments * nits * precompile/results: omit tx predicate results if empty * core: add invariant comment to predicate check * Address PR comments * Fix unpackWarpMessage and add unit tests * Rename OriginChainID -> SourceChainID to match ago warp message type * nits * x/warp: set public key in warp predicate unit tests * Update payload format * Clarify IWarpMessenger verified message return types * core/state: improve statedb warp specific comments * Update input param type to uint32 to avoid potential overflow on conversion * Update GetPredicateStorageSlots arg type to uint32 * warp/payload: add README for payload serialization (#835) * Fix merge * x/warp: add unit test for PrimaryNetwork to Subnet predicate verification (#831) * precompilebind: add ChainConfig with DUpgrade enabled to precompile chain config verify template
This PR adds a unit test for verifying a warp message from the Primary Network correctly uses the validator set of the receiving subnet.