-
Notifications
You must be signed in to change notification settings - Fork 94
feat: preinstalls #226
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
feat: preinstalls #226
Conversation
x/vm/types/preinstall.go
Outdated
import "github.com/ethereum/go-ethereum/common" | ||
|
||
type Preinstall struct { | ||
Address common.Address |
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.
Could we add names here to keep track of what these are?
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.
Yeah, I think that is a good idea. I will be doing that!
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.
Done!
x/vm/module.go
Outdated
@@ -127,6 +127,11 @@ func (AppModule) Name() string { | |||
func (am AppModule) RegisterServices(cfg module.Configurator) { | |||
types.RegisterMsgServer(cfg.MsgServer(), am.keeper) | |||
types.RegisterQueryServer(cfg.QueryServer(), am.keeper) | |||
|
|||
m := keeper.NewMigrator(am.keeper) | |||
if err := cfg.RegisterMigration(types.ModuleName, 9, m.Migrate9to10); err != nil { |
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.
Same as above - I want to avoid having migrations for modules before v1
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.
Done!
x/vm/genesis.go
Outdated
@@ -57,6 +57,10 @@ func InitGenesis( | |||
} | |||
} | |||
|
|||
if err := k.AddPreinstalls(ctx, types.DefaultPreinstalls); err != nil { |
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.
Could we add this into the evmd instead? I'm thinking that we could pass in the default preinstalls as a default there, but allow anyone to specify their own precompiles upon genesis inside their app
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.
Yeah for sure, I also felt there was something slightly off about this, so I will take another look to make this more reasonable.
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.
I've made this change as well, let me know if it is what you had in mind.
I haven't really tested it yet, is there a good way to test evmd genesis that I should be doing beyond what I have added unit tests for?
I believe I've made the required changes, so putting this in ready-for-review. |
// return errorsmod.Wrapf(types.ErrInvalidPreinstall, "preinstall %s already has an account in account keeper", preinstall.Address.String()) | ||
// create account with the account keeper | ||
account := k.accountKeeper.NewAccountWithAddress(ctx, accAddress) | ||
k.accountKeeper.SetAccount(ctx, account) |
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.
Why do we not want to error when an account exists--like you have in the comment?
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.
Oh yeah, this was actually something I hadn't fully finished thinking through, but the initial thinking was that this would be problematic these already existed. After the changes, this should not really happen, I think.
I'll have another look at this part!
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 is also an option to check here if this already exists, and then also check if the given account and code all match, and then just ignore and continue. Not sure if that is a legit scenario though 🤔
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.
Oh yeah, I might have done this because all the integration tests fail with this. It seems like they don't reset the account keeper or something.
I'm a bit lost with this integration test suite. Any pointers from you or @vladjdk on this?
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.
@@ -27,7 +27,7 @@ import ( | |||
) | |||
|
|||
// consensusVersion defines the current x/evm module consensus version. | |||
const consensusVersion = 9 | |||
const consensusVersion = 10 |
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.
Let's leave this--I think we're going to reset this for the production release since I don't think anyone is actually running module version 9.
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.
I'm going to merge this and follow up on a couple of things in a separate PR.
Thanks @gjermundgaraba !
I want to discuss how we add this, and if we want any temporary stuff or how we should do this.
In the current code I have the following:
The questions I have are:
a. Eric mentioned maybe wanting a cli command to add pre-installs. I could do that, but it seems like temporary code we might now want in the evm repo
b. If this is primarily to add them to the running testnet, I would suggest just changing the gaia binary being used to call the `keeper.Add