Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
d27e04ee
Unverified
Commit
d27e04ee
authored
Jul 27, 2021
by
Ralph Pichler
Committed by
GitHub
Jul 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update go-ethereum (#2342)
parent
c07b8164
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
319 additions
and
114 deletions
+319
-114
go.mod
go.mod
+4
-7
go.sum
go.sum
+136
-104
node.go
pkg/node/node.go
+1
-1
addressbook.go
pkg/settlement/swap/addressbook.go
+2
-2
chequebook_test.go
pkg/settlement/swap/chequebook/chequebook_test.go
+19
-0
export_test.go
pkg/settlement/swap/chequebook/export_test.go
+7
-0
export_test.go
pkg/settlement/swap/export_test.go
+10
-0
swap_test.go
pkg/settlement/swap/swap_test.go
+35
-0
migration.go
pkg/statestore/leveldb/migration.go
+43
-0
migration_test.go
pkg/statestore/leveldb/migration_test.go
+58
-0
sender_matcher_test.go
pkg/transaction/sender_matcher_test.go
+4
-0
No files found.
go.mod
View file @
d27e04ee
...
@@ -5,15 +5,13 @@ go 1.15
...
@@ -5,15 +5,13 @@ go 1.15
require (
require (
github.com/btcsuite/btcd v0.22.0-beta
github.com/btcsuite/btcd v0.22.0-beta
github.com/coreos/go-semver v0.3.0
github.com/coreos/go-semver v0.3.0
github.com/ethereum/go-ethereum v1.
9.2
3
github.com/ethereum/go-ethereum v1.
10.
3
github.com/ethersphere/go-price-oracle-abi v0.1.0
github.com/ethersphere/go-price-oracle-abi v0.1.0
github.com/ethersphere/go-storage-incentives-abi v0.3.0
github.com/ethersphere/go-storage-incentives-abi v0.3.0
github.com/ethersphere/go-sw3-abi v0.4.0
github.com/ethersphere/go-sw3-abi v0.4.0
github.com/ethersphere/langos v1.0.0
github.com/ethersphere/langos v1.0.0
github.com/gogo/protobuf v1.3.2
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5
github.com/google/go-cmp v0.5.5
github.com/google/uuid v1.1.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gorilla/handlers v1.4.2
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/gorilla/mux v1.7.4
...
@@ -25,7 +23,6 @@ require (
...
@@ -25,7 +23,6 @@ require (
github.com/kardianos/service v1.2.0
github.com/kardianos/service v1.2.0
github.com/klauspost/cpuid/v2 v2.0.8 // indirect
github.com/klauspost/cpuid/v2 v2.0.8 // indirect
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-libp2p v0.14.3
github.com/libp2p/go-libp2p v0.14.3
github.com/libp2p/go-libp2p-autonat v0.4.2
github.com/libp2p/go-libp2p-autonat v0.4.2
github.com/libp2p/go-libp2p-core v0.8.5
github.com/libp2p/go-libp2p-core v0.8.5
...
@@ -55,11 +52,11 @@ require (
...
@@ -55,11 +52,11 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0
github.com/spf13/viper v1.7.0
github.com/syndtr/goleveldb v1.0.1-0.202
00815110645-5c35d600f0ca
github.com/syndtr/goleveldb v1.0.1-0.202
10305035536-64b5b1c73954
github.com/uber/jaeger-client-go v2.24.0+incompatible
github.com/uber/jaeger-client-go v2.24.0+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4
github.com/vmihailenco/msgpack/v5 v5.3.4
github.com/wealdtech/go-ens/v3 v3.4.
4
github.com/wealdtech/go-ens/v3 v3.4.
6
gitlab.com/nolash/go-mockbytes v0.0.7
gitlab.com/nolash/go-mockbytes v0.0.7
go.uber.org/atomic v1.8.0
go.uber.org/atomic v1.8.0
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
...
@@ -69,7 +66,7 @@ require (
...
@@ -69,7 +66,7 @@ require (
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
golang.org/x/time v0.0.0-20
191024005414-555d28b269f0
golang.org/x/time v0.0.0-20
201208040808-7e3f01d25324
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v2 v2.4.0
...
...
go.sum
View file @
d27e04ee
This diff is collapsed.
Click to expand it.
pkg/node/node.go
View file @
d27e04ee
...
@@ -352,7 +352,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
...
@@ -352,7 +352,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
lightNodes
:=
lightnode
.
NewContainer
(
swarmAddress
)
lightNodes
:=
lightnode
.
NewContainer
(
swarmAddress
)
senderMatcher
:=
transaction
.
NewMatcher
(
swapBackend
,
types
.
NewEIP
155
Signer
(
big
.
NewInt
(
chainID
)),
stateStore
)
senderMatcher
:=
transaction
.
NewMatcher
(
swapBackend
,
types
.
NewEIP
2930
Signer
(
big
.
NewInt
(
chainID
)),
stateStore
)
p2ps
,
err
:=
libp2p
.
New
(
p2pCtx
,
signer
,
networkID
,
swarmAddress
,
addr
,
addressbook
,
stateStore
,
lightNodes
,
senderMatcher
,
logger
,
tracer
,
libp2p
.
Options
{
p2ps
,
err
:=
libp2p
.
New
(
p2pCtx
,
signer
,
networkID
,
swarmAddress
,
addr
,
addressbook
,
stateStore
,
lightNodes
,
senderMatcher
,
logger
,
tracer
,
libp2p
.
Options
{
PrivateKey
:
libp2pPrivateKey
,
PrivateKey
:
libp2pPrivateKey
,
...
...
pkg/settlement/swap/addressbook.go
View file @
d27e04ee
...
@@ -198,7 +198,7 @@ func peerKey(peer swarm.Address) string {
...
@@ -198,7 +198,7 @@ func peerKey(peer swarm.Address) string {
// chequebookPeerKey computes the key where to store the peer for a chequebook.
// chequebookPeerKey computes the key where to store the peer for a chequebook.
func
chequebookPeerKey
(
chequebook
common
.
Address
)
string
{
func
chequebookPeerKey
(
chequebook
common
.
Address
)
string
{
return
fmt
.
Sprintf
(
"%s%
s
"
,
peerChequebookPrefix
,
chequebook
)
return
fmt
.
Sprintf
(
"%s%
x
"
,
peerChequebookPrefix
,
chequebook
)
}
}
// peerBeneficiaryKey computes the key where to store the beneficiary for a peer.
// peerBeneficiaryKey computes the key where to store the beneficiary for a peer.
...
@@ -208,7 +208,7 @@ func peerBeneficiaryKey(peer swarm.Address) string {
...
@@ -208,7 +208,7 @@ func peerBeneficiaryKey(peer swarm.Address) string {
// beneficiaryPeerKey computes the key where to store the peer for a beneficiary.
// beneficiaryPeerKey computes the key where to store the peer for a beneficiary.
func
beneficiaryPeerKey
(
peer
common
.
Address
)
string
{
func
beneficiaryPeerKey
(
peer
common
.
Address
)
string
{
return
fmt
.
Sprintf
(
"%s%
s
"
,
beneficiaryPeerPrefix
,
peer
)
return
fmt
.
Sprintf
(
"%s%
x
"
,
beneficiaryPeerPrefix
,
peer
)
}
}
func
peerDeductedByKey
(
peer
swarm
.
Address
)
string
{
func
peerDeductedByKey
(
peer
swarm
.
Address
)
string
{
...
...
pkg/settlement/swap/chequebook/chequebook_test.go
View file @
d27e04ee
...
@@ -470,3 +470,22 @@ func TestChequebookWithdrawInsufficientFunds(t *testing.T) {
...
@@ -470,3 +470,22 @@ func TestChequebookWithdrawInsufficientFunds(t *testing.T) {
t
.
Fatalf
(
"got wrong error. wanted %v, got %v"
,
chequebook
.
ErrInsufficientFunds
,
err
)
t
.
Fatalf
(
"got wrong error. wanted %v, got %v"
,
chequebook
.
ErrInsufficientFunds
,
err
)
}
}
}
}
func
TestStateStoreKeys
(
t
*
testing
.
T
)
{
address
:=
common
.
HexToAddress
(
"0xabcd"
)
expected
:=
"swap_cashout_000000000000000000000000000000000000abcd"
if
chequebook
.
CashoutActionKey
(
address
)
!=
expected
{
t
.
Fatalf
(
"wrong cashout action key. wanted %s, got %s"
,
expected
,
chequebook
.
CashoutActionKey
(
address
))
}
expected
=
"swap_chequebook_last_issued_cheque_000000000000000000000000000000000000abcd"
if
chequebook
.
LastIssuedChequeKey
(
address
)
!=
expected
{
t
.
Fatalf
(
"wrong last issued cheque key. wanted %s, got %s"
,
expected
,
chequebook
.
LastIssuedChequeKey
(
address
))
}
expected
=
"swap_chequebook_last_received_cheque__000000000000000000000000000000000000abcd"
if
chequebook
.
LastReceivedChequeKey
(
address
)
!=
expected
{
t
.
Fatalf
(
"wrong last received cheque key. wanted %s, got %s"
,
expected
,
chequebook
.
LastReceivedChequeKey
(
address
))
}
}
pkg/settlement/swap/chequebook/export_test.go
0 → 100644
View file @
d27e04ee
package
chequebook
var
(
LastIssuedChequeKey
=
lastIssuedChequeKey
LastReceivedChequeKey
=
lastReceivedChequeKey
CashoutActionKey
=
cashoutActionKey
)
pkg/settlement/swap/export_test.go
0 → 100644
View file @
d27e04ee
package
swap
var
(
PeerKey
=
peerKey
ChequebookPeerKey
=
chequebookPeerKey
PeerBeneficiaryKey
=
peerBeneficiaryKey
BeneficiaryPeerKey
=
beneficiaryPeerKey
PeerDeductedByKey
=
peerDeductedByKey
PeerDeductedForKey
=
peerDeductedForKey
)
pkg/settlement/swap/swap_test.go
View file @
d27e04ee
...
@@ -750,3 +750,38 @@ func TestCashoutStatus(t *testing.T) {
...
@@ -750,3 +750,38 @@ func TestCashoutStatus(t *testing.T) {
t
.
Fatalf
(
"go wrong status. wanted %v, got %v"
,
expectedStatus
,
returnedStatus
)
t
.
Fatalf
(
"go wrong status. wanted %v, got %v"
,
expectedStatus
,
returnedStatus
)
}
}
}
}
func
TestStateStoreKeys
(
t
*
testing
.
T
)
{
address
:=
common
.
HexToAddress
(
"0xabcd"
)
swarmAddress
:=
swarm
.
MustParseHexAddress
(
"deff"
)
expected
:=
"swap_chequebook_peer_deff"
if
swap
.
PeerKey
(
swarmAddress
)
!=
expected
{
t
.
Fatalf
(
"wrong peer key. wanted %s, got %s"
,
expected
,
swap
.
PeerKey
(
swarmAddress
))
}
expected
=
"swap_peer_chequebook_000000000000000000000000000000000000abcd"
if
swap
.
ChequebookPeerKey
(
address
)
!=
expected
{
t
.
Fatalf
(
"wrong peer key. wanted %s, got %s"
,
expected
,
swap
.
ChequebookPeerKey
(
address
))
}
expected
=
"swap_peer_beneficiary_deff"
if
swap
.
PeerBeneficiaryKey
(
swarmAddress
)
!=
expected
{
t
.
Fatalf
(
"wrong peer beneficiary key. wanted %s, got %s"
,
expected
,
swap
.
PeerBeneficiaryKey
(
swarmAddress
))
}
expected
=
"swap_beneficiary_peer_000000000000000000000000000000000000abcd"
if
swap
.
BeneficiaryPeerKey
(
address
)
!=
expected
{
t
.
Fatalf
(
"wrong beneficiary peer key. wanted %s, got %s"
,
expected
,
swap
.
BeneficiaryPeerKey
(
address
))
}
expected
=
"swap_deducted_by_peer_deff"
if
swap
.
PeerDeductedByKey
(
swarmAddress
)
!=
expected
{
t
.
Fatalf
(
"wrong peer deducted by key. wanted %s, got %s"
,
expected
,
swap
.
PeerDeductedByKey
(
swarmAddress
))
}
expected
=
"swap_deducted_for_peer_deff"
if
swap
.
PeerDeductedForKey
(
swarmAddress
)
!=
expected
{
t
.
Fatalf
(
"wrong peer deducted for key. wanted %s, got %s"
,
expected
,
swap
.
PeerDeductedForKey
(
swarmAddress
))
}
}
pkg/statestore/leveldb/migration.go
View file @
d27e04ee
...
@@ -20,6 +20,8 @@ import (
...
@@ -20,6 +20,8 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"strings"
"strings"
"github.com/ethereum/go-ethereum/common"
)
)
var
(
var
(
...
@@ -35,6 +37,7 @@ const (
...
@@ -35,6 +37,7 @@ const (
dbSchemaCleanInterval
=
"clean-interval"
dbSchemaCleanInterval
=
"clean-interval"
dbSchemaNoStamp
=
"no-stamp"
dbSchemaNoStamp
=
"no-stamp"
dbSchemaFlushBlock
=
"flushblock"
dbSchemaFlushBlock
=
"flushblock"
dbSchemaSwapAddr
=
"swapaddr"
)
)
var
(
var
(
...
@@ -54,6 +57,7 @@ var schemaMigrations = []migration{
...
@@ -54,6 +57,7 @@ var schemaMigrations = []migration{
{
name
:
dbSchemaCleanInterval
,
fn
:
migrateGrace
},
{
name
:
dbSchemaCleanInterval
,
fn
:
migrateGrace
},
{
name
:
dbSchemaNoStamp
,
fn
:
migrateStamp
},
{
name
:
dbSchemaNoStamp
,
fn
:
migrateStamp
},
{
name
:
dbSchemaFlushBlock
,
fn
:
migrateFB
},
{
name
:
dbSchemaFlushBlock
,
fn
:
migrateFB
},
{
name
:
dbSchemaSwapAddr
,
fn
:
migrateSwap
},
}
}
func
migrateFB
(
s
*
store
)
error
{
func
migrateFB
(
s
*
store
)
error
{
...
@@ -108,6 +112,45 @@ func migrateGrace(s *store) error {
...
@@ -108,6 +112,45 @@ func migrateGrace(s *store) error {
return
nil
return
nil
}
}
func
migrateSwap
(
s
*
store
)
error
{
migratePrefix
:=
func
(
prefix
string
)
error
{
keys
,
err
:=
collectKeys
(
s
,
prefix
)
if
err
!=
nil
{
return
err
}
for
_
,
key
:=
range
keys
{
split
:=
strings
.
SplitAfter
(
key
,
prefix
)
if
len
(
split
)
!=
2
{
return
errors
.
New
(
"no peer in key"
)
}
addr
:=
common
.
BytesToAddress
([]
byte
(
split
[
1
]))
fixed
:=
fmt
.
Sprintf
(
"%s%x"
,
prefix
,
addr
)
var
chequebookAddress
common
.
Address
if
err
=
s
.
Get
(
key
,
&
chequebookAddress
);
err
!=
nil
{
return
err
}
if
err
=
s
.
Put
(
fixed
,
chequebookAddress
);
err
!=
nil
{
return
err
}
if
err
=
s
.
Delete
(
key
);
err
!=
nil
{
return
err
}
}
return
nil
}
if
err
:=
migratePrefix
(
"swap_peer_chequebook_"
);
err
!=
nil
{
return
err
}
return
migratePrefix
(
"swap_beneficiary_peer_"
)
}
func
(
s
*
store
)
migrate
(
schemaName
string
)
error
{
func
(
s
*
store
)
migrate
(
schemaName
string
)
error
{
migrations
,
err
:=
getMigrations
(
schemaName
,
dbSchemaCurrent
,
schemaMigrations
,
s
)
migrations
,
err
:=
getMigrations
(
schemaName
,
dbSchemaCurrent
,
schemaMigrations
,
s
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/statestore/leveldb/migration_test.go
View file @
d27e04ee
...
@@ -18,10 +18,13 @@ package leveldb
...
@@ -18,10 +18,13 @@ package leveldb
import
(
import
(
"errors"
"errors"
"fmt"
"io/ioutil"
"io/ioutil"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/storage"
)
)
func
TestOneMigration
(
t
*
testing
.
T
)
{
func
TestOneMigration
(
t
*
testing
.
T
)
{
...
@@ -282,3 +285,58 @@ func TestMigrationErrorTo(t *testing.T) {
...
@@ -282,3 +285,58 @@ func TestMigrationErrorTo(t *testing.T) {
t
.
Errorf
(
"migration ran but shouldnt have"
)
t
.
Errorf
(
"migration ran but shouldnt have"
)
}
}
}
}
func
TestMigrationSwap
(
t
*
testing
.
T
)
{
dir
:=
t
.
TempDir
()
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
// start the fresh statestore with the sanctuary schema name
db
,
err
:=
NewStateStore
(
dir
,
logger
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
db
.
Close
()
address
:=
common
.
HexToAddress
(
"0xabcd"
)
storedAddress
:=
common
.
HexToAddress
(
"0xffff"
)
legacyKey1
:=
fmt
.
Sprintf
(
"swap_peer_chequebook_%s"
,
address
[
:
])
legacyKey2
:=
fmt
.
Sprintf
(
"swap_beneficiary_peer_%s"
,
address
[
:
])
if
err
=
db
.
Put
(
legacyKey1
,
storedAddress
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
=
db
.
Put
(
legacyKey2
,
storedAddress
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
=
migrateSwap
(
db
.
(
*
store
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
var
retrievedAddress
common
.
Address
if
err
=
db
.
Get
(
"swap_peer_chequebook_000000000000000000000000000000000000abcd"
,
&
retrievedAddress
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
retrievedAddress
!=
storedAddress
{
t
.
Fatalf
(
"got wrong address. wanted %x, got %x"
,
storedAddress
,
retrievedAddress
)
}
if
err
=
db
.
Get
(
"swap_beneficiary_peer_000000000000000000000000000000000000abcd"
,
&
retrievedAddress
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
retrievedAddress
!=
storedAddress
{
t
.
Fatalf
(
"got wrong address. wanted %x, got %x"
,
storedAddress
,
retrievedAddress
)
}
if
err
=
db
.
Get
(
legacyKey1
,
&
retrievedAddress
);
err
!=
storage
.
ErrNotFound
{
t
.
Fatalf
(
"legacyKey1 not deleted. got error %v"
,
err
)
}
if
err
=
db
.
Get
(
legacyKey2
,
&
retrievedAddress
);
err
!=
storage
.
ErrNotFound
{
t
.
Fatalf
(
"legacyKey2 not deleted. got error %v"
,
err
)
}
}
pkg/transaction/sender_matcher_test.go
View file @
d27e04ee
...
@@ -237,3 +237,7 @@ func (*mockSigner) Hash(tx *types.Transaction) common.Hash {
...
@@ -237,3 +237,7 @@ func (*mockSigner) Hash(tx *types.Transaction) common.Hash {
func
(
*
mockSigner
)
Equal
(
types
.
Signer
)
bool
{
func
(
*
mockSigner
)
Equal
(
types
.
Signer
)
bool
{
return
false
return
false
}
}
func
(
*
mockSigner
)
ChainID
()
*
big
.
Int
{
return
big
.
NewInt
(
0
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment