Skip to content

Commit

Permalink
Merge pull request #5 from rinor/master
Browse files Browse the repository at this point in the history
Tally result dumper + minor fixes
  • Loading branch information
Mikhail Zabaluev committed Dec 2, 2020
2 parents ee042a5 + 066a125 commit b29beda
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 207 deletions.
37 changes: 37 additions & 0 deletions .goreleaser.yml
Expand Up @@ -44,6 +44,43 @@ builds:
goarch:
- amd64

- id: t-linux
ldflags: -s -w -X main.Version={{ .Version }} -X main.BuildDate={{ .Date }} -X main.CommitHash={{ .ShortCommit }}
binary: vitresult
main: ./cmd/vitresult/vitresult.go
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
- arm
- id: t-darwin-amd64
ldflags: -s -w -X main.Version={{ .Version }} -X main.BuildDate={{ .Date }} -X main.CommitHash={{ .ShortCommit }}
binary: vitresult
main: ./cmd/vitresult/vitresult.go
env:
- CGO_ENABLED=0
# - CC=o64-clang
# - CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
- id: t-windows-amd64
ldflags: -s -w -X main.Version={{ .Version }} -X main.BuildDate={{ .Date }} -X main.CommitHash={{ .ShortCommit }}
binary: vitresult
main: ./cmd/vitresult/vitresult.go
env:
- CGO_ENABLED=0
# - CC=x86_64-w64-mingw32-gcc
# - CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64

archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
Expand Down
2 changes: 1 addition & 1 deletion cmd/vitconfig/vitconfig.go
Expand Up @@ -666,7 +666,7 @@ func main() {
for i, proposal := range payloadProposals[pt] {

// tmp - hash the proposal (TODO: decide what to hash in production, file bytes ???)
externalID := blake2b.Sum256([]byte(proposal.Proposal.ID + proposal.InternalID + pt))
externalID := blake2b.Sum256([]byte(proposal.Proposal.ID + strconv.FormatUint(proposal.InternalID, 10) + pt))
proposal.ChainProposal.ExternalID = hex.EncodeToString(externalID[:])

// retrieve the voteplan internal index based on the proposal index we are at
Expand Down
23 changes: 23 additions & 0 deletions cmd/vitresult/test_data/public_fund.json
@@ -0,0 +1,23 @@
{
"id": 1,
"fund_name": "Fund2",
"fund_goal": "How will we encourage developers and entrepreneurs to build Dapps and businesses on top of Cardano in the next 6 months?",
"voting_power_info": "2020-11-30T20:57:04Z",
"voting_power_threshold": 8000000000,
"rewards_info": "2020-12-08T21:02:04Z",
"fund_start_time": "2020-11-30T20:57:04+00:00",
"fund_end_time": "2020-11-30T21:02:04+00:00",
"next_fund_start_time": "2020-12-31T00:00:00+00:00",
"chain_vote_plans": [
{
"id": 1,
"chain_voteplan_id": "2573f0af477fc1f68072e3a529275f63f9ce3b6f35348757bcea3e5670e5726a",
"chain_vote_start_time": "2020-11-30T20:57:04+00:00",
"chain_vote_end_time": "2020-11-30T21:02:04+00:00",
"chain_committee_end_time": "2020-12-01T21:02:04+00:00",
"chain_voteplan_payload": "public",
"chain_vote_encryption_key": "",
"fund_id": 1
}
]
}
78 changes: 78 additions & 0 deletions cmd/vitresult/test_data/public_proposals.json
@@ -0,0 +1,78 @@
[
{
"internal_id": 1,
"proposal_id": "16444246",
"proposal_category": {
"category_id": "",
"category_name": "Fund2 challenge",
"category_description": ""
},
"proposal_title": "Test proposal 16444246",
"proposal_summary": "To test the proposal process 16444246",
"proposal_problem": "We haven't tested proposal integration yet 16444246",
"proposal_solution": "Test the proposal integration process 16444246",
"proposal_public_key": "Ae2tdPwUPEYwrazXRJVK4NgHSZCjP9kLSMrx2awgYiBH61zT8kz6u33Sije",
"proposal_funds": 1000246000000,
"proposal_url": "https://iohk.submittable.com/submissions/16444246",
"proposal_files_url": "https://iohk.submittable.com/submissions/16444246/file/0",
"proposal_impact_score": 50,
"proposer": {
"proposer_name": "IOHK 16444246",
"proposer_email": "iohk_16444246@iohk.io",
"proposer_url": "https://iohk.io",
"proposer_relevant_experience": "IOHK 16444246 - relevant experience"
},
"chain_proposal_id": "d7fa4e00e408751319c3bdb84e95fd0dcffb81107a2561e691c33c1ae635c2cd",
"chain_proposal_index": 0,
"chain_vote_options": {
"blank": 0,
"yes": 1,
"no": 2
},
"chain_voteplan_id": "2573f0af477fc1f68072e3a529275f63f9ce3b6f35348757bcea3e5670e5726a",
"chain_vote_start_time": "2020-11-30T20:57:04+00:00",
"chain_vote_end_time": "2020-11-30T21:02:04+00:00",
"chain_committee_end_time": "2020-12-01T21:02:04+00:00",
"chain_voteplan_payload": "public",
"chain_vote_encryption_key": "",
"fund_id": 1
},
{
"internal_id": 2,
"proposal_id": "16444247",
"proposal_category": {
"category_id": "",
"category_name": "Fund2 challenge",
"category_description": ""
},
"proposal_title": "Test proposal 16444247",
"proposal_summary": "To test the proposal process 16444247",
"proposal_problem": "We haven't tested proposal integration yet 16444247",
"proposal_solution": "Test the proposal integration process 16444247",
"proposal_public_key": "Ae2tdPwUPEYwrazXRJVK4NgHSZCjP9kLSMrx2awgYiBH61zT8kz6u33Sije",
"proposal_funds": 1000247000000,
"proposal_url": "https://iohk.submittable.com/submissions/16444247",
"proposal_files_url": "https://iohk.submittable.com/submissions/16444247/file/0",
"proposal_impact_score": 150,
"proposer": {
"proposer_name": "IOHK 16444247",
"proposer_email": "iohk_16444247@iohk.io",
"proposer_url": "https://iohk.io",
"proposer_relevant_experience": "IOHK 16444247 - relevant experience"
},
"chain_proposal_id": "a47fb2420f61532f5bc2739dc47e86293d26aaf718ed84dec2b1f9f91a6597c7",
"chain_proposal_index": 1,
"chain_vote_options": {
"no": 2,
"yes": 1,
"blank": 0
},
"chain_voteplan_id": "2573f0af477fc1f68072e3a529275f63f9ce3b6f35348757bcea3e5670e5726a",
"chain_vote_start_time": "2020-11-30T20:57:04+00:00",
"chain_vote_end_time": "2020-11-30T21:02:04+00:00",
"chain_committee_end_time": "2020-12-01T21:02:04+00:00",
"chain_voteplan_payload": "public",
"chain_vote_encryption_key": "",
"fund_id": 1
}
]
69 changes: 69 additions & 0 deletions cmd/vitresult/test_data/public_tally_result.json
@@ -0,0 +1,69 @@
[
{
"id": "2573f0af477fc1f68072e3a529275f63f9ce3b6f35348757bcea3e5670e5726a",
"payload": "public",
"vote_start": {
"epoch": 0,
"slot_id": 0
},
"vote_end": {
"epoch": 0,
"slot_id": 15
},
"committee_end": {
"epoch": 1,
"slot_id": 15
},
"committee_member_keys": [],
"proposals": [
{
"index": 0,
"proposal_id": "d7fa4e00e408751319c3bdb84e95fd0dcffb81107a2561e691c33c1ae635c2cd",
"options": {
"start": 0,
"end": 3
},
"tally": {
"Public": {
"result": {
"results": [
0,
1,
0
],
"options": {
"start": 0,
"end": 3
}
}
}
},
"votes_cast": 1
},
{
"index": 1,
"proposal_id": "a47fb2420f61532f5bc2739dc47e86293d26aaf718ed84dec2b1f9f91a6597c7",
"options": {
"start": 0,
"end": 3
},
"tally": {
"Public": {
"result": {
"results": [
0,
0,
1
],
"options": {
"start": 0,
"end": 3
}
}
}
},
"votes_cast": 1
}
]
}
]

0 comments on commit b29beda

Please sign in to comment.