Skip to content

Commit e91e0db

Browse files
authored
chore: use ethereum ec lib instead of btc (#59)
1 parent cbab1df commit e91e0db

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/base/base-bench
33
go 1.22.8
44

55
require (
6-
github.com/btcsuite/btcd/btcec/v2 v2.3.4
76
github.com/ethereum-optimism/optimism v1.12.2
87
github.com/ethereum/go-ethereum v1.15.3
98
github.com/go-yaml/yaml v2.1.0+incompatible

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
1717
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
1818
github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3MdfoPyRVU=
1919
github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
20-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
21-
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
2220
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
2321
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
2422
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=

runner/payload/contract_worker.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/base/base-bench/runner/benchmark"
1111
"github.com/base/base-bench/runner/network/mempool"
12-
"github.com/btcsuite/btcd/btcec/v2"
1312
"github.com/ethereum-optimism/optimism/op-service/retry"
1413
"github.com/ethereum/go-ethereum/accounts/abi"
1514
"github.com/ethereum/go-ethereum/common"
@@ -56,15 +55,18 @@ func NewContractPayloadWorker(log log.Logger, elRPCURL string, params benchmark.
5655
}
5756

5857
chainID := params.Genesis(time.Now()).Config.ChainID
59-
priv, _ := btcec.PrivKeyFromBytes(prefundedPrivateKey)
58+
priv, err := crypto.ToECDSA(prefundedPrivateKey)
59+
if err != nil {
60+
return nil, nil, fmt.Errorf("failed to convert private key: %w", err)
61+
}
6062

6163
t := &ContractPayloadWorker{
6264
log: log,
6365
client: client,
6466
mempool: mempool,
6567
params: params,
6668
chainID: chainID,
67-
prefundedAccount: priv.ToECDSA(),
69+
prefundedAccount: priv,
6870
prefundAmount: prefundAmount,
6971
ContractPayloadWorkerConfig: config,
7072
}

runner/payload/worker.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package payload
33
import (
44
"context"
55
"crypto/ecdsa"
6+
"fmt"
67
"math/big"
78
"time"
89

910
"math/rand"
1011

1112
"github.com/base/base-bench/runner/benchmark"
1213
"github.com/base/base-bench/runner/network/mempool"
13-
"github.com/btcsuite/btcd/btcec/v2"
1414
"github.com/ethereum-optimism/optimism/op-service/retry"
1515
"github.com/ethereum/go-ethereum/common"
1616
"github.com/ethereum/go-ethereum/core/types"
@@ -59,15 +59,18 @@ func NewTransferPayloadWorker(log log.Logger, elRPCURL string, params benchmark.
5959
}
6060

6161
chainID := params.Genesis(time.Now()).Config.ChainID
62-
priv, _ := btcec.PrivKeyFromBytes(prefundedPrivateKey)
62+
priv, err := crypto.ToECDSA(prefundedPrivateKey)
63+
if err != nil {
64+
return nil, nil, fmt.Errorf("failed to convert private key: %w", err)
65+
}
6366

6467
t := &TransferOnlyPayloadWorker{
6568
log: log,
6669
client: client,
6770
mempool: mempool,
6871
params: params,
6972
chainID: chainID,
70-
prefundedAccount: priv.ToECDSA(),
73+
prefundedAccount: priv,
7174
prefundAmount: prefundAmount,
7275
}
7376

@@ -86,7 +89,7 @@ func (t *TransferOnlyPayloadWorker) generateAccounts() error {
8689

8790
src := rand.New(rand.NewSource(100))
8891
for i := 0; i < numAccounts; i++ {
89-
key, err := ecdsa.GenerateKey(btcec.S256(), src)
92+
key, err := ecdsa.GenerateKey(crypto.S256(), src)
9093
if err != nil {
9194
return err
9295
}

0 commit comments

Comments
 (0)