From 0bf9ab6808166fc95cde80efa4cf4f432c637201 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Tue, 27 Feb 2024 12:42:29 +0100 Subject: [PATCH] Looking for missing setup --- Dockerfiles/Dockerfile.frontend | 1 + Makefile | 5 +++++ PROGRESS.md | 15 +++++++++++++++ contracts/evoting/types/election.go | 4 ++-- services/dkg/pedersen/handler.go | 23 +++++++++++++++-------- services/dkg/pedersen/handler_test.go | 4 +++- services/dkg/pedersen/mod.go | 10 ++++++++++ web/frontend/package-lock.json | 16 ++++++++++------ web/frontend/tailwind.config.js | 4 ++-- 9 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 PROGRESS.md diff --git a/Dockerfiles/Dockerfile.frontend b/Dockerfiles/Dockerfile.frontend index 77376ff36..66c625910 100644 --- a/Dockerfiles/Dockerfile.frontend +++ b/Dockerfiles/Dockerfile.frontend @@ -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"] diff --git a/Makefile b/Makefile index db07a11ea..092d2145b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/PROGRESS.md b/PROGRESS.md new file mode 100644 index 000000000..0ce8cfbb2 --- /dev/null +++ b/PROGRESS.md @@ -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/dela@v0.0.0-20240226124625-ad067e63453b/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/dela@v0.0.0-20240226124625-ad067e63453b/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/dela@v0.0.0-20240226124625-ad067e63453b/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/dela@v0.0.0-20240226124625-ad067e63453b/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/dela@v0.0.0-20240226124625-ad067e63453b/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' + diff --git a/contracts/evoting/types/election.go b/contracts/evoting/types/election.go index fda807c88..2b0bf20ea 100644 --- a/contracts/evoting/types/election.go +++ b/contracts/evoting/types/election.go @@ -38,7 +38,7 @@ 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 ) @@ -46,7 +46,7 @@ const ( // 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 diff --git a/services/dkg/pedersen/handler.go b/services/dkg/pedersen/handler.go index 100505c24..fb59774c3 100644 --- a/services/dkg/pedersen/handler.go +++ b/services/dkg/pedersen/handler.go @@ -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" @@ -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) @@ -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 } @@ -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 { @@ -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 } diff --git a/services/dkg/pedersen/handler_test.go b/services/dkg/pedersen/handler_test.go index 52627d0ff..5419dcd24 100644 --- a/services/dkg/pedersen/handler_test.go +++ b/services/dkg/pedersen/handler_test.go @@ -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" @@ -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) diff --git a/services/dkg/pedersen/mod.go b/services/dkg/pedersen/mod.go index 4871c6bd3..c7b373f46 100644 --- a/services/dkg/pedersen/mod.go +++ b/services/dkg/pedersen/mod.go @@ -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() { @@ -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) @@ -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() @@ -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) @@ -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) @@ -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++ { @@ -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 { diff --git a/web/frontend/package-lock.json b/web/frontend/package-lock.json index 4fb6e675c..f4dcc5296 100644 --- a/web/frontend/package-lock.json +++ b/web/frontend/package-lock.json @@ -5376,9 +5376,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001354", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001354.tgz", - "integrity": "sha512-mImKeCkyGDAHNywYFA4bqnLAzTUvVkqPvhY4DV47X+Gl2c5Z8c3KNETnXp14GQt11LvxE8AwjzGxJ+rsikiOzg==", + "version": "1.0.30001591", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz", + "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==", "funding": [ { "type": "opencollective", @@ -5387,6 +5387,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -20659,9 +20663,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001354", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001354.tgz", - "integrity": "sha512-mImKeCkyGDAHNywYFA4bqnLAzTUvVkqPvhY4DV47X+Gl2c5Z8c3KNETnXp14GQt11LvxE8AwjzGxJ+rsikiOzg==" + "version": "1.0.30001591", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz", + "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==" }, "case-sensitive-paths-webpack-plugin": { "version": "2.4.0", diff --git a/web/frontend/tailwind.config.js b/web/frontend/tailwind.config.js index 28c795430..df9d549a4 100644 --- a/web/frontend/tailwind.config.js +++ b/web/frontend/tailwind.config.js @@ -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: {}, },