-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't initialize PowchainService if former deposit mechanism has been…
… disabled
- Loading branch information
1 parent
6df7ccf
commit f7c2169
Showing
9 changed files
with
153 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...c/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/MiscHelpersElectra.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.spec.logic.versions.electra.helpers; | ||
|
||
import tech.pegasys.teku.spec.config.SpecConfigElectra; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra; | ||
import tech.pegasys.teku.spec.logic.common.helpers.Predicates; | ||
import tech.pegasys.teku.spec.logic.versions.deneb.helpers.MiscHelpersDeneb; | ||
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; | ||
|
||
public class MiscHelpersElectra extends MiscHelpersDeneb { | ||
|
||
public MiscHelpersElectra( | ||
final SpecConfigElectra specConfig, | ||
final Predicates predicates, | ||
final SchemaDefinitionsElectra schemaDefinitions) { | ||
super(specConfig, predicates, schemaDefinitions); | ||
} | ||
|
||
@Override | ||
public boolean isFormerDepositMechanismDisabled(final BeaconState state) { | ||
return state | ||
.getEth1DepositIndex() | ||
.plus(1) | ||
.equals(BeaconStateElectra.required(state).getDepositReceiptsStartIndex()); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...st/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/MiscHelpersElectraTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.spec.logic.versions.electra.helpers; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
import tech.pegasys.teku.spec.Spec; | ||
import tech.pegasys.teku.spec.TestSpecFactory; | ||
import tech.pegasys.teku.spec.config.SpecConfigElectra; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.MutableBeaconStateElectra; | ||
import tech.pegasys.teku.spec.logic.common.helpers.Predicates; | ||
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; | ||
import tech.pegasys.teku.spec.util.DataStructureUtil; | ||
|
||
public class MiscHelpersElectraTest { | ||
|
||
private final Spec spec = TestSpecFactory.createMinimalElectra(); | ||
private final Predicates predicates = new Predicates(spec.getGenesisSpecConfig()); | ||
private final SchemaDefinitionsElectra schemaDefinitionsElectra = | ||
SchemaDefinitionsElectra.required(spec.getGenesisSchemaDefinitions()); | ||
private final MiscHelpersElectra miscHelpersElectra = | ||
new MiscHelpersElectra( | ||
spec.getGenesisSpecConfig().toVersionElectra().orElseThrow(), | ||
predicates, | ||
schemaDefinitionsElectra); | ||
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); | ||
|
||
@Test | ||
public void isFormerDepositMechanismDisabled_returnsTrueIfDisabled() { | ||
final BeaconState preState = dataStructureUtil.randomBeaconState(); | ||
|
||
final BeaconState state = | ||
BeaconStateElectra.required(preState) | ||
.updated( | ||
mutableState -> { | ||
mutableState.setEth1DepositIndex(UInt64.valueOf(32)); | ||
MutableBeaconStateElectra.required(mutableState) | ||
.setDepositReceiptsStartIndex(UInt64.valueOf(33)); | ||
}); | ||
|
||
assertThat(miscHelpersElectra.isFormerDepositMechanismDisabled(state)).isTrue(); | ||
} | ||
|
||
@Test | ||
public void isFormerDepositMechanismDisabled_returnsFalseIfNotDisabled() { | ||
final BeaconState preState = dataStructureUtil.randomBeaconState(); | ||
|
||
final BeaconState state = | ||
BeaconStateElectra.required(preState) | ||
.updated( | ||
mutableState -> { | ||
mutableState.setEth1DepositIndex(UInt64.valueOf(32)); | ||
MutableBeaconStateElectra.required(mutableState) | ||
.setDepositReceiptsStartIndex( | ||
SpecConfigElectra.UNSET_DEPOSIT_RECEIPTS_START_INDEX); | ||
}); | ||
|
||
assertThat(miscHelpersElectra.isFormerDepositMechanismDisabled(state)).isFalse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters