Skip to content

Commit 7cf92b7

Browse files
Fix MaruCluster config after merge regression (#459)
* Fix MaruCluster config after merge regression
1 parent be0fb67 commit 7cf92b7

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

jvm-libs/test-utils/src/main/kotlin/maru/test/cluster/MaruConfigHelper.kt

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import kotlin.time.Duration.Companion.seconds
1616
import maru.config.ApiConfig
1717
import maru.config.ApiEndpointConfig
1818
import maru.config.FollowersConfig
19+
import maru.config.ForkTransition
1920
import maru.config.MaruConfig
2021
import maru.config.ObservabilityConfig
2122
import maru.config.P2PConfig
@@ -32,12 +33,8 @@ val configTemplate: MaruConfig =
3233
MaruConfig(
3334
allowEmptyBlocks = true,
3435
persistence = Persistence(dataPath = Path.of("maru-data")),
35-
validatorElNode =
36-
ValidatorElNode(
37-
payloadValidationEnabled = false,
38-
ethApiEndpoint = ApiEndpointConfig(URI.create("http://replace-me:8545").toURL()),
39-
engineApiEndpoint = ApiEndpointConfig(URI.create("http://replace-me:8551").toURL()),
40-
),
36+
forkTransition = ForkTransition(),
37+
validatorElNode = null,
4138
api = ApiConfig(port = 0u),
4239
qbft = null, // Followers by default
4340
p2p =
@@ -124,19 +121,24 @@ internal fun setValidatorConfig(
124121
config: MaruConfig,
125122
elNode: ElNode?,
126123
): MaruConfig {
127-
val validatorConfig =
128-
elNode
129-
?.let {
130-
config.validatorElNode.copy(
131-
ethApiEndpoint =
132-
config.validatorElNode.ethApiEndpoint.copy(
133-
endpoint = URI.create(it.ethApiUrl()).toURL(),
134-
),
135-
engineApiEndpoint =
136-
config.validatorElNode.engineApiEndpoint.copy(
137-
endpoint = URI.create(it.engineApiUrl()).toURL(),
138-
),
139-
)
140-
} ?: throw IllegalArgumentException("Maru still depends on a El Node")
141-
return config.copy(validatorElNode = validatorConfig)
124+
if (elNode == null) return config
125+
126+
val updatedValidatorConfig =
127+
config.validatorElNode?.copy(
128+
engineApiEndpoint =
129+
config.validatorElNode!!.engineApiEndpoint.copy(
130+
endpoint = URI.create(elNode.engineApiUrl()).toURL(),
131+
),
132+
) ?: ValidatorElNode(
133+
payloadValidationEnabled = false,
134+
engineApiEndpoint = ApiEndpointConfig(endpoint = URI.create(elNode.engineApiUrl()).toURL()),
135+
)
136+
val updatedForkTransition =
137+
config.forkTransition.copy(
138+
l2EthApiEndpoint =
139+
config.forkTransition.l2EthApiEndpoint?.copy(
140+
endpoint = URI.create(elNode.ethApiUrl()).toURL(),
141+
) ?: ApiEndpointConfig(URI.create(elNode.ethApiUrl()).toURL()),
142+
)
143+
return config.copy(validatorElNode = updatedValidatorConfig, forkTransition = updatedForkTransition)
142144
}

jvm-libs/test-utils/src/main/kotlin/maru/test/cluster/TestMaruAppFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ fun createMaru(
2525
): MaruApp {
2626
initPersistence(config.persistence, nodeKeyData)
2727
var effectiveConfig = config
28+
effectiveConfig = setValidatorConfig(effectiveConfig, elNode)
2829
effectiveConfig =
2930
setQbftConfigIfSequencer(effectiveConfig, isSequencer = nodeRole == NodeRole.Sequencer, nodeKeyData)
3031
effectiveConfig = setP2pConfig(effectiveConfig, bootnodes, staticpeers)
31-
effectiveConfig = setValidatorConfig(effectiveConfig, elNode)
3232

3333
return MaruAppFactory().create(
3434
config = effectiveConfig,

0 commit comments

Comments
 (0)