Skip to content

Commit

Permalink
Remove MAX_TRANSACTIONS_PER_INCLUSION_LIST and use bellatrix.Transact…
Browse files Browse the repository at this point in the history
…ions as type
  • Loading branch information
nflaig committed Jan 24, 2025
1 parent 6b4953e commit a7a330c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
2 changes: 0 additions & 2 deletions packages/beacon-node/src/chain/errors/inclusionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export enum InclusionListErrorCode {
NOT_TIMELY = "INCLUSION_LIST_ERROR_NOT_TIMELY",
INVALID_COMMITTEE_ROOT = "INCLUSION_LIST_ERROR_INVALID_COMMITTEE_ROOT",
VALIDATOR_NOT_IN_COMMITTEE = "INCLUSION_LIST_ERROR_VALIDATOR_NOT_IN_COMMITTEE",
TOO_MANY_TRANSACTIONS = "INCLUSION_LIST_ERROR_TOO_MANY_TRANSACTIONS",
SPAM = "INCLUSION_LIST_ERROR_SPAM",
INVALID_SIGNATURE = "INCLUSION_LIST_ERROR_INVALID_SIGNATURE",
MORE_THAN_TWO = "INCLUSION_LIST_ERROR_MORE_THAN_TWO",
Expand All @@ -18,7 +17,6 @@ export type InclusionListErrorType =
| {code: InclusionListErrorCode.NOT_TIMELY}
| {code: InclusionListErrorCode.INVALID_COMMITTEE_ROOT}
| {code: InclusionListErrorCode.VALIDATOR_NOT_IN_COMMITTEE}
| {code: InclusionListErrorCode.TOO_MANY_TRANSACTIONS; numTransactions: number; transactionLimit: number}
| {code: InclusionListErrorCode.SPAM}
| {code: InclusionListErrorCode.INVALID_SIGNATURE}
| {code: InclusionListErrorCode.MORE_THAN_TWO; validatorIndex: ValidatorIndex};
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/src/chain/opPools/inclusionListPool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ChainForkConfig} from "@lodestar/config";
import {INCLUSION_LIST_COMMITTEE_SIZE} from "@lodestar/params";
import {Slot, ValidatorIndex, focil} from "@lodestar/types";
import {Slot, ValidatorIndex, bellatrix, focil} from "@lodestar/types";
import {MapDef} from "@lodestar/utils";
import {byteArrayEquals} from "../../util/bytes.js";
import {IClock} from "../../util/clock.js";
Expand All @@ -20,7 +20,7 @@ const SLOTS_RETAINED = 2; // TODO FOCIL: do we even need to retain previous slot
const MAX_INCLUSION_LISTS_PER_SLOT = INCLUSION_LIST_COMMITTEE_SIZE * 2;

type CachedInclusionList = {
transactions: focil.InclusionListTransactions;
transactions: bellatrix.Transactions;
seenTwice: boolean;
};

Expand Down Expand Up @@ -95,8 +95,8 @@ export class InclusionListPool {
/**
* Return a list of unique inclusion list transactions for the given slot
*/
getTransactions(slot: Slot): focil.InclusionListTransactions {
const uniqueTransactions: focil.InclusionListTransactions = [];
getTransactions(slot: Slot): bellatrix.Transactions {
const uniqueTransactions: bellatrix.Transactions = [];

const inclusionListsByValidator = this.inclusionListByValidatorBySlot.get(slot);
if (!inclusionListsByValidator) {
Expand Down
10 changes: 0 additions & 10 deletions packages/beacon-node/src/chain/validation/inclusionList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {MAX_TRANSACTIONS_PER_INCLUSION_LIST} from "@lodestar/params";
import {getInclusionListSignatureSet} from "@lodestar/state-transition";
import {focil} from "@lodestar/types";
import {InclusionListError, InclusionListErrorCode} from "../errors/inclusionList.js";
Expand Down Expand Up @@ -48,15 +47,6 @@ async function validateInclusionList(chain: IBeaconChain, inclusionList: focil.S

// [REJECT] The validator index message.validator_index is within the inclusion_list_committee corresponding to message.inclusion_list_committee_root.

// [REJECT] The transactions message.transactions length is within upperbound MAX_TRANSACTIONS_PER_INCLUSION_LIST
if (transactions.length > MAX_TRANSACTIONS_PER_INCLUSION_LIST) {
throw new InclusionListError(GossipAction.REJECT, {
code: InclusionListErrorCode.TOO_MANY_TRANSACTIONS,
numTransactions: transactions.length,
transactionLimit: MAX_TRANSACTIONS_PER_INCLUSION_LIST,
});
}

// TODO FOCIL: use a different cache similar to `seenAttesters` here?
// [IGNORE] The message is either the first or second valid message received from the validator with index message.validator_index.
if (chain.inclusionListPool.seenTwice(slot, validatorIndex)) {
Expand Down
3 changes: 0 additions & 3 deletions packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,3 @@ export const CONSOLIDATION_REQUEST_TYPE = 0x02;

// focil
export const INCLUSION_LIST_COMMITTEE_SIZE = 16;
// TODO FOCIL: same as `MAX_TRANSACTIONS_PER_PAYLOAD` for now but will likely
// be removed as we limit inclusion lists by bytes and not transaction count
export const MAX_TRANSACTIONS_PER_INCLUSION_LIST = 1048576;
11 changes: 3 additions & 8 deletions packages/types/src/focil/sszTypes.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import {BitVectorType, ContainerType, ListCompositeType} from "@chainsafe/ssz";
import {INCLUSION_LIST_COMMITTEE_SIZE, MAX_TRANSACTIONS_PER_INCLUSION_LIST} from "@lodestar/params";
import {BitVectorType, ContainerType} from "@chainsafe/ssz";
import {INCLUSION_LIST_COMMITTEE_SIZE} from "@lodestar/params";
import {ssz as bellatrixSsz} from "../bellatrix/index.js";
import {ssz as electraSsz} from "../electra/index.js";
import {ssz as primitiveSsz} from "../primitive/index.js";

const {Slot, Root, BLSSignature, ValidatorIndex} = primitiveSsz;

export const InclusionListTransactions = new ListCompositeType(
bellatrixSsz.Transaction,
MAX_TRANSACTIONS_PER_INCLUSION_LIST
);

export const InclusionList = new ContainerType(
{
slot: Slot,
validatorIndex: ValidatorIndex,
inclusionListCommitteeRoot: Root,
transactions: InclusionListTransactions,
transactions: bellatrixSsz.Transactions,
},
{typeName: "InclusionList", jsonCase: "eth2"}
);
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/focil/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as ssz from "./sszTypes.js";
export type InclusionList = ValueOf<typeof ssz.InclusionList>;
export type SignedInclusionList = ValueOf<typeof ssz.SignedInclusionList>;
export type InclusionListByCommitteeIndicesRequest = ValueOf<typeof ssz.InclusionListByCommitteeIndicesRequest>;
export type InclusionListTransactions = ValueOf<typeof ssz.InclusionListTransactions>;

export type BeaconState = ValueOf<typeof ssz.BeaconState>;
export type BeaconBlockBody = ValueOf<typeof ssz.BeaconBlockBody>;
Expand Down

0 comments on commit a7a330c

Please sign in to comment.