Skip to content

Commit

Permalink
e3: history no auto-increment (#7097)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Mar 15, 2023
1 parent ec76e0c commit 157a380
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 19 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 core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package vm
import (
"encoding/binary"
"errors"
"github.com/minio/sha256-simd"
"math/big"

"github.com/minio/sha256-simd"

"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
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.18

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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230315063413-59238cf44dab h1:P8FIZDukSMLAmjAMitj59ca6jKsxHIKUt1EH9m2izgI=
github.com/ledgerwatch/erigon-lib v0.0.0-20230315063413-59238cf44dab/go.mod h1:HbqSyXJh/Xd7a5WQScXOhAOTFyCuFu7OLJQfpCsYMnc=
github.com/ledgerwatch/erigon-lib v0.0.0-20230315064748-e143f7756f24 h1:vMymvQA0ZdaHzWgsfBwRmY3plXxfFhjckF4lLSskfFU=
github.com/ledgerwatch/erigon-lib v0.0.0-20230315064748-e143f7756f24/go.mod h1:HbqSyXJh/Xd7a5WQScXOhAOTFyCuFu7OLJQfpCsYMnc=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3 h1:tfzawK1gIIgRjVZeANXOr0Ziu+kqCIBuKMe0TXfl5Aw=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og=
Expand Down
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 157a380

Please sign in to comment.