Skip to content

Commit

Permalink
e3: history no auto-increment (erigontech#7097)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored and calmbeing committed Apr 24, 2023
1 parent c60bcb8 commit ac23b2d
Show file tree
Hide file tree
Showing 12 changed files with 1,336 additions and 16 deletions.
3 changes: 1 addition & 2 deletions cl/cltypes/attestations_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cltypes_test

import (
_ "embed"
"testing"

libcommon "github.com/ledgerwatch/erigon-lib/common"
Expand All @@ -10,8 +11,6 @@ import (
"github.com/ledgerwatch/erigon/cl/cltypes"
"github.com/ledgerwatch/erigon/cl/utils"
"github.com/ledgerwatch/erigon/common"

_ "embed"
)

var testAttData = &cltypes.AttestationData{
Expand Down
3 changes: 2 additions & 1 deletion cl/utils/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
package utils

import (
"github.com/minio/sha256-simd"
"hash"
"sync"

"github.com/minio/sha256-simd"
)

type HashFunc func(data []byte, extras ...[]byte) [32]byte
Expand Down
1 change: 1 addition & 0 deletions cmd/erigon-cl/core/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package state

import (
"encoding/binary"

"github.com/minio/sha256-simd"

lru2 "github.com/hashicorp/golang-lru/v2"
Expand Down
3 changes: 2 additions & 1 deletion crypto/ecies/ecies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ import (
"encoding/hex"
"flag"
"fmt"
"github.com/minio/sha256-simd"
"math/big"
"os"
"testing"

"github.com/minio/sha256-simd"

"github.com/ledgerwatch/erigon/crypto"
)

Expand Down
3 changes: 2 additions & 1 deletion crypto/ecies/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ import (
"crypto/elliptic"
"crypto/sha512"
"fmt"
"github.com/minio/sha256-simd"
"hash"

"github.com/minio/sha256-simd"

ethcrypto "github.com/ledgerwatch/erigon/crypto"
)

Expand Down
13 changes: 7 additions & 6 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ func ExecV3(ctx context.Context,

applyWorker.ResetTx(tx)

notifyReceived := func() { rwsReceiveCond.Signal() }
var t time.Time
var lastBlockNum uint64
drainF := func(txTask *exec22.TxTask) (added int64) {
Expand Down Expand Up @@ -259,7 +258,7 @@ func ExecV3(ctx context.Context,
processedResultSize, processedTxNum, conflicts, processedBlockNum, err := func() (processedResultSize int64, processedTxNum, conflicts, processedBlockNum uint64, err error) {
rwsLock.Lock()
defer rwsLock.Unlock()
return processResultQueue(rws, outputTxNum.Load(), rs, agg, tx, triggerCount, notifyReceived, applyWorker)
return processResultQueue(rws, outputTxNum.Load(), rs, agg, tx, triggerCount, rwsReceiveCond, applyWorker)
}()
if err != nil {
return err
Expand Down Expand Up @@ -329,7 +328,7 @@ func ExecV3(ctx context.Context,
case <-pruneEvery.C:
if rs.SizeEstimate() < commitThreshold {
if agg.CanPrune(tx) {
if err = agg.Prune(ctx, ethconfig.HistoryV3AggregationStep/10); err != nil { // prune part of retired data, before commit
if err = agg.Prune(ctx, ethconfig.HistoryV3AggregationStep*10); err != nil { // prune part of retired data, before commit
return err
}
} else {
Expand Down Expand Up @@ -365,7 +364,7 @@ func ExecV3(ctx context.Context,
}
}
applyWorker.ResetTx(tx)
processedResultSize, processedTxNum, conflicts, processedBlockNum, err := processResultQueue(rws, outputTxNum.Load(), rs, agg, tx, triggerCount, func() {}, applyWorker)
processedResultSize, processedTxNum, conflicts, processedBlockNum, err := processResultQueue(rws, outputTxNum.Load(), rs, agg, tx, triggerCount, nil, applyWorker)
if err != nil {
return err
}
Expand Down Expand Up @@ -769,7 +768,7 @@ func blockWithSenders(db kv.RoDB, tx kv.Tx, blockReader services.BlockReader, bl
return b, nil
}

func processResultQueue(rws *exec22.TxTaskQueue, outputTxNumIn uint64, rs *state.StateV3, agg *state2.AggregatorV3, applyTx kv.Tx, triggerCount *atomic2.Uint64, onSuccess func(), applyWorker *exec3.Worker) (resultSize int64, outputTxNum, conflicts, processedBlockNum uint64, err error) {
func processResultQueue(rws *exec22.TxTaskQueue, outputTxNumIn uint64, rs *state.StateV3, agg *state2.AggregatorV3, applyTx kv.Tx, triggerCount *atomic2.Uint64, rwsCond *sync.Cond, applyWorker *exec3.Worker) (resultSize int64, outputTxNum, conflicts, processedBlockNum uint64, err error) {
var i int
outputTxNum = outputTxNumIn
for rws.Len() > 0 && (*rws)[0].TxNum == outputTxNum {
Expand Down Expand Up @@ -797,7 +796,9 @@ func processResultQueue(rws *exec22.TxTaskQueue, outputTxNumIn uint64, rs *state
}
triggerCount.Add(rs.CommitTxNum(txTask.Sender, txTask.TxNum))
outputTxNum++
onSuccess()
if rwsCond != nil {
rwsCond.Signal()
}
if err := rs.ApplyHistory(txTask, agg); err != nil {
return resultSize, outputTxNum, conflicts, processedBlockNum, fmt.Errorf("StateV3.Apply: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.19

require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230315063413-59238cf44dab
github.com/ledgerwatch/erigon-lib v0.0.0-20230315064748-e143f7756f24
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3
github.com/ledgerwatch/log/v3 v3.7.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
1,312 changes: 1,312 additions & 0 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion p2p/discover/v5wire/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"github.com/minio/sha256-simd"
"reflect"
"strings"
"testing"

"github.com/minio/sha256-simd"

"github.com/ledgerwatch/erigon/common/hexutil"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/p2p/enode"
Expand Down
3 changes: 2 additions & 1 deletion p2p/discover/v5wire/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/minio/sha256-simd"
"hash"

"github.com/minio/sha256-simd"

"github.com/ledgerwatch/erigon/common/mclock"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/p2p/enr"
Expand Down
3 changes: 2 additions & 1 deletion p2p/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"crypto/ecdsa"
"errors"
"github.com/minio/sha256-simd"
"io"
"math/rand"
"net"
Expand All @@ -29,6 +28,8 @@ import (
"testing"
"time"

"github.com/minio/sha256-simd"

"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/p2p/enr"
Expand Down
3 changes: 2 additions & 1 deletion turbo/trie/vtree/verkle_utils_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package vtree

import (
"github.com/minio/sha256-simd"
"math/big"
"math/rand"
"testing"

"github.com/minio/sha256-simd"
)

func BenchmarkPedersenHash(b *testing.B) {
Expand Down

0 comments on commit ac23b2d

Please sign in to comment.