From a821e07b9464a9a289cef857f87f3fd9963cb7cf Mon Sep 17 00:00:00 2001 From: John Lee Date: Mon, 2 Oct 2023 12:42:47 -0400 Subject: [PATCH 1/2] Bump buildnumber.dat --- buildnumber.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildnumber.dat b/buildnumber.dat index 573541ac97..d00491fd7e 100644 --- a/buildnumber.dat +++ b/buildnumber.dat @@ -1 +1 @@ -0 +1 From 4c6d2b9ee9c1f55d01c63db88d50b3a29de289e4 Mon Sep 17 00:00:00 2001 From: ohill <145173879+ohill@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:31:39 -0400 Subject: [PATCH 2/2] Changes for relstable3.18.1 --- agreement/msgp_gen.go | 1250 ++++++++++------ crypto/merklearray/msgp_gen.go | 70 +- crypto/merklesignature/msgp_gen.go | 90 +- crypto/msgp_gen.go | 394 ++++- crypto/stateproof/msgp_gen.go | 114 +- daemon/algod/api/spec/v2/msgp_gen.go | 38 +- data/account/msgp_gen.go | 44 +- data/basics/msgp_gen.go | 386 +++-- data/basics/units.go | 8 + data/bookkeeping/msgp_gen.go | 377 +++-- data/committee/msgp_gen.go | 68 +- data/hashable/msgp_gen.go | 11 +- data/stateproofmsg/msgp_gen.go | 11 +- data/transactions/msgp_gen.go | 647 ++++++--- go.mod | 2 + ledger/encoded/msgp_gen.go | 53 +- ledger/ledgercore/msgp_gen.go | 92 +- ledger/msgp_gen.go | 87 +- ledger/store/trackerdb/generickv/msgp_gen.go | 15 +- ledger/store/trackerdb/msgp_gen.go | 224 ++- msgp/.gitignore | 13 + msgp/.travis.yml | 11 + msgp/LICENSE | 8 + msgp/Makefile | 47 + msgp/README.md | 4 + msgp/gen/elem.go | 992 +++++++++++++ msgp/gen/iszero.go | 68 + msgp/gen/marshal.go | 393 +++++ msgp/gen/maxsize.go | 379 +++++ msgp/gen/size.go | 325 +++++ msgp/gen/spec.go | 554 +++++++ msgp/gen/testgen.go | 104 ++ msgp/gen/topics.go | 48 + msgp/gen/unmarshal.go | 358 +++++ msgp/go.mod | 19 + msgp/go.sum | 27 + msgp/issue185_test.go | 312 ++++ msgp/main.go | 117 ++ msgp/msgp/defs.go | 142 ++ msgp/msgp/defs_test.go | 12 + msgp/msgp/elsize.go | 99 ++ msgp/msgp/errors.go | 354 +++++ msgp/msgp/errors_test.go | 89 ++ msgp/msgp/extension.go | 287 ++++ msgp/msgp/extension_test.go | 30 + msgp/msgp/floatbench_test.go | 25 + msgp/msgp/int.go | 20 + msgp/msgp/integers.go | 174 +++ msgp/msgp/read.go | 91 ++ msgp/msgp/read_bytes.go | 1359 ++++++++++++++++++ msgp/msgp/read_bytes_test.go | 100 ++ msgp/msgp/size.go | 39 + msgp/msgp/write.go | 65 + msgp/msgp/write_bytes.go | 288 ++++ msgp/msgp/write_bytes_test.go | 140 ++ msgp/msgp/write_test.go | 24 + msgp/parse/directives.go | 194 +++ msgp/parse/directives_test.go | 53 + msgp/parse/getast.go | 818 +++++++++++ msgp/parse/inline.go | 175 +++ msgp/printer/print.go | 168 +++ msgp/printer/print_test.go | 19 + network/msgp_gen.go | 116 +- node/msgp_gen.go | 34 +- protocol/msgp_gen.go | 77 +- protocol/test/msgp_gen.go | 11 +- rpcs/msgp_gen.go | 19 +- scripts/check_license.sh | 2 +- stateproof/msgp_gen.go | 50 +- tools/block-generator/go.mod | 1 + tools/x-repo-types/go.mod | 1 + 71 files changed, 11620 insertions(+), 1216 deletions(-) create mode 100644 msgp/.gitignore create mode 100644 msgp/.travis.yml create mode 100644 msgp/LICENSE create mode 100644 msgp/Makefile create mode 100644 msgp/README.md create mode 100644 msgp/gen/elem.go create mode 100644 msgp/gen/iszero.go create mode 100644 msgp/gen/marshal.go create mode 100644 msgp/gen/maxsize.go create mode 100644 msgp/gen/size.go create mode 100644 msgp/gen/spec.go create mode 100644 msgp/gen/testgen.go create mode 100644 msgp/gen/topics.go create mode 100644 msgp/gen/unmarshal.go create mode 100644 msgp/go.mod create mode 100644 msgp/go.sum create mode 100644 msgp/issue185_test.go create mode 100644 msgp/main.go create mode 100644 msgp/msgp/defs.go create mode 100644 msgp/msgp/defs_test.go create mode 100644 msgp/msgp/elsize.go create mode 100644 msgp/msgp/errors.go create mode 100644 msgp/msgp/errors_test.go create mode 100644 msgp/msgp/extension.go create mode 100644 msgp/msgp/extension_test.go create mode 100644 msgp/msgp/floatbench_test.go create mode 100644 msgp/msgp/int.go create mode 100644 msgp/msgp/integers.go create mode 100644 msgp/msgp/read.go create mode 100644 msgp/msgp/read_bytes.go create mode 100644 msgp/msgp/read_bytes_test.go create mode 100644 msgp/msgp/size.go create mode 100644 msgp/msgp/write.go create mode 100644 msgp/msgp/write_bytes.go create mode 100644 msgp/msgp/write_bytes_test.go create mode 100644 msgp/msgp/write_test.go create mode 100644 msgp/parse/directives.go create mode 100644 msgp/parse/directives_test.go create mode 100644 msgp/parse/getast.go create mode 100644 msgp/parse/inline.go create mode 100644 msgp/printer/print.go create mode 100644 msgp/printer/print_test.go diff --git a/agreement/msgp_gen.go b/agreement/msgp_gen.go index d083edd8e8..90de4bd8a5 100644 --- a/agreement/msgp_gen.go +++ b/agreement/msgp_gen.go @@ -20,6 +20,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -29,6 +30,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -38,6 +40,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -47,6 +50,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -56,6 +60,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -65,6 +70,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -74,6 +80,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -83,6 +90,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -92,6 +100,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -101,6 +110,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -110,6 +120,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -119,6 +130,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -128,6 +140,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -137,6 +150,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -146,6 +160,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -155,6 +170,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -164,6 +180,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -173,6 +190,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -182,6 +200,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -191,6 +210,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -200,6 +220,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -209,6 +230,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -218,6 +240,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -227,6 +250,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -236,6 +260,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -245,6 +270,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -254,6 +280,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -263,6 +290,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -272,6 +300,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -281,6 +310,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -290,6 +320,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -299,6 +330,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -308,6 +340,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -317,6 +350,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -326,6 +360,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -335,6 +370,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -344,6 +380,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -353,6 +390,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -362,6 +400,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -371,6 +410,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -380,6 +420,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -389,6 +430,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -398,6 +440,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -407,6 +450,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -416,6 +460,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -425,6 +470,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -434,6 +480,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -443,6 +490,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -452,6 +500,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -461,6 +510,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -554,7 +604,12 @@ func (_ *Certificate) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Certificate) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -568,7 +623,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -600,7 +655,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -628,7 +683,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]voteAuthenticator, zb0007) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) return @@ -657,7 +712,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0009) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) return @@ -688,7 +743,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -714,7 +769,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Step = step(zb0012) } case "prop": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return @@ -740,7 +795,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]voteAuthenticator, zb0013) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Votes", zb0001) return @@ -767,7 +822,7 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0015) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EquivocationVotes", zb0002) return @@ -786,6 +841,9 @@ func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Certificate) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Certificate) return ok @@ -843,7 +901,12 @@ func (_ *ConsensusVersionView) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ConsensusVersionView) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ConsensusVersionView) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -880,7 +943,7 @@ func (z *ConsensusVersionView) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Version.UnmarshalMsg(bts) + bts, err = (*z).Version.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Version") return @@ -931,7 +994,7 @@ func (z *ConsensusVersionView) UnmarshalMsg(bts []byte) (o []byte, err error) { } } case "Version": - bts, err = (*z).Version.UnmarshalMsg(bts) + bts, err = (*z).Version.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Version") return @@ -949,6 +1012,9 @@ func (z *ConsensusVersionView) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ConsensusVersionView) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ConsensusVersionView) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ConsensusVersionView) return ok @@ -998,7 +1064,12 @@ func (_ *Deadline) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Deadline) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Deadline) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1082,6 +1153,9 @@ func (z *Deadline) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Deadline) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Deadline) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Deadline) return ok @@ -1120,7 +1194,12 @@ func (_ TimeoutType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TimeoutType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TimeoutType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 int8 zb0001, bts, err = msgp.ReadInt8Bytes(bts) @@ -1134,6 +1213,9 @@ func (z *TimeoutType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TimeoutType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TimeoutType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TimeoutType) return ok @@ -1172,7 +1254,12 @@ func (_ actionType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *actionType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *actionType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint8 zb0001, bts, err = msgp.ReadUint8Bytes(bts) @@ -1186,6 +1273,9 @@ func (z *actionType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *actionType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *actionType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*actionType) return ok @@ -1243,7 +1333,12 @@ func (_ *blockAssembler) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *blockAssembler) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -1257,7 +1352,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Pipeline.UnmarshalMsg(bts) + bts, err = (*z).Pipeline.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Pipeline") return @@ -1273,7 +1368,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Payload.UnmarshalMsg(bts) + bts, err = (*z).Payload.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Payload") return @@ -1304,7 +1399,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Authenticators = make([]vote, zb0004) } for zb0001 := range (*z).Authenticators { - bts, err = (*z).Authenticators[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Authenticators[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Authenticators", zb0001) return @@ -1335,7 +1430,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Pipeline": - bts, err = (*z).Pipeline.UnmarshalMsg(bts) + bts, err = (*z).Pipeline.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Pipeline") return @@ -1347,7 +1442,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Payload": - bts, err = (*z).Payload.UnmarshalMsg(bts) + bts, err = (*z).Payload.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Payload") return @@ -1374,7 +1469,7 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Authenticators = make([]vote, zb0006) } for zb0001 := range (*z).Authenticators { - bts, err = (*z).Authenticators[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Authenticators[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Authenticators", zb0001) return @@ -1393,6 +1488,9 @@ func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *blockAssembler) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *blockAssembler) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*blockAssembler) return ok @@ -1480,7 +1578,12 @@ func (_ *bundle) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *bundle) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -1494,7 +1597,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).U.UnmarshalMsg(bts) + bts, err = (*z).U.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "U") return @@ -1522,7 +1625,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]vote, zb0005) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) return @@ -1551,7 +1654,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVote, zb0007) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) return @@ -1582,7 +1685,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "u": - bts, err = (*z).U.UnmarshalMsg(bts) + bts, err = (*z).U.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "U") return @@ -1608,7 +1711,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]vote, zb0009) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Votes", zb0001) return @@ -1635,7 +1738,7 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVote, zb0011) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EquivocationVotes", zb0002) return @@ -1654,6 +1757,9 @@ func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *bundle) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*bundle) return ok @@ -1707,7 +1813,12 @@ func (_ *compoundMessage) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *compoundMessage) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1721,7 +1832,7 @@ func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Vote.UnmarshalMsg(bts) + bts, err = (*z).Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Vote") return @@ -1729,7 +1840,7 @@ func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -1759,13 +1870,13 @@ func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Vote": - bts, err = (*z).Vote.UnmarshalMsg(bts) + bts, err = (*z).Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Vote") return } case "Proposal": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return @@ -1783,6 +1894,9 @@ func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *compoundMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *compoundMessage) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*compoundMessage) return ok @@ -1847,7 +1961,12 @@ func (_ *diskState) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *diskState) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *diskState) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -2037,6 +2156,9 @@ func (z *diskState) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *diskState) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *diskState) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*diskState) return ok @@ -2161,7 +2283,12 @@ func (_ *equivocationVote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *equivocationVote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -2175,7 +2302,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -2183,7 +2310,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -2215,7 +2342,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -2234,7 +2361,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } for zb0001 := 0; zb0001 < zb0007; zb0001++ { - bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0001) return @@ -2254,7 +2381,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } for zb0002 := 0; zb0002 < zb0008; zb0002++ { - bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0002) return @@ -2285,13 +2412,13 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -2317,7 +2444,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Step = step(zb0010) } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return @@ -2334,7 +2461,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } for zb0001 := 0; zb0001 < zb0011; zb0001++ { - bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposals", zb0001) return @@ -2352,7 +2479,7 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } for zb0002 := 0; zb0002 < zb0012; zb0002++ { - bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sigs", zb0002) return @@ -2371,6 +2498,9 @@ func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *equivocationVote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*equivocationVote) return ok @@ -2441,7 +2571,12 @@ func (_ *equivocationVoteAuthenticator) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *equivocationVoteAuthenticator) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -2455,7 +2590,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err } if zb0003 > 0 { zb0003-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -2463,7 +2598,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err } if zb0003 > 0 { zb0003-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -2482,7 +2617,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err return } for zb0001 := 0; zb0001 < zb0005; zb0001++ { - bts, err = (*z).Sigs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0001) return @@ -2502,7 +2637,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err return } for zb0002 := 0; zb0002 < zb0006; zb0002++ { - bts, err = (*z).Proposals[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0002) return @@ -2533,13 +2668,13 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return @@ -2556,7 +2691,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err return } for zb0001 := 0; zb0001 < zb0007; zb0001++ { - bts, err = (*z).Sigs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sigs", zb0001) return @@ -2574,7 +2709,7 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err return } for zb0002 := 0; zb0002 < zb0008; zb0002++ { - bts, err = (*z).Proposals[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposals", zb0002) return @@ -2593,6 +2728,9 @@ func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err return } +func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *equivocationVoteAuthenticator) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*equivocationVoteAuthenticator) return ok @@ -2643,7 +2781,12 @@ func (_ eventType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *eventType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *eventType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint8 zb0001, bts, err = msgp.ReadUint8Bytes(bts) @@ -2657,6 +2800,9 @@ func (z *eventType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *eventType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *eventType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*eventType) return ok @@ -2704,7 +2850,12 @@ func (_ *freshnessData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *freshnessData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *freshnessData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2718,7 +2869,7 @@ func (z *freshnessData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).PlayerRound.UnmarshalMsg(bts) + bts, err = (*z).PlayerRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "PlayerRound") return @@ -2784,7 +2935,7 @@ func (z *freshnessData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "PlayerRound": - bts, err = (*z).PlayerRound.UnmarshalMsg(bts) + bts, err = (*z).PlayerRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "PlayerRound") return @@ -2832,6 +2983,9 @@ func (z *freshnessData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *freshnessData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *freshnessData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*freshnessData) return ok @@ -2912,7 +3066,12 @@ func (_ *message) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *message) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2926,7 +3085,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).MessageHandle.UnmarshalMsg(bts) + bts, err = (*z).MessageHandle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MessageHandle") return @@ -2934,7 +3093,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Tag.UnmarshalMsg(bts) + bts, err = (*z).Tag.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Tag") return @@ -2942,7 +3101,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Vote.UnmarshalMsg(bts) + bts, err = (*z).Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Vote") return @@ -2950,7 +3109,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -2958,7 +3117,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Bundle.UnmarshalMsg(bts) + bts, err = (*z).Bundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Bundle") return @@ -2966,7 +3125,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UnauthenticatedVote.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedVote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UnauthenticatedVote") return @@ -2974,7 +3133,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UnauthenticatedProposal.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedProposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UnauthenticatedProposal") return @@ -2982,7 +3141,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UnauthenticatedBundle.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedBundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UnauthenticatedBundle") return @@ -3001,7 +3160,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).CompoundMessage.Vote.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CompoundMessage", "struct-from-array", "Vote") return @@ -3009,7 +3168,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CompoundMessage", "struct-from-array", "Proposal") return @@ -3039,13 +3198,13 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Vote": - bts, err = (*z).CompoundMessage.Vote.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CompoundMessage", "Vote") return } case "Proposal": - bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CompoundMessage", "Proposal") return @@ -3084,49 +3243,49 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "MessageHandle": - bts, err = (*z).MessageHandle.UnmarshalMsg(bts) + bts, err = (*z).MessageHandle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MessageHandle") return } case "Tag": - bts, err = (*z).Tag.UnmarshalMsg(bts) + bts, err = (*z).Tag.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Tag") return } case "Vote": - bts, err = (*z).Vote.UnmarshalMsg(bts) + bts, err = (*z).Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Vote") return } case "Proposal": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return } case "Bundle": - bts, err = (*z).Bundle.UnmarshalMsg(bts) + bts, err = (*z).Bundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Bundle") return } case "UnauthenticatedVote": - bts, err = (*z).UnauthenticatedVote.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedVote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UnauthenticatedVote") return } case "UnauthenticatedProposal": - bts, err = (*z).UnauthenticatedProposal.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedProposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UnauthenticatedProposal") return } case "UnauthenticatedBundle": - bts, err = (*z).UnauthenticatedBundle.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedBundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UnauthenticatedBundle") return @@ -3143,7 +3302,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).CompoundMessage.Vote.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CompoundMessage", "struct-from-array", "Vote") return @@ -3151,7 +3310,7 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CompoundMessage", "struct-from-array", "Proposal") return @@ -3181,13 +3340,13 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Vote": - bts, err = (*z).CompoundMessage.Vote.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Vote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CompoundMessage", "Vote") return } case "Proposal": - bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsg(bts) + bts, err = (*z).CompoundMessage.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CompoundMessage", "Proposal") return @@ -3214,6 +3373,9 @@ func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *message) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *message) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*message) return ok @@ -3280,7 +3442,12 @@ func (_ *messageEvent) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *messageEvent) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3306,7 +3473,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Input.UnmarshalMsg(bts) + bts, err = (*z).Input.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Input") return @@ -3355,7 +3522,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Tail == nil { (*z).Tail = new(messageEvent) } - bts, err = (*z).Tail.UnmarshalMsg(bts) + bts, err = (*z).Tail.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Tail") return @@ -3372,7 +3539,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proto") return @@ -3412,7 +3579,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).T = eventType(zb0005) } case "Input": - bts, err = (*z).Input.UnmarshalMsg(bts) + bts, err = (*z).Input.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Input") return @@ -3455,7 +3622,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Tail == nil { (*z).Tail = new(messageEvent) } - bts, err = (*z).Tail.UnmarshalMsg(bts) + bts, err = (*z).Tail.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Tail") return @@ -3468,7 +3635,7 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Proto": - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proto") return @@ -3486,6 +3653,9 @@ func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *messageEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *messageEvent) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*messageEvent) return ok @@ -3543,7 +3713,12 @@ func (_ *nextThresholdStatusEvent) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *nextThresholdStatusEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *nextThresholdStatusEvent) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3565,7 +3740,7 @@ func (z *nextThresholdStatusEvent) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -3601,7 +3776,7 @@ func (z *nextThresholdStatusEvent) UnmarshalMsg(bts []byte) (o []byte, err error return } case "Proposal": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return @@ -3619,6 +3794,9 @@ func (z *nextThresholdStatusEvent) UnmarshalMsg(bts []byte) (o []byte, err error return } +func (z *nextThresholdStatusEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *nextThresholdStatusEvent) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*nextThresholdStatusEvent) return ok @@ -3657,7 +3835,12 @@ func (_ period) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *period) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *period) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -3671,6 +3854,9 @@ func (z *period) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *period) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *period) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*period) return ok @@ -3737,7 +3923,12 @@ func (_ *periodRouter) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *periodRouter) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -3751,7 +3942,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).ProposalTracker.UnmarshalMsg(bts) + bts, err = (*z).ProposalTracker.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ProposalTracker") return @@ -3759,7 +3950,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).VoteTrackerPeriod.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerPeriod.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteTrackerPeriod") return @@ -3767,7 +3958,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).ProposalTrackerContract.UnmarshalMsg(bts) + bts, err = (*z).ProposalTrackerContract.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ProposalTrackerContract") return @@ -3791,7 +3982,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 step var zb0002 *stepRouter zb0005-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children") return @@ -3806,7 +3997,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(stepRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children", zb0001) return @@ -3839,19 +4030,19 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "ProposalTracker": - bts, err = (*z).ProposalTracker.UnmarshalMsg(bts) + bts, err = (*z).ProposalTracker.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ProposalTracker") return } case "VoteTrackerPeriod": - bts, err = (*z).VoteTrackerPeriod.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerPeriod.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteTrackerPeriod") return } case "ProposalTrackerContract": - bts, err = (*z).ProposalTrackerContract.UnmarshalMsg(bts) + bts, err = (*z).ProposalTrackerContract.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ProposalTrackerContract") return @@ -3873,7 +4064,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 step var zb0002 *stepRouter zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children") return @@ -3888,7 +4079,7 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(stepRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children", zb0001) return @@ -3909,6 +4100,9 @@ func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *periodRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *periodRouter) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*periodRouter) return ok @@ -3997,7 +4191,12 @@ func (_ *player) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *player) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4011,7 +4210,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -4055,7 +4254,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Deadline.UnmarshalMsg(bts) + bts, err = (*z).Deadline.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Deadline") return @@ -4087,7 +4286,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Pending.UnmarshalMsg(bts) + bts, err = (*z).Pending.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Pending") return @@ -4117,7 +4316,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Round": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -4153,7 +4352,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).LastConcluding = step(zb0008) } case "TimersDeadline": - bts, err = (*z).Deadline.UnmarshalMsg(bts) + bts, err = (*z).Deadline.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Deadline") return @@ -4177,7 +4376,7 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Pending": - bts, err = (*z).Pending.UnmarshalMsg(bts) + bts, err = (*z).Pending.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Pending") return @@ -4195,6 +4394,9 @@ func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *player) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *player) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*player) return ok @@ -4519,7 +4721,12 @@ func (_ *proposal) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposal) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -4533,7 +4740,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -4541,7 +4748,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Branch") return @@ -4549,7 +4756,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -4557,7 +4764,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -4565,7 +4772,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -4599,7 +4806,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -4607,7 +4814,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -4615,7 +4822,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -4647,7 +4854,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -4655,7 +4862,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -4663,7 +4870,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocol") return @@ -4679,7 +4886,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") return @@ -4687,7 +4894,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") return @@ -4695,7 +4902,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -4703,7 +4910,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -4748,12 +4955,12 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking", zb0001) return @@ -4783,7 +4990,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0009) } for zb0003 := range (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0003) return @@ -4792,7 +4999,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Payset") return @@ -4800,7 +5007,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SeedProof") return @@ -4820,7 +5027,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") return @@ -4850,31 +5057,31 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "prev": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Branch") return } case "seed": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "txn": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -4902,19 +5109,19 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "fees": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -4938,19 +5145,19 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rwcalr": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return } case "proto": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return } case "nextproto": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocol") return @@ -4962,25 +5169,25 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "nextbefore": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolVoteBefore") return } case "nextswitch": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolSwitchOn") return } case "upgradeprop": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -5019,12 +5226,12 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0013-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking", zb0001) return @@ -5052,20 +5259,20 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0015) } for zb0003 := range (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0003) return } } case "txns": - bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Payset") return } case "sdpf": - bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SeedProof") return @@ -5081,7 +5288,7 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.OriginalPeriod = period(zb0017) } case "oprop": - bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "OriginalProposer") return @@ -5099,6 +5306,9 @@ func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposal) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposal) return ok @@ -5159,7 +5369,12 @@ func (_ *proposalManager) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalManager) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalManager) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -5207,6 +5422,9 @@ func (z *proposalManager) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalManager) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalManager) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalManager) return ok @@ -5251,7 +5469,12 @@ func (_ *proposalSeeker) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalSeeker) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalSeeker) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -5265,7 +5488,7 @@ func (z *proposalSeeker) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Lowest.UnmarshalMsg(bts) + bts, err = (*z).Lowest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Lowest") return @@ -5311,7 +5534,7 @@ func (z *proposalSeeker) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Lowest": - bts, err = (*z).Lowest.UnmarshalMsg(bts) + bts, err = (*z).Lowest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Lowest") return @@ -5341,6 +5564,9 @@ func (z *proposalSeeker) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalSeeker) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalSeeker) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalSeeker) return ok @@ -5415,7 +5641,12 @@ func (_ *proposalStore) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalStore) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0005 int @@ -5445,12 +5676,12 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 period var zb0002 proposalValue zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Relevant") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Relevant", zb0001) return @@ -5460,7 +5691,7 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).Pinned.UnmarshalMsg(bts) + bts, err = (*z).Pinned.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Pinned") return @@ -5484,12 +5715,12 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 proposalValue var zb0004 blockAssembler zb0009-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Assemblers") return } - bts, err = zb0004.UnmarshalMsg(bts) + bts, err = zb0004.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Assemblers", zb0003) return @@ -5537,12 +5768,12 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 period var zb0002 proposalValue zb0011-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Relevant") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Relevant", zb0001) return @@ -5550,7 +5781,7 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Relevant[zb0001] = zb0002 } case "Pinned": - bts, err = (*z).Pinned.UnmarshalMsg(bts) + bts, err = (*z).Pinned.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Pinned") return @@ -5572,12 +5803,12 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 proposalValue var zb0004 blockAssembler zb0013-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Assemblers") return } - bts, err = zb0004.UnmarshalMsg(bts) + bts, err = zb0004.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Assemblers", zb0003) return @@ -5597,6 +5828,9 @@ func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalStore) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalStore) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalStore) return ok @@ -5695,7 +5929,12 @@ func (_ *proposalTable) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalTable) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalTable) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -5740,7 +5979,7 @@ func (z *proposalTable) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(messageEvent) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Pending", zb0001) return @@ -5812,7 +6051,7 @@ func (z *proposalTable) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(messageEvent) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Pending", zb0001) return @@ -5839,6 +6078,9 @@ func (z *proposalTable) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalTable) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalTable) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalTable) return ok @@ -5914,7 +6156,12 @@ func (_ *proposalTracker) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalTracker) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -5944,7 +6191,7 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 bool zb0005-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Duplicate") return @@ -5959,7 +6206,7 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Freezer.UnmarshalMsg(bts) + bts, err = (*z).Freezer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Freezer") return @@ -5967,7 +6214,7 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Staging.UnmarshalMsg(bts) + bts, err = (*z).Staging.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Staging") return @@ -6013,7 +6260,7 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 bool zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Duplicate") return @@ -6026,13 +6273,13 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Duplicate[zb0001] = zb0002 } case "Freezer": - bts, err = (*z).Freezer.UnmarshalMsg(bts) + bts, err = (*z).Freezer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Freezer") return } case "Staging": - bts, err = (*z).Staging.UnmarshalMsg(bts) + bts, err = (*z).Staging.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Staging") return @@ -6050,6 +6297,9 @@ func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalTracker) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalTracker) return ok @@ -6108,7 +6358,12 @@ func (_ *proposalTrackerContract) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalTrackerContract) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -6212,6 +6467,9 @@ func (z *proposalTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *proposalTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalTrackerContract) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalTrackerContract) return ok @@ -6289,7 +6547,12 @@ func (_ *proposalValue) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalValue) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -6315,7 +6578,7 @@ func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") return @@ -6323,7 +6586,7 @@ func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BlockDigest.UnmarshalMsg(bts) + bts, err = (*z).BlockDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "BlockDigest") return @@ -6331,7 +6594,7 @@ func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).EncodingDigest.UnmarshalMsg(bts) + bts, err = (*z).EncodingDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EncodingDigest") return @@ -6371,19 +6634,19 @@ func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).OriginalPeriod = period(zb0004) } case "oprop": - bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "OriginalProposer") return } case "dig": - bts, err = (*z).BlockDigest.UnmarshalMsg(bts) + bts, err = (*z).BlockDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "BlockDigest") return } case "encdig": - bts, err = (*z).EncodingDigest.UnmarshalMsg(bts) + bts, err = (*z).EncodingDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EncodingDigest") return @@ -6401,6 +6664,9 @@ func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalValue) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalValue) return ok @@ -6457,7 +6723,12 @@ func (_ *proposalVoteCounter) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposalVoteCounter) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposalVoteCounter) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -6495,12 +6766,12 @@ func (z *proposalVoteCounter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 vote zb0005-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Votes") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) return @@ -6554,12 +6825,12 @@ func (z *proposalVoteCounter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 vote zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Votes") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Votes", zb0001) return @@ -6579,6 +6850,9 @@ func (z *proposalVoteCounter) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposalVoteCounter) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposalVoteCounter) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposalVoteCounter) return ok @@ -6629,7 +6903,12 @@ func (_ *proposerSeed) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *proposerSeed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -6643,7 +6922,7 @@ func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Addr.UnmarshalMsg(bts) + bts, err = (*z).Addr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Addr") return @@ -6651,7 +6930,7 @@ func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VRF.UnmarshalMsg(bts) + bts, err = (*z).VRF.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VRF") return @@ -6681,13 +6960,13 @@ func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "addr": - bts, err = (*z).Addr.UnmarshalMsg(bts) + bts, err = (*z).Addr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Addr") return } case "vrf": - bts, err = (*z).VRF.UnmarshalMsg(bts) + bts, err = (*z).VRF.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VRF") return @@ -6705,6 +6984,9 @@ func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *proposerSeed) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*proposerSeed) return ok @@ -6791,7 +7073,12 @@ func (_ *rawVote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *rawVote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -6805,7 +7092,7 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -6813,7 +7100,7 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -6845,7 +7132,7 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -6875,13 +7162,13 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -6907,7 +7194,7 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Step = step(zb0006) } case "prop": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return @@ -6925,6 +7212,9 @@ func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *rawVote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*rawVote) return ok @@ -6990,7 +7280,12 @@ func (_ *rootRouter) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *rootRouter) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -7108,7 +7403,7 @@ func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Round var zb0002 *roundRouter zb0009-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children") return @@ -7123,7 +7418,7 @@ func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(roundRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children", zb0001) return @@ -7256,7 +7551,7 @@ func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Round var zb0002 *roundRouter zb0015-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children") return @@ -7271,7 +7566,7 @@ func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(roundRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children", zb0001) return @@ -7292,6 +7587,9 @@ func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *rootRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *rootRouter) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*rootRouter) return ok @@ -7375,7 +7673,12 @@ func (_ *roundRouter) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *roundRouter) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -7389,7 +7692,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).ProposalStore.UnmarshalMsg(bts) + bts, err = (*z).ProposalStore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ProposalStore") return @@ -7408,7 +7711,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteTrackerRound", "struct-from-array", "Freshest") return @@ -7446,7 +7749,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Freshest": - bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteTrackerRound", "Freshest") return @@ -7485,7 +7788,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 period var zb0002 *periodRouter zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children") return @@ -7500,7 +7803,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(periodRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Children", zb0001) return @@ -7533,7 +7836,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "ProposalStore": - bts, err = (*z).ProposalStore.UnmarshalMsg(bts) + bts, err = (*z).ProposalStore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ProposalStore") return @@ -7550,7 +7853,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteTrackerRound", "struct-from-array", "Freshest") return @@ -7588,7 +7891,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Freshest": - bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerRound.Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteTrackerRound", "Freshest") return @@ -7625,7 +7928,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 period var zb0002 *periodRouter zb0011-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children") return @@ -7640,7 +7943,7 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { if zb0002 == nil { zb0002 = new(periodRouter) } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Children", zb0001) return @@ -7661,6 +7964,9 @@ func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *roundRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *roundRouter) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*roundRouter) return ok @@ -7716,7 +8022,12 @@ func (_ *seedInput) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *seedInput) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -7730,7 +8041,7 @@ func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Alpha.UnmarshalMsg(bts) + bts, err = (*z).Alpha.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Alpha") return @@ -7738,7 +8049,7 @@ func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).History.UnmarshalMsg(bts) + bts, err = (*z).History.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "History") return @@ -7768,13 +8079,13 @@ func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "alpha": - bts, err = (*z).Alpha.UnmarshalMsg(bts) + bts, err = (*z).Alpha.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Alpha") return } case "hist": - bts, err = (*z).History.UnmarshalMsg(bts) + bts, err = (*z).History.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "History") return @@ -7792,6 +8103,9 @@ func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *seedInput) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*seedInput) return ok @@ -7839,7 +8153,12 @@ func (_ *selector) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *selector) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -7853,7 +8172,7 @@ func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -7861,7 +8180,7 @@ func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -7915,13 +8234,13 @@ func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "seed": - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -7959,6 +8278,9 @@ func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *selector) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*selector) return ok @@ -7997,7 +8319,12 @@ func (_ serializableError) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *serializableError) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *serializableError) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -8011,6 +8338,9 @@ func (z *serializableError) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *serializableError) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *serializableError) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*serializableError) return ok @@ -8049,7 +8379,12 @@ func (_ step) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *step) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *step) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -8063,6 +8398,9 @@ func (z *step) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *step) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *step) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*step) return ok @@ -8104,7 +8442,12 @@ func (_ *stepRouter) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *stepRouter) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -8118,7 +8461,7 @@ func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteTracker.UnmarshalMsg(bts) + bts, err = (*z).VoteTracker.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteTracker") return @@ -8126,7 +8469,7 @@ func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteTrackerContract.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerContract.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteTrackerContract") return @@ -8156,13 +8499,13 @@ func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "VoteTracker": - bts, err = (*z).VoteTracker.UnmarshalMsg(bts) + bts, err = (*z).VoteTracker.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteTracker") return } case "VoteTrackerContract": - bts, err = (*z).VoteTrackerContract.UnmarshalMsg(bts) + bts, err = (*z).VoteTrackerContract.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteTrackerContract") return @@ -8180,6 +8523,9 @@ func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *stepRouter) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *stepRouter) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*stepRouter) return ok @@ -8236,7 +8582,12 @@ func (_ *thresholdEvent) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *thresholdEvent) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -8262,7 +8613,7 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -8294,7 +8645,7 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -8302,7 +8653,7 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Bundle.UnmarshalMsg(bts) + bts, err = (*z).Bundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Bundle") return @@ -8310,7 +8661,7 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proto") return @@ -8350,7 +8701,7 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).T = eventType(zb0006) } case "Round": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -8376,19 +8727,19 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Step = step(zb0008) } case "Proposal": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return } case "Bundle": - bts, err = (*z).Bundle.UnmarshalMsg(bts) + bts, err = (*z).Bundle.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Bundle") return } case "Proto": - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proto") return @@ -8406,6 +8757,9 @@ func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *thresholdEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *thresholdEvent) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*thresholdEvent) return ok @@ -8739,7 +9093,12 @@ func (_ *transmittedPayload) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *transmittedPayload) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -8753,7 +9112,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -8761,7 +9120,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Branch") return @@ -8769,7 +9128,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -8777,7 +9136,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -8785,7 +9144,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -8819,7 +9178,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -8827,7 +9186,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -8835,7 +9194,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -8867,7 +9226,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -8875,7 +9234,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -8883,7 +9242,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocol") return @@ -8899,7 +9258,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") return @@ -8907,7 +9266,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") return @@ -8915,7 +9274,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -8923,7 +9282,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -8968,12 +9327,12 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking", zb0001) return @@ -9003,7 +9362,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0009) } for zb0003 := range (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0003) return @@ -9012,7 +9371,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Payset") return @@ -9020,7 +9379,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SeedProof") return @@ -9040,7 +9399,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") return @@ -9048,7 +9407,7 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).PriorVote.UnmarshalMsg(bts) + bts, err = (*z).PriorVote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "PriorVote") return @@ -9078,31 +9437,31 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "prev": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Branch") return } case "seed": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "txn": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -9130,19 +9489,19 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "fees": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -9166,19 +9525,19 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rwcalr": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return } case "proto": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return } case "nextproto": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocol") return @@ -9190,25 +9549,25 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "nextbefore": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolVoteBefore") return } case "nextswitch": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolSwitchOn") return } case "upgradeprop": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -9247,12 +9606,12 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0013-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking", zb0001) return @@ -9280,20 +9639,20 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0015) } for zb0003 := range (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0003) return } } case "txns": - bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Payset") return } case "sdpf": - bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SeedProof") return @@ -9309,13 +9668,13 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).unauthenticatedProposal.OriginalPeriod = period(zb0017) } case "oprop": - bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "OriginalProposer") return } case "pv": - bts, err = (*z).PriorVote.UnmarshalMsg(bts) + bts, err = (*z).PriorVote.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "PriorVote") return @@ -9333,6 +9692,9 @@ func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *transmittedPayload) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*transmittedPayload) return ok @@ -9466,7 +9828,12 @@ func (_ *unauthenticatedBundle) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *unauthenticatedBundle) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -9480,7 +9847,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -9512,7 +9879,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposal") return @@ -9540,7 +9907,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]voteAuthenticator, zb0007) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) return @@ -9569,7 +9936,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0009) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) return @@ -9600,7 +9967,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -9626,7 +9993,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Step = step(zb0012) } case "prop": - bts, err = (*z).Proposal.UnmarshalMsg(bts) + bts, err = (*z).Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposal") return @@ -9652,7 +10019,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Votes = make([]voteAuthenticator, zb0013) } for zb0001 := range (*z).Votes { - bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Votes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Votes", zb0001) return @@ -9679,7 +10046,7 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0015) } for zb0002 := range (*z).EquivocationVotes { - bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EquivocationVotes", zb0002) return @@ -9698,6 +10065,9 @@ func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *unauthenticatedBundle) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*unauthenticatedBundle) return ok @@ -9820,7 +10190,12 @@ func (_ *unauthenticatedEquivocationVote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *unauthenticatedEquivocationVote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -9834,7 +10209,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er } if zb0003 > 0 { zb0003-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -9842,7 +10217,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er } if zb0003 > 0 { zb0003-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -9874,7 +10249,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er } if zb0003 > 0 { zb0003-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -9893,7 +10268,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er return } for zb0001 := 0; zb0001 < zb0007; zb0001++ { - bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0001) return @@ -9913,7 +10288,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er return } for zb0002 := 0; zb0002 < zb0008; zb0002++ { - bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0002) return @@ -9944,13 +10319,13 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return @@ -9976,7 +10351,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er (*z).Step = step(zb0010) } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return @@ -9993,7 +10368,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er return } for zb0001 := 0; zb0001 < zb0011; zb0001++ { - bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proposals[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proposals", zb0001) return @@ -10011,7 +10386,7 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er return } for zb0002 := 0; zb0002 < zb0012; zb0002++ { - bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Sigs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sigs", zb0002) return @@ -10030,6 +10405,9 @@ func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, er return } +func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *unauthenticatedEquivocationVote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*unauthenticatedEquivocationVote) return ok @@ -10366,7 +10744,12 @@ func (_ *unauthenticatedProposal) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *unauthenticatedProposal) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -10380,7 +10763,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -10388,7 +10771,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Branch") return @@ -10396,7 +10779,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -10404,7 +10787,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -10412,7 +10795,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -10446,7 +10829,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -10454,7 +10837,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -10462,7 +10845,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -10494,7 +10877,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -10502,7 +10885,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -10510,7 +10893,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocol") return @@ -10526,7 +10909,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") return @@ -10534,7 +10917,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") return @@ -10542,7 +10925,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -10550,7 +10933,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -10595,12 +10978,12 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking", zb0001) return @@ -10630,7 +11013,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0009) } for zb0003 := range (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0003) return @@ -10639,7 +11022,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Payset") return @@ -10647,7 +11030,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).SeedProof.UnmarshalMsg(bts) + bts, err = (*z).SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SeedProof") return @@ -10667,7 +11050,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0004 > 0 { zb0004-- - bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") return @@ -10697,31 +11080,31 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) } switch string(field) { case "rnd": - bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "prev": - bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Branch") return } case "seed": - bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "txn": - bts, err = (*z).Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -10749,19 +11132,19 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) return } case "gh": - bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "fees": - bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -10785,19 +11168,19 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) return } case "rwcalr": - bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return } case "proto": - bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return } case "nextproto": - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocol") return @@ -10809,25 +11192,25 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) return } case "nextbefore": - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolVoteBefore") return } case "nextswitch": - bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolSwitchOn") return } case "upgradeprop": - bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -10866,12 +11249,12 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) var zb0001 protocol.StateProofType var zb0002 bookkeeping.StateProofTrackingData zb0013-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking", zb0001) return @@ -10899,20 +11282,20 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0015) } for zb0003 := range (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Block.BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0003) return } } case "txns": - bts, err = (*z).Block.Payset.UnmarshalMsg(bts) + bts, err = (*z).Block.Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Payset") return } case "sdpf": - bts, err = (*z).SeedProof.UnmarshalMsg(bts) + bts, err = (*z).SeedProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SeedProof") return @@ -10928,7 +11311,7 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).OriginalPeriod = period(zb0017) } case "oprop": - bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + bts, err = (*z).OriginalProposer.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "OriginalProposer") return @@ -10946,6 +11329,9 @@ func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *unauthenticatedProposal) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*unauthenticatedProposal) return ok @@ -11038,7 +11424,12 @@ func (_ *unauthenticatedVote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *unauthenticatedVote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -11052,7 +11443,7 @@ func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).R.UnmarshalMsg(bts) + bts, err = (*z).R.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "R") return @@ -11060,7 +11451,7 @@ func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -11068,7 +11459,7 @@ func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -11098,19 +11489,19 @@ func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "r": - bts, err = (*z).R.UnmarshalMsg(bts) + bts, err = (*z).R.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "R") return } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return } case "sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -11128,6 +11519,9 @@ func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *unauthenticatedVote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*unauthenticatedVote) return ok @@ -11196,7 +11590,12 @@ func (_ *vote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *vote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -11210,7 +11609,7 @@ func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).R.UnmarshalMsg(bts) + bts, err = (*z).R.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "R") return @@ -11218,7 +11617,7 @@ func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -11226,7 +11625,7 @@ func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -11256,19 +11655,19 @@ func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "r": - bts, err = (*z).R.UnmarshalMsg(bts) + bts, err = (*z).R.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "R") return } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return } case "sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -11286,6 +11685,9 @@ func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *vote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*vote) return ok @@ -11322,7 +11724,12 @@ func (_ *voteAggregator) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteAggregator) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteAggregator) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -11370,6 +11777,9 @@ func (z *voteAggregator) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteAggregator) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteAggregator) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteAggregator) return ok @@ -11426,7 +11836,12 @@ func (_ *voteAuthenticator) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteAuthenticator) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -11440,7 +11855,7 @@ func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -11448,7 +11863,7 @@ func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cred") return @@ -11456,7 +11871,7 @@ func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -11486,19 +11901,19 @@ func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "cred": - bts, err = (*z).Cred.UnmarshalMsg(bts) + bts, err = (*z).Cred.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cred") return } case "sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -11516,6 +11931,9 @@ func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteAuthenticator) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteAuthenticator) return ok @@ -11608,7 +12026,12 @@ func (_ *voteTracker) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteTracker) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0007 int @@ -11638,12 +12061,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 vote zb0009-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Voters") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Voters", zb0001) return @@ -11669,12 +12092,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 proposalValue var zb0004 proposalVoteCounter zb0011-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Counts") return } - bts, err = zb0004.UnmarshalMsg(bts) + bts, err = zb0004.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Counts", zb0003) return @@ -11700,12 +12123,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 basics.Address var zb0006 equivocationVote zb0013-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Equivocators") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Equivocators", zb0005) return @@ -11761,12 +12184,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 vote zb0015-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Voters") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Voters", zb0001) return @@ -11790,12 +12213,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 proposalValue var zb0004 proposalVoteCounter zb0017-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Counts") return } - bts, err = zb0004.UnmarshalMsg(bts) + bts, err = zb0004.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Counts", zb0003) return @@ -11819,12 +12242,12 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 basics.Address var zb0006 equivocationVote zb0019-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Equivocators") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Equivocators", zb0005) return @@ -11850,6 +12273,9 @@ func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteTracker) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteTracker) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteTracker) return ok @@ -11927,7 +12353,12 @@ func (_ *voteTrackerContract) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteTrackerContract) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -12025,6 +12456,9 @@ func (z *voteTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteTrackerContract) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteTrackerContract) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteTrackerContract) return ok @@ -12069,7 +12503,12 @@ func (_ *voteTrackerPeriod) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteTrackerPeriod) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -12102,7 +12541,7 @@ func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Cached.Proposal.UnmarshalMsg(bts) + bts, err = (*z).Cached.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cached", "struct-from-array", "Proposal") return @@ -12138,7 +12577,7 @@ func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Proposal": - bts, err = (*z).Cached.Proposal.UnmarshalMsg(bts) + bts, err = (*z).Cached.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Cached", "Proposal") return @@ -12196,7 +12635,7 @@ func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).Cached.Proposal.UnmarshalMsg(bts) + bts, err = (*z).Cached.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cached", "struct-from-array", "Proposal") return @@ -12232,7 +12671,7 @@ func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "Proposal": - bts, err = (*z).Cached.Proposal.UnmarshalMsg(bts) + bts, err = (*z).Cached.Proposal.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Cached", "Proposal") return @@ -12259,6 +12698,9 @@ func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteTrackerPeriod) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteTrackerPeriod) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteTrackerPeriod) return ok @@ -12300,7 +12742,12 @@ func (_ *voteTrackerRound) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *voteTrackerRound) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *voteTrackerRound) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -12314,7 +12761,7 @@ func (z *voteTrackerRound) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Freshest.UnmarshalMsg(bts) + bts, err = (*z).Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Freshest") return @@ -12352,7 +12799,7 @@ func (z *voteTrackerRound) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Freshest": - bts, err = (*z).Freshest.UnmarshalMsg(bts) + bts, err = (*z).Freshest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Freshest") return @@ -12376,6 +12823,9 @@ func (z *voteTrackerRound) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *voteTrackerRound) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *voteTrackerRound) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*voteTrackerRound) return ok diff --git a/crypto/merklearray/msgp_gen.go b/crypto/merklearray/msgp_gen.go index 35aa264fb1..20e8175898 100644 --- a/crypto/merklearray/msgp_gen.go +++ b/crypto/merklearray/msgp_gen.go @@ -13,6 +13,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -22,6 +23,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -31,6 +33,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -39,6 +42,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -68,7 +72,12 @@ func (_ Layer) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Layer) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Layer) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0002 int var zb0003 bool zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) @@ -89,7 +98,7 @@ func (z *Layer) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z) = make(Layer, zb0002) } for zb0001 := range *z { - bts, err = (*z)[zb0001].UnmarshalMsg(bts) + bts, err = (*z)[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, zb0001) return @@ -99,6 +108,9 @@ func (z *Layer) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Layer) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Layer) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Layer) return ok @@ -178,7 +190,12 @@ func (_ *Proof) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Proof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -212,7 +229,7 @@ func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Path = make([]crypto.GenericDigest, zb0004) } for zb0001 := range (*z).Path { - bts, err = (*z).Path[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Path[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Path", zb0001) return @@ -221,7 +238,7 @@ func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).HashFactory.UnmarshalMsg(bts) + bts, err = (*z).HashFactory.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "HashFactory") return @@ -279,14 +296,14 @@ func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Path = make([]crypto.GenericDigest, zb0006) } for zb0001 := range (*z).Path { - bts, err = (*z).Path[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Path[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Path", zb0001) return } } case "hsh": - bts, err = (*z).HashFactory.UnmarshalMsg(bts) + bts, err = (*z).HashFactory.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "HashFactory") return @@ -310,6 +327,9 @@ func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Proof) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Proof) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Proof) return ok @@ -392,7 +412,12 @@ func (_ *SingleLeafProof) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SingleLeafProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -426,7 +451,7 @@ func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Proof.Path = make([]crypto.GenericDigest, zb0004) } for zb0001 := range (*z).Proof.Path { - bts, err = (*z).Proof.Path[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proof.Path[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Path", zb0001) return @@ -435,7 +460,7 @@ func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Proof.HashFactory.UnmarshalMsg(bts) + bts, err = (*z).Proof.HashFactory.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "HashFactory") return @@ -493,14 +518,14 @@ func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Proof.Path = make([]crypto.GenericDigest, zb0006) } for zb0001 := range (*z).Proof.Path { - bts, err = (*z).Proof.Path[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Proof.Path[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Path", zb0001) return } } case "hsh": - bts, err = (*z).Proof.HashFactory.UnmarshalMsg(bts) + bts, err = (*z).Proof.HashFactory.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "HashFactory") return @@ -524,6 +549,9 @@ func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SingleLeafProof) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SingleLeafProof) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SingleLeafProof) return ok @@ -613,7 +641,12 @@ func (_ *Tree) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Tree) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -667,7 +700,7 @@ func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Levels[zb0001] = make(Layer, zb0007) } for zb0002 := range (*z).Levels[zb0001] { - bts, err = (*z).Levels[zb0001][zb0002].UnmarshalMsg(bts) + bts, err = (*z).Levels[zb0001][zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Levels", zb0001, zb0002) return @@ -685,7 +718,7 @@ func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Hash.UnmarshalMsg(bts) + bts, err = (*z).Hash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Hash") return @@ -763,7 +796,7 @@ func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Levels[zb0001] = make(Layer, zb0011) } for zb0002 := range (*z).Levels[zb0001] { - bts, err = (*z).Levels[zb0001][zb0002].UnmarshalMsg(bts) + bts, err = (*z).Levels[zb0001][zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Levels", zb0001, zb0002) return @@ -777,7 +810,7 @@ func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "hsh": - bts, err = (*z).Hash.UnmarshalMsg(bts) + bts, err = (*z).Hash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Hash") return @@ -801,6 +834,9 @@ func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Tree) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Tree) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Tree) return ok diff --git a/crypto/merklesignature/msgp_gen.go b/crypto/merklesignature/msgp_gen.go index cd8a00d4e8..9329caf04b 100644 --- a/crypto/merklesignature/msgp_gen.go +++ b/crypto/merklesignature/msgp_gen.go @@ -14,6 +14,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -23,6 +24,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -32,6 +34,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -41,6 +44,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -50,6 +54,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -59,6 +64,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -78,7 +84,12 @@ func (_ *Commitment) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Commitment) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Commitment) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -88,6 +99,9 @@ func (z *Commitment) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Commitment) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Commitment) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Commitment) return ok @@ -152,7 +166,12 @@ func (_ *KeyRoundPair) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *KeyRoundPair) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -184,7 +203,7 @@ func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Key == nil { (*z).Key = new(crypto.FalconSigner) } - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Key") return @@ -231,7 +250,7 @@ func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Key == nil { (*z).Key = new(crypto.FalconSigner) } - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Key") return @@ -250,6 +269,9 @@ func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *KeyRoundPair) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*KeyRoundPair) return ok @@ -324,7 +346,12 @@ func (_ *Secrets) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Secrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -354,7 +381,7 @@ func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).SignerContext.Tree.UnmarshalMsg(bts) + bts, err = (*z).SignerContext.Tree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Tree") return @@ -396,7 +423,7 @@ func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "tree": - bts, err = (*z).SignerContext.Tree.UnmarshalMsg(bts) + bts, err = (*z).SignerContext.Tree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Tree") return @@ -414,6 +441,9 @@ func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Secrets) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Secrets) return ok @@ -491,7 +521,12 @@ func (_ *Signature) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -505,7 +540,7 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Signature") return @@ -521,7 +556,7 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proof.UnmarshalMsg(bts) + bts, err = (*z).Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proof") return @@ -529,7 +564,7 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VerifyingKey.UnmarshalMsg(bts) + bts, err = (*z).VerifyingKey.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VerifyingKey") return @@ -559,7 +594,7 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "sig": - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Signature") return @@ -571,13 +606,13 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "prf": - bts, err = (*z).Proof.UnmarshalMsg(bts) + bts, err = (*z).Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proof") return } case "vkey": - bts, err = (*z).VerifyingKey.UnmarshalMsg(bts) + bts, err = (*z).VerifyingKey.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VerifyingKey") return @@ -595,6 +630,9 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Signature) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Signature) return ok @@ -663,7 +701,12 @@ func (_ *SignerContext) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SignerContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -693,7 +736,7 @@ func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Tree.UnmarshalMsg(bts) + bts, err = (*z).Tree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Tree") return @@ -735,7 +778,7 @@ func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "tree": - bts, err = (*z).Tree.UnmarshalMsg(bts) + bts, err = (*z).Tree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Tree") return @@ -753,6 +796,9 @@ func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SignerContext) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SignerContext) return ok @@ -812,7 +858,12 @@ func (_ *Verifier) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Verifier) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Verifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -888,6 +939,9 @@ func (z *Verifier) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Verifier) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Verifier) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Verifier) return ok diff --git a/crypto/msgp_gen.go b/crypto/msgp_gen.go index 7d7364de88..f143ef3e99 100644 --- a/crypto/msgp_gen.go +++ b/crypto/msgp_gen.go @@ -15,6 +15,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -24,6 +25,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -33,6 +35,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -42,6 +45,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -51,6 +55,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -60,6 +65,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -69,6 +75,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -78,6 +85,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -87,6 +95,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -96,6 +105,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -105,6 +115,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -114,6 +125,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -123,6 +135,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -132,6 +145,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -141,6 +155,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -150,6 +165,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -159,6 +175,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -168,6 +185,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -177,6 +195,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -186,6 +205,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -195,6 +215,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -204,6 +225,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -213,6 +235,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -222,6 +245,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -231,6 +255,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -240,6 +265,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -249,6 +275,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -258,6 +285,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -267,6 +295,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -276,6 +305,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -285,6 +315,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -294,6 +325,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -303,6 +335,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -312,6 +345,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -331,7 +365,12 @@ func (_ *Digest) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Digest) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Digest) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -341,6 +380,9 @@ func (z *Digest) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Digest) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Digest) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Digest) return ok @@ -377,7 +419,12 @@ func (_ *FalconPrivateKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconPrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconPrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -387,6 +434,9 @@ func (z *FalconPrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconPrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconPrivateKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconPrivateKey) return ok @@ -423,7 +473,12 @@ func (_ *FalconPublicKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconPublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconPublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -433,6 +488,9 @@ func (z *FalconPublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconPublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconPublicKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconPublicKey) return ok @@ -469,7 +527,12 @@ func (_ *FalconSeed) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconSeed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -479,6 +542,9 @@ func (z *FalconSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconSeed) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconSeed) return ok @@ -518,7 +584,12 @@ func (_ FalconSignature) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconSignature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 []byte var zb0002 int @@ -542,6 +613,9 @@ func (z *FalconSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconSignature) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconSignature) return ok @@ -601,7 +675,12 @@ func (_ *FalconSigner) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconSigner) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconSigner) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -677,6 +756,9 @@ func (z *FalconSigner) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconSigner) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconSigner) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconSigner) return ok @@ -732,7 +814,12 @@ func (_ *FalconVerifier) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *FalconVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *FalconVerifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -794,6 +881,9 @@ func (z *FalconVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *FalconVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *FalconVerifier) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*FalconVerifier) return ok @@ -834,7 +924,12 @@ func (_ GenericDigest) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *GenericDigest) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *GenericDigest) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 []byte var zb0002 int @@ -858,6 +953,9 @@ func (z *GenericDigest) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *GenericDigest) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *GenericDigest) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*GenericDigest) return ok @@ -908,7 +1006,12 @@ func (_ *HashFactory) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *HashFactory) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *HashFactory) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -981,6 +1084,9 @@ func (z *HashFactory) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *HashFactory) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *HashFactory) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*HashFactory) return ok @@ -1019,7 +1125,12 @@ func (_ HashType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *HashType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *HashType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint16 zb0001, bts, err = msgp.ReadUint16Bytes(bts) @@ -1033,6 +1144,9 @@ func (z *HashType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *HashType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *HashType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*HashType) return ok @@ -1068,7 +1182,12 @@ func (_ *MasterDerivationKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *MasterDerivationKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *MasterDerivationKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -1078,6 +1197,9 @@ func (z *MasterDerivationKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *MasterDerivationKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *MasterDerivationKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*MasterDerivationKey) return ok @@ -1154,7 +1276,12 @@ func (_ *MultisigSig) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *MultisigSig) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -1204,7 +1331,7 @@ func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Subsigs = make([]MultisigSubsig, zb0004) } for zb0001 := range (*z).Subsigs { - bts, err = (*z).Subsigs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Subsigs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Subsigs", zb0001) return @@ -1267,7 +1394,7 @@ func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Subsigs = make([]MultisigSubsig, zb0006) } for zb0001 := range (*z).Subsigs { - bts, err = (*z).Subsigs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Subsigs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Subsigs", zb0001) return @@ -1286,6 +1413,9 @@ func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *MultisigSig) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*MultisigSig) return ok @@ -1350,7 +1480,12 @@ func (_ *MultisigSubsig) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *MultisigSubsig) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *MultisigSubsig) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -1426,6 +1561,9 @@ func (z *MultisigSubsig) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *MultisigSubsig) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *MultisigSubsig) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*MultisigSubsig) return ok @@ -1484,7 +1622,12 @@ func (_ *OneTimeSignature) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0007 int @@ -1616,6 +1759,9 @@ func (z *OneTimeSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *OneTimeSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignature) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignature) return ok @@ -1751,7 +1897,12 @@ func (_ *OneTimeSignatureSecrets) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignatureSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0006 int @@ -1796,7 +1947,7 @@ func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).OneTimeSignatureSecretsPersistent.Batches = make([]ephemeralSubkey, zb0008) } for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { - bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsg(bts) + bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Batches", zb0002) return @@ -1828,7 +1979,7 @@ func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).OneTimeSignatureSecretsPersistent.Offsets = make([]ephemeralSubkey, zb0010) } for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { - bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsg(bts) + bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Offsets", zb0003) return @@ -1902,7 +2053,7 @@ func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).OneTimeSignatureSecretsPersistent.Batches = make([]ephemeralSubkey, zb0012) } for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { - bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsg(bts) + bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Batches", zb0002) return @@ -1930,7 +2081,7 @@ func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) (*z).OneTimeSignatureSecretsPersistent.Offsets = make([]ephemeralSubkey, zb0014) } for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { - bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsg(bts) + bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Offsets", zb0003) return @@ -1961,6 +2112,9 @@ func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignatureSecrets) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignatureSecrets) return ok @@ -2101,7 +2255,12 @@ func (_ *OneTimeSignatureSecretsPersistent) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0006 int @@ -2146,7 +2305,7 @@ func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, (*z).Batches = make([]ephemeralSubkey, zb0008) } for zb0002 := range (*z).Batches { - bts, err = (*z).Batches[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Batches[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Batches", zb0002) return @@ -2178,7 +2337,7 @@ func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, (*z).Offsets = make([]ephemeralSubkey, zb0010) } for zb0003 := range (*z).Offsets { - bts, err = (*z).Offsets[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Offsets[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Offsets", zb0003) return @@ -2252,7 +2411,7 @@ func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, (*z).Batches = make([]ephemeralSubkey, zb0012) } for zb0002 := range (*z).Batches { - bts, err = (*z).Batches[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Batches[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Batches", zb0002) return @@ -2280,7 +2439,7 @@ func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, (*z).Offsets = make([]ephemeralSubkey, zb0014) } for zb0003 := range (*z).Offsets { - bts, err = (*z).Offsets[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Offsets[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Offsets", zb0003) return @@ -2311,6 +2470,9 @@ func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, return } +func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignatureSecretsPersistent) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignatureSecretsPersistent) return ok @@ -2374,7 +2536,12 @@ func (_ *OneTimeSignatureSubkeyBatchID) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2450,6 +2617,9 @@ func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsg(bts []byte) (o []byte, err return } +func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignatureSubkeyBatchID) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignatureSubkeyBatchID) return ok @@ -2497,7 +2667,12 @@ func (_ *OneTimeSignatureSubkeyOffsetID) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2587,6 +2762,9 @@ func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsg(bts []byte) (o []byte, err return } +func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignatureSubkeyOffsetID) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignatureSubkeyOffsetID) return ok @@ -2625,7 +2803,12 @@ func (_ *OneTimeSignatureVerifier) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OneTimeSignatureVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OneTimeSignatureVerifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2635,6 +2818,9 @@ func (z *OneTimeSignatureVerifier) UnmarshalMsg(bts []byte) (o []byte, err error return } +func (z *OneTimeSignatureVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OneTimeSignatureVerifier) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OneTimeSignatureVerifier) return ok @@ -2671,7 +2857,12 @@ func (_ *PrivateKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *PrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2681,6 +2872,9 @@ func (z *PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *PrivateKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*PrivateKey) return ok @@ -2717,7 +2911,12 @@ func (_ *PublicKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *PublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2727,6 +2926,9 @@ func (z *PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *PublicKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*PublicKey) return ok @@ -2763,7 +2965,12 @@ func (_ *Seed) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Seed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2773,6 +2980,9 @@ func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Seed) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Seed) return ok @@ -2809,7 +3019,12 @@ func (_ *Signature) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -2819,6 +3034,9 @@ func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Signature) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Signature) return ok @@ -2861,7 +3079,12 @@ func (_ *SignatureSecrets) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SignatureSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -2937,6 +3160,9 @@ func (z *SignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SignatureSecrets) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SignatureSecrets) return ok @@ -2983,7 +3209,12 @@ func (_ *VRFSecrets) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *VRFSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *VRFSecrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -3059,6 +3290,9 @@ func (z *VRFSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *VRFSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *VRFSecrets) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*VRFSecrets) return ok @@ -3099,7 +3333,12 @@ func (_ *VrfOutput) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *VrfOutput) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *VrfOutput) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3109,6 +3348,9 @@ func (z *VrfOutput) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *VrfOutput) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *VrfOutput) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*VrfOutput) return ok @@ -3145,7 +3387,12 @@ func (_ *VrfPrivkey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *VrfPrivkey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *VrfPrivkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3155,6 +3402,9 @@ func (z *VrfPrivkey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *VrfPrivkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *VrfPrivkey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*VrfPrivkey) return ok @@ -3191,7 +3441,12 @@ func (_ *VrfProof) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *VrfProof) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *VrfProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3201,6 +3456,9 @@ func (z *VrfProof) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *VrfProof) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *VrfProof) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*VrfProof) return ok @@ -3237,7 +3495,12 @@ func (_ *VrfPubkey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *VrfPubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *VrfPubkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3247,6 +3510,9 @@ func (z *VrfPubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *VrfPubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *VrfPubkey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*VrfPubkey) return ok @@ -3283,7 +3549,12 @@ func (_ *ed25519PrivateKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ed25519PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ed25519PrivateKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3293,6 +3564,9 @@ func (z *ed25519PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ed25519PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ed25519PrivateKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ed25519PrivateKey) return ok @@ -3329,7 +3603,12 @@ func (_ *ed25519PublicKey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ed25519PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ed25519PublicKey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3339,6 +3618,9 @@ func (z *ed25519PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ed25519PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ed25519PublicKey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ed25519PublicKey) return ok @@ -3375,7 +3657,12 @@ func (_ *ed25519Seed) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ed25519Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ed25519Seed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3385,6 +3672,9 @@ func (z *ed25519Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ed25519Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ed25519Seed) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ed25519Seed) return ok @@ -3421,7 +3711,12 @@ func (_ *ed25519Signature) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ed25519Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ed25519Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -3431,6 +3726,9 @@ func (z *ed25519Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ed25519Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ed25519Signature) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ed25519Signature) return ok @@ -3479,7 +3777,12 @@ func (_ *ephemeralSubkey) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ephemeralSubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ephemeralSubkey) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0005 int @@ -3583,6 +3886,9 @@ func (z *ephemeralSubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ephemeralSubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ephemeralSubkey) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ephemeralSubkey) return ok diff --git a/crypto/stateproof/msgp_gen.go b/crypto/stateproof/msgp_gen.go index 94c84f000a..bd50401899 100644 --- a/crypto/stateproof/msgp_gen.go +++ b/crypto/stateproof/msgp_gen.go @@ -18,6 +18,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -27,6 +28,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -36,6 +38,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -45,6 +48,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -54,6 +58,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -63,6 +68,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -82,7 +88,12 @@ func (_ *MessageHash) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *MessageHash) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *MessageHash) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -92,6 +103,9 @@ func (z *MessageHash) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *MessageHash) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *MessageHash) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*MessageHash) return ok @@ -208,7 +222,12 @@ func (_ *Prover) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Prover) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -258,7 +277,7 @@ func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ProverPersistedFields.Participants = make([]basics.Participant, zb0006) } for zb0002 := range (*z).ProverPersistedFields.Participants { - bts, err = (*z).ProverPersistedFields.Participants[zb0002].UnmarshalMsg(bts) + bts, err = (*z).ProverPersistedFields.Participants[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Participants", zb0002) return @@ -277,7 +296,7 @@ func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).ProverPersistedFields.Parttree == nil { (*z).ProverPersistedFields.Parttree = new(merklearray.Tree) } - bts, err = (*z).ProverPersistedFields.Parttree.UnmarshalMsg(bts) + bts, err = (*z).ProverPersistedFields.Parttree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Parttree") return @@ -364,7 +383,7 @@ func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ProverPersistedFields.Participants = make([]basics.Participant, zb0008) } for zb0002 := range (*z).ProverPersistedFields.Participants { - bts, err = (*z).ProverPersistedFields.Participants[zb0002].UnmarshalMsg(bts) + bts, err = (*z).ProverPersistedFields.Participants[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Participants", zb0002) return @@ -381,7 +400,7 @@ func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).ProverPersistedFields.Parttree == nil { (*z).ProverPersistedFields.Parttree = new(merklearray.Tree) } - bts, err = (*z).ProverPersistedFields.Parttree.UnmarshalMsg(bts) + bts, err = (*z).ProverPersistedFields.Parttree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Parttree") return @@ -418,6 +437,9 @@ func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Prover) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Prover) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Prover) return ok @@ -551,7 +573,12 @@ func (_ *ProverPersistedFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ProverPersistedFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -601,7 +628,7 @@ func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Participants = make([]basics.Participant, zb0005) } for zb0002 := range (*z).Participants { - bts, err = (*z).Participants[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Participants[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Participants", zb0002) return @@ -620,7 +647,7 @@ func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Parttree == nil { (*z).Parttree = new(merklearray.Tree) } - bts, err = (*z).Parttree.UnmarshalMsg(bts) + bts, err = (*z).Parttree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Parttree") return @@ -707,7 +734,7 @@ func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Participants = make([]basics.Participant, zb0007) } for zb0002 := range (*z).Participants { - bts, err = (*z).Participants[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Participants[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Participants", zb0002) return @@ -724,7 +751,7 @@ func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Parttree == nil { (*z).Parttree = new(merklearray.Tree) } - bts, err = (*z).Parttree.UnmarshalMsg(bts) + bts, err = (*z).Parttree.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Parttree") return @@ -761,6 +788,9 @@ func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ProverPersistedFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ProverPersistedFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ProverPersistedFields) return ok @@ -860,7 +890,12 @@ func (_ *Reveal) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Reveal) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -885,7 +920,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).SigSlot.Sig.UnmarshalMsg(bts) + bts, err = (*z).SigSlot.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SigSlot", "struct-from-array", "Sig") return @@ -923,7 +958,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "s": - bts, err = (*z).SigSlot.Sig.UnmarshalMsg(bts) + bts, err = (*z).SigSlot.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SigSlot", "Sig") return @@ -946,7 +981,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Part.UnmarshalMsg(bts) + bts, err = (*z).Part.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Part") return @@ -987,7 +1022,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).SigSlot.Sig.UnmarshalMsg(bts) + bts, err = (*z).SigSlot.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SigSlot", "struct-from-array", "Sig") return @@ -1025,7 +1060,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "s": - bts, err = (*z).SigSlot.Sig.UnmarshalMsg(bts) + bts, err = (*z).SigSlot.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SigSlot", "Sig") return @@ -1046,7 +1081,7 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { } } case "p": - bts, err = (*z).Part.UnmarshalMsg(bts) + bts, err = (*z).Part.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Part") return @@ -1064,6 +1099,9 @@ func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Reveal) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Reveal) return ok @@ -1190,7 +1228,12 @@ func (_ *StateProof) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -1204,7 +1247,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).SigCommit.UnmarshalMsg(bts) + bts, err = (*z).SigCommit.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SigCommit") return @@ -1220,7 +1263,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).SigProofs.UnmarshalMsg(bts) + bts, err = (*z).SigProofs.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SigProofs") return @@ -1228,7 +1271,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).PartProofs.UnmarshalMsg(bts) + bts, err = (*z).PartProofs.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "PartProofs") return @@ -1270,7 +1313,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "struct-from-array", "Reveals") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Reveals", zb0001) return @@ -1331,7 +1374,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "c": - bts, err = (*z).SigCommit.UnmarshalMsg(bts) + bts, err = (*z).SigCommit.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SigCommit") return @@ -1343,13 +1386,13 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "S": - bts, err = (*z).SigProofs.UnmarshalMsg(bts) + bts, err = (*z).SigProofs.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SigProofs") return } case "P": - bts, err = (*z).PartProofs.UnmarshalMsg(bts) + bts, err = (*z).PartProofs.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "PartProofs") return @@ -1387,7 +1430,7 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "Reveals") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Reveals", zb0001) return @@ -1434,6 +1477,9 @@ func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateProof) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProof) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProof) return ok @@ -1515,7 +1561,12 @@ func (_ *sigslotCommit) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *sigslotCommit) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *sigslotCommit) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1529,7 +1580,7 @@ func (z *sigslotCommit) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -1567,7 +1618,7 @@ func (z *sigslotCommit) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "s": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -1591,6 +1642,9 @@ func (z *sigslotCommit) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *sigslotCommit) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *sigslotCommit) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*sigslotCommit) return ok diff --git a/daemon/algod/api/spec/v2/msgp_gen.go b/daemon/algod/api/spec/v2/msgp_gen.go index 140399c19c..45304fe948 100644 --- a/daemon/algod/api/spec/v2/msgp_gen.go +++ b/daemon/algod/api/spec/v2/msgp_gen.go @@ -13,6 +13,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -22,6 +23,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -73,7 +75,12 @@ func (_ *AccountApplicationModel) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AccountApplicationModel) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -97,7 +104,7 @@ func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) if (*z).AppLocalState == nil { (*z).AppLocalState = new(basics.AppLocalState) } - bts, err = (*z).AppLocalState.UnmarshalMsg(bts) + bts, err = (*z).AppLocalState.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppLocalState") return @@ -116,7 +123,7 @@ func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) if (*z).AppParams == nil { (*z).AppParams = new(basics.AppParams) } - bts, err = (*z).AppParams.UnmarshalMsg(bts) + bts, err = (*z).AppParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppParams") return @@ -157,7 +164,7 @@ func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) if (*z).AppLocalState == nil { (*z).AppLocalState = new(basics.AppLocalState) } - bts, err = (*z).AppLocalState.UnmarshalMsg(bts) + bts, err = (*z).AppLocalState.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppLocalState") return @@ -174,7 +181,7 @@ func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) if (*z).AppParams == nil { (*z).AppParams = new(basics.AppParams) } - bts, err = (*z).AppParams.UnmarshalMsg(bts) + bts, err = (*z).AppParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppParams") return @@ -193,6 +200,9 @@ func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *AccountApplicationModel) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AccountApplicationModel) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AccountApplicationModel) return ok @@ -274,7 +284,12 @@ func (_ *AccountAssetModel) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AccountAssetModel) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -298,7 +313,7 @@ func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).AssetParams == nil { (*z).AssetParams = new(basics.AssetParams) } - bts, err = (*z).AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams") return @@ -317,7 +332,7 @@ func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).AssetHolding == nil { (*z).AssetHolding = new(basics.AssetHolding) } - bts, err = (*z).AssetHolding.UnmarshalMsg(bts) + bts, err = (*z).AssetHolding.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetHolding") return @@ -358,7 +373,7 @@ func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).AssetParams == nil { (*z).AssetParams = new(basics.AssetParams) } - bts, err = (*z).AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams") return @@ -375,7 +390,7 @@ func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).AssetHolding == nil { (*z).AssetHolding = new(basics.AssetHolding) } - bts, err = (*z).AssetHolding.UnmarshalMsg(bts) + bts, err = (*z).AssetHolding.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetHolding") return @@ -394,6 +409,9 @@ func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AccountAssetModel) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AccountAssetModel) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AccountAssetModel) return ok diff --git a/data/account/msgp_gen.go b/data/account/msgp_gen.go index 3bef76693b..b7e6423046 100644 --- a/data/account/msgp_gen.go +++ b/data/account/msgp_gen.go @@ -15,6 +15,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -24,6 +25,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -103,7 +105,12 @@ func (_ *ParticipationKeyIdentity) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ParticipationKeyIdentity) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -117,7 +124,7 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).Parent.UnmarshalMsg(bts) + bts, err = (*z).Parent.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Parent") return @@ -125,7 +132,7 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).VRFSK.UnmarshalMsg(bts) + bts, err = (*z).VRFSK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VRFSK") return @@ -133,7 +140,7 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -141,7 +148,7 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).FirstValid.UnmarshalMsg(bts) + bts, err = (*z).FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FirstValid") return @@ -149,7 +156,7 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).LastValid.UnmarshalMsg(bts) + bts, err = (*z).LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LastValid") return @@ -187,31 +194,31 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error } switch string(field) { case "addr": - bts, err = (*z).Parent.UnmarshalMsg(bts) + bts, err = (*z).Parent.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Parent") return } case "vrfsk": - bts, err = (*z).VRFSK.UnmarshalMsg(bts) + bts, err = (*z).VRFSK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VRFSK") return } case "vote-id": - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "fv": - bts, err = (*z).FirstValid.UnmarshalMsg(bts) + bts, err = (*z).FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FirstValid") return } case "lv": - bts, err = (*z).LastValid.UnmarshalMsg(bts) + bts, err = (*z).LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LastValid") return @@ -235,6 +242,9 @@ func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error return } +func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ParticipationKeyIdentity) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ParticipationKeyIdentity) return ok @@ -280,7 +290,12 @@ func (_ StateProofKeys) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProofKeys) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0002 int var zb0003 bool zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) @@ -301,7 +316,7 @@ func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z) = make(StateProofKeys, zb0002) } for zb0001 := range *z { - bts, err = (*z)[zb0001].UnmarshalMsg(bts) + bts, err = (*z)[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, zb0001) return @@ -311,6 +326,9 @@ func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProofKeys) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProofKeys) return ok diff --git a/data/basics/msgp_gen.go b/data/basics/msgp_gen.go index 274b6c2b17..a317fda37e 100644 --- a/data/basics/msgp_gen.go +++ b/data/basics/msgp_gen.go @@ -17,6 +17,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -26,6 +27,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -34,6 +36,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -43,6 +46,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -52,6 +56,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -61,6 +66,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -70,6 +76,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -79,6 +86,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -88,6 +96,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -97,6 +106,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -106,6 +116,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -115,6 +126,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -124,6 +136,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -133,6 +146,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -142,6 +156,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -151,6 +166,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -160,6 +176,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -169,6 +186,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -178,6 +196,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -187,6 +206,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -196,6 +216,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -205,6 +226,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -214,6 +236,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -519,7 +542,12 @@ func (_ *AccountData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AccountData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0009 int @@ -545,7 +573,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") return @@ -561,7 +589,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardedMicroAlgos") return @@ -569,7 +597,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -577,7 +605,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -585,7 +613,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -646,12 +674,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 AssetIndex var zb0002 AssetParams zb0014-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams", zb0001) return @@ -682,7 +710,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 AssetIndex var zb0004 AssetHolding zb0016-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Assets") return @@ -761,7 +789,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -790,12 +818,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 AppIndex var zb0006 AppLocalState zb0020-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppLocalStates") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppLocalStates", zb0005) return @@ -826,12 +854,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0007 AppIndex var zb0008 AppParams zb0022-- - bts, err = zb0007.UnmarshalMsg(bts) + bts, err = zb0007.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppParams") return } - bts, err = zb0008.UnmarshalMsg(bts) + bts, err = zb0008.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppParams", zb0007) return @@ -969,7 +997,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Status = Status(zb0026) } case "algo": - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MicroAlgos") return @@ -981,25 +1009,25 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "ern": - bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardedMicroAlgos") return } case "vote": - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "sel": - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "stprf": - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return @@ -1052,12 +1080,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 AssetIndex var zb0002 AssetParams zb0029-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams", zb0001) return @@ -1086,7 +1114,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 AssetIndex var zb0004 AssetHolding zb0031-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Assets") return @@ -1163,7 +1191,7 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Assets[zb0003] = zb0004 } case "spend": - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return @@ -1190,12 +1218,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 AppIndex var zb0006 AppLocalState zb0035-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppLocalStates") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppLocalStates", zb0005) return @@ -1224,12 +1252,12 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0007 AppIndex var zb0008 AppParams zb0037-- - bts, err = zb0007.UnmarshalMsg(bts) + bts, err = zb0007.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppParams") return } - bts, err = zb0008.UnmarshalMsg(bts) + bts, err = zb0008.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppParams", zb0007) return @@ -1337,6 +1365,9 @@ func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AccountData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AccountData) return ok @@ -1429,6 +1460,9 @@ func (_ *Address) CanMarshalMsg(z interface{}) bool { func (z *Address) UnmarshalMsg(bts []byte) ([]byte, error) { return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) } +func (z *Address) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsgWithState(bts, st) +} func (_ *Address) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Address) return ok @@ -1465,7 +1499,12 @@ func (_ AppIndex) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AppIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AppIndex) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -1479,6 +1518,9 @@ func (z *AppIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AppIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AppIndex) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AppIndex) return ok @@ -1575,7 +1617,12 @@ func (_ *AppLocalState) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AppLocalState) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AppLocalState) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -1687,7 +1734,7 @@ func (z *AppLocalState) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "struct-from-array", "KeyValue") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "KeyValue", zb0001) return @@ -1815,7 +1862,7 @@ func (z *AppLocalState) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "KeyValue") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "KeyValue", zb0001) return @@ -1835,6 +1882,9 @@ func (z *AppLocalState) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AppLocalState) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AppLocalState) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AppLocalState) return ok @@ -2001,7 +2051,12 @@ func (_ *AppParams) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AppParams) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AppParams) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -2077,7 +2132,7 @@ func (z *AppParams) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "struct-from-array", "GlobalState") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GlobalState", zb0001) return @@ -2319,7 +2374,7 @@ func (z *AppParams) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "GlobalState") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GlobalState", zb0001) return @@ -2485,6 +2540,9 @@ func (z *AppParams) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AppParams) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AppParams) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AppParams) return ok @@ -2558,7 +2616,12 @@ func (_ *AssetHolding) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetHolding) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetHolding) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2634,6 +2697,9 @@ func (z *AssetHolding) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AssetHolding) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetHolding) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetHolding) return ok @@ -2672,7 +2738,12 @@ func (_ AssetIndex) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetIndex) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -2686,6 +2757,9 @@ func (z *AssetIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AssetIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetIndex) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetIndex) return ok @@ -2826,7 +2900,12 @@ func (_ *AssetParams) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetParams) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2926,7 +3005,7 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Manager.UnmarshalMsg(bts) + bts, err = (*z).Manager.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Manager") return @@ -2934,7 +3013,7 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Reserve.UnmarshalMsg(bts) + bts, err = (*z).Reserve.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Reserve") return @@ -2942,7 +3021,7 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Freeze.UnmarshalMsg(bts) + bts, err = (*z).Freeze.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Freeze") return @@ -2950,7 +3029,7 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Clawback.UnmarshalMsg(bts) + bts, err = (*z).Clawback.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Clawback") return @@ -3052,25 +3131,25 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "m": - bts, err = (*z).Manager.UnmarshalMsg(bts) + bts, err = (*z).Manager.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Manager") return } case "r": - bts, err = (*z).Reserve.UnmarshalMsg(bts) + bts, err = (*z).Reserve.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Reserve") return } case "f": - bts, err = (*z).Freeze.UnmarshalMsg(bts) + bts, err = (*z).Freeze.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Freeze") return } case "c": - bts, err = (*z).Clawback.UnmarshalMsg(bts) + bts, err = (*z).Clawback.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Clawback") return @@ -3088,6 +3167,9 @@ func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetParams) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetParams) return ok @@ -3418,7 +3500,12 @@ func (_ *BalanceRecord) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BalanceRecord) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0009 int @@ -3432,7 +3519,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).Addr.UnmarshalMsg(bts) + bts, err = (*z).Addr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Addr") return @@ -3452,7 +3539,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") return @@ -3468,7 +3555,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardedMicroAlgos") return @@ -3476,7 +3563,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -3484,7 +3571,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -3492,7 +3579,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -3553,12 +3640,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 AssetIndex var zb0002 AssetParams zb0014-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams", zb0001) return @@ -3589,7 +3676,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 AssetIndex var zb0004 AssetHolding zb0016-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Assets") return @@ -3668,7 +3755,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).AccountData.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AccountData.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -3697,12 +3784,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 AppIndex var zb0006 AppLocalState zb0020-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppLocalStates") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppLocalStates", zb0005) return @@ -3733,12 +3820,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0007 AppIndex var zb0008 AppParams zb0022-- - bts, err = zb0007.UnmarshalMsg(bts) + bts, err = zb0007.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppParams") return } - bts, err = zb0008.UnmarshalMsg(bts) + bts, err = zb0008.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AppParams", zb0007) return @@ -3866,7 +3953,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "addr": - bts, err = (*z).Addr.UnmarshalMsg(bts) + bts, err = (*z).Addr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Addr") return @@ -3882,7 +3969,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).AccountData.Status = Status(zb0026) } case "algo": - bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MicroAlgos") return @@ -3894,25 +3981,25 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "ern": - bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardedMicroAlgos") return } case "vote": - bts, err = (*z).AccountData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "sel": - bts, err = (*z).AccountData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "stprf": - bts, err = (*z).AccountData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).AccountData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return @@ -3965,12 +4052,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 AssetIndex var zb0002 AssetParams zb0029-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams", zb0001) return @@ -3999,7 +4086,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0003 AssetIndex var zb0004 AssetHolding zb0031-- - bts, err = zb0003.UnmarshalMsg(bts) + bts, err = zb0003.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Assets") return @@ -4076,7 +4163,7 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).AccountData.Assets[zb0003] = zb0004 } case "spend": - bts, err = (*z).AccountData.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AccountData.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return @@ -4103,12 +4190,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0005 AppIndex var zb0006 AppLocalState zb0035-- - bts, err = zb0005.UnmarshalMsg(bts) + bts, err = zb0005.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppLocalStates") return } - bts, err = zb0006.UnmarshalMsg(bts) + bts, err = zb0006.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppLocalStates", zb0005) return @@ -4137,12 +4224,12 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0007 AppIndex var zb0008 AppParams zb0037-- - bts, err = zb0007.UnmarshalMsg(bts) + bts, err = zb0007.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppParams") return } - bts, err = zb0008.UnmarshalMsg(bts) + bts, err = zb0008.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AppParams", zb0007) return @@ -4250,6 +4337,9 @@ func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BalanceRecord) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BalanceRecord) return ok @@ -4345,7 +4435,12 @@ func (_ CreatableIndex) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *CreatableIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *CreatableIndex) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -4359,6 +4454,9 @@ func (z *CreatableIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *CreatableIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *CreatableIndex) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*CreatableIndex) return ok @@ -4397,7 +4495,12 @@ func (_ CreatableType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *CreatableType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *CreatableType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -4411,6 +4514,9 @@ func (z *CreatableType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *CreatableType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *CreatableType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*CreatableType) return ok @@ -4449,7 +4555,12 @@ func (_ DeltaAction) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *DeltaAction) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *DeltaAction) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -4463,6 +4574,9 @@ func (z *DeltaAction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *DeltaAction) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *DeltaAction) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*DeltaAction) return ok @@ -4522,7 +4636,12 @@ func (_ *Participant) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Participant) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Participant) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4536,7 +4655,7 @@ func (z *Participant) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).PK.UnmarshalMsg(bts) + bts, err = (*z).PK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "PK") return @@ -4574,7 +4693,7 @@ func (z *Participant) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "p": - bts, err = (*z).PK.UnmarshalMsg(bts) + bts, err = (*z).PK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "PK") return @@ -4598,6 +4717,9 @@ func (z *Participant) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Participant) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Participant) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Participant) return ok @@ -4636,7 +4758,12 @@ func (_ Round) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Round) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Round) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -4650,6 +4777,9 @@ func (z *Round) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Round) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Round) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Round) return ok @@ -4688,7 +4818,12 @@ func (_ RoundInterval) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *RoundInterval) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *RoundInterval) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -4702,6 +4837,9 @@ func (z *RoundInterval) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *RoundInterval) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *RoundInterval) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*RoundInterval) return ok @@ -4755,7 +4893,12 @@ func (_ StateDelta) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateDelta) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0003 int var zb0004 bool zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) @@ -4782,7 +4925,7 @@ func (z *StateDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, zb0001) return @@ -4793,6 +4936,9 @@ func (z *StateDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateDelta) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateDelta) return ok @@ -4863,7 +5009,12 @@ func (_ *StateSchema) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateSchema) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateSchema) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4939,6 +5090,9 @@ func (z *StateSchema) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateSchema) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateSchema) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateSchema) return ok @@ -5042,7 +5196,12 @@ func (_ *StateSchemas) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateSchemas) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateSchemas) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -5374,6 +5533,9 @@ func (z *StateSchemas) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateSchemas) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateSchemas) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateSchemas) return ok @@ -5412,7 +5574,12 @@ func (_ Status) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Status) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Status) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 byte zb0001, bts, err = msgp.ReadByteBytes(bts) @@ -5426,6 +5593,9 @@ func (z *Status) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Status) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Status) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Status) return ok @@ -5479,7 +5649,12 @@ func (_ TealKeyValue) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TealKeyValue) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TealKeyValue) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0003 int var zb0004 bool zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) @@ -5506,7 +5681,7 @@ func (z *TealKeyValue) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, zb0001) return @@ -5517,6 +5692,9 @@ func (z *TealKeyValue) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TealKeyValue) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TealKeyValue) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TealKeyValue) return ok @@ -5566,7 +5744,12 @@ func (_ TealType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TealType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TealType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -5580,6 +5763,9 @@ func (z *TealType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TealType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TealType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TealType) return ok @@ -5648,7 +5834,12 @@ func (_ *TealValue) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TealValue) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TealValue) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -5746,6 +5937,9 @@ func (z *TealValue) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TealValue) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TealValue) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TealValue) return ok @@ -5816,7 +6010,12 @@ func (_ *ValueDelta) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ValueDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ValueDelta) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -5934,6 +6133,9 @@ func (z *ValueDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ValueDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ValueDelta) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ValueDelta) return ok diff --git a/data/basics/units.go b/data/basics/units.go index fbbb55eb92..d94ca95b6e 100644 --- a/data/basics/units.go +++ b/data/basics/units.go @@ -94,6 +94,14 @@ func (*MicroAlgos) CanUnmarshalMsg(z interface{}) bool { // UnmarshalMsg implements msgp.Unmarshaler func (a *MicroAlgos) UnmarshalMsg(bts []byte) (o []byte, err error) { + return a.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} + +// UnmarshalMsgWithState implements msgp.Unmarshaler +func (a *MicroAlgos) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + return nil, msgp.ErrMaxDepthExceeded{} + } a.Raw, o, err = msgp.ReadUint64Bytes(bts) return } diff --git a/data/bookkeeping/msgp_gen.go b/data/bookkeeping/msgp_gen.go index 6ccafb53ad..3ed5667dd8 100644 --- a/data/bookkeeping/msgp_gen.go +++ b/data/bookkeeping/msgp_gen.go @@ -20,6 +20,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -29,6 +30,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -37,6 +39,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -46,6 +49,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -55,6 +59,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -64,6 +69,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -73,6 +79,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -82,6 +89,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -91,6 +99,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -100,6 +109,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -109,6 +119,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -118,6 +129,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -402,7 +414,12 @@ func (_ *Block) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Block) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -416,7 +433,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -424,7 +441,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Branch") return @@ -432,7 +449,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -440,7 +457,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -448,7 +465,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -482,7 +499,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -490,7 +507,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -498,7 +515,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -530,7 +547,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -538,7 +555,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -546,7 +563,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocol") return @@ -562,7 +579,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") return @@ -570,7 +587,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") return @@ -578,7 +595,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -586,7 +603,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -631,12 +648,12 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 StateProofTrackingData zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking", zb0001) return @@ -666,7 +683,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0009) } for zb0003 := range (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0003) return @@ -675,7 +692,7 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).Payset.UnmarshalMsg(bts) + bts, err = (*z).Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Payset") return @@ -705,31 +722,31 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).BlockHeader.Round.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "prev": - bts, err = (*z).BlockHeader.Branch.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Branch") return } case "seed": - bts, err = (*z).BlockHeader.Seed.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "txn": - bts, err = (*z).BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -757,19 +774,19 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "fees": - bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -793,19 +810,19 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rwcalr": - bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return } case "proto": - bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return } case "nextproto": - bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocol") return @@ -817,25 +834,25 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "nextbefore": - bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolVoteBefore") return } case "nextswitch": - bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolSwitchOn") return } case "upgradeprop": - bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -874,12 +891,12 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 StateProofTrackingData zb0012-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking", zb0001) return @@ -907,14 +924,14 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0014) } for zb0003 := range (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).BlockHeader.ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0003) return } } case "txns": - bts, err = (*z).Payset.UnmarshalMsg(bts) + bts, err = (*z).Payset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Payset") return @@ -932,6 +949,9 @@ func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Block) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Block) return ok @@ -990,6 +1010,9 @@ func (_ *BlockHash) CanMarshalMsg(z interface{}) bool { func (z *BlockHash) UnmarshalMsg(bts []byte) ([]byte, error) { return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) } +func (z *BlockHash) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsgWithState(bts, st) +} func (_ *BlockHash) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BlockHash) return ok @@ -1276,7 +1299,12 @@ func (_ *BlockHeader) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BlockHeader) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -1290,7 +1318,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -1298,7 +1326,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).Branch.UnmarshalMsg(bts) + bts, err = (*z).Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Branch") return @@ -1306,7 +1334,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -1314,7 +1342,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -1322,7 +1350,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -1356,7 +1384,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -1364,7 +1392,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -1372,7 +1400,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -1404,7 +1432,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -1412,7 +1440,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -1420,7 +1448,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocol") return @@ -1436,7 +1464,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") return @@ -1444,7 +1472,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") return @@ -1452,7 +1480,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -1460,7 +1488,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -1505,12 +1533,12 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 StateProofTrackingData zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofTracking", zb0001) return @@ -1540,7 +1568,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0009) } for zb0003 := range (*z).ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0003) return @@ -1571,31 +1599,31 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rnd": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "prev": - bts, err = (*z).Branch.UnmarshalMsg(bts) + bts, err = (*z).Branch.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Branch") return } case "seed": - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "txn": - bts, err = (*z).TxnCommitments.NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).TxnCommitments.NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).TxnCommitments.Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).TxnCommitments.Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -1623,19 +1651,19 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "fees": - bts, err = (*z).RewardsState.FeeSink.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -1659,19 +1687,19 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rwcalr": - bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return } case "proto": - bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return } case "nextproto": - bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocol") return @@ -1683,25 +1711,25 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "nextbefore": - bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolVoteBefore") return } case "nextswitch": - bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NextProtocolSwitchOn") return } case "upgradeprop": - bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -1740,12 +1768,12 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 protocol.StateProofType var zb0002 StateProofTrackingData zb0012-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofTracking", zb0001) return @@ -1773,7 +1801,7 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ParticipationUpdates.ExpiredParticipationAccounts = make([]basics.Address, zb0014) } for zb0003 := range (*z).ParticipationUpdates.ExpiredParticipationAccounts { - bts, err = (*z).ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ParticipationUpdates.ExpiredParticipationAccounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0003) return @@ -1792,6 +1820,9 @@ func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BlockHeader) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BlockHeader) return ok @@ -1940,7 +1971,12 @@ func (_ *Genesis) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Genesis) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -1962,7 +1998,7 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Network.UnmarshalMsg(bts) + bts, err = (*z).Network.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Network") return @@ -1970,7 +2006,7 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proto") return @@ -1998,7 +2034,7 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Allocation = make([]GenesisAllocation, zb0004) } for zb0001 := range (*z).Allocation { - bts, err = (*z).Allocation[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Allocation[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Allocation", zb0001) return @@ -2075,13 +2111,13 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "network": - bts, err = (*z).Network.UnmarshalMsg(bts) + bts, err = (*z).Network.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Network") return } case "proto": - bts, err = (*z).Proto.UnmarshalMsg(bts) + bts, err = (*z).Proto.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proto") return @@ -2107,7 +2143,7 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Allocation = make([]GenesisAllocation, zb0006) } for zb0001 := range (*z).Allocation { - bts, err = (*z).Allocation[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Allocation[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Allocation", zb0001) return @@ -2156,6 +2192,9 @@ func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Genesis) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Genesis) return ok @@ -2284,7 +2323,12 @@ func (_ *GenesisAccountData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *GenesisAccountData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2298,7 +2342,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Status.UnmarshalMsg(bts) + bts, err = (*z).Status.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Status") return @@ -2306,7 +2350,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") return @@ -2314,7 +2358,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -2322,7 +2366,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -2330,7 +2374,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -2338,7 +2382,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") return @@ -2346,7 +2390,7 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") return @@ -2384,43 +2428,43 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "onl": - bts, err = (*z).Status.UnmarshalMsg(bts) + bts, err = (*z).Status.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Status") return } case "algo": - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MicroAlgos") return } case "vote": - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "stprf": - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return } case "sel": - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "voteFst": - bts, err = (*z).VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirstValid") return } case "voteLst": - bts, err = (*z).VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLastValid") return @@ -2444,6 +2488,9 @@ func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *GenesisAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *GenesisAccountData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*GenesisAccountData) return ok @@ -2488,7 +2535,12 @@ func (_ *GenesisAllocation) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *GenesisAllocation) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2518,7 +2570,7 @@ func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).State.UnmarshalMsg(bts) + bts, err = (*z).State.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "State") return @@ -2560,7 +2612,7 @@ func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "state": - bts, err = (*z).State.UnmarshalMsg(bts) + bts, err = (*z).State.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "State") return @@ -2578,6 +2630,9 @@ func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *GenesisAllocation) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*GenesisAllocation) return ok @@ -2659,7 +2714,12 @@ func (_ *LightBlockHeader) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *LightBlockHeader) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2673,7 +2733,7 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Seed") return @@ -2681,7 +2741,7 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -2689,7 +2749,7 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -2697,7 +2757,7 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sha256TxnCommitment.UnmarshalMsg(bts) + bts, err = (*z).Sha256TxnCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256TxnCommitment") return @@ -2727,25 +2787,25 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "0": - bts, err = (*z).Seed.UnmarshalMsg(bts) + bts, err = (*z).Seed.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Seed") return } case "r": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "gh": - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "tc": - bts, err = (*z).Sha256TxnCommitment.UnmarshalMsg(bts) + bts, err = (*z).Sha256TxnCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256TxnCommitment") return @@ -2763,6 +2823,9 @@ func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *LightBlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *LightBlockHeader) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*LightBlockHeader) return ok @@ -2820,7 +2883,12 @@ func (_ *ParticipationUpdates) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ParticipationUpdates) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ParticipationUpdates) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2854,7 +2922,7 @@ func (z *ParticipationUpdates) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ExpiredParticipationAccounts = make([]basics.Address, zb0004) } for zb0001 := range (*z).ExpiredParticipationAccounts { - bts, err = (*z).ExpiredParticipationAccounts[zb0001].UnmarshalMsg(bts) + bts, err = (*z).ExpiredParticipationAccounts[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ExpiredParticipationAccounts", zb0001) return @@ -2905,7 +2973,7 @@ func (z *ParticipationUpdates) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ExpiredParticipationAccounts = make([]basics.Address, zb0006) } for zb0001 := range (*z).ExpiredParticipationAccounts { - bts, err = (*z).ExpiredParticipationAccounts[zb0001].UnmarshalMsg(bts) + bts, err = (*z).ExpiredParticipationAccounts[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ExpiredParticipationAccounts", zb0001) return @@ -2924,6 +2992,9 @@ func (z *ParticipationUpdates) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ParticipationUpdates) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ParticipationUpdates) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ParticipationUpdates) return ok @@ -3024,7 +3095,12 @@ func (_ *RewardsState) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *RewardsState) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3038,7 +3114,7 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).FeeSink.UnmarshalMsg(bts) + bts, err = (*z).FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FeeSink") return @@ -3046,7 +3122,7 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsPool") return @@ -3078,7 +3154,7 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") return @@ -3108,13 +3184,13 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "fees": - bts, err = (*z).FeeSink.UnmarshalMsg(bts) + bts, err = (*z).FeeSink.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FeeSink") return } case "rwd": - bts, err = (*z).RewardsPool.UnmarshalMsg(bts) + bts, err = (*z).RewardsPool.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsPool") return @@ -3138,7 +3214,7 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rwcalr": - bts, err = (*z).RewardsRecalculationRound.UnmarshalMsg(bts) + bts, err = (*z).RewardsRecalculationRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardsRecalculationRound") return @@ -3156,6 +3232,9 @@ func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *RewardsState) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*RewardsState) return ok @@ -3224,7 +3303,12 @@ func (_ *StateProofTrackingData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProofTrackingData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3238,7 +3322,7 @@ func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofVotersCommitment.UnmarshalMsg(bts) + bts, err = (*z).StateProofVotersCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofVotersCommitment") return @@ -3246,7 +3330,7 @@ func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofOnlineTotalWeight.UnmarshalMsg(bts) + bts, err = (*z).StateProofOnlineTotalWeight.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofOnlineTotalWeight") return @@ -3254,7 +3338,7 @@ func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofNextRound.UnmarshalMsg(bts) + bts, err = (*z).StateProofNextRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofNextRound") return @@ -3284,19 +3368,19 @@ func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) } switch string(field) { case "v": - bts, err = (*z).StateProofVotersCommitment.UnmarshalMsg(bts) + bts, err = (*z).StateProofVotersCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofVotersCommitment") return } case "t": - bts, err = (*z).StateProofOnlineTotalWeight.UnmarshalMsg(bts) + bts, err = (*z).StateProofOnlineTotalWeight.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofOnlineTotalWeight") return } case "n": - bts, err = (*z).StateProofNextRound.UnmarshalMsg(bts) + bts, err = (*z).StateProofNextRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofNextRound") return @@ -3314,6 +3398,9 @@ func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *StateProofTrackingData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProofTrackingData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProofTrackingData) return ok @@ -3373,7 +3460,12 @@ func (_ *TxnCommitments) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TxnCommitments) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3387,7 +3479,7 @@ func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NativeSha512_256Commitment") return @@ -3395,7 +3487,7 @@ func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sha256Commitment") return @@ -3425,13 +3517,13 @@ func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "txn": - bts, err = (*z).NativeSha512_256Commitment.UnmarshalMsg(bts) + bts, err = (*z).NativeSha512_256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NativeSha512_256Commitment") return } case "txn256": - bts, err = (*z).Sha256Commitment.UnmarshalMsg(bts) + bts, err = (*z).Sha256Commitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sha256Commitment") return @@ -3449,6 +3541,9 @@ func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TxnCommitments) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TxnCommitments) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TxnCommitments) return ok @@ -3517,7 +3612,12 @@ func (_ *UpgradeVote) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *UpgradeVote) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3531,7 +3631,7 @@ func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") return @@ -3539,7 +3639,7 @@ func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") return @@ -3577,13 +3677,13 @@ func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "upgradeprop": - bts, err = (*z).UpgradePropose.UnmarshalMsg(bts) + bts, err = (*z).UpgradePropose.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradePropose") return } case "upgradedelay": - bts, err = (*z).UpgradeDelay.UnmarshalMsg(bts) + bts, err = (*z).UpgradeDelay.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "UpgradeDelay") return @@ -3607,6 +3707,9 @@ func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *UpgradeVote) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*UpgradeVote) return ok diff --git a/data/committee/msgp_gen.go b/data/committee/msgp_gen.go index 6427f3eb8a..e028a24054 100644 --- a/data/committee/msgp_gen.go +++ b/data/committee/msgp_gen.go @@ -14,6 +14,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -23,6 +24,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -32,6 +34,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -41,6 +44,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -111,7 +115,12 @@ func (_ *Credential) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Credential) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -133,7 +142,7 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VrfOut.UnmarshalMsg(bts) + bts, err = (*z).VrfOut.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VrfOut") return @@ -149,7 +158,7 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Hashable.UnmarshalMsg(bts) + bts, err = (*z).Hashable.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Hashable") return @@ -157,7 +166,7 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proof") return @@ -193,7 +202,7 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "h": - bts, err = (*z).VrfOut.UnmarshalMsg(bts) + bts, err = (*z).VrfOut.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VrfOut") return @@ -205,13 +214,13 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "hc": - bts, err = (*z).Hashable.UnmarshalMsg(bts) + bts, err = (*z).Hashable.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Hashable") return } case "pf": - bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsg(bts) + bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proof") return @@ -229,6 +238,9 @@ func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Credential) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Credential) return ok @@ -264,7 +276,12 @@ func (_ *Seed) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Seed) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -274,6 +291,9 @@ func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Seed) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Seed) return ok @@ -325,7 +345,12 @@ func (_ *UnauthenticatedCredential) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *UnauthenticatedCredential) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -339,7 +364,7 @@ func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err erro } if zb0001 > 0 { zb0001-- - bts, err = (*z).Proof.UnmarshalMsg(bts) + bts, err = (*z).Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Proof") return @@ -369,7 +394,7 @@ func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err erro } switch string(field) { case "pf": - bts, err = (*z).Proof.UnmarshalMsg(bts) + bts, err = (*z).Proof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Proof") return @@ -387,6 +412,9 @@ func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err erro return } +func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *UnauthenticatedCredential) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*UnauthenticatedCredential) return ok @@ -455,7 +483,12 @@ func (_ *hashableCredential) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *hashableCredential) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -469,7 +502,7 @@ func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).RawOut.UnmarshalMsg(bts) + bts, err = (*z).RawOut.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RawOut") return @@ -477,7 +510,7 @@ func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Member.UnmarshalMsg(bts) + bts, err = (*z).Member.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Member") return @@ -515,13 +548,13 @@ func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "v": - bts, err = (*z).RawOut.UnmarshalMsg(bts) + bts, err = (*z).RawOut.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RawOut") return } case "m": - bts, err = (*z).Member.UnmarshalMsg(bts) + bts, err = (*z).Member.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Member") return @@ -545,6 +578,9 @@ func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *hashableCredential) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*hashableCredential) return ok diff --git a/data/hashable/msgp_gen.go b/data/hashable/msgp_gen.go index 74707f076a..09b46dd2c5 100644 --- a/data/hashable/msgp_gen.go +++ b/data/hashable/msgp_gen.go @@ -11,6 +11,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -45,7 +46,12 @@ func (_ *Message) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Message) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -107,6 +113,9 @@ func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Message) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Message) return ok diff --git a/data/stateproofmsg/msgp_gen.go b/data/stateproofmsg/msgp_gen.go index 02a17491bf..6bcfccd18a 100644 --- a/data/stateproofmsg/msgp_gen.go +++ b/data/stateproofmsg/msgp_gen.go @@ -13,6 +13,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -83,7 +84,12 @@ func (_ *Message) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Message) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -241,6 +247,9 @@ func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Message) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Message) return ok diff --git a/data/transactions/msgp_gen.go b/data/transactions/msgp_gen.go index 1dd4a0930a..1cdd1e9701 100644 --- a/data/transactions/msgp_gen.go +++ b/data/transactions/msgp_gen.go @@ -21,6 +21,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -30,6 +31,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -39,6 +41,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -48,6 +51,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -57,6 +61,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -66,6 +71,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -75,6 +81,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -84,6 +91,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -93,6 +101,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -102,6 +111,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -111,6 +121,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -120,6 +131,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -129,6 +141,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -138,6 +151,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -147,6 +161,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -156,6 +171,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -165,6 +181,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -174,6 +191,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -183,6 +201,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -192,6 +211,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -384,7 +404,12 @@ func (_ *ApplicationCallTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ApplicationCallTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0006 int @@ -398,7 +423,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0006 > 0 { zb0006-- - bts, err = (*z).ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ApplicationID") return @@ -467,7 +492,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).Accounts = make([]basics.Address, zb0011) } for zb0002 := range (*z).Accounts { - bts, err = (*z).Accounts[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Accounts[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Accounts", zb0002) return @@ -496,7 +521,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).ForeignApps = make([]basics.AppIndex, zb0013) } for zb0003 := range (*z).ForeignApps { - bts, err = (*z).ForeignApps[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ForeignApps[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ForeignApps", zb0003) return @@ -638,7 +663,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).ForeignAssets = make([]basics.AssetIndex, zb0021) } for zb0005 := range (*z).ForeignAssets { - bts, err = (*z).ForeignAssets[zb0005].UnmarshalMsg(bts) + bts, err = (*z).ForeignAssets[zb0005].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ForeignAssets", zb0005) return @@ -647,7 +672,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0006 > 0 { zb0006-- - bts, err = (*z).LocalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).LocalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LocalStateSchema") return @@ -655,7 +680,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0006 > 0 { zb0006-- - bts, err = (*z).GlobalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).GlobalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GlobalStateSchema") return @@ -729,7 +754,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error } switch string(field) { case "apid": - bts, err = (*z).ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ApplicationID") return @@ -792,7 +817,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).Accounts = make([]basics.Address, zb0028) } for zb0002 := range (*z).Accounts { - bts, err = (*z).Accounts[zb0002].UnmarshalMsg(bts) + bts, err = (*z).Accounts[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Accounts", zb0002) return @@ -819,7 +844,7 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).ForeignApps = make([]basics.AppIndex, zb0030) } for zb0003 := range (*z).ForeignApps { - bts, err = (*z).ForeignApps[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ForeignApps[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ForeignApps", zb0003) return @@ -957,20 +982,20 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error (*z).ForeignAssets = make([]basics.AssetIndex, zb0038) } for zb0005 := range (*z).ForeignAssets { - bts, err = (*z).ForeignAssets[zb0005].UnmarshalMsg(bts) + bts, err = (*z).ForeignAssets[zb0005].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ForeignAssets", zb0005) return } } case "apls": - bts, err = (*z).LocalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).LocalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LocalStateSchema") return } case "apgs": - bts, err = (*z).GlobalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).GlobalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GlobalStateSchema") return @@ -1026,6 +1051,9 @@ func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error return } +func (z *ApplicationCallTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ApplicationCallTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ApplicationCallTxnFields) return ok @@ -1173,7 +1201,12 @@ func (_ *ApplyData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ApplyData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1187,7 +1220,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") return @@ -1203,7 +1236,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SenderRewards") return @@ -1211,7 +1244,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") return @@ -1219,7 +1252,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CloseRewards") return @@ -1227,7 +1260,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EvalDelta") return @@ -1235,7 +1268,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") return @@ -1243,7 +1276,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ApplicationID") return @@ -1273,7 +1306,7 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "ca": - bts, err = (*z).ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ClosingAmount") return @@ -1285,37 +1318,37 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rs": - bts, err = (*z).SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SenderRewards") return } case "rr": - bts, err = (*z).ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ReceiverRewards") return } case "rc": - bts, err = (*z).CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CloseRewards") return } case "dt": - bts, err = (*z).EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EvalDelta") return } case "caid": - bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ConfigAsset") return } case "apid": - bts, err = (*z).ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ApplicationID") return @@ -1333,6 +1366,9 @@ func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ApplyData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ApplyData) return ok @@ -1392,7 +1428,12 @@ func (_ *AssetConfigTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetConfigTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1406,7 +1447,7 @@ func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") return @@ -1414,7 +1455,7 @@ func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams") return @@ -1444,13 +1485,13 @@ func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "caid": - bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ConfigAsset") return } case "apar": - bts, err = (*z).AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams") return @@ -1468,6 +1509,9 @@ func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetConfigTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetConfigTxnFields) return ok @@ -1536,7 +1580,12 @@ func (_ *AssetFreezeTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetFreezeTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1550,7 +1599,7 @@ func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).FreezeAccount.UnmarshalMsg(bts) + bts, err = (*z).FreezeAccount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FreezeAccount") return @@ -1558,7 +1607,7 @@ func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).FreezeAsset.UnmarshalMsg(bts) + bts, err = (*z).FreezeAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FreezeAsset") return @@ -1596,13 +1645,13 @@ func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "fadd": - bts, err = (*z).FreezeAccount.UnmarshalMsg(bts) + bts, err = (*z).FreezeAccount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FreezeAccount") return } case "faid": - bts, err = (*z).FreezeAsset.UnmarshalMsg(bts) + bts, err = (*z).FreezeAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FreezeAsset") return @@ -1626,6 +1675,9 @@ func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetFreezeTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetFreezeTxnFields) return ok @@ -1712,7 +1764,12 @@ func (_ *AssetTransferTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AssetTransferTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1726,7 +1783,7 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).XferAsset.UnmarshalMsg(bts) + bts, err = (*z).XferAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "XferAsset") return @@ -1742,7 +1799,7 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).AssetSender.UnmarshalMsg(bts) + bts, err = (*z).AssetSender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetSender") return @@ -1750,7 +1807,7 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).AssetReceiver.UnmarshalMsg(bts) + bts, err = (*z).AssetReceiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetReceiver") return @@ -1758,7 +1815,7 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).AssetCloseTo.UnmarshalMsg(bts) + bts, err = (*z).AssetCloseTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetCloseTo") return @@ -1788,7 +1845,7 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) } switch string(field) { case "xaid": - bts, err = (*z).XferAsset.UnmarshalMsg(bts) + bts, err = (*z).XferAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "XferAsset") return @@ -1800,19 +1857,19 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) return } case "asnd": - bts, err = (*z).AssetSender.UnmarshalMsg(bts) + bts, err = (*z).AssetSender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetSender") return } case "arcv": - bts, err = (*z).AssetReceiver.UnmarshalMsg(bts) + bts, err = (*z).AssetReceiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetReceiver") return } case "aclose": - bts, err = (*z).AssetCloseTo.UnmarshalMsg(bts) + bts, err = (*z).AssetCloseTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetCloseTo") return @@ -1830,6 +1887,9 @@ func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AssetTransferTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AssetTransferTxnFields) return ok @@ -1889,7 +1949,12 @@ func (_ *BoxRef) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BoxRef) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BoxRef) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1985,6 +2050,9 @@ func (z *BoxRef) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BoxRef) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BoxRef) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BoxRef) return ok @@ -2107,7 +2175,12 @@ func (_ *EvalDelta) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *EvalDelta) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0006 int @@ -2121,7 +2194,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0006 > 0 { zb0006-- - bts, err = (*z).GlobalDelta.UnmarshalMsg(bts) + bts, err = (*z).GlobalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GlobalDelta") return @@ -2155,7 +2228,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "struct-from-array", "LocalDeltas") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LocalDeltas", zb0001) return @@ -2185,7 +2258,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).SharedAccts = make([]basics.Address, zb0010) } for zb0003 := range (*z).SharedAccts { - bts, err = (*z).SharedAccts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).SharedAccts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SharedAccts", zb0003) return @@ -2243,7 +2316,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).InnerTxns = make([]SignedTxnWithAD, zb0014) } for zb0005 := range (*z).InnerTxns { - bts, err = (*z).InnerTxns[zb0005].UnmarshalMsg(bts) + bts, err = (*z).InnerTxns[zb0005].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "InnerTxns", zb0005) return @@ -2274,7 +2347,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "gd": - bts, err = (*z).GlobalDelta.UnmarshalMsg(bts) + bts, err = (*z).GlobalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GlobalDelta") return @@ -2306,7 +2379,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "LocalDeltas") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LocalDeltas", zb0001) return @@ -2334,7 +2407,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).SharedAccts = make([]basics.Address, zb0018) } for zb0003 := range (*z).SharedAccts { - bts, err = (*z).SharedAccts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).SharedAccts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SharedAccts", zb0003) return @@ -2388,7 +2461,7 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).InnerTxns = make([]SignedTxnWithAD, zb0022) } for zb0005 := range (*z).InnerTxns { - bts, err = (*z).InnerTxns[zb0005].UnmarshalMsg(bts) + bts, err = (*z).InnerTxns[zb0005].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "InnerTxns", zb0005) return @@ -2407,6 +2480,9 @@ func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *EvalDelta) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *EvalDelta) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*EvalDelta) return ok @@ -2570,7 +2646,12 @@ func (_ *Header) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Header) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2584,7 +2665,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -2592,7 +2673,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Fee.UnmarshalMsg(bts) + bts, err = (*z).Fee.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Fee") return @@ -2600,7 +2681,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).FirstValid.UnmarshalMsg(bts) + bts, err = (*z).FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FirstValid") return @@ -2608,7 +2689,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).LastValid.UnmarshalMsg(bts) + bts, err = (*z).LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LastValid") return @@ -2652,7 +2733,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -2660,7 +2741,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Group.UnmarshalMsg(bts) + bts, err = (*z).Group.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Group") return @@ -2676,7 +2757,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).RekeyTo.UnmarshalMsg(bts) + bts, err = (*z).RekeyTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RekeyTo") return @@ -2706,25 +2787,25 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "snd": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "fee": - bts, err = (*z).Fee.UnmarshalMsg(bts) + bts, err = (*z).Fee.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Fee") return } case "fv": - bts, err = (*z).FirstValid.UnmarshalMsg(bts) + bts, err = (*z).FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FirstValid") return } case "lv": - bts, err = (*z).LastValid.UnmarshalMsg(bts) + bts, err = (*z).LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LastValid") return @@ -2762,13 +2843,13 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "grp": - bts, err = (*z).Group.UnmarshalMsg(bts) + bts, err = (*z).Group.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Group") return @@ -2780,7 +2861,7 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rekey": - bts, err = (*z).RekeyTo.UnmarshalMsg(bts) + bts, err = (*z).RekeyTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RekeyTo") return @@ -2798,6 +2879,9 @@ func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Header) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Header) return ok @@ -2905,7 +2989,12 @@ func (_ *KeyregTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *KeyregTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -2919,7 +3008,7 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VotePK.UnmarshalMsg(bts) + bts, err = (*z).VotePK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VotePK") return @@ -2927,7 +3016,7 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SelectionPK.UnmarshalMsg(bts) + bts, err = (*z).SelectionPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionPK") return @@ -2935,7 +3024,7 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofPK.UnmarshalMsg(bts) + bts, err = (*z).StateProofPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofPK") return @@ -2943,7 +3032,7 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteFirst.UnmarshalMsg(bts) + bts, err = (*z).VoteFirst.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirst") return @@ -2951,7 +3040,7 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteLast.UnmarshalMsg(bts) + bts, err = (*z).VoteLast.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLast") return @@ -2997,31 +3086,31 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "votekey": - bts, err = (*z).VotePK.UnmarshalMsg(bts) + bts, err = (*z).VotePK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VotePK") return } case "selkey": - bts, err = (*z).SelectionPK.UnmarshalMsg(bts) + bts, err = (*z).SelectionPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionPK") return } case "sprfkey": - bts, err = (*z).StateProofPK.UnmarshalMsg(bts) + bts, err = (*z).StateProofPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofPK") return } case "votefst": - bts, err = (*z).VoteFirst.UnmarshalMsg(bts) + bts, err = (*z).VoteFirst.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirst") return } case "votelst": - bts, err = (*z).VoteLast.UnmarshalMsg(bts) + bts, err = (*z).VoteLast.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLast") return @@ -3051,6 +3140,9 @@ func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *KeyregTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*KeyregTxnFields) return ok @@ -3135,7 +3227,12 @@ func (_ *LogicSig) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *LogicSig) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -3167,7 +3264,7 @@ func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -3175,7 +3272,7 @@ func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Msig.UnmarshalMsg(bts) + bts, err = (*z).Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msig") return @@ -3260,13 +3357,13 @@ func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return } case "msig": - bts, err = (*z).Msig.UnmarshalMsg(bts) + bts, err = (*z).Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msig") return @@ -3321,6 +3418,9 @@ func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *LogicSig) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*LogicSig) return ok @@ -3364,7 +3464,12 @@ func (_ OnCompletion) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OnCompletion) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OnCompletion) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -3378,6 +3483,9 @@ func (z *OnCompletion) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *OnCompletion) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OnCompletion) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OnCompletion) return ok @@ -3446,7 +3554,12 @@ func (_ *PaymentTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *PaymentTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3460,7 +3573,7 @@ func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Receiver.UnmarshalMsg(bts) + bts, err = (*z).Receiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Receiver") return @@ -3468,7 +3581,7 @@ func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Amount.UnmarshalMsg(bts) + bts, err = (*z).Amount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Amount") return @@ -3476,7 +3589,7 @@ func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).CloseRemainderTo.UnmarshalMsg(bts) + bts, err = (*z).CloseRemainderTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CloseRemainderTo") return @@ -3506,19 +3619,19 @@ func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "rcv": - bts, err = (*z).Receiver.UnmarshalMsg(bts) + bts, err = (*z).Receiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Receiver") return } case "amt": - bts, err = (*z).Amount.UnmarshalMsg(bts) + bts, err = (*z).Amount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Amount") return } case "close": - bts, err = (*z).CloseRemainderTo.UnmarshalMsg(bts) + bts, err = (*z).CloseRemainderTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CloseRemainderTo") return @@ -3536,6 +3649,9 @@ func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *PaymentTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*PaymentTxnFields) return ok @@ -3581,7 +3697,12 @@ func (_ Payset) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Payset) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Payset) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0002 int var zb0003 bool zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) @@ -3602,7 +3723,7 @@ func (z *Payset) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z) = make(Payset, zb0002) } for zb0001 := range *z { - bts, err = (*z)[zb0001].UnmarshalMsg(bts) + bts, err = (*z)[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, zb0001) return @@ -3612,6 +3733,9 @@ func (z *Payset) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Payset) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Payset) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Payset) return ok @@ -3702,7 +3826,12 @@ func (_ *SignedTxn) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SignedTxn) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -3716,7 +3845,7 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -3724,7 +3853,7 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Msig.UnmarshalMsg(bts) + bts, err = (*z).Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msig") return @@ -3732,7 +3861,7 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Lsig.UnmarshalMsg(bts) + bts, err = (*z).Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Lsig") return @@ -3740,7 +3869,7 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Txn.UnmarshalMsg(bts) + bts, err = (*z).Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Txn") return @@ -3748,7 +3877,7 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -3778,31 +3907,31 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return } case "msig": - bts, err = (*z).Msig.UnmarshalMsg(bts) + bts, err = (*z).Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msig") return } case "lsig": - bts, err = (*z).Lsig.UnmarshalMsg(bts) + bts, err = (*z).Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Lsig") return } case "txn": - bts, err = (*z).Txn.UnmarshalMsg(bts) + bts, err = (*z).Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Txn") return } case "sgnr": - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return @@ -3820,6 +3949,9 @@ func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SignedTxn) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SignedTxn) return ok @@ -3996,7 +4128,12 @@ func (_ *SignedTxnInBlock) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SignedTxnInBlock) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4010,7 +4147,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -4018,7 +4155,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msig") return @@ -4026,7 +4163,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Lsig") return @@ -4034,7 +4171,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Txn") return @@ -4042,7 +4179,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.SignedTxn.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -4050,7 +4187,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") return @@ -4066,7 +4203,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SenderRewards") return @@ -4074,7 +4211,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") return @@ -4082,7 +4219,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CloseRewards") return @@ -4090,7 +4227,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EvalDelta") return @@ -4098,7 +4235,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") return @@ -4106,7 +4243,7 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxnWithAD.ApplyData.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ApplicationID") return @@ -4152,37 +4289,37 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "sig": - bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return } case "msig": - bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msig") return } case "lsig": - bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Lsig") return } case "txn": - bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Txn") return } case "sgnr": - bts, err = (*z).SignedTxnWithAD.SignedTxn.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.SignedTxn.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return } case "ca": - bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ClosingAmount") return @@ -4194,37 +4331,37 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rs": - bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SenderRewards") return } case "rr": - bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ReceiverRewards") return } case "rc": - bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CloseRewards") return } case "dt": - bts, err = (*z).SignedTxnWithAD.ApplyData.EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EvalDelta") return } case "caid": - bts, err = (*z).SignedTxnWithAD.ApplyData.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ConfigAsset") return } case "apid": - bts, err = (*z).SignedTxnWithAD.ApplyData.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).SignedTxnWithAD.ApplyData.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ApplicationID") return @@ -4254,6 +4391,9 @@ func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SignedTxnInBlock) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SignedTxnInBlock) return ok @@ -4412,7 +4552,12 @@ func (_ *SignedTxnWithAD) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *SignedTxnWithAD) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4426,7 +4571,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxn.Sig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -4434,7 +4579,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxn.Msig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msig") return @@ -4442,7 +4587,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxn.Lsig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Lsig") return @@ -4450,7 +4595,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxn.Txn.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Txn") return @@ -4458,7 +4603,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignedTxn.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -4466,7 +4611,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") return @@ -4482,7 +4627,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SenderRewards") return @@ -4490,7 +4635,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") return @@ -4498,7 +4643,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CloseRewards") return @@ -4506,7 +4651,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "EvalDelta") return @@ -4514,7 +4659,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") return @@ -4522,7 +4667,7 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).ApplyData.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ApplicationID") return @@ -4552,37 +4697,37 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "sig": - bts, err = (*z).SignedTxn.Sig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return } case "msig": - bts, err = (*z).SignedTxn.Msig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Msig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msig") return } case "lsig": - bts, err = (*z).SignedTxn.Lsig.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Lsig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Lsig") return } case "txn": - bts, err = (*z).SignedTxn.Txn.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.Txn.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Txn") return } case "sgnr": - bts, err = (*z).SignedTxn.AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).SignedTxn.AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return } case "ca": - bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ClosingAmount") return @@ -4594,37 +4739,37 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rs": - bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SenderRewards") return } case "rr": - bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ReceiverRewards") return } case "rc": - bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CloseRewards") return } case "dt": - bts, err = (*z).ApplyData.EvalDelta.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.EvalDelta.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "EvalDelta") return } case "caid": - bts, err = (*z).ApplyData.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ConfigAsset") return } case "apid": - bts, err = (*z).ApplyData.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplyData.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ApplicationID") return @@ -4642,6 +4787,9 @@ func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *SignedTxnWithAD) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*SignedTxnWithAD) return ok @@ -4710,7 +4858,12 @@ func (_ *StateProofTxnFields) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProofTxnFields) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -4724,7 +4877,7 @@ func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofType.UnmarshalMsg(bts) + bts, err = (*z).StateProofType.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofType") return @@ -4732,7 +4885,7 @@ func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProof.UnmarshalMsg(bts) + bts, err = (*z).StateProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProof") return @@ -4740,7 +4893,7 @@ func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Message.UnmarshalMsg(bts) + bts, err = (*z).Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Message") return @@ -4770,19 +4923,19 @@ func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "sptype": - bts, err = (*z).StateProofType.UnmarshalMsg(bts) + bts, err = (*z).StateProofType.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofType") return } case "sp": - bts, err = (*z).StateProof.UnmarshalMsg(bts) + bts, err = (*z).StateProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProof") return } case "spmsg": - bts, err = (*z).Message.UnmarshalMsg(bts) + bts, err = (*z).Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Message") return @@ -4800,6 +4953,9 @@ func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateProofTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProofTxnFields) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProofTxnFields) return ok @@ -5312,7 +5468,12 @@ func (_ *Transaction) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Transaction) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0007 int @@ -5326,7 +5487,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Type.UnmarshalMsg(bts) + bts, err = (*z).Type.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Type") return @@ -5334,7 +5495,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.Sender.UnmarshalMsg(bts) + bts, err = (*z).Header.Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -5342,7 +5503,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.Fee.UnmarshalMsg(bts) + bts, err = (*z).Header.Fee.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Fee") return @@ -5350,7 +5511,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.FirstValid.UnmarshalMsg(bts) + bts, err = (*z).Header.FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FirstValid") return @@ -5358,7 +5519,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.LastValid.UnmarshalMsg(bts) + bts, err = (*z).Header.LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LastValid") return @@ -5402,7 +5563,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).Header.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GenesisHash") return @@ -5410,7 +5571,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.Group.UnmarshalMsg(bts) + bts, err = (*z).Header.Group.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Group") return @@ -5426,7 +5587,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).Header.RekeyTo.UnmarshalMsg(bts) + bts, err = (*z).Header.RekeyTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RekeyTo") return @@ -5434,7 +5595,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VotePK") return @@ -5442,7 +5603,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionPK") return @@ -5450,7 +5611,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).KeyregTxnFields.StateProofPK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.StateProofPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofPK") return @@ -5458,7 +5619,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirst") return @@ -5466,7 +5627,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLast") return @@ -5490,7 +5651,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Receiver") return @@ -5498,7 +5659,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Amount") return @@ -5506,7 +5667,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CloseRemainderTo") return @@ -5514,7 +5675,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") return @@ -5522,7 +5683,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetParams") return @@ -5530,7 +5691,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "XferAsset") return @@ -5546,7 +5707,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetSender") return @@ -5554,7 +5715,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetReceiver") return @@ -5562,7 +5723,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AssetCloseTo") return @@ -5570,7 +5731,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsg(bts) + bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FreezeAccount") return @@ -5578,7 +5739,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "FreezeAsset") return @@ -5594,7 +5755,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).ApplicationCallTxnFields.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ApplicationID") return @@ -5663,7 +5824,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.Accounts = make([]basics.Address, zb0014) } for zb0003 := range (*z).ApplicationCallTxnFields.Accounts { - bts, err = (*z).ApplicationCallTxnFields.Accounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.Accounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Accounts", zb0003) return @@ -5692,7 +5853,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.ForeignApps = make([]basics.AppIndex, zb0016) } for zb0004 := range (*z).ApplicationCallTxnFields.ForeignApps { - bts, err = (*z).ApplicationCallTxnFields.ForeignApps[zb0004].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ForeignApps[zb0004].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ForeignApps", zb0004) return @@ -5834,7 +5995,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.ForeignAssets = make([]basics.AssetIndex, zb0024) } for zb0006 := range (*z).ApplicationCallTxnFields.ForeignAssets { - bts, err = (*z).ApplicationCallTxnFields.ForeignAssets[zb0006].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ForeignAssets[zb0006].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "ForeignAssets", zb0006) return @@ -5843,7 +6004,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).ApplicationCallTxnFields.LocalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.LocalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LocalStateSchema") return @@ -5851,7 +6012,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).ApplicationCallTxnFields.GlobalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.GlobalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GlobalStateSchema") return @@ -5903,7 +6064,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).StateProofTxnFields.StateProofType.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.StateProofType.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofType") return @@ -5911,7 +6072,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).StateProofTxnFields.StateProof.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.StateProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProof") return @@ -5919,7 +6080,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).StateProofTxnFields.Message.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Message") return @@ -5949,31 +6110,31 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "type": - bts, err = (*z).Type.UnmarshalMsg(bts) + bts, err = (*z).Type.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Type") return } case "snd": - bts, err = (*z).Header.Sender.UnmarshalMsg(bts) + bts, err = (*z).Header.Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "fee": - bts, err = (*z).Header.Fee.UnmarshalMsg(bts) + bts, err = (*z).Header.Fee.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Fee") return } case "fv": - bts, err = (*z).Header.FirstValid.UnmarshalMsg(bts) + bts, err = (*z).Header.FirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FirstValid") return } case "lv": - bts, err = (*z).Header.LastValid.UnmarshalMsg(bts) + bts, err = (*z).Header.LastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LastValid") return @@ -6011,13 +6172,13 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "gh": - bts, err = (*z).Header.GenesisHash.UnmarshalMsg(bts) + bts, err = (*z).Header.GenesisHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GenesisHash") return } case "grp": - bts, err = (*z).Header.Group.UnmarshalMsg(bts) + bts, err = (*z).Header.Group.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Group") return @@ -6029,37 +6190,37 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rekey": - bts, err = (*z).Header.RekeyTo.UnmarshalMsg(bts) + bts, err = (*z).Header.RekeyTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RekeyTo") return } case "votekey": - bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VotePK") return } case "selkey": - bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionPK") return } case "sprfkey": - bts, err = (*z).KeyregTxnFields.StateProofPK.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.StateProofPK.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofPK") return } case "votefst": - bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirst") return } case "votelst": - bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsg(bts) + bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLast") return @@ -6077,37 +6238,37 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "rcv": - bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Receiver") return } case "amt": - bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Amount") return } case "close": - bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsg(bts) + bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CloseRemainderTo") return } case "caid": - bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ConfigAsset") return } case "apar": - bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsg(bts) + bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetParams") return } case "xaid": - bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "XferAsset") return @@ -6119,31 +6280,31 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "asnd": - bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetSender") return } case "arcv": - bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetReceiver") return } case "aclose": - bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsg(bts) + bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AssetCloseTo") return } case "fadd": - bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsg(bts) + bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FreezeAccount") return } case "faid": - bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsg(bts) + bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "FreezeAsset") return @@ -6155,7 +6316,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "apid": - bts, err = (*z).ApplicationCallTxnFields.ApplicationID.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ApplicationID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ApplicationID") return @@ -6218,7 +6379,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.Accounts = make([]basics.Address, zb0033) } for zb0003 := range (*z).ApplicationCallTxnFields.Accounts { - bts, err = (*z).ApplicationCallTxnFields.Accounts[zb0003].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.Accounts[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Accounts", zb0003) return @@ -6245,7 +6406,7 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.ForeignApps = make([]basics.AppIndex, zb0035) } for zb0004 := range (*z).ApplicationCallTxnFields.ForeignApps { - bts, err = (*z).ApplicationCallTxnFields.ForeignApps[zb0004].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ForeignApps[zb0004].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ForeignApps", zb0004) return @@ -6383,20 +6544,20 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).ApplicationCallTxnFields.ForeignAssets = make([]basics.AssetIndex, zb0043) } for zb0006 := range (*z).ApplicationCallTxnFields.ForeignAssets { - bts, err = (*z).ApplicationCallTxnFields.ForeignAssets[zb0006].UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.ForeignAssets[zb0006].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "ForeignAssets", zb0006) return } } case "apls": - bts, err = (*z).ApplicationCallTxnFields.LocalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.LocalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LocalStateSchema") return } case "apgs": - bts, err = (*z).ApplicationCallTxnFields.GlobalStateSchema.UnmarshalMsg(bts) + bts, err = (*z).ApplicationCallTxnFields.GlobalStateSchema.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GlobalStateSchema") return @@ -6440,19 +6601,19 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "sptype": - bts, err = (*z).StateProofTxnFields.StateProofType.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.StateProofType.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofType") return } case "sp": - bts, err = (*z).StateProofTxnFields.StateProof.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.StateProof.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProof") return } case "spmsg": - bts, err = (*z).StateProofTxnFields.Message.UnmarshalMsg(bts) + bts, err = (*z).StateProofTxnFields.Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Message") return @@ -6470,6 +6631,9 @@ func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Transaction) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Transaction) return ok @@ -6564,7 +6728,12 @@ func (_ *TxGroup) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TxGroup) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -6598,7 +6767,7 @@ func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).TxGroupHashes = make([]crypto.Digest, zb0004) } for zb0001 := range (*z).TxGroupHashes { - bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "TxGroupHashes", zb0001) return @@ -6649,7 +6818,7 @@ func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).TxGroupHashes = make([]crypto.Digest, zb0006) } for zb0001 := range (*z).TxGroupHashes { - bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsg(bts) + bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "TxGroupHashes", zb0001) return @@ -6668,6 +6837,9 @@ func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TxGroup) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TxGroup) return ok @@ -6708,6 +6880,9 @@ func (_ *Txid) CanMarshalMsg(z interface{}) bool { func (z *Txid) UnmarshalMsg(bts []byte) ([]byte, error) { return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) } +func (z *Txid) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsgWithState(bts, st) +} func (_ *Txid) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Txid) return ok diff --git a/go.mod b/go.mod index 33938aa428..fb1fa811ef 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/algorand/go-algorand go 1.20 +replace github.com/algorand/msgp => ./msgp + require ( github.com/DataDog/zstd v1.5.2 github.com/algorand/avm-abi v0.2.0 diff --git a/ledger/encoded/msgp_gen.go b/ledger/encoded/msgp_gen.go index cd9c99aaa2..4ac41dbd40 100644 --- a/ledger/encoded/msgp_gen.go +++ b/ledger/encoded/msgp_gen.go @@ -15,6 +15,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -24,6 +25,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -33,6 +35,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -76,7 +79,12 @@ func (_ *BalanceRecordV5) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BalanceRecordV5) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -90,7 +98,7 @@ func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Address.UnmarshalMsg(bts) + bts, err = (*z).Address.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Address") return @@ -98,7 +106,7 @@ func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).AccountData.UnmarshalMsg(bts) + bts, err = (*z).AccountData.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AccountData") return @@ -128,13 +136,13 @@ func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "pk": - bts, err = (*z).Address.UnmarshalMsg(bts) + bts, err = (*z).Address.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Address") return } case "ad": - bts, err = (*z).AccountData.UnmarshalMsg(bts) + bts, err = (*z).AccountData.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AccountData") return @@ -152,6 +160,9 @@ func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BalanceRecordV5) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BalanceRecordV5) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BalanceRecordV5) return ok @@ -245,7 +256,12 @@ func (_ *BalanceRecordV6) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BalanceRecordV6) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -259,7 +275,7 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Address.UnmarshalMsg(bts) + bts, err = (*z).Address.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Address") return @@ -267,7 +283,7 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).AccountData.UnmarshalMsg(bts) + bts, err = (*z).AccountData.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AccountData") return @@ -301,7 +317,7 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "struct-from-array", "Resources") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Resources", zb0001) return @@ -341,13 +357,13 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "a": - bts, err = (*z).Address.UnmarshalMsg(bts) + bts, err = (*z).Address.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Address") return } case "b": - bts, err = (*z).AccountData.UnmarshalMsg(bts) + bts, err = (*z).AccountData.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AccountData") return @@ -379,7 +395,7 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "Resources") return } - bts, err = zb0002.UnmarshalMsg(bts) + bts, err = zb0002.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Resources", zb0001) return @@ -405,6 +421,9 @@ func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BalanceRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BalanceRecordV6) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BalanceRecordV6) return ok @@ -481,7 +500,12 @@ func (_ *KVRecordV6) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *KVRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *KVRecordV6) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -597,6 +621,9 @@ func (z *KVRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *KVRecordV6) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *KVRecordV6) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*KVRecordV6) return ok diff --git a/ledger/ledgercore/msgp_gen.go b/ledger/ledgercore/msgp_gen.go index b0b8bdd280..63d1a9750b 100644 --- a/ledger/ledgercore/msgp_gen.go +++ b/ledger/ledgercore/msgp_gen.go @@ -15,6 +15,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -24,6 +25,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -33,6 +35,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -42,6 +45,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -169,7 +173,12 @@ func (_ *AccountTotals) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AccountTotals) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -194,7 +203,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Online.Money.UnmarshalMsg(bts) + bts, err = (*z).Online.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Online", "struct-from-array", "Money") return @@ -232,7 +241,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).Online.Money.UnmarshalMsg(bts) + bts, err = (*z).Online.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Online", "Money") return @@ -266,7 +275,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0005 > 0 { zb0005-- - bts, err = (*z).Offline.Money.UnmarshalMsg(bts) + bts, err = (*z).Offline.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Offline", "struct-from-array", "Money") return @@ -304,7 +313,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).Offline.Money.UnmarshalMsg(bts) + bts, err = (*z).Offline.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Offline", "Money") return @@ -338,7 +347,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0007 > 0 { zb0007-- - bts, err = (*z).NotParticipating.Money.UnmarshalMsg(bts) + bts, err = (*z).NotParticipating.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NotParticipating", "struct-from-array", "Money") return @@ -376,7 +385,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).NotParticipating.Money.UnmarshalMsg(bts) + bts, err = (*z).NotParticipating.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "NotParticipating", "Money") return @@ -440,7 +449,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0009 > 0 { zb0009-- - bts, err = (*z).Online.Money.UnmarshalMsg(bts) + bts, err = (*z).Online.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Online", "struct-from-array", "Money") return @@ -478,7 +487,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).Online.Money.UnmarshalMsg(bts) + bts, err = (*z).Online.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Online", "Money") return @@ -510,7 +519,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0011 > 0 { zb0011-- - bts, err = (*z).Offline.Money.UnmarshalMsg(bts) + bts, err = (*z).Offline.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Offline", "struct-from-array", "Money") return @@ -548,7 +557,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).Offline.Money.UnmarshalMsg(bts) + bts, err = (*z).Offline.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Offline", "Money") return @@ -580,7 +589,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0013 > 0 { zb0013-- - bts, err = (*z).NotParticipating.Money.UnmarshalMsg(bts) + bts, err = (*z).NotParticipating.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NotParticipating", "struct-from-array", "Money") return @@ -618,7 +627,7 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).NotParticipating.Money.UnmarshalMsg(bts) + bts, err = (*z).NotParticipating.Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "NotParticipating", "Money") return @@ -657,6 +666,9 @@ func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AccountTotals) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AccountTotals) return ok @@ -716,7 +728,12 @@ func (_ *AlgoCount) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *AlgoCount) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -730,7 +747,7 @@ func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Money.UnmarshalMsg(bts) + bts, err = (*z).Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Money") return @@ -768,7 +785,7 @@ func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "mon": - bts, err = (*z).Money.UnmarshalMsg(bts) + bts, err = (*z).Money.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Money") return @@ -792,6 +809,9 @@ func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *AlgoCount) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*AlgoCount) return ok @@ -860,7 +880,12 @@ func (_ *OnlineRoundParamsData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *OnlineRoundParamsData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *OnlineRoundParamsData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -890,7 +915,7 @@ func (z *OnlineRoundParamsData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") return @@ -932,7 +957,7 @@ func (z *OnlineRoundParamsData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "proto": - bts, err = (*z).CurrentProtocol.UnmarshalMsg(bts) + bts, err = (*z).CurrentProtocol.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "CurrentProtocol") return @@ -950,6 +975,9 @@ func (z *OnlineRoundParamsData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *OnlineRoundParamsData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *OnlineRoundParamsData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*OnlineRoundParamsData) return ok @@ -1027,7 +1055,12 @@ func (_ *StateProofVerificationContext) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProofVerificationContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1041,7 +1074,7 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err } if zb0001 > 0 { zb0001-- - bts, err = (*z).LastAttestedRound.UnmarshalMsg(bts) + bts, err = (*z).LastAttestedRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LastAttestedRound") return @@ -1049,7 +1082,7 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err } if zb0001 > 0 { zb0001-- - bts, err = (*z).VotersCommitment.UnmarshalMsg(bts) + bts, err = (*z).VotersCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VotersCommitment") return @@ -1057,7 +1090,7 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err } if zb0001 > 0 { zb0001-- - bts, err = (*z).OnlineTotalWeight.UnmarshalMsg(bts) + bts, err = (*z).OnlineTotalWeight.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "OnlineTotalWeight") return @@ -1065,7 +1098,7 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err } if zb0001 > 0 { zb0001-- - bts, err = (*z).Version.UnmarshalMsg(bts) + bts, err = (*z).Version.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Version") return @@ -1095,25 +1128,25 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err } switch string(field) { case "spround": - bts, err = (*z).LastAttestedRound.UnmarshalMsg(bts) + bts, err = (*z).LastAttestedRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LastAttestedRound") return } case "vc": - bts, err = (*z).VotersCommitment.UnmarshalMsg(bts) + bts, err = (*z).VotersCommitment.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VotersCommitment") return } case "pw": - bts, err = (*z).OnlineTotalWeight.UnmarshalMsg(bts) + bts, err = (*z).OnlineTotalWeight.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "OnlineTotalWeight") return } case "v": - bts, err = (*z).Version.UnmarshalMsg(bts) + bts, err = (*z).Version.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Version") return @@ -1131,6 +1164,9 @@ func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err return } +func (z *StateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProofVerificationContext) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProofVerificationContext) return ok diff --git a/ledger/msgp_gen.go b/ledger/msgp_gen.go index 7148edfa68..19fb667a25 100644 --- a/ledger/msgp_gen.go +++ b/ledger/msgp_gen.go @@ -16,6 +16,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -25,6 +26,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -34,6 +36,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -43,6 +46,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -52,6 +56,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -74,7 +79,12 @@ func (_ CatchpointCatchupState) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *CatchpointCatchupState) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *CatchpointCatchupState) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 int32 zb0001, bts, err = msgp.ReadInt32Bytes(bts) @@ -88,6 +98,9 @@ func (z *CatchpointCatchupState) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *CatchpointCatchupState) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *CatchpointCatchupState) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*CatchpointCatchupState) return ok @@ -210,7 +223,12 @@ func (_ *CatchpointFileHeader) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *CatchpointFileHeader) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -232,7 +250,7 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BalancesRound.UnmarshalMsg(bts) + bts, err = (*z).BalancesRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "BalancesRound") return @@ -240,7 +258,7 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BlocksRound.UnmarshalMsg(bts) + bts, err = (*z).BlocksRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "BlocksRound") return @@ -248,7 +266,7 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Totals.UnmarshalMsg(bts) + bts, err = (*z).Totals.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Totals") return @@ -288,7 +306,7 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BlockHeaderDigest.UnmarshalMsg(bts) + bts, err = (*z).BlockHeaderDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "BlockHeaderDigest") return @@ -324,19 +342,19 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "balancesRound": - bts, err = (*z).BalancesRound.UnmarshalMsg(bts) + bts, err = (*z).BalancesRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "BalancesRound") return } case "blocksRound": - bts, err = (*z).BlocksRound.UnmarshalMsg(bts) + bts, err = (*z).BlocksRound.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "BlocksRound") return } case "accountTotals": - bts, err = (*z).Totals.UnmarshalMsg(bts) + bts, err = (*z).Totals.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Totals") return @@ -366,7 +384,7 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "blockHeaderDigest": - bts, err = (*z).BlockHeaderDigest.UnmarshalMsg(bts) + bts, err = (*z).BlockHeaderDigest.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "BlockHeaderDigest") return @@ -384,6 +402,9 @@ func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *CatchpointFileHeader) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*CatchpointFileHeader) return ok @@ -443,7 +464,12 @@ func (_ *catchpointFileBalancesChunkV5) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *catchpointFileBalancesChunkV5) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *catchpointFileBalancesChunkV5) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -477,7 +503,7 @@ func (z *catchpointFileBalancesChunkV5) UnmarshalMsg(bts []byte) (o []byte, err (*z).Balances = make([]encoded.BalanceRecordV5, zb0004) } for zb0001 := range (*z).Balances { - bts, err = (*z).Balances[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Balances[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Balances", zb0001) return @@ -528,7 +554,7 @@ func (z *catchpointFileBalancesChunkV5) UnmarshalMsg(bts []byte) (o []byte, err (*z).Balances = make([]encoded.BalanceRecordV5, zb0006) } for zb0001 := range (*z).Balances { - bts, err = (*z).Balances[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Balances[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Balances", zb0001) return @@ -547,6 +573,9 @@ func (z *catchpointFileBalancesChunkV5) UnmarshalMsg(bts []byte) (o []byte, err return } +func (z *catchpointFileBalancesChunkV5) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *catchpointFileBalancesChunkV5) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*catchpointFileBalancesChunkV5) return ok @@ -625,7 +654,12 @@ func (_ *catchpointFileChunkV6) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *catchpointFileChunkV6) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -659,7 +693,7 @@ func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Balances = make([]encoded.BalanceRecordV6, zb0005) } for zb0001 := range (*z).Balances { - bts, err = (*z).Balances[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Balances[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Balances", zb0001) return @@ -688,7 +722,7 @@ func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).KVs = make([]encoded.KVRecordV6, zb0007) } for zb0002 := range (*z).KVs { - bts, err = (*z).KVs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).KVs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "KVs", zb0002) return @@ -739,7 +773,7 @@ func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Balances = make([]encoded.BalanceRecordV6, zb0009) } for zb0001 := range (*z).Balances { - bts, err = (*z).Balances[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Balances[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Balances", zb0001) return @@ -766,7 +800,7 @@ func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).KVs = make([]encoded.KVRecordV6, zb0011) } for zb0002 := range (*z).KVs { - bts, err = (*z).KVs[zb0002].UnmarshalMsg(bts) + bts, err = (*z).KVs[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "KVs", zb0002) return @@ -785,6 +819,9 @@ func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *catchpointFileChunkV6) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *catchpointFileChunkV6) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*catchpointFileChunkV6) return ok @@ -854,7 +891,12 @@ func (_ *catchpointStateProofVerificationContext) CanMarshalMsg(z interface{}) b } // UnmarshalMsg implements msgp.Unmarshaler -func (z *catchpointStateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *catchpointStateProofVerificationContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -888,7 +930,7 @@ func (z *catchpointStateProofVerificationContext) UnmarshalMsg(bts []byte) (o [] (*z).Data = make([]ledgercore.StateProofVerificationContext, zb0004) } for zb0001 := range (*z).Data { - bts, err = (*z).Data[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Data[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Data", zb0001) return @@ -939,7 +981,7 @@ func (z *catchpointStateProofVerificationContext) UnmarshalMsg(bts []byte) (o [] (*z).Data = make([]ledgercore.StateProofVerificationContext, zb0006) } for zb0001 := range (*z).Data { - bts, err = (*z).Data[zb0001].UnmarshalMsg(bts) + bts, err = (*z).Data[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Data", zb0001) return @@ -958,6 +1000,9 @@ func (z *catchpointStateProofVerificationContext) UnmarshalMsg(bts []byte) (o [] return } +func (z *catchpointStateProofVerificationContext) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *catchpointStateProofVerificationContext) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*catchpointStateProofVerificationContext) return ok diff --git a/ledger/store/trackerdb/generickv/msgp_gen.go b/ledger/store/trackerdb/generickv/msgp_gen.go index 4f5cba66b1..214b08500c 100644 --- a/ledger/store/trackerdb/generickv/msgp_gen.go +++ b/ledger/store/trackerdb/generickv/msgp_gen.go @@ -13,6 +13,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -56,7 +57,12 @@ func (_ *creatableEntry) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *creatableEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *creatableEntry) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -70,7 +76,7 @@ func (z *creatableEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Ctype.UnmarshalMsg(bts) + bts, err = (*z).Ctype.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Ctype") return @@ -108,7 +114,7 @@ func (z *creatableEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "Ctype": - bts, err = (*z).Ctype.UnmarshalMsg(bts) + bts, err = (*z).Ctype.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Ctype") return @@ -132,6 +138,9 @@ func (z *creatableEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *creatableEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *creatableEntry) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*creatableEntry) return ok diff --git a/ledger/store/trackerdb/msgp_gen.go b/ledger/store/trackerdb/msgp_gen.go index 203fd9fdba..fe2f6cd4a9 100644 --- a/ledger/store/trackerdb/msgp_gen.go +++ b/ledger/store/trackerdb/msgp_gen.go @@ -19,6 +19,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -28,6 +29,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -37,6 +39,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -46,6 +49,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -55,6 +59,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -64,6 +69,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -73,6 +79,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -82,6 +89,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -296,7 +304,12 @@ func (_ *BaseAccountData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BaseAccountData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -310,7 +323,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Status.UnmarshalMsg(bts) + bts, err = (*z).Status.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Status") return @@ -318,7 +331,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") return @@ -334,7 +347,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "RewardedMicroAlgos") return @@ -342,7 +355,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AuthAddr") return @@ -422,7 +435,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -430,7 +443,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -438,7 +451,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") return @@ -446,7 +459,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") return @@ -462,7 +475,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -500,13 +513,13 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "a": - bts, err = (*z).Status.UnmarshalMsg(bts) + bts, err = (*z).Status.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Status") return } case "b": - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MicroAlgos") return @@ -518,13 +531,13 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "d": - bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "RewardedMicroAlgos") return } case "e": - bts, err = (*z).AuthAddr.UnmarshalMsg(bts) + bts, err = (*z).AuthAddr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AuthAddr") return @@ -584,25 +597,25 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "A": - bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "B": - bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "C": - bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirstValid") return } case "D": - bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLastValid") return @@ -614,7 +627,7 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "F": - bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return @@ -638,6 +651,9 @@ func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BaseAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BaseAccountData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BaseAccountData) return ok @@ -751,7 +767,12 @@ func (_ *BaseOnlineAccountData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BaseOnlineAccountData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -765,7 +786,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -773,7 +794,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -781,7 +802,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") return @@ -789,7 +810,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") return @@ -805,7 +826,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -813,7 +834,7 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") return @@ -851,25 +872,25 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "A": - bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "B": - bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "C": - bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirstValid") return } case "D": - bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLastValid") return @@ -881,13 +902,13 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "F": - bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsg(bts) + bts, err = (*z).BaseVotingData.StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return } case "Y": - bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + bts, err = (*z).MicroAlgos.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "MicroAlgos") return @@ -911,6 +932,9 @@ func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BaseOnlineAccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BaseOnlineAccountData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BaseOnlineAccountData) return ok @@ -1006,7 +1030,12 @@ func (_ *BaseVotingData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *BaseVotingData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1020,7 +1049,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteID") return @@ -1028,7 +1057,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SelectionID") return @@ -1036,7 +1065,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") return @@ -1044,7 +1073,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") return @@ -1060,7 +1089,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofID") return @@ -1090,25 +1119,25 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "A": - bts, err = (*z).VoteID.UnmarshalMsg(bts) + bts, err = (*z).VoteID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteID") return } case "B": - bts, err = (*z).SelectionID.UnmarshalMsg(bts) + bts, err = (*z).SelectionID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SelectionID") return } case "C": - bts, err = (*z).VoteFirstValid.UnmarshalMsg(bts) + bts, err = (*z).VoteFirstValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteFirstValid") return } case "D": - bts, err = (*z).VoteLastValid.UnmarshalMsg(bts) + bts, err = (*z).VoteLastValid.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VoteLastValid") return @@ -1120,7 +1149,7 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "F": - bts, err = (*z).StateProofID.UnmarshalMsg(bts) + bts, err = (*z).StateProofID.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofID") return @@ -1138,6 +1167,9 @@ func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *BaseVotingData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *BaseVotingData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*BaseVotingData) return ok @@ -1242,7 +1274,12 @@ func (_ *CatchpointFirstStageInfo) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *CatchpointFirstStageInfo) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -1256,7 +1293,7 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).Totals.UnmarshalMsg(bts) + bts, err = (*z).Totals.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Totals") return @@ -1264,7 +1301,7 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).TrieBalancesHash.UnmarshalMsg(bts) + bts, err = (*z).TrieBalancesHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "TrieBalancesHash") return @@ -1304,7 +1341,7 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error } if zb0001 > 0 { zb0001-- - bts, err = (*z).StateProofVerificationHash.UnmarshalMsg(bts) + bts, err = (*z).StateProofVerificationHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "StateProofVerificationHash") return @@ -1334,13 +1371,13 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error } switch string(field) { case "accountTotals": - bts, err = (*z).Totals.UnmarshalMsg(bts) + bts, err = (*z).Totals.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Totals") return } case "trieBalancesHash": - bts, err = (*z).TrieBalancesHash.UnmarshalMsg(bts) + bts, err = (*z).TrieBalancesHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "TrieBalancesHash") return @@ -1370,7 +1407,7 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error return } case "spVerificationHash": - bts, err = (*z).StateProofVerificationHash.UnmarshalMsg(bts) + bts, err = (*z).StateProofVerificationHash.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "StateProofVerificationHash") return @@ -1388,6 +1425,9 @@ func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error return } +func (z *CatchpointFirstStageInfo) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *CatchpointFirstStageInfo) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*CatchpointFirstStageInfo) return ok @@ -1426,7 +1466,12 @@ func (_ ResourceFlags) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ResourceFlags) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ResourceFlags) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint8 zb0001, bts, err = msgp.ReadUint8Bytes(bts) @@ -1440,6 +1485,9 @@ func (z *ResourceFlags) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ResourceFlags) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ResourceFlags) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ResourceFlags) return ok @@ -1715,7 +1763,12 @@ func (_ *ResourcesData) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ResourcesData) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -1785,7 +1838,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Manager.UnmarshalMsg(bts) + bts, err = (*z).Manager.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Manager") return @@ -1793,7 +1846,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Reserve.UnmarshalMsg(bts) + bts, err = (*z).Reserve.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Reserve") return @@ -1801,7 +1854,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Freeze.UnmarshalMsg(bts) + bts, err = (*z).Freeze.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Freeze") return @@ -1809,7 +1862,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Clawback.UnmarshalMsg(bts) + bts, err = (*z).Clawback.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Clawback") return @@ -1849,7 +1902,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).KeyValue.UnmarshalMsg(bts) + bts, err = (*z).KeyValue.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "KeyValue") return @@ -1893,7 +1946,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).GlobalState.UnmarshalMsg(bts) + bts, err = (*z).GlobalState.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "GlobalState") return @@ -2025,25 +2078,25 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "h": - bts, err = (*z).Manager.UnmarshalMsg(bts) + bts, err = (*z).Manager.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Manager") return } case "i": - bts, err = (*z).Reserve.UnmarshalMsg(bts) + bts, err = (*z).Reserve.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Reserve") return } case "j": - bts, err = (*z).Freeze.UnmarshalMsg(bts) + bts, err = (*z).Freeze.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Freeze") return } case "k": - bts, err = (*z).Clawback.UnmarshalMsg(bts) + bts, err = (*z).Clawback.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Clawback") return @@ -2073,7 +2126,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "p": - bts, err = (*z).KeyValue.UnmarshalMsg(bts) + bts, err = (*z).KeyValue.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "KeyValue") return @@ -2111,7 +2164,7 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } case "s": - bts, err = (*z).GlobalState.UnmarshalMsg(bts) + bts, err = (*z).GlobalState.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "GlobalState") return @@ -2175,6 +2228,9 @@ func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ResourcesData) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ResourcesData) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ResourcesData) return ok @@ -2282,7 +2338,12 @@ func (_ *TxTailRound) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TxTailRound) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0004 int @@ -2311,7 +2372,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).TxnIDs = make([]transactions.Txid, zb0006) } for zb0001 := range (*z).TxnIDs { - bts, err = (*z).TxnIDs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).TxnIDs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "TxnIDs", zb0001) return @@ -2335,7 +2396,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).LastValid = make([]basics.Round, zb0008) } for zb0002 := range (*z).LastValid { - bts, err = (*z).LastValid[zb0002].UnmarshalMsg(bts) + bts, err = (*z).LastValid[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "LastValid", zb0002) return @@ -2359,7 +2420,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Leases = make([]TxTailRoundLease, zb0010) } for zb0003 := range (*z).Leases { - bts, err = (*z).Leases[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Leases[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Leases", zb0003) return @@ -2368,7 +2429,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0004 > 0 { zb0004-- - bts, err = (*z).Hdr.UnmarshalMsg(bts) + bts, err = (*z).Hdr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Hdr") return @@ -2413,7 +2474,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).TxnIDs = make([]transactions.Txid, zb0012) } for zb0001 := range (*z).TxnIDs { - bts, err = (*z).TxnIDs[zb0001].UnmarshalMsg(bts) + bts, err = (*z).TxnIDs[zb0001].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "TxnIDs", zb0001) return @@ -2435,7 +2496,7 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).LastValid = make([]basics.Round, zb0014) } for zb0002 := range (*z).LastValid { - bts, err = (*z).LastValid[zb0002].UnmarshalMsg(bts) + bts, err = (*z).LastValid[zb0002].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "LastValid", zb0002) return @@ -2457,14 +2518,14 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).Leases = make([]TxTailRoundLease, zb0016) } for zb0003 := range (*z).Leases { - bts, err = (*z).Leases[zb0003].UnmarshalMsg(bts) + bts, err = (*z).Leases[zb0003].UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Leases", zb0003) return } } case "h": - bts, err = (*z).Hdr.UnmarshalMsg(bts) + bts, err = (*z).Hdr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Hdr") return @@ -2482,6 +2543,9 @@ func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TxTailRound) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TxTailRound) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TxTailRound) return ok @@ -2571,7 +2635,12 @@ func (_ *TxTailRoundLease) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TxTailRoundLease) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TxTailRoundLease) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -2585,7 +2654,7 @@ func (z *TxTailRoundLease) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -2631,7 +2700,7 @@ func (z *TxTailRoundLease) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "s": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return @@ -2661,6 +2730,9 @@ func (z *TxTailRoundLease) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TxTailRoundLease) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TxTailRoundLease) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TxTailRoundLease) return ok diff --git a/msgp/.gitignore b/msgp/.gitignore new file mode 100644 index 0000000000..2d19289705 --- /dev/null +++ b/msgp/.gitignore @@ -0,0 +1,13 @@ +_generated/generated.go +_generated/generated_test.go +_generated/*_gen.go +_generated/*_gen_test.go +_generated/embeddedStruct/*_gen.go +_generated/embeddedStruct/*_gen_test.go +msgp/defgen_test.go +msgp/cover.out +*~ +*.coverprofile +.idea/ +.vscode/ +cover.out diff --git a/msgp/.travis.yml b/msgp/.travis.yml new file mode 100644 index 0000000000..5f574c093b --- /dev/null +++ b/msgp/.travis.yml @@ -0,0 +1,11 @@ +language: go + +go: + - 1.12.x + - tip + +env: + - GIMME_ARCH=amd64 + - GIMME_ARCH=386 + +script: "make travis" diff --git a/msgp/LICENSE b/msgp/LICENSE new file mode 100644 index 0000000000..14d60424e8 --- /dev/null +++ b/msgp/LICENSE @@ -0,0 +1,8 @@ +Copyright (c) 2014 Philip Hofer +Portions Copyright (c) 2009 The Go Authors (license at http://golang.org) where indicated + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/msgp/Makefile b/msgp/Makefile new file mode 100644 index 0000000000..a77d20d5ce --- /dev/null +++ b/msgp/Makefile @@ -0,0 +1,47 @@ + +# NOTE: This Makefile is only necessary if you +# plan on developing the msgp tool and library. +# Installation can still be performed with a +# normal `go install`. + +# generated unit test files +MGEN = ./msgp/defgen_test.go + +SHELL := /bin/bash + +BIN = $(GOBIN)/msgp + +.PHONY: clean wipe install get-deps bench all + +$(BIN): */*.go + @go install ./... + +install: $(BIN) + +$(MGEN): ./msgp/defs_test.go + go generate ./msgp + +test: all + go test -covermode=atomic -coverprofile=cover.out ./... + +bench: all + go test -bench ./... + +clean: + $(RM) $(MGEN) + +wipe: clean + $(RM) $(BIN) + +get-deps: + go get -d -t ./... + +all: install $(MGEN) + +# travis CI enters here +travis: + go get -d -t ./... + go build -o "$${GOPATH%%:*}/bin/msgp" . + go generate ./msgp + go generate ./_generated + go test -v ./... ./_generated diff --git a/msgp/README.md b/msgp/README.md new file mode 100644 index 0000000000..f5d3528a03 --- /dev/null +++ b/msgp/README.md @@ -0,0 +1,4 @@ +MessagePack Code Generator +======= + +Based on [github.com/tinylib/msgp](https://github.com/tinylib/msgp) diff --git a/msgp/gen/elem.go b/msgp/gen/elem.go new file mode 100644 index 0000000000..707b56bd94 --- /dev/null +++ b/msgp/gen/elem.go @@ -0,0 +1,992 @@ +package gen + +import ( + "fmt" + "go/ast" + "strconv" + "strings" +) + +var ( + identNext = 0 + identPrefix = "za" +) + +func resetIdent(prefix string) { + identPrefix = prefix + identNext = 0 +} + +// generate a random identifier name +func randIdent() string { + identNext++ + return fmt.Sprintf("%s%04d", identPrefix, identNext) +} + +// This code defines the type declaration tree. +// +// Consider the following: +// +// type Marshaler struct { +// Thing1 *float64 `msg:"thing1"` +// Body []byte `msg:"body"` +// } +// +// A parser using this generator as a backend +// should parse the above into: +// +// var val Elem = &Ptr{ +// name: "z", +// Value: &Struct{ +// Name: "Marshaler", +// Fields: []StructField{ +// { +// FieldTag: "thing1", +// FieldElem: &Ptr{ +// name: "z.Thing1", +// Value: &BaseElem{ +// name: "*z.Thing1", +// Value: Float64, +// Convert: false, +// }, +// }, +// }, +// { +// FieldTag: "body", +// FieldElem: &BaseElem{ +// name: "z.Body", +// Value: Bytes, +// Convert: false, +// }, +// }, +// }, +// }, +// } + +// Base is one of the +// base types +type Primitive uint8 + +// this is effectively the +// list of currently available +// ReadXxxx / WriteXxxx methods. +const ( + Invalid Primitive = iota + Bytes + String + Float32 + Float64 + Complex64 + Complex128 + Uint + Uint8 + Uint16 + Uint32 + Uint64 + Uintptr + Byte + Int + Int8 + Int16 + Int32 + Int64 + Bool + Intf // interface{} + Time // time.Time + Ext // extension + Error // error + Duration // time.Duration + + IDENT // IDENT means an unrecognized identifier +) + +// all of the recognized identities +// that map to primitive types +var primitives = map[string]Primitive{ + "[]byte": Bytes, + "string": String, + "float32": Float32, + "float64": Float64, + "complex64": Complex64, + "complex128": Complex128, + "uint": Uint, + "uint8": Uint8, + "uint16": Uint16, + "uint32": Uint32, + "uint64": Uint64, + "uintptr": Uintptr, + "byte": Byte, + "rune": Int32, + "int": Int, + "int8": Int8, + "int16": Int16, + "int32": Int32, + "int64": Int64, + "bool": Bool, + "interface{}": Intf, + "time.Time": Time, + "msgp.Extension": Ext, + "error": Error, + "time.Duration": Duration, +} + +// types built into the library +// that satisfy all of the +// interfaces. +var builtins = map[string]struct{}{ + "msgp.Raw": struct{}{}, + "msgp.Number": struct{}{}, +} + +// Callback represents a function that can is expected to be printed into the generated code. +// for example, at the end of a successful unmarshalling. +type Callback struct { + Fname string + CallbackType CallbackType +} + +type CallbackType uint64 + +// UnmarshalCallBack represents a type callback that should run over the generated code. +const UnmarshalCallBack CallbackType = 1 + +func (c Callback) IsUnmarshallCallback() bool { return c.CallbackType == UnmarshalCallBack } +func (c Callback) GetName() string { return c.Fname } + +// common data/methods for every Elem +type common struct { + vname, alias string + allocbound string + maxtotalbytes string + callbacks []Callback +} + +func (c *common) SetVarname(s string) { c.vname = s } +func (c *common) Varname() string { return c.vname } +func (c *common) Alias(typ string) { c.alias = typ } +func (c *common) SortInterface() string { return "" } +func (c *common) SetAllocBound(s string) { c.allocbound = s } +func (c *common) AllocBound() string { return c.allocbound } +func (c *common) SetMaxTotalBytes(s string) { c.maxtotalbytes = s } +func (c *common) MaxTotalBytes() string { return c.maxtotalbytes } +func (c *common) GetCallbacks() []Callback { return c.callbacks } +func (c *common) AddCallback(cb Callback) { c.callbacks = append(c.callbacks, cb) } +func (c *common) hidden() {} + +func IsDangling(e Elem) bool { + if be, ok := e.(*BaseElem); ok && be.Dangling() { + return true + } + return false +} + +// Elem is a go type capable of being +// serialized into MessagePack. It is +// implemented by *Ptr, *Struct, *Array, +// *Slice, *Map, and *BaseElem. +type Elem interface { + // SetVarname sets this nodes + // variable name and recursively + // sets the names of all its children. + // In general, this should only be + // called on the parent of the tree. + SetVarname(s string) + + // Varname returns the variable + // name of the element. + Varname() string + + // TypeName is the canonical + // go type name of the node + // e.g. "string", "int", "map[string]float64" + // OR the alias name, if it has been set. + TypeName() string + + // Alias sets a type (alias) name + Alias(typ string) + + // Copy should perform a deep copy of the object + Copy() Elem + + // Complexity returns a measure of the + // complexity of element (greater than + // or equal to 1.) + Complexity() int + + // ZeroExpr returns the expression for the correct zero/empty + // value. Can be used for assignment. + // Returns "" if zero/empty not supported for this Elem. + ZeroExpr() string + + // IfZeroExpr returns the expression to compare to zero/empty + // for this type. It is meant to be used in an if statement + // and may include the simple statement form followed by + // semicolon and then the expression. + // Returns "" if zero/empty not supported for this Elem. + IfZeroExpr() string + + // SortInterface returns the sort.Interface for sorting a + // slice of this type. + SortInterface() string + + // Comparable returns whether the type is comparable, along the lines + // of the Go spec (https://golang.org/ref/spec#Comparison_operators), + // used to determine whether we can compare to a zero value to determine + // zeroness. + Comparable() bool + + // SetAllocBound specifies the maximum number of elements to allocate + // when decoding this type. Meaningful for slices and maps. + // Blank means unspecified bound. "-" means no bound. + SetAllocBound(bound string) + + // AllocBound returns the maximum number of elements to allocate + // when decoding this type. Meaningful for slices and maps. + AllocBound() string + + // SetMaxTotalBytes specifies the maximum number of bytes to allocate when + // decoding this type. + // Blank means unspecified bound. "-" means no bound. + SetMaxTotalBytes(bound string) + + // MaxTotalBytes specifies the maximum number of bytes to allocate when + // decoding this type. Meaningful for slices of strings or byteslices. + MaxTotalBytes() string + + // AddCallback adds to the elem a Callback it should call at the end of marshaling + AddCallback(Callback) + + // GetCallbacks fetches all callbacks this Elem stored. + GetCallbacks() []Callback + + hidden() +} + +// Ident returns the *BaseElem that corresponds +// to the provided identity. +func Ident(importPrefix string, id string) *BaseElem { + p, ok := primitives[id] + if ok { + return &BaseElem{Value: p} + } + id = importPrefix + id + be := &BaseElem{Value: IDENT, IdentName: id} + be.Alias(id) + return be +} + +type Array struct { + common + Index string // index variable name + Size string // array size + SizeHint string // const object referred to by Size + Els Elem // child +} + +func (a *Array) SetVarname(s string) { + a.common.SetVarname(s) +ridx: + a.Index = randIdent() + + // try to avoid using the same + // index as a parent slice + if strings.Contains(a.Varname(), a.Index) { + goto ridx + } + + a.Els.SetVarname(fmt.Sprintf("%s[%s]", a.Varname(), a.Index)) +} + +func (a *Array) TypeName() string { + if a.common.alias != "" { + return a.common.alias + } + a.common.Alias(fmt.Sprintf("[%s]%s", a.Size, a.Els.TypeName())) + return a.common.alias +} + +func (a *Array) Copy() Elem { + b := *a + b.Els = a.Els.Copy() + return &b +} + +func (a *Array) Complexity() int { return 1 + a.Els.Complexity() } + +func (a *Array) sz() int { + szString := a.SizeHint + if szString == "" { + szString = a.Size + } + + s, err := strconv.Atoi(szString) + if err != nil { + panic(err) + } + + return s +} + +// ZeroExpr returns the zero/empty expression or empty string if not supported. +func (a *Array) ZeroExpr() string { + zeroElem := a.Els.ZeroExpr() + if zeroElem == "" { + return "" + } + + sz := a.sz() + + res := fmt.Sprintf("%s{", a.TypeName()) + for i := 0; i < sz; i++ { + res += fmt.Sprintf("%s, ", zeroElem) + } + res += "}" + return res +} + +// IfZeroExpr returns the expression to compare to zero/empty. +func (a *Array) IfZeroExpr() string { + // Special case for arrays of comparable elements: Go generates + // faster code if we just compare to a zero value. + if a.Els.Comparable() { + return fmt.Sprintf("%s == (%s{})", a.Varname(), a.TypeName()) + } + + sz := a.sz() + + var res string + for i := 0; i < sz; i++ { + el := a.Els.Copy() + el.SetVarname(fmt.Sprintf("%s[%d]", a.Varname(), i)) + if res != "" { + res += " && " + } + res += "(" + el.IfZeroExpr() + ")" + } + return res +} + +// Comparable returns whether this elem's type is comparable. +func (a *Array) Comparable() bool { + return a.Els.Comparable() +} + +// Map is a map[string]Elem +type Map struct { + common + Keyidx string // key variable name + Key Elem // type of map key + Validx string // value variable name + Value Elem // value element +} + +func (m *Map) SetVarname(s string) { + m.common.SetVarname(s) +ridx: + m.Keyidx = randIdent() + m.Validx = randIdent() + + // just in case + if m.Keyidx == m.Validx { + goto ridx + } + + m.Key.SetVarname(m.Keyidx) + m.Value.SetVarname(m.Validx) +} + +func (m *Map) TypeName() string { + if m.common.alias != "" { + return m.common.alias + } + m.common.Alias("map[" + m.Key.TypeName() + "]" + m.Value.TypeName()) + return m.common.alias +} + +func (m *Map) Copy() Elem { + g := *m + g.Key = m.Key.Copy() + g.Value = m.Value.Copy() + return &g +} + +func (m *Map) Complexity() int { return 2 + m.Value.Complexity() } + +// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. +func (m *Map) ZeroExpr() string { return "nil" } + +// IfZeroExpr returns the expression to compare to zero/empty. +func (m *Map) IfZeroExpr() string { return "len(" + m.Varname() + ") == 0" } + +// Comparable returns whether this elem's type is comparable. +func (m *Map) Comparable() bool { + return false +} + +type Slice struct { + common + Index string + Els Elem // The type of each element +} + +func (s *Slice) SetVarname(a string) { + s.common.SetVarname(a) + s.Index = randIdent() + varName := s.Varname() + if varName[0] == '*' { + // Pointer-to-slice requires parenthesis for slicing. + varName = "(" + varName + ")" + } + s.Els.SetVarname(fmt.Sprintf("%s[%s]", varName, s.Index)) +} + +func (s *Slice) TypeName() string { + if s.common.alias != "" { + return s.common.alias + } + s.common.Alias("[]" + s.Els.TypeName()) + return s.common.alias +} + +func (s *Slice) Copy() Elem { + z := *s + z.Els = s.Els.Copy() + return &z +} + +func (s *Slice) Complexity() int { + return 1 + s.Els.Complexity() +} + +// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. +func (s *Slice) ZeroExpr() string { return "nil" } + +// IfZeroExpr returns the expression to compare to zero/empty. +func (s *Slice) IfZeroExpr() string { return "len(" + s.Varname() + ") == 0" } + +// Comparable returns whether this elem's type is comparable. +func (s *Slice) Comparable() bool { + return false +} + +type Ptr struct { + common + Value Elem +} + +func (s *Ptr) SetVarname(a string) { + s.common.SetVarname(a) + + // struct fields are dereferenced + // automatically... + switch x := s.Value.(type) { + case *Struct: + // struct fields are automatically dereferenced + x.SetVarname(a) + return + + case *BaseElem: + // identities have pointer receivers + if x.Value == IDENT { + x.SetVarname(a) + } else { + x.SetVarname("*" + a) + } + return + + default: + s.Value.SetVarname("*" + a) + return + } +} + +func (s *Ptr) TypeName() string { + if s.common.alias != "" { + return s.common.alias + } + s.common.Alias("*" + s.Value.TypeName()) + return s.common.alias +} + +func (s *Ptr) Copy() Elem { + v := *s + v.Value = s.Value.Copy() + return &v +} + +func (s *Ptr) Complexity() int { return 1 + s.Value.Complexity() } + +func (s *Ptr) Needsinit() bool { + if be, ok := s.Value.(*BaseElem); ok && be.needsref { + return false + } + return true +} + +// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. +func (s *Ptr) ZeroExpr() string { return "nil" } + +// IfZeroExpr returns the expression to compare to zero/empty. +func (s *Ptr) IfZeroExpr() string { return s.Varname() + " == nil" } + +// Comparable returns whether this elem's type is comparable. +func (s *Ptr) Comparable() bool { + return false +} + +type Struct struct { + common + Fields []StructField // field list + AsTuple bool // write as an array instead of a map +} + +func (s *Struct) TypeName() string { + if s.common.alias != "" { + return s.common.alias + } + str := "struct{\n" + for i := range s.Fields { + str += s.Fields[i].FieldName + + " " + s.Fields[i].FieldElem.TypeName() + + " " + s.Fields[i].RawTag + ";\n" + } + str += "}" + s.common.Alias(str) + return s.common.alias +} + +func (s *Struct) SetVarname(a string) { + s.common.SetVarname(a) + writeStructFields(s.Fields, a) +} + +func (s *Struct) Copy() Elem { + g := *s + g.Fields = make([]StructField, len(s.Fields)) + copy(g.Fields, s.Fields) + for i := range s.Fields { + g.Fields[i].FieldElem = s.Fields[i].FieldElem.Copy() + } + return &g +} + +func (s *Struct) Complexity() int { + c := 1 + for i := range s.Fields { + c += s.Fields[i].FieldElem.Complexity() + } + return c +} + +// ZeroExpr returns the zero/empty expression or empty string if not supported. +func (s *Struct) ZeroExpr() string { + if s.alias == "" { + return "" // structs with no names not supported (for now) + } + return "(" + s.TypeName() + "{})" +} + +// IfZeroExpr returns the expression to compare to zero/empty. +func (s *Struct) IfZeroExpr() string { + if s.alias == "" { + return "" // structs with no names not supported (for now) + } + + var res string + for i := range s.Fields { + if !ast.IsExported(s.Fields[i].FieldName) { + continue + } + + fieldZero := s.Fields[i].FieldElem.IfZeroExpr() + if fieldZero != "" { + if res != "" { + res += " && " + } + res += "(" + fieldZero + ")" + } + } + return res +} + +// Comparable returns whether this elem's type is comparable. +func (s *Struct) Comparable() bool { + for _, sf := range s.Fields { + if !sf.FieldElem.Comparable() { + return false + } + } + return true +} + +// AnyHasTagPart returns true if HasTagPart(p) is true for any field. +func (s *Struct) AnyHasTagPart(pname string) bool { + for _, sf := range s.Fields { + if sf.HasTagPart(pname) { + return true + } + } + return false +} + +// UnderscoreStructHasTagPart returns true if HasTagPart(p) is true for the _struct field. +func (s *Struct) UnderscoreStructHasTagPart(pname string) bool { + for _, sf := range s.Fields { + if sf.FieldName == "_struct" && sf.HasTagPart(pname) { + return true + } + } + return false +} + +// HasAnyStructTag returns true if any of the fields in the struct have +// a codec: tag. This is used to determine which structs we can skip +// because they are not intended for encoding/decoding. +func (s *Struct) HasAnyStructTag() bool { + for _, sf := range s.Fields { + if sf.HasCodecTag { + return true + } + } + return false +} + +// HasUnderscoreStructTag returns true if there is a field named _struct +// with a codec: tag. This is used to ensure developers don't forget to +// annotate their structs with omitempty (unless explicitly opted out). +func (s *Struct) HasUnderscoreStructTag() bool { + for _, sf := range s.Fields { + if sf.FieldName == "_struct" && sf.HasCodecTag { + return true + } + } + return false +} + +type StructField struct { + FieldTag string // the string inside the `codec:""` tag up to the first comma + FieldTagParts []string // the string inside the `codec:""` tag split by commas + RawTag string // the full struct tag + HasCodecTag bool // has a `codec:` tag + FieldName string // the name of the struct field + FieldElem Elem // the field type + FieldPath []string // set of embedded struct names for accessing FieldName +} + +type byFieldTag []StructField + +func (a byFieldTag) Len() int { return len(a) } +func (a byFieldTag) Less(i, j int) bool { return a[i].FieldTag < a[j].FieldTag } +func (a byFieldTag) Swap(i, j int) { a[i], a[j] = a[j], a[i] } + +// HasTagPart returns true if the specified tag part (option) is present. +func (sf *StructField) HasTagPart(pname string) bool { + if len(sf.FieldTagParts) < 2 { + return false + } + for _, p := range sf.FieldTagParts[1:] { + if p == pname { + return true + } + } + return false +} + +type ShimMode int + +const ( + Cast ShimMode = iota + Convert +) + +// BaseElem is an element that +// can be represented by a primitive +// MessagePack type. +type BaseElem struct { + common + ShimMode ShimMode // Method used to shim + ShimToBase string // shim to base type, or empty + ShimFromBase string // shim from base type, or empty + Value Primitive // Type of element + IdentName string // name, for Value == IDENT + Convert bool // should we do an explicit conversion? + mustinline bool // must inline; not printable + needsref bool // needs reference for shim +} + +func (s *BaseElem) Dangling() bool { return s.mustinline } + +func (s *BaseElem) Alias(typ string) { + s.common.Alias(typ) + if s.Value != IDENT { + s.Convert = true + } + if strings.Contains(typ, ".") { + s.mustinline = true + } +} + +func (s *BaseElem) SetVarname(a string) { + // extensions whose parents + // are not pointers need to + // be explicitly referenced + if s.Value == Ext || s.needsref { + if strings.HasPrefix(a, "*") { + s.common.SetVarname(a[1:]) + return + } + s.common.SetVarname("&" + a) + return + } + + s.common.SetVarname(a) +} + +// TypeName returns the syntactically correct Go +// type name for the base element. +func (s *BaseElem) TypeName() string { + if s.common.alias != "" { + return s.common.alias + } + s.common.Alias(s.BaseType()) + return s.common.alias +} + +// ToBase, used if Convert==true, is used as tmp = {{ToBase}}({{Varname}}) +func (s *BaseElem) ToBase() string { + if s.ShimToBase != "" { + return s.ShimToBase + } + return s.BaseType() +} + +// FromBase, used if Convert==true, is used as {{Varname}} = {{FromBase}}(tmp) +func (s *BaseElem) FromBase() string { + if s.ShimFromBase != "" { + return s.ShimFromBase + } + return s.TypeName() +} + +// BaseName returns the string form of the +// base type (e.g. Float64, Ident, etc) +func (s *BaseElem) BaseName() string { + // time and duration are special cases; + // we strip the package prefix + if s.Value == Time { + return "Time" + } + if s.Value == Duration { + return "Duration" + } + return s.Value.String() +} + +func (s *BaseElem) BaseType() string { + switch s.Value { + case IDENT: + return s.TypeName() + + // exceptions to the naming/capitalization + // rule: + case Intf: + return "interface{}" + case Bytes: + return "[]byte" + case Time: + return "time.Time" + case Ext: + return "msgp.Extension" + + // everything else is base.String() with + // the first letter as lowercase + default: + return strings.ToLower(s.BaseName()) + } +} + +func (s *BaseElem) Needsref(b bool) { + s.needsref = b +} + +func (s *BaseElem) Copy() Elem { + g := *s + return &g +} + +func (s *BaseElem) Complexity() int { + if s.Convert && !s.mustinline { + return 2 + } + // we need to return 1 if !printable(), + // in order to make sure that stuff gets + // inlined appropriately + return 1 +} + +// Resolved returns whether or not +// the type of the element is +// a primitive or a builtin provided +// by the package. +func (s *BaseElem) Resolved() bool { + if s.Value == IDENT { + _, ok := builtins[s.TypeName()] + return ok + } + return true +} + +// ZeroExpr returns the zero/empty expression or empty string if not supported. +func (s *BaseElem) ZeroExpr() string { + + switch s.Value { + case Bytes: + return "nil" + case String: + return "\"\"" + case Complex64, Complex128: + return "complex(0,0)" + case Float32, + Float64, + Uint, + Uint8, + Uint16, + Uint32, + Uint64, + Byte, + Int, + Int8, + Int16, + Int32, + Int64, + Duration: + return "0" + case Bool: + return "false" + + case Time: + return "(time.Time{})" + } + + return "" +} + +// IfZeroExpr returns the expression to compare to zero/empty. +func (s *BaseElem) IfZeroExpr() string { + // Byte slices are special: we treat both nil and empty as + // zero for encoding purposes. + if s.Value == Bytes { + return "len(" + s.Varname() + ") == 0" + } + + z := s.ZeroExpr() + if z == "" { + // Assume this is an identifier from another package, + // and that it has generated code for MsgIsZero. + return s.Varname() + ".MsgIsZero()" + } + return s.Varname() + " == " + z +} + +// Comparable returns whether this elem's type is comparable. +func (s *BaseElem) Comparable() bool { + switch s.Value { + case String, Float32, Float64, Complex64, Complex128, + Uint, Uint8, Uint16, Uint32, Uint64, Byte, + Int, Int8, Int16, Int32, Int64, Bool, Time: + return true + default: + return false + } +} + +// SortInterface returns a sort.Interface for sorting a slice of this type. +func (s *BaseElem) SortInterface() string { + sortIntf, ok := sortInterface[s.TypeName()] + if ok { + return sortIntf + } + return "" +} + +func (k Primitive) String() string { + switch k { + case String: + return "String" + case Bytes: + return "Bytes" + case Float32: + return "Float32" + case Float64: + return "Float64" + case Complex64: + return "Complex64" + case Complex128: + return "Complex128" + case Uint: + return "Uint" + case Uint8: + return "Uint8" + case Uint16: + return "Uint16" + case Uint32: + return "Uint32" + case Uint64: + return "Uint64" + case Byte: + return "Byte" + case Int: + return "Int" + case Int8: + return "Int8" + case Int16: + return "Int16" + case Int32: + return "Int32" + case Int64: + return "Int64" + case Bool: + return "Bool" + case Intf: + return "Intf" + case Time: + return "time.Time" + case Duration: + return "time.Duration" + case Ext: + return "Extension" + case IDENT: + return "Ident" + default: + return "INVALID" + } +} + +// writeStructFields is a trampoline for writeBase for +// all of the fields in a struct +func writeStructFields(s []StructField, name string) { + for i := range s { + var path string + for _, pathelem := range s[i].FieldPath { + path += "." + pathelem + } + s[i].FieldElem.SetVarname(fmt.Sprintf("%s%s.%s", name, path, s[i].FieldName)) + } +} + +// SetSortInterface registers sort.Interface types from +// the msgp:sort directive. It would have been nice to +// register it inside the Elem, but unfortunately that +// only affects the type definition; call sites that +// refer to that type (e.g., map keys) have a different +// Elem that does not inherit (get copied) from the type +// definition in f.Identities. +var sortInterface map[string]string + +func SetSortInterface(sorttype string, sortintf string) { + if sortInterface == nil { + sortInterface = make(map[string]string) + } + + sortInterface[sorttype] = sortintf +} diff --git a/msgp/gen/iszero.go b/msgp/gen/iszero.go new file mode 100644 index 0000000000..2f7ed2c306 --- /dev/null +++ b/msgp/gen/iszero.go @@ -0,0 +1,68 @@ +package gen + +import ( + "io" +) + +func isZeros(w io.Writer, topics *Topics) *isZeroGen { + return &isZeroGen{ + p: printer{w: w}, + topics: topics, + } +} + +type isZeroGen struct { + passes + p printer + ctx *Context + topics *Topics +} + +func (s *isZeroGen) Method() Method { return IsZero } + +func (s *isZeroGen) Apply(dirs []string) error { + return nil +} + +func (s *isZeroGen) Execute(p Elem) ([]string, error) { + if !s.p.ok() { + return nil, s.p.err + } + p = s.applyall(p) + if p == nil { + return nil, nil + } + + // We might change p.Varname in methodReceiver(); make a copy + // to not affect other code that will use p. + p = p.Copy() + + s.ctx = &Context{} + s.ctx.PushString(p.TypeName()) + + s.p.comment("MsgIsZero returns whether this is a zero value") + + if IsDangling(p) { + baseType := p.(*BaseElem).IdentName + ptrName := p.Varname() + receiver := methodReceiver(p) + s.p.printf("\nfunc (%s %s) MsgIsZero() bool {", ptrName, receiver) + s.p.printf("\n return ((*(%s))(%s)).MsgIsZero()", baseType, ptrName) + s.p.printf("\n}") + s.topics.Add(receiver, "MsgIsZero") + return nil, s.p.err + } + + ptrName := p.Varname() + receiver := imutMethodReceiver(p) + s.p.printf("\nfunc (%s %s) MsgIsZero() bool {", ptrName, receiver) + ize := p.IfZeroExpr() + if ize == "" { + ize = "true" + } + s.p.printf("\nreturn %s", ize) + s.p.printf("\n}") + + s.topics.Add(receiver, "MsgIsZero") + return nil, s.p.err +} diff --git a/msgp/gen/marshal.go b/msgp/gen/marshal.go new file mode 100644 index 0000000000..56340d66fa --- /dev/null +++ b/msgp/gen/marshal.go @@ -0,0 +1,393 @@ +package gen + +import ( + "fmt" + "go/ast" + "io" + "sort" + "strings" + + "github.com/algorand/msgp/msgp" +) + +func marshal(w io.Writer, topics *Topics) *marshalGen { + return &marshalGen{ + p: printer{w: w}, + topics: topics, + } +} + +type marshalGen struct { + passes + p printer + fuse []byte + ctx *Context + msgs []string + topics *Topics +} + +func (m *marshalGen) Method() Method { return Marshal } + +func (m *marshalGen) Apply(dirs []string) error { + return nil +} + +func (m *marshalGen) Execute(p Elem) ([]string, error) { + m.msgs = nil + if !m.p.ok() { + return m.msgs, m.p.err + } + p = m.applyall(p) + if p == nil { + return m.msgs, nil + } + + // We might change p.Varname in methodReceiver(); make a copy + // to not affect other code that will use p. + p = p.Copy() + + m.ctx = &Context{} + + m.p.comment("MarshalMsg implements msgp.Marshaler") + + if IsDangling(p) { + baseType := p.(*BaseElem).IdentName + c := p.Varname() + methodRecv := methodReceiver(p) + m.p.printf("\nfunc (%s %s) MarshalMsg(b []byte) []byte {", c, methodRecv) + m.p.printf("\n return ((*(%s))(%s)).MarshalMsg(b)", baseType, c) + m.p.printf("\n}") + + m.p.printf("\nfunc (_ %[2]s) CanMarshalMsg(%[1]s interface{}) bool {", c, methodRecv) + m.p.printf("\n _, ok := (%s).(%s)", c, methodRecv) + m.p.printf("\n return ok") + m.p.printf("\n}") + + m.topics.Add(methodRecv, "MarshalMsg") + m.topics.Add(methodRecv, "CanMarshalMsg") + + return m.msgs, m.p.err + } + + // save the vname before + // calling methodReceiver so + // that z.Msgsize() is printed correctly + c := p.Varname() + methodRecv := imutMethodReceiver(p) + + m.p.printf("\nfunc (%s %s) MarshalMsg(b []byte) (o []byte) {", c, methodRecv) + m.p.printf("\no = msgp.Require(b, %s.Msgsize())", c) + next(m, p) + m.p.nakedReturn() + + m.p.printf("\nfunc (_ %[2]s) CanMarshalMsg(%[1]s interface{}) bool {", c, methodRecv) + m.p.printf("\n _, ok := (%s).(%s)", c, methodRecv) + + // If this is a value receiver, check for a pointer type too + if methodRecv == p.TypeName() { + m.p.printf("\n if !ok {") + m.p.printf("\n _, ok = (%s).(*%s)", c, methodRecv) + m.p.printf("\n }") + } + + m.p.printf("\n return ok") + m.p.printf("\n}") + + m.topics.Add(methodRecv, "MarshalMsg") + m.topics.Add(methodRecv, "CanMarshalMsg") + + return m.msgs, m.p.err +} + +func (m *marshalGen) rawAppend(typ string, argfmt string, arg interface{}) { + m.p.printf("\no = msgp.Append%s(o, %s)", typ, fmt.Sprintf(argfmt, arg)) +} + +func (m *marshalGen) fuseHook() { + if len(m.fuse) > 0 { + m.rawbytes(m.fuse) + m.fuse = m.fuse[:0] + } +} + +func (m *marshalGen) Fuse(b []byte) { + if len(m.fuse) == 0 { + m.fuse = b + } else { + m.fuse = append(m.fuse, b...) + } +} + +func (m *marshalGen) gStruct(s *Struct) { + if !m.p.ok() { + return + } + + if s.AsTuple { + m.tuple(s) + } else { + m.mapstruct(s) + } + return +} + +func (m *marshalGen) tuple(s *Struct) { + data := make([]byte, 0, 5) + data = msgp.AppendArrayHeader(data, uint32(len(s.Fields))) + m.p.printf("\n// array header, size %d", len(s.Fields)) + m.Fuse(data) + if len(s.Fields) == 0 { + m.fuseHook() + } + for i := range s.Fields { + if !m.p.ok() { + return + } + m.ctx.PushString(s.Fields[i].FieldName) + next(m, s.Fields[i].FieldElem) + m.ctx.Pop() + } +} + +func isFieldOmitEmpty(sf StructField, s *Struct) bool { + tagName := "omitempty" + + // go-codec distinguished between omitempty and omitemptyarray + e := sf.FieldElem + _, isArray := e.(*Array) + if isArray { + tagName = "omitemptyarray" + } + + return sf.HasTagPart(tagName) || s.UnderscoreStructHasTagPart(tagName) +} + +func (m *marshalGen) mapstruct(s *Struct) { + + // Every struct must have a _struct annotation with a codec: tag. + // In the common case, the tag would contain omitempty, but it could + // also be blank, if for some reason omitempty is not desired. This + // check guards against developers forgetting to specify omitempty. + if !s.HasUnderscoreStructTag() { + m.msgs = append(m.msgs, fmt.Sprintf("Missing _struct annotation on struct %v", s)) + return + } + + sortedFields := append([]StructField(nil), s.Fields...) + sort.Sort(byFieldTag(sortedFields)) + + oeIdentPrefix := randIdent() + + var data []byte + nfields := len(sortedFields) + bm := bmask{ + bitlen: nfields, + varname: oeIdentPrefix + "Mask", + } + + exportedFields := 0 + for _, sf := range sortedFields { + if !ast.IsExported(sf.FieldName) { + continue + } + exportedFields++ + } + + omitempty := s.AnyHasTagPart("omitempty") + var fieldNVar string + needCloseBrace := false + needBmDecl := true + if omitempty { + + fieldNVar = oeIdentPrefix + "Len" + + m.p.printf("\n// omitempty: check for empty values") + m.p.printf("\n%s := uint32(%d)", fieldNVar, exportedFields) + for i, sf := range sortedFields { + if !m.p.ok() { + return + } + + if !ast.IsExported(sf.FieldName) { + continue + } + + fieldOmitEmpty := isFieldOmitEmpty(sf, s) + if ize := sf.FieldElem.IfZeroExpr(); ize != "" && fieldOmitEmpty { + if needBmDecl { + m.p.printf("\n%s", bm.typeDecl()) + needBmDecl = false + } + + m.p.printf("\nif %s {", ize) + m.p.printf("\n%s--", fieldNVar) + m.p.printf("\n%s", bm.setStmt(i)) + m.p.printf("\n}") + } + } + + m.p.printf("\n// variable map header, size %s", fieldNVar) + m.p.varAppendMapHeader("o", fieldNVar, exportedFields) + if !m.p.ok() { + return + } + + // quick check for the case where the entire thing is empty, but only at the top level + if !strings.Contains(s.Varname(), ".") { + m.p.printf("\nif %s != 0 {", fieldNVar) + needCloseBrace = true + } + + } else { + + // non-omitempty version + data = make([]byte, 0, 64) + data = msgp.AppendMapHeader(data, uint32(exportedFields)) + m.p.printf("\n// map header, size %d", exportedFields) + m.Fuse(data) + if exportedFields == 0 { + m.fuseHook() + } + + } + + for i, sf := range sortedFields { + if !ast.IsExported(sf.FieldName) { + continue + } + + if !m.p.ok() { + return + } + + fieldOmitEmpty := isFieldOmitEmpty(sf, s) + + // if field is omitempty, wrap with if statement based on the emptymask + oeField := fieldOmitEmpty && sf.FieldElem.IfZeroExpr() != "" + if oeField { + m.p.printf("\nif %s == 0 { // if not empty", bm.readExpr(i)) + } + + data = msgp.AppendString(nil, sf.FieldTag) + + m.p.printf("\n// string %q", sf.FieldTag) + m.Fuse(data) + m.fuseHook() + + m.ctx.PushString(sf.FieldName) + next(m, sf.FieldElem) + m.ctx.Pop() + + if oeField { + m.p.printf("\n}") // close if statement + } + + } + + if needCloseBrace { + m.p.printf("\n}") + } +} + +// append raw data +func (m *marshalGen) rawbytes(bts []byte) { + m.p.print("\no = append(o, ") + for _, b := range bts { + m.p.printf("0x%x,", b) + } + m.p.print(")") +} + +func (m *marshalGen) gMap(s *Map) { + if !m.p.ok() { + return + } + m.fuseHook() + vname := s.Varname() + m.p.printf("\nif %s == nil {", vname) + m.p.printf("\n o = msgp.AppendNil(o)") + m.p.printf("\n} else {") + m.rawAppend(mapHeader, lenAsUint32, vname) + m.p.printf("\n}") + + m.p.printf("\n%s_keys := make([]%s, 0, len(%s))", s.Keyidx, s.Key.TypeName(), vname) + m.p.printf("\nfor %s := range %s {", s.Keyidx, vname) + m.p.printf("\n%s_keys = append(%s_keys, %s)", s.Keyidx, s.Keyidx, s.Keyidx) + m.p.closeblock() + + m.p.printf("\nsort.Sort(%s(%s_keys))", s.Key.SortInterface(), s.Keyidx) + + m.p.printf("\nfor _, %s := range %s_keys {", s.Keyidx, s.Keyidx) + m.p.printf("\n%s := %s[%s]", s.Validx, vname, s.Keyidx) + m.p.printf("\n_ = %s", s.Validx) // we may not use the value, if it's a struct{} + m.ctx.PushVar(s.Keyidx) + next(m, s.Key) + next(m, s.Value) + m.ctx.Pop() + m.p.closeblock() +} + +func (m *marshalGen) gSlice(s *Slice) { + if !m.p.ok() { + return + } + m.fuseHook() + vname := s.Varname() + m.p.printf("\nif %s == nil {", vname) + m.p.printf("\n o = msgp.AppendNil(o)") + m.p.printf("\n} else {") + m.rawAppend(arrayHeader, lenAsUint32, vname) + m.p.printf("\n}") + m.p.rangeBlock(m.ctx, s.Index, vname, m, s.Els) +} + +func (m *marshalGen) gArray(a *Array) { + if !m.p.ok() { + return + } + m.fuseHook() + if be, ok := a.Els.(*BaseElem); ok && be.Value == Byte { + m.rawAppend("Bytes", "(%s)[:]", a.Varname()) + return + } + + m.rawAppend(arrayHeader, literalFmt, a.Size) + m.p.rangeBlock(m.ctx, a.Index, a.Varname(), m, a.Els) +} + +func (m *marshalGen) gPtr(p *Ptr) { + if !m.p.ok() { + return + } + m.fuseHook() + m.p.printf("\nif %s == nil {\no = msgp.AppendNil(o)\n} else {", p.Varname()) + next(m, p.Value) + m.p.closeblock() +} + +func (m *marshalGen) gBase(b *BaseElem) { + if !m.p.ok() { + return + } + m.fuseHook() + vname := b.Varname() + + if b.Convert { + if b.ShimMode == Cast { + vname = tobaseConvert(b) + } else { + vname = randIdent() + m.p.printf("\nvar %s %s", vname, b.BaseType()) + m.p.printf("\n%s = %s", vname, tobaseConvert(b)) + } + } + + switch b.Value { + case IDENT: + m.p.printf("\no = %s.MarshalMsg(o)", vname) + case Intf, Ext: + m.p.printf("\no = msgp.Append%s(o, %s)", b.BaseName(), vname) + default: + m.rawAppend(b.BaseName(), literalFmt, vname) + } +} diff --git a/msgp/gen/maxsize.go b/msgp/gen/maxsize.go new file mode 100644 index 0000000000..50522492cc --- /dev/null +++ b/msgp/gen/maxsize.go @@ -0,0 +1,379 @@ +package gen + +import ( + "bytes" + "fmt" + "go/ast" + "io" + "reflect" + "strconv" + "strings" + + "github.com/algorand/msgp/msgp" +) + +type maxSizeState uint8 + +const ( + // need to write "s = ..." + assignM maxSizeState = iota + + // need to write "s += ..." + addM + + // can just append "+ ..." + exprM + + multM + // the result is multiplied by whatever is preceeding it +) + +func maxSizes(w io.Writer, topics *Topics) *maxSizeGen { + return &maxSizeGen{ + p: printer{w: w}, + state: assignM, + topics: topics, + } +} + +type maxSizeGen struct { + passes + p printer + state maxSizeState + ctx *Context + topics *Topics +} + +func (s *maxSizeGen) Method() Method { return MaxSize } + +func (s *maxSizeGen) Apply(dirs []string) error { + return nil +} + +// this lets us chain together addition +// operations where possible +func (s *maxSizeGen) addConstant(sz string) { + if !s.p.ok() { + return + } + + switch s.state { + case assignM: + s.p.print("\ns = " + sz) + s.state = exprM + return + case addM: + s.p.print("\ns += " + sz) + s.state = exprM + return + case exprM: + s.p.print(" + " + sz) + return + case multM: + s.p.print(" * ( " + sz + ")") + s.state = addM + return + } + + panic("unknown size state") +} + +func (s *maxSizeGen) Execute(p Elem) ([]string, error) { + if !s.p.ok() { + return nil, s.p.err + } + p = s.applyall(p) + if p == nil { + return nil, nil + } + + // We might change p.Varname in methodReceiver(); make a copy + // to not affect other code that will use p. + p = p.Copy() + + s.p.comment("MaxSize returns a maximum valid message size for this message type") + + if IsDangling(p) { + baseType := p.(*BaseElem).IdentName + s.p.printf("\nfunc %s int{", getMaxSizeMethod(p.TypeName())) + s.p.printf("\n return %s", getMaxSizeMethod(baseType)) + s.p.printf("\n}") + s.topics.Add(baseType, getMaxSizeMethod(baseType)) + return nil, s.p.err + } + + s.ctx = &Context{} + s.ctx.PushString(p.TypeName()) + + // receiver := imutMethodReceiver(p) + s.p.printf("\nfunc %s (s int) {", getMaxSizeMethod(p.TypeName())) + s.state = assignM + next(s, p) + s.p.nakedReturn() + s.topics.Add(p.TypeName(), getMaxSizeMethod(p.TypeName())) + return nil, s.p.err +} + +func (s *maxSizeGen) gStruct(st *Struct) { + if !s.p.ok() { + return + } + + nfields := uint32(0) + for i := range st.Fields { + if ast.IsExported(st.Fields[i].FieldName) { + nfields += 1 + } + } + + if st.AsTuple { + data := msgp.AppendArrayHeader(nil, nfields) + s.addConstant(strconv.Itoa(len(data))) + for i := range st.Fields { + if !ast.IsExported(st.Fields[i].FieldName) { + continue + } + + if !s.p.ok() { + return + } + next(s, st.Fields[i].FieldElem) + } + } else { + data := msgp.AppendMapHeader(nil, nfields) + s.addConstant(strconv.Itoa(len(data))) + for i := range st.Fields { + if !ast.IsExported(st.Fields[i].FieldName) { + continue + } + + data = data[:0] + data = msgp.AppendString(data, st.Fields[i].FieldTag) + s.addConstant(strconv.Itoa(len(data))) + next(s, st.Fields[i].FieldElem) + } + } +} + +func (s *maxSizeGen) gPtr(p *Ptr) { + s.state = addM // inner must use add + next(s, p.Value) + s.state = addM // closing block; reset to add +} + +func (s *maxSizeGen) gSlice(sl *Slice) { + if !s.p.ok() { + return + } + s.state = addM + s.p.comment("Calculating size of slice: " + sl.Varname()) + if (sl.AllocBound() == "" || sl.AllocBound() == "-") && (sl.MaxTotalBytes() == "" || sl.MaxTotalBytes() == "-") { + s.p.printf("\npanic(\"Slice %s is unbounded\")", sl.Varname()) + s.state = addM // reset the add to prevent further + expressions from being added to the end the panic statement + return + } + + s.addConstant(builtinSize(arrayHeader)) + + // use maxtotalbytes if it's available + if sl.common.MaxTotalBytes() != "" && sl.common.MaxTotalBytes() != "-" { + s.addConstant(sl.common.MaxTotalBytes()) + return + } + + topLevelAllocBound := sl.AllocBound() + childElement := sl.Els + if sl.Els.AllocBound() == "" && len(strings.Split(sl.AllocBound(), ",")) > 1 { + splitIndex := strings.Index(sl.AllocBound(), ",") + childElement = sl.Els.Copy() + childElement.SetAllocBound(sl.AllocBound()[splitIndex+1:]) + topLevelAllocBound = sl.AllocBound()[:splitIndex] + } + + if str, err := maxSizeExpr(childElement); err == nil { + s.addConstant(fmt.Sprintf("((%s) * (%s))", topLevelAllocBound, str)) + } else { + s.p.printf("\npanic(\"Unable to determine max size: %s\")", err) + } + s.state = addM + return +} + +func (s *maxSizeGen) gArray(a *Array) { + if !s.p.ok() { + return + } + // If this is not the first line where we define s = ... then we need to reset the state + // to addM so that the comment is printed correctly on a newline + if s.state != assignM { + s.state = addM + } + s.p.comment("Calculating size of array: " + a.Varname()) + + s.addConstant(builtinSize(arrayHeader)) + + if str, err := maxSizeExpr(a.Els); err == nil { + s.addConstant(fmt.Sprintf("((%s) * (%s))", a.Size, str)) + } else { + s.p.printf("\npanic(\"Unable to determine max size: %s\")", err) + + } + s.state = addM + return +} + +func (s *maxSizeGen) gMap(m *Map) { + vn := m.Varname() + s.state = addM + s.addConstant(builtinSize(mapHeader)) + topLevelAllocBound := m.AllocBound() + if topLevelAllocBound != "" && topLevelAllocBound == "-" { + s.p.printf("\npanic(\"Map %s is unbounded\")", m.Varname()) + s.state = addM // reset the add to prevent further + expressions from being added to the end the panic statement + return + } + splitBounds := strings.Split(m.AllocBound(), ",") + if len(splitBounds) > 1 { + topLevelAllocBound = splitBounds[0] + m.Key.SetAllocBound(splitBounds[1]) + if len(splitBounds) > 2 { + m.Value.SetAllocBound(splitBounds[2]) + } + } + + s.p.comment("Adding size of map keys for " + vn) + s.p.printf("\ns += %s", topLevelAllocBound) + s.state = multM + next(s, m.Key) + + s.p.comment("Adding size of map values for " + vn) + s.p.printf("\ns += %s", topLevelAllocBound) + s.state = multM + next(s, m.Value) + + s.state = addM +} + +func (s *maxSizeGen) gBase(b *BaseElem) { + if !s.p.ok() { + return + } + if b.MaxTotalBytes() != "" { + s.p.comment("Using maxtotalbytes for: " + b.Varname()) + s.state = addM + s.addConstant(b.MaxTotalBytes()) + s.state = addM + return + } + if b.Convert && b.ShimMode == Convert { + s.state = addM + vname := randIdent() + s.p.printf("\nvar %s %s", vname, b.BaseType()) + + // ensure we don't get "unused variable" warnings from outer slice iterations + s.p.printf("\n_ = %s", b.Varname()) + + value, err := baseMaxSizeExpr(b.Value, vname, b.BaseName(), b.TypeName(), b.common.AllocBound()) + if err != nil { + s.p.printf("\npanic(\"Unable to determine max size: %s\")", err) + s.state = addM // reset the add to prevent further + expressions from being added to the end the panic statement + return + } + s.p.printf("\ns += %s", value) + s.state = exprM + + } else { + vname := b.Varname() + if b.Convert { + vname = tobaseConvert(b) + } + value, err := baseMaxSizeExpr(b.Value, vname, b.BaseName(), b.TypeName(), b.common.AllocBound()) + if err != nil { + s.p.printf("\npanic(\"Unable to determine max size: %s\")", err) + s.state = addM // reset the add to prevent further + expressions from being added to the end the panic statement + return + } + s.addConstant(value) + } +} + +func baseMaxSizeExpr(value Primitive, vname, basename, typename string, allocbound string) (string, error) { + if typename == "msgp.Raw" { + return "", fmt.Errorf("MaxSize() not implemented for Raw type") + } + switch value { + case Ext: + return "", fmt.Errorf("MaxSize() not implemented for Ext type") + case Intf: + return "", fmt.Errorf("MaxSize() not implemented for Interfaces") + case IDENT: + return getMaxSizeMethod(typename), nil + case Bytes: + if allocbound == "" || allocbound == "-" { + return "", fmt.Errorf("Byteslice type %s is unbounded", vname) + } + return "msgp.BytesPrefixSize + " + allocbound, nil + case String: + if allocbound == "" || allocbound == "-" { + return "", fmt.Errorf("String type %s is unbounded", vname) + } + return "msgp.StringPrefixSize + " + allocbound, nil + default: + return builtinSize(basename), nil + } +} + +// return a fixed-size expression, if possible. +// only possible for *BaseElem, *Array and Struct. +// returns (expr, err) +func maxSizeExpr(e Elem) (string, error) { + switch e := e.(type) { + case *Array: + if str, err := maxSizeExpr(e.Els); err == nil { + return fmt.Sprintf("(%s * (%s))", e.Size, str), nil + } else { + return "", err + } + case *BaseElem: + if fixedSize(e.Value) { + return builtinSize(e.BaseName()), nil + } else if (e.TypeName()) == "msgp.Raw" { + return "", fmt.Errorf("Raw type is unbounded") + } else if (e.Value) == String { + if e.AllocBound() == "" || e.AllocBound() == "-" { + return "", fmt.Errorf("String type is unbounded for %s", e.Varname()) + } + return fmt.Sprintf("(msgp.StringPrefixSize + %s)", e.AllocBound()), nil + } else if (e.Value) == IDENT { + return fmt.Sprintf("(%s)", getMaxSizeMethod(e.TypeName())), nil + } else if (e.Value) == Bytes { + if e.AllocBound() == "" || e.AllocBound() == "-" { + return "", fmt.Errorf("Inner byteslice type is unbounded") + } + return fmt.Sprintf("(msgp.BytesPrefixSize + %s)", e.AllocBound()), nil + } + case *Struct: + return fmt.Sprintf("(%s)", getMaxSizeMethod(e.TypeName())), nil + case *Slice: + if e.AllocBound() == "" || e.AllocBound() == "-" { + return "", fmt.Errorf("Slice %s is unbounded", e.Varname()) + } + if str, err := maxSizeExpr(e.Els); err == nil { + return fmt.Sprintf("(%s * (%s))", e.AllocBound(), str), nil + } else { + return "", err + } + } + return fmt.Sprintf("%s, %s", e.TypeName(), reflect.TypeOf(e)), nil +} + +func getMaxSizeMethod(typeName string) (s string) { + var pos int + dotIndex := strings.Index(typeName, ".") + if dotIndex != -1 { + pos = dotIndex + 1 + } + b := []byte(typeName) + b[pos] = bytes.ToUpper(b)[pos] + return string(b) + "MaxSize()" +} diff --git a/msgp/gen/size.go b/msgp/gen/size.go new file mode 100644 index 0000000000..d3cbb3d63d --- /dev/null +++ b/msgp/gen/size.go @@ -0,0 +1,325 @@ +package gen + +import ( + "fmt" + "go/ast" + "io" + "strconv" + + "github.com/algorand/msgp/msgp" +) + +type sizeState uint8 + +const ( + // need to write "s = ..." + assign sizeState = iota + + // need to write "s += ..." + add + + // can just append "+ ..." + expr +) + +func sizes(w io.Writer, topics *Topics) *sizeGen { + return &sizeGen{ + p: printer{w: w}, + state: assign, + topics: topics, + } +} + +type sizeGen struct { + passes + p printer + state sizeState + ctx *Context + topics *Topics +} + +func (s *sizeGen) Method() Method { return Size } + +func (s *sizeGen) Apply(dirs []string) error { + return nil +} + +func builtinSize(typ string) string { + return "msgp." + typ + "Size" +} + +// this lets us chain together addition +// operations where possible +func (s *sizeGen) addConstant(sz string) { + if !s.p.ok() { + return + } + + switch s.state { + case assign: + s.p.print("\ns = " + sz) + s.state = expr + return + case add: + s.p.print("\ns += " + sz) + s.state = expr + return + case expr: + s.p.print(" + " + sz) + return + } + + panic("unknown size state") +} + +func (s *sizeGen) Execute(p Elem) ([]string, error) { + if !s.p.ok() { + return nil, s.p.err + } + p = s.applyall(p) + if p == nil { + return nil, nil + } + + // We might change p.Varname in methodReceiver(); make a copy + // to not affect other code that will use p. + p = p.Copy() + + s.p.comment("Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message") + + if IsDangling(p) { + baseType := p.(*BaseElem).IdentName + ptrName := p.Varname() + receiver := methodReceiver(p) + s.p.printf("\nfunc (%s %s) Msgsize() int {", ptrName, receiver) + s.p.printf("\n return ((*(%s))(%s)).Msgsize()", baseType, ptrName) + s.p.printf("\n}") + s.topics.Add(receiver, "Msgsize") + return nil, s.p.err + } + + s.ctx = &Context{} + s.ctx.PushString(p.TypeName()) + + ptrName := p.Varname() + receiver := imutMethodReceiver(p) + s.p.printf("\nfunc (%s %s) Msgsize() (s int) {", ptrName, receiver) + s.state = assign + next(s, p) + s.p.nakedReturn() + s.topics.Add(receiver, "Msgsize") + return nil, s.p.err +} + +func (s *sizeGen) gStruct(st *Struct) { + if !s.p.ok() { + return + } + + nfields := uint32(0) + for i := range st.Fields { + if ast.IsExported(st.Fields[i].FieldName) { + nfields += 1 + } + } + + if st.AsTuple { + data := msgp.AppendArrayHeader(nil, nfields) + s.addConstant(strconv.Itoa(len(data))) + for i := range st.Fields { + if !ast.IsExported(st.Fields[i].FieldName) { + continue + } + + if !s.p.ok() { + return + } + next(s, st.Fields[i].FieldElem) + } + } else { + data := msgp.AppendMapHeader(nil, nfields) + s.addConstant(strconv.Itoa(len(data))) + for i := range st.Fields { + if !ast.IsExported(st.Fields[i].FieldName) { + continue + } + + data = data[:0] + data = msgp.AppendString(data, st.Fields[i].FieldTag) + s.addConstant(strconv.Itoa(len(data))) + next(s, st.Fields[i].FieldElem) + } + } +} + +func (s *sizeGen) gPtr(p *Ptr) { + s.state = add // inner must use add + s.p.printf("\nif %s == nil {\ns += msgp.NilSize\n} else {", p.Varname()) + next(s, p.Value) + s.state = add // closing block; reset to add + s.p.closeblock() +} + +func (s *sizeGen) gSlice(sl *Slice) { + if !s.p.ok() { + return + } + + s.addConstant(builtinSize(arrayHeader)) + + // if the slice's element is a fixed size + // (e.g. float64, [32]int, etc.), then + // print the length times the element size directly + if str, ok := fixedsizeExpr(sl.Els); ok { + s.addConstant(fmt.Sprintf("(%s * (%s))", lenExpr(sl), str)) + return + } + + // add inside the range block, and immediately after + s.state = add + s.p.rangeBlock(s.ctx, sl.Index, sl.Varname(), s, sl.Els) + s.state = add +} + +func (s *sizeGen) gArray(a *Array) { + if !s.p.ok() { + return + } + + s.addConstant(builtinSize(arrayHeader)) + + // if the array's children are a fixed + // size, we can compile an expression + // that always represents the array's wire size + if str, ok := fixedsizeExpr(a); ok { + s.addConstant(str) + return + } + + s.state = add + s.p.rangeBlock(s.ctx, a.Index, a.Varname(), s, a.Els) + s.state = add +} + +func (s *sizeGen) gMap(m *Map) { + s.addConstant(builtinSize(mapHeader)) + vn := m.Varname() + s.p.printf("\nif %s != nil {", vn) + s.p.printf("\nfor %s, %s := range %s {", m.Keyidx, m.Validx, vn) + s.p.printf("\n_ = %s", m.Keyidx) // we may not use the key + s.p.printf("\n_ = %s", m.Validx) // we may not use the value + s.p.printf("\ns += 0") + s.state = expr + s.ctx.PushVar(m.Keyidx) + next(s, m.Key) + next(s, m.Value) + s.ctx.Pop() + s.p.closeblock() + s.p.closeblock() + s.state = add +} + +func (s *sizeGen) gBase(b *BaseElem) { + if !s.p.ok() { + return + } + if b.Convert && b.ShimMode == Convert { + s.state = add + vname := randIdent() + s.p.printf("\nvar %s %s", vname, b.BaseType()) + + // ensure we don't get "unused variable" warnings from outer slice iterations + s.p.printf("\n_ = %s", b.Varname()) + + s.p.printf("\ns += %s", basesizeExpr(b.Value, vname, b.BaseName())) + s.state = expr + + } else { + vname := b.Varname() + if b.Convert { + vname = tobaseConvert(b) + } + s.addConstant(basesizeExpr(b.Value, vname, b.BaseName())) + } +} + +// returns "len(slice)" +func lenExpr(sl *Slice) string { + return "len(" + sl.Varname() + ")" +} + +// is a given primitive always the same (max) +// size on the wire? +func fixedSize(p Primitive) bool { + switch p { + case Intf, Ext, IDENT, Bytes, String: + return false + default: + return true + } +} + +// strip reference from string +func stripRef(s string) string { + if s[0] == '&' { + return s[1:] + } + return s +} + +// return a fixed-size expression, if possible. +// only possible for *BaseElem and *Array. +// returns (expr, ok) +func fixedsizeExpr(e Elem) (string, bool) { + switch e := e.(type) { + case *Array: + if str, ok := fixedsizeExpr(e.Els); ok { + return fmt.Sprintf("(%s * (%s))", e.Size, str), true + } + case *BaseElem: + if fixedSize(e.Value) { + return builtinSize(e.BaseName()), true + } + case *Struct: + var str string + for _, f := range e.Fields { + if fs, ok := fixedsizeExpr(f.FieldElem); ok { + if str == "" { + str = fs + } else { + str += "+" + fs + } + } else { + return "", false + } + } + var hdrlen int + mhdr := msgp.AppendMapHeader(nil, uint32(len(e.Fields))) + hdrlen += len(mhdr) + var strbody []byte + for _, f := range e.Fields { + strbody = msgp.AppendString(strbody[:0], f.FieldTag) + hdrlen += len(strbody) + } + return fmt.Sprintf("%d + %s", hdrlen, str), true + } + return "", false +} + +// print size expression of a variable name +func basesizeExpr(value Primitive, vname, basename string) string { + switch value { + case Ext: + return "msgp.ExtensionPrefixSize + " + stripRef(vname) + ".Len()" + case Intf: + return "msgp.GuessSize(" + vname + ")" + case IDENT: + return vname + ".Msgsize()" + case Bytes: + return "msgp.BytesPrefixSize + len(" + vname + ")" + case String: + return "msgp.StringPrefixSize + len(" + vname + ")" + default: + return builtinSize(basename) + } +} diff --git a/msgp/gen/spec.go b/msgp/gen/spec.go new file mode 100644 index 0000000000..5567b72c5c --- /dev/null +++ b/msgp/gen/spec.go @@ -0,0 +1,554 @@ +package gen + +import ( + "bytes" + "fmt" + "io" + "strings" +) + +const ( + lenAsUint32 = "uint32(len(%s))" + literalFmt = "%s" + intFmt = "%d" + quotedFmt = `"%s"` + mapHeader = "MapHeader" + arrayHeader = "ArrayHeader" + mapKey = "MapKeyPtr" + stringTyp = "String" + u32 = "uint32" +) + +// Method is a bitfield representing something that the +// generator knows how to print. +type Method uint8 + +// are the bits in 'f' set in 'm'? +func (m Method) isset(f Method) bool { return (m&f == f) } + +// String implements fmt.Stringer +func (m Method) String() string { + switch m { + case 0, invalidmeth: + return "" + case Marshal: + return "marshal" + case Unmarshal: + return "unmarshal" + case Size: + return "size" + case IsZero: + return "iszero" + case MaxSize: + return "maxsize" + case Test: + return "test" + default: + // return e.g. "marshal+unmarshal+test" + modes := [...]Method{Marshal, Unmarshal, Size, IsZero, MaxSize, Test} + any := false + nm := "" + for _, mm := range modes { + if m.isset(mm) { + if any { + nm += "+" + mm.String() + } else { + nm += mm.String() + any = true + } + } + } + return nm + + } +} + +func strtoMeth(s string) Method { + switch s { + case "marshal": + return Marshal + case "unmarshal": + return Unmarshal + case "size": + return Size + case "iszero": + return IsZero + case "maxsize": + return MaxSize + case "test": + return Test + default: + return 0 + } +} + +const ( + Marshal Method = 1 << iota // msgp.Marshaler + Unmarshal // msgp.Unmarshaler + Size // msgp.Sizer + IsZero // implement MsgIsZero() + Test // generate tests + MaxSize // msgp.MaxSize + invalidmeth // this isn't a method + marshaltest = Marshal | Unmarshal | Test // tests for Marshaler and Unmarshaler +) + +type Printer struct { + gens []generator +} + +func NewPrinter(m Method, topics *Topics, out io.Writer, tests io.Writer) *Printer { + if m.isset(Test) && tests == nil { + panic("cannot print tests with 'nil' tests argument!") + } + gens := make([]generator, 0, 7) + if m.isset(Marshal) { + gens = append(gens, marshal(out, topics)) + } + if m.isset(Unmarshal) { + gens = append(gens, unmarshal(out, topics)) + } + if m.isset(Size) { + gens = append(gens, sizes(out, topics)) + } + if m.isset(IsZero) { + gens = append(gens, isZeros(out, topics)) + } + if m.isset(MaxSize) { + gens = append(gens, maxSizes(out, topics)) + } + if m.isset(marshaltest) { + gens = append(gens, mtest(tests)) + } + if len(gens) == 0 { + panic("NewPrinter called with invalid method flags") + } + return &Printer{gens: gens} +} + +// TransformPass is a pass that transforms individual +// elements. (Note that if the returned is different from +// the argument, it should not point to the same objects.) +type TransformPass func(Elem) Elem + +// IgnoreTypename is a pass that just ignores +// types of a given name. +func IgnoreTypename(name string) TransformPass { + return func(e Elem) Elem { + if e.TypeName() == name { + return nil + } + return e + } +} + +// ApplyDirective applies a directive to a named pass +// and all of its dependents. +func (p *Printer) ApplyDirective(pass Method, t TransformPass) { + for _, g := range p.gens { + if g.Method().isset(pass) { + g.Add(t) + } + } +} + +// Print prints an Elem. +func (p *Printer) Print(e Elem) ([]string, error) { + // If the elem is a struct and has no _struct annotations, skip it. + es, ok := e.(*Struct) + if ok && !es.HasAnyStructTag() { + return nil, nil + } + + var msgs []string + + for _, g := range p.gens { + // Elem.SetVarname() is called before the Print() step in parse.FileSet.PrintTo(). + // Elem.SetVarname() generates identifiers as it walks the Elem. This can cause + // collisions between idents created during SetVarname and idents created during Print, + // hence the separate prefixes. + resetIdent("zb") + m, err := g.Execute(e) + resetIdent("za") + + if err != nil { + return nil, err + } + + msgs = append(msgs, m...) + } + return msgs, nil +} + +type contextItem interface { + Arg() string +} + +type contextString string + +func (c contextString) Arg() string { + return fmt.Sprintf("%q", c) +} + +type contextVar string + +func (c contextVar) Arg() string { + return string(c) +} + +type Context struct { + path []contextItem +} + +func (c *Context) PushString(s string) { + c.path = append(c.path, contextString(s)) +} + +func (c *Context) PushVar(s string) { + c.path = append(c.path, contextVar(s)) +} + +func (c *Context) Pop() { + c.path = c.path[:len(c.path)-1] +} + +func (c *Context) ArgsStr() string { + var out string + for idx, p := range c.path { + if idx > 0 { + out += ", " + } + out += p.Arg() + } + return out +} + +// generator is the interface through +// which code is generated. +type generator interface { + Method() Method + Add(p TransformPass) + Execute(Elem) ([]string, error) // execute writes the method for the provided object. +} + +type passes []TransformPass + +func (p *passes) Add(t TransformPass) { + *p = append(*p, t) +} + +func (p *passes) applyall(e Elem) Elem { + for _, t := range *p { + e = t(e) + if e == nil { + return nil + } + } + return e +} + +type traversal interface { + gMap(*Map) + gSlice(*Slice) + gArray(*Array) + gPtr(*Ptr) + gBase(*BaseElem) + gStruct(*Struct) +} + +// type-switch dispatch to the correct +// method given the type of 'e' +func next(t traversal, e Elem) { + switch e := e.(type) { + case *Map: + t.gMap(e) + case *Struct: + t.gStruct(e) + case *Slice: + t.gSlice(e) + case *Array: + t.gArray(e) + case *Ptr: + t.gPtr(e) + case *BaseElem: + t.gBase(e) + default: + panic("bad element type") + } +} + +// possibly-immutable method receiver +func imutMethodReceiver(p Elem) string { + switch e := p.(type) { + case *Struct: + // TODO(HACK): actually do real math here. + if len(e.Fields) <= 3 { + for i := range e.Fields { + if be, ok := e.Fields[i].FieldElem.(*BaseElem); !ok || (be.Value == IDENT || be.Value == Bytes) { + goto nope + } + } + return p.TypeName() + } + nope: + p.SetVarname("(*" + p.Varname() + ")") + return "*" + p.TypeName() + + // gets dereferenced automatically + case *Array: + p.SetVarname("(*" + p.Varname() + ")") + return "*" + p.TypeName() + + // everything else can be + // by-value. + default: + return p.TypeName() + } +} + +// if necessary, wraps a type +// so that its method receiver +// is of the write type. +func methodReceiver(p Elem) string { + p.SetVarname("(*" + p.Varname() + ")") + return "*" + p.TypeName() +} + +// shared utility for generators +type printer struct { + w io.Writer + err error +} + +// writes "var {{name}} {{typ}};" +func (p *printer) declare(name string, typ string) { + p.printf("\nvar %s %s", name, typ) +} + +// does: +// +// if m == nil { +// m = make(type, size) +// } else if len(m) > 0 { +// for key := range m { delete(m, key) } +// } +// +func (p *printer) resizeMap(size string, isnil string, m *Map, ctx string) []string { + vn := m.Varname() + if !p.ok() { + return nil + } + + allocbound := m.AllocBound() + if allocbound == "" { + return []string{fmt.Sprintf("Missing allocbound on map %v", m)} + } + allocbound = strings.Split(allocbound, ",")[0] + if allocbound != "-" { + p.printf("\nif %s > %s {", size, allocbound) + p.printf("\nerr = msgp.ErrOverflow(uint64(%s), uint64(%s))", size, allocbound) + p.printf("\nerr = msgp.WrapError(err, %s)", ctx) + p.printf("\nreturn") + p.printf("\n}") + } + + // go-codec compat: nil clears map, but if a map already exists + // (e.g., because we are decoding the same key twice), then keep + // the map as-is. + + p.printf("\nif %s {", isnil) + p.printf("\n %s = nil", vn) + p.printf("\n} else if %s == nil {", vn) + p.printf("\n %s = make(%s, %s)", vn, m.TypeName(), size) + p.closeblock() + + return nil +} + +// assign key to value based on varnames +func (p *printer) mapAssign(m *Map) { + if !p.ok() { + return + } + p.printf("\n%s[%s] = %s", m.Varname(), m.Keyidx, m.Validx) +} + +// clear map keys +func (p *printer) clearMap(name string) { + p.printf("\nfor key := range %[1]s { delete(%[1]s, key) }", name) +} + +func (p *printer) wrapErrCheck(ctx string) { + p.print("\nif err != nil {") + p.printf("\nerr = msgp.WrapError(err, %s)", ctx) + p.printf("\nreturn") + p.print("\n}") +} + +func (p *printer) resizeSlice(size string, isnil string, s *Slice, ctx string) []string { + allocbound := s.AllocBound() + if allocbound == "" { + return []string{fmt.Sprintf("Missing allocbound on slice %v", s)} + } + allocbound = strings.Split(allocbound, ",")[0] + if allocbound != "-" { + p.printf("\nif %s > %s {", size, allocbound) + p.printf("\nerr = msgp.ErrOverflow(uint64(%s), uint64(%s))", size, allocbound) + p.printf("\nerr = msgp.WrapError(err, %s)", ctx) + p.printf("\nreturn") + p.printf("\n}") + } + + p.printf("\nif %s {", isnil) + p.printf("\n %s = nil", s.Varname()) + p.printf("\n} else if %[1]s != nil && cap(%[1]s) >= %[2]s {", s.Varname(), size) + p.printf("\n %[1]s = (%[1]s)[:%[2]s]", s.Varname(), size) + p.printf("\n} else {") + p.printf("\n %[1]s = make(%[3]s, %[2]s)", s.Varname(), size, s.TypeName()) + p.printf("\n}") + + return nil +} + +func (p *printer) arrayCheck(want string, got string) { + p.printf("\nif %[1]s != %[2]s { err = msgp.ArrayError{Wanted: %[2]s, Got: %[1]s}; return }", got, want) +} + +func (p *printer) arrayCheckBound(want string, got string) { + p.printf("\nif %[1]s > %[2]s { err = msgp.ArrayError{Wanted: %[2]s, Got: %[1]s}; return }", got, want) +} + +func (p *printer) closeblock() { p.print("\n}") } + +// does: +// +// for idx := range iter { +// {{generate inner}} +// } +// +func (p *printer) rangeBlock(ctx *Context, idx string, iter string, t traversal, inner Elem) { + ctx.PushVar(idx) + p.printf("\n for %s := range %s {", idx, iter) + next(t, inner) + p.closeblock() + ctx.Pop() +} + +func (p *printer) nakedReturn() { + if p.ok() { + p.print("\nreturn\n}\n") + } +} + +func (p *printer) comment(s string) { + p.print("\n// " + s) +} + +func (p *printer) printf(format string, args ...interface{}) { + if p.err == nil { + _, p.err = fmt.Fprintf(p.w, format, args...) + } +} + +func (p *printer) print(format string) { + if p.err == nil { + _, p.err = io.WriteString(p.w, format) + } +} + +func (p *printer) initPtr(pt *Ptr) { + if pt.Needsinit() { + vname := pt.Varname() + p.printf("\nif %s == nil { %s = new(%s); }", vname, vname, pt.Value.TypeName()) + } +} + +func (p *printer) ok() bool { return p.err == nil } + +func tobaseConvert(b *BaseElem) string { + return b.ToBase() + "(" + b.Varname() + ")" +} + +func (p *printer) varWriteMapHeader(receiver string, sizeVarname string, maxSize int) { + if maxSize <= 15 { + p.printf("\nerr = %s.Append(0x80 | uint8(%s))", receiver, sizeVarname) + } else { + p.printf("\nerr = %s.WriteMapHeader(%s)", receiver, sizeVarname) + } +} + +func (p *printer) varAppendMapHeader(sliceVarname string, sizeVarname string, maxSize int) { + if maxSize <= 15 { + p.printf("\n%s = append(%s, 0x80 | uint8(%s))", sliceVarname, sliceVarname, sizeVarname) + } else { + p.printf("\n%s = msgp.AppendMapHeader(%s, %s)", sliceVarname, sliceVarname, sizeVarname) + } +} + +// bmask is a bitmask of a the specified number of bits +type bmask struct { + bitlen int + varname string +} + +// typeDecl returns the variable declaration as a var statement +func (b *bmask) typeDecl() string { + return fmt.Sprintf("var %s %s /* %d bits */", b.varname, b.typeName(), b.bitlen) +} + +// typeName returns the type, e.g. "uint8" or "[2]uint64" +func (b *bmask) typeName() string { + + if b.bitlen <= 8 { + return "uint8" + } + if b.bitlen <= 16 { + return "uint16" + } + if b.bitlen <= 32 { + return "uint32" + } + if b.bitlen <= 64 { + return "uint64" + } + + return fmt.Sprintf("[%d]uint64", (b.bitlen+64-1)/64) +} + +// readExpr returns the expression to read from a position in the bitmask. +// Compare ==0 for false or !=0 for true. +func (b *bmask) readExpr(bitoffset int) string { + + if bitoffset < 0 || bitoffset >= b.bitlen { + panic(fmt.Errorf("bitoffset %d out of range for bitlen %d", bitoffset, b.bitlen)) + } + + var buf bytes.Buffer + buf.Grow(len(b.varname) + 16) + buf.WriteByte('(') + buf.WriteString(b.varname) + if b.bitlen > 64 { + fmt.Fprintf(&buf, "[%d]", (bitoffset / 64)) + } + buf.WriteByte('&') + fmt.Fprintf(&buf, "0x%X", (uint64(1) << (uint64(bitoffset) % 64))) + buf.WriteByte(')') + + return buf.String() + +} + +// setStmt returns the statement to set the specified bit in the bitmask. +func (b *bmask) setStmt(bitoffset int) string { + + var buf bytes.Buffer + buf.Grow(len(b.varname) + 16) + buf.WriteString(b.varname) + if b.bitlen > 64 { + fmt.Fprintf(&buf, "[%d]", (bitoffset / 64)) + } + fmt.Fprintf(&buf, " |= 0x%X", (uint64(1) << (uint64(bitoffset) % 64))) + + return buf.String() + +} diff --git a/msgp/gen/testgen.go b/msgp/gen/testgen.go new file mode 100644 index 0000000000..f046702ff6 --- /dev/null +++ b/msgp/gen/testgen.go @@ -0,0 +1,104 @@ +package gen + +import ( + "io" + "text/template" +) + +var ( + marshalTestTempl = template.New("MarshalTest") +) + +// TODO(philhofer): +// for simplicity's sake, right now +// we can only generate tests for types +// that can be initialized with the +// "Type{}" syntax. +// we should support all the types. + +func mtest(w io.Writer) *mtestGen { + return &mtestGen{w: w} +} + +type mtestGen struct { + passes + w io.Writer +} + +func (m *mtestGen) Execute(p Elem) ([]string, error) { + p = m.applyall(p) + if p != nil && !IsDangling(p) { + switch p.(type) { + case *Struct, *Array, *Slice, *Map: + return nil, marshalTestTempl.Execute(m.w, p) + } + } + return nil, nil +} + +func (m *mtestGen) Method() Method { return marshaltest } + +func init() { + template.Must(marshalTestTempl.Parse(`func TestMarshalUnmarshal{{.TypeName}}(t *testing.T) { + partitiontest.PartitionTest(t) + v := {{.TypeName}}{} + bts := v.MarshalMsg(nil) + left, err := v.UnmarshalMsg(bts) + if err != nil { + t.Fatal(err) + } + if len(left) > 0 { + t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) + } + + left, err = msgp.Skip(bts) + if err != nil { + t.Fatal(err) + } + if len(left) > 0 { + t.Errorf("%d bytes left over after Skip(): %q", len(left), left) + } +} + +func TestRandomizedEncoding{{.TypeName}}(t *testing.T) { + protocol.RunEncodingTest(t, &{{.TypeName}}{}) +} + +func BenchmarkMarshalMsg{{.TypeName}}(b *testing.B) { + v := {{.TypeName}}{} + b.ReportAllocs() + b.ResetTimer() + for i:=0; i %s\n", value)) + } + outbuf.WriteString("//\n") + } + outbuf.WriteString("\n") + return outbuf.Bytes() +} + +func (t *Topics) Add(key, value string) { + if t.structs == nil { + t.structs = make(map[string][]string) + } + if key[0] == '*' { + key = key[1:] + value = "(*) " + value + } + t.structs[key] = append(t.structs[key], value) +} diff --git a/msgp/gen/unmarshal.go b/msgp/gen/unmarshal.go new file mode 100644 index 0000000000..509d9bece9 --- /dev/null +++ b/msgp/gen/unmarshal.go @@ -0,0 +1,358 @@ +package gen + +import ( + "go/ast" + "io" + "strconv" + "strings" +) + +func unmarshal(w io.Writer, topics *Topics) *unmarshalGen { + return &unmarshalGen{ + p: printer{w: w}, + topics: topics, + } +} + +type unmarshalGen struct { + passes + p printer + hasfield bool + ctx *Context + msgs []string + topics *Topics +} + +func (u *unmarshalGen) Method() Method { return Unmarshal } + +func (u *unmarshalGen) needsField() { + if u.hasfield { + return + } + u.p.print("\nvar field []byte; _ = field") + u.hasfield = true +} + +func (u *unmarshalGen) Execute(p Elem) ([]string, error) { + u.msgs = nil + u.hasfield = false + if !u.p.ok() { + return u.msgs, u.p.err + } + p = u.applyall(p) + if p == nil { + return u.msgs, nil + } + + // We might change p.Varname in methodReceiver(); make a copy + // to not affect other code that will use p. + p = p.Copy() + + u.ctx = &Context{} + + u.p.comment("UnmarshalMsg implements msgp.Unmarshaler") + + if IsDangling(p) { + baseType := p.(*BaseElem).IdentName + c := p.Varname() + methodRecv := methodReceiver(p) + u.p.printf("\nfunc (%s %s) UnmarshalMsg(bts []byte) ([]byte, error) {", c, methodRecv) + u.p.printf("\n return ((*(%s))(%s)).UnmarshalMsg(bts)", baseType, c) + u.p.printf("\n}") + + u.p.printf("\nfunc (%s %s) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) ([]byte, error) {", c, methodRecv) + u.p.printf("\n return ((*(%s))(%s)).UnmarshalMsgWithState(bts, st)", baseType, c) + u.p.printf("\n}") + + u.p.printf("\nfunc (_ %[2]s) CanUnmarshalMsg(%[1]s interface{}) bool {", c, methodRecv) + u.p.printf("\n _, ok := (%s).(%s)", c, methodRecv) + u.p.printf("\n return ok") + u.p.printf("\n}") + + u.topics.Add(methodRecv, "UnmarshalMsg") + u.topics.Add(methodRecv, "UnmarshalMsgWithState") + u.topics.Add(methodRecv, "CanUnmarshalMsg") + + return u.msgs, u.p.err + } + + // save the vname before calling methodReceiver + c := p.Varname() + methodRecv := methodReceiver(p) + + u.p.printf("\nfunc (%s %s) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) {", c, methodRecv) + u.p.printf("\n if st.Depth == 0 {") + u.p.printf("\n err = msgp.ErrMaxDepthExceeded{}") + u.p.printf("\n return") + u.p.printf("\n }") + u.p.printf("\n st.Depth--") + next(u, p) + u.p.print("\no = bts") + + // right before the return: attempt to inspect well formed: + for _, callback := range p.GetCallbacks() { + if !callback.IsUnmarshallCallback() { + continue + } + + u.p.printf("\nif err = %s.%s(); err != nil {", c, callback.GetName()) + u.p.printf("\n return") + u.p.printf("\n}") + } + u.p.nakedReturn() + + u.p.printf("\nfunc (%s %s) UnmarshalMsg(bts []byte) (o []byte, err error) {", c, methodRecv) + u.p.printf("\n return %s.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState)", c) + u.p.printf("\n}") + + u.p.printf("\nfunc (_ %[2]s) CanUnmarshalMsg(%[1]s interface{}) bool {", c, methodRecv) + u.p.printf("\n _, ok := (%s).(%s)", c, methodRecv) + u.p.printf("\n return ok") + u.p.printf("\n}") + + u.topics.Add(methodRecv, "UnmarshalMsg") + u.topics.Add(methodRecv, "UnmarshalMsgWithState") + u.topics.Add(methodRecv, "CanUnmarshalMsg") + + return u.msgs, u.p.err +} + +// does assignment to the variable "name" with the type "base" +func (u *unmarshalGen) assignAndCheck(name string, isnil string, base string) { + if !u.p.ok() { + return + } + u.p.printf("\n%s, %s, bts, err = msgp.Read%sBytes(bts)", name, isnil, base) + u.p.wrapErrCheck(u.ctx.ArgsStr()) +} + +func (u *unmarshalGen) gStruct(s *Struct) { + if !u.p.ok() { + return + } + if s.AsTuple { + u.tuple(s) + } else { + u.mapstruct(s) + } + return +} + +func (u *unmarshalGen) tuple(s *Struct) { + + // open block + sz := randIdent() + u.p.declare(sz, "int") + u.assignAndCheck(sz, "_", arrayHeader) + u.p.arrayCheck(strconv.Itoa(len(s.Fields)), sz) + for i := range s.Fields { + if !u.p.ok() { + return + } + u.ctx.PushString(s.Fields[i].FieldName) + next(u, s.Fields[i].FieldElem) + u.ctx.Pop() + } +} + +func (u *unmarshalGen) mapstruct(s *Struct) { + u.needsField() + sz := randIdent() + isnil := randIdent() + u.p.declare(sz, "int") + u.p.declare(isnil, "bool") + + // go-codec compat: decode an array as sequential elements from this struct, + // in the order they are defined in the Go type (as opposed to canonical + // order by sorted tag). + u.p.printf("\n%s, %s, bts, err = msgp.Read%sBytes(bts)", sz, isnil, mapHeader) + u.p.printf("\nif _, ok := err.(msgp.TypeError); ok {") + + u.assignAndCheck(sz, isnil, arrayHeader) + + u.ctx.PushString("struct-from-array") + for i := range s.Fields { + if !ast.IsExported(s.Fields[i].FieldName) { + continue + } + + u.p.printf("\nif %s > 0 {", sz) + u.p.printf("\n%s--", sz) + u.ctx.PushString(s.Fields[i].FieldName) + next(u, s.Fields[i].FieldElem) + u.ctx.Pop() + u.p.printf("\n}") + } + + u.p.printf("\nif %s > 0 {", sz) + u.p.printf("\nerr = msgp.ErrTooManyArrayFields(%s)", sz) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + u.p.printf("\n}") + u.ctx.Pop() + + u.p.printf("\n} else {") + u.p.wrapErrCheck(u.ctx.ArgsStr()) + + u.p.printf("\nif %s {", isnil) + u.p.printf("\n %s = %s{}", s.Varname(), s.TypeName()) + u.p.printf("\n}") + + u.p.printf("\nfor %s > 0 {", sz) + u.p.printf("\n%s--; field, bts, err = msgp.ReadMapKeyZC(bts)", sz) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + u.p.print("\nswitch string(field) {") + for i := range s.Fields { + if !ast.IsExported(s.Fields[i].FieldName) { + continue + } + + if !u.p.ok() { + return + } + u.p.printf("\ncase \"%s\":", s.Fields[i].FieldTag) + u.ctx.PushString(s.Fields[i].FieldName) + next(u, s.Fields[i].FieldElem) + u.ctx.Pop() + } + u.p.print("\ndefault:\nerr = msgp.ErrNoField(string(field))") + u.p.wrapErrCheck(u.ctx.ArgsStr()) + u.p.print("\n}") // close switch + u.p.print("\n}") // close for loop + u.p.print("\n}") // close else statement for array decode +} + +func (u *unmarshalGen) gBase(b *BaseElem) { + if !u.p.ok() { + return + } + + refname := b.Varname() // assigned to + lowered := b.Varname() // passed as argument + if b.Convert { + // begin 'tmp' block + refname = randIdent() + lowered = b.ToBase() + "(" + lowered + ")" + u.p.printf("\n{\nvar %s %s", refname, b.BaseType()) + } + + switch b.Value { + case Bytes: + if b.common.AllocBound() != "" { + sz := randIdent() + u.p.printf("\nvar %s int", sz) + u.p.printf("\n%s, err = msgp.ReadBytesBytesHeader(bts)", sz) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + u.p.printf("\nif %s > %s {", sz, b.common.AllocBound()) + u.p.printf("\nerr = msgp.ErrOverflow(uint64(%s), uint64(%s))", sz, b.common.AllocBound()) + u.p.printf("\nreturn") + u.p.printf("\n}") + } + u.p.printf("\n%s, bts, err = msgp.ReadBytesBytes(bts, %s)", refname, lowered) + case Ext: + u.p.printf("\nbts, err = msgp.ReadExtensionBytes(bts, %s)", lowered) + case IDENT: + u.p.printf("\nbts, err = %s.UnmarshalMsgWithState(bts, st)", lowered) + case String: + if b.common.AllocBound() != "" { + sz := randIdent() + u.p.printf("\nvar %s int", sz) + u.p.printf("\n%s, err = msgp.ReadBytesBytesHeader(bts)", sz) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + u.p.printf("\nif %s > %s {", sz, b.common.AllocBound()) + u.p.printf("\nerr = msgp.ErrOverflow(uint64(%s), uint64(%s))", sz, b.common.AllocBound()) + u.p.printf("\nreturn") + u.p.printf("\n}") + } + u.p.printf("\n%s, bts, err = msgp.ReadStringBytes(bts)", refname) + default: + u.p.printf("\n%s, bts, err = msgp.Read%sBytes(bts)", refname, b.BaseName()) + } + u.p.wrapErrCheck(u.ctx.ArgsStr()) + + if b.Convert { + // close 'tmp' block + if b.ShimMode == Cast { + u.p.printf("\n%s = %s(%s)\n", b.Varname(), b.FromBase(), refname) + } else { + u.p.printf("\n%s, err = %s(%s)", b.Varname(), b.FromBase(), refname) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + } + u.p.printf("}") + } +} + +func (u *unmarshalGen) gArray(a *Array) { + if !u.p.ok() { + return + } + + // special case for [const]byte objects + // see decode.go for symmetry + if be, ok := a.Els.(*BaseElem); ok && be.Value == Byte { + u.p.printf("\nbts, err = msgp.ReadExactBytes(bts, (%s)[:])", a.Varname()) + u.p.wrapErrCheck(u.ctx.ArgsStr()) + return + } + + sz := randIdent() + u.p.declare(sz, "int") + u.assignAndCheck(sz, "_", arrayHeader) + u.p.arrayCheckBound(a.Size, sz) + + u.ctx.PushVar(a.Index) + u.p.printf("\nfor %[1]s := 0; %[1]s < %[2]s; %[1]s++ {", a.Index, sz) + next(u, a.Els) + u.p.closeblock() + u.ctx.Pop() +} + +func (u *unmarshalGen) gSlice(s *Slice) { + if !u.p.ok() { + return + } + sz := randIdent() + isnil := randIdent() + u.p.declare(sz, "int") + u.p.declare(isnil, "bool") + u.assignAndCheck(sz, isnil, arrayHeader) + resizemsgs := u.p.resizeSlice(sz, isnil, s, u.ctx.ArgsStr()) + u.msgs = append(u.msgs, resizemsgs...) + childElement := s.Els + if s.Els.AllocBound() == "" && len(strings.Split(s.AllocBound(), ",")) > 1 { + childElement = s.Els.Copy() + childElement.SetAllocBound(s.AllocBound()[strings.Index(s.AllocBound(), ",")+1:]) + } + u.p.rangeBlock(u.ctx, s.Index, s.Varname(), u, childElement) +} + +func (u *unmarshalGen) gMap(m *Map) { + if !u.p.ok() { + return + } + sz := randIdent() + isnil := randIdent() + u.p.declare(sz, "int") + u.p.declare(isnil, "bool") + u.assignAndCheck(sz, isnil, mapHeader) + + // allocate or clear map + resizemsgs := u.p.resizeMap(sz, isnil, m, u.ctx.ArgsStr()) + u.msgs = append(u.msgs, resizemsgs...) + + // loop and get key,value + u.p.printf("\nfor %s > 0 {", sz) + u.p.printf("\nvar %s %s; var %s %s; %s--", m.Keyidx, m.Key.TypeName(), m.Validx, m.Value.TypeName(), sz) + next(u, m.Key) + u.ctx.PushVar(m.Keyidx) + next(u, m.Value) + u.ctx.Pop() + u.p.mapAssign(m) + u.p.closeblock() +} + +func (u *unmarshalGen) gPtr(p *Ptr) { + u.p.printf("\nif msgp.IsNil(bts) { bts, err = msgp.ReadNilBytes(bts); if err != nil { return }; %s = nil; } else { ", p.Varname()) + u.p.initPtr(p) + next(u, p.Value) + u.p.closeblock() +} diff --git a/msgp/go.mod b/msgp/go.mod new file mode 100644 index 0000000000..c5f3bfa33b --- /dev/null +++ b/msgp/go.mod @@ -0,0 +1,19 @@ +module github.com/algorand/msgp + +go 1.20 + +require ( + github.com/daixiang0/gci v0.3.2 + github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 + golang.org/x/tools v0.1.5 +) + +require ( + github.com/hexops/gotextdiff v1.0.3 // indirect + github.com/kr/text v0.2.0 // indirect + golang.org/x/mod v0.5.0 // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/msgp/go.sum b/msgp/go.sum new file mode 100644 index 0000000000..6b653c5230 --- /dev/null +++ b/msgp/go.sum @@ -0,0 +1,27 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/daixiang0/gci v0.3.2 h1:MDBsgEJGSJ++/N6Je/b2yK5x5WqmKYlzmILLVP41nl8= +github.com/daixiang0/gci v0.3.2/go.mod h1:jaASoJmv/ykO9dAAPy31iJnreV19248qKDdVWf3QgC4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 h1:OXcKh35JaYsGMRzpvFkLv/MEyPuL49CThT1pZ8aSml4= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= +golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q= +golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/msgp/issue185_test.go b/msgp/issue185_test.go new file mode 100644 index 0000000000..c888b4158a --- /dev/null +++ b/msgp/issue185_test.go @@ -0,0 +1,312 @@ +package main + +import ( + "fmt" + "go/ast" + "go/parser" + "go/token" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "sort" + "testing" + "text/template" + + "github.com/algorand/msgp/gen" +) + +// When stuff's going wrong, you'll be glad this is here! +const debugTemp = false + +// Ensure that consistent identifiers are generated on a per-method basis by msgp. +// +// Also ensure that no duplicate identifiers appear in a method. +// +// structs are currently processed alphabetically by msgp. this test relies on +// that property. +// +func TestIssue185Idents(t *testing.T) { + t.SkipNow() + + var identCases = []struct { + tpl *template.Template + expectedChanged []string + }{ + {tpl: issue185IdentsTpl, expectedChanged: []string{"Test1"}}, + {tpl: issue185ComplexIdentsTpl, expectedChanged: []string{"Test2"}}, + } + + methods := []string{"Msgsize", "MarshalMsg", "UnmarshalMsg"} + + for idx, identCase := range identCases { + // generate the code, extract the generated variable names, mapped to function name + var tplData issue185TplData + varsBefore, err := loadVars(identCase.tpl, tplData) + if err != nil { + t.Fatalf("%d: could not extract before vars: %v", idx, err) + } + + // regenerate the code with extra field(s), extract the generated variable + // names, mapped to function name + tplData.Extra = true + varsAfter, err := loadVars(identCase.tpl, tplData) + if err != nil { + t.Fatalf("%d: could not extract after vars: %v", idx, err) + } + + // ensure that all declared variable names inside each of the methods we + // expect to change have actually changed + for _, stct := range identCase.expectedChanged { + for _, method := range methods { + fn := fmt.Sprintf("%s.%s", stct, method) + + bv, av := varsBefore.Value(fn), varsAfter.Value(fn) + if len(bv) > 0 && len(av) > 0 && reflect.DeepEqual(bv, av) { + t.Fatalf("%d vars identical! expected vars to change for %s", idx, fn) + } + delete(varsBefore, fn) + delete(varsAfter, fn) + } + } + + // all of the remaining keys should not have changed + for bmethod, bvars := range varsBefore { + avars := varsAfter.Value(bmethod) + + if !reflect.DeepEqual(bvars, avars) { + t.Fatalf("%d: vars changed! expected vars identical for %s", idx, bmethod) + } + delete(varsBefore, bmethod) + delete(varsAfter, bmethod) + } + + if len(varsBefore) > 0 || len(varsAfter) > 0 { + t.Fatalf("%d: unexpected methods remaining", idx) + } + } +} + +type issue185TplData struct { + Extra bool +} + +func TestIssue185Overlap(t *testing.T) { + t.SkipNow() + + var overlapCases = []struct { + tpl *template.Template + data issue185TplData + }{ + {tpl: issue185IdentsTpl, data: issue185TplData{Extra: false}}, + {tpl: issue185IdentsTpl, data: issue185TplData{Extra: true}}, + {tpl: issue185ComplexIdentsTpl, data: issue185TplData{Extra: false}}, + {tpl: issue185ComplexIdentsTpl, data: issue185TplData{Extra: true}}, + } + + for idx, o := range overlapCases { + // regenerate the code with extra field(s), extract the generated variable + // names, mapped to function name + mvars, err := loadVars(o.tpl, o.data) + if err != nil { + t.Fatalf("%d: could not extract after vars: %v", idx, err) + } + + identCnt := 0 + for fn, vars := range mvars { + sort.Strings(vars) + + // Loose sanity check to make sure the tests expectations aren't broken. + // If the prefix ever changes, this needs to change. + for _, v := range vars { + if v[0] == 'z' { + identCnt++ + } + } + + for i := 0; i < len(vars)-1; i++ { + if vars[i] == vars[i+1] { + t.Fatalf("%d: duplicate var %s in function %s", idx, vars[i], fn) + } + } + } + + // one last sanity check: if there aren't any vars that start with 'z', + // this test's expectations are unsatisfiable. + if identCnt == 0 { + t.Fatalf("%d: no generated identifiers found", idx) + } + } +} + +func loadVars(tpl *template.Template, tplData interface{}) (vars extractedVars, err error) { + tempDir, err := ioutil.TempDir("", "msgp-") + if err != nil { + err = fmt.Errorf("could not create temp dir: %v", err) + return + } + + if !debugTemp { + defer os.RemoveAll(tempDir) + } else { + fmt.Println(tempDir) + } + tfile := filepath.Join(tempDir, "msg.go") + genFile := newFilename(tfile, "") + + if err = goGenerateTpl(tempDir, tfile, tpl, tplData); err != nil { + err = fmt.Errorf("could not generate code: %v", err) + return + } + + vars, err = extractVars(genFile) + if err != nil { + err = fmt.Errorf("could not extract after vars: %v", err) + return + } + + return +} + +type varVisitor struct { + vars []string + fset *token.FileSet +} + +func (v *varVisitor) Visit(node ast.Node) (w ast.Visitor) { + gen, ok := node.(*ast.GenDecl) + if !ok { + return v + } + for _, spec := range gen.Specs { + if vspec, ok := spec.(*ast.ValueSpec); ok { + for _, n := range vspec.Names { + v.vars = append(v.vars, n.Name) + } + } + } + return v +} + +type extractedVars map[string][]string + +func (e extractedVars) Value(key string) []string { + if v, ok := e[key]; ok { + return v + } + panic(fmt.Errorf("unknown key %s", key)) +} + +func extractVars(file string) (extractedVars, error) { + fset := token.NewFileSet() + + f, err := parser.ParseFile(fset, file, nil, 0) + if err != nil { + return nil, err + } + + vars := make(map[string][]string) + for _, d := range f.Decls { + switch d := d.(type) { + case *ast.FuncDecl: + sn := "" + switch rt := d.Recv.List[0].Type.(type) { + case *ast.Ident: + sn = rt.Name + case *ast.StarExpr: + sn = rt.X.(*ast.Ident).Name + default: + panic("unknown receiver type") + } + + key := fmt.Sprintf("%s.%s", sn, d.Name.Name) + vis := &varVisitor{fset: fset} + ast.Walk(vis, d.Body) + vars[key] = vis.vars + } + } + return vars, nil +} + +func goGenerateTpl(cwd, tfile string, tpl *template.Template, tplData interface{}) error { + outf, err := os.OpenFile(tfile, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0600) + if err != nil { + return err + } + defer outf.Close() + + if err := tpl.Execute(outf, tplData); err != nil { + return err + } + + mode := gen.Size | gen.Marshal | gen.Unmarshal + + return Run(tfile, mode, false, "") +} + +var issue185IdentsTpl = template.Must(template.New("").Parse(` +package issue185 + +//go:generate msgp + +type Test1 struct { + Foo string + Bar string + {{ if .Extra }}Baz []string{{ end }} + Qux string +} + +type Test2 struct { + Foo string + Bar string + Baz string +} +`)) + +var issue185ComplexIdentsTpl = template.Must(template.New("").Parse(` +package issue185 + +//go:generate msgp + +type Test1 struct { + Foo string + Bar string + Baz string +} + +type Test2 struct { + Foo string + Bar string + Baz []string + Qux map[string]string + Yep map[string]map[string]string + Quack struct { + Quack struct { + Quack struct { + {{ if .Extra }}Extra []string{{ end }} + Quack string + } + } + } + Nup struct { + Foo string + Bar string + Baz []string + Qux map[string]string + Yep map[string]map[string]string + } + Ding struct { + Dong struct { + Dung struct { + Thing string + } + } + } +} + +type Test3 struct { + Foo string + Bar string + Baz string +} +`)) diff --git a/msgp/main.go b/msgp/main.go new file mode 100644 index 0000000000..8a157d28f4 --- /dev/null +++ b/msgp/main.go @@ -0,0 +1,117 @@ +// msgp is a code generation tool for +// creating methods to serialize and de-serialize +// Go data structures to and from MessagePack. +// +// This package is targeted at the `go generate` tool. +// To use it, include the following directive in a +// go source file with types requiring source generation: +// +// //go:generate msgp +// +// The go generate tool should set the proper environment variables for +// the generator to execute without any command-line flags. However, the +// following options are supported, if you need them: +// +// -o = output file name (default is {input}_gen.go) +// -file = input file name (or directory; default is $GOFILE, which is set by the `go generate` command) +// -io = satisfy the `msgp.Decodable` and `msgp.Encodable` interfaces (default is true) +// -marshal = satisfy the `msgp.Marshaler` and `msgp.Unmarshaler` interfaces (default is true) +// -tests = generate tests and benchmarks (default is true) +// +// For more information, please read README.md, and the wiki at github.com/tinylib/msgp +// +package main + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/algorand/msgp/gen" + "github.com/algorand/msgp/parse" + "github.com/algorand/msgp/printer" + "github.com/ttacon/chalk" +) + +var ( + out = flag.String("o", "", "output file") + file = flag.String("file", "", "input file") + marshal = flag.Bool("marshal", true, "create Marshal and Unmarshal methods") + tests = flag.Bool("tests", true, "create tests and benchmarks") + unexported = flag.Bool("unexported", true, "also process unexported types") + skipFormat = flag.Bool("skip-format", false, "skip formatting the generated code (for debug)") + warnPkgMask = flag.String("warnmask", "", "skip generating warnings on datatypes outside given package") +) + +func main() { + flag.Parse() + + // GOFILE is set by go generate + if *file == "" { + *file = os.Getenv("GOFILE") + if *file == "" { + fmt.Println(chalk.Red.Color("No file to parse.")) + os.Exit(1) + } + } + + var mode gen.Method + if *marshal { + mode |= (gen.Marshal | gen.Unmarshal | gen.Size | gen.IsZero | gen.MaxSize) + } + if *tests { + mode |= gen.Test + } + + if mode&^gen.Test == 0 { + fmt.Println(chalk.Red.Color("No methods to generate; -marshal=false")) + os.Exit(1) + } + + if err := Run(*file, mode, *unexported, *warnPkgMask); err != nil { + fmt.Println(chalk.Red.Color(err.Error())) + os.Exit(1) + } +} + +// Run writes all methods using the associated file or path, e.g. +// +// err := msgp.Run("path/to/myfile.go", gen.Size|gen.Marshal|gen.Unmarshal|gen.Test, false) +// +func Run(gofile string, mode gen.Method, unexported bool, warnPkgMask string) error { + if mode&^gen.Test == 0 { + return nil + } + fmt.Println(chalk.Magenta.Color("======== MessagePack Code Generator =======")) + fmt.Printf(chalk.Magenta.Color(">>> Input: \"%s\"\n"), gofile) + fs, err := parse.File(gofile, unexported, warnPkgMask) + if err != nil { + return err + } + + if len(fs.Identities) == 0 { + fmt.Println(chalk.Magenta.Color("No types requiring code generation were found!")) + return nil + } + + return printer.PrintFile(newFilename(gofile, fs.Package), fs, mode, *skipFormat) +} + +// picks a new file name based on input flags and input filename(s). +func newFilename(old string, pkg string) string { + if *out != "" { + if pre := strings.TrimPrefix(*out, old); len(pre) > 0 && + !strings.HasSuffix(*out, ".go") { + return filepath.Join(old, *out) + } + return *out + } + + if fi, err := os.Stat(old); err == nil && fi.IsDir() { + old = filepath.Join(old, pkg) + } + // new file name is old file name + _gen.go + return strings.TrimSuffix(old, ".go") + "_gen.go" +} diff --git a/msgp/msgp/defs.go b/msgp/msgp/defs.go new file mode 100644 index 0000000000..b1188b041d --- /dev/null +++ b/msgp/msgp/defs.go @@ -0,0 +1,142 @@ +// This package is the support library for the msgp code generator (http://github.com/algorand/msgp). +// +// This package defines the utilites used by the msgp code generator for encoding and decoding MessagePack +// from []byte and io.Reader/io.Writer types. Much of this package is devoted to helping the msgp code +// generator implement the Marshaler/Unmarshaler and Encodable/Decodable interfaces. +// +// This package defines four "families" of functions: +// - AppendXxxx() appends an object to a []byte in MessagePack encoding. +// - ReadXxxxBytes() reads an object from a []byte and returns the remaining bytes. +// - (*Writer).WriteXxxx() writes an object to the buffered *Writer type. +// - (*Reader).ReadXxxx() reads an object from a buffered *Reader type. +// +// Once a type has satisfied the `Encodable` and `Decodable` interfaces, +// it can be written and read from arbitrary `io.Writer`s and `io.Reader`s using +// msgp.Encode(io.Writer, msgp.Encodable) +// and +// msgp.Decode(io.Reader, msgp.Decodable) +// +// There are also methods for converting MessagePack to JSON without +// an explicit de-serialization step. +// +// For additional tips, tricks, and gotchas, please visit +// the wiki at http://github.com/tinylib/msgp +package msgp + +const last4 = 0x0f +const first4 = 0xf0 +const last5 = 0x1f +const first3 = 0xe0 +const last7 = 0x7f + +func isfixint(b byte) bool { + return b>>7 == 0 +} + +func isnfixint(b byte) bool { + return b&first3 == mnfixint +} + +func isfixmap(b byte) bool { + return b&first4 == mfixmap +} + +func isfixarray(b byte) bool { + return b&first4 == mfixarray +} + +func isfixstr(b byte) bool { + return b&first3 == mfixstr +} + +func wfixint(u uint8) byte { + return u & last7 +} + +func rfixint(b byte) uint8 { + return b +} + +func wnfixint(i int8) byte { + return byte(i) | mnfixint +} + +func rnfixint(b byte) int8 { + return int8(b) +} + +func rfixmap(b byte) uint8 { + return b & last4 +} + +func wfixmap(u uint8) byte { + return mfixmap | (u & last4) +} + +func rfixstr(b byte) uint8 { + return b & last5 +} + +func wfixstr(u uint8) byte { + return (u & last5) | mfixstr +} + +func rfixarray(b byte) uint8 { + return (b & last4) +} + +func wfixarray(u uint8) byte { + return (u & last4) | mfixarray +} + +// These are all the byte +// prefixes defined by the +// msgpack standard +const ( + // 0XXXXXXX + mfixint uint8 = 0x00 + + // 111XXXXX + mnfixint uint8 = 0xe0 + + // 1000XXXX + mfixmap uint8 = 0x80 + + // 1001XXXX + mfixarray uint8 = 0x90 + + // 101XXXXX + mfixstr uint8 = 0xa0 + + mnil uint8 = 0xc0 + mfalse uint8 = 0xc2 + mtrue uint8 = 0xc3 + mbin8 uint8 = 0xc4 + mbin16 uint8 = 0xc5 + mbin32 uint8 = 0xc6 + mext8 uint8 = 0xc7 + mext16 uint8 = 0xc8 + mext32 uint8 = 0xc9 + mfloat32 uint8 = 0xca + mfloat64 uint8 = 0xcb + muint8 uint8 = 0xcc + muint16 uint8 = 0xcd + muint32 uint8 = 0xce + muint64 uint8 = 0xcf + mint8 uint8 = 0xd0 + mint16 uint8 = 0xd1 + mint32 uint8 = 0xd2 + mint64 uint8 = 0xd3 + mfixext1 uint8 = 0xd4 + mfixext2 uint8 = 0xd5 + mfixext4 uint8 = 0xd6 + mfixext8 uint8 = 0xd7 + mfixext16 uint8 = 0xd8 + mstr8 uint8 = 0xd9 + mstr16 uint8 = 0xda + mstr32 uint8 = 0xdb + marray16 uint8 = 0xdc + marray32 uint8 = 0xdd + mmap16 uint8 = 0xde + mmap32 uint8 = 0xdf +) diff --git a/msgp/msgp/defs_test.go b/msgp/msgp/defs_test.go new file mode 100644 index 0000000000..667dfd6012 --- /dev/null +++ b/msgp/msgp/defs_test.go @@ -0,0 +1,12 @@ +package msgp_test + +//go:generate msgp -o=defgen_test.go -tests=false + +type Blobs []Blob + +type Blob struct { + Name string `msg:"name"` + Float float64 `msg:"float"` + Bytes []byte `msg:"bytes"` + Amount int64 `msg:"amount"` +} diff --git a/msgp/msgp/elsize.go b/msgp/msgp/elsize.go new file mode 100644 index 0000000000..95762e7eeb --- /dev/null +++ b/msgp/msgp/elsize.go @@ -0,0 +1,99 @@ +package msgp + +// size of every object on the wire, +// plus type information. gives us +// constant-time type information +// for traversing composite objects. +// +var sizes = [256]bytespec{ + mnil: {size: 1, extra: constsize, typ: NilType}, + mfalse: {size: 1, extra: constsize, typ: BoolType}, + mtrue: {size: 1, extra: constsize, typ: BoolType}, + mbin8: {size: 2, extra: extra8, typ: BinType}, + mbin16: {size: 3, extra: extra16, typ: BinType}, + mbin32: {size: 5, extra: extra32, typ: BinType}, + mext8: {size: 3, extra: extra8, typ: ExtensionType}, + mext16: {size: 4, extra: extra16, typ: ExtensionType}, + mext32: {size: 6, extra: extra32, typ: ExtensionType}, + mfloat32: {size: 5, extra: constsize, typ: Float32Type}, + mfloat64: {size: 9, extra: constsize, typ: Float64Type}, + muint8: {size: 2, extra: constsize, typ: UintType}, + muint16: {size: 3, extra: constsize, typ: UintType}, + muint32: {size: 5, extra: constsize, typ: UintType}, + muint64: {size: 9, extra: constsize, typ: UintType}, + mint8: {size: 2, extra: constsize, typ: IntType}, + mint16: {size: 3, extra: constsize, typ: IntType}, + mint32: {size: 5, extra: constsize, typ: IntType}, + mint64: {size: 9, extra: constsize, typ: IntType}, + mfixext1: {size: 3, extra: constsize, typ: ExtensionType}, + mfixext2: {size: 4, extra: constsize, typ: ExtensionType}, + mfixext4: {size: 6, extra: constsize, typ: ExtensionType}, + mfixext8: {size: 10, extra: constsize, typ: ExtensionType}, + mfixext16: {size: 18, extra: constsize, typ: ExtensionType}, + mstr8: {size: 2, extra: extra8, typ: StrType}, + mstr16: {size: 3, extra: extra16, typ: StrType}, + mstr32: {size: 5, extra: extra32, typ: StrType}, + marray16: {size: 3, extra: array16v, typ: ArrayType}, + marray32: {size: 5, extra: array32v, typ: ArrayType}, + mmap16: {size: 3, extra: map16v, typ: MapType}, + mmap32: {size: 5, extra: map32v, typ: MapType}, +} + +func init() { + // set up fixed fields + + // fixint + for i := mfixint; i < 0x80; i++ { + sizes[i] = bytespec{size: 1, extra: constsize, typ: IntType} + } + + // nfixint + for i := uint16(mnfixint); i < 0x100; i++ { + sizes[uint8(i)] = bytespec{size: 1, extra: constsize, typ: IntType} + } + + // fixstr gets constsize, + // since the prefix yields the size + for i := mfixstr; i < 0xc0; i++ { + sizes[i] = bytespec{size: 1 + rfixstr(i), extra: constsize, typ: StrType} + } + + // fixmap + for i := mfixmap; i < 0x90; i++ { + sizes[i] = bytespec{size: 1, extra: varmode(2 * rfixmap(i)), typ: MapType} + } + + // fixarray + for i := mfixarray; i < 0xa0; i++ { + sizes[i] = bytespec{size: 1, extra: varmode(rfixarray(i)), typ: ArrayType} + } +} + +// a valid bytespsec has +// non-zero 'size' and +// non-zero 'typ' +type bytespec struct { + size uint8 // prefix size information + extra varmode // extra size information + typ Type // type + _ byte // makes bytespec 4 bytes (yes, this matters) +} + +// size mode +// if positive, # elements for composites +type varmode int8 + +const ( + constsize varmode = 0 // constant size (size bytes + uint8(varmode) objects) + extra8 = -1 // has uint8(p[1]) extra bytes + extra16 = -2 // has be16(p[1:]) extra bytes + extra32 = -3 // has be32(p[1:]) extra bytes + map16v = -4 // use map16 + map32v = -5 // use map32 + array16v = -6 // use array16 + array32v = -7 // use array32 +) + +func getType(v byte) Type { + return sizes[v].typ +} diff --git a/msgp/msgp/errors.go b/msgp/msgp/errors.go new file mode 100644 index 0000000000..fd2618855f --- /dev/null +++ b/msgp/msgp/errors.go @@ -0,0 +1,354 @@ +package msgp + +import ( + "fmt" + "reflect" +) + +const resumableDefault = false + +var ( + // ErrShortBytes is returned when the + // slice being decoded is too short to + // contain the contents of the message + ErrShortBytes error = errShort{} + + // this error is only returned + // if we reach code that should + // be unreachable + fatal error = errFatal{} +) + +type ErrNoField string + +func (e ErrNoField) Error() string { + return fmt.Sprintf("Unknown field: %s", string(e)) +} + +type ErrTooManyArrayFields int + +func (e ErrTooManyArrayFields) Error() string { + return fmt.Sprintf("Too many array fields when decoding into struct: %d left", int(e)) +} + +// Error is the interface satisfied +// by all of the errors that originate +// from this package. +type Error interface { + error + + // Resumable returns whether + // or not the error means that + // the stream of data is malformed + // and the information is unrecoverable. + Resumable() bool +} + +// contextError allows msgp Error instances to be enhanced with additional +// context about their origin. +type contextError interface { + Error + + // withContext must not modify the error instance - it must clone and + // return a new error with the context added. + withContext(ctx string) error +} + +// Cause returns the underlying cause of an error that has been wrapped +// with additional context. +func Cause(e error) error { + out := e + if e, ok := e.(errWrapped); ok && e.cause != nil { + out = e.cause + } + return out +} + +// Resumable returns whether or not the error means that the stream of data is +// malformed and the information is unrecoverable. +func Resumable(e error) bool { + if e, ok := e.(Error); ok { + return e.Resumable() + } + return resumableDefault +} + +// WrapError wraps an error with additional context that allows the part of the +// serialized type that caused the problem to be identified. Underlying errors +// can be retrieved using Cause() +// +// The input error is not modified - a new error should be returned. +// +// ErrShortBytes is not wrapped with any context due to backward compatibility +// issues with the public API. +func WrapError(err error, ctx ...interface{}) error { + switch e := err.(type) { + case errShort, ErrMaxDepthExceeded: + return e + case contextError: + return e.withContext(ctxString(ctx)) + default: + return errWrapped{cause: err, ctx: ctxString(ctx)} + } +} + +// ctxString converts the incoming interface{} slice into a single string. +func ctxString(ctx []interface{}) string { + out := "" + for idx, cv := range ctx { + if idx > 0 { + out += "/" + } + out += fmt.Sprintf("%v", cv) + } + return out +} + +func addCtx(ctx, add string) string { + if ctx != "" { + return add + "/" + ctx + } else { + return add + } +} + +// errWrapped allows arbitrary errors passed to WrapError to be enhanced with +// context and unwrapped with Cause() +type errWrapped struct { + cause error + ctx string +} + +func (e errWrapped) Error() string { + if e.ctx != "" { + return fmt.Sprintf("%s at %s", e.cause, e.ctx) + } else { + return e.cause.Error() + } +} + +func (e errWrapped) Resumable() bool { + if e, ok := e.cause.(Error); ok { + return e.Resumable() + } + return resumableDefault +} + +type errShort struct{} + +func (e errShort) Error() string { return "msgp: too few bytes left to read object" } +func (e errShort) Resumable() bool { return false } + +// errOverflow is returned when the message +// being decoded has some length field that +// exceeds the maximum allowed length. +type errOverflow struct { + l uint64 + bound uint64 +} + +func (e errOverflow) Error() string { + return fmt.Sprintf("msgp: length overflow: %d > %d", e.l, e.bound) +} + +func (e errOverflow) Resumable() bool { + return false +} + +func ErrOverflow(l uint64, bound uint64) error { + return errOverflow{l, bound} +} + +type errFatal struct { + ctx string +} + +func (f errFatal) Error() string { + out := "msgp: fatal decoding error (unreachable code)" + if f.ctx != "" { + out += " at " + f.ctx + } + return out +} + +func (f errFatal) Resumable() bool { return false } + +func (f errFatal) withContext(ctx string) error { f.ctx = addCtx(f.ctx, ctx); return f } + +// ArrayError is an error returned +// when decoding a fix-sized array +// of the wrong size +type ArrayError struct { + Wanted int + Got int + ctx string +} + +// Error implements the error interface +func (a ArrayError) Error() string { + out := fmt.Sprintf("msgp: wanted array of size %d; got %d", a.Wanted, a.Got) + if a.ctx != "" { + out += " at " + a.ctx + } + return out +} + +// Resumable is always 'true' for ArrayErrors +func (a ArrayError) Resumable() bool { return true } + +func (a ArrayError) withContext(ctx string) error { a.ctx = addCtx(a.ctx, ctx); return a } + +// IntOverflow is returned when a call +// would downcast an integer to a type +// with too few bits to hold its value. +type IntOverflow struct { + Value int64 // the value of the integer + FailedBitsize int // the bit size that the int64 could not fit into + ctx string +} + +// Error implements the error interface +func (i IntOverflow) Error() string { + str := fmt.Sprintf("msgp: %d overflows int%d", i.Value, i.FailedBitsize) + if i.ctx != "" { + str += " at " + i.ctx + } + return str +} + +// Resumable is always 'true' for overflows +func (i IntOverflow) Resumable() bool { return true } + +func (i IntOverflow) withContext(ctx string) error { i.ctx = addCtx(i.ctx, ctx); return i } + +// UintOverflow is returned when a call +// would downcast an unsigned integer to a type +// with too few bits to hold its value +type UintOverflow struct { + Value uint64 // value of the uint + FailedBitsize int // the bit size that couldn't fit the value + ctx string +} + +// Error implements the error interface +func (u UintOverflow) Error() string { + str := fmt.Sprintf("msgp: %d overflows uint%d", u.Value, u.FailedBitsize) + if u.ctx != "" { + str += " at " + u.ctx + } + return str +} + +// Resumable is always 'true' for overflows +func (u UintOverflow) Resumable() bool { return true } + +func (u UintOverflow) withContext(ctx string) error { u.ctx = addCtx(u.ctx, ctx); return u } + +// UintBelowZero is returned when a call +// would cast a signed integer below zero +// to an unsigned integer. +type UintBelowZero struct { + Value int64 // value of the incoming int + ctx string +} + +// Error implements the error interface +func (u UintBelowZero) Error() string { + str := fmt.Sprintf("msgp: attempted to cast int %d to unsigned", u.Value) + if u.ctx != "" { + str += " at " + u.ctx + } + return str +} + +// Resumable is always 'true' for overflows +func (u UintBelowZero) Resumable() bool { return true } + +func (u UintBelowZero) withContext(ctx string) error { + u.ctx = ctx + return u +} + +// A TypeError is returned when a particular +// decoding method is unsuitable for decoding +// a particular MessagePack value. +type TypeError struct { + Method Type // Type expected by method + Encoded Type // Type actually encoded + + ctx string +} + +// Error implements the error interface +func (t TypeError) Error() string { + out := fmt.Sprintf("msgp: attempted to decode type %q with method for %q", t.Encoded, t.Method) + if t.ctx != "" { + out += " at " + t.ctx + } + return out +} + +// Resumable returns 'true' for TypeErrors +func (t TypeError) Resumable() bool { return true } + +func (t TypeError) withContext(ctx string) error { t.ctx = addCtx(t.ctx, ctx); return t } + +// returns either InvalidPrefixError or +// TypeError depending on whether or not +// the prefix is recognized +func badPrefix(want Type, lead byte) error { + t := sizes[lead].typ + if t == InvalidType { + return InvalidPrefixError(lead) + } + return TypeError{Method: want, Encoded: t} +} + +// InvalidPrefixError is returned when a bad encoding +// uses a prefix that is not recognized in the MessagePack standard. +// This kind of error is unrecoverable. +type InvalidPrefixError byte + +// Error implements the error interface +func (i InvalidPrefixError) Error() string { + return fmt.Sprintf("msgp: unrecognized type prefix 0x%x", byte(i)) +} + +// Resumable returns 'false' for InvalidPrefixErrors +func (i InvalidPrefixError) Resumable() bool { return false } + +// ErrUnsupportedType is returned +// when a bad argument is supplied +// to a function that takes `interface{}`. +type ErrUnsupportedType struct { + T reflect.Type + + ctx string +} + +// Error implements error +func (e *ErrUnsupportedType) Error() string { + out := fmt.Sprintf("msgp: type %q not supported", e.T) + if e.ctx != "" { + out += " at " + e.ctx + } + return out +} + +// Resumable returns 'true' for ErrUnsupportedType +func (e *ErrUnsupportedType) Resumable() bool { return true } + +func (e *ErrUnsupportedType) withContext(ctx string) error { + o := *e + o.ctx = addCtx(o.ctx, ctx) + return &o +} + +// ErrMaxDepthExceeded is returned if the maximum traversal depth is exceeded. +type ErrMaxDepthExceeded struct{} + +// Error implements error +func (e ErrMaxDepthExceeded) Error() string { return "Max depth exceeded" } + +// Resumable implements Error +func (e ErrMaxDepthExceeded) Resumable() bool { return false } diff --git a/msgp/msgp/errors_test.go b/msgp/msgp/errors_test.go new file mode 100644 index 0000000000..308bec64d7 --- /dev/null +++ b/msgp/msgp/errors_test.go @@ -0,0 +1,89 @@ +package msgp + +import ( + "errors" + "fmt" + "strings" + "testing" +) + +func TestWrapVanillaErrorWithNoAdditionalContext(t *testing.T) { + err := errors.New("test") + w := WrapError(err) + if w == err { + t.Fatal() + } + if w.Error() != err.Error() { + t.Fatal() + } + if w.(errWrapped).Resumable() { + t.Fatal() + } +} + +func TestWrapVanillaErrorWithAdditionalContext(t *testing.T) { + err := errors.New("test") + w := WrapError(err, "foo", "bar") + if w == err { + t.Fatal() + } + if w.Error() == err.Error() { + t.Fatal() + } + if w.(Error).Resumable() { + t.Fatal() + } + if !strings.HasPrefix(w.Error(), err.Error()) { + t.Fatal() + } + rest := w.Error()[len(err.Error()):] + if rest != " at foo/bar" { + t.Fatal() + } +} + +func TestWrapResumableError(t *testing.T) { + err := ArrayError{} + w := WrapError(err) + if !w.(Error).Resumable() { + t.Fatal() + } +} + +func TestWrapMultiple(t *testing.T) { + err := &TypeError{} + w := WrapError(WrapError(err, "b"), "a") + expected := `msgp: attempted to decode type "" with method for "" at a/b` + if expected != w.Error() { + t.Fatal() + } +} + +func TestCause(t *testing.T) { + for idx, err := range []error{ + errors.New("test"), + ArrayError{}, + &ErrUnsupportedType{}, + } { + t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) { + cerr := WrapError(err, "test") + if cerr == err { + t.Fatal() + } + if Cause(err) != err { + t.Fatal() + } + }) + } +} + +func TestCauseShortByte(t *testing.T) { + err := ErrShortBytes + cerr := WrapError(err, "test") + if cerr != err { + t.Fatal() + } + if Cause(err) != err { + t.Fatal() + } +} diff --git a/msgp/msgp/extension.go b/msgp/msgp/extension.go new file mode 100644 index 0000000000..4f279baa18 --- /dev/null +++ b/msgp/msgp/extension.go @@ -0,0 +1,287 @@ +package msgp + +import ( + "fmt" + "math" +) + +const ( + // Complex64Extension is the extension number used for complex64 + Complex64Extension = 3 + + // Complex128Extension is the extension number used for complex128 + Complex128Extension = 4 + + // TimeExtension is the extension number used for time.Time + TimeExtension = 5 +) + +// our extensions live here +var extensionReg = make(map[int8]func() Extension) + +// RegisterExtension registers extensions so that they +// can be initialized and returned by methods that +// decode `interface{}` values. This should only +// be called during initialization. f() should return +// a newly-initialized zero value of the extension. Keep in +// mind that extensions 3, 4, and 5 are reserved for +// complex64, complex128, and time.Time, respectively, +// and that MessagePack reserves extension types from -127 to -1. +// +// For example, if you wanted to register a user-defined struct: +// +// msgp.RegisterExtension(10, func() msgp.Extension { &MyExtension{} }) +// +// RegisterExtension will panic if you call it multiple times +// with the same 'typ' argument, or if you use a reserved +// type (3, 4, or 5). +func RegisterExtension(typ int8, f func() Extension) { + switch typ { + case Complex64Extension, Complex128Extension, TimeExtension: + panic(fmt.Sprint("msgp: forbidden extension type:", typ)) + } + if _, ok := extensionReg[typ]; ok { + panic(fmt.Sprint("msgp: RegisterExtension() called with typ", typ, "more than once")) + } + extensionReg[typ] = f +} + +// ExtensionTypeError is an error type returned +// when there is a mis-match between an extension type +// and the type encoded on the wire +type ExtensionTypeError struct { + Got int8 + Want int8 +} + +// Error implements the error interface +func (e ExtensionTypeError) Error() string { + return fmt.Sprintf("msgp: error decoding extension: wanted type %d; got type %d", e.Want, e.Got) +} + +// Resumable returns 'true' for ExtensionTypeErrors +func (e ExtensionTypeError) Resumable() bool { return true } + +func errExt(got int8, wanted int8) error { + return ExtensionTypeError{Got: got, Want: wanted} +} + +// Extension is the interface fulfilled +// by types that want to define their +// own binary encoding. +type Extension interface { + // ExtensionType should return + // a int8 that identifies the concrete + // type of the extension. (Types <0 are + // officially reserved by the MessagePack + // specifications.) + ExtensionType() int8 + + // Len should return the length + // of the data to be encoded + Len() int + + // MarshalBinaryTo should copy + // the data into the supplied slice, + // assuming that the slice has length Len() + MarshalBinaryTo([]byte) error + + UnmarshalBinary([]byte) error +} + +// RawExtension implements the Extension interface +type RawExtension struct { + Data []byte + Type int8 +} + +// ExtensionType implements Extension.ExtensionType, and returns r.Type +func (r *RawExtension) ExtensionType() int8 { return r.Type } + +// Len implements Extension.Len, and returns len(r.Data) +func (r *RawExtension) Len() int { return len(r.Data) } + +// MarshalBinaryTo implements Extension.MarshalBinaryTo, +// and returns a copy of r.Data +func (r *RawExtension) MarshalBinaryTo(d []byte) error { + copy(d, r.Data) + return nil +} + +// UnmarshalBinary implements Extension.UnmarshalBinary, +// and sets r.Data to the contents of the provided slice +func (r *RawExtension) UnmarshalBinary(b []byte) error { + if cap(r.Data) >= len(b) { + r.Data = r.Data[0:len(b)] + } else { + r.Data = make([]byte, len(b)) + } + copy(r.Data, b) + return nil +} + +// peekExtension peeks at the extension encoding type +// (must guarantee at least 1 byte in 'b') +func peekExtension(b []byte) (int8, error) { + spec := sizes[b[0]] + size := spec.size + if spec.typ != ExtensionType { + return 0, badPrefix(ExtensionType, b[0]) + } + if len(b) < int(size) { + return 0, ErrShortBytes + } + // for fixed extensions, + // the type information is in + // the second byte + if spec.extra == constsize { + return int8(b[1]), nil + } + // otherwise, it's in the last + // part of the prefix + return int8(b[size-1]), nil +} + +// AppendExtension appends a MessagePack extension to the provided slice +func AppendExtension(b []byte, e Extension) ([]byte, error) { + l := e.Len() + var o []byte + var n int + switch l { + case 0: + o, n = ensure(b, 3) + o[n] = mext8 + o[n+1] = 0 + o[n+2] = byte(e.ExtensionType()) + return o[:n+3], nil + case 1: + o, n = ensure(b, 3) + o[n] = mfixext1 + o[n+1] = byte(e.ExtensionType()) + n += 2 + case 2: + o, n = ensure(b, 4) + o[n] = mfixext2 + o[n+1] = byte(e.ExtensionType()) + n += 2 + case 4: + o, n = ensure(b, 6) + o[n] = mfixext4 + o[n+1] = byte(e.ExtensionType()) + n += 2 + case 8: + o, n = ensure(b, 10) + o[n] = mfixext8 + o[n+1] = byte(e.ExtensionType()) + n += 2 + case 16: + o, n = ensure(b, 18) + o[n] = mfixext16 + o[n+1] = byte(e.ExtensionType()) + n += 2 + default: + switch { + case l < math.MaxUint8: + o, n = ensure(b, l+3) + o[n] = mext8 + o[n+1] = byte(uint8(l)) + o[n+2] = byte(e.ExtensionType()) + n += 3 + case l < math.MaxUint16: + o, n = ensure(b, l+4) + o[n] = mext16 + big.PutUint16(o[n+1:], uint16(l)) + o[n+3] = byte(e.ExtensionType()) + n += 4 + default: + o, n = ensure(b, l+6) + o[n] = mext32 + big.PutUint32(o[n+1:], uint32(l)) + o[n+5] = byte(e.ExtensionType()) + n += 6 + } + } + return o, e.MarshalBinaryTo(o[n:]) +} + +// ReadExtensionBytes reads an extension from 'b' into 'e' +// and returns any remaining bytes. +// Possible errors: +// - ErrShortBytes ('b' not long enough) +// - ExtensionTypeError{} (wire type not the same as e.Type()) +// - TypeError{} (next object not an extension) +// - InvalidPrefixError +// - An umarshal error returned from e.UnmarshalBinary +func ReadExtensionBytes(b []byte, e Extension) ([]byte, error) { + l := len(b) + if l < 3 { + return b, ErrShortBytes + } + lead := b[0] + var ( + sz int // size of 'data' + off int // offset of 'data' + typ int8 + ) + switch lead { + case mfixext1: + typ = int8(b[1]) + sz = 1 + off = 2 + case mfixext2: + typ = int8(b[1]) + sz = 2 + off = 2 + case mfixext4: + typ = int8(b[1]) + sz = 4 + off = 2 + case mfixext8: + typ = int8(b[1]) + sz = 8 + off = 2 + case mfixext16: + typ = int8(b[1]) + sz = 16 + off = 2 + case mext8: + sz = int(uint8(b[1])) + typ = int8(b[2]) + off = 3 + if sz == 0 { + return b[3:], e.UnmarshalBinary(b[3:3]) + } + case mext16: + if l < 4 { + return b, ErrShortBytes + } + sz = int(big.Uint16(b[1:])) + typ = int8(b[3]) + off = 4 + case mext32: + if l < 6 { + return b, ErrShortBytes + } + var err error + sz, err = u32int(big.Uint32(b[1:])) + if err != nil { + return b, err + } + typ = int8(b[5]) + off = 6 + default: + return b, badPrefix(ExtensionType, lead) + } + + if typ != e.ExtensionType() { + return b, errExt(typ, e.ExtensionType()) + } + + // the data of the extension starts + // at 'off' and is 'sz' bytes long + if len(b[off:]) < sz { + return b, ErrShortBytes + } + tot := off + sz + return b[tot:], e.UnmarshalBinary(b[off:tot]) +} diff --git a/msgp/msgp/extension_test.go b/msgp/msgp/extension_test.go new file mode 100644 index 0000000000..a977ea4667 --- /dev/null +++ b/msgp/msgp/extension_test.go @@ -0,0 +1,30 @@ +package msgp + +import ( + "math/rand" + "testing" + "time" +) + +var extSizes = [...]int{0, 1, 2, 4, 8, 16, int(tint8), int(tuint16), int(tuint32)} + +func randomExt() RawExtension { + e := RawExtension{} + e.Type = int8(rand.Int()) + e.Data = RandBytes(extSizes[rand.Intn(len(extSizes))]) + return e +} + +func TestReadWriteExtensionBytes(t *testing.T) { + var bts []byte + rand.Seed(time.Now().Unix()) + + for i := 0; i < 24; i++ { + e := randomExt() + bts, _ = AppendExtension(bts[0:0], &e) + _, err := ReadExtensionBytes(bts, &e) + if err != nil { + t.Errorf("error with extension (length %d): %s", len(bts), err) + } + } +} diff --git a/msgp/msgp/floatbench_test.go b/msgp/msgp/floatbench_test.go new file mode 100644 index 0000000000..575b081bb5 --- /dev/null +++ b/msgp/msgp/floatbench_test.go @@ -0,0 +1,25 @@ +package msgp + +import ( + "testing" +) + +func BenchmarkReadWriteFloat32(b *testing.B) { + var f float32 = 3.9081 + bts := AppendFloat32([]byte{}, f) + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts = AppendFloat32(bts[0:0], f) + f, bts, _ = ReadFloat32Bytes(bts) + } +} + +func BenchmarkReadWriteFloat64(b *testing.B) { + var f float64 = 3.9081 + bts := AppendFloat64([]byte{}, f) + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts = AppendFloat64(bts[0:0], f) + f, bts, _ = ReadFloat64Bytes(bts) + } +} diff --git a/msgp/msgp/int.go b/msgp/msgp/int.go new file mode 100644 index 0000000000..75bfa1500d --- /dev/null +++ b/msgp/msgp/int.go @@ -0,0 +1,20 @@ +package msgp + +// MaxInt is the maximum int, which might be int32 or int64 +const MaxInt = int((^uint(0)) >> 1) + +func u32int(x uint32) (int, error) { + if uint64(x) > uint64(MaxInt) { + return 0, ErrOverflow(uint64(x), uint64(MaxInt)) + } + + return int(x), nil +} + +func u64int(x uint64) (int, error) { + if x > uint64(MaxInt) { + return 0, ErrOverflow(x, uint64(MaxInt)) + } + + return int(x), nil +} diff --git a/msgp/msgp/integers.go b/msgp/msgp/integers.go new file mode 100644 index 0000000000..f817d77598 --- /dev/null +++ b/msgp/msgp/integers.go @@ -0,0 +1,174 @@ +package msgp + +/* ---------------------------------- + integer encoding utilities + (inline-able) + + TODO(tinylib): there are faster, + albeit non-portable solutions + to the code below. implement + byteswap? + ---------------------------------- */ + +func putMint64(b []byte, i int64) { + b[0] = mint64 + b[1] = byte(i >> 56) + b[2] = byte(i >> 48) + b[3] = byte(i >> 40) + b[4] = byte(i >> 32) + b[5] = byte(i >> 24) + b[6] = byte(i >> 16) + b[7] = byte(i >> 8) + b[8] = byte(i) +} + +func getMint64(b []byte) int64 { + return (int64(b[1]) << 56) | (int64(b[2]) << 48) | + (int64(b[3]) << 40) | (int64(b[4]) << 32) | + (int64(b[5]) << 24) | (int64(b[6]) << 16) | + (int64(b[7]) << 8) | (int64(b[8])) +} + +func putMint32(b []byte, i int32) { + b[0] = mint32 + b[1] = byte(i >> 24) + b[2] = byte(i >> 16) + b[3] = byte(i >> 8) + b[4] = byte(i) +} + +func getMint32(b []byte) int32 { + return (int32(b[1]) << 24) | (int32(b[2]) << 16) | (int32(b[3]) << 8) | (int32(b[4])) +} + +func putMint16(b []byte, i int16) { + b[0] = mint16 + b[1] = byte(i >> 8) + b[2] = byte(i) +} + +func getMint16(b []byte) (i int16) { + return (int16(b[1]) << 8) | int16(b[2]) +} + +func putMint8(b []byte, i int8) { + b[0] = mint8 + b[1] = byte(i) +} + +func getMint8(b []byte) (i int8) { + return int8(b[1]) +} + +func putMuint64(b []byte, u uint64) { + b[0] = muint64 + b[1] = byte(u >> 56) + b[2] = byte(u >> 48) + b[3] = byte(u >> 40) + b[4] = byte(u >> 32) + b[5] = byte(u >> 24) + b[6] = byte(u >> 16) + b[7] = byte(u >> 8) + b[8] = byte(u) +} + +func getMuint64(b []byte) uint64 { + return (uint64(b[1]) << 56) | (uint64(b[2]) << 48) | + (uint64(b[3]) << 40) | (uint64(b[4]) << 32) | + (uint64(b[5]) << 24) | (uint64(b[6]) << 16) | + (uint64(b[7]) << 8) | (uint64(b[8])) +} + +func putMuint32(b []byte, u uint32) { + b[0] = muint32 + b[1] = byte(u >> 24) + b[2] = byte(u >> 16) + b[3] = byte(u >> 8) + b[4] = byte(u) +} + +func getMuint32(b []byte) uint32 { + return (uint32(b[1]) << 24) | (uint32(b[2]) << 16) | (uint32(b[3]) << 8) | (uint32(b[4])) +} + +func putMuint16(b []byte, u uint16) { + b[0] = muint16 + b[1] = byte(u >> 8) + b[2] = byte(u) +} + +func getMuint16(b []byte) uint16 { + return (uint16(b[1]) << 8) | uint16(b[2]) +} + +func putMuint8(b []byte, u uint8) { + b[0] = muint8 + b[1] = byte(u) +} + +func getMuint8(b []byte) uint8 { + return uint8(b[1]) +} + +func getUnix(b []byte) (sec int64, nsec int32) { + sec = (int64(b[0]) << 56) | (int64(b[1]) << 48) | + (int64(b[2]) << 40) | (int64(b[3]) << 32) | + (int64(b[4]) << 24) | (int64(b[5]) << 16) | + (int64(b[6]) << 8) | (int64(b[7])) + + nsec = (int32(b[8]) << 24) | (int32(b[9]) << 16) | (int32(b[10]) << 8) | (int32(b[11])) + return +} + +func putUnix(b []byte, sec int64, nsec int32) { + b[0] = byte(sec >> 56) + b[1] = byte(sec >> 48) + b[2] = byte(sec >> 40) + b[3] = byte(sec >> 32) + b[4] = byte(sec >> 24) + b[5] = byte(sec >> 16) + b[6] = byte(sec >> 8) + b[7] = byte(sec) + b[8] = byte(nsec >> 24) + b[9] = byte(nsec >> 16) + b[10] = byte(nsec >> 8) + b[11] = byte(nsec) +} + +/* ----------------------------- + prefix utilities + ----------------------------- */ + +// write prefix and uint8 +func prefixu8(b []byte, pre byte, sz uint8) { + b[0] = pre + b[1] = byte(sz) +} + +// write prefix and big-endian uint16 +func prefixu16(b []byte, pre byte, sz uint16) { + b[0] = pre + b[1] = byte(sz >> 8) + b[2] = byte(sz) +} + +// write prefix and big-endian uint32 +func prefixu32(b []byte, pre byte, sz uint32) { + b[0] = pre + b[1] = byte(sz >> 24) + b[2] = byte(sz >> 16) + b[3] = byte(sz >> 8) + b[4] = byte(sz) +} + +func prefixu64(b []byte, pre byte, sz uint64) { + b[0] = pre + b[1] = byte(sz >> 56) + b[2] = byte(sz >> 48) + b[3] = byte(sz >> 40) + b[4] = byte(sz >> 32) + b[5] = byte(sz >> 24) + b[6] = byte(sz >> 16) + b[7] = byte(sz >> 8) + b[8] = byte(sz) +} diff --git a/msgp/msgp/read.go b/msgp/msgp/read.go new file mode 100644 index 0000000000..f214e07451 --- /dev/null +++ b/msgp/msgp/read.go @@ -0,0 +1,91 @@ +package msgp + +// Type is a MessagePack wire type, +// including this package's built-in +// extension types. +type Type byte + +// MessagePack Types +// +// The zero value of Type +// is InvalidType. +const ( + InvalidType Type = iota + + // MessagePack built-in types + + StrType + BinType + MapType + ArrayType + Float64Type + Float32Type + BoolType + IntType + UintType + NilType + ExtensionType + + // pseudo-types provided + // by extensions + + Complex64Type + Complex128Type + TimeType + + _maxtype +) + +// String implements fmt.Stringer +func (t Type) String() string { + switch t { + case StrType: + return "str" + case BinType: + return "bin" + case MapType: + return "map" + case ArrayType: + return "array" + case Float64Type: + return "float64" + case Float32Type: + return "float32" + case BoolType: + return "bool" + case UintType: + return "uint" + case IntType: + return "int" + case ExtensionType: + return "ext" + case NilType: + return "nil" + default: + return "" + } +} + +// Unmarshaler is the interface fulfilled +// by objects that know how to unmarshal +// themselves from MessagePack. +// UnmarshalMsg unmarshals the object +// from binary, returing any leftover +// bytes and any errors encountered. +// CanUnmarshalMsg checks that o is of the same type as +// was used to generate the UnmarshalMsg code; it can be +// used to guard against UnmarshalMsg() going to an embedded +// field in a struct rather than unmarshaling the entire struct. +type Unmarshaler interface { + UnmarshalMsg([]byte) ([]byte, error) + UnmarshalMsgWithState([]byte, UnmarshalState) ([]byte, error) + CanUnmarshalMsg(o interface{}) bool +} + +// UnmarshalState holds state while running UnmarshalMsg. +type UnmarshalState struct { + Depth uint64 +} + +// DefaultUnmarshalState defines the default state. +var DefaultUnmarshalState = UnmarshalState{Depth: 10000} diff --git a/msgp/msgp/read_bytes.go b/msgp/msgp/read_bytes.go new file mode 100644 index 0000000000..0ade0fb1ca --- /dev/null +++ b/msgp/msgp/read_bytes.go @@ -0,0 +1,1359 @@ +package msgp + +import ( + "encoding/binary" + "math" + "time" +) + +var big = binary.BigEndian + +// NextType returns the type of the next +// object in the slice. If the length +// of the input is zero, it returns +// InvalidType. +func NextType(b []byte) Type { + if len(b) == 0 { + return InvalidType + } + spec := sizes[b[0]] + t := spec.typ + if t == ExtensionType && len(b) > int(spec.size) { + var tp int8 + if spec.extra == constsize { + tp = int8(b[1]) + } else { + tp = int8(b[spec.size-1]) + } + switch tp { + case TimeExtension: + return TimeType + case Complex128Extension: + return Complex128Type + case Complex64Extension: + return Complex64Type + default: + return ExtensionType + } + } + return t +} + +// IsNil returns true if len(b)>0 and +// the leading byte is a 'nil' MessagePack +// byte; false otherwise +func IsNil(b []byte) bool { + if len(b) != 0 && b[0] == mnil { + return true + } + return false +} + +// Raw is raw MessagePack. +// Raw allows you to read and write +// data without interpreting its contents. +type Raw []byte + +// CanMarshalMsg returns true if the z interface is a Raw object ( part of the Marshaler interface ) +func (Raw) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Raw) + if !ok { + _, ok = (z).(*Raw) + } + return ok +} + +// MarshalMsg implements msgp.Marshaler. +// It appends the raw contents of 'raw' +// to the provided byte slice. If 'raw' +// is 0 bytes, 'nil' will be appended instead. +func (r Raw) MarshalMsg(b []byte) []byte { + i := len(r) + if i == 0 { + return AppendNil(b) + } + o, l := ensure(b, i) + copy(o[l:], []byte(r)) + return o +} + +// CanUnmarshalMsg returns true if the z interface is a Raw object ( part of the Unmarshaler interface ) +func (*Raw) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Raw) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler. +// It sets the contents of *Raw to be the next +// object in the provided byte slice. +func (r *Raw) UnmarshalMsg(b []byte) ([]byte, error) { + return r.UnmarshalMsgWithState(b, DefaultUnmarshalState) +} + +// UnmarshalMsg implements msgp.Unmarshaler. +// It sets the contents of *Raw to be the next +// object in the provided byte slice. +func (r *Raw) UnmarshalMsgWithState(b []byte, st UnmarshalState) ([]byte, error) { + if st.Depth == 0 { + return nil, ErrMaxDepthExceeded{} + } + l := len(b) + out, err := Skip(b) + if err != nil { + return b, err + } + rlen := l - len(out) + if IsNil(b[:rlen]) { + rlen = 0 + } + if cap(*r) < rlen { + *r = make(Raw, rlen) + } else { + *r = (*r)[0:rlen] + } + copy(*r, b[:rlen]) + return out, nil +} + +// Msgsize implements msgp.Sizer +func (r Raw) Msgsize() int { + l := len(r) + if l == 0 { + return 1 // for 'nil' + } + return l +} + +// MsgIsZero returns whether this is a zero value +func (r *Raw) MsgIsZero() bool { + return len(*r) == 0 +} + +// ReadMapHeaderBytes reads a map header size +// from 'b' and returns the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a map) +func ReadMapHeaderBytes(b []byte) (sz int, isnil bool, o []byte, err error) { + l := len(b) + if l < 1 { + err = ErrShortBytes + return + } + + lead := b[0] + if isfixmap(lead) { + sz = int(rfixmap(lead)) + o = b[1:] + return + } + + switch lead { + // go-codec compatibility: mnil decodes as a nil map / empty struct + case mnil: + sz = 0 + o = b[1:] + isnil = true + return + + case mmap16: + if l < 3 { + err = ErrShortBytes + return + } + sz = int(big.Uint16(b[1:])) + o = b[3:] + return + + case mmap32: + if l < 5 { + err = ErrShortBytes + return + } + sz, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + o = b[5:] + return + + default: + o = b + err = badPrefix(MapType, lead) + return + } +} + +// ReadMapKeyZC attempts to read a map key +// from 'b' and returns the key bytes and the remaining bytes +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a str or bin) +func ReadMapKeyZC(b []byte) ([]byte, []byte, error) { + o, x, err := ReadStringZC(b) + if err != nil { + if tperr, ok := err.(TypeError); ok && tperr.Encoded == BinType { + return ReadBytesZC(b) + } + return nil, b, err + } + return o, x, nil +} + +// ReadArrayHeaderBytes attempts to read +// the array header size off of 'b' and return +// the size and remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not an array) +func ReadArrayHeaderBytes(b []byte) (sz int, isnil bool, o []byte, err error) { + return readArrayHeaderBytes(b, true) +} + +func readArrayHeaderBytes(b []byte, flattenMap bool) (sz int, isnil bool, o []byte, err error) { + if len(b) < 1 { + return 0, false, nil, ErrShortBytes + } + lead := b[0] + if isfixarray(lead) { + sz = int(rfixarray(lead)) + o = b[1:] + return + } + + // go-codec compat: map can be decoded as an array, by alternating + // the map keys and values in the decoded array. + if flattenMap && isfixmap(lead) { + sz = 2 * int(rfixmap(lead)) + o = b[1:] + return + } + + switch lead { + case mnil: + // go-codec compat: nil decodes as an empty array (nil for slice) + sz = 0 + o = b[1:] + isnil = true + return + + case marray16: + if len(b) < 3 { + err = ErrShortBytes + return + } + sz = int(big.Uint16(b[1:])) + o = b[3:] + return + + case marray32: + if len(b) < 5 { + err = ErrShortBytes + return + } + sz, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + o = b[5:] + return + + // go-codec compat: map can be decoded as an array, by alternating + // the map keys and values in the decoded array. + case mmap16: + if flattenMap { + if len(b) < 3 { + err = ErrShortBytes + return + } + sz = 2 * int(big.Uint16(b[1:])) + o = b[3:] + return + } + + case mmap32: + if flattenMap { + if len(b) < 5 { + err = ErrShortBytes + return + } + u64sz := 2 * uint64(big.Uint32(b[1:])) + sz, err = u64int(u64sz) + if err != nil { + return + } + o = b[5:] + return + } + } + + o = b + err = badPrefix(ArrayType, lead) + return +} + +// ReadNilBytes tries to read a "nil" byte +// off of 'b' and return the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a 'nil') +// - InvalidPrefixError +func ReadNilBytes(b []byte) ([]byte, error) { + if len(b) < 1 { + return nil, ErrShortBytes + } + if b[0] != mnil { + return b, badPrefix(NilType, b[0]) + } + return b[1:], nil +} + +// ReadFloat64Bytes tries to read a float64 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a float64) +func ReadFloat64Bytes(b []byte) (f float64, o []byte, err error) { + if len(b) < 9 { + if len(b) >= 5 && b[0] == mfloat32 { + var tf float32 + tf, o, err = ReadFloat32Bytes(b) + f = float64(tf) + return + } + if b[0] == mnil { + o = b[1:] + return + } + err = ErrShortBytes + return + } + + if b[0] != mfloat64 { + if b[0] == mfloat32 { + var tf float32 + tf, o, err = ReadFloat32Bytes(b) + f = float64(tf) + return + } + err = badPrefix(Float64Type, b[0]) + return + } + + f = math.Float64frombits(getMuint64(b)) + o = b[9:] + return +} + +// ReadFloat32Bytes tries to read a float64 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a float32) +func ReadFloat32Bytes(b []byte) (f float32, o []byte, err error) { + if len(b) < 1 { + err = ErrShortBytes + return + } + + if b[0] == mnil { + o = b[1:] + return + } + + if b[0] != mfloat32 { + err = TypeError{Method: Float32Type, Encoded: getType(b[0])} + return + } + + if len(b) < 5 { + err = ErrShortBytes + return + } + + f = math.Float32frombits(getMuint32(b)) + o = b[5:] + return +} + +// ReadBoolBytes tries to read a float64 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a bool) +func ReadBoolBytes(b []byte) (bool, []byte, error) { + if len(b) < 1 { + return false, b, ErrShortBytes + } + switch b[0] { + case mtrue: + return true, b[1:], nil + case mfalse: + return false, b[1:], nil + case mnil: + return false, b[1:], nil + default: + return false, b, badPrefix(BoolType, b[0]) + } +} + +// ReadDurationBytes tries to read a time.Duration +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError (not a int) +func ReadDurationBytes(b []byte) (d time.Duration, o []byte, err error) { + i, o, err := ReadInt64Bytes(b) + return time.Duration(i), o, err +} + +// ReadInt64Bytes tries to read an int64 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError (not a int) +func ReadInt64Bytes(b []byte) (i int64, o []byte, err error) { + l := len(b) + if l < 1 { + return 0, nil, ErrShortBytes + } + + lead := b[0] + if isfixint(lead) { + i = int64(rfixint(lead)) + o = b[1:] + return + } + if isnfixint(lead) { + i = int64(rnfixint(lead)) + o = b[1:] + return + } + + switch lead { + case mnil: + i = 0 + o = b[1:] + return + + case mint8: + if l < 2 { + err = ErrShortBytes + return + } + i = int64(getMint8(b)) + o = b[2:] + return + + case muint8: + if l < 2 { + err = ErrShortBytes + return + } + i = int64(getMuint8(b)) + o = b[2:] + return + + case mint16: + if l < 3 { + err = ErrShortBytes + return + } + i = int64(getMint16(b)) + o = b[3:] + return + + case muint16: + if l < 3 { + err = ErrShortBytes + return + } + i = int64(getMuint16(b)) + o = b[3:] + return + + case mint32: + if l < 5 { + err = ErrShortBytes + return + } + i = int64(getMint32(b)) + o = b[5:] + return + + case muint32: + if l < 5 { + err = ErrShortBytes + return + } + i = int64(getMuint32(b)) + o = b[5:] + return + + case mint64: + if l < 9 { + err = ErrShortBytes + return + } + i = int64(getMint64(b)) + o = b[9:] + return + + case muint64: + if l < 9 { + err = ErrShortBytes + return + } + u := getMuint64(b) + // go-codec compat: uint64 encodings that exceed MaxInt64 + // just overflow when parsed as int64. + // + // if u > math.MaxInt64 { + // err = UintOverflow{Value: u, FailedBitsize: 64} + // return + // } + i = int64(u) + o = b[9:] + return + + default: + err = badPrefix(IntType, lead) + return + } +} + +// ReadInt32Bytes tries to read an int32 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a int) +// - IntOverflow{} (value doesn't fit in int32) +func ReadInt32Bytes(b []byte) (int32, []byte, error) { + i, o, err := ReadInt64Bytes(b) + if i > math.MaxInt32 || i < math.MinInt32 { + return 0, o, IntOverflow{Value: i, FailedBitsize: 32} + } + return int32(i), o, err +} + +// ReadInt16Bytes tries to read an int16 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a int) +// - IntOverflow{} (value doesn't fit in int16) +func ReadInt16Bytes(b []byte) (int16, []byte, error) { + i, o, err := ReadInt64Bytes(b) + if i > math.MaxInt16 || i < math.MinInt16 { + return 0, o, IntOverflow{Value: i, FailedBitsize: 16} + } + return int16(i), o, err +} + +// ReadInt8Bytes tries to read an int16 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a int) +// - IntOverflow{} (value doesn't fit in int8) +func ReadInt8Bytes(b []byte) (int8, []byte, error) { + i, o, err := ReadInt64Bytes(b) + if i > math.MaxInt8 || i < math.MinInt8 { + return 0, o, IntOverflow{Value: i, FailedBitsize: 8} + } + return int8(i), o, err +} + +// ReadUint64Bytes tries to read a uint64 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a uint) +func ReadUint64Bytes(b []byte) (u uint64, o []byte, err error) { + l := len(b) + if l < 1 { + return 0, nil, ErrShortBytes + } + + lead := b[0] + if isfixint(lead) { + u = uint64(rfixint(lead)) + o = b[1:] + return + } + + switch lead { + case mnil: + u = 0 + o = b[1:] + return + + case mint8: + if l < 2 { + err = ErrShortBytes + return + } + v := int64(getMint8(b)) + if v < 0 { + err = UintBelowZero{Value: v} + return + } + u = uint64(v) + o = b[2:] + return + + case muint8: + if l < 2 { + err = ErrShortBytes + return + } + u = uint64(getMuint8(b)) + o = b[2:] + return + + case mint16: + if l < 3 { + err = ErrShortBytes + return + } + v := int64(getMint16(b)) + if v < 0 { + err = UintBelowZero{Value: v} + return + } + u = uint64(v) + o = b[3:] + return + + case muint16: + if l < 3 { + err = ErrShortBytes + return + } + u = uint64(getMuint16(b)) + o = b[3:] + return + + case mint32: + if l < 5 { + err = ErrShortBytes + return + } + v := int64(getMint32(b)) + if v < 0 { + err = UintBelowZero{Value: v} + return + } + u = uint64(v) + o = b[5:] + return + + case muint32: + if l < 5 { + err = ErrShortBytes + return + } + u = uint64(getMuint32(b)) + o = b[5:] + return + + case mint64: + if l < 9 { + err = ErrShortBytes + return + } + v := int64(getMint64(b)) + if v < 0 { + err = UintBelowZero{Value: v} + return + } + u = uint64(v) + o = b[9:] + return + + case muint64: + if l < 9 { + err = ErrShortBytes + return + } + u = getMuint64(b) + o = b[9:] + return + + default: + if isnfixint(lead) { + err = UintBelowZero{Value: int64(rnfixint(lead))} + } else { + err = badPrefix(UintType, lead) + } + return + } +} + +// ReadUint32Bytes tries to read a uint32 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a uint) +// - UintOverflow{} (value too large for uint32) +func ReadUint32Bytes(b []byte) (uint32, []byte, error) { + v, o, err := ReadUint64Bytes(b) + if v > math.MaxUint32 { + return 0, nil, UintOverflow{Value: v, FailedBitsize: 32} + } + return uint32(v), o, err +} + +// ReadUint16Bytes tries to read a uint16 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a uint) +// - UintOverflow{} (value too large for uint16) +func ReadUint16Bytes(b []byte) (uint16, []byte, error) { + v, o, err := ReadUint64Bytes(b) + if v > math.MaxUint16 { + return 0, nil, UintOverflow{Value: v, FailedBitsize: 16} + } + return uint16(v), o, err +} + +// ReadUint8Bytes tries to read a uint8 +// from 'b' and return the value and the remaining bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a uint) +// - UintOverflow{} (value too large for uint8) +func ReadUint8Bytes(b []byte) (uint8, []byte, error) { + v, o, err := ReadUint64Bytes(b) + if v > math.MaxUint8 { + return 0, nil, UintOverflow{Value: v, FailedBitsize: 8} + } + return uint8(v), o, err +} + +// ReadByteBytes is analogous to ReadUint8Bytes +func ReadByteBytes(b []byte) (byte, []byte, error) { + return ReadUint8Bytes(b) +} + +// ReadBytesBytes reads a 'bin' object +// from 'b' and returns its value and +// the remaining bytes in 'b'. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a 'bin' object) +func ReadBytesBytes(b []byte, scratch []byte) (v []byte, o []byte, err error) { + return readBytesBytes(b, scratch, false, true) +} + +func readBytesBytesSlow(b []byte, flattenMap bool) (v []byte, o []byte, err error) { + var count int + count, _, o, err = readArrayHeaderBytes(b, flattenMap) + if err != nil { + return + } + + if len(o) < count { + err = ErrShortBytes + return + } + + v = make([]byte, count) + for idx := range v { + v[idx], o, err = ReadByteBytes(o) + if err != nil { + return + } + } + + return +} + +// ReadBytesBytesHeader reads the header of a 'bin' object +// from 'b' and return it's length, in bytes. +// Possible errors: +// - ErrShortBytes (too few bytes) +// - TypeError{} (not a 'bin' object) +func ReadBytesBytesHeader(b []byte) (sz int, err error) { + l := len(b) + if l < 1 { + return 0, ErrShortBytes + } + + lead := b[0] + + // go-codec compat: decode string encodings into byte arrays + + if isfixstr(lead) { + sz = int(rfixstr(lead)) + return + } + + switch lead { + case mstr8: + if l < 2 { + err = ErrShortBytes + return + } + sz = int(b[1]) + return + + case mstr16: + if l < 3 { + err = ErrShortBytes + return + } + sz = int(big.Uint16(b[1:])) + return + + case mstr32: + if l < 5 { + err = ErrShortBytes + return + } + sz, err = u32int(big.Uint32(b[1:])) + return + + case mnil: + sz = 0 + return + + case mbin8: + if l < 2 { + err = ErrShortBytes + return + } + sz = int(b[1]) + return + + case mbin16: + if l < 3 { + err = ErrShortBytes + return + } + sz = int(big.Uint16(b[1:])) + return + + case mbin32: + if l < 5 { + err = ErrShortBytes + return + } + sz, err = u32int(big.Uint32(b[1:])) + return + + default: + sz, _, _, err = readArrayHeaderBytes(b, true) + return + } +} + +func readBytesBytes(b []byte, scratch []byte, zc bool, flattenMap bool) (v []byte, o []byte, err error) { + l := len(b) + if l < 1 { + return nil, nil, ErrShortBytes + } + + lead := b[0] + var read int + + // go-codec compat: decode string encodings into byte arrays + + if isfixstr(lead) { + read = int(rfixstr(lead)) + b = b[1:] + } else { + switch lead { + case mstr8: + if l < 2 { + err = ErrShortBytes + return + } + read = int(b[1]) + b = b[2:] + + case mstr16: + if l < 3 { + err = ErrShortBytes + return + } + read = int(big.Uint16(b[1:])) + b = b[3:] + + case mstr32: + if l < 5 { + err = ErrShortBytes + return + } + read, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + b = b[5:] + + case mnil: + v = nil + o = b[1:] + return + + case mbin8: + if l < 2 { + err = ErrShortBytes + return + } + read = int(b[1]) + b = b[2:] + + case mbin16: + if l < 3 { + err = ErrShortBytes + return + } + read = int(big.Uint16(b[1:])) + b = b[3:] + + case mbin32: + if l < 5 { + err = ErrShortBytes + return + } + read, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + b = b[5:] + + default: + // go-codec compat: decode into byte array/slice from + // explicit array encodings (including the weird case + // of decoding a map as a key-value interleaved array). + v, o, err = readBytesBytesSlow(b, flattenMap) + if err != nil { + // If that doesn't work, return the original error code. + err = badPrefix(BinType, lead) + } + return + } + } + + if len(b) < read { + err = ErrShortBytes + return + } + + // zero-copy + if zc { + v = b[0:read] + o = b[read:] + return + } + + // The "scratch != nil" check is to match go-codec behavior: + // decode zero-length byte slices as a non-nil byte slice. + if scratch != nil && cap(scratch) >= read { + v = scratch[0:read] + } else { + v = make([]byte, read) + } + + o = b[copy(v, b):] + return +} + +// ReadBytesZC extracts the messagepack-encoded +// binary field without copying. The returned []byte +// points to the same memory as the input slice. +// Possible errors: +// - ErrShortBytes (b not long enough) +// - TypeError{} (object not 'bin') +func ReadBytesZC(b []byte) (v []byte, o []byte, err error) { + return readBytesBytes(b, nil, true, true) +} + +func readExactBytesSlow(b []byte, into []byte) (o []byte, err error) { + var count int + count, _, o, err = ReadArrayHeaderBytes(b) + if err != nil { + return + } + + if count > len(into) { + err = ArrayError{Wanted: len(into), Got: count} + return + } + + for idx := 0; idx < count; idx++ { + into[idx], o, err = ReadByteBytes(o) + if err != nil { + return + } + } + + return +} + +func ReadExactBytes(b []byte, into []byte) (o []byte, err error) { + l := len(b) + if l < 1 { + err = ErrShortBytes + return + } + + lead := b[0] + var read int + var skip int + + // go-codec compat: decode string encodings into byte arrays + + if isfixstr(lead) { + read = int(rfixstr(lead)) + skip = 1 + } else { + switch lead { + case mstr8: + if l < 2 { + err = ErrShortBytes + return + } + read = int(b[1]) + skip = 2 + + case mstr16: + if l < 3 { + err = ErrShortBytes + return + } + read = int(big.Uint16(b[1:])) + skip = 3 + + case mstr32: + if l < 5 { + err = ErrShortBytes + return + } + read, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + skip = 5 + + case mnil: + // go-codec compat: decoding nil into an array clears the array; + // different from decoding a zero-length array (which updates + // in-place). + for i := range into { + into[i] = 0 + } + read = 0 + skip = 1 + + case mbin8: + if l < 2 { + err = ErrShortBytes + return + } + read = int(b[1]) + skip = 2 + + case mbin16: + if l < 3 { + err = ErrShortBytes + return + } + read = int(big.Uint16(b[1:])) + skip = 3 + + case mbin32: + if l < 5 { + err = ErrShortBytes + return + } + read, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + skip = 5 + + default: + // go-codec compat: decode into byte array from + // explicit array encodings (including the weird case + // of decoding a map as a key-value interleaved array). + o, err = readExactBytesSlow(b, into) + if err != nil { + // If that doesn't work, return the original error code. + err = badPrefix(BinType, lead) + } + return + } + } + + // go-codec compat: allow decoding a different number of bytes than the + // size of the fixed array; take the min of the size of the Go type and + // the encoded array size. + // + // if read != len(into) { + // err = ArrayError{Wanted: uint32(len(into)), Got: uint32(read)} + // return + // } + + if read > len(b[skip:]) { + err = ErrShortBytes + return + } + + copy(into, b[skip:skip+read]) + o = b[skip+read:] + return +} + +// ReadStringZC reads a messagepack string field +// without copying. The returned []byte points +// to the same memory as the input slice. +// Possible errors: +// - ErrShortBytes (b not long enough) +// - TypeError{} (object not 'str') +func ReadStringZC(b []byte) (v []byte, o []byte, err error) { + l := len(b) + if l < 1 { + return nil, nil, ErrShortBytes + } + + lead := b[0] + var read int + + if isfixstr(lead) { + read = int(rfixstr(lead)) + b = b[1:] + } else { + switch lead { + case mnil: + read = 0 + b = b[1:] + + case mstr8: + if l < 2 { + err = ErrShortBytes + return + } + read = int(b[1]) + b = b[2:] + + case mstr16: + if l < 3 { + err = ErrShortBytes + return + } + read = int(big.Uint16(b[1:])) + b = b[3:] + + case mstr32: + if l < 5 { + err = ErrShortBytes + return + } + read, err = u32int(big.Uint32(b[1:])) + if err != nil { + return + } + b = b[5:] + + default: + // go-codec compat: decode bin types into string + v, o, err = readBytesBytes(b, nil, true, false) + if err != nil { + // If the fallback fails, return original error code + err = TypeError{Method: StrType, Encoded: getType(lead)} + } + return + } + } + + if len(b) < read { + err = ErrShortBytes + return + } + + v = b[0:read] + o = b[read:] + return +} + +// ReadStringBytes reads a 'str' object +// from 'b' and returns its value and the +// remaining bytes in 'b'. +// Possible errors: +// - ErrShortBytes (b not long enough) +// - TypeError{} (not 'str' type) +// - InvalidPrefixError +func ReadStringBytes(b []byte) (string, []byte, error) { + v, o, err := ReadStringZC(b) + return string(v), o, err +} + +// ReadStringAsBytes reads a 'str' object +// into a slice of bytes. 'v' is the value of +// the 'str' object, which may reside in memory +// pointed to by 'scratch.' 'o' is the remaining bytes +// in 'b'. +// Possible errors: +// - ErrShortBytes (b not long enough) +// - TypeError{} (not 'str' type) +// - InvalidPrefixError (unknown type marker) +func ReadStringAsBytes(b []byte, scratch []byte) (v []byte, o []byte, err error) { + var tmp []byte + tmp, o, err = ReadStringZC(b) + v = append(scratch[:0], tmp...) + return +} + +// ReadComplex128Bytes reads a complex128 +// extension object from 'b' and returns the +// remaining bytes. +// Possible errors: +// - ErrShortBytes (not enough bytes in 'b') +// - TypeError{} (object not a complex128) +// - InvalidPrefixError +// - ExtensionTypeError{} (object an extension of the correct size, but not a complex128) +func ReadComplex128Bytes(b []byte) (c complex128, o []byte, err error) { + if len(b) < 18 { + err = ErrShortBytes + return + } + if b[0] != mfixext16 { + err = badPrefix(Complex128Type, b[0]) + return + } + if int8(b[1]) != Complex128Extension { + err = errExt(int8(b[1]), Complex128Extension) + return + } + c = complex(math.Float64frombits(big.Uint64(b[2:])), + math.Float64frombits(big.Uint64(b[10:]))) + o = b[18:] + return +} + +// ReadComplex64Bytes reads a complex64 +// extension object from 'b' and returns the +// remaining bytes. +// Possible errors: +// - ErrShortBytes (not enough bytes in 'b') +// - TypeError{} (object not a complex64) +// - ExtensionTypeError{} (object an extension of the correct size, but not a complex64) +func ReadComplex64Bytes(b []byte) (c complex64, o []byte, err error) { + if len(b) < 10 { + err = ErrShortBytes + return + } + if b[0] != mfixext8 { + err = badPrefix(Complex64Type, b[0]) + return + } + if b[1] != Complex64Extension { + err = errExt(int8(b[1]), Complex64Extension) + return + } + c = complex(math.Float32frombits(big.Uint32(b[2:])), + math.Float32frombits(big.Uint32(b[6:]))) + o = b[10:] + return +} + +// ReadTimeBytes reads a time.Time +// extension object from 'b' and returns the +// remaining bytes. +// Possible errors: +// - ErrShortBytes (not enough bytes in 'b') +// - TypeError{} (object not a complex64) +// - ExtensionTypeError{} (object an extension of the correct size, but not a time.Time) +func ReadTimeBytes(b []byte) (t time.Time, o []byte, err error) { + if len(b) < 1 { + err = ErrShortBytes + return + } + if b[0] == mnil { + o = b[1:] + return + } + if len(b) < 15 { + err = ErrShortBytes + return + } + if b[0] != mext8 || b[1] != 12 { + err = badPrefix(TimeType, b[0]) + return + } + if int8(b[2]) != TimeExtension { + err = errExt(int8(b[2]), TimeExtension) + return + } + sec, nsec := getUnix(b[3:]) + t = time.Unix(sec, int64(nsec)).Local() + o = b[15:] + return +} + +// Skip skips the next object in 'b' and +// returns the remaining bytes. If the object +// is a map or array, all of its elements +// will be skipped. +// Possible Errors: +// - ErrShortBytes (not enough bytes in b) +// - InvalidPrefixError (bad encoding) +func Skip(b []byte) ([]byte, error) { + sz, asz, err := getSize(b) + if err != nil { + return b, err + } + if uintptr(len(b)) < sz { + return b, ErrShortBytes + } + b = b[sz:] + for asz > 0 { + b, err = Skip(b) + if err != nil { + return b, err + } + asz-- + } + return b, nil +} + +// returns (skip N bytes, skip M objects, error) +func getSize(b []byte) (uintptr, uintptr, error) { + l := len(b) + if l == 0 { + return 0, 0, ErrShortBytes + } + lead := b[0] + spec := &sizes[lead] // get type information + size, mode := spec.size, spec.extra + if size == 0 { + return 0, 0, InvalidPrefixError(lead) + } + if mode >= 0 { // fixed composites + return uintptr(size), uintptr(mode), nil + } + if l < int(size) { + return 0, 0, ErrShortBytes + } + switch mode { + case extra8: + return uintptr(size) + uintptr(b[1]), 0, nil + case extra16: + return uintptr(size) + uintptr(big.Uint16(b[1:])), 0, nil + case extra32: + return uintptr(size) + uintptr(big.Uint32(b[1:])), 0, nil + case map16v: + return uintptr(size), 2 * uintptr(big.Uint16(b[1:])), nil + case map32v: + return uintptr(size), 2 * uintptr(big.Uint32(b[1:])), nil + case array16v: + return uintptr(size), uintptr(big.Uint16(b[1:])), nil + case array32v: + return uintptr(size), uintptr(big.Uint32(b[1:])), nil + default: + return 0, 0, fatal + } +} diff --git a/msgp/msgp/read_bytes_test.go b/msgp/msgp/read_bytes_test.go new file mode 100644 index 0000000000..73a4a16b02 --- /dev/null +++ b/msgp/msgp/read_bytes_test.go @@ -0,0 +1,100 @@ +package msgp + +import ( + "testing" + "time" +) + +func BenchmarkReadMapHeaderBytes(b *testing.B) { + sizes := []uint32{1, 100, tuint16, tuint32} + buf := make([]byte, 0, 5*len(sizes)) + for _, sz := range sizes { + buf = AppendMapHeader(buf, sz) + } + b.SetBytes(int64(len(buf) / len(sizes))) + b.ReportAllocs() + b.ResetTimer() + o := buf + for i := 0; i < b.N; i++ { + _, _, buf, _ = ReadMapHeaderBytes(buf) + if len(buf) == 0 { + buf = o + } + } +} + +func BenchmarkReadArrayHeaderBytes(b *testing.B) { + sizes := []uint32{1, 100, tuint16, tuint32} + buf := make([]byte, 0, 5*len(sizes)) + for _, sz := range sizes { + buf = AppendArrayHeader(buf, sz) + } + b.SetBytes(int64(len(buf) / len(sizes))) + b.ReportAllocs() + b.ResetTimer() + o := buf + for i := 0; i < b.N; i++ { + _, _, buf, _ = ReadArrayHeaderBytes(buf) + if len(buf) == 0 { + buf = o + } + } +} + +func BenchmarkReadNilByte(b *testing.B) { + buf := []byte{mnil} + b.SetBytes(1) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + ReadNilBytes(buf) + } +} + +func BenchmarkReadFloat64Bytes(b *testing.B) { + f := float64(3.14159) + buf := make([]byte, 0, 9) + buf = AppendFloat64(buf, f) + b.SetBytes(int64(len(buf))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + ReadFloat64Bytes(buf) + } +} + +func BenchmarkReadFloat32Bytes(b *testing.B) { + f := float32(3.14159) + buf := make([]byte, 0, 5) + buf = AppendFloat32(buf, f) + b.SetBytes(int64(len(buf))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + ReadFloat32Bytes(buf) + } +} + +func BenchmarkReadBoolBytes(b *testing.B) { + buf := []byte{mtrue, mfalse, mtrue, mfalse} + b.SetBytes(1) + b.ReportAllocs() + b.ResetTimer() + o := buf + for i := 0; i < b.N; i++ { + _, buf, _ = ReadBoolBytes(buf) + if len(buf) == 0 { + buf = o + } + } +} + +func BenchmarkReadTimeBytes(b *testing.B) { + data := AppendTime(nil, time.Now()) + b.SetBytes(15) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + ReadTimeBytes(data) + } +} diff --git a/msgp/msgp/size.go b/msgp/msgp/size.go new file mode 100644 index 0000000000..e3a613b248 --- /dev/null +++ b/msgp/msgp/size.go @@ -0,0 +1,39 @@ +package msgp + +// The sizes provided +// are the worst-case +// encoded sizes for +// each type. For variable- +// length types ([]byte, string), +// the total encoded size is +// the prefix size plus the +// length of the object. +const ( + Int64Size = 9 + IntSize = Int64Size + UintSize = Int64Size + Int8Size = 2 + Int16Size = 3 + Int32Size = 5 + Uint8Size = 2 + ByteSize = Uint8Size + Uint16Size = 3 + Uint32Size = 5 + Uint64Size = Int64Size + Float64Size = 9 + Float32Size = 5 + Complex64Size = 10 + Complex128Size = 18 + + DurationSize = Int64Size + TimeSize = 15 + BoolSize = 1 + NilSize = 1 + + MapHeaderSize = 5 + ArrayHeaderSize = 5 + + BytesPrefixSize = 5 + StringPrefixSize = 5 + ExtensionPrefixSize = 6 +) diff --git a/msgp/msgp/write.go b/msgp/msgp/write.go new file mode 100644 index 0000000000..da23cf7010 --- /dev/null +++ b/msgp/msgp/write.go @@ -0,0 +1,65 @@ +package msgp + +// Sizer is an interface implemented +// by types that can estimate their +// size when MessagePack encoded. +// This interface is optional, but +// encoding/marshaling implementations +// may use this as a way to pre-allocate +// memory for serialization. +type Sizer interface { + Msgsize() int +} + +// MaxSizer is an interface implemented +// by types that can determine their max +// when implemented. +// This interface is optional, but +// implementations may use this as a way to limit +// number of bytes read during deserialization +type MaxSizer interface { + MaxSize() int +} + +// Require ensures that cap(old)-len(old) >= extra. +// It might be that this is impossible because len(old)+extra +// overflows int. If so, Require will not grow the slice, +// but at this point, we have run out of memory, and panic +// (from subsequent out-of-bounds access) is as good of an +// outcome as any. +func Require(old []byte, extra int) []byte { + l := len(old) + c := cap(old) + r := l + extra + if c >= r { + return old + } else if l == 0 { + return make([]byte, 0, extra) + } + // the new size is the greater + // of double the old capacity + // and the sum of the old length + // and the number of new bytes + // necessary. + c <<= 1 + if c < r { + c = r + } + n := make([]byte, l, c) + copy(n, old) + return n +} + +// Marshaler is the interface implemented +// by types that know how to marshal themselves +// as MessagePack. MarshalMsg appends the marshalled +// form of the object to the provided +// byte slice, returning the extended slice. +// CanMarshalMsg checks that o is of the same type as +// was used to generate the MarshalMsg code; it can be +// used to guard against MarshalMsg() going to an embedded +// field in a struct rather than marshaling the entire struct. +type Marshaler interface { + MarshalMsg([]byte) []byte + CanMarshalMsg(o interface{}) bool +} diff --git a/msgp/msgp/write_bytes.go b/msgp/msgp/write_bytes.go new file mode 100644 index 0000000000..b96715ccf3 --- /dev/null +++ b/msgp/msgp/write_bytes.go @@ -0,0 +1,288 @@ +package msgp + +import ( + "math" + "time" +) + +// ensure 'sz' extra bytes in 'b' btw len(b) and cap(b) +// If the growth length overflows, we are anyway running +// out of memory, so panic (on a subsequent out-of-bounds +// slice reference) seems like as good of a result as any. +func ensure(b []byte, sz int) ([]byte, int) { + l := len(b) + c := cap(b) + if c-l < sz { + o := make([]byte, (2*c)+sz) // exponential growth + n := copy(o, b) + return o[:n+sz], n + } + return b[:l+sz], l +} + +// AppendMapHeader appends a map header with the +// given size to the slice +func AppendMapHeader(b []byte, sz uint32) []byte { + switch { + case sz <= 15: + return append(b, wfixmap(uint8(sz))) + + case sz <= math.MaxUint16: + o, n := ensure(b, 3) + prefixu16(o[n:], mmap16, uint16(sz)) + return o + + default: + o, n := ensure(b, 5) + prefixu32(o[n:], mmap32, sz) + return o + } +} + +// AppendArrayHeader appends an array header with +// the given size to the slice +func AppendArrayHeader(b []byte, sz uint32) []byte { + switch { + case sz <= 15: + return append(b, wfixarray(uint8(sz))) + + case sz <= math.MaxUint16: + o, n := ensure(b, 3) + prefixu16(o[n:], marray16, uint16(sz)) + return o + + default: + o, n := ensure(b, 5) + prefixu32(o[n:], marray32, sz) + return o + } +} + +// AppendNil appends a 'nil' byte to the slice +func AppendNil(b []byte) []byte { return append(b, mnil) } + +// AppendFloat64 appends a float64 to the slice +func AppendFloat64(b []byte, f float64) []byte { + o, n := ensure(b, Float64Size) + prefixu64(o[n:], mfloat64, math.Float64bits(f)) + return o +} + +// AppendFloat32 appends a float32 to the slice +func AppendFloat32(b []byte, f float32) []byte { + o, n := ensure(b, Float32Size) + prefixu32(o[n:], mfloat32, math.Float32bits(f)) + return o +} + +// AppendDuration appends a time.Duration to the slice +func AppendDuration(b []byte, d time.Duration) []byte { + return AppendInt64(b, int64(d)) +} + +// AppendInt64 appends an int64 to the slice +func AppendInt64(b []byte, i int64) []byte { + if i >= 0 { + return AppendUint64(b, uint64(i)) + } + switch { + case i >= -32: + return append(b, wnfixint(int8(i))) + case i >= math.MinInt8: + o, n := ensure(b, 2) + putMint8(o[n:], int8(i)) + return o + case i >= math.MinInt16: + o, n := ensure(b, 3) + putMint16(o[n:], int16(i)) + return o + case i >= math.MinInt32: + o, n := ensure(b, 5) + putMint32(o[n:], int32(i)) + return o + default: + o, n := ensure(b, 9) + putMint64(o[n:], i) + return o + } +} + +// AppendInt8 appends an int8 to the slice +func AppendInt8(b []byte, i int8) []byte { return AppendInt64(b, int64(i)) } + +// AppendInt16 appends an int16 to the slice +func AppendInt16(b []byte, i int16) []byte { return AppendInt64(b, int64(i)) } + +// AppendInt32 appends an int32 to the slice +func AppendInt32(b []byte, i int32) []byte { return AppendInt64(b, int64(i)) } + +// AppendUint64 appends a uint64 to the slice +func AppendUint64(b []byte, u uint64) []byte { + switch { + case u <= (1<<7)-1: + return append(b, wfixint(uint8(u))) + + case u <= math.MaxUint8: + o, n := ensure(b, 2) + putMuint8(o[n:], uint8(u)) + return o + + case u <= math.MaxUint16: + o, n := ensure(b, 3) + putMuint16(o[n:], uint16(u)) + return o + + case u <= math.MaxUint32: + o, n := ensure(b, 5) + putMuint32(o[n:], uint32(u)) + return o + + default: + o, n := ensure(b, 9) + putMuint64(o[n:], u) + return o + + } +} + +// AppendUint8 appends a uint8 to the slice +func AppendUint8(b []byte, u uint8) []byte { return AppendUint64(b, uint64(u)) } + +// AppendByte is analogous to AppendUint8 +func AppendByte(b []byte, u byte) []byte { return AppendUint8(b, uint8(u)) } + +// AppendUint16 appends a uint16 to the slice +func AppendUint16(b []byte, u uint16) []byte { return AppendUint64(b, uint64(u)) } + +// AppendUint32 appends a uint32 to the slice +func AppendUint32(b []byte, u uint32) []byte { return AppendUint64(b, uint64(u)) } + +// AppendBytes appends bytes to the slice as MessagePack 'bin' data +func AppendBytes(b []byte, bts []byte) []byte { + sz := len(bts) + var o []byte + var n int + switch { + case bts == nil: + o, n = ensure(b, 1) + o[n] = mnil + n += 1 + case sz <= math.MaxUint8: + o, n = ensure(b, 2+sz) + prefixu8(o[n:], mbin8, uint8(sz)) + n += 2 + case sz <= math.MaxUint16: + o, n = ensure(b, 3+sz) + prefixu16(o[n:], mbin16, uint16(sz)) + n += 3 + default: + o, n = ensure(b, 5+sz) + prefixu32(o[n:], mbin32, uint32(sz)) + n += 5 + } + return o[:n+copy(o[n:], bts)] +} + +// AppendBool appends a bool to the slice +func AppendBool(b []byte, t bool) []byte { + if t { + return append(b, mtrue) + } + return append(b, mfalse) +} + +// AppendString appends a string as a MessagePack 'str' to the slice +func AppendString(b []byte, s string) []byte { + sz := len(s) + var n int + var o []byte + switch { + case sz <= 31: + o, n = ensure(b, 1+sz) + o[n] = wfixstr(uint8(sz)) + n++ + case sz <= math.MaxUint8: + o, n = ensure(b, 2+sz) + prefixu8(o[n:], mstr8, uint8(sz)) + n += 2 + case sz <= math.MaxUint16: + o, n = ensure(b, 3+sz) + prefixu16(o[n:], mstr16, uint16(sz)) + n += 3 + default: + o, n = ensure(b, 5+sz) + prefixu32(o[n:], mstr32, uint32(sz)) + n += 5 + } + return o[:n+copy(o[n:], s)] +} + +// AppendStringFromBytes appends a []byte +// as a MessagePack 'str' to the slice 'b.' +func AppendStringFromBytes(b []byte, str []byte) []byte { + sz := len(str) + var n int + var o []byte + switch { + case sz <= 31: + o, n = ensure(b, 1+sz) + o[n] = wfixstr(uint8(sz)) + n++ + case sz <= math.MaxUint8: + o, n = ensure(b, 2+sz) + prefixu8(o[n:], mstr8, uint8(sz)) + n += 2 + case sz <= math.MaxUint16: + o, n = ensure(b, 3+sz) + prefixu16(o[n:], mstr16, uint16(sz)) + n += 3 + default: + o, n = ensure(b, 5+sz) + prefixu32(o[n:], mstr32, uint32(sz)) + n += 5 + } + return o[:n+copy(o[n:], str)] +} + +// AppendComplex64 appends a complex64 to the slice as a MessagePack extension +func AppendComplex64(b []byte, c complex64) []byte { + o, n := ensure(b, Complex64Size) + o[n] = mfixext8 + o[n+1] = Complex64Extension + big.PutUint32(o[n+2:], math.Float32bits(real(c))) + big.PutUint32(o[n+6:], math.Float32bits(imag(c))) + return o +} + +// AppendComplex128 appends a complex128 to the slice as a MessagePack extension +func AppendComplex128(b []byte, c complex128) []byte { + o, n := ensure(b, Complex128Size) + o[n] = mfixext16 + o[n+1] = Complex128Extension + big.PutUint64(o[n+2:], math.Float64bits(real(c))) + big.PutUint64(o[n+10:], math.Float64bits(imag(c))) + return o +} + +// AppendTime appends a time.Time to the slice as a MessagePack extension +func AppendTime(b []byte, t time.Time) []byte { + o, n := ensure(b, TimeSize) + t = t.UTC() + o[n] = mext8 + o[n+1] = 12 + o[n+2] = TimeExtension + putUnix(o[n+3:], t.Unix(), int32(t.Nanosecond())) + return o +} + +// AppendMapStrStr appends a map[string]string to the slice +// as a MessagePack map with 'str'-type keys and values +func AppendMapStrStr(b []byte, m map[string]string) []byte { + sz := uint32(len(m)) + b = AppendMapHeader(b, sz) + for key, val := range m { + b = AppendString(b, key) + b = AppendString(b, val) + } + return b +} diff --git a/msgp/msgp/write_bytes_test.go b/msgp/msgp/write_bytes_test.go new file mode 100644 index 0000000000..d7e88738cf --- /dev/null +++ b/msgp/msgp/write_bytes_test.go @@ -0,0 +1,140 @@ +package msgp + +import ( + "testing" + "time" +) + +func BenchmarkAppendMapHeader(b *testing.B) { + buf := make([]byte, 0, 9) + N := b.N / 4 + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < N; i++ { + AppendMapHeader(buf[:0], 0) + AppendMapHeader(buf[:0], uint32(tint8)) + AppendMapHeader(buf[:0], tuint16) + AppendMapHeader(buf[:0], tuint32) + } +} + +func BenchmarkAppendArrayHeader(b *testing.B) { + buf := make([]byte, 0, 9) + N := b.N / 4 + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < N; i++ { + AppendArrayHeader(buf[:0], 0) + AppendArrayHeader(buf[:0], uint32(tint8)) + AppendArrayHeader(buf[:0], tuint16) + AppendArrayHeader(buf[:0], tuint32) + } +} + +func TestAppendNil(t *testing.T) { + var bts []byte + bts = AppendNil(bts[0:0]) + if bts[0] != mnil { + t.Fatal("bts[0] is not 'nil'") + } +} + +func BenchmarkAppendFloat64(b *testing.B) { + f := float64(3.14159) + buf := make([]byte, 0, 9) + b.SetBytes(9) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendFloat64(buf[0:0], f) + } +} + +func BenchmarkAppendFloat32(b *testing.B) { + f := float32(3.14159) + buf := make([]byte, 0, 5) + b.SetBytes(5) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendFloat32(buf[0:0], f) + } +} + +func BenchmarkAppendInt64(b *testing.B) { + is := []int64{0, 1, -5, -50, int64(tint16), int64(tint32), int64(tint64)} + l := len(is) + buf := make([]byte, 0, 9) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendInt64(buf[0:0], is[i%l]) + } +} + +func BenchmarkAppendUint64(b *testing.B) { + us := []uint64{0, 1, 15, uint64(tuint16), uint64(tuint32), tuint64} + buf := make([]byte, 0, 9) + b.ReportAllocs() + b.ResetTimer() + l := len(us) + for i := 0; i < b.N; i++ { + AppendUint64(buf[0:0], us[i%l]) + } +} + +func benchappendBytes(size uint32, b *testing.B) { + bts := RandBytes(int(size)) + buf := make([]byte, 0, len(bts)+5) + b.SetBytes(int64(len(bts) + 5)) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendBytes(buf[0:0], bts) + } +} + +func BenchmarkAppend16Bytes(b *testing.B) { benchappendBytes(16, b) } + +func BenchmarkAppend256Bytes(b *testing.B) { benchappendBytes(256, b) } + +func BenchmarkAppend2048Bytes(b *testing.B) { benchappendBytes(2048, b) } + +func benchappendString(size uint32, b *testing.B) { + str := string(RandBytes(int(size))) + buf := make([]byte, 0, len(str)+5) + b.SetBytes(int64(len(str) + 5)) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendString(buf[0:0], str) + } +} + +func BenchmarkAppend16String(b *testing.B) { benchappendString(16, b) } + +func BenchmarkAppend256String(b *testing.B) { benchappendString(256, b) } + +func BenchmarkAppend2048String(b *testing.B) { benchappendString(2048, b) } + +func BenchmarkAppendBool(b *testing.B) { + vs := []bool{true, false} + buf := make([]byte, 0, 1) + b.SetBytes(1) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendBool(buf[0:0], vs[i%2]) + } +} + +func BenchmarkAppendTime(b *testing.B) { + t := time.Now() + b.SetBytes(15) + buf := make([]byte, 0, 15) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + AppendTime(buf[0:0], t) + } +} diff --git a/msgp/msgp/write_test.go b/msgp/msgp/write_test.go new file mode 100644 index 0000000000..25b65a091e --- /dev/null +++ b/msgp/msgp/write_test.go @@ -0,0 +1,24 @@ +package msgp + +import ( + "math" + "math/rand" +) + +var ( + tint8 int8 = 126 // cannot be most fix* types + tint16 int16 = 150 // cannot be int8 + tint32 int32 = math.MaxInt16 + 100 // cannot be int16 + tint64 int64 = math.MaxInt32 + 100 // cannot be int32 + tuint16 uint32 = 300 // cannot be uint8 + tuint32 uint32 = math.MaxUint16 + 100 // cannot be uint16 + tuint64 uint64 = math.MaxUint32 + 100 // cannot be uint32 +) + +func RandBytes(sz int) []byte { + out := make([]byte, sz) + for i := range out { + out[i] = byte(rand.Int63n(math.MaxInt64) % 256) + } + return out +} diff --git a/msgp/parse/directives.go b/msgp/parse/directives.go new file mode 100644 index 0000000000..75d00111f8 --- /dev/null +++ b/msgp/parse/directives.go @@ -0,0 +1,194 @@ +package parse + +import ( + "errors" + "fmt" + "go/ast" + "strings" + + "github.com/algorand/msgp/gen" +) + +const linePrefix = "//msgp:" + +// func(args, fileset) +type directive func([]string, *FileSet) error + +// func(passName, args, printer) +type passDirective func(gen.Method, []string, *gen.Printer) error + +// map of all recognized directives +// +// to add a directive, define a func([]string, *FileSet) error +// and then add it to this list. +var directives = map[string]directive{ + "shim": applyShim, + "ignore": ignore, + "tuple": astuple, + "sort": sortintf, + "allocbound": allocbound, + // _postunmarshalcheck is used to add callbacks to the end of un-marshalling that are tied to a specific Element. + _postunmarshalcheck: postunmarshalcheck, +} + +const _postunmarshalcheck = "postunmarshalcheck" + +var errNotEnoughArguments = errors.New("postunmarshalcheck did not receive enough arguments. expected at least 3") + +//msgp:postunmarshalcheck {Type} {funcName} {funcName} ... +// the functions should have no params, and output zero. +func postunmarshalcheck(text []string, f *FileSet) error { + if len(text) < 3 { + return errNotEnoughArguments + } + // not error but doesn't do anything + if text[0] != _postunmarshalcheck { + return nil + } + text = text[1:] + + elemType := text[0] + elem, ok := f.Identities[elemType] + if !ok { + return errors.New(fmt.Sprintf("postunmarshalcheck error: type %v does not exist", elemType)) + } + for _, fName := range text[1:] { + elem.AddCallback(gen.Callback{ + Fname: fName, + CallbackType: gen.UnmarshalCallBack, + }) + } + return nil +} + +var passDirectives = map[string]passDirective{ + "ignore": passignore, +} + +func passignore(m gen.Method, text []string, p *gen.Printer) error { + pushstate(m.String()) + for _, a := range text { + p.ApplyDirective(m, gen.IgnoreTypename(a)) + infof("ignoring %s\n", a) + } + popstate() + return nil +} + +// find all comment lines that begin with //msgp: +func yieldComments(c []*ast.CommentGroup) []string { + var out []string + for _, cg := range c { + for _, line := range cg.List { + if strings.HasPrefix(line.Text, linePrefix) { + out = append(out, strings.TrimPrefix(line.Text, linePrefix)) + } + } + } + return out +} + +//msgp:shim {Type} as:{Newtype} using:{toFunc/fromFunc} mode:{Mode} +func applyShim(text []string, f *FileSet) error { + if len(text) < 4 || len(text) > 5 { + return fmt.Errorf("shim directive should have 3 or 4 arguments; found %d", len(text)-1) + } + + name := text[1] + be := gen.Ident("", strings.TrimPrefix(strings.TrimSpace(text[2]), "as:")) // parse as::{base} + if name[0] == '*' { + name = name[1:] + be.Needsref(true) + } + be.Alias(name) + + usestr := strings.TrimPrefix(strings.TrimSpace(text[3]), "using:") // parse using::{method/method} + + methods := strings.Split(usestr, "/") + if len(methods) != 2 { + return fmt.Errorf("expected 2 using::{} methods; found %d (%q)", len(methods), text[3]) + } + + be.ShimToBase = methods[0] + be.ShimFromBase = methods[1] + + if len(text) == 5 { + modestr := strings.TrimPrefix(strings.TrimSpace(text[4]), "mode:") // parse mode::{mode} + switch modestr { + case "cast": + be.ShimMode = gen.Cast + case "convert": + be.ShimMode = gen.Convert + default: + return fmt.Errorf("invalid shim mode; found %s, expected 'cast' or 'convert", modestr) + } + } + + infof("%s -> %s\n", name, be.Value.String()) + f.findShim(name, be) + + return nil +} + +//msgp:ignore {TypeA} {TypeB}... +func ignore(text []string, f *FileSet) error { + if len(text) < 2 { + return nil + } + for _, item := range text[1:] { + name := strings.TrimSpace(item) + if _, ok := f.Identities[name]; ok { + delete(f.Identities, name) + infof("ignoring %s\n", name) + } + } + return nil +} + +//msgp:tuple {TypeA} {TypeB}... +func astuple(text []string, f *FileSet) error { + if len(text) < 2 { + return nil + } + for _, item := range text[1:] { + name := strings.TrimSpace(item) + if el, ok := f.Identities[name]; ok { + if st, ok := el.(*gen.Struct); ok { + st.AsTuple = true + infoln(name) + } else { + warnf("%s: only structs can be tuples\n", name) + } + } + } + return nil +} + +//msgp:sort {Type} {SortInterface} +func sortintf(text []string, f *FileSet) error { + if len(text) != 3 { + return nil + } + sortType := strings.TrimSpace(text[1]) + sortIntf := strings.TrimSpace(text[2]) + gen.SetSortInterface(sortType, sortIntf) + infof("sorting %s using %s\n", sortType, sortIntf) + return nil +} + +//msgp:allocbound {Type} {Bound} +func allocbound(text []string, f *FileSet) error { + if len(text) != 3 { + return nil + } + allocBoundType := strings.TrimSpace(text[1]) + allocBound := strings.TrimSpace(text[2]) + t, ok := f.Identities[allocBoundType] + if !ok { + warnf("allocbound: cannot find type %s\n", allocBoundType) + } else { + t.SetAllocBound(allocBound) + infof("allocbound(%s): setting to %s\n", allocBoundType, allocBound) + } + return nil +} diff --git a/msgp/parse/directives_test.go b/msgp/parse/directives_test.go new file mode 100644 index 0000000000..e237290f1b --- /dev/null +++ b/msgp/parse/directives_test.go @@ -0,0 +1,53 @@ +package parse + +import ( + "testing" + + "github.com/algorand/msgp/gen" +) + +const ( + testStructName = "TestStruct" + testFuncName = "callback" +) + +func TestPostunmarshalcheck(t *testing.T) { + st := gen.Struct{ + Fields: nil, + AsTuple: false, + } + + fl := FileSet{ + Identities: map[string]gen.Elem{testStructName: &st}, + Directives: []string{"postunmarshalcheck"}, // raw preprocessor directives + } + if err := postunmarshalcheck([]string{"postunmarshalcheck", testStructName, testFuncName}, &fl); err != nil { + t.Fatal() + } + if testFuncName != st.GetCallbacks()[0].GetName() { + t.Fatal() + } + if !st.GetCallbacks()[0].IsUnmarshallCallback() { + t.Fatal() + } +} + +func TestPostunmarshalcheckFailures(t *testing.T) { + + st := gen.Struct{ + Fields: nil, + AsTuple: false, + } + + fl := FileSet{ + Identities: map[string]gen.Elem{testStructName: &st}, + Directives: []string{"postunmarshalcheck"}, // raw preprocessor directives + } + if err := postunmarshalcheck([]string{"postunmarshalcheck", testFuncName}, &fl); err == nil { + t.Fatal() + } + + if err := postunmarshalcheck([]string{"postunmarshalcheck", "non-existing-type", testFuncName}, &fl); err == nil { + t.Fatal() + } +} diff --git a/msgp/parse/getast.go b/msgp/parse/getast.go new file mode 100644 index 0000000000..d0ff38091f --- /dev/null +++ b/msgp/parse/getast.go @@ -0,0 +1,818 @@ +package parse + +import ( + "fmt" + "go/ast" + "reflect" + "sort" + "strings" + + "github.com/algorand/msgp/gen" + "github.com/ttacon/chalk" + "golang.org/x/tools/go/packages" +) + +// A FileSet is the in-memory representation of a +// parsed file. +type FileSet struct { + Package string // package name + PkgPath string // package path + Specs map[string]ast.Expr // type specs in file + Aliases map[string]ast.Expr // type aliases in file + Interfaces map[string]ast.Expr // type interfaces in file + Consts map[string]ast.Expr // consts + Identities map[string]gen.Elem // processed from specs + Directives []string // raw preprocessor directives + Imports []*ast.ImportSpec // imports + ImportSet ImportSet + ImportName map[string]string +} + +// An ImportSet describes the FileSets for a group of imported packages +type ImportSet map[string]*FileSet + +// File parses a file at the relative path +// provided and produces a new *FileSet. +// If you pass in a path to a directory, the entire +// directory will be parsed. +// If unexport is false, only exported identifiers are included in the FileSet. +// If the resulting FileSet would be empty, an error is returned. +func File(name string, unexported bool, warnPkgMask string) (*FileSet, error) { + pushstate(name) + defer popstate() + + cfg := &packages.Config{ + Mode: packages.NeedName | packages.NeedImports | packages.NeedDeps | packages.NeedSyntax | packages.NeedFiles | packages.NeedExportsFile | packages.NeedTypesInfo, + } + + pkgs, err := packages.Load(cfg, name) + if err != nil { + return nil, err + } + + if len(pkgs) != 1 { + return nil, fmt.Errorf("multiple packages in directory: %s", name) + } + + var one *packages.Package + for _, nm := range pkgs { + one = nm + break + } + + imps := make(map[string]*FileSet) + + fs := packageToFileSet(one, imps, unexported) + for _, ifs := range imps { + ifs.process(warnPkgMask) + ifs.applyDirectives() + ifs.propInline() + } + fs.process(warnPkgMask) + fs.applyDirectives() + fs.propInline() + return fs, nil +} + +func packageToFileSet(p *packages.Package, imps map[string]*FileSet, unexported bool) *FileSet { + fs := &FileSet{ + Package: p.Name, + PkgPath: p.PkgPath, + Specs: make(map[string]ast.Expr), + Aliases: make(map[string]ast.Expr), + Interfaces: make(map[string]ast.Expr), + Consts: make(map[string]ast.Expr), + Identities: make(map[string]gen.Elem), + ImportSet: imps, + ImportName: make(map[string]string), + } + + for name, importpkg := range p.Imports { + _, ok := imps[name] + if ok { + continue + } + + imps[name] = packageToFileSet(importpkg, imps, unexported) + } + + for _, fl := range p.Syntax { + pushstate(fl.Name.Name) + fs.Directives = append(fs.Directives, yieldComments(fl.Comments)...) + if !unexported { + ast.FileExports(fl) + } + + for _, importspec := range fl.Imports { + pkgpath := importspec.Path.Value[1 : len(importspec.Path.Value)-1] + if pkgpath == "C" { + continue + } + + var importname string + if importspec.Name != nil { + importname = importspec.Name.Name + } else { + p, ok := imps[pkgpath] + if !ok { + fmt.Printf("missing import %s\n", pkgpath) + } else { + importname = p.Package + } + } + fs.ImportName[importname] = pkgpath + } + + fs.getTypeSpecs(fl) + popstate() + } + + return fs +} + +// applyDirectives applies all of the directives that +// are known to the parser. additional method-specific +// directives remain in f.Directives +func (f *FileSet) applyDirectives() { + newdirs := make([]string, 0, len(f.Directives)) + for _, d := range f.Directives { + chunks := strings.Split(d, " ") + if len(chunks) > 0 { + if fn, ok := directives[chunks[0]]; ok { + pushstate(chunks[0]) + err := fn(chunks, f) + if err != nil { + warnln(err.Error()) + } + popstate() + } else { + newdirs = append(newdirs, d) + } + } + } + f.Directives = newdirs +} + +// A linkset is a graph of unresolved +// identities. +// +// Since gen.Ident can only represent +// one level of type indirection (e.g. Foo -> uint8), +// type declarations like `type Foo Bar` +// aren't resolve-able until we've processed +// everything else. +// +// The goal of this dependency resolution +// is to distill the type declaration +// into just one level of indirection. +// In other words, if we have: +// +// type A uint64 +// type B A +// type C B +// type D C +// +// ... then we want to end up +// figuring out that D is just a uint64. +type linkset map[string]*gen.BaseElem + +func (f *FileSet) resolve(ls linkset) { + progress := true + for progress && len(ls) > 0 { + progress = false + for name, elem := range ls { + real, ok := f.Identities[elem.TypeName()] + if ok { + // copy the old type descriptor, + // alias it to the new value, + // and insert it into the resolved + // identities list + progress = true + nt := real.Copy() + nt.Alias(name) + f.Identities[name] = nt + delete(ls, name) + } + } + } + + // what's left can't be resolved + for name, elem := range ls { + // warnf("couldn't resolve type %s (%s)\n", name, elem.TypeName()) + nt := elem.Copy() + nt.Alias(name) + f.Identities[name] = nt + } +} + +// process takes the contents of f.Specs and +// uses them to populate f.Identities +func (f *FileSet) process(warnPkgMask string) { + if warnPkgMask != "" && !strings.HasPrefix(f.PkgPath, warnPkgMask) { + increasePrintLevel() + defer decreasePrintLevel() + } + deferred := make(linkset) +parse: + for name, def := range f.Specs { + pushstate(name) + + el := f.parseExpr("", def) + + if el == nil { + warnln("failed to parse") + popstate() + continue parse + } + // push unresolved identities into + // the graph of links and resolve after + // we've handled every possible named type. + if be, ok := el.(*gen.BaseElem); ok && be.Value == gen.IDENT { + deferred[name] = be + popstate() + continue parse + } + el.Alias(name) + f.Identities[name] = el + popstate() + } + + if len(deferred) > 0 { + f.resolve(deferred) + } +} + +func strToMethod(s string) gen.Method { + switch s { + case "test": + return gen.Test + case "size": + return gen.Size + case "marshal": + return gen.Marshal + case "unmarshal": + return gen.Unmarshal + case "maxsize": + return gen.MaxSize + default: + return 0 + } +} + +func (f *FileSet) applyDirs(p *gen.Printer) { + // apply directives of the form + // + // //msgp:encode ignore {{TypeName}} + // +loop: + for _, d := range f.Directives { + chunks := strings.Split(d, " ") + if len(chunks) > 1 { + for i := range chunks { + chunks[i] = strings.TrimSpace(chunks[i]) + } + m := strToMethod(chunks[0]) + if m == 0 { + warnf("unknown pass name: %q\n", chunks[0]) + continue loop + } + if fn, ok := passDirectives[chunks[1]]; ok { + pushstate(chunks[1]) + err := fn(m, chunks[2:], p) + if err != nil { + warnf("error applying directive: %s\n", err) + } + popstate() + } else { + warnf("unrecognized directive %q\n", chunks[1]) + } + } else { + warnf("empty directive: %q\n", d) + } + } +} + +func (f *FileSet) PrintTo(p *gen.Printer) error { + var msgs []string + + f.applyDirs(p) + names := make([]string, 0, len(f.Identities)) + for name := range f.Identities { + names = append(names, name) + } + sort.Strings(names) + for _, name := range names { + el := f.Identities[name] + el.SetVarname("z") + pushstate(el.TypeName()) + m, err := p.Print(el) + popstate() + if err != nil { + return err + } + msgs = append(msgs, m...) + } + for _, msg := range msgs { + warnln(msg) + } + if len(msgs) > 0 { + return fmt.Errorf("Errors encountered, exiting") + } + return nil +} + +// getTypeSpecs extracts all of the *ast.TypeSpecs in the file +// into fs.Identities, but does not set the actual element +func (fs *FileSet) getTypeSpecs(f *ast.File) { + + // collect all imports... + fs.Imports = append(fs.Imports, f.Imports...) + + // check all declarations... + for i := range f.Decls { + + // for GenDecls... + if g, ok := f.Decls[i].(*ast.GenDecl); ok { + + // and check the specs... + for _, s := range g.Specs { + + // for ast.TypeSpecs.... + switch s := s.(type) { + case *ast.TypeSpec: + switch s.Type.(type) { + + // this is the list of parse-able + // type specs + case *ast.StructType, + *ast.ArrayType, + *ast.StarExpr, + *ast.SelectorExpr, + *ast.MapType, + *ast.Ident: + + if strings.HasPrefix(s.Name.Name, "_Ctype_") || s.Name.Name == "_" { + continue + } + + if s.Assign == 0 { + fs.Specs[s.Name.Name] = s.Type + } else { + fs.Aliases[s.Name.Name] = s.Type + } + case *ast.InterfaceType: + fs.Interfaces[s.Name.Name] = s.Type + } + + case *ast.ValueSpec: + if len(s.Names) == 1 && len(s.Values) == 1 { + fs.Consts[s.Names[0].Name] = s.Values[0] + } + } + } + } + } +} + +func fieldName(f *ast.Field) string { + switch len(f.Names) { + case 0: + return stringify(f.Type) + case 1: + return f.Names[0].Name + default: + return f.Names[0].Name + " (and others)" + } +} + +func (fs *FileSet) parseFieldList(importPrefix string, fl *ast.FieldList) []gen.StructField { + if fl == nil || fl.NumFields() == 0 { + return nil + } + out := make([]gen.StructField, 0, fl.NumFields()) + for _, field := range fl.List { + pushstate(fieldName(field)) + fds := fs.getField(importPrefix, field) + if len(fds) > 0 { + out = append(out, fds...) + } else { + warnln("ignored.") + } + popstate() + } + return out +} + +// translate *ast.Field into []gen.StructField +func (fs *FileSet) getField(importPrefix string, f *ast.Field) []gen.StructField { + sf := make([]gen.StructField, 1) + var extension, flatten bool + var allocbound string + var allocbounds []string + var maxtotalbytes string + + // always flatten embedded structs + flatten = true + + // parse tag; otherwise field name is field tag + if f.Tag != nil { + var body string + body, sf[0].HasCodecTag = reflect.StructTag(strings.Trim(f.Tag.Value, "`")).Lookup("codec") + tags := strings.Split(body, ",") + for _, tag := range tags[1:] { + if tag == "extension" { + extension = true + } + if strings.HasPrefix(tag, "allocbound=") { + allocbounds = append(allocbounds, strings.Split(tag, "=")[1]) + } + if strings.HasPrefix(tag, "maxtotalbytes=") { + maxtotalbytes = strings.Split(tag, "=")[1] + } + } + // ignore "-" fields + if tags[0] == "-" { + return nil + } + sf[0].FieldTag = tags[0] + sf[0].FieldTagParts = tags + sf[0].RawTag = f.Tag.Value + } + allocbound = strings.Join(allocbounds, ",") + ex := fs.parseExpr(importPrefix, f.Type) + if ex == nil { + return nil + } + + // parse field name + switch len(f.Names) { + case 0: + if flatten { + maybe := fs.getFieldsFromEmbeddedStruct(importPrefix, f.Type) + if maybe != nil { + // Prefix all field names with the explicit + // embedded struct selector, to avoid ambiguity. + for i := range maybe { + maybe[i].FieldPath = append([]string{embedded(f.Type)}, maybe[i].FieldPath...) + } + + return maybe + } + } + + // If not flattening, or the embedded type wasn't a struct, + // embed it under the type name. + sf[0].FieldName = embedded(f.Type) + case 1: + sf[0].FieldName = f.Names[0].Name + default: + // this is for a multiple in-line declaration, + // e.g. type A struct { One, Two int } + sf = sf[0:0] + for _, nm := range f.Names { + sf = append(sf, gen.StructField{ + FieldTag: nm.Name, + FieldName: nm.Name, + FieldElem: ex.Copy(), + }) + } + return sf + } + + // resolve local package type aliases that referenced in this package structs + resolveAlias := func(el gen.Elem) { + if a, ok := fs.Aliases[el.TypeName()]; ok { + if b, ok := a.(*ast.SelectorExpr); ok { + if c, ok := b.X.(*ast.Ident); ok { + el.Alias(c.Name + "." + b.Sel.Name) + } + } else if b, ok := a.(*ast.Ident); ok { + el.Alias(b.Name) + } + } + } + // resolve field alias type + resolveAlias(ex) + // resolve field map type that have alias type key or value + if m, ok := ex.(*gen.Map); ok { + resolveAlias(m.Key) + resolveAlias(m.Value) + } + // resolve field slice type that have alias type element + if m, ok := ex.(*gen.Slice); ok { + resolveAlias(m.Els) + } + + sf[0].FieldElem = ex + if sf[0].FieldTag == "" { + sf[0].FieldTag = sf[0].FieldName + } + if sf[0].FieldTagParts == nil { + sf[0].FieldTagParts = []string{sf[0].FieldName} + } + sf[0].FieldElem.SetAllocBound(allocbound) + sf[0].FieldElem.SetMaxTotalBytes(maxtotalbytes) + + // validate extension + if extension { + switch ex := ex.(type) { + case *gen.Ptr: + if b, ok := ex.Value.(*gen.BaseElem); ok { + b.Value = gen.Ext + } else { + warnln("couldn't cast to extension.") + return nil + } + case *gen.BaseElem: + ex.Value = gen.Ext + default: + warnln("couldn't cast to extension.") + return nil + } + } + return sf +} + +func (fs *FileSet) getFieldsFromEmbeddedStruct(importPrefix string, f ast.Expr) []gen.StructField { + switch f := f.(type) { + case *ast.Ident: + s, ok := fs.Specs[f.Name] + if !ok { + s = fs.Aliases[f.Name] + } + + switch s := s.(type) { + case *ast.StructType: + return fs.parseFieldList(importPrefix, s.Fields) + default: + return nil + } + case *ast.SelectorExpr: + pkg := f.X + pkgid, ok := pkg.(*ast.Ident) + if !ok { + return nil + } + + pkgname, ok := fs.ImportName[pkgid.Name] + if !ok { + return nil + } + + pkgfs, ok := fs.ImportSet[pkgname] + if !ok { + return nil + } + + return pkgfs.getFieldsFromEmbeddedStruct(pkgid.Name+".", f.Sel) + default: + // other possibilities are disallowed + return nil + } +} + +// extract embedded field name +// +// so, for a struct like +// +// type A struct { +// io.Writer +// } +// +// we want "Writer" +func embedded(f ast.Expr) string { + switch f := f.(type) { + case *ast.Ident: + return f.Name + case *ast.StarExpr: + return embedded(f.X) + case *ast.SelectorExpr: + return f.Sel.Name + default: + // other possibilities are disallowed + return "" + } +} + +// stringify a field type name +func stringify(e ast.Expr) string { + switch e := e.(type) { + case *ast.Ident: + return e.Name + case *ast.StarExpr: + return "*" + stringify(e.X) + case *ast.SelectorExpr: + return stringify(e.X) + "." + e.Sel.Name + case *ast.ArrayType: + if e.Len == nil { + return "[]" + stringify(e.Elt) + } + return fmt.Sprintf("[%s]%s", stringify(e.Len), stringify(e.Elt)) + case *ast.InterfaceType: + if e.Methods == nil || e.Methods.NumFields() == 0 { + return "interface{}" + } + } + return "" +} + +// recursively translate ast.Expr to gen.Elem; nil means type not supported +// expected input types: +// - *ast.MapType (map[T]J) +// - *ast.Ident (name) +// - *ast.ArrayType ([(sz)]T) +// - *ast.StarExpr (*T) +// - *ast.StructType (struct {}) +// - *ast.SelectorExpr (a.B) +// - *ast.InterfaceType (interface {}) +func (fs *FileSet) parseExpr(importPrefix string, e ast.Expr) gen.Elem { + switch e := e.(type) { + + case *ast.MapType: + kt := fs.parseExpr(importPrefix, e.Key) + if kt == nil { + return nil + } + + vt := fs.parseExpr(importPrefix, e.Value) + if vt == nil { + return nil + } + + return &gen.Map{Key: kt, Value: vt} + + case *ast.Ident: + b := gen.Ident(importPrefix, e.Name) + + // work to resove this expression + // can be done later, once we've resolved + // everything else. + if b.Value == gen.IDENT { + _, specOK := fs.Specs[e.Name] + _, aliasOK := fs.Aliases[e.Name] + _, interfaceOK := fs.Interfaces[e.Name] + if !specOK && !aliasOK && !interfaceOK { + warnf("non-local identifier: %s\n", e.Name) + } + } + return b + + case *ast.ArrayType: + + // special case for []byte + if e.Len == nil { + if i, ok := e.Elt.(*ast.Ident); ok && i.Name == "byte" { + return &gen.BaseElem{Value: gen.Bytes} + } + } + + // return early if we don't know + // what the slice element type is + els := fs.parseExpr(importPrefix, e.Elt) + if els == nil { + return nil + } + + // array and not a slice + if e.Len != nil { + switch s := e.Len.(type) { + case *ast.BasicLit: + return &gen.Array{ + Size: s.Value, + Els: els, + } + + case *ast.Ident: + sizeHint := "" + if s.Obj != nil && s.Obj.Kind == ast.Con { + switch d := s.Obj.Decl.(type) { + case *ast.ValueSpec: + if len(d.Names) == 1 && len(d.Values) == 1 { + v := d.Values[0] + // Keep trying to resolve this value + repeat := true + for repeat { + switch vv := v.(type) { + case *ast.BasicLit: + sizeHint = vv.Value + repeat = false + case *ast.SelectorExpr: + switch xv := vv.X.(type) { + case *ast.Ident: + pkgpath := fs.ImportName[xv.Name] + pkg := fs.ImportSet[pkgpath] + v = pkg.Consts[vv.Sel.Name] + } + default: + repeat = false + } + } + } + } + } + return &gen.Array{ + Size: s.String(), + SizeHint: sizeHint, + Els: els, + } + + case *ast.SelectorExpr: + return &gen.Array{ + Size: stringify(s), + Els: els, + } + + default: + return nil + } + } + return &gen.Slice{Els: els} + + case *ast.StarExpr: + if v := fs.parseExpr(importPrefix, e.X); v != nil { + return &gen.Ptr{Value: v} + } + return nil + + case *ast.StructType: + return &gen.Struct{Fields: fs.parseFieldList(importPrefix, e.Fields)} + + case *ast.SelectorExpr: + return gen.Ident("", stringify(e)) + + case *ast.InterfaceType: + // support `interface{}` + if len(e.Methods.List) == 0 { + return &gen.BaseElem{Value: gen.Intf} + } + return nil + + default: // other types not supported + return nil + } +} + +func infof(s string, v ...interface{}) { + pushstate(s) + if print(0) { + fmt.Printf(chalk.Green.Color(strings.Join(logctx, ": ")), v...) + } + popstate() +} + +func infoln(s string) { + pushstate(s) + if print(0) { + fmt.Println(chalk.Green.Color(strings.Join(logctx, ": "))) + } + popstate() +} + +func warnf(s string, v ...interface{}) { + pushstate(s) + if print(1) { + fmt.Printf(chalk.Yellow.Color(strings.Join(logctx, ": ")), v...) + } + popstate() +} + +func warnln(s string) { + pushstate(s) + if print(1) { + fmt.Println(chalk.Yellow.Color(strings.Join(logctx, ": "))) + } + popstate() +} + +func fatalf(s string, v ...interface{}) { + pushstate(s) + if print(2) { + fmt.Printf(chalk.Red.Color(strings.Join(logctx, ": ")), v...) + } + popstate() +} + +var logctx []string +var printlevel int + +func increasePrintLevel() { + printlevel++ +} + +func decreasePrintLevel() { + printlevel-- +} + +func print(level int) bool { + return printlevel < level +} + +// push logging state +func pushstate(s string) { + logctx = append(logctx, s) +} + +// pop logging state +func popstate() { + logctx = logctx[:len(logctx)-1] +} diff --git a/msgp/parse/inline.go b/msgp/parse/inline.go new file mode 100644 index 0000000000..0fba91dbf4 --- /dev/null +++ b/msgp/parse/inline.go @@ -0,0 +1,175 @@ +package parse + +import ( + "sort" + + "github.com/algorand/msgp/gen" +) + +// This file defines when and how we +// propagate type information from +// one type declaration to another. +// After the processing pass, every +// non-primitive type is marshalled/unmarshalled/etc. +// through a function call. Here, we propagate +// the type information into the caller's type +// tree *if* the child type is simple enough. +// +// For example, types like +// +// type A [4]int +// +// will get pushed into parent methods, +// whereas types like +// +// type B [3]map[string]struct{A, B [4]string} +// +// will not. + +// this is an approximate measure +// of the number of children in a node +const maxComplex = 5 + +// begin recursive search for identities with the +// given name and replace them with be +func (f *FileSet) findShim(id string, be *gen.BaseElem) { + for name, el := range f.Identities { + pushstate(name) + switch el := el.(type) { + case *gen.Struct: + for i := range el.Fields { + f.nextShim(&el.Fields[i].FieldElem, id, be) + } + case *gen.Array: + f.nextShim(&el.Els, id, be) + case *gen.Slice: + f.nextShim(&el.Els, id, be) + case *gen.Map: + f.nextShim(&el.Value, id, be) + case *gen.Ptr: + f.nextShim(&el.Value, id, be) + } + popstate() + } + // we'll need this at the top level as well + f.Identities[id] = be +} + +func (f *FileSet) nextShim(ref *gen.Elem, id string, be *gen.BaseElem) { + if (*ref).TypeName() == id { + vn := (*ref).Varname() + *ref = be.Copy() + (*ref).SetVarname(vn) + } else { + switch el := (*ref).(type) { + case *gen.Struct: + for i := range el.Fields { + f.nextShim(&el.Fields[i].FieldElem, id, be) + } + case *gen.Array: + f.nextShim(&el.Els, id, be) + case *gen.Slice: + f.nextShim(&el.Els, id, be) + case *gen.Map: + f.nextShim(&el.Value, id, be) + case *gen.Ptr: + f.nextShim(&el.Value, id, be) + } + } +} + +// propInline identifies and inlines candidates +func (f *FileSet) propInline() { + type gelem struct { + name string + el gen.Elem + } + + all := make([]gelem, 0, len(f.Identities)) + + for name, el := range f.Identities { + all = append(all, gelem{name: name, el: el}) + } + + // make sure we process inlining determinstically: + // start with the least-complex elems; + // use identifier names as a tie-breaker + sort.Slice(all, func(i, j int) bool { + ig, jg := &all[i], &all[j] + ic, jc := ig.el.Complexity(), jg.el.Complexity() + return ic < jc || (ic == jc && ig.name < jg.name) + }) + + for i := range all { + name := all[i].name + pushstate(name) + switch el := all[i].el.(type) { + case *gen.Struct: + for i := range el.Fields { + f.nextInline(&el.Fields[i].FieldElem, name) + } + case *gen.Array: + f.nextInline(&el.Els, name) + case *gen.Slice: + f.nextInline(&el.Els, name) + case *gen.Map: + f.nextInline(&el.Value, name) + case *gen.Ptr: + f.nextInline(&el.Value, name) + } + popstate() + } +} + +const fatalloop = `detected infinite recursion in inlining loop! +Please file a bug at github.com/tinylib/msgp/issues! +Thanks! +` + +func (f *FileSet) nextInline(ref *gen.Elem, root string) { + switch el := (*ref).(type) { + case *gen.BaseElem: + // ensure that we're not inlining + // a type into itself + typ := el.TypeName() + if el.Value == gen.IDENT && typ != root { + if node, ok := f.Identities[typ]; ok && node.Complexity() < maxComplex { + // infof("inlining %s\n", typ) + + // This should never happen; it will cause + // infinite recursion. + if node == *ref { + panic(fatalloop) + } + + *ref = node.Copy() + f.nextInline(ref, node.TypeName()) + } else if !ok && !el.Resolved() { + // this is the point at which we're sure that + // we've got a type that isn't a primitive, + // a library builtin, or a processed type + + // we correctly handle this case by forwarding + // methods to the unresolved identifier; the + // code will fail to compile if the requisite + // methods aren't available for that type. + + // warnf("unresolved identifier: %s\n", typ) + } + } + case *gen.Struct: + for i := range el.Fields { + f.nextInline(&el.Fields[i].FieldElem, root) + } + case *gen.Array: + f.nextInline(&el.Els, root) + case *gen.Slice: + f.nextInline(&el.Els, root) + case *gen.Map: + f.nextInline(&el.Value, root) + case *gen.Ptr: + f.nextInline(&el.Value, root) + default: + panic("bad elem type") + } +} diff --git a/msgp/printer/print.go b/msgp/printer/print.go new file mode 100644 index 0000000000..fb45e1ed41 --- /dev/null +++ b/msgp/printer/print.go @@ -0,0 +1,168 @@ +package printer + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "strings" + + "github.com/algorand/msgp/gen" + "github.com/algorand/msgp/parse" + "github.com/daixiang0/gci/pkg/gci" + "github.com/daixiang0/gci/pkg/gci/sections" + "github.com/ttacon/chalk" + "golang.org/x/tools/imports" +) + +func infof(s string, v ...interface{}) { + fmt.Printf(chalk.Magenta.Color(s), v...) +} + +// PrintFile prints the methods for the provided list +// of elements to the given file name and canonical +// package path. +func PrintFile(file string, f *parse.FileSet, mode gen.Method, skipFormat bool) error { + out, tests, err := generate(f, mode) + if err != nil { + return err + } + + // we'll run goimports on the main file + // in another goroutine, and run it here + // for the test file. empirically, this + // takes about the same amount of time as + // doing them in serial when GOMAXPROCS=1, + // and faster otherwise. + res := goformat(file, out.Bytes(), skipFormat) + if tests != nil { + testfile := strings.TrimSuffix(file, ".go") + "_test.go" + err = format(testfile, tests.Bytes(), skipFormat) + if err != nil { + return err + } + infof(">>> Wrote and formatted \"%s\"\n", testfile) + } + err = <-res + if err != nil { + return err + } + return nil +} + +func format(file string, data []byte, skipFormat bool) error { + if skipFormat { + return ioutil.WriteFile(file, data, 0600) + } + // first run through goimports (which cleans up unused deps & does gofmt) + out, err := imports.Process(file, data, nil) + if err != nil { + return err + } + if err := ioutil.WriteFile(file, out, 0600); err != nil { + return err + } + // then run through gci to arrange import order + if err := gci.WriteFormattedFiles([]string{file}, gci.GciConfiguration{ + Sections: gci.SectionList{ + sections.StandardPackage{}, + sections.DefaultSection{}, + sections.Prefix{ImportPrefix: "github.com/algorand"}, + sections.Prefix{ImportPrefix: "github.com/algorand/go-algorand"}, + }, + SectionSeparators: gci.SectionList{sections.NewLine{}}, + }); err != nil { + return err + } + return nil +} + +func goformat(file string, data []byte, skipFormat bool) <-chan error { + out := make(chan error, 1) + go func(file string, data []byte, end chan error) { + end <- format(file, data, skipFormat) + infof(">>> Wrote and formatted \"%s\"\n", file) + }(file, data, out) + return out +} + +func dedupImports(imp []string) []string { + m := make(map[string]struct{}) + for i := range imp { + m[imp[i]] = struct{}{} + } + r := []string{} + for k := range m { + r = append(r, k) + } + return r +} + +func generate(f *parse.FileSet, mode gen.Method) (*bytes.Buffer, *bytes.Buffer, error) { + outbuf := bytes.NewBuffer(make([]byte, 0, 4096)) + writePkgHeader(outbuf, f.Package) + + myImports := []string{"github.com/algorand/msgp/msgp"} + for _, imp := range f.Imports { + if imp.Name != nil { + // have an alias, include it. + myImports = append(myImports, imp.Name.Name+` `+imp.Path.Value) + } else { + myImports = append(myImports, imp.Path.Value) + } + } + dedup := dedupImports(myImports) + writeImportHeader(outbuf, dedup...) + + var testbuf *bytes.Buffer + var testwr io.Writer + if mode&gen.Test == gen.Test { + testbuf = bytes.NewBuffer(make([]byte, 0, 4096)) + writeBuildHeader(testbuf, []string{"!skip_msgp_testing"}) + writePkgHeader(testbuf, f.Package) + writeImportHeader( + testbuf, + "github.com/algorand/msgp/msgp", + "github.com/algorand/go-algorand/protocol", + "github.com/algorand/go-algorand/test/partitiontest", + "testing") + testwr = testbuf + } + funcbuf := bytes.NewBuffer(make([]byte, 0, 4096)) + var topics gen.Topics + + err := f.PrintTo(gen.NewPrinter(mode, &topics, funcbuf, testwr)) + if err == nil { + outbuf.Write(topics.Bytes()) + outbuf.Write(funcbuf.Bytes()) + } + return outbuf, testbuf, err +} + +func writePkgHeader(b *bytes.Buffer, name string) { + b.WriteString("package ") + b.WriteString(name) + b.WriteByte('\n') + // write generated code marker + // https://github.com/tinylib/msgp/issues/229 + // https://golang.org/s/generatedcode + b.WriteString("// Code generated by github.com/algorand/msgp DO NOT EDIT.\n\n") +} + +func writeImportHeader(b *bytes.Buffer, imports ...string) { + b.WriteString("import (\n") + for _, im := range imports { + if im[len(im)-1] == '"' { + // support aliased imports + fmt.Fprintf(b, "\t%s\n", im) + } else { + fmt.Fprintf(b, "\t%q\n", im) + } + } + b.WriteString(")\n\n") +} + +func writeBuildHeader(b *bytes.Buffer, buildHeaders []string) { + headers := fmt.Sprintf("//go:build %s\n// +build %s\n\n", strings.Join(buildHeaders, " "), strings.Join(buildHeaders, " ")) + b.WriteString(headers) +} diff --git a/msgp/printer/print_test.go b/msgp/printer/print_test.go new file mode 100644 index 0000000000..112fa10a74 --- /dev/null +++ b/msgp/printer/print_test.go @@ -0,0 +1,19 @@ +package printer + +import ( + "bytes" + "testing" +) + +func TestWriteBuildHeader(t *testing.T) { + testBuf := bytes.NewBuffer(make([]byte, 0, 4096)) + buildHeaders := []string{"foobar"} + expectedBuf := bytes.NewBuffer(make([]byte, 0, 4096)) + expectedBuf.WriteString("//go:build foobar\n// +build foobar\n\n") + + writeBuildHeader(testBuf, buildHeaders) + + if testBuf.String() != expectedBuf.String() { + t.Errorf("testBuf:\n%s not equal to expectedBuf:\n%s", testBuf, expectedBuf) + } +} diff --git a/network/msgp_gen.go b/network/msgp_gen.go index 8c32ee026f..53216cec3c 100644 --- a/network/msgp_gen.go +++ b/network/msgp_gen.go @@ -13,6 +13,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -22,6 +23,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -31,6 +33,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -40,6 +43,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -49,6 +53,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -58,6 +63,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -67,6 +73,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -76,6 +83,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -98,7 +106,12 @@ func (_ disconnectReason) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *disconnectReason) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *disconnectReason) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -112,6 +125,9 @@ func (z *disconnectReason) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *disconnectReason) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *disconnectReason) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*disconnectReason) return ok @@ -180,7 +196,12 @@ func (_ *identityChallenge) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityChallenge) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityChallenge) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -194,7 +215,7 @@ func (z *identityChallenge) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0002 > 0 { zb0002-- - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Key") return @@ -250,7 +271,7 @@ func (z *identityChallenge) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "pk": - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Key") return @@ -290,6 +311,9 @@ func (z *identityChallenge) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *identityChallenge) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityChallenge) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityChallenge) return ok @@ -361,7 +385,12 @@ func (_ *identityChallengeResponse) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityChallengeResponse) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityChallengeResponse) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -375,7 +404,7 @@ func (z *identityChallengeResponse) UnmarshalMsg(bts []byte) (o []byte, err erro } if zb0003 > 0 { zb0003-- - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Key") return @@ -421,7 +450,7 @@ func (z *identityChallengeResponse) UnmarshalMsg(bts []byte) (o []byte, err erro } switch string(field) { case "pk": - bts, err = (*z).Key.UnmarshalMsg(bts) + bts, err = (*z).Key.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Key") return @@ -451,6 +480,9 @@ func (z *identityChallengeResponse) UnmarshalMsg(bts []byte) (o []byte, err erro return } +func (z *identityChallengeResponse) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityChallengeResponse) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityChallengeResponse) return ok @@ -515,7 +547,12 @@ func (_ *identityChallengeResponseSigned) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityChallengeResponseSigned) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -529,7 +566,7 @@ func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, er } if zb0001 > 0 { zb0001-- - bts, err = (*z).Msg.UnmarshalMsg(bts) + bts, err = (*z).Msg.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msg") return @@ -537,7 +574,7 @@ func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, er } if zb0001 > 0 { zb0001-- - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Signature") return @@ -567,13 +604,13 @@ func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, er } switch string(field) { case "icr": - bts, err = (*z).Msg.UnmarshalMsg(bts) + bts, err = (*z).Msg.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msg") return } case "sig": - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Signature") return @@ -591,6 +628,9 @@ func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, er return } +func (z *identityChallengeResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityChallengeResponseSigned) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityChallengeResponseSigned) return ok @@ -650,7 +690,12 @@ func (_ *identityChallengeSigned) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityChallengeSigned) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -664,7 +709,7 @@ func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).Msg.UnmarshalMsg(bts) + bts, err = (*z).Msg.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Msg") return @@ -672,7 +717,7 @@ func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) } if zb0001 > 0 { zb0001-- - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Signature") return @@ -702,13 +747,13 @@ func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) } switch string(field) { case "ic": - bts, err = (*z).Msg.UnmarshalMsg(bts) + bts, err = (*z).Msg.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Msg") return } case "sig": - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Signature") return @@ -726,6 +771,9 @@ func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *identityChallengeSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityChallengeSigned) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityChallengeSigned) return ok @@ -761,7 +809,12 @@ func (_ *identityChallengeValue) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityChallengeValue) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityChallengeValue) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- bts, err = msgp.ReadExactBytes(bts, (*z)[:]) if err != nil { err = msgp.WrapError(err) @@ -771,6 +824,9 @@ func (z *identityChallengeValue) UnmarshalMsg(bts []byte) (o []byte, err error) return } +func (z *identityChallengeValue) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityChallengeValue) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityChallengeValue) return ok @@ -822,7 +878,12 @@ func (_ *identityVerificationMessage) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityVerificationMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityVerificationMessage) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -884,6 +945,9 @@ func (z *identityVerificationMessage) UnmarshalMsg(bts []byte) (o []byte, err er return } +func (z *identityVerificationMessage) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityVerificationMessage) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityVerificationMessage) return ok @@ -958,7 +1022,12 @@ func (_ *identityVerificationMessageSigned) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *identityVerificationMessageSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *identityVerificationMessageSigned) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0002 int @@ -1030,7 +1099,7 @@ func (z *identityVerificationMessageSigned) UnmarshalMsg(bts []byte) (o []byte, } if zb0002 > 0 { zb0002-- - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Signature") return @@ -1116,7 +1185,7 @@ func (z *identityVerificationMessageSigned) UnmarshalMsg(bts []byte) (o []byte, } } case "sig": - bts, err = (*z).Signature.UnmarshalMsg(bts) + bts, err = (*z).Signature.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Signature") return @@ -1134,6 +1203,9 @@ func (z *identityVerificationMessageSigned) UnmarshalMsg(bts []byte) (o []byte, return } +func (z *identityVerificationMessageSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *identityVerificationMessageSigned) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*identityVerificationMessageSigned) return ok diff --git a/node/msgp_gen.go b/node/msgp_gen.go index 146e8635bb..ee32584eb9 100644 --- a/node/msgp_gen.go +++ b/node/msgp_gen.go @@ -14,6 +14,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -23,6 +24,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -57,7 +59,12 @@ func (_ *netPrioResponse) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *netPrioResponse) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *netPrioResponse) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -139,6 +146,9 @@ func (z *netPrioResponse) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *netPrioResponse) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *netPrioResponse) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*netPrioResponse) return ok @@ -229,7 +239,12 @@ func (_ *netPrioResponseSigned) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *netPrioResponseSigned) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -321,7 +336,7 @@ func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -329,7 +344,7 @@ func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sender") return @@ -337,7 +352,7 @@ func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -443,19 +458,19 @@ func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { } } case "Round": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "Sender": - bts, err = (*z).Sender.UnmarshalMsg(bts) + bts, err = (*z).Sender.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sender") return } case "Sig": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -473,6 +488,9 @@ func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *netPrioResponseSigned) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *netPrioResponseSigned) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*netPrioResponseSigned) return ok diff --git a/protocol/msgp_gen.go b/protocol/msgp_gen.go index db191f018d..f33c8e3553 100644 --- a/protocol/msgp_gen.go +++ b/protocol/msgp_gen.go @@ -11,6 +11,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -20,6 +21,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -29,6 +31,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -38,6 +41,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -47,6 +51,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -56,6 +61,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -65,6 +71,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -87,7 +94,12 @@ func (_ ConsensusVersion) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *ConsensusVersion) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *ConsensusVersion) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string var zb0002 int @@ -111,6 +123,9 @@ func (z *ConsensusVersion) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *ConsensusVersion) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *ConsensusVersion) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*ConsensusVersion) return ok @@ -149,7 +164,12 @@ func (_ Error) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Error) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Error) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -163,6 +183,9 @@ func (z *Error) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Error) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Error) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Error) return ok @@ -201,7 +224,12 @@ func (_ HashID) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *HashID) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *HashID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -215,6 +243,9 @@ func (z *HashID) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *HashID) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *HashID) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*HashID) return ok @@ -253,7 +284,12 @@ func (_ NetworkID) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *NetworkID) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *NetworkID) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -267,6 +303,9 @@ func (z *NetworkID) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *NetworkID) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *NetworkID) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*NetworkID) return ok @@ -305,7 +344,12 @@ func (_ StateProofType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *StateProofType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *StateProofType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 uint64 zb0001, bts, err = msgp.ReadUint64Bytes(bts) @@ -319,6 +363,9 @@ func (z *StateProofType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *StateProofType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *StateProofType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*StateProofType) return ok @@ -357,7 +404,12 @@ func (_ Tag) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *Tag) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *Tag) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string zb0001, bts, err = msgp.ReadStringBytes(bts) @@ -371,6 +423,9 @@ func (z *Tag) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *Tag) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *Tag) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*Tag) return ok @@ -409,7 +464,12 @@ func (_ TxType) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *TxType) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *TxType) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- { var zb0001 string var zb0002 int @@ -433,6 +493,9 @@ func (z *TxType) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *TxType) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *TxType) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*TxType) return ok diff --git a/protocol/test/msgp_gen.go b/protocol/test/msgp_gen.go index 518afb1cb7..9a66ba3e52 100644 --- a/protocol/test/msgp_gen.go +++ b/protocol/test/msgp_gen.go @@ -11,6 +11,7 @@ import ( // |-----> MarshalMsg // |-----> CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> Msgsize // |-----> MsgIsZero @@ -40,7 +41,12 @@ func (_ testSlice) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *testSlice) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *testSlice) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var zb0002 int var zb0003 bool zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) @@ -71,6 +77,9 @@ func (z *testSlice) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *testSlice) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *testSlice) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*testSlice) return ok diff --git a/rpcs/msgp_gen.go b/rpcs/msgp_gen.go index 5f8af433f7..d31c619108 100644 --- a/rpcs/msgp_gen.go +++ b/rpcs/msgp_gen.go @@ -14,6 +14,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -39,7 +40,12 @@ func (_ *EncodedBlockCert) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *EncodedBlockCert) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -53,7 +59,7 @@ func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Block.UnmarshalMsg(bts) + bts, err = (*z).Block.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Block") return @@ -61,7 +67,7 @@ func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Certificate.UnmarshalMsg(bts) + bts, err = (*z).Certificate.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Certificate") return @@ -91,13 +97,13 @@ func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "block": - bts, err = (*z).Block.UnmarshalMsg(bts) + bts, err = (*z).Block.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Block") return } case "cert": - bts, err = (*z).Certificate.UnmarshalMsg(bts) + bts, err = (*z).Certificate.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Certificate") return @@ -115,6 +121,9 @@ func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *EncodedBlockCert) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*EncodedBlockCert) return ok diff --git a/scripts/check_license.sh b/scripts/check_license.sh index 51f83d7d4f..9e40983f93 100755 --- a/scripts/check_license.sh +++ b/scripts/check_license.sh @@ -4,7 +4,7 @@ PROJECT_ROOT=$(git rev-parse --show-toplevel) LICENSE_LOCATION="$PROJECT_ROOT"/scripts/LICENSE_HEADER NUMLINES=$(< "$LICENSE_LOCATION" wc -l | tr -d ' ') LICENSE=$(sed "s/{DATE_Y}/$(date +"%Y")/" "$LICENSE_LOCATION") -VERSIONED_GO_FILES=$(git ls-tree --full-tree --name-only -r HEAD | grep "\.go$") +VERSIONED_GO_FILES=$(git ls-tree --full-tree --name-only -r HEAD | grep "\.go$" | grep -v "^msgp/") EXCLUDE=( "Code generated by" "David Lazar" diff --git a/stateproof/msgp_gen.go b/stateproof/msgp_gen.go index 11ad409337..0339ba3ea3 100644 --- a/stateproof/msgp_gen.go +++ b/stateproof/msgp_gen.go @@ -19,6 +19,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -28,6 +29,7 @@ import ( // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg // |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState // |-----> (*) CanUnmarshalMsg // |-----> (*) Msgsize // |-----> (*) MsgIsZero @@ -80,7 +82,12 @@ func (_ *sigFromAddr) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *sigFromAddr) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0001 int @@ -94,7 +101,7 @@ func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).SignerAddress.UnmarshalMsg(bts) + bts, err = (*z).SignerAddress.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "SignerAddress") return @@ -102,7 +109,7 @@ func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Round") return @@ -110,7 +117,7 @@ func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0001 > 0 { zb0001-- - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Sig") return @@ -140,19 +147,19 @@ func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch string(field) { case "a": - bts, err = (*z).SignerAddress.UnmarshalMsg(bts) + bts, err = (*z).SignerAddress.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "SignerAddress") return } case "r": - bts, err = (*z).Round.UnmarshalMsg(bts) + bts, err = (*z).Round.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Round") return } case "s": - bts, err = (*z).Sig.UnmarshalMsg(bts) + bts, err = (*z).Sig.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Sig") return @@ -170,6 +177,9 @@ func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *sigFromAddr) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*sigFromAddr) return ok @@ -266,7 +276,12 @@ func (_ *spProver) CanMarshalMsg(z interface{}) bool { } // UnmarshalMsg implements msgp.Unmarshaler -func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { +func (z *spProver) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.Depth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.Depth-- var field []byte _ = field var zb0003 int @@ -290,7 +305,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Prover == nil { (*z).Prover = new(stateproof.Prover) } - bts, err = (*z).Prover.UnmarshalMsg(bts) + bts, err = (*z).Prover.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Prover") return @@ -320,7 +335,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 uint64 zb0005-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "AddrToPos") return @@ -335,7 +350,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).VotersHdr.UnmarshalMsg(bts) + bts, err = (*z).VotersHdr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "VotersHdr") return @@ -343,7 +358,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { } if zb0003 > 0 { zb0003-- - bts, err = (*z).Message.UnmarshalMsg(bts) + bts, err = (*z).Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "struct-from-array", "Message") return @@ -383,7 +398,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { if (*z).Prover == nil { (*z).Prover = new(stateproof.Prover) } - bts, err = (*z).Prover.UnmarshalMsg(bts) + bts, err = (*z).Prover.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Prover") return @@ -411,7 +426,7 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { var zb0001 basics.Address var zb0002 uint64 zb0007-- - bts, err = zb0001.UnmarshalMsg(bts) + bts, err = zb0001.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "AddrToPos") return @@ -424,13 +439,13 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { (*z).AddrToPos[zb0001] = zb0002 } case "hdr": - bts, err = (*z).VotersHdr.UnmarshalMsg(bts) + bts, err = (*z).VotersHdr.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "VotersHdr") return } case "msg": - bts, err = (*z).Message.UnmarshalMsg(bts) + bts, err = (*z).Message.UnmarshalMsgWithState(bts, st) if err != nil { err = msgp.WrapError(err, "Message") return @@ -448,6 +463,9 @@ func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { return } +func (z *spProver) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} func (_ *spProver) CanUnmarshalMsg(z interface{}) bool { _, ok := (z).(*spProver) return ok diff --git a/tools/block-generator/go.mod b/tools/block-generator/go.mod index fc692a77b3..b0bae0f24e 100644 --- a/tools/block-generator/go.mod +++ b/tools/block-generator/go.mod @@ -1,6 +1,7 @@ module github.com/algorand/go-algorand/tools/block-generator replace github.com/algorand/go-algorand => ../.. +replace github.com/algorand/msgp => ../../msgp go 1.20 diff --git a/tools/x-repo-types/go.mod b/tools/x-repo-types/go.mod index df9ddf0114..7427bc676e 100644 --- a/tools/x-repo-types/go.mod +++ b/tools/x-repo-types/go.mod @@ -3,6 +3,7 @@ module github.com/algorand/go-algorand/tools/x-repo-types go 1.20 replace github.com/algorand/go-algorand => ../.. +replace github.com/algorand/msgp => ../../msgp require ( github.com/algorand/go-algorand v0.0.0