-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add inclusion lists for censorship resistance
- Loading branch information
Showing
17 changed files
with
378 additions
and
81 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
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
36 changes: 36 additions & 0 deletions
36
packages/state-transition/src/slot/upgradeStateToElectra.ts
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,36 @@ | ||
import {ssz} from "@lodestar/types"; | ||
import {getCachedBeaconState} from "../cache/stateCache.js"; | ||
import {CachedBeaconStateDeneb} from "../types.js"; | ||
import {CachedBeaconStateElectra} from "../types.js"; | ||
|
||
/** | ||
* Upgrade a state from Capella to Deneb. | ||
*/ | ||
export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): CachedBeaconStateElectra { | ||
const {config} = stateDeneb; | ||
|
||
const stateDenebNode = ssz.deneb.BeaconState.commitViewDU(stateDeneb); | ||
const stateElectraView = ssz.electra.BeaconState.getViewDU(stateDenebNode); | ||
|
||
const stateElectra = getCachedBeaconState(stateElectraView, stateDeneb); | ||
|
||
stateElectra.fork = ssz.phase0.Fork.toViewDU({ | ||
previousVersion: stateDeneb.fork.currentVersion, | ||
currentVersion: config.ELECTRA_FORK_VERSION, | ||
epoch: stateDeneb.epochCtx.epoch, | ||
}); | ||
|
||
// TODO ELECTRA: check if this is following is required, since it seemed to be an issue in deneb state u[grade | ||
// (see upgradeStateToDeneb) | ||
// | ||
// stateElectra.latestExecutionPayloadHeader = ssz.electra.BeaconState.fields.latestExecutionPayloadHeader.toViewDU({ | ||
// ...stateDeneb.latestExecutionPayloadHeader.toValue(), | ||
// previousInclusionListSummaryRoot: ssz.Root.defaultValue(), | ||
// }); | ||
|
||
stateElectra.commit(); | ||
// Clear cache to ensure the cache of capella fields is not used by new deneb fields | ||
stateElectra["clearCache"](); | ||
|
||
return stateElectra; | ||
} |
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
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
Oops, something went wrong.