Skip to content

Commit

Permalink
rename config var
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Nov 1, 2023
1 parent dc159ea commit 017c4ce
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rollup/conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"try_times": 5,
"base_url": "http://localhost:8750"
},
"is_test_env": true,
"enable_test_env_bypass_features": true,
"finalize_batch_without_proof_timeout_sec": 7200,
"gas_oracle_sender_private_key": "1313131313131313131313131313131313131313131313131313131313131313",
"commit_sender_private_key": "1414141414141414141414141414141414141414141414141414141414141414",
Expand Down
6 changes: 3 additions & 3 deletions rollup/internal/config/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ type RelayerConfig struct {
CommitSenderPrivateKey *ecdsa.PrivateKey `json:"-"`
FinalizeSenderPrivateKey *ecdsa.PrivateKey `json:"-"`

// Indicates if the environment is a test environment.
IsTestEnv bool `json:"is_test_env"`
// The timeout in seconds for finalizing a batch without proof, only used in test env.
// Indicates if bypass features specific to testing environments are enabled.
EnableTestEnvBypassFeatures bool `json:"enable_test_env_bypass_features"`
// The timeout in seconds for finalizing a batch without proof, only used when EnableTestEnvBypassFeatures is true.
FinalizeBatchWithoutProofTimeoutSec uint64 `json:"finalize_batch_without_proof_timeout_sec"`
}

Expand Down
2 changes: 1 addition & 1 deletion rollup/internal/controller/relayer/l1_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewLayer1Relayer(ctx context.Context, db *gorm.DB, cfg *config.RelayerConfi
}

// Ensure test features aren't enabled on the mainnet.
if gasOracleSender.GetChainID() == big.NewInt(1) && cfg.IsTestEnv {
if gasOracleSender.GetChainID() == big.NewInt(1) && cfg.EnableTestEnvBypassFeatures {
return nil, fmt.Errorf("cannot enable test env features in mainnet")
}

Expand Down
4 changes: 2 additions & 2 deletions rollup/internal/controller/relayer/l2_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewLayer2Relayer(ctx context.Context, l2Client *ethclient.Client, db *gorm.
}

// Ensure test features aren't enabled on the mainnet.
if commitSender.GetChainID() == big.NewInt(1) && cfg.IsTestEnv {
if commitSender.GetChainID() == big.NewInt(1) && cfg.EnableTestEnvBypassFeatures {
return nil, fmt.Errorf("cannot enable test env features in mainnet")
}

Expand Down Expand Up @@ -433,7 +433,7 @@ func (r *Layer2Relayer) ProcessCommittedBatches() {
case types.ProvingTaskUnassigned, types.ProvingTaskAssigned:
now := time.Now()
elapsedTime := now.Sub(batch.CreatedAt)
if r.cfg.IsTestEnv && elapsedTime.Seconds() > float64(r.cfg.FinalizeBatchWithoutProofTimeoutSec) {
if r.cfg.EnableTestEnvBypassFeatures && elapsedTime.Seconds() > float64(r.cfg.FinalizeBatchWithoutProofTimeoutSec) {
if err := r.finalizeBatch(batch, false); err != nil {
log.Error("Failed to finalize timeout batch without proof", "index", batch.Index, "hash", batch.Hash, "err", err)
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/internal/controller/relayer/l2_relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func testL2RelayerFinalizeTimeoutBatches(t *testing.T) {
defer database.CloseDB(db)

l2Cfg := cfg.L2Config
l2Cfg.RelayerConfig.IsTestEnv = true
l2Cfg.RelayerConfig.EnableTestEnvBypassFeatures = true
l2Cfg.RelayerConfig.FinalizeBatchWithoutProofTimeoutSec = 0
relayer, err := NewLayer2Relayer(context.Background(), l2Cli, db, l2Cfg.RelayerConfig, false, nil)
assert.NoError(t, err)
Expand Down

0 comments on commit 017c4ce

Please sign in to comment.