Skip to content

Commit 951c649

Browse files
committed
Temp removal of encoding package
1 parent ef17a69 commit 951c649

File tree

2 files changed

+39
-44
lines changed

2 files changed

+39
-44
lines changed

rollup/fees/rollup_fee.go

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import (
77
"math/big"
88

99
"github.com/holiman/uint256"
10-
"github.com/scroll-tech/da-codec/encoding"
11-
1210
"github.com/scroll-tech/go-ethereum/common"
1311
"github.com/scroll-tech/go-ethereum/core/types"
1412
"github.com/scroll-tech/go-ethereum/crypto"
15-
"github.com/scroll-tech/go-ethereum/log"
1613
"github.com/scroll-tech/go-ethereum/params"
1714
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
1815
)
@@ -178,36 +175,36 @@ func readGPOStorageSlots(addr common.Address, state StateDB) gpoState {
178175
// compression_ratio(tx) = size(tx) * PRECISION / size(zstd(tx))
179176
func estimateTxCompressionRatio(data []byte, blockNumber uint64, blockTime uint64, config *params.ChainConfig) (*big.Int, error) {
180177
// By definition, the compression ratio of empty data is infinity
181-
if len(data) == 0 {
182-
return U256MAX, nil
183-
}
184-
185-
// Compress data using da-codec
186-
compressed, err := encoding.CompressScrollBatchBytes(data, blockNumber, blockTime, config)
187-
if err != nil {
188-
log.Error("Batch compression failed, using 1.0 compression ratio", "error", err, "data size", len(data), "data", common.Bytes2Hex(data))
189-
return nil, fmt.Errorf("batch compression failed: %w", err)
190-
}
191-
192-
if len(compressed) == 0 {
193-
log.Error("Compressed data is empty, using 1.0 compression ratio", "data size", len(data), "data", common.Bytes2Hex(data))
194-
return nil, fmt.Errorf("compressed data is empty")
195-
}
196-
197-
// Make sure compression ratio >= 1 by checking if compressed data is bigger or equal to original data
198-
// This behavior is consistent with DA Batch compression in codecv7 and later versions
199-
if len(compressed) >= len(data) {
200-
return rcfg.Precision, nil
201-
}
202-
203-
// compression_ratio = size(tx) * PRECISION / size(zstd(tx))
204-
originalSize := new(big.Int).SetUint64(uint64(len(data)))
205-
compressedSize := new(big.Int).SetUint64(uint64(len(compressed)))
206-
207-
ratio := new(big.Int).Mul(originalSize, rcfg.Precision)
208-
ratio.Div(ratio, compressedSize)
209-
210-
return ratio, nil
178+
//if len(data) == 0 {
179+
return U256MAX, nil
180+
//}
181+
182+
//// Compress data using da-codec
183+
//compressed, err := encoding.CompressScrollBatchBytes(data, blockNumber, blockTime, config)
184+
//if err != nil {
185+
// log.Error("Batch compression failed, using 1.0 compression ratio", "error", err, "data size", len(data), "data", common.Bytes2Hex(data))
186+
// return nil, fmt.Errorf("batch compression failed: %w", err)
187+
//}
188+
//
189+
//if len(compressed) == 0 {
190+
// log.Error("Compressed data is empty, using 1.0 compression ratio", "data size", len(data), "data", common.Bytes2Hex(data))
191+
// return nil, fmt.Errorf("compressed data is empty")
192+
//}
193+
//
194+
//// Make sure compression ratio >= 1 by checking if compressed data is bigger or equal to original data
195+
//// This behavior is consistent with DA Batch compression in codecv7 and later versions
196+
//if len(compressed) >= len(data) {
197+
// return rcfg.Precision, nil
198+
//}
199+
//
200+
//// compression_ratio = size(tx) * PRECISION / size(zstd(tx))
201+
//originalSize := new(big.Int).SetUint64(uint64(len(data)))
202+
//compressedSize := new(big.Int).SetUint64(uint64(len(compressed)))
203+
//
204+
//ratio := new(big.Int).Mul(originalSize, rcfg.Precision)
205+
//ratio.Div(ratio, compressedSize)
206+
//
207+
//return ratio, nil
211208
}
212209

213210
// calculatePenalty computes the penalty multiplier based on compression ratio

rollup/l1/reader.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"fmt"
77
"math/big"
88

9-
"github.com/scroll-tech/da-codec/encoding"
10-
119
"github.com/scroll-tech/go-ethereum"
1210
"github.com/scroll-tech/go-ethereum/accounts/abi"
1311
"github.com/scroll-tech/go-ethereum/common"
@@ -427,19 +425,19 @@ func (r *Reader) FetchCommitTxData(commitEvent *CommitBatchEvent) (*CommitBatchA
427425

428426
// in commitAndFinalizeBatch, the last batch hash is encoded in the finalize struct as this is the only batch we're
429427
// committing when calling this function.
430-
codec, err := encoding.CodecFromVersion(encoding.CodecVersion(commitAndFinalizeArgs.Version))
431-
if err != nil {
432-
return nil, fmt.Errorf("failed to get codec from version %d, err: %w", commitAndFinalizeArgs.Version, err)
433-
}
434-
daBatch, err := codec.NewDABatchFromBytes(commitAndFinalizeArgs.FinalizeStruct.BatchHeader)
435-
if err != nil {
436-
return nil, fmt.Errorf("failed to decode daBatch from bytes, err: %w", err)
437-
}
428+
//codec, err := encoding.CodecFromVersion(encoding.CodecVersion(commitAndFinalizeArgs.Version))
429+
//if err != nil {
430+
// return nil, fmt.Errorf("failed to get codec from version %d, err: %w", commitAndFinalizeArgs.Version, err)
431+
//}
432+
//daBatch, err := codec.NewDABatchFromBytes(commitAndFinalizeArgs.FinalizeStruct.BatchHeader)
433+
//if err != nil {
434+
// return nil, fmt.Errorf("failed to decode daBatch from bytes, err: %w", err)
435+
//}
438436

439437
args = &CommitBatchArgs{
440438
Version: commitAndFinalizeArgs.Version,
441439
ParentBatchHash: commitAndFinalizeArgs.ParentBatchHash,
442-
LastBatchHash: daBatch.Hash(),
440+
//LastBatchHash: daBatch.Hash(),
443441
}
444442
} else {
445443
return nil, fmt.Errorf("unknown method name for commit transaction: %s", method.Name)

0 commit comments

Comments
 (0)