Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optim submitter #570

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tx-submitter/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Main() func(ctx *cli.Context) error {
"rough_estimate_gas", cfg.RoughEstimateGas,
"rough_estimate_base_gas", cfg.RollupTxGasBase,
"rough_estimate_per_l1_msg", cfg.RollupTxGasPerL1Msg,
"log_level", cfg.LogLevel,
)

ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -206,7 +207,7 @@ func Main() func(ctx *cli.Context) error {
rotator,
)
// init rollup service
if err := sr.Init(); err != nil {
if err := sr.PreCheck(); err != nil {
return err
}
// metrics
Expand Down
2 changes: 1 addition & 1 deletion tx-submitter/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ var (
ExternalSignRsaPriv = cli.StringFlag{
Name: "external_rsa_priv",
Usage: "The rsa private key of the external sign",
EnvVar: prefixEnvVar("EXTERNAL_RSA_PRIV"),
EnvVar: prefixEnvVar("EXTERNAL_SIGN_RSA_PRIV"),
}
RoughEstimateGasFlag = cli.BoolFlag{
Name: "rough_estimate_gas",
Expand Down
1 change: 1 addition & 0 deletions tx-submitter/iface/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ type IL1Staking interface {
IsStaker(opts *bind.CallOpts, addr common.Address) (bool, error)
GetStakersBitmap(opts *bind.CallOpts, _stakers []common.Address) (*big.Int, error)
GetActiveStakers(opts *bind.CallOpts) ([]common.Address, error)
GetStakers(opts *bind.CallOpts) ([255]common.Address, error)
}
47 changes: 34 additions & 13 deletions tx-submitter/services/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,12 @@ func (r *Rollup) buildSignatureInput(batch *eth.RPCRollupBatch) (*bindings.IRoll
return &sigData, nil
}

func (sr *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) {
tip, err := sr.L1Client.SuggestGasTipCap(context.Background())
func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) {
tip, err := r.L1Client.SuggestGasTipCap(context.Background())
if err != nil {
return nil, nil, nil, err
}
head, err := sr.L1Client.HeaderByNumber(context.Background(), nil)
head, err := r.L1Client.HeaderByNumber(context.Background(), nil)
if err != nil {
return nil, nil, nil, err
}
Expand All @@ -812,22 +812,43 @@ func (sr *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) {
}

//calldata fee bump x*fee/100
if sr.cfg.CalldataFeeBump > 0 {
if r.cfg.CalldataFeeBump > 0 {
// feecap
gasFeeCap = new(big.Int).Mul(gasFeeCap, big.NewInt(int64(sr.cfg.CalldataFeeBump)))
gasFeeCap = new(big.Int).Mul(gasFeeCap, big.NewInt(int64(r.cfg.CalldataFeeBump)))
gasFeeCap = new(big.Int).Div(gasFeeCap, big.NewInt(100))
// tip
tip = new(big.Int).Mul(tip, big.NewInt(int64(sr.cfg.CalldataFeeBump)))
tip = new(big.Int).Mul(tip, big.NewInt(int64(r.cfg.CalldataFeeBump)))
tip = new(big.Int).Div(tip, big.NewInt(100))
}

return tip, gasFeeCap, blobFee, nil
}

// Init is run before the submitter to check whether the submitter can be started
func (sr *Rollup) Init() error {
// PreCheck is run before the submitter to check whether the submitter can be started
func (r *Rollup) PreCheck() error {

isStaker, err := sr.IsStaker()
// debug stakers
stakers, err := r.Staking.GetStakers(nil)
if err != nil {
log.Debug("get stakers error", "err", err)
} else {
log.Debug("stakers", "len", len(stakers))
for _, s := range stakers {
log.Debug("staker", "addr", s.Hex())
}
}
// debug active stakers
activeStakers, err := r.Staking.GetActiveStakers(nil)
if err != nil {
log.Debug("get active stakers error", "err", err)
} else {
log.Debug("active stakers", "len", len(activeStakers))
for _, s := range activeStakers {
log.Debug("active staker", "addr", s.Hex())
}
}

isStaker, err := r.IsStaker()
if err != nil {
return fmt.Errorf("check if this account is sequencer error:%v", err)
}
Expand All @@ -839,12 +860,12 @@ func (sr *Rollup) Init() error {
return nil
}

func (sr *Rollup) WalletAddr() common.Address {
func (r *Rollup) WalletAddr() common.Address {

if sr.cfg.ExternalSign {
return common.HexToAddress(sr.cfg.ExternalSignAddress)
if r.cfg.ExternalSign {
return common.HexToAddress(r.cfg.ExternalSignAddress)
} else {
return crypto.PubkeyToAddress(sr.privKey.PublicKey)
return crypto.PubkeyToAddress(r.privKey.PublicKey)
}

}
Expand Down
Loading