@lodestar/state-transition 1.42.0-dev.4411584fd8 → 1.42.0-dev.47afaa6bb7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +2 -3
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts +2 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +5 -3
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts +3 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +11 -28
- package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.d.ts +5 -1
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.js +14 -1
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/index.d.ts +2 -2
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -2
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +2 -2
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +4 -0
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/slot/upgradeStateToAltair.d.ts.map +1 -1
- package/lib/slot/upgradeStateToAltair.js +2 -1
- package/lib/slot/upgradeStateToAltair.js.map +1 -1
- package/lib/stateTransition.d.ts +1 -1
- package/lib/stateTransition.d.ts.map +1 -1
- package/lib/stateTransition.js +1 -1
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +14 -12
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +29 -39
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/index.d.ts +1 -0
- package/lib/stateView/index.d.ts.map +1 -1
- package/lib/stateView/index.js +1 -0
- package/lib/stateView/index.js.map +1 -1
- package/lib/stateView/interface.d.ts +107 -55
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js +22 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +40 -0
- package/lib/stateView/stateViewFactory.d.ts.map +1 -0
- package/lib/stateView/stateViewFactory.js +46 -0
- package/lib/stateView/stateViewFactory.js.map +1 -0
- package/lib/testUtils/cache.d.ts.map +1 -1
- package/lib/testUtils/cache.js +1 -1
- package/lib/testUtils/cache.js.map +1 -1
- package/lib/testUtils/util.d.ts +13 -1
- package/lib/testUtils/util.d.ts.map +1 -1
- package/lib/testUtils/util.js +119 -19
- package/lib/testUtils/util.js.map +1 -1
- package/lib/util/gloas.d.ts +2 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/rootCache.d.ts +2 -2
- package/lib/util/rootCache.d.ts.map +1 -1
- package/lib/util/rootCache.js +2 -3
- package/lib/util/rootCache.js.map +1 -1
- package/lib/util/shuffling.d.ts +2 -1
- package/lib/util/shuffling.d.ts.map +1 -1
- package/lib/util/shuffling.js +2 -2
- package/lib/util/shuffling.js.map +1 -1
- package/package.json +7 -7
- package/src/block/isValidIndexedAttestation.ts +2 -3
- package/src/block/processAttestationsAltair.ts +7 -4
- package/src/block/processExecutionPayloadEnvelope.ts +18 -35
- package/src/index.ts +20 -2
- package/src/signatureSets/executionPayloadEnvelope.ts +30 -2
- package/src/signatureSets/index.ts +3 -4
- package/src/signatureSets/voluntaryExits.ts +5 -2
- package/src/slot/upgradeStateToAltair.ts +2 -1
- package/src/stateTransition.ts +1 -1
- package/src/stateView/beaconStateView.ts +53 -58
- package/src/stateView/index.ts +1 -0
- package/src/stateView/interface.ts +153 -74
- package/src/stateView/stateViewFactory.ts +78 -0
- package/src/testUtils/cache.ts +1 -1
- package/src/testUtils/util.ts +136 -22
- package/src/util/gloas.ts +2 -1
- package/src/util/rootCache.ts +4 -5
- package/src/util/shuffling.ts +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,I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AAa,CAAC,kBAAkB,CAAC;CAAG"}
|
package/lib/util/shuffling.js
CHANGED
|
@@ -14,7 +14,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
|
|
|
14
14
|
if (state.slot === decisionSlot) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
return getBlockRootAtSlot(
|
|
17
|
+
return state.getBlockRootAtSlot(decisionSlot);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Returns the slot at which the proposer shuffling was decided. The block root at this slot
|
|
@@ -22,7 +22,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
|
|
|
22
22
|
*/
|
|
23
23
|
function proposerShufflingDecisionSlot(fork, state) {
|
|
24
24
|
// After fulu, the decision slot is in previous epoch due to deterministic proposer lookahead
|
|
25
|
-
const epoch = isForkPostFulu(fork) ? state.
|
|
25
|
+
const epoch = isForkPostFulu(fork) ? state.epoch - 1 : state.epoch;
|
|
26
26
|
const startSlot = computeStartSlotAtEpoch(epoch);
|
|
27
27
|
return Math.max(startSlot - 1, 0);
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffling.js","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"shuffling.js","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAGnD;;;;;;GAMG;AACH,MA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,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,cAAc,CAAC;gBACvB,IAAI,EAAE,kBAAkB,CAAC,4BAA4B;gBACrD,KAAK;gBACL,QAAQ,EAAE,cAAc,CAAC,MAAM;aAChC,CAAC,CAAC;QACL,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,UAAU,CAAC;AAAA,CACnB;SAEW,kBAAkB;AAA9B,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;AAAC,CAChF,EAFY,kBAAkB,KAAlB,kBAAkB,QAE7B;AAQD,MAAM,OAAO,cAAe,SAAQ,aAAiC;CAAG"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.42.0-dev.
|
|
14
|
+
"version": "1.42.0-dev.47afaa6bb7",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"@chainsafe/pubkey-index-map": "^3.0.0",
|
|
68
68
|
"@chainsafe/ssz": "^1.2.2",
|
|
69
69
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
70
|
-
"@lodestar/config": "^1.42.0-dev.
|
|
71
|
-
"@lodestar/params": "^1.42.0-dev.
|
|
72
|
-
"@lodestar/types": "^1.42.0-dev.
|
|
73
|
-
"@lodestar/utils": "^1.42.0-dev.
|
|
70
|
+
"@lodestar/config": "^1.42.0-dev.47afaa6bb7",
|
|
71
|
+
"@lodestar/params": "^1.42.0-dev.47afaa6bb7",
|
|
72
|
+
"@lodestar/types": "^1.42.0-dev.47afaa6bb7",
|
|
73
|
+
"@lodestar/utils": "^1.42.0-dev.47afaa6bb7",
|
|
74
74
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@lodestar/api": "^1.42.0-dev.
|
|
77
|
+
"@lodestar/api": "^1.42.0-dev.47afaa6bb7"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"ethereum",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"beacon",
|
|
83
83
|
"blockchain"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "8cdb55e5b512d09d1ef1b98b8597cc51ac2dabd1"
|
|
86
86
|
}
|
|
@@ -74,9 +74,8 @@ export function isValidIndexedAttestationIndices(
|
|
|
74
74
|
prev = index;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// check if indices are out of bounds,
|
|
78
|
-
|
|
79
|
-
if (lastIndex && lastIndex >= validatorsLen) {
|
|
77
|
+
// check if indices are out of bounds, `prev` is the highest index since indices are sorted
|
|
78
|
+
if (prev >= validatorsLen) {
|
|
80
79
|
return false;
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BitArray} from "@chainsafe/ssz";
|
|
1
2
|
import {
|
|
2
3
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
3
4
|
ForkSeq,
|
|
@@ -17,6 +18,7 @@ import {Attestation, Epoch, phase0} from "@lodestar/types";
|
|
|
17
18
|
import {byteArrayEquals, intSqrt} from "@lodestar/utils";
|
|
18
19
|
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
19
20
|
import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js";
|
|
21
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
20
22
|
import {CachedBeaconStateAltair, CachedBeaconStateGloas} from "../types.js";
|
|
21
23
|
import {isAttestationSameSlot, isAttestationSameSlotRootCache} from "../util/gloas.js";
|
|
22
24
|
import {increaseBalance, verifySignatureSet} from "../util/index.js";
|
|
@@ -41,7 +43,7 @@ export function processAttestationsAltair(
|
|
|
41
43
|
const {epochCtx} = state;
|
|
42
44
|
const {effectiveBalanceIncrements} = epochCtx;
|
|
43
45
|
const stateSlot = state.slot;
|
|
44
|
-
const rootCache = new RootCache(state);
|
|
46
|
+
const rootCache = new RootCache(new BeaconStateView(state));
|
|
45
47
|
const currentEpoch = epochCtx.epoch;
|
|
46
48
|
|
|
47
49
|
// Process all attestations first and then increase the balance of the proposer once
|
|
@@ -80,7 +82,7 @@ export function processAttestationsAltair(
|
|
|
80
82
|
stateSlot - data.slot,
|
|
81
83
|
epochCtx.epoch,
|
|
82
84
|
rootCache,
|
|
83
|
-
fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability
|
|
85
|
+
fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability : null
|
|
84
86
|
);
|
|
85
87
|
|
|
86
88
|
// For each participant, update their participation
|
|
@@ -177,7 +179,7 @@ export function getAttestationParticipationStatus(
|
|
|
177
179
|
inclusionDelay: number,
|
|
178
180
|
currentEpoch: Epoch,
|
|
179
181
|
rootCache: RootCache,
|
|
180
|
-
executionPayloadAvailability:
|
|
182
|
+
executionPayloadAvailability: BitArray | null
|
|
181
183
|
): number {
|
|
182
184
|
const justifiedCheckpoint =
|
|
183
185
|
data.target.epoch === currentEpoch ? rootCache.currentJustifiedCheckpoint : rootCache.previousJustifiedCheckpoint;
|
|
@@ -221,7 +223,8 @@ export function getAttestationParticipationStatus(
|
|
|
221
223
|
throw new Error(`data index must be 0 or 1 index=${data.index}`);
|
|
222
224
|
}
|
|
223
225
|
|
|
224
|
-
isMatchingPayload =
|
|
226
|
+
isMatchingPayload =
|
|
227
|
+
Boolean(data.index) === executionPayloadAvailability.get(data.slot % SLOTS_PER_HISTORICAL_ROOT);
|
|
225
228
|
}
|
|
226
229
|
|
|
227
230
|
isMatchingHead = isMatchingHead && isMatchingPayload;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
BUILDER_INDEX_SELF_BUILD,
|
|
4
|
-
DOMAIN_BEACON_BUILDER,
|
|
5
|
-
SLOTS_PER_EPOCH,
|
|
6
|
-
SLOTS_PER_HISTORICAL_ROOT,
|
|
7
|
-
} from "@lodestar/params";
|
|
1
|
+
import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
8
2
|
import {gloas, ssz} from "@lodestar/types";
|
|
9
3
|
import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
|
|
4
|
+
import {getExecutionPayloadEnvelopeSignatureSet} from "../signatureSets/executionPayloadEnvelope.js";
|
|
5
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
10
6
|
import {CachedBeaconStateGloas} from "../types.js";
|
|
11
|
-
import {
|
|
7
|
+
import {computeTimeAtSlot} from "../util/index.js";
|
|
8
|
+
import {verifySignatureSet} from "../util/signatureSets.js";
|
|
12
9
|
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
13
10
|
import {processDepositRequest} from "./processDepositRequest.js";
|
|
14
11
|
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
15
12
|
|
|
16
13
|
export type ProcessExecutionPayloadEnvelopeOpts = {
|
|
14
|
+
verifySignature?: boolean;
|
|
15
|
+
verifyStateRoot?: boolean;
|
|
17
16
|
dontTransferCache?: boolean;
|
|
18
17
|
};
|
|
19
18
|
|
|
@@ -23,14 +22,14 @@ export type ProcessExecutionPayloadEnvelopeOpts = {
|
|
|
23
22
|
export function processExecutionPayloadEnvelope(
|
|
24
23
|
state: CachedBeaconStateGloas,
|
|
25
24
|
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
26
|
-
verify: boolean,
|
|
27
25
|
opts?: ProcessExecutionPayloadEnvelopeOpts
|
|
28
26
|
): CachedBeaconStateGloas {
|
|
27
|
+
const {verifySignature = true, verifyStateRoot = true} = opts ?? {};
|
|
29
28
|
const envelope = signedEnvelope.message;
|
|
30
29
|
const payload = envelope.payload;
|
|
31
30
|
const fork = state.config.getForkSeq(envelope.slot);
|
|
32
31
|
|
|
33
|
-
if (
|
|
32
|
+
if (verifySignature && !verifyExecutionPayloadEnvelopeSignature(state, signedEnvelope)) {
|
|
34
33
|
throw Error(`Execution payload envelope has invalid signature builderIndex=${envelope.builderIndex}`);
|
|
35
34
|
}
|
|
36
35
|
|
|
@@ -70,7 +69,7 @@ export function processExecutionPayloadEnvelope(
|
|
|
70
69
|
|
|
71
70
|
postState.commit();
|
|
72
71
|
|
|
73
|
-
if (
|
|
72
|
+
if (verifyStateRoot && !byteArrayEquals(envelope.stateRoot, postState.hashTreeRoot())) {
|
|
74
73
|
throw new Error(
|
|
75
74
|
`Envelope's state root does not match state envelope=${toRootHex(envelope.stateRoot)} state=${toRootHex(postState.hashTreeRoot())}`
|
|
76
75
|
);
|
|
@@ -160,28 +159,12 @@ function verifyExecutionPayloadEnvelopeSignature(
|
|
|
160
159
|
state: CachedBeaconStateGloas,
|
|
161
160
|
signedEnvelope: gloas.SignedExecutionPayloadEnvelope
|
|
162
161
|
): boolean {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (builderIndex === BUILDER_INDEX_SELF_BUILD) {
|
|
172
|
-
const validatorIndex = state.latestBlockHeader.proposerIndex;
|
|
173
|
-
const proposerPubkey = state.epochCtx.pubkeyCache.get(validatorIndex);
|
|
174
|
-
if (!proposerPubkey) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
publicKey = proposerPubkey;
|
|
178
|
-
} else {
|
|
179
|
-
publicKey = PublicKey.fromBytes(state.builders.getReadonly(builderIndex).pubkey);
|
|
180
|
-
}
|
|
181
|
-
const signature = Signature.fromBytes(signedEnvelope.signature, true);
|
|
182
|
-
|
|
183
|
-
return verify(signingRoot, publicKey, signature);
|
|
184
|
-
} catch (_e) {
|
|
185
|
-
return false; // Catch all BLS errors: failed key validation, failed signature validation, invalid signature
|
|
186
|
-
}
|
|
162
|
+
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
163
|
+
state.config,
|
|
164
|
+
state.epochCtx.pubkeyCache,
|
|
165
|
+
new BeaconStateView(state),
|
|
166
|
+
signedEnvelope,
|
|
167
|
+
state.latestBlockHeader.proposerIndex
|
|
168
|
+
);
|
|
169
|
+
return verifySignatureSet(signatureSet);
|
|
187
170
|
}
|
package/src/index.ts
CHANGED
|
@@ -35,14 +35,32 @@ export {
|
|
|
35
35
|
isStateValidatorsNodesPopulated,
|
|
36
36
|
loadCachedBeaconState,
|
|
37
37
|
} from "./cache/stateCache.js";
|
|
38
|
-
export {type SyncCommitteeCache} from "./cache/syncCommitteeCache.js";
|
|
38
|
+
export {type SyncCommitteeCache, SyncCommitteeCacheEmpty} from "./cache/syncCommitteeCache.js";
|
|
39
39
|
export * from "./constants/index.js";
|
|
40
40
|
export type {EpochTransitionStep} from "./epoch/index.js";
|
|
41
41
|
export {type BeaconStateTransitionMetrics, getMetrics} from "./metrics.js";
|
|
42
42
|
export * from "./rewards/index.js";
|
|
43
43
|
export * from "./signatureSets/index.js";
|
|
44
44
|
export * from "./stateTransition.js";
|
|
45
|
-
export
|
|
45
|
+
export {BeaconStateView} from "./stateView/beaconStateView.js";
|
|
46
|
+
export {
|
|
47
|
+
type IBeaconStateView,
|
|
48
|
+
type IBeaconStateViewAltair,
|
|
49
|
+
type IBeaconStateViewBellatrix,
|
|
50
|
+
type IBeaconStateViewCapella,
|
|
51
|
+
type IBeaconStateViewDeneb,
|
|
52
|
+
type IBeaconStateViewElectra,
|
|
53
|
+
type IBeaconStateViewFulu,
|
|
54
|
+
type IBeaconStateViewGloas,
|
|
55
|
+
isStatePostAltair,
|
|
56
|
+
isStatePostBellatrix,
|
|
57
|
+
isStatePostCapella,
|
|
58
|
+
isStatePostDeneb,
|
|
59
|
+
isStatePostElectra,
|
|
60
|
+
isStatePostFulu,
|
|
61
|
+
isStatePostGloas,
|
|
62
|
+
} from "./stateView/interface.js";
|
|
63
|
+
export {createBeaconStateView, createBeaconStateViewForHistoricalRegen} from "./stateView/stateViewFactory.js";
|
|
46
64
|
export type {
|
|
47
65
|
BeaconStateAllForks,
|
|
48
66
|
BeaconStateAltair,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import {PublicKey} from "@chainsafe/blst";
|
|
1
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
3
|
-
import {gloas, ssz} from "@lodestar/types";
|
|
3
|
+
import {BUILDER_INDEX_SELF_BUILD, DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
4
|
+
import {ValidatorIndex, gloas, ssz} from "@lodestar/types";
|
|
5
|
+
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
|
+
import {IBeaconStateView, isStatePostGloas} from "../stateView/interface.js";
|
|
4
7
|
import {computeSigningRoot} from "../util/index.js";
|
|
8
|
+
import {type SingleSignatureSet, createSingleSignatureSetFromComponents} from "../util/signatureSets.js";
|
|
5
9
|
|
|
6
10
|
export function getExecutionPayloadEnvelopeSigningRoot(
|
|
7
11
|
config: BeaconConfig,
|
|
@@ -11,3 +15,27 @@ export function getExecutionPayloadEnvelopeSigningRoot(
|
|
|
11
15
|
|
|
12
16
|
return computeSigningRoot(ssz.gloas.ExecutionPayloadEnvelope, envelope, domain);
|
|
13
17
|
}
|
|
18
|
+
|
|
19
|
+
export function getExecutionPayloadEnvelopeSignatureSet(
|
|
20
|
+
config: BeaconConfig,
|
|
21
|
+
pubkeyCache: PubkeyCache,
|
|
22
|
+
state: IBeaconStateView,
|
|
23
|
+
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
24
|
+
proposerIndex: ValidatorIndex
|
|
25
|
+
): SingleSignatureSet {
|
|
26
|
+
if (!isStatePostGloas(state)) {
|
|
27
|
+
throw new Error(`Expected gloas+ state for execution payload envelope signature, got fork=${state.forkName}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const envelope = signedEnvelope.message;
|
|
31
|
+
const pubkey =
|
|
32
|
+
envelope.builderIndex === BUILDER_INDEX_SELF_BUILD
|
|
33
|
+
? pubkeyCache.getOrThrow(proposerIndex)
|
|
34
|
+
: PublicKey.fromBytes(state.getBuilder(envelope.builderIndex).pubkey);
|
|
35
|
+
|
|
36
|
+
return createSingleSignatureSetFromComponents(
|
|
37
|
+
pubkey,
|
|
38
|
+
getExecutionPayloadEnvelopeSigningRoot(config, envelope),
|
|
39
|
+
signedEnvelope.signature
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -3,8 +3,7 @@ import {ForkSeq} from "@lodestar/params";
|
|
|
3
3
|
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
6
|
-
import {
|
|
7
|
-
import {CachedBeaconStateAllForks} from "../types.js";
|
|
6
|
+
import {IBeaconStateView} from "../stateView/interface.js";
|
|
8
7
|
import {ISignatureSet} from "../util/index.js";
|
|
9
8
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
10
9
|
import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
|
|
@@ -32,7 +31,7 @@ export * from "./voluntaryExits.js";
|
|
|
32
31
|
export function getBlockSignatureSets(
|
|
33
32
|
config: BeaconConfig,
|
|
34
33
|
currentSyncCommitteeIndexed: SyncCommitteeCache,
|
|
35
|
-
state:
|
|
34
|
+
state: IBeaconStateView,
|
|
36
35
|
signedBlock: SignedBeaconBlock,
|
|
37
36
|
indexedAttestations: IndexedAttestation[],
|
|
38
37
|
opts?: {
|
|
@@ -48,7 +47,7 @@ export function getBlockSignatureSets(
|
|
|
48
47
|
...getProposerSlashingsSignatureSets(config, signedBlock),
|
|
49
48
|
...getAttesterSlashingsSignatureSets(config, signedBlock),
|
|
50
49
|
...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
|
|
51
|
-
...getVoluntaryExitsSignatureSets(config,
|
|
50
|
+
...getVoluntaryExitsSignatureSets(config, state, signedBlock),
|
|
52
51
|
];
|
|
53
52
|
|
|
54
53
|
if (!opts?.skipProposerSignature) {
|
|
@@ -3,7 +3,7 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
3
3
|
import {ForkSeq} from "@lodestar/params";
|
|
4
4
|
import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
5
5
|
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
|
-
import {IBeaconStateView} from "../stateView/interface.js";
|
|
6
|
+
import {IBeaconStateView, IBeaconStateViewGloas, isStatePostGloas} from "../stateView/interface.js";
|
|
7
7
|
import {
|
|
8
8
|
ISignatureSet,
|
|
9
9
|
SignatureSetType,
|
|
@@ -34,6 +34,9 @@ export function getVoluntaryExitSignatureSet(
|
|
|
34
34
|
const fork = config.getForkSeq(state.slot);
|
|
35
35
|
|
|
36
36
|
if (fork >= ForkSeq.gloas && isBuilderVoluntaryExit(signedVoluntaryExit)) {
|
|
37
|
+
if (!isStatePostGloas(state)) {
|
|
38
|
+
throw new Error(`Expected gloas+ state for builder voluntary exit signature, got fork=${state.forkName}`);
|
|
39
|
+
}
|
|
37
40
|
return getBuilderVoluntaryExitSignatureSet(config, state, signedVoluntaryExit);
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -68,7 +71,7 @@ export function getValidatorVoluntaryExitSignatureSet(
|
|
|
68
71
|
|
|
69
72
|
export function getBuilderVoluntaryExitSignatureSet(
|
|
70
73
|
config: BeaconConfig,
|
|
71
|
-
state:
|
|
74
|
+
state: IBeaconStateViewGloas,
|
|
72
75
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
73
76
|
): ISignatureSet {
|
|
74
77
|
const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
@@ -3,6 +3,7 @@ import {ForkSeq} from "@lodestar/params";
|
|
|
3
3
|
import {ssz} from "@lodestar/types";
|
|
4
4
|
import {getAttestationParticipationStatus} from "../block/processAttestationsAltair.js";
|
|
5
5
|
import {getCachedBeaconState} from "../cache/stateCache.js";
|
|
6
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
6
7
|
import {CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js";
|
|
7
8
|
import {RootCache, newZeroedArray} from "../util/index.js";
|
|
8
9
|
import {getNextSyncCommittee} from "../util/syncCommittee.js";
|
|
@@ -125,7 +126,7 @@ function translateParticipation(
|
|
|
125
126
|
pendingAttesations: CompositeViewDU<typeof ssz.phase0.EpochAttestations>
|
|
126
127
|
): void {
|
|
127
128
|
const {epochCtx} = state;
|
|
128
|
-
const rootCache = new RootCache(state);
|
|
129
|
+
const rootCache = new RootCache(new BeaconStateView(state));
|
|
129
130
|
const epochParticipation = state.previousEpochParticipation;
|
|
130
131
|
|
|
131
132
|
for (const attestation of pendingAttesations.getAllReadonly()) {
|
package/src/stateTransition.ts
CHANGED
|
@@ -76,7 +76,7 @@ export enum StateHashTreeRootSource {
|
|
|
76
76
|
prepareNextEpoch = "prepare_next_epoch",
|
|
77
77
|
regenState = "regen_state",
|
|
78
78
|
computeNewStateRoot = "compute_new_state_root",
|
|
79
|
-
|
|
79
|
+
computePayloadEnvelopeStateRoot = "compute_payload_envelope_state_root",
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {CompactMultiProof, ProofType, Tree, createProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
|
-
import {ByteViews} from "@chainsafe/ssz";
|
|
2
|
+
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
-
import {ForkSeq, SLOTS_PER_HISTORICAL_ROOT, isForkPostGloas} from "@lodestar/params";
|
|
4
|
+
import {ForkName, ForkSeq, SLOTS_PER_HISTORICAL_ROOT, isForkPostGloas} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
BeaconBlock,
|
|
7
|
+
BeaconState,
|
|
7
8
|
BlindedBeaconBlock,
|
|
8
9
|
BuilderIndex,
|
|
9
10
|
Bytes32,
|
|
@@ -28,11 +29,11 @@ import {
|
|
|
28
29
|
} from "@lodestar/types";
|
|
29
30
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
30
31
|
import {processExecutionPayloadEnvelope} from "../block/index.js";
|
|
32
|
+
import {ProcessExecutionPayloadEnvelopeOpts} from "../block/processExecutionPayloadEnvelope.js";
|
|
31
33
|
import {VoluntaryExitValidity, getVoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
32
34
|
import {getExpectedWithdrawals} from "../block/processWithdrawals.js";
|
|
33
35
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
34
36
|
import {EpochTransitionCacheOpts} from "../cache/epochTransitionCache.js";
|
|
35
|
-
import {PubkeyCache, createPubkeyCache} from "../cache/pubkeyCache.js";
|
|
36
37
|
import {RewardCache} from "../cache/rewardCache.js";
|
|
37
38
|
import {
|
|
38
39
|
CachedBeaconStateAllForks,
|
|
@@ -46,7 +47,6 @@ import {
|
|
|
46
47
|
isStateValidatorsNodesPopulated,
|
|
47
48
|
} from "../cache/stateCache.js";
|
|
48
49
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
49
|
-
import {BeaconStateAllForks} from "../cache/types.js";
|
|
50
50
|
import {computeUnrealizedCheckpoints} from "../epoch/computeUnrealizedCheckpoints.js";
|
|
51
51
|
import {getFinalizedRootProof, getSyncCommitteesWitness} from "../lightClient/proofs.js";
|
|
52
52
|
import {SyncCommitteeWitness} from "../lightClient/types.js";
|
|
@@ -63,11 +63,10 @@ import {isExecutionEnabled, isExecutionStateType, isMergeTransitionComplete} fro
|
|
|
63
63
|
import {canBuilderCoverBid} from "../util/gloas.js";
|
|
64
64
|
import {loadState} from "../util/loadState/loadState.js";
|
|
65
65
|
import {getRandaoMix} from "../util/seed.js";
|
|
66
|
-
import {getStateTypeFromBytes} from "../util/sszBytes.js";
|
|
67
66
|
import {getLatestWeakSubjectivityCheckpointEpoch} from "../util/weakSubjectivity.js";
|
|
68
|
-
import {IBeaconStateView} from "./interface.js";
|
|
67
|
+
import {IBeaconStateView, IBeaconStateViewLatestFork} from "./interface.js";
|
|
69
68
|
|
|
70
|
-
export class BeaconStateView implements
|
|
69
|
+
export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
71
70
|
private readonly config: BeaconConfig;
|
|
72
71
|
// Cached values extracted from the tree
|
|
73
72
|
// phase0
|
|
@@ -91,8 +90,9 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
91
90
|
// fulu
|
|
92
91
|
private _proposerLookahead: fulu.ProposerLookahead | null = null;
|
|
93
92
|
// gloas
|
|
94
|
-
private _executionPayloadAvailability:
|
|
93
|
+
private _executionPayloadAvailability: BitArray | null = null;
|
|
95
94
|
private _latestExecutionPayloadBid: ExecutionPayloadBid | null = null;
|
|
95
|
+
private _payloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
|
|
96
96
|
|
|
97
97
|
constructor(readonly cachedState: CachedBeaconStateAllForks) {
|
|
98
98
|
this.config = cachedState.config;
|
|
@@ -100,6 +100,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
100
100
|
|
|
101
101
|
// phase0
|
|
102
102
|
|
|
103
|
+
get forkName(): ForkName {
|
|
104
|
+
return this.config.getForkName(this.cachedState.slot);
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
get slot(): number {
|
|
104
108
|
return this.cachedState.slot;
|
|
105
109
|
}
|
|
@@ -356,15 +360,15 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
356
360
|
|
|
357
361
|
// gloas
|
|
358
362
|
|
|
359
|
-
get executionPayloadAvailability():
|
|
363
|
+
get executionPayloadAvailability(): BitArray {
|
|
360
364
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
361
|
-
throw new Error("executionPayloadAvailability is not available before
|
|
365
|
+
throw new Error("executionPayloadAvailability is not available before Gloas");
|
|
362
366
|
}
|
|
363
367
|
|
|
364
368
|
if (this._executionPayloadAvailability === null) {
|
|
365
|
-
this._executionPayloadAvailability = (
|
|
366
|
-
.
|
|
367
|
-
|
|
369
|
+
this._executionPayloadAvailability = (
|
|
370
|
+
this.cachedState as CachedBeaconStateGloas
|
|
371
|
+
).executionPayloadAvailability.toValue();
|
|
368
372
|
}
|
|
369
373
|
|
|
370
374
|
return this._executionPayloadAvailability;
|
|
@@ -372,7 +376,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
372
376
|
|
|
373
377
|
get latestExecutionPayloadBid(): ExecutionPayloadBid {
|
|
374
378
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
375
|
-
throw new Error("latestExecutionPayloadBid is not available before
|
|
379
|
+
throw new Error("latestExecutionPayloadBid is not available before Gloas");
|
|
376
380
|
}
|
|
377
381
|
|
|
378
382
|
if (this._latestExecutionPayloadBid === null) {
|
|
@@ -383,9 +387,22 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
383
387
|
return this._latestExecutionPayloadBid;
|
|
384
388
|
}
|
|
385
389
|
|
|
390
|
+
get payloadExpectedWithdrawals(): capella.Withdrawal[] {
|
|
391
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
392
|
+
throw new Error("payloadExpectedWithdrawals is not available before Gloas");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (this._payloadExpectedWithdrawals === null) {
|
|
396
|
+
this._payloadExpectedWithdrawals = (
|
|
397
|
+
this.cachedState as CachedBeaconStateGloas
|
|
398
|
+
).payloadExpectedWithdrawals.toValue();
|
|
399
|
+
}
|
|
400
|
+
return this._payloadExpectedWithdrawals;
|
|
401
|
+
}
|
|
402
|
+
|
|
386
403
|
getBuilder(index: BuilderIndex): gloas.Builder {
|
|
387
404
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
388
|
-
throw new Error("Builders are not supported before
|
|
405
|
+
throw new Error("Builders are not supported before Gloas");
|
|
389
406
|
}
|
|
390
407
|
|
|
391
408
|
return (this.cachedState as CachedBeaconStateGloas).builders.getReadonly(index);
|
|
@@ -393,7 +410,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
393
410
|
|
|
394
411
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean {
|
|
395
412
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
396
|
-
throw new Error("Builders are not supported before
|
|
413
|
+
throw new Error("Builders are not supported before Gloas");
|
|
397
414
|
}
|
|
398
415
|
|
|
399
416
|
return canBuilderCoverBid(this.cachedState as CachedBeaconStateGloas, builderIndex, bidAmount);
|
|
@@ -403,9 +420,9 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
403
420
|
* Return the index of the validator in the PTC committee for the given slot.
|
|
404
421
|
* return -1 if validator is not in the PTC committee for the given slot.
|
|
405
422
|
*/
|
|
406
|
-
|
|
423
|
+
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number {
|
|
407
424
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
408
|
-
throw new Error("PTC committees are not supported before
|
|
425
|
+
throw new Error("PTC committees are not supported before Gloas");
|
|
409
426
|
}
|
|
410
427
|
|
|
411
428
|
const ptcCommittee = (this.cachedState as CachedBeaconStateGloas).epochCtx.getPayloadTimelinessCommittee(slot);
|
|
@@ -502,6 +519,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
502
519
|
return this.cachedState.epochCtx.syncProposerReward;
|
|
503
520
|
}
|
|
504
521
|
|
|
522
|
+
getIndexedSyncCommittee(slot: Slot): SyncCommitteeCache {
|
|
523
|
+
return this.cachedState.epochCtx.getIndexedSyncCommittee(slot);
|
|
524
|
+
}
|
|
525
|
+
|
|
505
526
|
getIndexedSyncCommitteeAtEpoch(epoch: Epoch): SyncCommitteeCache {
|
|
506
527
|
return this.cachedState.epochCtx.getIndexedSyncCommitteeAtEpoch(epoch);
|
|
507
528
|
}
|
|
@@ -712,6 +733,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
712
733
|
return new BeaconStateView(cachedState);
|
|
713
734
|
}
|
|
714
735
|
|
|
736
|
+
toValue(): BeaconState {
|
|
737
|
+
return this.cachedState.toValue();
|
|
738
|
+
}
|
|
739
|
+
|
|
715
740
|
serialize(): Uint8Array {
|
|
716
741
|
return this.cachedState.serialize();
|
|
717
742
|
}
|
|
@@ -761,49 +786,19 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
761
786
|
return new BeaconStateView(newState);
|
|
762
787
|
}
|
|
763
788
|
|
|
764
|
-
processExecutionPayloadEnvelope(
|
|
789
|
+
processExecutionPayloadEnvelope(
|
|
790
|
+
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
791
|
+
opts?: ProcessExecutionPayloadEnvelopeOpts
|
|
792
|
+
): BeaconStateView {
|
|
765
793
|
const fork = this.config.getForkName(this.cachedState.slot);
|
|
766
794
|
if (!isForkPostGloas(fork)) {
|
|
767
795
|
throw Error(`processExecutionPayloadEnvelope is only available for gloas+ forks, got fork=${fork}`);
|
|
768
796
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
*/
|
|
776
|
-
export function createBeaconStateViewForHistoricalRegen(
|
|
777
|
-
config: BeaconConfig,
|
|
778
|
-
stateBytes: Uint8Array
|
|
779
|
-
): IBeaconStateView {
|
|
780
|
-
const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
|
|
781
|
-
|
|
782
|
-
const pubkeyCache = createPubkeyCache();
|
|
783
|
-
syncPubkeyCache(state, pubkeyCache);
|
|
784
|
-
const cachedState = createCachedBeaconState(
|
|
785
|
-
state,
|
|
786
|
-
{
|
|
787
|
-
config,
|
|
788
|
-
pubkeyCache,
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
skipSyncPubkeys: true,
|
|
792
|
-
}
|
|
793
|
-
);
|
|
794
|
-
|
|
795
|
-
return new BeaconStateView(cachedState);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* Populate a PubkeyIndexMap with any new entries based on a BeaconState
|
|
800
|
-
*/
|
|
801
|
-
function syncPubkeyCache(state: BeaconStateAllForks, pubkeyCache: PubkeyCache): void {
|
|
802
|
-
// Get the validators sub tree once for all the loop
|
|
803
|
-
|
|
804
|
-
const newCount = state.validators.length;
|
|
805
|
-
for (let i = pubkeyCache.size; i < newCount; i++) {
|
|
806
|
-
const pubkey = state.validators.getReadonly(i).pubkey;
|
|
807
|
-
pubkeyCache.set(i, pubkey);
|
|
797
|
+
const postPayloadState = processExecutionPayloadEnvelope(
|
|
798
|
+
this.cachedState as CachedBeaconStateGloas,
|
|
799
|
+
signedEnvelope,
|
|
800
|
+
opts
|
|
801
|
+
);
|
|
802
|
+
return new BeaconStateView(postPayloadState);
|
|
808
803
|
}
|
|
809
804
|
}
|
package/src/stateView/index.ts
CHANGED