Skip to content

Commit

Permalink
Looking for missing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Feb 27, 2024
1 parent 0738d1d commit 0bf9ab6
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 19 deletions.
1 change: 1 addition & 0 deletions Dockerfiles/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ ENV REACT_APP_NOMOCK=on
WORKDIR /web/frontend
COPY ../web/frontend .
RUN npm install
RUN npm run build
ENTRYPOINT ["npm"]
CMD ["start"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ docker-dela:
docker buildx build --platform=linux/amd64 -f Dockerfiles/Dockerfile.dela.local \
-t ghcr.io/c4dt/d-voting-dela:separate_ballots --progress=plain .
docker push ghcr.io/c4dt/d-voting-dela:separate_ballots

docker-frontend:
docker buildx build --platform=linux/amd64 -f Dockerfiles/Dockerfile.frontend \
-t ghcr.io/c4dt/d-voting-frontend:separate_ballots --progress=plain .
docker push ghcr.io/c4dt/d-voting-frontend:separate_ballots
15 changes: 15 additions & 0 deletions PROGRESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# More errors

Sometimes when "Initializing" a new form one of the node fails with a

dela-worker-2_1 | 2024-02-27T10:04:16Z WRN ../../../go/pkg/mod/github.com/c4dt/[email protected]/mino/minogrpc/session/mod.go:398 > parent is closing error="client: rpc error: code = Canceled desc = context canceled" addr=https://node.dela-2.c4dt.org:443
dela-worker-4_1 | 2024-02-27T10:04:16Z INF ../../../go/pkg/mod/github.com/c4dt/[email protected]/core/ordering/cosipbft/fastsync/default.go:187 > Got 0 fastsync blocks from https://node.dela-1.c4dt.org:443 addr=https://node.dela-4.c4dt.org:443
dela-worker-4_1 | 2024-02-27T10:04:16Z INF ../../../go/pkg/mod/github.com/c4dt/[email protected]/core/ordering/cosipbft/fastsync/default.go:187 > Got 0 fastsync blocks from https://node.dela-2.c4dt.org:443 addr=https://node.dela-4.c4dt.org:443
dela-worker-4_1 | 2024-02-27T10:04:16Z INF ../../../go/pkg/mod/github.com/c4dt/[email protected]/core/ordering/cosipbft/fastsync/default.go:204 > Currently have 4 blocks addr=https://node.dela-4.c4dt.org:443
dela-worker-2_1 | 2024-02-27T10:04:58Z WRN ../../../go/pkg/mod/github.com/c4dt/[email protected]/core/ordering/cosipbft/cosipbft.go:758 > propagation failed error="failed to call client: rpc error: code = Unknown desc = handler failed to process: pbftsm finalized failed: mismatch state prepare != commit" addr=https://node.dela-2.c4dt.org:443


# Fix new error

failed to compute pubshares: failed to create stream: gateway connection failed: invalid address type 'fake.Address'

4 changes: 2 additions & 2 deletions contracts/evoting/types/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ const (
PubSharesSubmitted Status = 4
// ResultAvailable is when the ballots have been decrypted
ResultAvailable Status = 5
// Canceled is when the form has been cancel
// Canceled is when the form has been canceled
Canceled Status = 6
)

// BallotsPerBlock to improve performance, so that (de)serializing only touches
// 100 ballots at a time.
var BallotsPerBlock = uint32(100)

// TestCastBallots: if true, automatically fills every block with ballots.
// TestCastBallots if true, automatically fills every block with ballots.
var TestCastBallots = false

// formFormat contains the supported formats for the form. Right now
Expand Down
23 changes: 15 additions & 8 deletions services/dkg/pedersen/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"go.dedis.ch/dela/core/txn"
"go.dedis.ch/dela/core/txn/pool"
"go.dedis.ch/dela/crypto"
"go.dedis.ch/dela/mino/minogrpc/session"
jsondela "go.dedis.ch/dela/serde/json"

etypes "github.com/c4dt/d-voting/contracts/evoting/types"
"github.com/c4dt/d-voting/internal/testing/fake"
"github.com/c4dt/d-voting/services/dkg"
"github.com/c4dt/d-voting/services/dkg/pedersen/types"
"go.dedis.ch/dela"
Expand Down Expand Up @@ -294,7 +294,7 @@ func (h *Handler) doDKG(deals, resps *list.List, out mino.Sender, from mino.Addr
h.privShare = distKey.PriShare()
h.Unlock()

fmt.Println("*** PRIV SHARE STORED ***")
fmt.Println("Private share created")

done := types.NewStartDone(distKey.Public())
err = <-out.Send(done, from)
Expand Down Expand Up @@ -691,7 +691,7 @@ func (hd *HandlerData) UnmarshalJSON(data []byte) error {
}
hd.PrivKey = privKey

fmt.Printf("Unmarshalled actor: %s -> %+v", string(data), hd)
fmt.Printf("Unmarshalled actor: %s -> %+v\n", string(data), hd)

return nil
}
Expand Down Expand Up @@ -759,13 +759,17 @@ func (s *state) MarshalJSON() ([]byte, error) {
}
}

