Sammy Rosso d55757500f
Integrate EIP-4881 Deposit Tree Into Prysm via a Feature Flag (#11942)
* Initial spec rewrite

* Finish adding merkle tree implementation

* Last bits

* Move reverse function

* Add comments

* Add deposit tree snapshot

* Add deposit tree

* Add comments + cleanup

* Fixes

* Add missing errors

* Small fixes

* Add unhandled error

* Cleanup

* Fix unsafe file.Close

* Add missing comments

* Small fixes

* Address some of deepSource' compaints

* Add depositCount check

* Add finalizedDeposit check

* Replace pointer magic with copy()

* Add test for slice reversal

* add back bytes method

* Add package level description

* Remove zerohash gen and add additional checks

* Add additional comments

* Small lint fixes

* Forgot an error

* Small fixes

* Move Uint64ToBytesLittleEndian32 + test

* Fix uint subtraction issue

* Move mixInLength below error handling

* Fix

* Fix deposit root

* integrate 4881

* edits

* added in deposit tree fetcher

* add file

* Add remaining fetcher functions

* Add new file for inserter functions

* Fixes and additional funcs

* Cleanup

* Add

* Graph

* pushed up edits

* fix up

* Updates

* Add EIP4881 toggle flag

* Add interfaces

* Fix tests

* More changes

* Fix

* Remove generated graph

* Fix spacing

* Changes

* Fixes

* Changes

* Test Fix

* gaz

* Fix a couple tests

* Fix last tests

* define protos

* proto methods

* pushed

* regen

* Add proto funcs

* builds

* pushin up

* Fix and cleanup

* Fix spectest

* General cleanup

* add 4881 to e2e

* Remove debug statements + remove test skip

* Implement first set of  missing methods

* Replace Zerohashes + cleanup

* gazelle

* fmt

* Put back defensive check

* Add error logs

* InsertFinalizedDeposits: return an error

* Remove logging

* Radek' Review

* Lint fixes

* build

* Remove cancel

* Update beacon-chain/deterministic-genesis/service.go

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* Update beacon-chain/cache/depositsnapshot/deposit_inserter.go

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* Cleanup

* Fix panic when DepositSnapshot is nil on init

* Gofmt

* Fix RootEquivalence test

* Gofmt

* Add missing comments

* Nishant' review

* Add Insert benchmarks

* fix up copy method

* Fix deep copy

* Fix conflicts

* Return error

* Fix linter issues

* add in migration logic

* Cleanup + tests

* fix

* Fix incorrect index in test

* Fix linter

* Gofmt

* fix it

* fixes for off by 1

* gaz

* fix cast

* fix it

* remove ErrZeroIndex

* Fix merkle_tree_test

* add fallback

* add fix for insertion bug

* add many fixes

* fix empty snapshot

* clean up

* use feature

* remove check

* fix failing tests

* skip it

* fix test

* fix test again

* fix for the last time

* Apply suggestions from code review

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* fix it

* remove cancel

* fix for voting

* addressing more comments

* fix err

* potuz's review

* one more test

* fix bad test

* make 4881 part of dev mode

* add workaround for new trie

* comment

* preston's review

* james's review

* add comment

* james review

* preston's review

* remove skipped test

* gaz

---------

Co-authored-by: rauljordan <raul@prysmaticlabs.com>
Co-authored-by: nisdas <nishdas93@gmail.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2023-09-07 03:19:32 +00:00

243 lines
8.7 KiB
Go

package features
import (
"time"
"github.com/urfave/cli/v2"
)
var (
// PraterTestnet flag for the multiclient Ethereum consensus testnet.
PraterTestnet = &cli.BoolFlag{
Name: "prater",
Usage: "Run Prysm configured for the Prater / Goerli test network",
Aliases: []string{"goerli"},
}
// SepoliaTestnet flag for the multiclient Ethereum consensus testnet.
SepoliaTestnet = &cli.BoolFlag{
Name: "sepolia",
Usage: "Run Prysm configured for the Sepolia beacon chain test network",
}
// HoleskyTestnet flag for the multiclient Ethereum consensus testnet.
HoleskyTestnet = &cli.BoolFlag{
Name: "holesky",
Usage: "Run Prysm configured for the Holesky beacon chain test network",
}
// Mainnet flag for easier tooling, no-op
Mainnet = &cli.BoolFlag{
Value: true,
Name: "mainnet",
Usage: "Run on Ethereum Beacon Chain Main Net. This is the default and can be omitted.",
}
devModeFlag = &cli.BoolFlag{
Name: "dev",
Usage: "Enable experimental features still in development. These features may not be stable.",
}
writeSSZStateTransitionsFlag = &cli.BoolFlag{
Name: "interop-write-ssz-state-transitions",
Usage: "Write ssz states to disk after attempted state transition",
}
enableExternalSlasherProtectionFlag = &cli.BoolFlag{
Name: "enable-external-slasher-protection",
Usage: "Enables the validator to connect to a beacon node using the --slasher flag" +
"for remote slashing protection",
}
disableGRPCConnectionLogging = &cli.BoolFlag{
Name: "disable-grpc-connection-logging",
Usage: "Disables displaying logs for newly connected grpc clients",
}
disableReorgLateBlocks = &cli.BoolFlag{
Name: "disable-reorg-late-blocks",
Usage: "Disables reorgs of late blocks",
}
disablePeerScorer = &cli.BoolFlag{
Name: "disable-peer-scorer",
Usage: "(Danger): Disables P2P peer scorer. Do NOT use this in production!",
}
writeWalletPasswordOnWebOnboarding = &cli.BoolFlag{
Name: "write-wallet-password-on-web-onboarding",
Usage: "(Danger): Writes the wallet password to the wallet directory on completing Prysm web onboarding. " +
"We recommend against this flag unless you are an advanced user.",
}
aggregateFirstInterval = &cli.DurationFlag{
Name: "aggregate-first-interval",
Usage: "(Advanced): Specifies the first interval in which attestations are aggregated in the slot (typically unnaggregated attestations are aggregated in this interval)",
Value: 6500 * time.Millisecond,
Hidden: true,
}
aggregateSecondInterval = &cli.DurationFlag{
Name: "aggregate-second-interval",
Usage: "(Advanced): Specifies the second interval in which attestations are aggregated in the slot",
Value: 9500 * time.Millisecond,
Hidden: true,
}
aggregateThirdInterval = &cli.DurationFlag{
Name: "aggregate-third-interval",
Usage: "(Advanced): Specifies the third interval in which attestations are aggregated in the slot",
Value: 11800 * time.Millisecond,
Hidden: true,
}
dynamicKeyReloadDebounceInterval = &cli.DurationFlag{
Name: "dynamic-key-reload-debounce-interval",
Usage: "(Advanced): Specifies the time duration the validator waits to reload new keys if they have " +
"changed on disk. Default 1s, can be any type of duration such as 1.5s, 1000ms, 1m.",
Value: time.Second,
}
disableBroadcastSlashingFlag = &cli.BoolFlag{
Name: "disable-broadcast-slashings",
Usage: "Disables broadcasting slashings submitted to the beacon node.",
}
attestTimely = &cli.BoolFlag{
Name: "attest-timely",
Usage: "Fixes validator can attest timely after current block processes. See #8185 for more details",
}
enableSlasherFlag = &cli.BoolFlag{
Name: "slasher",
Usage: "Enables a slasher in the beacon node for detecting slashable offenses",
}
enableSlashingProtectionPruning = &cli.BoolFlag{
Name: "enable-slashing-protection-history-pruning",
Usage: "Enables the pruning of the validator client's slashing protection database",
}
enableDoppelGangerProtection = &cli.BoolFlag{
Name: "enable-doppelganger",
Usage: "Enables the validator to perform a doppelganger check. (Warning): This is not " +
"a foolproof method to find duplicate instances in the network. Your validator will still be" +
" vulnerable if it is being run in unsafe configurations.",
}
disableStakinContractCheck = &cli.BoolFlag{
Name: "disable-staking-contract-check",
Usage: "Disables checking of staking contract deposits when proposing blocks, useful for devnets",
}
enableHistoricalSpaceRepresentation = &cli.BoolFlag{
Name: "enable-historical-state-representation",
Usage: "Enables the beacon chain to save historical states in a space efficient manner." +
" (Warning): Once enabled, this feature migrates your database in to a new schema and " +
"there is no going back. At worst, your entire database might get corrupted.",
}
enableStartupOptimistic = &cli.BoolFlag{
Name: "startup-optimistic",
Usage: "Treats every block as optimistically synced at launch. Use with caution",
Value: false,
Hidden: true,
}
enableFullSSZDataLogging = &cli.BoolFlag{
Name: "enable-full-ssz-data-logging",
Usage: "Enables displaying logs for full ssz data on rejected gossip messages",
}
SaveFullExecutionPayloads = &cli.BoolFlag{
Name: "save-full-execution-payloads",
Usage: "Saves beacon blocks with full execution payloads instead of execution payload headers in the database",
}
EnableBeaconRESTApi = &cli.BoolFlag{
Name: "enable-beacon-rest-api",
Usage: "Experimental enable of the beacon REST API when querying a beacon node",
}
enableVerboseSigVerification = &cli.BoolFlag{
Name: "enable-verbose-sig-verification",
Usage: "Enables identifying invalid signatures if batch verification fails when processing block",
}
enableOptionalEngineMethods = &cli.BoolFlag{
Name: "enable-optional-engine-methods",
Usage: "Enables the optional engine methods",
}
prepareAllPayloads = &cli.BoolFlag{
Name: "prepare-all-payloads",
Usage: "Informs the engine to prepare all local payloads. Useful for relayers and builders",
}
disableBuildBlockParallel = &cli.BoolFlag{
Name: "disable-build-block-parallel",
Usage: "Disables building a beacon block in parallel for consensus and execution",
}
enableEIP4881 = &cli.BoolFlag{
Name: "enable-eip-4881",
Usage: "Enables the deposit tree specified in EIP4881",
}
disableResourceManager = &cli.BoolFlag{
Name: "disable-resource-manager",
Usage: "Disables running the libp2p resource manager",
}
// DisableRegistrationCache a flag for disabling the validator registration cache and use db instead.
DisableRegistrationCache = &cli.BoolFlag{
Name: "disable-registration-cache",
Usage: "A temporary flag for disabling the validator registration cache instead of using the db. note: registrations do not clear on restart while using the db",
}
disableAggregateParallel = &cli.BoolFlag{
Name: "disable-aggregate-parallel",
Usage: "Disables parallel aggregation of attestations",
}
)
// devModeFlags holds list of flags that are set when development mode is on.
var devModeFlags = []cli.Flag{
enableVerboseSigVerification,
enableOptionalEngineMethods,
enableEIP4881,
}
// ValidatorFlags contains a list of all the feature flags that apply to the validator client.
var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
writeWalletPasswordOnWebOnboarding,
enableExternalSlasherProtectionFlag,
HoleskyTestnet,
PraterTestnet,
SepoliaTestnet,
Mainnet,
dynamicKeyReloadDebounceInterval,
attestTimely,
enableSlashingProtectionPruning,
enableDoppelGangerProtection,
EnableBeaconRESTApi,
}...)
// E2EValidatorFlags contains a list of the validator feature flags to be tested in E2E.
var E2EValidatorFlags = []string{
"--enable-doppelganger",
}
// BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client.
var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []cli.Flag{
devModeFlag,
writeSSZStateTransitionsFlag,
disableGRPCConnectionLogging,
HoleskyTestnet,
PraterTestnet,
SepoliaTestnet,
Mainnet,
disablePeerScorer,
disableBroadcastSlashingFlag,
enableSlasherFlag,
enableHistoricalSpaceRepresentation,
disableStakinContractCheck,
disableReorgLateBlocks,
SaveFullExecutionPayloads,
enableStartupOptimistic,
enableFullSSZDataLogging,
enableVerboseSigVerification,
enableOptionalEngineMethods,
prepareAllPayloads,
disableBuildBlockParallel,
aggregateFirstInterval,
aggregateSecondInterval,
aggregateThirdInterval,
enableEIP4881,
disableResourceManager,
DisableRegistrationCache,
disableAggregateParallel,
}...)...)
// E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.
var E2EBeaconChainFlags = []string{
"--dev",
}
// NetworkFlags contains a list of network flags.
var NetworkFlags = []cli.Flag{
Mainnet,
PraterTestnet,
SepoliaTestnet,
HoleskyTestnet,
}