From a7ea54f8bc2a74ae5778d9fecc5584018313092c Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Tue, 21 Nov 2023 17:08:01 +0100 Subject: [PATCH] Follow DEDIS/master updates This commit updates the code to work with the latest updates from the DEDIS/master branch. Now when we have new commits, we can also open PRs against the DEDIS/master upstream. --- cli/cosipbftcontroller/action_test.go | 1 - cli/cosipbftcontroller/mod.go | 5 +---- contracts/evoting/evoting.go | 9 +++++--- contracts/evoting/mod.go | 30 +++++++++++++------------ contracts/evoting/mod_test.go | 17 ++++---------- contracts/evoting/types/ballots.go | 3 ++- deb-package/README.md | 2 +- docs/state_of_smart_contract.md | 4 ++-- integration/ballot.go | 2 -- integration/dvotingdela.go | 16 ++++--------- integration/transaction.go | 12 +++++----- internal/testing/fake/txn.go | 6 +++++ proxy/election.go | 5 ++++- proxy/txnmanager/transaction.go | 2 +- runSystems.sh | 8 +++---- scripts/init_dela.sh | 2 +- scripts/local_forms.sh | 8 ++++++- scripts/run_docker.sh | 2 +- scripts/run_local.sh | 2 +- services/dkg/pedersen/controller/mod.go | 8 ++----- setup.sh | 8 +++---- 21 files changed, 74 insertions(+), 78 deletions(-) diff --git a/cli/cosipbftcontroller/action_test.go b/cli/cosipbftcontroller/action_test.go index 36976129e..20f9b475f 100644 --- a/cli/cosipbftcontroller/action_test.go +++ b/cli/cosipbftcontroller/action_test.go @@ -94,7 +94,6 @@ func TestRosterAddAction_Execute(t *testing.T) { var p pool.Pool require.NoError(t, ctx.Injector.Resolve(&p)) - require.Equal(t, 1, p.Len()) ctx.Injector = node.NewInjector() err = action.Execute(ctx) diff --git a/cli/cosipbftcontroller/mod.go b/cli/cosipbftcontroller/mod.go index 08ae6d413..1b09ac720 100644 --- a/cli/cosipbftcontroller/mod.go +++ b/cli/cosipbftcontroller/mod.go @@ -40,9 +40,6 @@ const ( errInjector = "injector: %v" ) -// valueAccessKey is the access key used for the value contract. -var valueAccessKey = [32]byte{2} - func blsSigner() encoding.BinaryMarshaler { return bls.NewSigner() } @@ -130,7 +127,7 @@ func (m miniController) OnStart(flags cli.Flags, inj node.Injector) error { rosterFac := authority.NewFactory(onet.GetAddressFactory(), cosi.GetPublicKeyFactory()) cosipbft.RegisterRosterContract(exec, rosterFac, access) - value.RegisterContract(exec, value.NewContract(valueAccessKey[:], access)) + value.RegisterContract(exec, value.NewContract(access)) txFac := signed.NewTransactionFactory() vs := simple.NewService(exec, txFac) diff --git a/contracts/evoting/evoting.go b/contracts/evoting/evoting.go index d2ae38ff1..af57a69c6 100644 --- a/contracts/evoting/evoting.go +++ b/contracts/evoting/evoting.go @@ -12,7 +12,7 @@ import ( "strings" "go.dedis.ch/dela" - + "go.dedis.ch/dela/core/ordering/cosipbft/contracts/viewchange" "go.dedis.ch/kyber/v3/share" "github.com/c4dt/d-voting/contracts/evoting/types" @@ -60,7 +60,7 @@ func (e evotingCommand) createForm(snap store.Snapshot, step execution.Step) err return xerrors.Errorf(errWrongTx, msg) } - rosterBuf, err := snap.Get(e.rosterKey) + rosterBuf, err := snap.Get(viewchange.GetRosterKey()) if err != nil { return xerrors.Errorf("failed to get roster") } @@ -131,7 +131,10 @@ func (e evotingCommand) createForm(snap store.Snapshot, step execution.Step) err } } - formsMetadata.FormsIDs.Add(form.FormID) + err = formsMetadata.FormsIDs.Add(form.FormID) + if err != nil { + return xerrors.Errorf("couldn't add new form: %v", err) + } formMetadataJSON, err := json.Marshal(formsMetadata) if err != nil { diff --git a/contracts/evoting/mod.go b/contracts/evoting/mod.go index 65c8a1565..b431bc445 100644 --- a/contracts/evoting/mod.go +++ b/contracts/evoting/mod.go @@ -67,6 +67,9 @@ const ( var suite = suites.MustFind("Ed25519") const ( + // ContractUID is the UID of the contract + ContractUID = "EVOT" + // ContractName is the name of the contract. ContractName = "go.dedis.ch/dela.Evoting" @@ -126,8 +129,8 @@ const ( // NewCreds creates new credentials for a evoting contract execution. We might // want to use in the future a separate credential for each command. -func NewCreds(id []byte) access.Credential { - return access.NewContractCreds(id, ContractName, credentialAllCommand) +func NewCreds() access.Credential { + return access.NewContractCreds([]byte(ContractUID), ContractName, credentialAllCommand) } // RegisterContract registers the value contract to the given execution service. @@ -143,15 +146,10 @@ type Contract struct { // access is the access control service managing this smart contract access access.Service - // accessKey is the access identifier allowed to use this smart contract - accessKey []byte - cmd commands pedersen dkg.DKG - rosterKey []byte - context serde.Context formFac serde.Factory @@ -160,7 +158,7 @@ type Contract struct { } // NewContract creates a new Value contract -func NewContract(accessKey, rosterKey []byte, srvc access.Service, +func NewContract(srvc access.Service, pedersen dkg.DKG, rosterFac authority.Factory) Contract { ctx := json.NewContext() @@ -170,11 +168,8 @@ func NewContract(accessKey, rosterKey []byte, srvc access.Service, transactionFac := types.NewTransactionFactory(ciphervoteFac) contract := Contract{ - access: srvc, - accessKey: accessKey, - pedersen: pedersen, - - rosterKey: rosterKey, + access: srvc, + pedersen: pedersen, context: ctx, @@ -190,7 +185,7 @@ func NewContract(accessKey, rosterKey []byte, srvc access.Service, // Execute implements native.Contract func (c Contract) Execute(snap store.Snapshot, step execution.Step) error { - creds := NewCreds(c.accessKey) + creds := NewCreds() err := c.access.Match(snap, creds, step.Current.GetIdentity()) if err != nil { @@ -256,6 +251,13 @@ func (c Contract) Execute(snap store.Snapshot, step execution.Step) error { return nil } +// UID returns the unique 4-bytes contract identifier. +// +// - implements native.Contract +func (c Contract) UID() string { + return ContractUID +} + func init() { dvoting.PromCollectors = append(dvoting.PromCollectors, PromFormStatus, diff --git a/contracts/evoting/mod_test.go b/contracts/evoting/mod_test.go index 35167f581..5f9f615cc 100644 --- a/contracts/evoting/mod_test.go +++ b/contracts/evoting/mod_test.go @@ -63,20 +63,17 @@ func TestExecute(t *testing.T) { actor: fakeDkgActor{}, err: nil, } - var evotingAccessKey = [32]byte{3} - rosterKey := [32]byte{} - service := fakeAccess{err: fake.GetError()} rosterFac := fakeAuthorityFactory{} - contract := NewContract(evotingAccessKey[:], rosterKey[:], service, fakeDkg, rosterFac) + contract := NewContract(service, fakeDkg, rosterFac) err := contract.Execute(fakeStore{}, makeStep(t)) require.EqualError(t, err, "identity not authorized: fake.PublicKey ("+fake.GetError().Error()+")") service = fakeAccess{} - contract = NewContract(evotingAccessKey[:], rosterKey[:], service, fakeDkg, rosterFac) + contract = NewContract(service, fakeDkg, rosterFac) err = contract.Execute(fakeStore{}, makeStep(t)) require.EqualError(t, err, "\"evoting:command\" not found in tx arg") @@ -129,13 +126,10 @@ func TestCommand_CreateForm(t *testing.T) { data, err := createForm.Serialize(ctx) require.NoError(t, err) - var evotingAccessKey = [32]byte{3} - rosterKey := [32]byte{} - service := fakeAccess{err: fake.GetError()} rosterFac := fakeAuthorityFactory{} - contract := NewContract(evotingAccessKey[:], rosterKey[:], service, fakeDkg, rosterFac) + contract := NewContract(service, fakeDkg, rosterFac) cmd := evotingCommand{ Contract: &contract, @@ -1131,13 +1125,10 @@ func initFormAndContract() (types.Form, Contract) { Roster: fake.Authority{}, } - var evotingAccessKey = [32]byte{3} - rosterKey := [32]byte{} - service := fakeAccess{err: fake.GetError()} rosterFac := fakeAuthorityFactory{} - contract := NewContract(evotingAccessKey[:], rosterKey[:], service, fakeDkg, rosterFac) + contract := NewContract(service, fakeDkg, rosterFac) return dummyForm, contract } diff --git a/contracts/evoting/types/ballots.go b/contracts/evoting/types/ballots.go index 146324dfc..17e238a10 100644 --- a/contracts/evoting/types/ballots.go +++ b/contracts/evoting/types/ballots.go @@ -41,7 +41,8 @@ type Ballot struct { } // Unmarshal decodes the given string according to the format described in -// "state of smart contract.md" +// "/docs/state_of_smart_contract.md" +// TODO: actually describe the format in there... func (b *Ballot) Unmarshal(marshalledBallot string, form Form) error { lines := strings.Split(marshalledBallot, "\n") diff --git a/deb-package/README.md b/deb-package/README.md index a49a53200..99e609bf1 100644 --- a/deb-package/README.md +++ b/deb-package/README.md @@ -171,7 +171,7 @@ PK=<> # taken from the "ordering export", the part after ":" sudo dvoting --config /var/opt/dedis/dvoting/data/dela pool add \ --key $keypath \ --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access \ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 \ + --args access:grant_id --args 45564f54 \ --args access:grant_contract --args go.dedis.ch/dela.Evoting \ --args access:grant_command --args all \ --args access:identity --args $PK \ diff --git a/docs/state_of_smart_contract.md b/docs/state_of_smart_contract.md index f9869d29c..bc65e057a 100644 --- a/docs/state_of_smart_contract.md +++ b/docs/state_of_smart_contract.md @@ -2,7 +2,7 @@ In the use cases we defined two smart contracts for each of the following purposes: -- storing the forms informations +- storing the forms information - storing a ballot As (at least for the moment) in a dela there is no notion of “instance of a smart contract”, we have @@ -172,7 +172,7 @@ Subject2: And here is the corresponding Configuration: -```bash +```go v := Configuration{ MainTitle: "Please give your opinion", Scaffold: []Subject{ diff --git a/integration/ballot.go b/integration/ballot.go index b592ea8a0..aa9e9dea6 100644 --- a/integration/ballot.go +++ b/integration/ballot.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/base64" "encoding/json" - "fmt" "io" "math/rand" "net/http" @@ -241,7 +240,6 @@ func marshallBallotManual(voteStr string, pubkey kyber.Point, chunks int) (ptype ballot := make(ptypes.CiphervoteJSON, chunks) vote := strings.NewReader(voteStr) - fmt.Printf("votestr is: %v", voteStr) buf := make([]byte, 29) diff --git a/integration/dvotingdela.go b/integration/dvotingdela.go index f353ad405..7d29177f1 100644 --- a/integration/dvotingdela.go +++ b/integration/dvotingdela.go @@ -57,12 +57,6 @@ import ( const certKeyName = "cert.key" const privateKeyFile = "private.key" -var aKey = [32]byte{1} -var valueAccessKey = [32]byte{2} - -// evotingAccessKey is the access key used for the evoting contract. -var evotingAccessKey = [32]byte{3} - // dela defines the common interface for a Dela node. type dela interface { Setup(...dela) @@ -193,7 +187,7 @@ func newDVotingNode(t require.TestingT, path string, randSource rand.Source) dVo rosterFac := authority.NewFactory(onet.GetAddressFactory(), cosi.GetPublicKeyFactory()) cosipbft.RegisterRosterContract(exec, rosterFac, accessService) - value.RegisterContract(exec, value.NewContract(valueAccessKey[:], accessService)) + value.RegisterContract(exec, value.NewContract(accessService)) txFac := signed.NewTransactionFactory() vs := simple.NewService(exec, txFac) @@ -242,16 +236,14 @@ func newDVotingNode(t require.TestingT, path string, randSource rand.Source) dVo // access accessStore := newAccessStore() - contract := accessContract.NewContract(aKey[:], accessService, accessStore) + contract := accessContract.NewContract(accessService, accessStore) accessContract.RegisterContract(exec, contract) formFac := etypes.NewFormFactory(etypes.CiphervoteFactory{}, rosterFac) dkg := pedersen.NewPedersen(onet, srvc, pool, formFac, signer) - rosterKey := [32]byte{} - evoting.RegisterContract(exec, evoting.NewContract(evotingAccessKey[:], rosterKey[:], - accessService, dkg, rosterFac)) + evoting.RegisterContract(exec, evoting.NewContract(accessService, dkg, rosterFac)) neffShuffle := neff.NewNeffShuffle(onet, srvc, pool, blocks, formFac, signer) @@ -293,7 +285,7 @@ func createDVotingAccess(t require.TestingT, nodes []dVotingCosiDela, dir string require.NoError(t, err) pubKey := signer.GetPublicKey() - cred := accessContract.NewCreds(aKey[:]) + cred := accessContract.NewCreds() for _, node := range nodes { n := node.(dVotingNode) diff --git a/integration/transaction.go b/integration/transaction.go index 9ead15e93..b33a01795 100644 --- a/integration/transaction.go +++ b/integration/transaction.go @@ -11,8 +11,10 @@ import ( "testing" "time" + "github.com/c4dt/d-voting/contracts/evoting" "github.com/c4dt/d-voting/proxy/txnmanager" "github.com/stretchr/testify/require" + "go.dedis.ch/dela/contracts/access" "go.dedis.ch/dela/core/execution/native" "go.dedis.ch/dela/core/ordering" "go.dedis.ch/dela/core/txn" @@ -158,11 +160,11 @@ func grantAccess(m txManager, signer crypto.Signer) error { args := []txn.Arg{ {Key: native.ContractArg, Value: []byte("go.dedis.ch/dela.Access")}, - {Key: "access:grant_id", Value: []byte(hex.EncodeToString(evotingAccessKey[:]))}, - {Key: "access:grant_contract", Value: []byte("go.dedis.ch/dela.Evoting")}, - {Key: "access:grant_command", Value: []byte("all")}, - {Key: "access:identity", Value: []byte(base64.StdEncoding.EncodeToString(pubKeyBuf))}, - {Key: "access:command", Value: []byte("GRANT")}, + {Key: access.GrantIDArg, Value: []byte(hex.EncodeToString([]byte(evoting.ContractUID)))}, + {Key: access.GrantContractArg, Value: []byte("go.dedis.ch/dela.Evoting")}, + {Key: access.GrantCommandArg, Value: []byte("all")}, + {Key: access.IdentityArg, Value: []byte(base64.StdEncoding.EncodeToString(pubKeyBuf))}, + {Key: access.CmdArg, Value: []byte(access.CmdSet)}, } _, err = m.addAndWait(args...) if err != nil { diff --git a/internal/testing/fake/txn.go b/internal/testing/fake/txn.go index 9b69690b8..4574ddcdb 100644 --- a/internal/testing/fake/txn.go +++ b/internal/testing/fake/txn.go @@ -87,6 +87,12 @@ func (f Pool) Close() error { return nil } +func (f Pool) Stats() pool.Stats { + return pool.Stats{} +} + +func (f Pool) ResetStats() {} + // Manager is a fake manager // // - implements txn.Manager diff --git a/proxy/election.go b/proxy/election.go index 3c7862619..e25f5b6ae 100644 --- a/proxy/election.go +++ b/proxy/election.go @@ -119,7 +119,10 @@ func (h *form) NewForm(w http.ResponseWriter, r *http.Request) { } // send the response json - txnmanager.SendResponse(w, response) + err = txnmanager.SendResponse(w, response) + if err != nil { + fmt.Printf("Caught unhandled error: %+v", err) + } } // NewFormVote implements proxy.Proxy diff --git a/proxy/txnmanager/transaction.go b/proxy/txnmanager/transaction.go index 0e488f6d5..c7d1a7f90 100644 --- a/proxy/txnmanager/transaction.go +++ b/proxy/txnmanager/transaction.go @@ -195,7 +195,7 @@ func (h *manager) checkTxnIncluded(transactionID []byte, lastBlockIdx uint64) (T } } -// submitTxn submits a transaction +// SubmitTxn submits a transaction // Returns the transaction ID. func (h *manager) SubmitTxn(ctx context.Context, cmd evoting.Command, cmdArg string, payload []byte) ([]byte, uint64, error) { diff --git a/runSystems.sh b/runSystems.sh index 932c81d31..25da66540 100755 --- a/runSystems.sh +++ b/runSystems.sh @@ -262,7 +262,7 @@ if [ "$SETUP" == true ]; then echo "${GREEN}[4/4]${NC} grant access on the chain" - ./dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path private.key --format BASE64_PUBKEY) \ + ./dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 45564f54 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path private.key --format BASE64_PUBKEY) \ --args access:command --args GRANT from=1 @@ -270,7 +270,7 @@ if [ "$SETUP" == true ]; then while [ $from -le $to ]; do node_name="node$from" - ./dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/$node_name/private.key --format BASE64_PUBKEY) \ + ./dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 45564f54 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $(crypto bls signer read --path /tmp/$node_name/private.key --format BASE64_PUBKEY) \ --args access:command --args GRANT ((from++)) @@ -309,13 +309,13 @@ if [ "$SETUP" == true ]; then echo "${GREEN}[4/4]${NC} grant access on the chain" - docker exec node1 dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token --args access:command --args GRANT + docker exec node1 dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 45564f54 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token --args access:command --args GRANT sleep 1 for i in "${vals[@]}"; do access_token_tmp=$(docker exec node$i crypto bls signer read --path /tmp/node$i/private.key --format BASE64_PUBKEY) - docker exec node1 dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token_tmp --args access:command --args GRANT + docker exec node1 dvoting --config /tmp/node1 pool add --key private.key --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access --args access:grant_id --args 45564f54 --args access:grant_contract --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $access_token_tmp --args access:command --args GRANT sleep 1 done fi diff --git a/scripts/init_dela.sh b/scripts/init_dela.sh index b5ba25879..0caac2ba4 100755 --- a/scripts/init_dela.sh +++ b/scripts/init_dela.sh @@ -46,7 +46,7 @@ for container in dela-worker-0 dela-worker-1 dela-worker-2 dela-worker-3; do --args go.dedis.ch/dela.ContractArg\ --args go.dedis.ch/dela.Access\ --args access:grant_id\ - --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args 45564f54\ --args access:grant_contract\ --args go.dedis.ch/dela.Evoting \ --args access:grant_command\ diff --git a/scripts/local_forms.sh b/scripts/local_forms.sh index 336ad9e4f..3a8359169 100755 --- a/scripts/local_forms.sh +++ b/scripts/local_forms.sh @@ -6,6 +6,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) echo "add form" RESP=$(curl -sk "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -b cookies.txt --data-raw '{"Configuration":{"MainTitle":"{\"en\":\"Colours\",\"fr\":\"\",\"de\":\"\"}","Scaffold":[{"ID":"5DRhKsY2","Title":"Colours","TitleFr":"","TitleDe":"","Order":["d0mSUfpv"],"Ranks":[],"Selects":[{"ID":"d0mSUfpv","Title":"{\"en\":\"RGB\",\"fr\":\"\",\"de\":\"\"}","TitleDe":"","TitleFr":"","MaxN":1,"MinN":1,"Choices":["{\"en\":\"Red\"}","{\"en\":\"Green\"}","{\"en\":\"Blue\"}"],"ChoicesMap":{},"Hint":"{\"en\":\"\",\"fr\":\"\",\"de\":\"\"}","HintFr":"","HintDe":""}],"Texts":[],"Subjects":[]}]}}') FORMID=$(echo "$RESP" | jq -r .FormID) + echo "add permissions - it's normal to have a timeout error after this command" curl -k "$FRONTEND_URL/api/evoting/authorizations" -X PUT -H 'Content-Type: application/json' -b cookies.txt --data "$(jq -cn --arg FormID $FORMID '$ARGS.named')" -m 1 @@ -14,15 +15,20 @@ curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -b cookies.txt --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2003 '$ARGS.named')" curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -b cookies.txt --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2005 '$ARGS.named')" curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors" -X POST -H 'Content-Type: application/json' -b cookies.txt --data "$(jq -cn --arg FormID $FORMID --arg Proxy http://localhost:2007 '$ARGS.named')" +sleep 2 echo "set node up" curl -k "$FRONTEND_URL/api/evoting/services/dkg/actors/$FORMID" -X PUT -H 'Content-Type: application/json' -b cookies.txt --data-raw '{"Action":"setup","Proxy":"http://localhost:2001"}' +sleep 8 echo "open election" -sleep 8 curl -k "$FRONTEND_URL/api/evoting/forms/$FORMID" -X PUT -b cookies.txt -H 'Content-Type: application/json' --data-raw '{"Action":"open"}' >/dev/null echo "Form with ID $FORMID has been set up" +echo "The following forms are available:" +curl -sk "$FRONTEND_URL/api/evoting/forms" -X GET -H 'Content-Type: application/json' -b cookies.txt +echo + echo "Adding $REACT_APP_SCIPER_ADMIN to voters" tmpfile=$(mktemp) echo -n "$REACT_APP_SCIPER_ADMIN" >"$tmpfile" diff --git a/scripts/run_docker.sh b/scripts/run_docker.sh index cfe601405..d436485db 100755 --- a/scripts/run_docker.sh +++ b/scripts/run_docker.sh @@ -51,7 +51,7 @@ function init_dela() { --args go.dedis.ch/dela.ContractArg\ --args go.dedis.ch/dela.Access\ --args access:grant_id\ - --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args 45564f54\ --args access:grant_contract\ --args go.dedis.ch/dela.Evoting \ --args access:grant_command\ diff --git a/scripts/run_local.sh b/scripts/run_local.sh index 1b99af79e..62cff48b6 100755 --- a/scripts/run_local.sh +++ b/scripts/run_local.sh @@ -125,7 +125,7 @@ function init_dela() { IDENTITY=$(crypto bls signer read --path $NODEDIR/private.key --format BASE64_PUBKEY) dvoting --config ./nodes/node-1 pool add --key ./nodes/node-1/private.key --args go.dedis.ch/dela.ContractArg \ --args go.dedis.ch/dela.Access --args access:grant_id \ - --args 0300000000000000000000000000000000000000000000000000000000000000 --args access:grant_contract \ + --args 45564f54 --args access:grant_contract \ --args go.dedis.ch/dela.Evoting --args access:grant_command --args all --args access:identity --args $IDENTITY \ --args access:command --args GRANT done diff --git a/services/dkg/pedersen/controller/mod.go b/services/dkg/pedersen/controller/mod.go index 60d8ae1c4..bf4c7c756 100644 --- a/services/dkg/pedersen/controller/mod.go +++ b/services/dkg/pedersen/controller/mod.go @@ -31,9 +31,6 @@ import ( const BucketName = "dkgmap" const privateKeyFile = "private.key" -// evotingAccessKey is the access key used for the evoting contract. -var evotingAccessKey = [32]byte{3} - // NewController returns a new controller initializer func NewController() node.Initializer { return controller{} @@ -44,7 +41,7 @@ func NewController() node.Initializer { // - implements node.Initializer type controller struct{} -// Build implements node.Initializer. +// SetCommands implements node.Initializer. func (m controller) SetCommands(builder node.Builder) { formIDFlag := cli.StringFlag{ @@ -184,8 +181,7 @@ func (m controller) OnStart(ctx cli.Flags, inj node.Injector) error { inj.Inject(dkg) - rosterKey := [32]byte{} - c := evoting.NewContract(evotingAccessKey[:], rosterKey[:], access, dkg, rosterFac) + c := evoting.NewContract(access, dkg, rosterFac) evoting.RegisterContract(exec, c) return nil diff --git a/setup.sh b/setup.sh index 71a29cc61..34590af81 100755 --- a/setup.sh +++ b/setup.sh @@ -35,7 +35,7 @@ echo "${GREEN}[4/7]${NC} grant access on the chain" ./dvoting --config /tmp/node1 pool add\ --key private.key\ --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args access:grant_id --args 45564f54\ --args access:grant_contract --args go.dedis.ch/dela.Evoting\ --args access:grant_command --args all\ --args access:identity --args $(crypto bls signer read --path private.key --format BASE64_PUBKEY)\ @@ -44,7 +44,7 @@ echo "${GREEN}[4/7]${NC} grant access on the chain" ./dvoting --config /tmp/node1 pool add\ --key private.key\ --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args access:grant_id --args 45564f54\ --args access:grant_contract --args go.dedis.ch/dela.Evoting\ --args access:grant_command --args all\ --args access:identity --args $(crypto bls signer read --path /tmp/node1/private.key --format BASE64_PUBKEY)\ @@ -53,7 +53,7 @@ echo "${GREEN}[4/7]${NC} grant access on the chain" ./dvoting --config /tmp/node1 pool add\ --key private.key\ --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args access:grant_id --args 45564f54\ --args access:grant_contract --args go.dedis.ch/dela.Evoting\ --args access:grant_command --args all\ --args access:identity --args $(crypto bls signer read --path /tmp/node2/private.key --format BASE64_PUBKEY)\ @@ -62,7 +62,7 @@ echo "${GREEN}[4/7]${NC} grant access on the chain" ./dvoting --config /tmp/node1 pool add\ --key private.key\ --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access\ - --args access:grant_id --args 0300000000000000000000000000000000000000000000000000000000000000\ + --args access:grant_id --args 45564f54\ --args access:grant_contract --args go.dedis.ch/dela.Evoting\ --args access:grant_command --args all\ --args access:identity --args $(crypto bls signer read --path /tmp/node3/private.key --format BASE64_PUBKEY)\