Skip to content

Commit d27e04e

Browse files
chore: update go-ethereum (#2342)
1 parent c07b816 commit d27e04e

File tree

11 files changed

+319
-114
lines changed

11 files changed

+319
-114
lines changed

go.mod

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ go 1.15
55
require (
66
github.com/btcsuite/btcd v0.22.0-beta
77
github.com/coreos/go-semver v0.3.0
8-
github.com/ethereum/go-ethereum v1.9.23
8+
github.com/ethereum/go-ethereum v1.10.3
99
github.com/ethersphere/go-price-oracle-abi v0.1.0
1010
github.com/ethersphere/go-storage-incentives-abi v0.3.0
1111
github.com/ethersphere/go-sw3-abi v0.4.0
1212
github.com/ethersphere/langos v1.0.0
1313
github.com/gogo/protobuf v1.3.2
14-
github.com/golang/protobuf v1.5.2 // indirect
1514
github.com/google/go-cmp v0.5.5
16-
github.com/google/uuid v1.1.4 // indirect
1715
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
1816
github.com/gorilla/handlers v1.4.2
1917
github.com/gorilla/mux v1.7.4
@@ -25,7 +23,6 @@ require (
2523
github.com/kardianos/service v1.2.0
2624
github.com/klauspost/cpuid/v2 v2.0.8 // indirect
2725
github.com/koron/go-ssdp v0.0.2 // indirect
28-
github.com/kr/text v0.2.0 // indirect
2926
github.com/libp2p/go-libp2p v0.14.3
3027
github.com/libp2p/go-libp2p-autonat v0.4.2
3128
github.com/libp2p/go-libp2p-core v0.8.5
@@ -55,11 +52,11 @@ require (
5552
github.com/spf13/jwalterweatherman v1.1.0 // indirect
5653
github.com/spf13/pflag v1.0.5 // indirect
5754
github.com/spf13/viper v1.7.0
58-
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
55+
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
5956
github.com/uber/jaeger-client-go v2.24.0+incompatible
6057
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
6158
github.com/vmihailenco/msgpack/v5 v5.3.4
62-
github.com/wealdtech/go-ens/v3 v3.4.4
59+
github.com/wealdtech/go-ens/v3 v3.4.6
6360
gitlab.com/nolash/go-mockbytes v0.0.7
6461
go.uber.org/atomic v1.8.0
6562
go.uber.org/multierr v1.7.0 // indirect
@@ -69,7 +66,7 @@ require (
6966
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
7067
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
7168
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
72-
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
69+
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
7370
google.golang.org/protobuf v1.27.1 // indirect
7471
gopkg.in/ini.v1 v1.57.0 // indirect
7572
gopkg.in/yaml.v2 v2.4.0

go.sum

+136-104
Large diffs are not rendered by default.

pkg/node/node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
352352

353353
lightNodes := lightnode.NewContainer(swarmAddress)
354354

355-
senderMatcher := transaction.NewMatcher(swapBackend, types.NewEIP155Signer(big.NewInt(chainID)), stateStore)
355+
senderMatcher := transaction.NewMatcher(swapBackend, types.NewEIP2930Signer(big.NewInt(chainID)), stateStore)
356356

357357
p2ps, err := libp2p.New(p2pCtx, signer, networkID, swarmAddress, addr, addressbook, stateStore, lightNodes, senderMatcher, logger, tracer, libp2p.Options{
358358
PrivateKey: libp2pPrivateKey,

pkg/settlement/swap/addressbook.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func peerKey(peer swarm.Address) string {
198198

199199
// chequebookPeerKey computes the key where to store the peer for a chequebook.
200200
func chequebookPeerKey(chequebook common.Address) string {
201-
return fmt.Sprintf("%s%s", peerChequebookPrefix, chequebook)
201+
return fmt.Sprintf("%s%x", peerChequebookPrefix, chequebook)
202202
}
203203

204204
// peerBeneficiaryKey computes the key where to store the beneficiary for a peer.
@@ -208,7 +208,7 @@ func peerBeneficiaryKey(peer swarm.Address) string {
208208

209209
// beneficiaryPeerKey computes the key where to store the peer for a beneficiary.
210210
func beneficiaryPeerKey(peer common.Address) string {
211-
return fmt.Sprintf("%s%s", beneficiaryPeerPrefix, peer)
211+
return fmt.Sprintf("%s%x", beneficiaryPeerPrefix, peer)
212212
}
213213

214214
func peerDeductedByKey(peer swarm.Address) string {

pkg/settlement/swap/chequebook/chequebook_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,22 @@ func TestChequebookWithdrawInsufficientFunds(t *testing.T) {
470470
t.Fatalf("got wrong error. wanted %v, got %v", chequebook.ErrInsufficientFunds, err)
471471
}
472472
}
473+
474+
func TestStateStoreKeys(t *testing.T) {
475+
address := common.HexToAddress("0xabcd")
476+
477+
expected := "swap_cashout_000000000000000000000000000000000000abcd"
478+
if chequebook.CashoutActionKey(address) != expected {
479+
t.Fatalf("wrong cashout action key. wanted %s, got %s", expected, chequebook.CashoutActionKey(address))
480+
}
481+
482+
expected = "swap_chequebook_last_issued_cheque_000000000000000000000000000000000000abcd"
483+
if chequebook.LastIssuedChequeKey(address) != expected {
484+
t.Fatalf("wrong last issued cheque key. wanted %s, got %s", expected, chequebook.LastIssuedChequeKey(address))
485+
}
486+
487+
expected = "swap_chequebook_last_received_cheque__000000000000000000000000000000000000abcd"
488+
if chequebook.LastReceivedChequeKey(address) != expected {
489+
t.Fatalf("wrong last received cheque key. wanted %s, got %s", expected, chequebook.LastReceivedChequeKey(address))
490+
}
491+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package chequebook
2+
3+
var (
4+
LastIssuedChequeKey = lastIssuedChequeKey
5+
LastReceivedChequeKey = lastReceivedChequeKey
6+
CashoutActionKey = cashoutActionKey
7+
)

pkg/settlement/swap/export_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package swap
2+
3+
var (
4+
PeerKey = peerKey
5+
ChequebookPeerKey = chequebookPeerKey
6+
PeerBeneficiaryKey = peerBeneficiaryKey
7+
BeneficiaryPeerKey = beneficiaryPeerKey
8+
PeerDeductedByKey = peerDeductedByKey
9+
PeerDeductedForKey = peerDeductedForKey
10+
)

pkg/settlement/swap/swap_test.go

+35
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,38 @@ func TestCashoutStatus(t *testing.T) {
750750
t.Fatalf("go wrong status. wanted %v, got %v", expectedStatus, returnedStatus)
751751
}
752752
}
753+
754+
func TestStateStoreKeys(t *testing.T) {
755+
address := common.HexToAddress("0xabcd")
756+
swarmAddress := swarm.MustParseHexAddress("deff")
757+
758+
expected := "swap_chequebook_peer_deff"
759+
if swap.PeerKey(swarmAddress) != expected {
760+
t.Fatalf("wrong peer key. wanted %s, got %s", expected, swap.PeerKey(swarmAddress))
761+
}
762+
763+
expected = "swap_peer_chequebook_000000000000000000000000000000000000abcd"
764+
if swap.ChequebookPeerKey(address) != expected {
765+
t.Fatalf("wrong peer key. wanted %s, got %s", expected, swap.ChequebookPeerKey(address))
766+
}
767+
768+
expected = "swap_peer_beneficiary_deff"
769+
if swap.PeerBeneficiaryKey(swarmAddress) != expected {
770+
t.Fatalf("wrong peer beneficiary key. wanted %s, got %s", expected, swap.PeerBeneficiaryKey(swarmAddress))
771+
}
772+
773+
expected = "swap_beneficiary_peer_000000000000000000000000000000000000abcd"
774+
if swap.BeneficiaryPeerKey(address) != expected {
775+
t.Fatalf("wrong beneficiary peer key. wanted %s, got %s", expected, swap.BeneficiaryPeerKey(address))
776+
}
777+
778+
expected = "swap_deducted_by_peer_deff"
779+
if swap.PeerDeductedByKey(swarmAddress) != expected {
780+
t.Fatalf("wrong peer deducted by key. wanted %s, got %s", expected, swap.PeerDeductedByKey(swarmAddress))
781+
}
782+
783+
expected = "swap_deducted_for_peer_deff"
784+
if swap.PeerDeductedForKey(swarmAddress) != expected {
785+
t.Fatalf("wrong peer deducted for key. wanted %s, got %s", expected, swap.PeerDeductedForKey(swarmAddress))
786+
}
787+
}

pkg/statestore/leveldb/migration.go

+43
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"errors"
2121
"fmt"
2222
"strings"
23+
24+
"github.com/ethereum/go-ethereum/common"
2325
)
2426

2527
var (
@@ -35,6 +37,7 @@ const (
3537
dbSchemaCleanInterval = "clean-interval"
3638
dbSchemaNoStamp = "no-stamp"
3739
dbSchemaFlushBlock = "flushblock"
40+
dbSchemaSwapAddr = "swapaddr"
3841
)
3942

4043
var (
@@ -54,6 +57,7 @@ var schemaMigrations = []migration{
5457
{name: dbSchemaCleanInterval, fn: migrateGrace},
5558
{name: dbSchemaNoStamp, fn: migrateStamp},
5659
{name: dbSchemaFlushBlock, fn: migrateFB},
60+
{name: dbSchemaSwapAddr, fn: migrateSwap},
5761
}
5862

5963
func migrateFB(s *store) error {
@@ -108,6 +112,45 @@ func migrateGrace(s *store) error {
108112
return nil
109113
}
110114

115+
func migrateSwap(s *store) error {
116+
migratePrefix := func(prefix string) error {
117+
keys, err := collectKeys(s, prefix)
118+
if err != nil {
119+
return err
120+
}
121+
122+
for _, key := range keys {
123+
split := strings.SplitAfter(key, prefix)
124+
if len(split) != 2 {
125+
return errors.New("no peer in key")
126+
}
127+
128+
addr := common.BytesToAddress([]byte(split[1]))
129+
fixed := fmt.Sprintf("%s%x", prefix, addr)
130+
131+
var chequebookAddress common.Address
132+
if err = s.Get(key, &chequebookAddress); err != nil {
133+
return err
134+
}
135+
136+
if err = s.Put(fixed, chequebookAddress); err != nil {
137+
return err
138+
}
139+
140+
if err = s.Delete(key); err != nil {
141+
return err
142+
}
143+
}
144+
return nil
145+
}
146+
147+
if err := migratePrefix("swap_peer_chequebook_"); err != nil {
148+
return err
149+
}
150+
151+
return migratePrefix("swap_beneficiary_peer_")
152+
}
153+
111154
func (s *store) migrate(schemaName string) error {
112155
migrations, err := getMigrations(schemaName, dbSchemaCurrent, schemaMigrations, s)
113156
if err != nil {

pkg/statestore/leveldb/migration_test.go

+58
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ package leveldb
1818

1919
import (
2020
"errors"
21+
"fmt"
2122
"io/ioutil"
2223
"testing"
2324

25+
"github.com/ethereum/go-ethereum/common"
2426
"github.com/ethersphere/bee/pkg/logging"
27+
"github.com/ethersphere/bee/pkg/storage"
2528
)
2629

2730
func TestOneMigration(t *testing.T) {
@@ -282,3 +285,58 @@ func TestMigrationErrorTo(t *testing.T) {
282285
t.Errorf("migration ran but shouldnt have")
283286
}
284287
}
288+
289+
func TestMigrationSwap(t *testing.T) {
290+
dir := t.TempDir()
291+
logger := logging.New(ioutil.Discard, 0)
292+
293+
// start the fresh statestore with the sanctuary schema name
294+
db, err := NewStateStore(dir, logger)
295+
if err != nil {
296+
t.Fatal(err)
297+
}
298+
defer db.Close()
299+
300+
address := common.HexToAddress("0xabcd")
301+
storedAddress := common.HexToAddress("0xffff")
302+
303+
legacyKey1 := fmt.Sprintf("swap_peer_chequebook_%s", address[:])
304+
legacyKey2 := fmt.Sprintf("swap_beneficiary_peer_%s", address[:])
305+
306+
if err = db.Put(legacyKey1, storedAddress); err != nil {
307+
t.Fatal(err)
308+
}
309+
310+
if err = db.Put(legacyKey2, storedAddress); err != nil {
311+
t.Fatal(err)
312+
}
313+
314+
if err = migrateSwap(db.(*store)); err != nil {
315+
t.Fatal(err)
316+
}
317+
318+
var retrievedAddress common.Address
319+
if err = db.Get("swap_peer_chequebook_000000000000000000000000000000000000abcd", &retrievedAddress); err != nil {
320+
t.Fatal(err)
321+
}
322+
323+
if retrievedAddress != storedAddress {
324+
t.Fatalf("got wrong address. wanted %x, got %x", storedAddress, retrievedAddress)
325+
}
326+
327+
if err = db.Get("swap_beneficiary_peer_000000000000000000000000000000000000abcd", &retrievedAddress); err != nil {
328+
t.Fatal(err)
329+
}
330+
331+
if retrievedAddress != storedAddress {
332+
t.Fatalf("got wrong address. wanted %x, got %x", storedAddress, retrievedAddress)
333+
}
334+
335+
if err = db.Get(legacyKey1, &retrievedAddress); err != storage.ErrNotFound {
336+
t.Fatalf("legacyKey1 not deleted. got error %v", err)
337+
}
338+
339+
if err = db.Get(legacyKey2, &retrievedAddress); err != storage.ErrNotFound {
340+
t.Fatalf("legacyKey2 not deleted. got error %v", err)
341+
}
342+
}

pkg/transaction/sender_matcher_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,7 @@ func (*mockSigner) Hash(tx *types.Transaction) common.Hash {
237237
func (*mockSigner) Equal(types.Signer) bool {
238238
return false
239239
}
240+
241+
func (*mockSigner) ChainID() *big.Int {
242+
return big.NewInt(0)
243+
}

0 commit comments

Comments
 (0)