diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 3f6579b56..8a7f4f8d9 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -109,11 +109,11 @@ type BatchPoster struct { dapWriter daprovider.Writer // This deviates from the DA spec but is necessary for the batch poster to work efficiently // since we need to an extended method on the SequencerInbox contract - eigenDAWriter eigenda.EigenDAWriter - dataPoster *dataposter.DataPoster - redisLock *redislock.Simple - messagesPerBatch *arbmath.MovingAverage[uint64] - non4844BatchCount int // Count of consecutive non-4844 batches posted + eigenDAWriter eigenda.EigenDAWriter + dataPoster *dataposter.DataPoster + redisLock *redislock.Simple + messagesPerBatch *arbmath.MovingAverage[uint64] + non4844BatchCount int // Count of consecutive non-4844 batches posted // This is an atomic variable that should only be accessed atomically. // An estimate of the number of batches we want to post but haven't yet. // This doesn't include batches which we don't want to post yet due to the L1 bounds. @@ -238,7 +238,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{ Enable: false, DisableDapFallbackStoreDataOnChain: false, // This default is overridden for L3 chains in applyChainParameters in cmd/nitro/nitro.go - MaxSize: 100000, + MaxSize: 100000, MaxEigenDABatchSize: 2_000_000, // Try to fill 3 blobs per batch Max4844BatchSize: blobs.BlobEncodableData*(params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)/2 - 2000, @@ -274,7 +274,7 @@ var TestBatchPosterConfig = BatchPosterConfig{ Enable: true, MaxSize: 100000, Max4844BatchSize: DefaultBatchPosterConfig.Max4844BatchSize, - MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize, + MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize, PollInterval: time.Millisecond * 10, ErrorDelay: time.Millisecond * 10, MaxDelay: 0, @@ -298,7 +298,7 @@ var EigenDABatchPosterConfig = BatchPosterConfig{ Enable: true, MaxSize: 100000, Max4844BatchSize: DefaultBatchPosterConfig.Max4844BatchSize, - MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize, + MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize, PollInterval: time.Millisecond * 10, ErrorDelay: time.Millisecond * 10, MaxDelay: 0, @@ -710,7 +710,7 @@ type buildingBatch struct { msgCount arbutil.MessageIndex haveUsefulMessage bool use4844 bool - useEigenDA bool + useEigenDA bool } func newBatchSegments(firstDelayed uint64, config *BatchPosterConfig, backlog uint64, use4844 bool, useEigenDA bool) *batchSegments { diff --git a/arbnode/sequencer_inbox.go b/arbnode/sequencer_inbox.go index ce90e92d8..6af0eb310 100644 --- a/arbnode/sequencer_inbox.go +++ b/arbnode/sequencer_inbox.go @@ -175,8 +175,8 @@ func (m *SequencerInboxBatch) getSequencerData(ctx context.Context, client arbut calldata := tx.Data() data := []byte{daprovider.EigenDAMessageHeaderFlag} - data = append(data, calldata[:]...) - + data = append(data, calldata...) + return data, nil default: return nil, fmt.Errorf("batch has invalid data location %v", m.dataLocation) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index a226af1e0..fae4aadd5 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -605,8 +605,8 @@ func mainImpl() int { // NOTE: since the SRS is stored within the arbitrator and predetermines the max batch size // supported for proving stateless execution - it could be possible to read from dynamically - // otherwise it maybe best to expose the max supported batch size from the disperser directly - // to ensure dynamically adaptability within the rollup. + // otherwise it maybe best to expose the max supported batch size from the disperser directly + // to ensure dynamically adaptability within the rollup. if nodeConfig.Node.BatchPoster.Enable && nodeConfig.Node.EigenDA.Enable { if nodeConfig.Node.BatchPoster.MaxEigenDABatchSize > eigenda.MaxBatchSize { log.Error("batchPoster's MaxEigenDABatchSize too large.", "MaxEigenDABatchSize", eigenda.MaxBatchSize) diff --git a/cmd/replay/main.go b/cmd/replay/main.go index 1c43b6012..07d63e91d 100644 --- a/cmd/replay/main.go +++ b/cmd/replay/main.go @@ -124,6 +124,7 @@ func (dasReader *PreimageDASReader) ExpirationPolicy(ctx context.Context) (dapro } type BlobPreimageReader struct{} + func (r *BlobPreimageReader) GetBlobs( ctx context.Context, batchBlockHash common.Hash, @@ -149,8 +150,8 @@ func (r *BlobPreimageReader) Initialize(ctx context.Context) error { return nil } - type EigenDAPreimageReader struct{} + // QueryBlob returns the blob for the given cert from the preimage oracle using the hash of the // certificate kzg commitment for identifying the preimage. func (dasReader *EigenDAPreimageReader) QueryBlob(ctx context.Context, cert *eigenda.EigenDABlobInfo, domain string) ([]byte, error) { @@ -177,12 +178,10 @@ func (dasReader *EigenDAPreimageReader) QueryBlob(ctx context.Context, cert *eig println("Error decoding blob: ", err) return nil, err } - + return decodedBlob, nil } - - // To generate: // key, _ := crypto.HexToECDSA("0000000000000000000000000000000000000000000000000000000000000001") // sig, _ := crypto.Sign(make([]byte, 32), key) diff --git a/eigenda/decoding.go b/eigenda/decoding.go index 373947751..83bf8327e 100644 --- a/eigenda/decoding.go +++ b/eigenda/decoding.go @@ -93,7 +93,6 @@ func DecodeBlob(data []byte) ([]byte, error) { } - func EncodeBlob(data []byte) ([]byte, error) { var err error data, err = encodeBlob(data) @@ -104,8 +103,6 @@ func EncodeBlob(data []byte) ([]byte, error) { return IFFT(data) } - - func encodeBlob(rawData []byte) ([]byte, error) { codecBlobHeader := make([]byte, 32) // first byte is always 0 to ensure the codecBlobHeader is a valid bn254 element @@ -118,13 +115,13 @@ func encodeBlob(rawData []byte) ([]byte, error) { // encode raw data modulo bn254 rawDataPadded := codec.ConvertByPaddingEmptyByte(rawData) - // append raw data - encodedData := append(codecBlobHeader, rawDataPadded...) + // append raw data; reassgin avoids copying + encodedData := codecBlobHeader + encodedData = append(encodedData, rawDataPadded...) return encodedData, nil } - func IFFT(data []byte) ([]byte, error) { // we now IFFT data regardless of the encoding type // convert data to fr.Element @@ -156,4 +153,4 @@ func IFFT(data []byte) ([]byte, error) { } return rs.ToByteArray(dataIFFTFr, dataFrLenPow2*encoding.BYTES_PER_SYMBOL), nil -} \ No newline at end of file +} diff --git a/eigenda/proxy.go b/eigenda/proxy.go index 1c2238e8f..40b0188cd 100644 --- a/eigenda/proxy.go +++ b/eigenda/proxy.go @@ -15,10 +15,9 @@ type EigenDAProxyClient struct { client ProxyClient } -func NewEigenDAProxyClient(RPCUrl string) *EigenDAProxyClient { - +func NewEigenDAProxyClient(rpcUrl string) *EigenDAProxyClient { c := New(&Config{ - URL: RPCUrl, + URL: rpcUrl, }) return &EigenDAProxyClient{client: c} } @@ -89,7 +88,7 @@ func StrToDomainType(s string) DomainType { // TODO: Add support for custom http client option type Config struct { - URL string + URL string } // ProxyClient is an interface for communicating with the EigenDA proxy server @@ -141,7 +140,7 @@ func (c *client) GetData(ctx context.Context, comm []byte, domain DomainType) ([ req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { - return nil, fmt.Errorf("failed to construct http request: %e", err) + return nil, fmt.Errorf("failed to construct http request: %w", err) } req.Header.Set("Content-Type", "application/octet-stream") diff --git a/eigenda/reader.go b/eigenda/reader.go index 21799eec1..12202ee4d 100644 --- a/eigenda/reader.go +++ b/eigenda/reader.go @@ -35,11 +35,10 @@ func (d *readerForEigenDA) RecoverPayloadFromBatch( preimageRecorder daprovider.PreimageRecorder, validateSeqMsg bool, ) ([]byte, error) { - // offset sequencer message at 41 + // offset sequencer message at 41 return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[41:], d.readerEigenDA, preimageRecorder, "binary") } - func RecoverPayloadFromEigenDABatch(ctx context.Context, sequencerMsg []byte, daReader EigenDAReader, @@ -83,7 +82,7 @@ func RecoverPayloadFromEigenDABatch(ctx context.Context, // ParseSequencerMsg parses the inbox tx calldata into a structured EigenDABlobInfo func ParseSequencerMsg(calldata []byte) (*EigenDABlobInfo, error) { - + if len(calldata) < 4 { return nil, errors.New("calldata is shorter than expected method signature length") } @@ -140,6 +139,6 @@ func (d *binaryReaderForEigenDA) RecoverPayloadFromBatch( preimageRecorder daprovider.PreimageRecorder, validateSeqMsg bool, ) ([]byte, error) { - // offset sequencer message at 41 + // offset sequencer message at 41 return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[41:], d.readerEigenDA, preimageRecorder, "binary") } diff --git a/eigenda/types.go b/eigenda/types.go index d628e2a06..4d799b3c9 100644 --- a/eigenda/types.go +++ b/eigenda/types.go @@ -254,9 +254,9 @@ func (e *EigenDABlobInfo) ToDisperserBlobInfo() (*DisperserBlobInfo, error) { // Convert BlobVerificationProof var disperserBlobVerificationProof DisperserBlobVerificationProof - if &e.BlobVerificationProof != nil { + if !e.BlobVerificationProof.IsEmpty() { var disperserBatchMetadata DisperserBatchMetadata - if &e.BlobVerificationProof.BatchMetadata != nil { + if !e.BlobVerificationProof.BatchMetadata.IsEmpty() { metadata := e.BlobVerificationProof.BatchMetadata quorumNumbers := metadata.BatchHeader.QuorumNumbers quorumSignedPercentages := metadata.BatchHeader.SignedStakeForQuorums @@ -395,3 +395,29 @@ func (ip *InboxPayload) Load(callDataValues []interface{}) error { *ip = payload return nil } + +// IsEmpty checks if BlobVerificationProof is effectively empty +func (b BlobVerificationProof) IsEmpty() bool { + return b.BatchID == 0 && + b.BlobIndex == 0 && + b.BatchMetadata.IsEmpty() && + len(b.InclusionProof) == 0 && + len(b.QuorumIndices) == 0 +} + +// IsEmpty checks if BatchMetadata is effectively empty +func (bm BatchMetadata) IsEmpty() bool { + return bm.BatchHeader.IsEmpty() && + len(bm.Fee) == 0 && + bm.SignatoryRecordHash == [32]byte{} && + bm.ConfirmationBlockNumber == 0 && + len(bm.BatchHeaderHash) == 0 +} + +// IsEmpty checks if BatchHeader is effectively empty +func (bh BatchHeader) IsEmpty() bool { + return bh.BlobHeadersRoot == [32]byte{} && + len(bh.QuorumNumbers) == 0 && + len(bh.SignedStakeForQuorums) == 0 && + bh.ReferenceBlockNumber == 0 +} diff --git a/validator/server_jit/jit_machine.go b/validator/server_jit/jit_machine.go index 473c01be0..4aaa447ec 100644 --- a/validator/server_jit/jit_machine.go +++ b/validator/server_jit/jit_machine.go @@ -67,7 +67,6 @@ func (machine *JitMachine) close() { func (machine *JitMachine) prove( ctxIn context.Context, entry *validator.ValidationInput, ) (validator.GoGlobalState, error) { - ctx, cancel := context.WithCancel(ctxIn) defer cancel() // ensure our cleanup functions run when we're done