Skip to content

Commit

Permalink
Delete boilerplate code & clean
Browse files Browse the repository at this point in the history
  • Loading branch information
cemozerr committed Jun 5, 2019
1 parent 32c0e63 commit aed37d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,24 +972,19 @@ public static boolean is_power_of_two(UnsignedLong value) {
public static int get_beacon_proposer_index(
BeaconState state, UnsignedLong slot, boolean registry_change)
throws IllegalArgumentException {
if (state instanceof BeaconStateWithCache
&& ((BeaconStateWithCache) state).getCurrentBeaconProposerIndex() > -1) {
return ((BeaconStateWithCache) state).getCurrentBeaconProposerIndex();
} else {
UnsignedLong epoch = slot_to_epoch(slot);
UnsignedLong current_epoch = get_current_epoch(state);
UnsignedLong previous_epoch = get_previous_epoch(state);
UnsignedLong next_epoch = current_epoch.plus(UnsignedLong.ONE);
UnsignedLong epoch = slot_to_epoch(slot);
UnsignedLong current_epoch = get_current_epoch(state);
UnsignedLong previous_epoch = get_previous_epoch(state);
UnsignedLong next_epoch = current_epoch.plus(UnsignedLong.ONE);

checkArgument(
previous_epoch.compareTo(epoch) <= 0 && epoch.compareTo(next_epoch) <= 0,
"get_beacon_proposer_index: slot not in range");
checkArgument(
previous_epoch.compareTo(epoch) <= 0 && epoch.compareTo(next_epoch) <= 0,
"get_beacon_proposer_index: slot not in range");

List<Integer> first_committee =
get_crosslink_committees_at_slot(state, slot, registry_change).get(0).getCommittee();
// TODO: replace slot.intValue() with an UnsignedLong value
return first_committee.get(epoch.intValue() % first_committee.size());
}
List<Integer> first_committee =
get_crosslink_committees_at_slot(state, slot, registry_change).get(0).getCommittee();
// TODO: replace slot.intValue() with an UnsignedLong value
return first_committee.get(epoch.intValue() % first_committee.size());
}

public static int get_beacon_proposer_index(BeaconState state, UnsignedLong slot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import tech.pegasys.artemis.statetransition.util.BlockProcessorUtil;
import tech.pegasys.artemis.statetransition.util.EpochProcessingException;
import tech.pegasys.artemis.statetransition.util.EpochProcessorUtil;
import tech.pegasys.artemis.statetransition.util.PreProcessingUtil;
import tech.pegasys.artemis.util.alogger.ALogger;

public class StateTransition {
Expand All @@ -49,8 +48,6 @@ public void initiate(BeaconStateWithCache state, BeaconBlock block)

cache_state(state);
// Client specific optimization
// preProcessor(state);
// PreProcessingUtil.cacheCurrentBeaconProposerIndex(state);

if (state.getSlot().compareTo(UnsignedLong.valueOf(Constants.GENESIS_SLOT)) > 0
&& state
Expand All @@ -61,7 +58,6 @@ public void initiate(BeaconStateWithCache state, BeaconBlock block)
epochProcessor(state, block);
}

// PreProcessingUtil.cacheCrosslinkCommitteesAtSlot(state);
slotProcessor(state);

if (block != null) {
Expand All @@ -72,12 +68,6 @@ public void initiate(BeaconStateWithCache state, BeaconBlock block)
state.invalidateCache();
}

protected void preProcessor(BeaconStateWithCache state) {
// calculate currentBeaconProposerIndex
PreProcessingUtil.cacheCurrentBeaconProposerIndex(state);
PreProcessingUtil.cacheCrosslinkCommitteesAtSlot(state);
}

/**
* Caches the given state.
*
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/run_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ create_tmux_windows() {
fi

# Rename the window to add some spice
tmux rename-window 'the dude abides'
tmux rename-window 'jonny is dead. all hail Cem'

# Loop over the remaining nodes
while [[ $idx -lt $NODES ]]
Expand Down

0 comments on commit aed37d9

Please sign in to comment.