diff --git a/common/consts/consts.go b/common/consts/consts.go new file mode 100644 index 00000000..95ba90c9 --- /dev/null +++ b/common/consts/consts.go @@ -0,0 +1,8 @@ +package consts + +// EthHappyPathFinalizationDepth is the number of blocks that must be included on top of a block for it to be considered "final", +// under happy-path aka normal network conditions. +// +// See https://docs.optimism.io/stack/transactions/transaction-finality for a quick TLDR explanation, +// or https://eth2book.info/capella/part3/transition/epoch/#finalisation for full details. +var EthHappyPathFinalizationDepthBlocks = uint8(64) diff --git a/flags/eigendaflags/cli.go b/flags/eigendaflags/cli.go index 77bba378..6f75463f 100644 --- a/flags/eigendaflags/cli.go +++ b/flags/eigendaflags/cli.go @@ -5,6 +5,7 @@ import ( "strconv" "time" + "github.com/Layr-Labs/eigenda-proxy/common/consts" "github.com/Layr-Labs/eigenda/api/clients" "github.com/Layr-Labs/eigenda/api/clients/codecs" "github.com/urfave/cli/v2" @@ -209,7 +210,7 @@ func validateConfirmationFlag(val string) error { return fmt.Errorf("confirmation-depth must be either 'finalized' or a number, got: %s", val) } - if depth >= 64 { + if depth >= uint64(consts.EthHappyPathFinalizationDepthBlocks) { // We keep this low (<128) to avoid requiring an archive node (see how this is used in CertVerifier). // Note: assuming here that no sane person would ever need to set this to a number to something >64. // But perhaps someone testing crazy reorg scenarios where finalization takes >2 epochs might want to set this to a higher number...? diff --git a/verify/cert.go b/verify/cert.go index b243d6cb..7d25e6dc 100644 --- a/verify/cert.go +++ b/verify/cert.go @@ -8,6 +8,7 @@ import ( "math/big" "time" + "github.com/Layr-Labs/eigenda-proxy/common/consts" "github.com/Layr-Labs/eigenda/api/grpc/disperser" binding "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager" @@ -26,7 +27,7 @@ type CertVerifier struct { l log.Logger // ethConfirmationDepth is used to verify that a blob's batch commitment has been bridged to the EigenDAServiceManager contract at least // this many blocks in the past. To do so we make an eth_call to the contract at the current block_number - ethConfirmationDepth. - // Hence in order to not require an archive node, this value should be kept low. We force it to be < 64. + // Hence in order to not require an archive node, this value should be kept low. We force it to be < 64 (consts.EthHappyPathFinalizationDepthBlocks). // waitForFinalization should be used instead of ethConfirmationDepth if the user wants to wait for finality (typically 64 blocks in happy case). ethConfirmationDepth uint64 waitForFinalization bool @@ -40,7 +41,7 @@ type CertVerifier struct { } func NewCertVerifier(cfg *Config, l log.Logger) (*CertVerifier, error) { - if cfg.EthConfirmationDepth >= 64 { + if cfg.EthConfirmationDepth >= uint64(consts.EthHappyPathFinalizationDepthBlocks) { // We keep this low (<128) to avoid requiring an archive node. return nil, fmt.Errorf("confirmation depth must be less than 64; consider using cfg.WaitForFinalization=true instead") }