return json.Marshal(&struct {
ret, err := json.Marshal(&struct {
DistKey []byte `json:",omitempty"`
Participants [][]byte `json:",omitempty"`
}{
DistKey: distKeyBuf,
Participants: participantsBuf,
})

fmt.Printf("Marshalling state: %+v\n=%s\n", s, string(ret))

return ret, err
}

func (s *state) UnmarshalJSON(data []byte) error {
Expand All @@ -790,17 +794,20 @@ func (s *state) UnmarshalJSON(data []byte) error {
}

if aux.Participants != nil {
// TODO: Is using a fake implementation a problem?
f := fake.NewBadMino().GetAddressFactory()
//f := fake.NewBadMino().GetAddressFactory()
f := session.AddressFactory{}
var participants = make([]mino.Address, len(aux.Participants))
for i := 0; i < len(aux.Participants); i++ {
participants[i] = f.FromText(aux.Participants[i])
for i, partStr := range aux.Participants {
participants[i] = f.FromText(partStr)
fmt.Printf("Unmarshalling %s into %+v", partStr, participants[i])
}
s.SetParticipants(participants)
} else {
s.SetParticipants(nil)
}

fmt.Printf("State from JSON %s is now: %+v\n", string(data), s)

return nil
}

Expand Down
4 changes: 3 additions & 1 deletion services/dkg/pedersen/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
formTypes "github.com/c4dt/d-voting/contracts/evoting/types"
"go.dedis.ch/dela/core/access"
"go.dedis.ch/dela/core/txn/signed"
"go.dedis.ch/dela/mino/minogrpc/session"
"go.dedis.ch/dela/serde/json"

"github.com/c4dt/d-voting/internal/testing/fake"
Expand Down Expand Up @@ -264,7 +265,8 @@ func TestState_MarshalJSON(t *testing.T) {

// Try with some data
distKey := suite.Point().Pick(suite.RandomStream())
participants := []mino.Address{fake.NewAddress(0), fake.NewAddress(1)}
//participants := []mino.Address{fake.NewAddress(0), fake.NewAddress(1)}
participants := []mino.Address{session.NewAddress("grpcs://localhost:12345"), session.NewAddress("grpcs://localhost:1234")}

s1.SetDistKey(distKey)
s1.SetParticipants(participants)
Expand Down
10 changes: 10 additions & 0 deletions services/dkg/pedersen/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func (a *Actor) setErr(err error, args map[string]interface{}) {
// participating nodes. This function updates the actor's status in case of
// error to allow asynchronous call of this function.
func (a *Actor) Setup() (kyber.Point, error) {
a.log.Info().Msg("DEBUG setup - 1")
a.log.Info().Msg("setup")

if a.handler.startRes.Done() {
Expand All @@ -255,6 +256,8 @@ func (a *Actor) Setup() (kyber.Point, error) {
return nil, err
}

a.log.Info().Msg("DEBUG setup - 2")

if form.Roster.Len() == 0 {
err := xerrors.Errorf("the roster is empty")
a.setErr(err, nil)
Expand All @@ -268,6 +271,7 @@ func (a *Actor) Setup() (kyber.Point, error) {
}

a.log.Info().Msgf("sending getkey request to %v", addrs)
a.log.Info().Msg("DEBUG setup - 3")

// get the peer DKG pub keys
getPeerKey := types.NewGetPeerPubKey()
Expand All @@ -289,6 +293,7 @@ func (a *Actor) Setup() (kyber.Point, error) {
a.setErr(err, nil)
return nil, err
}
a.log.Info().Msg("DEBUG setup - 4")

for i := 0; i < lenAddrs; i++ {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
Expand All @@ -315,6 +320,7 @@ func (a *Actor) Setup() (kyber.Point, error) {

dela.Logger.Info().Msgf("Public key: %s", resp.GetPublicKey().String())
}
a.log.Info().Msg("DEBUG setup - 5")

message := types.NewStart(associatedAddrs, dkgPeerPubkeys)

Expand All @@ -329,6 +335,7 @@ func (a *Actor) Setup() (kyber.Point, error) {
}

dkgPubKeys := make([]kyber.Point, lenAddrs)
a.log.Info().Msg("DEBUG setup - 6")

for i := 0; i < lenAddrs; i++ {

Expand Down Expand Up @@ -362,14 +369,17 @@ func (a *Actor) Setup() (kyber.Point, error) {

a.log.Info().Msgf("ok for %s", addr.String())
}
a.log.Info().Msg("DEBUG setup - 7")

*a.status = dkg.Status{Status: dkg.Setup}
evoting.PromFormDkgStatus.WithLabelValues(a.formID).Set(float64(dkg.Setup))

a.log.Info().Msg("DEBUG setup - 8")
return dkgPubKeys[0], a.store()
}

func (a *Actor) store() error {
fmt.Printf("Storing actor for form %s\n", a.formID)
return a.db.Update(func(tx kv.WritableTx) error {
formIDBuf, err := hex.DecodeString(a.formID)
if err != nil {
Expand Down
16 changes: 10 additions & 6 deletions web/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions web/frontend/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: false, // or 'media' or 'class'
content: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: 'media', // or 'media' or 'class'
theme: {
extend: {},
},
Expand Down

0 comments on commit 0bf9ab6

Please sign in to comment.