-
Notifications
You must be signed in to change notification settings - Fork 72
[DONOT MERGE]: Hotfix/submitter blob hoodi 1 #794
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ import ( | |
| "github.com/morph-l2/go-ethereum" | ||
| "github.com/morph-l2/go-ethereum/accounts/abi" | ||
| "github.com/morph-l2/go-ethereum/common" | ||
| "github.com/morph-l2/go-ethereum/consensus/misc/eip4844" | ||
| "github.com/morph-l2/go-ethereum/core" | ||
| ethtypes "github.com/morph-l2/go-ethereum/core/types" | ||
| "github.com/morph-l2/go-ethereum/crypto" | ||
|
|
@@ -1279,7 +1278,9 @@ func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) { | |
| // calc blob fee cap | ||
| var blobFee *big.Int | ||
| if head.ExcessBlobGas != nil { | ||
| blobFee = eip4844.CalcBlobFee(*head.ExcessBlobGas) | ||
| log.Info("market blob fee info", "excess blob gas", *head.ExcessBlobGas) | ||
| minBlobGasPrice := big.NewInt(params.BlobTxMinBlobGasprice) | ||
| blobFee = fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(uint64(*head.ExcessBlobGas)), new(big.Int).SetUint64(5007716)) | ||
| // Set to 3x to handle blob market congestion | ||
| blobFee = new(big.Int).Mul(blobFee, big.NewInt(3)) | ||
| } | ||
|
|
@@ -1902,3 +1903,20 @@ func (r *Rollup) CancelTx(tx *ethtypes.Transaction) (*ethtypes.Transaction, erro | |
|
|
||
| return newTx, nil | ||
| } | ||
|
|
||
| // fakeExponential approximates factor * e ** (numerator / denominator) using | ||
| // Taylor expansion. | ||
| func fakeExponential(factor, numerator, denominator *big.Int) *big.Int { | ||
| var ( | ||
| output = new(big.Int) | ||
| accum = new(big.Int).Mul(factor, denominator) | ||
| ) | ||
| for i := 1; accum.Sign() > 0; i++ { | ||
| output.Add(output, accum) | ||
|
|
||
| accum.Mul(accum, numerator) | ||
| accum.Div(accum, denominator) | ||
| accum.Div(accum, big.NewInt(int64(i))) | ||
| } | ||
| return output.Div(output, denominator) | ||
| } | ||
|
Comment on lines
+1931
to
+1947
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add iteration limit to prevent potential infinite loops. The Apply this diff to add a safety limit: func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
+ const maxIterations = 100 // Safety limit for Taylor expansion
var (
output = new(big.Int)
accum = new(big.Int).Mul(factor, denominator)
)
for i := 1; accum.Sign() > 0; i++ {
+ if i > maxIterations {
+ log.Warn("fakeExponential: max iterations reached",
+ "numerator", numerator.String(),
+ "denominator", denominator.String())
+ break
+ }
output.Add(output, accum)
accum.Mul(accum, numerator)
accum.Div(accum, denominator)
accum.Div(accum, big.NewInt(int64(i)))
}
return output.Div(output, denominator)
}
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding nil and bounds validation for blob fee calculation.
The blob fee calculation lacks defensive checks:
getBlobFee(head)may return nil or zero in edge cases (though the current implementation doesn't)blobFeevalue after the 3x multiplication to prevent excessive costsApply this diff to add validation:
if head.ExcessBlobGas != nil { log.Info("market blob fee info", "excess blob gas", *head.ExcessBlobGas) blobFee = r.getBlobFee(head) + if blobFee == nil || blobFee.Sign() <= 0 { + return nil, nil, nil, fmt.Errorf("invalid blob fee calculated") + } // Set to 3x to handle blob market congestion blobFee = new(big.Int).Mul(blobFee, big.NewInt(3)) + // Consider adding max bounds check here if r.cfg.MaxBlobFee is added }Note: The aggressive 3x multiplier and missing max bounds configuration have been previously flagged in past review comments.