Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new vote extenison type THRESHOLD_RAW #715

Merged
merged 57 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ffda052
feat: allow passing sign id used to sign vote extensions
lklimek Dec 12, 2023
4e1028f
chore: improve docs
lklimek Dec 12, 2023
8040f9f
chore: rename proto sign_id
lklimek Dec 12, 2023
222bbd3
chore: doc
lklimek Dec 12, 2023
c8722f9
doc: typo
lklimek Dec 12, 2023
1e28df1
feat: add vote extension sign request id
lklimek Dec 12, 2023
37a1b36
test: fix tests build
lklimek Dec 12, 2023
37340ab
chore: remove printf
lklimek Dec 12, 2023
459d279
doc: proto THRESHOLD_RECOVER_RAW docs
lklimek Dec 12, 2023
6978fc6
chore: vote extension fixes
lklimek Dec 13, 2023
7ede91c
chore: self review
lklimek Dec 13, 2023
92779a1
chore: fix tests
lklimek Dec 13, 2023
d03eea9
fix: tests
lklimek Dec 13, 2023
449a8f3
chore: code cleanup
lklimek Dec 13, 2023
903b2ae
feat: allow pwldtx prefix in sign_request_id
lklimek Dec 14, 2023
58f0db1
fix: return checksum of SignRequestId
lklimek Dec 14, 2023
9e1b291
doc: update api spec
lklimek Dec 14, 2023
ed330eb
chore: change prefix
lklimek Dec 14, 2023
ca7be85
refactor: sign item refactoring and removal of reversals in sign id
lklimek Dec 15, 2023
4da18ba
test: update test vectors in TestVoteExtensionsRawSignDataRawVector
lklimek Dec 15, 2023
b9071af
refactor: SIgnItem moved to crypto and replaces all crypto.SignID calls
lklimek Dec 15, 2023
815a4a0
test: fix tests
lklimek Dec 15, 2023
34fd62c
refactor(types): vote extensions support for multiple types
lklimek Dec 20, 2023
a0af38f
test(e2e): workaround for broken ConsensusParams
lklimek Dec 20, 2023
d6e1d9c
refactor: vote extensions refactoring
lklimek Dec 20, 2023
59a9262
refactor: further vote extensions refactoring
lklimek Dec 21, 2023
b3de990
Merge remote-tracking branch 'origin/v0.14-dev' into feat/vote-extens…
lklimek Dec 21, 2023
12884fd
chore: don't reverse signhash
lklimek Dec 21, 2023
658131a
test: update sign id test vectors
lklimek Dec 21, 2023
f93f40e
test(e2e): double-check that each vote extension has signature
lklimek Dec 21, 2023
50f35c3
test: fix test vector
lklimek Dec 21, 2023
5f5ded8
build: allow choice of docker image architecture to use
lklimek Dec 21, 2023
9e1d9a1
test(e2e): TestApp_TxTooBig needs correct tx order
lklimek Dec 21, 2023
615251a
fix: vote extension marshal panic
lklimek Dec 21, 2023
b158f3b
build: fix platform selection for docker build
lklimek Dec 21, 2023
db1e2f0
test(types): test vote extension marshaling
lklimek Dec 21, 2023
b7c67dc
chore: reverse sign request id
lklimek Jan 3, 2024
d9eca5e
chore: simplify code
lklimek Jan 3, 2024
8018594
chore: remove reverse
lklimek Jan 3, 2024
78eb049
refactor: rename SignItem.Raw -> Msg
lklimek Jan 4, 2024
3b9f869
chore: reverse bytes in extension and require 32 bytes for RAW
lklimek Jan 4, 2024
55b8327
chore: reverse generated request id
lklimek Jan 4, 2024
1757ecc
chore: add debug
lklimek Jan 4, 2024
77eaa48
test: working test vector for withdrawals
lklimek Jan 4, 2024
a10c82a
test: withdrawals
lklimek Jan 5, 2024
638d475
test: vote extension test fix
lklimek Jan 29, 2024
8bdd48d
test(consensus): fix vote extension tests
lklimek Jan 29, 2024
e0c9d56
chore: update protobuf
lklimek Jan 29, 2024
b6f4ca9
revert: move SignItem back to types
lklimek Jan 29, 2024
a6c5cf0
chore: remove log
lklimek Jan 30, 2024
85e4810
Merge remote-tracking branch 'origin/v0.14-dev' into feat/vote-extens…
lklimek Jan 31, 2024
e3810d8
build: update golangci-lint 1.55.0 to 1.55.2
lklimek Jan 31, 2024
62af8fc
chore: apply linter comments
lklimek Jan 31, 2024
b052983
chore: decrease logs size
lklimek Jan 31, 2024
3731326
test(e2e): increase e2e test timeout
lklimek Jan 31, 2024
61eb29a
chore: text
lklimek Jan 31, 2024
1ba6448
test(e2e): increase timeout
lklimek Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ on:
type: string
description: "Docker tag"
required: false

