Skip to content

Commit

Permalink
wip-elderberry validium
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Jul 22, 2024
1 parent eca9e9d commit e18eb66
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ func newTxBuilder(cfg config.Config, ethman *etherman.Client) (txbuilder.TxBuild
}
case contracts.VersionElderberry:
if cfg.Common.IsValidiumMode {
err = fmt.Errorf("Elderberry+Validium not implemented yet")
//txBuilder = txbuilder.NewTxBuilderElderberryValidium(*ethman.Contracts.Elderberry.ZkEVM, da, *auth, auth.From)
txBuilder = txbuilder.NewTxBuilderElderberryValidium(ethman.Contracts.Elderberry.Rollup, da, *auth, auth.From, cfg.SequenceSender.MaxBatchesForL1)
} else {
txBuilder = txbuilder.NewTxBuilderElderberryZKEVM(ethman.Contracts.Elderberry.Rollup, *auth, auth.From, cfg.SequenceSender.MaxTxSizeForL1)
}
Expand Down
4 changes: 4 additions & 0 deletions dataavailability/dataavailability.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ func New(backend DABackender) (*DataAvailability, error) {
func (d *DataAvailability) PostSequence(ctx context.Context, sequenceBanana etherman.SequenceBanana) ([]byte, error) {
return d.backend.PostSequence(ctx, sequenceBanana)
}

func (d *DataAvailability) PostSequenceElderberry(ctx context.Context, batchesData [][]byte) ([]byte, error) {
return d.backend.PostSequenceElderberry(ctx, batchesData)
}
3 changes: 3 additions & 0 deletions dataavailability/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type SequenceSender interface {
// PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
// as expected by the contract
PostSequence(ctx context.Context, sequence etherman.SequenceBanana) ([]byte, error)
// PostSequenceElderberry sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
// as expected by the contract
PostSequenceElderberry(ctx context.Context, batchesData [][]byte) ([]byte, error)
}

type SequenceSenderElderberry interface {
Expand Down
4 changes: 0 additions & 4 deletions sequencesender/txbuilder/elderberry_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,3 @@ func getLastSequencedBatchNumber(sequences seqsendertypes.Sequence) uint64 {
}
return sequences.FirstBatch().BatchNumber() - 1
}

func (t *TxBuilderElderberryZKEVM) String() string {
return "Elderberry/ZKEVM"
}
6 changes: 3 additions & 3 deletions sequencesender/txbuilder/elderberry_validium.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type TxBuilderElderberryValidium struct {

func NewTxBuilderElderberryValidium(zkevm contracts.RollupElderberryType,
da dataavailability.SequenceSenderElderberry,
opts bind.TransactOpts, sender common.Address, maxTxSizeForL1 uint64) *TxBuilderElderberryValidium {
opts bind.TransactOpts, sender common.Address, maxBatchesForL1 uint64) *TxBuilderElderberryValidium {
return &TxBuilderElderberryValidium{
da: da,
TxBuilderElderberryBase: *NewTxBuilderElderberryBase(
zkevm, opts,
),
condNewSeq: &NewSequenceConditionalMaxSize{
maxTxSizeForL1: maxTxSizeForL1,
condNewSeq: &NewSequenceConditionalNumBatches{
maxBatchesForL1: maxBatchesForL1,
},
}
}
Expand Down
11 changes: 4 additions & 7 deletions sequencesender/txbuilder/elderberry_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func NewTxBuilderElderberryZKEVM(zkevm contracts.RollupElderberryType, opts bind
}
}

func (t *TxBuilderElderberryZKEVM) NewSequenceIfWorthToSend(ctx context.Context, sequenceBatches []seqsendertypes.Batch, l2Coinbase common.Address, batchNumber uint64) (seqsendertypes.Sequence, error) {
return t.condNewSeq.NewSequenceIfWorthToSend(ctx, t, sequenceBatches, t.opts.From, l2Coinbase, batchNumber)
}

func (t *TxBuilderElderberryZKEVM) BuildSequenceBatchesTx(ctx context.Context, sender common.Address, sequences seqsendertypes.Sequence) (*ethtypes.Transaction, error) {

newopts := t.opts
Expand Down Expand Up @@ -77,13 +81,6 @@ func (t *TxBuilderElderberryZKEVM) warningMessage(batches []polygonvalidiumetrog
log.Warnf("Sequencer address: ", opts.From, "l2CoinBase: ", l2Coinbase, " Batches to send: %+v", batches)
}

func getLastSequencedBatchNumber(sequences seqsendertypes.Sequence) uint64 {
if sequences.Len() == 0 {
return 0
}
return sequences.FirstBatch().BatchNumber() - 1
}

func (t *TxBuilderElderberryZKEVM) String() string {
return "Elderberry/ZKEVM"
}

0 comments on commit e18eb66

Please sign in to comment.