@@ -120,16 +120,64 @@ func (a *Activity) createRepositoryIfNotExists(ctx context.Context) error {
120120 return nil
121121}
122122
123+ // generateReplace generates a replace directive for a specific module version
124+ // This forces a specific version of a dependency
123125func generateReplace (dependencies map [string ]string , owner , repo , tag string ) string {
124126 orig := dependencies [fmt .Sprintf ("%s/%s" , owner , repo )]
125127 return fmt .Sprintf ("go mod edit -replace %s=github.com/%s/%s@%s" , orig , owner , repo , tag )
126128}
127129
128- func generateTag (imageName , version , repo , sha string ) string {
130+ func generateMultipleReplaces (req messages.BuildDockerImageRequest ) string {
131+ var replaceCommands []string
132+
133+ // For cometbft builds, replace cometbft dependency in cosmos-sdk simapp
134+ if req .Repo == "cometbft" {
135+ replaceCommands = append (replaceCommands ,
136+ generateReplace (dependencies , repoOwners [req .Repo ], req .Repo , req .SHA ))
137+ }
138+
139+ // For EVM builds with optional SDK version override
140+ if req .CosmosSdkSha != "" {
141+ replaceCommands = append (replaceCommands ,
142+ generateReplace (dependencies , repoOwners ["cosmos-sdk" ], "cosmos-sdk" , req .CosmosSdkSha ))
143+ }
144+
145+ // For EVM builds with optional CometBFT version override
146+ if req .CometBFTSha != "" {
147+ replaceCommands = append (replaceCommands ,
148+ generateReplace (dependencies , repoOwners ["cometbft" ], "cometbft" , req .CometBFTSha ))
149+ }
150+
151+ return strings .Join (replaceCommands , " && " )
152+ }
153+
154+ func generateTag (req messages.BuildDockerImageRequest ) string {
155+ imageName := req .ImageConfig .Image
156+ version := req .ImageConfig .Version
157+ repo := req .Repo
158+ sha := req .SHA
159+
129160 if repo == "cometbft" {
130161 return fmt .Sprintf ("%s-%s-%s-%s" , imageName , version , repo , sha )
131162 }
132- return fmt .Sprintf ("%s-%s" , repo , sha )
163+
164+ // For EVM builds, include SDK and CometBFT versions in tag if specified
165+ // This ensures different dependency versions get different image tags
166+ tag := fmt .Sprintf ("%s-%s" , repo , sha )
167+ if req .CosmosSdkSha != "" {
168+ // Sanitize the version string to be tag-friendly (remove @ and special chars)
169+ sdkVersion := strings .ReplaceAll (req .CosmosSdkSha , "@" , "-" )
170+ sdkVersion = strings .ReplaceAll (sdkVersion , "/" , "-" )
171+ tag = fmt .Sprintf ("%s-sdk-%s" , tag , sdkVersion )
172+ }
173+ if req .CometBFTSha != "" {
174+ // Sanitize the version string to be tag-friendly
175+ cometVersion := strings .ReplaceAll (req .CometBFTSha , "@" , "-" )
176+ cometVersion = strings .ReplaceAll (cometVersion , "/" , "-" )
177+ tag = fmt .Sprintf ("%s-comet-%s" , tag , cometVersion )
178+ }
179+
180+ return tag
133181}
134182
135183func (a * Activity ) imageExistsInECR (ctx context.Context , tag string ) (bool , error ) {
@@ -165,7 +213,7 @@ func (a *Activity) imageExistsInECR(ctx context.Context, tag string) (bool, erro
165213func (a * Activity ) BuildDockerImage (ctx context.Context , req messages.BuildDockerImageRequest ) (messages.BuildDockerImageResponse , error ) {
166214 logger , _ := zap .NewDevelopment ()
167215
168- tag := generateTag (req . ImageConfig . Image , req . ImageConfig . Version , req . Repo , req . SHA )
216+ tag := generateTag (req )
169217
170218 var username , password string
171219 var err error
@@ -242,15 +290,22 @@ func (a *Activity) BuildDockerImage(ctx context.Context, req messages.BuildDocke
242290 buildArguments := make (map [string ]string )
243291 buildArguments ["GIT_SHA" ] = tag
244292
293+ // Generate replace commands for go.mod modifications
294+ replaceCmd := generateMultipleReplaces (req )
295+
245296 // When load testing CometBFT, we build a simapp image using a specified SDK version, and then edit go.mod to replace
246297 // CometBFT with the specified commit SHA
247298 if req .Repo == "cometbft" {
248299 buildArguments ["CHAIN_SRC" ] = "https://github.com/cosmos/cosmos-sdk"
249300 buildArguments ["CHAIN_TAG" ] = req .ImageConfig .Version
250- buildArguments ["REPLACE_CMD" ] = generateReplace ( dependencies , repoOwners [ req . Repo ], req . Repo , req . SHA )
301+ buildArguments ["REPLACE_CMD" ] = replaceCmd
251302 } else {
252303 buildArguments ["CHAIN_TAG" ] = req .SHA
253304 buildArguments ["CHAIN_SRC" ] = fmt .Sprintf ("https://github.com/%s/%s" , repoOwners [req .Repo ], req .Repo )
305+ // For EVM builds with optional replacements
306+ if replaceCmd != "" {
307+ buildArguments ["REPLACE_CMD" ] = replaceCmd
308+ }
254309 }
255310
256311 for k , v := range buildArguments {
0 commit comments