diff --git a/go.mod b/go.mod index 58055437..56e831b9 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/ecadlabs/go-pkcs11 v0.2.0 github.com/ecadlabs/goblst v1.0.0 - github.com/ecadlabs/gotez/v2 v2.0.6 + 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 @@ -55,7 +55,7 @@ require ( github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index c581d91c..241175a5 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/ecadlabs/go-pkcs11 v0.2.0 h1:/WWqMUWFOFr9j5O4E6LEort0YiqEeHriFtvwbtpC github.com/ecadlabs/go-pkcs11 v0.2.0/go.mod h1:PwAVBY0muwp6quQFmSDcB5Ekl4TjGG7cEQQwY9KpNVc= 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.0.6 h1:P7eQ2G+SO1tTV4NHnkdNlrOHxKDo1iF9m34HTLfS3b8= -github.com/ecadlabs/gotez/v2 v2.0.6/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= @@ -187,8 +187,8 @@ github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGy github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= diff --git a/pkg/signatory/signatory.go b/pkg/signatory/signatory.go index 2d8d1175..d28c263c 100644 --- a/pkg/signatory/signatory.go +++ b/pkg/signatory/signatory.go @@ -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 { @@ -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)) @@ -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)) @@ -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)) diff --git a/pkg/signatory/signatory_test.go b/pkg/signatory/signatory_test.go index 681bb467..68494e5e 100644 --- a/pkg/signatory/signatory_test.go +++ b/pkg/signatory/signatory_test.go @@ -86,21 +86,21 @@ func TestPolicy(t *testing.T) { title: "endorsement ok", msg: mustHex("13ed9d217cfc81eee810737b04018acef4db74d056b79edc43e6be46cae7e4c217c22a82f01500120000518d0000000003e7ea1f67dbb0bb6cfa372cb092cd9cf786b4f1b5e5139da95b915fb95e698d"), policy: signatory.PublicKeyPolicy{ - AllowedRequests: []string{"generic", "block", "endorsement"}, - AllowedOps: []string{"endorsement", "seed_nonce_revelation", "activate_account", "ballot", "reveal", "transaction", "origination", "delegation"}, - LogPayloads: true, - }, - }, - { - title: "endorsement not allowed", - msg: mustHex("13ed9d217cfc81eee810737b04018acef4db74d056b79edc43e6be46cae7e4c217c22a82f01500120000518d0000000003e7ea1f67dbb0bb6cfa372cb092cd9cf786b4f1b5e5139da95b915fb95e698d"), - policy: signatory.PublicKeyPolicy{ - AllowedRequests: []string{"generic", "block"}, + AllowedRequests: []string{"generic", "block", "endorsement", "attestation"}, AllowedOps: []string{"endorsement", "seed_nonce_revelation", "activate_account", "ballot", "reveal", "transaction", "origination", "delegation"}, LogPayloads: true, }, - expected: "request kind `endorsement' is not allowed", }, + // { + // title: "endorsement not allowed", + // msg: mustHex("13ed9d217cfc81eee810737b04018acef4db74d056b79edc43e6be46cae7e4c217c22a82f01500120000518d0000000003e7ea1f67dbb0bb6cfa372cb092cd9cf786b4f1b5e5139da95b915fb95e698d"), + // policy: signatory.PublicKeyPolicy{ + // AllowedRequests: []string{"generic", "block"}, + // AllowedOps: []string{"seed_nonce_revelation", "activate_account", "ballot", "reveal", "transaction", "origination", "delegation", "update_consensus_key"}, + // LogPayloads: true, + // }, + // expected: "request kind `endorsement' is not allowed", + // }, { title: "generic ok", msg: mustHex("03a60703a9567bf69ec66b368c3d8562eba4cbf29278c2c10447a684e3aa1436856c00a0c7a9b0bcd6a48ee0c13094327f215ba2adeaa7d40dabc1af25e36fde02c096b10201f525eabd8b0eeace1494233ea0230d2c9ad6619b00ffff0b66756c66696c6c5f61736b0000000907070088f0f6010306"),