Skip to content

Commit

Permalink
Merge branch 'release/0.3.0' into feat/support-v1-txs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanswrt committed Nov 18, 2020
2 parents 3e7536e + acc35a4 commit 7ca86bb
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 14 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## 0.2.5
- Add support for Devnet
- Update Darknode dependency
- Use `ren_queryConfig` RPC to load selector whitelist and confirmations
- Add unit tests for resolver
- Use Darknode signatory for query parameter

## 0.2.4
- Fix overriding confirmations
- Update Darknode/Multichain dependencies
- Fix function parsing the network
- Add support for Devnet

## 0.2.3
- Update to Multichain v0.2.14
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ENV GOPRIVATE=github.com/renproject/darknode
WORKDIR /lightnode
COPY go.mod .
COPY go.sum .
RUN go mod edit -replace=github.com/filecoin-project/filecoin-ffi=$(go env GOPATH)/src/github.com/filecoin-project/filecoin-ffi
RUN go mod download

# Copy the code into the container.
COPY . .
RUN go mod edit -replace=github.com/filecoin-project/filecoin-ffi=$(go env GOPATH)/src/github.com/filecoin-project/filecoin-ffi

# Build the code inside the container.
RUN go build ./cmd/lightnode
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ require (
github.com/onsi/gomega v1.10.1
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/renproject/aw v0.4.0-9
github.com/renproject/darknode v0.5.3-0.20201029001917-7e184a65a858
github.com/renproject/darknode v0.5.3-0.20201105235245-6c826ec308fa
github.com/renproject/id v0.4.2
github.com/renproject/kv v1.1.2
github.com/renproject/multichain v0.2.15
github.com/renproject/multichain v0.2.16
github.com/renproject/pack v0.2.5
github.com/renproject/phi v0.1.0
github.com/rjeczalik/notify v0.9.2 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1501,12 +1501,18 @@ github.com/renproject/aw v0.4.0-9 h1:O3rFYg4arz+kuu+qqn/+FYtWDhsstD/R8/+RkOTrOCE
github.com/renproject/aw v0.4.0-9/go.mod h1:iuELPkEjsWV9dSyZ9TE5SKsTr+jv2I9naHDhsodH3Z0=
github.com/renproject/darknode v0.5.3-0.20201029001917-7e184a65a858 h1:Wff3jAiCM0PgZX2ueJ+8pCN73CunJK3f52dqx7jOh1w=
github.com/renproject/darknode v0.5.3-0.20201029001917-7e184a65a858/go.mod h1:4oa4V3iIGj4ogrxLuiGDxU69RX2PgvNSXuCSMfrfofA=
github.com/renproject/darknode v0.5.3-0.20201030045646-ff1b2342fc79 h1:jfUbFwZcqUZleMXJNGLsRIj5Hea6hLyc/ZqJSBJqrkY=
github.com/renproject/darknode v0.5.3-0.20201030045646-ff1b2342fc79/go.mod h1:4oa4V3iIGj4ogrxLuiGDxU69RX2PgvNSXuCSMfrfofA=
github.com/renproject/darknode v0.5.3-0.20201105235245-6c826ec308fa h1:dqxkur6pg3FTQ8ZpK0qmODPR+o1ROFlhjcUXDEnZzsw=
github.com/renproject/darknode v0.5.3-0.20201105235245-6c826ec308fa/go.mod h1:GFR/Ko25V7yuZb8hw9/MXuC/69HEKjomuJpNOfl26WU=
github.com/renproject/id v0.4.2 h1:XseNDPPCJtsZjIWR7Qgf+zxy0Gt5xsLrfwpQxJt5wFQ=
github.com/renproject/id v0.4.2/go.mod h1:bCzV4zZkyWetf0GvhJxMT9HQNnGUwzQpImtXOUXqq0k=
github.com/renproject/kv v1.1.2 h1:P18yHdDVJTEZ9yeyx6o82ICY1m6f+VdtAt/ouZez+AU=
github.com/renproject/kv v1.1.2/go.mod h1:78bvdAtYiYxCoT9ihVhl8qdmjl7s9fST/FkRLnZ6rXY=
github.com/renproject/multichain v0.2.15 h1:m8aVAih2CUmlnel/gNPgc/SC6gF3ODXc1+jE08NgVUo=
github.com/renproject/multichain v0.2.15/go.mod h1:Ooie8BYJ5d+pg+299ZCb7i+9s2oBtVfeHLalZb4NXUo=
github.com/renproject/multichain v0.2.16 h1:mfGu90PAW11CrNqqigFwxNuwk3b4azaauKhdBbq2SG4=
github.com/renproject/multichain v0.2.16/go.mod h1:Ooie8BYJ5d+pg+299ZCb7i+9s2oBtVfeHLalZb4NXUo=
github.com/renproject/pack v0.2.5 h1:BNfam8PCb5qJuIX36IqOkcRgaZLOZsM1lZZSakbOxb4=
github.com/renproject/pack v0.2.5/go.mod h1:pzX3Hc04RoPft89LaZJVp0xgngVGi90V7GvyC3mOGg4=
github.com/renproject/phi v0.1.0 h1:ZOn7QeDribk/uV46OhQWcTLxyuLg7P+xR1Hfl5cOQuI=
Expand Down
2 changes: 1 addition & 1 deletion resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var _ = Describe("Resolver", func() {
resolver := init(ctx)
defer cleanup()

urlI, err := url.Parse("http://localhost/?id=localhost")
urlI, err := url.Parse("http://localhost/?id=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
Expect(err).ShouldNot(HaveOccurred())
params := jsonrpc.ParamsQueryConfig{}
req := http.Request{
Expand Down
25 changes: 18 additions & 7 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ type MultiAddrStore struct {

// New constructs a new `MultiAddrStore`.
func New(store db.Table, bootstrapAddrs []wire.Address) MultiAddrStore {
multiStore := MultiAddrStore{
store: store,
bootstrapAddrs: bootstrapAddrs,
}

for _, addr := range bootstrapAddrs {
if err := store.Insert(addr.Value, addr.String()); err != nil {
if err := multiStore.Insert(addr); err != nil {
panic(fmt.Sprintf("[MultiAddrStore] cannot initialize the store with bootstrap nodes addresses"))
}
}
return MultiAddrStore{
store: store,
bootstrapAddrs: bootstrapAddrs,
}
return multiStore
}

// Get retrieves a multi-address from the store.
Expand All @@ -38,12 +40,21 @@ func (multiStore *MultiAddrStore) Get(id string) (wire.Address, error) {

// Insert puts the given multi-address into the store.
func (multiStore *MultiAddrStore) Insert(addr wire.Address) error {
return multiStore.store.Insert(addr.Value, addr.String())
signatory, err := addr.Signatory()
if err != nil {
return err
}

return multiStore.store.Insert(signatory.String(), addr.String())
}

// Delete removes the given multi-address from the store.
func (multiStore *MultiAddrStore) Delete(addr wire.Address) error {
return multiStore.store.Delete(addr.Value)
signatory, err := addr.Signatory()
if err != nil {
return err
}
return multiStore.store.Delete(signatory.String())
}

// Size returns the number of entries in the store.
Expand Down
21 changes: 21 additions & 0 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,26 @@ var _ = Describe("Store", func() {
Expect(err).ShouldNot(HaveOccurred())
Expect(len(addrs)).To(Equal(randomSize))
})

It("should fetch the correct multiaddr for a given signatory", func() {
r := rand.New(rand.NewSource(GinkgoRandomSeed()))
expectedSize := rand.Intn(100) + 1
addrs := make([]wire.Address, expectedSize)
for i := 0; i < expectedSize; i++ {
addrs[i] = randomAddress(r)
}
addrStore := New(kv.NewTable(kv.NewMemDB(kv.JSONCodec), "addresses"), nil)

for i := 0; i < expectedSize; i++ {
Expect(addrStore.Insert(addrs[i])).ShouldNot(HaveOccurred())
signatory, err := addrs[i].Signatory()
Expect(err).ShouldNot(HaveOccurred())
fetchedAddr, err := addrStore.Get(signatory.String())
Expect(err).ShouldNot(HaveOccurred())
Expect(fetchedAddr).To(Equal(addrs[i]))

}
Expect(len(addrs)).To(Equal(expectedSize))
})
})
})
6 changes: 4 additions & 2 deletions testutils/darknode.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ func NewMockDarknode(serverURL string, store store.MultiAddrStore) *MockDarknode
panic(err)
}
addr := wire.NewUnsignedAddress(wire.TCP, fmt.Sprintf("%v:%v", host, port), uint64(time.Now().Unix()))
if err := store.Insert(addr); err != nil {

if err := addr.Sign((*id.PrivKey)(key)); err != nil {
panic(err)
}
if err := addr.Sign((*id.PrivKey)(key)); err != nil {
if err := store.Insert(addr); err != nil {
panic(err)
}

return &MockDarknode{
Me: addr,
Store: store,
Expand Down

0 comments on commit 7ca86bb

Please sign in to comment.