Skip to content

Commit

Permalink
feat: implement EIP-6110 (#6042)
Browse files Browse the repository at this point in the history
* Add immutable in the dependencies

* Initial change to pubkeyCache

* Added todos

* Moved unfinalized cache to epochCache

* Move populating finalized cache to afterProcessEpoch

* Specify unfinalized cache during state cloning

* Move from unfinalized to finalized cache in afterProcessEpoch

* Confused myself

* Clean up

* Change logic

* Fix cloning issue

* Clean up redundant code

* Add CarryoverData in epochCtx.createFromState

* Fix typo

* Update usage of pubkeyCache

* Update pubkeyCache usage

* Fix lint

* Fix lint

* Add 6110 to ChainConfig

* Add 6110 to BeaconPreset

* Define 6110 fork and container

* Add V6110 api to execution engine

* Update test

* Add depositReceiptsRoot to process_execution_payload

* State transitioning to EIP6110

* State transitioning to EIP6110

* Light client change in EIP-6110

* Update tests

* produceBlock

* Refactor processDeposit to match the spec

* Implement processDepositReceipt

* Implement 6110 fork guard for pubkeyCache

* Handle changes in eth1 deposit

* Update eth1 deposit test

* Fix typo

* Lint

* Remove embarassing comments

* Address comments

* Modify applyDeposit signature

* Update packages/state-transition/src/cache/epochCache.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Update packages/state-transition/src/cache/epochCache.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Update packages/state-transition/src/cache/pubkeyCache.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Remove old code

* Rename fields in epochCache and immutableData

* Remove CarryoverData

* Move isAfter6110 from var to method

* Fix cyclic import

* Fix operations spec runner

* Fix for spec test

* Fix spec test

* state.depositReceiptsStartIndex to BigInt

* getDeposit requires cached state

* default depositReceiptsStartIndex value in genesis

* Fix pubkeyCache bug

* newUnfinalizedPubkeyIndexMap in createCachedBeaconState

* Lint

* Pass epochCache instead of pubkey2IndexFn in apis

* Address comments

* Add unit test on pubkey cache cloning

* Add unfinalizedPubkeyCacheSize to metrics

* Add unfinalizedPubkeyCacheSize to metrics

* Clean up code

* Add besu to el-interop

* Add 6110 genesis file

* Template for sim test

* Add unit test for getEth1DepositCount

* Update sim test

* Update besudocker

* Finish beacon api calls in sim test

* Update epochCache.createFromState()

* Fix bug unfinalized validators are not finalized

* Add sim test to run a few blocks

* Lint

* Merge branch 'unstable' into 611

* Add more check to sim test

* Update besu docker image instruction

* Update sim test with correct tx

* Address comment + cleanup

* Clean up code

* Properly handle promise rejection

* Lint

* Update packages/beacon-node/src/execution/engine/types.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Update comments

* Accept type undefined in ExecutionPayloadBodyRpc

* Update comment and semantic

* Remove if statement when adding finalized validator

* Comment on repeated insert on finalized cache

* rename createFromState

* Add comment on getPubkey()

* Stash change to reduce diffs

* Stash change to reduce diffs

* Lint

* addFinalizedPubkey on finalized checkpoint

* Update comment

* Use OrderedMap for unfinalized cache

* Pull out logic of deleting pubkeys for batch op

* Add updateUnfinalizedPubkeys in regen

* Update updateUnfinalizedPubkeys logic

* Add comment

* Add metrics for state context caches

* Address comment

* Address comment

* Deprecate eth1Data polling when condition is reached

* Fix conflicts

* Fix sim test

* Lint

* Fix type

* Fix test

* Fix test

* Lint

* Update packages/light-client/src/spec/utils.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Fix spec test

* Address comments

* Improve cache logic on checkpoint finalized

* Update sim test according to new cache logic

* Update comment

* Lint

* Finalized pubkey cache only update once per checkpoint

* Add perf test for updateUnfinalizedPubkeys

* Add perf test for updateUnfinalizedPubkeys

* Tweak params for perf test

* Freeze besu docker image version for 6110

* Add benchmark result

* Use Map instead of OrderedMap. Update benchmark

* Minor optimization

* Minor optimization

* Add memory test for immutable.js

* Update test

* Reduce code duplication

* Lint

* Remove try/catch in updateUnfinalizedPubkeys

* Introduce EpochCache metric

* Add historicalValidatorLengths

* Polish code

* Migrate state-transition unit tests to vitest

* Fix calculation of pivot index

* `historicalValidatorLengths` only activate post 6110

* Update sim test

* Lint

* Update packages/state-transition/src/cache/epochCache.ts

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Improve readability on historicalValidatorLengths

* Update types

* Fix calculation

* Add eth1data poll todo

* Add epochCache.getValidatorCountAtEpoch

* Add todo

* Add getStateIterator for state cache

* Partial commit

* Update perf test

* updateUnfinalizedPubkeys directly modify states from regen

* Update sim test. Lint

* Add todo

* some improvements and a fix for effectiveBalanceIncrements fork safeness

* rename eip6110 to elctra

* fix electra-interop.test.ts

---------

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>
Co-authored-by: gajinder <develop@g11tech.io>

lint and tsc

small cleanup

fix rebase issue
  • Loading branch information
ensi321 authored and g11tech committed May 6, 2024
1 parent c231c3d commit f5a9d9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/test/sim/electra-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
blockHash: dataToBytes(newPayloadBlockHash, 32),
receiptsRoot: dataToBytes("0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", 32),
blobGasUsed: 0n,
exits: [],
withdrawalRequests: [],
};
const parentBeaconBlockRoot = dataToBytes("0x0000000000000000000000000000000000000000000000000000000000000000", 32);
const payloadResult = await executionEngine.notifyNewPayload(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ describe("AggregatedAttestationPool", function () {
epochParticipation[committee[i]] = 0b000;
}
}
(originalState as CachedBeaconStateAltair).previousEpochParticipation =
(originalState as unknown as CachedBeaconStateAltair).previousEpochParticipation =
ssz.altair.EpochParticipation.toViewDU(epochParticipation);
(originalState as CachedBeaconStateAltair).currentEpochParticipation =
(originalState as unknown as CachedBeaconStateAltair).currentEpochParticipation =
ssz.altair.EpochParticipation.toViewDU(epochParticipation);
originalState.commit();
let altairState: CachedBeaconStateAllForks;
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/test/unit/executionEngine/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe("ExecutionEngine / http", () => {
},
],
depositReceipts: null, // depositReceipts is null pre-electra
exits: null,
withdrawalRequests: null,
},
null, // null returned for missing blocks
{
Expand All @@ -199,7 +199,7 @@ describe("ExecutionEngine / http", () => {
],
withdrawals: null, // withdrawals is null pre-capella
depositReceipts: null, // depositReceipts is null pre-electra
exits: null,
withdrawalRequests: null,
},
],
};
Expand Down Expand Up @@ -248,7 +248,7 @@ describe("ExecutionEngine / http", () => {
},
],
depositReceipts: null, // depositReceipts is null pre-electra
exits: null,
withdrawalRequests: null,
},
null, // null returned for missing blocks
{
Expand All @@ -258,7 +258,7 @@ describe("ExecutionEngine / http", () => {
],
withdrawals: null, // withdrawals is null pre-capella
depositReceipts: null, // depositReceipts is null pre-electra
exits: null,
withdrawalRequests: null,
},
],
};
Expand Down

0 comments on commit f5a9d9c

Please sign in to comment.