From 12ae503aa9ba7c454a17ec6b18802429979d0e73 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:41:14 -0400 Subject: [PATCH 1/4] encoding: eliminate unnecessary allocations (#5655) --- merklesignature/persistentMerkleSignatureScheme.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/merklesignature/persistentMerkleSignatureScheme.go b/merklesignature/persistentMerkleSignatureScheme.go index c862dcb965..a5e114a46a 100644 --- a/merklesignature/persistentMerkleSignatureScheme.go +++ b/merklesignature/persistentMerkleSignatureScheme.go @@ -98,7 +98,8 @@ func (s *Secrets) Persist(store db.Accessor) error { return fmt.Errorf("Secrets.Persist: %w", ErrKeyLifetimeIsZero) } round := indexToRound(s.FirstValid, s.KeyLifetime, 0) - encodedKey := protocol.GetEncodingBuf() + encodedBuf := protocol.GetEncodingBuf() + encodedKey := encodedBuf.Bytes() err := store.Atomic(func(ctx context.Context, tx *sql.Tx) error { err := InstallStateProofTable(tx) // assumes schema table already exists (created by partInstallDatabase) if err != nil { @@ -126,7 +127,7 @@ func (s *Secrets) Persist(store db.Accessor) error { return nil }) - protocol.PutEncodingBuf(encodedKey) + protocol.PutEncodingBuf(encodedBuf.Update(encodedKey)) if err != nil { return fmt.Errorf("Secrets.Persist: %w", err) } From 5cd72731b60bea43354347c7e67dc5ef45dbc120 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Fri, 1 Sep 2023 12:36:29 -0400 Subject: [PATCH 2/4] merklearray: simplify single-leaf proofs (#5703) --- merklearray/proof.go | 5 +++-- merklearray/proof_test.go | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/merklearray/proof.go b/merklearray/proof.go index 0489312035..3455baa08f 100644 --- a/merklearray/proof.go +++ b/merklearray/proof.go @@ -149,7 +149,7 @@ func (p *SingleLeafProof) GetConcatenatedProof() []byte { } // ProofDataToSingleLeafProof receives serialized proof data and uses it to construct a proof object. -func ProofDataToSingleLeafProof(hashTypeData string, treeDepth uint64, proofBytes []byte) (SingleLeafProof, error) { +func ProofDataToSingleLeafProof(hashTypeData string, proofBytes []byte) (SingleLeafProof, error) { hashType, err := crypto.UnmarshalHashType(hashTypeData) if err != nil { return SingleLeafProof{}, err @@ -158,7 +158,7 @@ func ProofDataToSingleLeafProof(hashTypeData string, treeDepth uint64, proofByte var proof SingleLeafProof proof.HashFactory = crypto.HashFactory{HashType: hashType} - proof.TreeDepth = uint8(treeDepth) + proof.TreeDepth = 0 digestSize := proof.HashFactory.NewHash().Size() if len(proofBytes)%digestSize != 0 { @@ -172,6 +172,7 @@ func ProofDataToSingleLeafProof(hashTypeData string, treeDepth uint64, proofByte copy(d[:], proofBytes) proofPath = append(proofPath, d[:]) proofBytes = proofBytes[len(d):] + proof.TreeDepth++ } proof.Path = proofPath diff --git a/merklearray/proof_test.go b/merklearray/proof_test.go index 9591d6ee41..a160371550 100644 --- a/merklearray/proof_test.go +++ b/merklearray/proof_test.go @@ -157,8 +157,9 @@ func TestConcatenatedProofsMissingChild(t *testing.T) { err = Verify(tree.Root(), map[uint64]crypto.Hashable{6: array[6]}, newP.ToProof()) a.NoError(err) - recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), uint64(p.TreeDepth), concatenatedProof) + recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), concatenatedProof) a.NoError(err) + a.Equal(recomputedProof.TreeDepth, p.TreeDepth) // verify that we can reconstruct the original singleLeafProof from the concatenated proof err = Verify(tree.Root(), map[uint64]crypto.Hashable{6: array[6]}, recomputedProof.ToProof()) @@ -189,8 +190,9 @@ func TestConcatenatedProofsFullTree(t *testing.T) { err = Verify(tree.Root(), map[uint64]crypto.Hashable{6: array[6]}, newP.ToProof()) a.NoError(err) - recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), uint64(p.TreeDepth), concatenatedProof) + recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), concatenatedProof) a.NoError(err) + a.Equal(recomputedProof.TreeDepth, p.TreeDepth) // verify that we can reconstruct the original singleLeafProof from the concatenated proof err = Verify(tree.Root(), map[uint64]crypto.Hashable{6: array[6]}, recomputedProof.ToProof()) @@ -218,8 +220,9 @@ func TestConcatenatedProofsOneLeaf(t *testing.T) { err = Verify(tree.Root(), map[uint64]crypto.Hashable{0: array[0]}, newP.ToProof()) a.NoError(err) - recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), uint64(p.TreeDepth), concatenatedProof) + recomputedProof, err := ProofDataToSingleLeafProof(p.HashFactory.HashType.String(), concatenatedProof) a.NoError(err) + a.Equal(recomputedProof.TreeDepth, p.TreeDepth) // verify that we can reconstruct the original singleLeafProof from the concatenated proof err = Verify(tree.Root(), map[uint64]crypto.Hashable{0: array[0]}, recomputedProof.ToProof()) @@ -230,7 +233,7 @@ func TestProofDeserializationError(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - _, err := ProofDataToSingleLeafProof(crypto.Sha256.String(), 1, []byte{1}) + _, err := ProofDataToSingleLeafProof(crypto.Sha256.String(), []byte{1}) a.ErrorIs(err, ErrProofLengthDigestSizeMismatch) } From c2d638ba71e57409142214628598c3e6363f525f Mon Sep 17 00:00:00 2001 From: "145173879+ohill@users.noreply.github.com" <145173879+ohill@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:08:59 -0400 Subject: [PATCH 3/4] Prep for remerge --- merklearray/msgp_gen.go | 16 ++--- merklesignature/msgp_gen.go | 24 +++---- msgp_gen.go | 136 ++++++++++++++++++------------------ stateproof/msgp_gen.go | 24 +++---- 4 files changed, 100 insertions(+), 100 deletions(-) diff --git a/merklearray/msgp_gen.go b/merklearray/msgp_gen.go index 20e8175898..db308439e0 100644 --- a/merklearray/msgp_gen.go +++ b/merklearray/msgp_gen.go @@ -73,11 +73,11 @@ func (_ Layer) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Layer) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var zb0002 int var zb0003 bool zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) @@ -191,11 +191,11 @@ func (_ *Proof) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Proof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -413,11 +413,11 @@ func (_ *SingleLeafProof) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *SingleLeafProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -642,11 +642,11 @@ func (_ *Tree) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Tree) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int diff --git a/merklesignature/msgp_gen.go b/merklesignature/msgp_gen.go index 9329caf04b..8cac8a7395 100644 --- a/merklesignature/msgp_gen.go +++ b/merklesignature/msgp_gen.go @@ -85,11 +85,11 @@ func (_ *Commitment) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Commitment) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -167,11 +167,11 @@ func (_ *KeyRoundPair) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *KeyRoundPair) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int @@ -347,11 +347,11 @@ func (_ *Secrets) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Secrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -522,11 +522,11 @@ func (_ *Signature) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int @@ -702,11 +702,11 @@ func (_ *SignerContext) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *SignerContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int @@ -859,11 +859,11 @@ func (_ *Verifier) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Verifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int diff --git a/msgp_gen.go b/msgp_gen.go index f143ef3e99..ab5bdceb88 100644 --- a/msgp_gen.go +++ b/msgp_gen.go @@ -366,11 +366,11 @@ func (_ *Digest) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Digest) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -420,11 +420,11 @@ func (_ *FalconPrivateKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconPrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -474,11 +474,11 @@ func (_ *FalconPublicKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconPublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -528,11 +528,11 @@ func (_ *FalconSeed) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconSeed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -585,11 +585,11 @@ func (_ FalconSignature) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconSignature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- { var zb0001 []byte var zb0002 int @@ -676,11 +676,11 @@ func (_ *FalconSigner) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconSigner) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int @@ -815,11 +815,11 @@ func (_ *FalconVerifier) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *FalconVerifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -925,11 +925,11 @@ func (_ GenericDigest) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *GenericDigest) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- { var zb0001 []byte var zb0002 int @@ -1007,11 +1007,11 @@ func (_ *HashFactory) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *HashFactory) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int @@ -1126,11 +1126,11 @@ func (_ HashType) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *HashType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- { var zb0001 uint16 zb0001, bts, err = msgp.ReadUint16Bytes(bts) @@ -1183,11 +1183,11 @@ func (_ *MasterDerivationKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *MasterDerivationKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -1277,11 +1277,11 @@ func (_ *MultisigSig) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *MultisigSig) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -1481,11 +1481,11 @@ func (_ *MultisigSubsig) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *MultisigSubsig) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int @@ -1623,11 +1623,11 @@ func (_ *OneTimeSignature) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0007 int @@ -1898,11 +1898,11 @@ func (_ *OneTimeSignatureSecrets) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignatureSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0006 int @@ -2256,11 +2256,11 @@ func (_ *OneTimeSignatureSecretsPersistent) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0006 int @@ -2537,11 +2537,11 @@ func (_ *OneTimeSignatureSubkeyBatchID) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -2668,11 +2668,11 @@ func (_ *OneTimeSignatureSubkeyOffsetID) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0002 int @@ -2804,11 +2804,11 @@ func (_ *OneTimeSignatureVerifier) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *OneTimeSignatureVerifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2858,11 +2858,11 @@ func (_ *PrivateKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *PrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2912,11 +2912,11 @@ func (_ *PublicKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *PublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2966,11 +2966,11 @@ func (_ *Seed) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Seed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3020,11 +3020,11 @@ func (_ *Signature) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3080,11 +3080,11 @@ func (_ *SignatureSecrets) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *SignatureSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int @@ -3210,11 +3210,11 @@ func (_ *VRFSecrets) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *VRFSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int @@ -3334,11 +3334,11 @@ func (_ *VrfOutput) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *VrfOutput) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3388,11 +3388,11 @@ func (_ *VrfPrivkey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *VrfPrivkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3442,11 +3442,11 @@ func (_ *VrfProof) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *VrfProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3496,11 +3496,11 @@ func (_ *VrfPubkey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *VrfPubkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3550,11 +3550,11 @@ func (_ *ed25519PrivateKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ed25519PrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3604,11 +3604,11 @@ func (_ *ed25519PublicKey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ed25519PublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3658,11 +3658,11 @@ func (_ *ed25519Seed) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ed25519Seed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3712,11 +3712,11 @@ func (_ *ed25519Signature) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ed25519Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3778,11 +3778,11 @@ func (_ *ephemeralSubkey) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ephemeralSubkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0005 int diff --git a/stateproof/msgp_gen.go b/stateproof/msgp_gen.go index bd50401899..51b3dc3848 100644 --- a/stateproof/msgp_gen.go +++ b/stateproof/msgp_gen.go @@ -89,11 +89,11 @@ func (_ *MessageHash) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *MessageHash) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -223,11 +223,11 @@ func (_ *Prover) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Prover) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0004 int @@ -574,11 +574,11 @@ func (_ *ProverPersistedFields) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *ProverPersistedFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0003 int @@ -891,11 +891,11 @@ func (_ *Reveal) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *Reveal) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int @@ -1229,11 +1229,11 @@ func (_ *StateProof) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *StateProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0004 int @@ -1562,11 +1562,11 @@ func (_ *sigslotCommit) CanMarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (z *sigslotCommit) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { - if st.Depth == 0 { + if st.AllowableDepth == 0 { err = msgp.ErrMaxDepthExceeded{} return } - st.Depth-- + st.AllowableDepth-- var field []byte _ = field var zb0001 int From b60bff4f8828de5974801aea9b72245e0e8e562c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:13:53 -0400 Subject: [PATCH 4/4] Build: bump golang.org/x/net from 0.12.0 to 0.17.0 (#5779) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chris erway --- stateproof/coinGenerator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stateproof/coinGenerator.go b/stateproof/coinGenerator.go index 1c019c869f..eb73e10f86 100644 --- a/stateproof/coinGenerator.go +++ b/stateproof/coinGenerator.go @@ -76,7 +76,7 @@ func makeCoinGenerator(choice *coinChoiceSeed) coinGenerator { choice.version = VersionForCoinGenerator rep := crypto.HashRep(choice) shk := sha3.NewShake256() - shk.Write(rep) //nolint:errcheck // ShakeHash.Write may panic, but does not return error + shk.Write(rep) // hash.Hash interface's Write may panic, but does not return error threshold := prepareRejectionSamplingThreshold(choice.signedWeight) return coinGenerator{shkContext: shk, signedWeight: choice.signedWeight, threshold: threshold}