Skip to content

Commit

Permalink
Paris DAL attestation fix (#508)
Browse files Browse the repository at this point in the history
* gotez v2.1.2 fixes Paris DAL attestation issue

* mod tidy

* gotez v2.1.3

* use correct  and  request type names while allowing legacy ones
  • Loading branch information
e-asphyx authored Oct 16, 2024
1 parent 5df0f7f commit a283606
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/certusone/yubihsm-go v0.3.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ecadlabs/goblst v1.0.0
github.com/ecadlabs/gotez/v2 v2.1.2
github.com/ecadlabs/gotez/v2 v2.1.3
github.com/go-playground/validator/v10 v10.16.0
github.com/google/tink/go v1.7.0
github.com/google/uuid v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/ecadlabs/goblst v1.0.0 h1:8/e3SQGwqbV0+ul+pg0aSNFfC3lgQcvEed3VdDBXSl8=
github.com/ecadlabs/goblst v1.0.0/go.mod h1:s67gqaOol9o6fguh+evH75X5uQniOhv1HG/EU8xPLPY=
github.com/ecadlabs/gotez/v2 v2.1.2 h1:6VVORG5cFhHsTLbJ5X5SxmK6OnlpmVM5iEOXQNTm5Z4=
github.com/ecadlabs/gotez/v2 v2.1.2/go.mod h1:QypK0m1eDPmB9R7Uvgmsfm+JS7Z5Y6dIbIq1tMVYayU=
github.com/ecadlabs/gotez/v2 v2.1.3 h1:RGNtvb+UAtstTQYCsdE4XAeaEZwj3a5AliLluEOsoAg=
github.com/ecadlabs/gotez/v2 v2.1.3/go.mod h1:QypK0m1eDPmB9R7Uvgmsfm+JS7Z5Y6dIbIq1tMVYayU=
github.com/ecadlabs/pretty v0.0.0-20230412124801-f948fc689a04 h1:7WdblGykGxtGGtchW4kzTaJJO8Fm+JKhLzhttOOWr9k=
github.com/ecadlabs/pretty v0.0.0-20230412124801-f948fc689a04/go.mod h1:VApUlocsLMpp4hUXHxTTIlosebnwo0BM6e1hy78qTPM=
github.com/enceve/crypto v0.0.0-20160707101852-34d48bb93815 h1:D22EM5TeYZJp43hGDx6dUng8mvtyYbB9BnE3+BmJR1Q=
Expand Down
18 changes: 15 additions & 3 deletions pkg/signatory/signatory.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *Signatory) logger() log.FieldLogger {
}

var defaultPolicy = PublicKeyPolicy{
AllowedRequests: []string{"block", "preendorsement", "endorsement"},
AllowedRequests: []string{"block", "preattestation", "attestation"},
}

func (s *Signatory) fetchPolicyOrDefault(keyHash crypt.PublicKeyHash) *PublicKeyPolicy {
Expand Down Expand Up @@ -596,6 +596,18 @@ func (s *Signatory) Ready(ctx context.Context) (bool, error) {
return true, nil
}

func fixupRequests(req []string) {
for i := range req {
switch req[i] {
case "endorsement":
req[i] = "attestation"
case "preendorsement":
req[i] = "preattestation"
}
}
sort.Strings(req)
}

// PreparePolicy prepares policy data by hashing keys etc
func PreparePolicy(src config.TezosConfig) (out Policy, err error) {
policy := make(Policy, len(src))
Expand All @@ -614,7 +626,7 @@ func PreparePolicy(src config.TezosConfig) (out Policy, err error) {
for req := range v.Allow {
pol.AllowedRequests = append(pol.AllowedRequests, req)
}
sort.Strings(pol.AllowedRequests)
fixupRequests(pol.AllowedRequests)

if ops, ok := v.Allow["generic"]; ok {
pol.AllowedOps = make([]string, len(ops))
Expand All @@ -625,7 +637,7 @@ func PreparePolicy(src config.TezosConfig) (out Policy, err error) {
if v.AllowedOperations != nil {
pol.AllowedRequests = make([]string, len(v.AllowedOperations))
copy(pol.AllowedRequests, v.AllowedOperations)
sort.Strings(pol.AllowedRequests)
fixupRequests(pol.AllowedRequests)
}
if v.AllowedKinds != nil {
pol.AllowedOps = make([]string, len(v.AllowedKinds))
Expand Down

0 comments on commit a283606

Please sign in to comment.