@@ -16,6 +16,7 @@ import kotlin.time.Duration.Companion.seconds
1616import maru.config.ApiConfig
1717import maru.config.ApiEndpointConfig
1818import maru.config.FollowersConfig
19+ import maru.config.ForkTransition
1920import maru.config.MaruConfig
2021import maru.config.ObservabilityConfig
2122import 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}
0 commit comments