-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
EVM Relayer DB migrations PoC #13617
Conversation
note: discovered wrongly schema'd eth_txs types
I see you updated files related to
|
6188659
to
1715ce5
Compare
6427ad9
to
b73cfaf
Compare
b73cfaf
to
9af599a
Compare
9af599a
to
76fc0b8
Compare
@@ -79,6 +92,13 @@ func (cc *EVMForwardersController) Delete(c *gin.Context) { | |||
jsonAPIError(c, http.StatusUnprocessableEntity, err) | |||
return | |||
} | |||
// this is a breaking change, but it's necessary to support multiple chains | |||
chainId, err := stringutils.ToInt64(c.Param("chainID")) |
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 don't know much about the forwarder, but if we didn't support multiple chains before... how did it work, you could only use forwarders on the default chain or something?
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.
no, we were leaking the DB id and expecting user to use that. that DB id was unique b/c all the forwarders were in one table
var evmInitialState string | ||
|
||
// NewEVMDB creates a new EVM database with the given schema and chainId | ||
func NewDB(t testing.TB, cfg evm.Cfg) *sqlx.DB { |
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.
Name of function in comment should match name of function
err = evmdb.Migrate(context.Background(), db, evmdb.Cfg{ | ||
Schema: "evm_" + chain.ID().String(), | ||
ChainID: ubig.New(chain.ID()), | ||
}) |
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.
Have we thought through what happens if the node gets shut down while the relay is migrating? Is completing the migration what we want, or would it be better to abort?
goose.AddMigrationContext(upFunc, downFunc) | ||
return 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.
TODO: remove if unused
if err != nil { | ||
return nil, err | ||
} | ||
b := make([]byte, 1024*1024) |
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 not sure how to do this cleanly off the top of my head, but I assume once we get past the initial draft stage, we'd want to make this able to handle arbitrarily large migration files. If not, we should at least make it a constant or config option so we can increase it later if needed.
} | ||
*/ | ||
// Migrate migrates a subsystem of the chainlink database. | ||
// It generates migrations based on the template for the subsystem and applies them to the database. |
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.
TODO: update comment to be evm specific (I assume "chainlink database" will no longer be a meaningful concept, right?)
return fmt.Errorf("failed to generate migrations for opt %v: %w", cfg, err) | ||
} | ||
fmt.Printf("Generated migrations: %v\n", migrations) | ||
*/ |
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.
Getting a little confused about all of the commented code. I see setupPluginMigraitons is commented out, as well as
Register0002, then this portion of
Migratewhich calls
generateMigrationsis commented, even though
generateMigrations` is uncommented? Which of these will we end up using, or are they all still WIP?
@@ -72,6 +74,7 @@ func (r *RelayerFactory) NewEVM(ctx context.Context, config EVMFactoryConfig) (m | |||
|
|||
relayerOpts := evmrelay.RelayerOpts{ | |||
DS: ccOpts.DS, | |||
DBURL: &dburl, |
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.
Cool, so... we tell all relays to use the databse url in the global toml config (config.AppConfig.Database().URL()
) by default, but allow it to be overridden on a per-relay basis by reading the CL_DATABASE
environment variable that's set locally on each running relay? I think that makes sense
I don't see any big problems with this approach, seems like some good progress in the right direction. Left some minor comments and questions, but most of them may not be too relevant at this stage as it's such an early draft--I assume more of the details will be filled in as it progresses. |
977375d
to
c2b2a28
Compare
Quality Gate failedFailed conditions See analysis details on SonarQube Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Ticket
BCF-3266
The point of this PR is to propose a mechanism for DB migrations that are scoped to schema.
The motivation is that (one day) LOOPPs will need to own and manage migrations.
The scope of this example is:
core/store/migrate/plugins
for all the feature worknode db migrate|rollback|status|version --relayer evm -chain-id <id>
- if one test use evm relayer chainid=7 and other chainid=11, they have different resource requirements
Out of scope
Opens:
rollback
Requires Dependencies
Resolves Dependencies