Skip to content

Commit

Permalink
fix config name
Browse files Browse the repository at this point in the history
  • Loading branch information
zjg555543 committed Oct 18, 2023
1 parent ea4769a commit 6d6f13c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ LastBatchVirtualizationTimeMaxWaitPeriod = "5s"
MaxTxSizeForL1 = 1000
L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
UseValidium = true
[Aggregator]
Host = "0.0.0.0"
Expand Down
4 changes: 0 additions & 4 deletions etherman/datacommittee.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,3 @@ func (etherMan *Client) GetCurrentDataCommitteeMembers() ([]DataCommitteeMember,
}
return members, nil
}

func (etherMan *Client) GetConfigUseValidium() bool {
return etherMan.UseValidium
}
6 changes: 1 addition & 5 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ type L1Config struct {
GlobalExitRootManagerAddr common.Address `json:"polygonZkEVMGlobalExitRootAddress"`
// Address of the data availability committee contract
DataCommitteeAddr common.Address `json:"dataCommitteeContract"`

UseValidium bool `mapstructure:"useValidium"`
}

type externalGasProviders struct {
Expand All @@ -145,7 +143,6 @@ type Client struct {
GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
Matic *matic.Matic
DataCommittee *datacommittee.Datacommittee
UseValidium bool
SCAddresses []common.Address

GasProviders externalGasProviders
Expand Down Expand Up @@ -203,7 +200,6 @@ func NewClient(cfg Config, l1Config L1Config) (*Client, error) {
Matic: matic,
GlobalExitRootManager: globalExitRoot,
DataCommittee: dataCommittee,
UseValidium: l1Config.UseValidium,
SCAddresses: scAddresses,
GasProviders: externalGasProviders{
MultiGasProvider: cfg.MultiGasProvider,
Expand Down Expand Up @@ -562,7 +558,7 @@ func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethm

var tx *types.Transaction
var err error
if etherMan.UseValidium && len(committeeSignaturesAndAddrs) > 0 {
if len(committeeSignaturesAndAddrs) > 0 {
for _, seq := range sequences {
batch := polygonzkevm.PolygonZkEVMBatchData{
TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data),
Expand Down
8 changes: 4 additions & 4 deletions etherman/etherman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ func TestSequencedBatchesEvent(t *testing.T) {
GlobalExitRoot: ger,
Timestamp: currentBlock.Time(),
MinForcedTimestamp: uint64(blocks[2].ForcedBatches[0].ForcedAt.Unix()),
Transactions: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
})
sequences = append(sequences, polygonzkevm.PolygonZkEVMBatchData{
GlobalExitRoot: ger,
Timestamp: currentBlock.Time() + 1,
MinForcedTimestamp: 0,
Transactions: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
})
_, err = etherman.ZkEVM.SequenceBatches(auth, sequences, auth.From, []byte{})
require.NoError(t, err)
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestVerifyBatchEvent(t *testing.T) {
GlobalExitRoot: common.Hash{},
Timestamp: initBlock.Time(),
MinForcedTimestamp: 0,
Transactions: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
}
_, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonZkEVMBatchData{tx}, auth.From, []byte{})
require.NoError(t, err)
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestSendSequences(t *testing.T) {
Timestamp: int64(currentBlock.Time() - 1),
BatchL2Data: batchL2Data,
}
tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, auth.From)
tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, auth.From, nil)
require.NoError(t, err)
log.Debug("TX: ", tx.Hash())
ethBackend.Commit()
Expand Down
3 changes: 3 additions & 0 deletions sequencesender/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ type Config struct {
PrivateKey types.KeystoreFileConfig `mapstructure:"PrivateKey"`
// Batch number where there is a forkid change (fork upgrade)
ForkUpgradeBatchNumber uint64

// UseValidium is a flag to enable/disable the use of validium
UseValidium bool `mapstructure:"UseValidium"`
}
1 change: 0 additions & 1 deletion sequencesender/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type etherman interface {
GetLatestBlockTimestamp(ctx context.Context) (uint64, error)
GetLatestBatchNumber() (uint64, error)
GetCurrentDataCommittee() (*theEtherman.DataCommittee, error)
GetConfigUseValidium() bool
}

// stateInterface gathers the methods required to interact with the state.
Expand Down
6 changes: 5 additions & 1 deletion sequencesender/sequencesender.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context, ticker *time.Tic
waitTick(ctx, ticker)
return
}
if !s.isValidium() {
signaturesAndAddrs = nil
}

to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, s.cfg.L2Coinbase, signaturesAndAddrs)
if err != nil {
log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
Expand Down Expand Up @@ -323,7 +327,7 @@ func isDataForEthTxTooBig(err error) bool {
}

func (s *SequenceSender) isValidium() bool {
if !s.etherman.GetConfigUseValidium() {
if !s.cfg.UseValidium {
return false
}

Expand Down

0 comments on commit 6d6f13c

Please sign in to comment.