Skip to content

Commit

Permalink
refactored sequencer and fix aggr cfg value (0xPolygonHermez#1079)
Browse files Browse the repository at this point in the history
* refactored sequencer and fix aggr cfg value

* fixed lint err
  • Loading branch information
Mikelle authored Aug 24, 2022
1 parent d386586 commit 14846a8
Show file tree
Hide file tree
Showing 17 changed files with 366 additions and 271 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ generate-mocks: ## Generates mocks for the tests, using mockery tool
mockery --name=stateInterface --dir=jsonrpc --output=jsonrpc --outpkg=jsonrpc --inpackage --structname=stateMock --filename=mock_state_test.go
mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=jsonrpc --outpkg=jsonrpc --structname=dbTxMock --filename=mock_dbtx_test.go

mockery --name=txManager --dir=sequencer --output=sequencer --outpkg=sequencer --structname=txmanagerMock --filename=txmanager-mock_test.go
mockery --name=etherman --dir=sequencer --output=sequencer --outpkg=sequencer --structname=ethermanMock --filename=etherman-mock_test.go
mockery --name=etherman --dir=sequencer/profitabilitychecker --output=sequencer/profitabilitychecker --outpkg=profitabilitychecker_test --structname=ethermanMock --filename=etherman-mock_test.go
mockery --name=stateInterface --dir=sequencer/broadcast --output=sequencer/broadcast --outpkg=broadcast_test --structname=stateMock --filename=state-mock_test.go
mockery --name=txManager --dir=sequencer --output=sequencer/mocks --outpkg=mocks --structname=TxmanagerMock --filename=mock_txmanager.go
mockery --name=etherman --dir=sequencer --output=sequencer/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go
mockery --name=etherman --dir=sequencer/profitabilitychecker --output=sequencer/profitabilitychecker/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go
mockery --name=stateInterface --dir=sequencer/broadcast --output=sequencer/broadcast/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go

mockery --name=ethermanInterface --dir=synchronizer --output=synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go
mockery --name=stateInterface --dir=synchronizer --output=synchronizer --outpkg=synchronizer --structname=stateMock --filename=mock_state.go
Expand Down
2 changes: 1 addition & 1 deletion aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewAggregator(
State: state,
EthTxManager: ethTxManager,
Ethman: etherman,
ProverClient: prover.NewClient(zkProverClient),
ProverClient: prover.NewClient(zkProverClient, cfg.IntervalFrequencyToGetProofGenerationState),
ProfitabilityChecker: profitabilityChecker,
}

Expand Down
2 changes: 1 addition & 1 deletion aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Config struct {

// IntervalFrequencyToGetProofGenerationStateInSeconds is the time the aggregator waits until
// trying to get proof generation status, in case prover client returns PENDING state
IntervalFrequencyToGetProofGenerationStateInSeconds types.Duration `mapstructure:"IntervalFrequencyToGetProofGenerationStateInSeconds"`
IntervalFrequencyToGetProofGenerationState types.Duration `mapstructure:"IntervalFrequencyToGetProofGenerationState"`

// TxProfitabilityCheckerType type for checking is it profitable for aggregator to validate batch
// possible values: base/acceptall
Expand Down
13 changes: 8 additions & 5 deletions aggregator/prover/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import (

// Client wrapper for the zkprover client
type Client struct {
ZkProverClient pb.ZKProverServiceClient
IntervalFrequencyToGetProofGenerationStateInSeconds types.Duration
ZkProverClient pb.ZKProverServiceClient
IntervalFrequencyToGetProofGenerationState types.Duration
}

// NewClient inits zkprover wrapper client
func NewClient(pc pb.ZKProverServiceClient) *Client {
return &Client{ZkProverClient: pc}
func NewClient(pc pb.ZKProverServiceClient, intervalFrequencyToGetProofGenerationState types.Duration) *Client {
return &Client{
ZkProverClient: pc,
IntervalFrequencyToGetProofGenerationState: intervalFrequencyToGetProofGenerationState,
}
}

// GetGenProofID get id of generation proof request
Expand Down Expand Up @@ -80,7 +83,7 @@ func (c *Client) GetResGetProof(ctx context.Context, genProofID string, batchNum

if resGetProofState == pb.GetProofResponse_RESULT_GET_PROOF_PENDING {
// in this case aggregator will wait, to send another request
time.Sleep(c.IntervalFrequencyToGetProofGenerationStateInSeconds.Duration)
time.Sleep(c.IntervalFrequencyToGetProofGenerationState.Duration)
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.debug.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MaxSteps = 8388608

[Aggregator]
IntervalToConsolidateState = "10s"
IntervalFrequencyToGetProofGenerationStateInSeconds = "5s"
IntervalFrequencyToGetProofGenerationState = "5s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"

Expand Down
2 changes: 1 addition & 1 deletion config/config.local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MaxSteps = 8388608

[Aggregator]
IntervalToConsolidateState = "10s"
IntervalFrequencyToGetProofGenerationStateInSeconds = "5s"
IntervalFrequencyToGetProofGenerationState = "5s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"

Expand Down
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Type = "default"
DefaultPrice = "2000"
[Aggregator]
IntervalFrequencyToGetProofGenerationStateInSeconds = "5s"
IntervalFrequencyToGetProofGenerationState = "5s"
IntervalToConsolidateState = "3s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"
Expand Down
Loading

0 comments on commit 14846a8

Please sign in to comment.