Skip to content

Commit 6fafbe0

Browse files
committed
wire rollback command
1 parent 96fd078 commit 6fafbe0

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

evolve/template/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ const (
1515
EvNodePackage = "github.com/evstack/ev-node"
1616
EvNodeVersion = "v1.0.0-beta.2.0.20250819153439-29b8ddf5a753"
1717

18+
GoDataStorePackageFork = "github.com/celestiaorg/go-datastore"
19+
GoDataStoreVersionFork = "v0.0.0-20250801131506-48a63ae531e4"
20+
GoDataStorePackage = "github.com/ipfs/go-datastore"
21+
1822
EvNodeDaCmd = "github.com/evstack/ev-node/da/cmd/local-da"
1923
)

evolve/template/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func NewEvolveGenerator(chain *chain.Chain, withCometMigration bool) (*genny.Gen
3030

3131
g.RunFn(commandsStartModify(appPath, binaryName, chain.Version))
3232
g.RunFn(commandsGenesisModify(appPath, binaryName))
33+
g.RunFn(commandsRollbackModify(appPath, binaryName))
3334
if withCometMigration {
3435
g.RunFn(migrateFromCometModify(appPath))
3536
}

evolve/template/init.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,35 @@ func commandsGenesisModify(appPath, binaryName string) genny.RunFn {
128128
}
129129
}
130130

131+
// commandsRollbackModify modifies the application rollback command to use evolve.
132+
func commandsRollbackModify(appPath, binaryName string) genny.RunFn {
133+
return func(r *genny.Runner) error {
134+
cmdPath := filepath.Join(appPath, "cmd", binaryName, "cmd/commands.go")
135+
f, err := r.Disk.Find(cmdPath)
136+
if err != nil {
137+
return err
138+
}
139+
140+
// use ast to modify the function that initializes genesisCmd
141+
content, err := xast.ModifyFunction(f.String(), "initRootCmd",
142+
xast.AppendFuncCode(`
143+
// override rollback command
144+
evNodeRollbackCmd := abciserver.NewRollbackCmd(newApp, app.DefaultNodeHome)
145+
if currentRollbackCmd, _, err := rootCmd.Find([]string{evNodeRollbackCmd.Name()}); err == nil{
146+
rootCmd.RemoveCommand(currentRollbackCmd)
147+
}
148+
rootCmd.AddCommand(evNodeRollbackCmd)
149+
`,
150+
),
151+
)
152+
if err != nil {
153+
return err
154+
}
155+
156+
return r.File(genny.NewFileS(cmdPath, content))
157+
}
158+
}
159+
131160
// updateDependencies makes sure the correct dependencies are added to the go.mod files.
132161
// ev-abci expects evolve v1 to be used.
133162
func updateDependencies(appPath string) error {
@@ -144,6 +173,9 @@ func updateDependencies(appPath string) error {
144173
return errors.Errorf("failed to add local-da tool: %w", err)
145174
}
146175

176+
// add required replaces
177+
gomod.AddReplace(GoDataStorePackage, "", GoDataStorePackageFork, GoDataStoreVersionFork)
178+
147179
// save go.mod
148180
data, err := gomod.Format()
149181
if err != nil {

0 commit comments

Comments
 (0)