-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec runner merge sanity and operations fixes
- Loading branch information
Showing
17 changed files
with
341 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"config": { | ||
"chainId":1, | ||
"homesteadBlock":0, | ||
"eip150Block":0, | ||
"eip155Block":0, | ||
"eip158Block":0, | ||
"byzantiumBlock":0, | ||
"constantinopleBlock":0, | ||
"petersburgBlock":0, | ||
"istanbulBlock":0, | ||
"muirGlacierBlock":0, | ||
"berlinBlock":0, | ||
"londonBlock":0, | ||
"clique": { | ||
"period": 5, | ||
"epoch": 30000 | ||
}, | ||
"terminalTotalDifficulty":0 | ||
}, | ||
"nonce":"0x42", | ||
"timestamp":"0x0", | ||
"extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"gasLimit":"0x1C9C380", | ||
"difficulty":"0x400000000", | ||
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"coinbase":"0x0000000000000000000000000000000000000000", | ||
"alloc":{ | ||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"} | ||
}, | ||
"number":"0x0", | ||
"gasUsed":"0x0", | ||
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"baseFeePerGas":"0x7" | ||
} |
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,19 @@ | ||
FROM golang:1.17-alpine as builder | ||
RUN apk add --no-cache gcc musl-dev linux-headers git | ||
WORKDIR /usr/app | ||
|
||
RUN git clone -b kintsugi-spec https://github.com/MariusVanDerWijden/go-ethereum.git | ||
RUN cd /usr/app/go-ethereum && go run build/ci.go install ./cmd/geth | ||
|
||
|
||
# Pull Geth into a second stage deploy alpine container | ||
FROM alpine:latest | ||
RUN apk add --no-cache bash curl | ||
|
||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder usr/app/go-ethereum/build/bin/geth /usr/local/bin/ | ||
|
||
WORKDIR /usr/app | ||
|
||
EXPOSE 30303 30303/udp | ||
ENTRYPOINT ["geth"] |
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
17 changes: 17 additions & 0 deletions
17
packages/beacon-state-transition/src/merge/block/processAttesterSlashing.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,17 @@ | ||
import {allForks, merge, phase0} from "@chainsafe/lodestar-types"; | ||
import {ForkName} from "@chainsafe/lodestar-params"; | ||
import {CachedBeaconState} from "../../allForks/util"; | ||
import {processAttesterSlashing as processAttesterSlashingAllForks} from "../../allForks/block"; | ||
|
||
export function processAttesterSlashing( | ||
state: CachedBeaconState<merge.BeaconState>, | ||
attesterSlashing: phase0.AttesterSlashing, | ||
verifySignatures = true | ||
): void { | ||
processAttesterSlashingAllForks( | ||
ForkName.merge, | ||
state as CachedBeaconState<allForks.BeaconState>, | ||
attesterSlashing, | ||
verifySignatures | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/beacon-state-transition/src/merge/block/processOperations.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,44 @@ | ||
import {readonlyValues} from "@chainsafe/ssz"; | ||
import {altair, merge} from "@chainsafe/lodestar-types"; | ||
|
||
import {CachedBeaconState} from "../../allForks/util"; | ||
import {processProposerSlashing} from "./processProposerSlashing"; | ||
import {processAttesterSlashing} from "./processAttesterSlashing"; | ||
import {processAttestations} from "../../altair/block/processAttestation"; | ||
import {processDeposit} from "../../altair/block/processDeposit"; | ||
import {processVoluntaryExit} from "../../altair/block/processVoluntaryExit"; | ||
import {MAX_DEPOSITS} from "@chainsafe/lodestar-params"; | ||
|
||
export function processOperations( | ||
state: CachedBeaconState<merge.BeaconState>, | ||
body: merge.BeaconBlockBody, | ||
verifySignatures = true | ||
): void { | ||
// verify that outstanding deposits are processed up to the maximum number of deposits | ||
const maxDeposits = Math.min(MAX_DEPOSITS, state.eth1Data.depositCount - state.eth1DepositIndex); | ||
if (body.deposits.length !== maxDeposits) { | ||
throw new Error( | ||
`Block contains incorrect number of deposits: depositCount=${body.deposits.length} expected=${maxDeposits}` | ||
); | ||
} | ||
|
||
for (const proposerSlashing of readonlyValues(body.proposerSlashings)) { | ||
processProposerSlashing(state, proposerSlashing, verifySignatures); | ||
} | ||
for (const attesterSlashing of readonlyValues(body.attesterSlashings)) { | ||
processAttesterSlashing(state, attesterSlashing, verifySignatures); | ||
} | ||
|
||
processAttestations( | ||
(state as unknown) as CachedBeaconState<altair.BeaconState>, | ||
Array.from(readonlyValues(body.attestations)), | ||
verifySignatures | ||
); | ||
|
||
for (const deposit of readonlyValues(body.deposits)) { | ||
processDeposit((state as unknown) as CachedBeaconState<altair.BeaconState>, deposit); | ||
} | ||
for (const voluntaryExit of readonlyValues(body.voluntaryExits)) { | ||
processVoluntaryExit((state as unknown) as CachedBeaconState<altair.BeaconState>, voluntaryExit, verifySignatures); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/beacon-state-transition/src/merge/block/processProposerSlashing.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,17 @@ | ||
import {allForks, merge, phase0} from "@chainsafe/lodestar-types"; | ||
import {ForkName} from "@chainsafe/lodestar-params"; | ||
import {CachedBeaconState} from "../../allForks/util"; | ||
import {processProposerSlashing as processProposerSlashingAllForks} from "../../allForks/block"; | ||
|
||
export function processProposerSlashing( | ||
state: CachedBeaconState<merge.BeaconState>, | ||
proposerSlashing: phase0.ProposerSlashing, | ||
verifySignatures = true | ||
): void { | ||
processProposerSlashingAllForks( | ||
ForkName.merge, | ||
state as CachedBeaconState<allForks.BeaconState>, | ||
proposerSlashing, | ||
verifySignatures | ||
); | ||
} |
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 @@ | ||
export {processSlashings} from "./processSlashings"; |
8 changes: 8 additions & 0 deletions
8
packages/beacon-state-transition/src/merge/epoch/processSlashings.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,8 @@ | ||
import {allForks, merge} from "@chainsafe/lodestar-types"; | ||
import {ForkName} from "@chainsafe/lodestar-params"; | ||
import {CachedBeaconState, IEpochProcess} from "../../allForks/util"; | ||
import {processSlashingsAllForks} from "../../allForks/epoch/processSlashings"; | ||
|
||
export function processSlashings(state: CachedBeaconState<merge.BeaconState>, epochProcess: IEpochProcess): void { | ||
processSlashingsAllForks(ForkName.merge, state as CachedBeaconState<allForks.BeaconState>, epochProcess); | ||
} |
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.