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

Nits #52

Merged
merged 3 commits into from
Mar 11, 2022
Merged

Nits #52

merged 3 commits into from
Mar 11, 2022

Conversation

aaronbuchwald
Copy link
Collaborator

This PR:

  1. Does a cleanup of the minter precompile test suite
  2. Moves VM errors into their own package so they can be shared across the EVM and precompiles in their own package
  3. Reverts the change that makes it so only explicitly allowed addresses can mint (makes it so that admins are enabled as well)

core/stateful_precompile_test.go Outdated Show resolved Hide resolved
@@ -83,7 +84,7 @@ func (s AllowListRole) IsAdmin() bool {
// IsEnabled returns true if [s] indicates that it has permission to access the resource.
func (s AllowListRole) IsEnabled() bool {
switch s {
case AllowListEnabled:
case AllowListAdmin, AllowListEnabled:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this is kind-of misleading since both of role name and function contains Enabled however the function returns true for Admin as well. Plus do we really want admins to be able to mint tokens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Admin is a strictly higher and should be considered enabled as well. If we don't consider it enabled, then the UX for an admin will be that they have to create a new address, mark it as enabled, and then mint funds from that address. It's much simpler if we just treat Admin as a strictly higher privilege level.

core/stateful_precompile_test.go Show resolved Hide resolved
core/stateful_precompile_test.go Show resolved Hide resolved
core/stateful_precompile_test.go Show resolved Hide resolved
},
"mint big": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why have we removed this test-case? I'd prefer to test mint capabilities here instead of allowList capabilities. (or preferably both of them).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added it back in. I didn't think this was really different than the other minting test case.

@@ -153,7 +154,7 @@ func createAllowListRoleSetter(precompileAddr common.Address, role AllowListRole
modifyAddress := common.BytesToAddress(input)

if readOnly {
return nil, remainingGas, ErrWriteProtection
return nil, remainingGas, vmerrs.ErrWriteProtection
Copy link
Collaborator

Choose a reason for hiding this comment

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

ooh seems I imported go-ethereum vm package, instead of subnet-evm. that's why it worked haha

Copy link
Collaborator

Choose a reason for hiding this comment

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

but certainly not a bad idea? :P

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 should migrate to a separate package. We should not rely on any geth packages where we also have the same package present in our code.

// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package vmerrs
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we rename this to error as it's actually not in the vm package? or maybe at least vmerrors?

Copy link
Collaborator

Choose a reason for hiding this comment

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

alternatively we can try to import VM package from geth for errors? it won't be a clean way but still works, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently this is specific to vm errors, I'd be alright with renaming it to vmerrors, but prefer the shortened vmerrs tbh.

Same comment on importing the VM package as above.

aaronbuchwald and others added 2 commits March 11, 2022 09:41
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
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.

LGTM 👍

@aaronbuchwald aaronbuchwald merged commit 1b7c1ad into minter-precompile Mar 11, 2022
@aaronbuchwald aaronbuchwald deleted the minter-precompile-nits branch May 5, 2022 17:10
aaronbuchwald pushed a commit that referenced this pull request Feb 2, 2023
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.

2 participants