Skip to content

Conversation

gjermundgaraba
Copy link
Contributor

@gjermundgaraba gjermundgaraba commented Jun 17, 2025

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:

  • A method on the vm keeper that takes in a list of preinstalls and sets them
  • Calling said method from InitGenesis with a list of types.DefaultPreinstalls (this could be changed to making it actually configurable in Genesis, as well)
  • A store migration from 9 to 10 that also adds the same default list (I've not added tests for this yet, because I want to answer the questions below first)

The questions I have are:

  1. What mechanism do we want to use for this?
    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
  2. How configurable do we need this to be right now?

@gjermundgaraba gjermundgaraba requested a review from vladjdk June 17, 2025 19:32
import "github.com/ethereum/go-ethereum/common"

type Preinstall struct {
Address common.Address
Copy link
Member

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?

Copy link
Contributor Author

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!

Copy link
Contributor Author

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 {
Copy link
Member

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

Copy link
Contributor Author

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 {
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

@gjermundgaraba
Copy link
Contributor Author

I believe I've made the required changes, so putting this in ready-for-review.
I also linted the proto files, so got some extra changes from that. I hope that's OK, if not I can revert that commit.

@gjermundgaraba gjermundgaraba marked this pull request as ready for review June 25, 2025 21:08
@gjermundgaraba gjermundgaraba requested a review from vladjdk June 25, 2025 21:09
Comment on lines +37 to +40
// 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)
Copy link
Contributor

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?

Copy link
Contributor Author

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!

Copy link
Contributor Author

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 🤔

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Which tests? All integ tests are passing with this diff
Screenshot 2025-06-26 at 12 05 32 PM

@@ -27,7 +27,7 @@ import (
)

// consensusVersion defines the current x/evm module consensus version.
const consensusVersion = 9
const consensusVersion = 10
Copy link
Contributor

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.

Copy link
Contributor

@Eric-Warehime Eric-Warehime left a 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 !

@Eric-Warehime Eric-Warehime merged commit 9b96d1f into main Jun 26, 2025
18 checks passed
@Eric-Warehime Eric-Warehime deleted the gjermund/preinstalls branch June 26, 2025 21:50
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.

3 participants