Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge crypto into erigon-lib/crypto #12515

Merged
merged 8 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move crypto/cryptopool into erigon-lib
  • Loading branch information
yperbasis committed Oct 28, 2024
commit 66ee3a05755d778b3741d41b6ea33922ffb19a7d
5 changes: 2 additions & 3 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ import (
"github.com/goccy/go-json"
lru "github.com/hashicorp/golang-lru/arc/v2"

"github.com/erigontech/erigon/turbo/services"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/dbutils"
"github.com/erigontech/erigon-lib/log/v3"
Expand All @@ -51,10 +50,10 @@ import (
"github.com/erigontech/erigon/core/types/accounts"
"github.com/erigontech/erigon/core/vm/evmtypes"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/params"
"github.com/erigontech/erigon/rlp"
"github.com/erigontech/erigon/rpc"
"github.com/erigontech/erigon/turbo/services"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion core/snaptype/block_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import (
"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/background"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/downloader/snaptype"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon-lib/recsplit"
"github.com/erigontech/erigon-lib/seg"
types2 "github.com/erigontech/erigon-lib/types"

"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
)

Expand Down
2 changes: 1 addition & 1 deletion core/types/bloom9.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"unsafe"

"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
)

type bytesBacked interface {
Expand Down
5 changes: 3 additions & 2 deletions core/types/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"fmt"
"io"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/protolambda/ztyp/codec"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
"github.com/erigontech/erigon/turbo/rlphacks"
"github.com/erigontech/erigon/turbo/trie"
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import (

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
)

Expand Down
38 changes: 0 additions & 38 deletions crypto/cryptopool/buf_pool.go

This file was deleted.

4 changes: 2 additions & 2 deletions erigon-lib/common/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func (a *Address) checksumHex() []byte {
buf := a.hex()

// compute checksum
sha := cryptopool.GetLegacyKeccak256()
sha := cryptopool.NewLegacyKeccak256()
//nolint:errcheck
sha.Write(buf[2:])
hash := sha.Sum(nil)
cryptopool.ReturnLegacyKeccak256(sha)
cryptopool.ReturnToPoolKeccak256(sha)

for i := 2; i < len(buf); i++ {
hashByte := hash[(i-2)/2]
Expand Down
5 changes: 3 additions & 2 deletions erigon-lib/crypto/cryptopool/buf_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import (
"golang.org/x/crypto/sha3"
)

// pool holds LegacyKeccak hashers.
var pool = sync.Pool{
New: func() interface{} {
return sha3.NewLegacyKeccak256()
},
}

func GetLegacyKeccak256() hash.Hash {
func NewLegacyKeccak256() hash.Hash {
h := pool.Get().(hash.Hash)
h.Reset()
return h
}
func ReturnLegacyKeccak256(h hash.Hash) { pool.Put(h) }
func ReturnToPoolKeccak256(h hash.Hash) { pool.Put(h) }
3 changes: 2 additions & 1 deletion polygon/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ import (
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/common/length"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/misc"
"github.com/erigontech/erigon/core/rawdb"
Expand All @@ -53,7 +55,6 @@ import (
"github.com/erigontech/erigon/core/types/accounts"
"github.com/erigontech/erigon/core/vm/evmtypes"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/eth/ethconfig/estimate"
"github.com/erigontech/erigon/params"
"github.com/erigontech/erigon/polygon/bor/borcfg"
Expand Down
3 changes: 2 additions & 1 deletion turbo/jsonrpc/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ import (
"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/rawdbv3"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/core"
"github.com/erigontech/erigon/core/rawdb"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/core/vm"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/polygon/bor/borcfg"
bortypes "github.com/erigontech/erigon/polygon/bor/types"
"github.com/erigontech/erigon/rpc"
Expand Down