Skip to content

Commit 6faec7e

Browse files
remove blocks compression (#1453)
1 parent c35b07d commit 6faec7e

File tree

3 files changed

+3
-42
lines changed

3 files changed

+3
-42
lines changed

common/debug/experiments.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import (
66
"sync/atomic"
77
)
88

9-
var (
10-
compressBlocks bool
11-
getCompressBlocks sync.Once
12-
)
13-
149
// atomic: bit 0 is the value, bit 1 is the initialized flag
1510
var getNodeData uint32
1611

@@ -47,13 +42,6 @@ func OverrideGetNodeData(val bool) {
4742
}
4843
}
4944

50-
func IsBlockCompressionEnabled() bool {
51-
getCompressBlocks.Do(func() {
52-
_, compressBlocks = os.LookupEnv("COMPRESS_BLOCKS")
53-
})
54-
return compressBlocks
55-
}
56-
5745
var (
5846
testDB string
5947
getTestDB sync.Once

core/rawdb/accessors_chain.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@ import (
2424
"fmt"
2525
"math/big"
2626

27-
"github.com/ledgerwatch/turbo-geth/ethdb"
28-
"github.com/ledgerwatch/turbo-geth/ethdb/cbor"
29-
3027
"github.com/ledgerwatch/turbo-geth/common"
3128
"github.com/ledgerwatch/turbo-geth/common/dbutils"
32-
"github.com/ledgerwatch/turbo-geth/common/debug"
3329
"github.com/ledgerwatch/turbo-geth/core/types"
30+
"github.com/ledgerwatch/turbo-geth/ethdb"
31+
"github.com/ledgerwatch/turbo-geth/ethdb/cbor"
3432
"github.com/ledgerwatch/turbo-geth/log"
3533
"github.com/ledgerwatch/turbo-geth/rlp"
36-
37-
"github.com/golang/snappy"
3834
)
3935

4036
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
@@ -334,9 +330,6 @@ func WriteTransactions(db ethdb.Database, txs []*types.Transaction, baseTxId uin
334330

335331
// WriteBodyRLP stores an RLP encoded block body into the database.
336332
func WriteBodyRLP(db DatabaseWriter, hash common.Hash, number uint64, rlp rlp.RawValue) {
337-
if debug.IsBlockCompressionEnabled() {
338-
rlp = snappy.Encode(nil, rlp)
339-
}
340333
if err := db.Put(dbutils.BlockBodyPrefix, dbutils.BlockBodyKey(number, hash), rlp); err != nil {
341334
log.Crit("Failed to store block body", "err", err)
342335
}

migrations/transactions.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66
"fmt"
77
"time"
88

9-
"github.com/golang/snappy"
109
"github.com/ledgerwatch/turbo-geth/common/dbutils"
11-
"github.com/ledgerwatch/turbo-geth/common/debug"
1210
"github.com/ledgerwatch/turbo-geth/common/etl"
1311
"github.com/ledgerwatch/turbo-geth/core/types"
1412
"github.com/ledgerwatch/turbo-geth/ethdb"
@@ -23,18 +21,6 @@ var transactionsTable = Migration{
2321
defer logEvery.Stop()
2422
logPrefix := "tx_table"
2523

26-
decompressBlockBody := func(compressed []byte) ([]byte, error) {
27-
if !debug.IsBlockCompressionEnabled() || len(compressed) == 0 {
28-
return compressed, nil
29-
}
30-
31-
var bodyRlp []byte
32-
bodyRlp, err = snappy.Decode(nil, compressed)
33-
if err != nil {
34-
return nil, fmt.Errorf("err on decode block: %w", err)
35-
}
36-
return bodyRlp, nil
37-
}
3824
const loadStep = "load"
3925
reader := bytes.NewReader(nil)
4026
buf := bytes.NewBuffer(make([]byte, 4096))
@@ -102,13 +88,7 @@ var transactionsTable = Migration{
10288
}
10389
// don't need canonical check
10490

105-
var bodyRlp []byte
106-
bodyRlp, err = decompressBlockBody(v)
107-
if err != nil {
108-
return false, err
109-
}
110-
111-
reader.Reset(bodyRlp)
91+
reader.Reset(v)
11292
if err = rlp.Decode(reader, body); err != nil {
11393
return false, fmt.Errorf("[%s]: invalid block body RLP: %w", logPrefix, err)
11494
}

0 commit comments

Comments
 (0)