e3: history no auto-increment (#7097)

This commit is contained in:
Alex Sharov 2023-03-15 15:03:57 +07:00 committed by GitHub
parent ec76e0c5c1
commit 157a380be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 28 additions and 19 deletions

View File

@ -1,6 +1,7 @@
package cltypes_test
import (
_ "embed"
"testing"
libcommon "github.com/ledgerwatch/erigon-lib/common"
@ -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{

View File

@ -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

View File

@ -2,6 +2,7 @@ package state
import (
"encoding/binary"
"github.com/minio/sha256-simd"
lru2 "github.com/hashicorp/golang-lru/v2"

View File

@ -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"

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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) {
@ -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
@ -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 {
@ -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
}
@ -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 {
@ -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)
}

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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"

View File

@ -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"

View File

@ -20,7 +20,6 @@ import (
"context"
"crypto/ecdsa"
"errors"
"github.com/minio/sha256-simd"
"io"
"math/rand"
"net"
@ -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"

View File

@ -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) {