platforms:
type: choice
description: "Image architecture to build"
default: "linux/amd64,linux/arm64"
options:
- "linux/amd64,linux/arm64"
- "linux/amd64"
- "linux/arm64"
release:
types:
- published
Expand Down Expand Up @@ -79,7 +88,7 @@ jobs:
with:
context: .
file: ./DOCKER/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event.inputs.platforms }}
target: base
push: false
cache-from: |
Expand All @@ -95,7 +104,7 @@ jobs:
with:
context: .
file: ./DOCKER/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event.inputs.platforms }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down
4 changes: 2 additions & 2 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali
if app.shouldCommitVerify {
vsu := app.getActiveValidatorSetUpdates()
qsd := types.QuorumSignData{
Block: makeBlockSignItem(req, btcjson.LLMQType_5_60, vsu.QuorumHash),
Extensions: makeVoteExtensionSignItems(req, btcjson.LLMQType_5_60, vsu.QuorumHash),
Block: makeBlockSignItem(req, btcjson.LLMQType_5_60, vsu.QuorumHash),
VoteExtensionSignItems: makeVoteExtensionSignItems(req, btcjson.LLMQType_5_60, vsu.QuorumHash),
}
err := app.verifyBlockCommit(qsd, req.Commit)
if err != nil {
Expand Down
49 changes: 16 additions & 33 deletions abci/example/kvstore/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
abci "github.com/dashpay/tenderdash/abci/types"
"github.com/dashpay/tenderdash/crypto/encoding"
tmbytes "github.com/dashpay/tenderdash/libs/bytes"
types1 "github.com/dashpay/tenderdash/proto/tendermint/types"
"github.com/dashpay/tenderdash/types"
)

Expand All @@ -23,27 +22,16 @@ func (app *Application) verifyBlockCommit(qsd types.QuorumSignData, commit abci.
if err != nil {
return err
}
return verifier.Verify(pubKey, types.QuorumSigns{
BlockSign: commit.BlockSignature,
ExtensionSigns: makeThresholdVoteExtensions(commit.ThresholdVoteExtensions),
})
}

func makeThresholdVoteExtensions(pbVoteExtensions []*types1.VoteExtension) []types.ThresholdExtensionSign {
voteExtensions := types.VoteExtensionsFromProto(pbVoteExtensions)
var thresholdExtensionSigns []types.ThresholdExtensionSign
thresholdVoteExtensions, ok := voteExtensions[types1.VoteExtensionType_THRESHOLD_RECOVER]
if !ok {
return nil
extSigs := make([][]byte, 0, len(commit.ThresholdVoteExtensions))
for _, ext := range commit.ThresholdVoteExtensions {
extSigs = append(extSigs, ext.Signature)
}
thresholdExtensionSigns = make([]types.ThresholdExtensionSign, len(thresholdVoteExtensions))
for i, voteExtension := range thresholdVoteExtensions {
thresholdExtensionSigns[i] = types.ThresholdExtensionSign{
Extension: voteExtension.Extension,
ThresholdSignature: voteExtension.Signature,
}
}
return thresholdExtensionSigns

return verifier.Verify(pubKey, types.QuorumSigns{
BlockSign: commit.BlockSignature,
VoteExtensionSignatures: extSigs,
})
}

func makeBlockSignItem(
Expand All @@ -67,19 +55,14 @@ func makeVoteExtensionSignItems(
req *abci.RequestFinalizeBlock,
quorumType btcjson.LLMQType,
quorumHash []byte,
) map[types1.VoteExtensionType][]types.SignItem {
items := make(map[types1.VoteExtensionType][]types.SignItem)
reqID := types.VoteExtensionRequestID(req.Height, req.Round)
protoExtensionsMap := types1.VoteExtensionsToMap(req.Commit.ThresholdVoteExtensions)
for t, exts := range protoExtensionsMap {
if items[t] == nil && len(exts) > 0 {
items[t] = make([]types.SignItem, len(exts))
}
chainID := req.Block.Header.ChainID
for i, ext := range exts {
raw := types.VoteExtensionSignBytes(chainID, req.Height, req.Round, ext)
items[t][i] = types.NewSignItem(quorumType, quorumHash, reqID, raw)
}
) []types.SignItem {

extensions := types.VoteExtensionsFromProto(req.Commit.ThresholdVoteExtensions...)
chainID := req.Block.Header.ChainID

items, err := extensions.SignItems(chainID, quorumType, quorumHash, req.Height, req.Round)
if err != nil {
panic(fmt.Errorf("vote extension sign items: %w", err))
}
return items
}
20 changes: 20 additions & 0 deletions abci/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,23 @@ func (m *RequestFinalizeBlock) ToCanonicalVote() (types.CanonicalVote, error) {
}
return cv, nil
}

// Convert to proto.types.VoteExtension.
// Signature field will be nil, as ExtendVoteExtension doesn't have it.
func (m *ExtendVoteExtension) ToVoteExtension() types.VoteExtension {
ve := types.VoteExtension{
Type: m.Type,
Extension: m.Extension,
}

// workaround for a bug in gogoproto
if m.XSignRequestId != nil {
src := m.GetSignRequestId()

ve.XSignRequestId = &types.VoteExtension_SignRequestId{
SignRequestId: bytes.Clone(src),
}
}

return ve
}
Loading
Loading