Skip to content

Commit

Permalink
batcher use txn manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Jan 8, 2024
1 parent 7de8438 commit 0c9760e
Show file tree
Hide file tree
Showing 12 changed files with 406 additions and 191 deletions.
4 changes: 2 additions & 2 deletions core/eth/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (t *Transactor) GetOperatorStakesForQuorums(ctx context.Context, quorums []
// BuildConfirmBatchTxn builds a transaction to confirm a batch header and signature aggregation. The signature aggregation must satisfy the quorum thresholds
// specified in the batch header. If the signature aggregation does not satisfy the quorum thresholds, the transaction will fail.
// Note that this function returns a transaction without publishing it to the blockchain. The caller is responsible for publishing the transaction.
func (t *Transactor) BuildConfirmBatchTxn(ctx context.Context, batchHeader core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation core.SignatureAggregation) (*types.Transaction, error) {
func (t *Transactor) BuildConfirmBatchTxn(ctx context.Context, batchHeader *core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation *core.SignatureAggregation) (*types.Transaction, error) {
quorumNumbers := quorumParamsToQuorumNumbers(quorums)
nonSignerOperatorIds := make([][32]byte, len(signatureAggregation.NonSigners))
for i := range signatureAggregation.NonSigners {
Expand Down Expand Up @@ -496,7 +496,7 @@ func (t *Transactor) BuildConfirmBatchTxn(ctx context.Context, batchHeader core.

// ConfirmBatch confirms a batch header and signature aggregation. The signature aggregation must satisfy the quorum thresholds
// specified in the batch header. If the signature aggregation does not satisfy the quorum thresholds, the transaction will fail.
func (t *Transactor) ConfirmBatch(ctx context.Context, batchHeader core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation core.SignatureAggregation) (*types.Receipt, error) {
func (t *Transactor) ConfirmBatch(ctx context.Context, batchHeader *core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation *core.SignatureAggregation) (*types.Receipt, error) {
tx, err := t.BuildConfirmBatchTxn(ctx, batchHeader, quorums, signatureAggregation)
if err != nil {
t.Logger.Error("Failed to build a ConfirmBatch txn", "err", err)
Expand Down
8 changes: 7 additions & 1 deletion core/mock/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ func (t *MockTransactor) GetOperatorStakesForQuorums(ctx context.Context, quorum
return result.(core.OperatorStakes), args.Error(1)
}

func (t *MockTransactor) ConfirmBatch(ctx context.Context, batchHeader core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation core.SignatureAggregation) (*types.Receipt, error) {
func (t *MockTransactor) BuildConfirmBatchTxn(ctx context.Context, batchHeader *core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation *core.SignatureAggregation) (*types.Transaction, error) {
args := t.Called()
result := args.Get(0)
return result.(*types.Transaction), args.Error(1)
}

func (t *MockTransactor) ConfirmBatch(ctx context.Context, batchHeader *core.BatchHeader, quorums map[core.QuorumID]*core.QuorumResult, signatureAggregation *core.SignatureAggregation) (*types.Receipt, error) {
args := t.Called()
var receipt *types.Receipt
if args.Get(0) != nil {
Expand Down
5 changes: 4 additions & 1 deletion core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ type Transactor interface {
// The indices of the operators within each quorum are also returned.
GetOperatorStakesForQuorums(ctx context.Context, quorums []QuorumID, blockNumber uint32) (OperatorStakes, error)

// BuildConfirmBatchTxn builds a transaction to confirm a batch header and signature aggregation.
BuildConfirmBatchTxn(ctx context.Context, batchHeader *BatchHeader, quorums map[QuorumID]*QuorumResult, signatureAggregation *SignatureAggregation) (*types.Transaction, error)

// ConfirmBatch confirms a batch header and signature aggregation. The signature aggregation must satisfy the quorum thresholds
// specified in the batch header. If the signature aggregation does not satisfy the quorum thresholds, the transaction will fail.
ConfirmBatch(ctx context.Context, batchHeader BatchHeader, quorums map[QuorumID]*QuorumResult, signatureAggregation SignatureAggregation) (*types.Receipt, error)
ConfirmBatch(ctx context.Context, batchHeader *BatchHeader, quorums map[QuorumID]*QuorumResult, signatureAggregation *SignatureAggregation) (*types.Receipt, error)

// GetBlockStaleMeasure returns the BLOCK_STALE_MEASURE defined onchain.
GetBlockStaleMeasure(ctx context.Context) (uint32, error)
Expand Down
Loading

0 comments on commit 0c9760e

Please sign in to comment.