Skip to content

Commit

Permalink
final alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Oct 20, 2023
1 parent 2413d28 commit 703b346
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 54 deletions.
17 changes: 8 additions & 9 deletions examples/don/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ This package shows a high level integration with DONs.

Multiple nodes are created for serving multiple DONs.
Each node is composed of the following components:
- p2p agent integrated with grpc (`../api/grpc/*`)
- node orchestrator (`./lib/node.go`) to manage the internal processes within the node
- producer (`./lib/transmitter.go`) to publish messages
- message consumer (`./lib/consumer.go`)
- verifier (`./lib/verifier.go`) and signer (`./lib/signer.go`) to verify and sign messages
- p2p agent integrated with grpc (`../../api/grpc/*`)
- node orchestrator (`./node.go`) to manage the internal processes within the node
- don orchestrator (`./localdon.go`) to facilitate the behaviour of a single don, locally within the same process.
- producer (`./transmitter.go`) to publish messages
- message consumer (`./consumer.go`)
- verifier (`./verifier.go`) and signer (`./signer.go`) to verify and sign messages


Within `./tests`, you can find the following tests:
You can find the following tests:

**Local Test**

This test creates a local network of nodes and sends messages between them.
A boostrapper node (kad DHT) is used for peer discovery.

DON orchestrator (`./tests/testdon.go`) is used to manage the DONs and mock consensus rounds that produces dummy reports from a central location, which is helpful for testing.

`Sha256Signer` is used for signing/verifying messages, it doesn't rely on keys and is used for testing with key infrastructure.
DON orchestrator (`./localdon.go`) is used to manage the DONs and mock consensus rounds that produces dummy reports from a central location, which is helpful for testing.
7 changes: 2 additions & 5 deletions examples/don/localdon.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ type mockedDon struct {
reports []MockedSignedReport
}

func newMockedDon(id string, signer Signer, nodes ...*Node) *mockedDon {
func newMockedDon(id string, nodes ...*Node) *mockedDon {
for i, n := range nodes {
if signer == nil {
signer = NewSigner(OracleID(i))
}
n.Signers[id] = signer
n.Signers[id] = NewSigner(OracleID(i))
}
return &mockedDon{
id: id,
Expand Down
2 changes: 1 addition & 1 deletion examples/don/localdon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestCrossDONCommunication(t *testing.T) {
for did, cfg := range donsCfg {
for j := 0; j < cfg.dons; j++ {
donNodes := getRandomNodes(cfg.nodes, nodes)
don := newMockedDon(did, &Sha256Signer{}, donNodes...)
don := newMockedDon(did, donNodes...)
dons[did] = append(dons[did], don)
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/don/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func defaultNodeOpts() *nodeOpts {
return &nodeOpts{
reportManipulator: func(*MockedSignedReport) {},
bufferSize: 1024,
signer: &Sha256Signer{},
}
}

Expand Down
3 changes: 0 additions & 3 deletions examples/don/reportbuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ func TestReportBuffer_GetLatest(t *testing.T) {
require.True(t, rb.Add(testDon, MockedSignedReport{SeqNumber: int64(i + 1)}))
}
require.True(t, rb.Add(testDon, MockedSignedReport{SeqNumber: int64(n + 1)}))
rb.lock.Lock()
t.Logf("buffer: %+v", rb.reports[testDon])
rb.lock.Unlock()

latest := rb.GetLatest(testDon)
require.NotNil(t, latest)
Expand Down
33 changes: 0 additions & 33 deletions examples/don/signer.go

This file was deleted.

7 changes: 6 additions & 1 deletion examples/don/signer_ocr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
"fmt"
)

// OcrSigner is a mocked signer that uses `sha256(data)` as signature.
type Signer interface {
OracleID() OracleID
Sign(reportCtx ReportContext, report []byte) ([]byte, error)
Verify(pubKey OnchainPublicKey, reportCtx ReportContext, report, signed []byte) error
}

type OcrSigner struct {
k *EvmKeyring
oid OracleID
Expand Down
1 change: 0 additions & 1 deletion examples/don/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func TestVerifier_validateSequence(t *testing.T) {
t.Skip()
n := 100
rb := NewReportBuffer(n)

Expand Down

0 comments on commit 703b346

Please sign in to comment.