Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overall 3.0.3 review #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 105 additions & 107 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,7 @@ func (b *BatchPoster) encodeAddBatch(
methodName := sequencerBatchPostMethodName
if use4844 {
methodName = sequencerBatchPostWithBlobsMethodName
}
if useEigenDA {
} else if useEigenDA {
methodName = sequencerBatchPostWithEigendaMethodName
}
method, ok := b.seqInboxABI.Methods[methodName]
Expand All @@ -966,122 +965,120 @@ func (b *BatchPoster) encodeAddBatch(
var calldata []byte
var kzgBlobs []kzg4844.Blob
var err error
if use4844 {
kzgBlobs, err = blobs.EncodeBlobs(l2MessageData)
if err != nil {
return nil, nil, fmt.Errorf("failed to encode blobs: %w", err)
}
// EIP4844 transactions to the sequencer inbox will not use transaction calldata for L2 info.
calldata, err = method.Inputs.Pack(
seqNum,
new(big.Int).SetUint64(delayedMsg),
b.config().gasRefunder,
new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
)
} else if useEigenDA {

blobVerificationProofType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{
{Name: "batchID", Type: "uint32"},
{Name: "blobIndex", Type: "uint32"},
{Name: "batchMetadata", Type: "tuple",
Components: []abi.ArgumentMarshaling{
{Name: "batchHeader", Type: "tuple",
Components: []abi.ArgumentMarshaling{
{Name: "blobHeadersRoot", Type: "bytes32"},
{Name: "quorumNumbers", Type: "bytes"},
{Name: "signedStakeForQuorums", Type: "bytes"},
{Name: "referenceBlockNumber", Type: "uint32"},
},
},
{Name: "signatoryRecordHash", Type: "bytes32"},
{Name: "confirmationBlockNumber", Type: "uint32"},
},
},
{
Name: "inclusionProof",
Type: "bytes",
},
{
Name: "quorumIndices",
Type: "bytes",
},
})

if err != nil {
return nil, nil, err
switch {
case use4844:
{
kzgBlobs, err = blobs.EncodeBlobs(l2MessageData)
if err != nil {
return nil, nil, fmt.Errorf("failed to encode blobs: %w", err)
}
// EIP4844 transactions to the sequencer inbox will not use transaction calldata for L2 info.
calldata, err = method.Inputs.Pack(
seqNum,
new(big.Int).SetUint64(delayedMsg),
b.config().gasRefunder,
new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
)
}

blobHeaderType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{
{Name: "commitment", Type: "tuple", Components: []abi.ArgumentMarshaling{
{Name: "X", Type: "uint256"},
{Name: "Y", Type: "uint256"},
}},
{Name: "dataLength", Type: "uint32"},
{Name: "quorumBlobParams", Type: "tuple[]", Components: []abi.ArgumentMarshaling{
{Name: "quorumNumber", Type: "uint8"},
{Name: "adversaryThresholdPercentage", Type: "uint8"},
{Name: "confirmationThresholdPercentage", Type: "uint8"},
{Name: "chunkLength", Type: "uint32"},
}},
})
if err != nil {
return nil, nil, err
case useEigenDA:
{
calldata, err = b.encodeEigenDABatch(seqNum, prevMsgNum, newMsgNum, delayedMsg, eigenDaBlobInfo)
}

addressType, err := abi.NewType("address", "", nil)
if err != nil {
return nil, nil, err
default:
{
calldata, err = method.Inputs.Pack(
seqNum,
l2MessageData,
new(big.Int).SetUint64(delayedMsg),
b.config().gasRefunder,
new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
)
}
}

uint256Type, err := abi.NewType("uint256", "", nil)
if err != nil {
return nil, nil, err
}
if err != nil {
return nil, nil, err
}
fullCalldata := append([]byte{}, method.ID...)
fullCalldata = append(fullCalldata, calldata...)
return fullCalldata, kzgBlobs, nil
}

// Create ABI arguments
arguments := abi.Arguments{
{Type: uint256Type},
{Type: blobVerificationProofType},
{Type: blobHeaderType},
{Type: addressType},
{Type: uint256Type},
{Type: uint256Type},
{Type: uint256Type},
}
func (b *BatchPoster) encodeEigenDABatch(seqNum *big.Int, prevMsgNum, newMsgNum arbutil.MessageIndex, delayedMsg uint64, eigenDaBlobInfo *eigenda.EigenDABlobInfo) ([]byte, error) {
blobVerificationProofType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{
{Name: "batchID", Type: "uint32"},
{Name: "blobIndex", Type: "uint32"},
{Name: "batchMetadata", Type: "tuple",
Components: []abi.ArgumentMarshaling{
{Name: "batchHeader", Type: "tuple",
Components: []abi.ArgumentMarshaling{
{Name: "blobHeadersRoot", Type: "bytes32"},
{Name: "quorumNumbers", Type: "bytes"},
{Name: "signedStakeForQuorums", Type: "bytes"},
{Name: "referenceBlockNumber", Type: "uint32"},
},
},
{Name: "signatoryRecordHash", Type: "bytes32"},
{Name: "confirmationBlockNumber", Type: "uint32"},
},
},
{Name: "inclusionProof", Type: "bytes"},
{Name: "quorumIndices", Type: "bytes"},
})
if err != nil {
return nil, err
}

// define values array
values := make([]interface{}, 7)
values[0] = seqNum
values[1] = eigenDaBlobInfo.BlobVerificationProof
values[2] = eigenDaBlobInfo.BlobHeader
values[3] = b.config().gasRefunder
values[4] = new(big.Int).SetUint64(delayedMsg)
values[5] = new(big.Int).SetUint64(uint64(prevMsgNum))
values[6] = new(big.Int).SetUint64(uint64(newMsgNum))
blobHeaderType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{
{Name: "commitment", Type: "tuple", Components: []abi.ArgumentMarshaling{
{Name: "X", Type: "uint256"},
{Name: "Y", Type: "uint256"},
}},
{Name: "dataLength", Type: "uint32"},
{Name: "quorumBlobParams", Type: "tuple[]", Components: []abi.ArgumentMarshaling{
{Name: "quorumNumber", Type: "uint8"},
{Name: "adversaryThresholdPercentage", Type: "uint8"},
{Name: "confirmationThresholdPercentage", Type: "uint8"},
{Name: "chunkLength", Type: "uint32"},
}},
})
if err != nil {
return nil, err
}

calldata, err = arguments.PackValues(values)
addressType, err := abi.NewType("address", "", nil)
if err != nil {
return nil, err
}

if err != nil {
return nil, nil, err
}
uint256Type, err := abi.NewType("uint256", "", nil)
if err != nil {
return nil, err
}

} else {
calldata, err = method.Inputs.Pack(
seqNum,
l2MessageData,
new(big.Int).SetUint64(delayedMsg),
b.config().gasRefunder,
new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
)
arguments := abi.Arguments{
{Type: uint256Type},
{Type: blobVerificationProofType},
{Type: blobHeaderType},
{Type: addressType},
{Type: uint256Type},
{Type: uint256Type},
{Type: uint256Type},
}
if err != nil {
return nil, nil, err

values := []interface{}{
seqNum,
eigenDaBlobInfo.BlobVerificationProof,
eigenDaBlobInfo.BlobHeader,
b.config().gasRefunder,
new(big.Int).SetUint64(delayedMsg),
new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
}
fullCalldata := append([]byte{}, method.ID...)
fullCalldata = append(fullCalldata, calldata...)
return fullCalldata, kzgBlobs, nil

return arguments.PackValues(values)
}

var ErrNormalGasEstimationFailed = errors.New("normal gas estimation failed")
Expand Down Expand Up @@ -1143,6 +1140,7 @@ func (b *BatchPoster) estimateGas(ctx context.Context, sequencerMessage []byte,
// However, we set nextMsgNum to 1 because it is necessary for a correct estimation for the final to be non-zero.
// Because we're likely estimating against older state, this might not be the actual next message,
// but the gas used should be the same.
//TODO: better determination of batch type (4844, EigenDA, etc)
data, kzgBlobs, err := b.encodeAddBatch(abi.MaxUint256, 0, 1, sequencerMessage, delayedMessages, len(realBlobs) > 0, eigenDaBlobInfo != nil, eigenDaBlobInfo)
if err != nil {
return 0, err
Expand Down
2 changes: 1 addition & 1 deletion nitro-testnode
Loading