From 8b0be4523a46d73f63c26a8a9875fb40e4096ab9 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Thu, 5 Mar 2020 16:44:38 -0500 Subject: [PATCH] Merge pending changed from beta 2.0.11 to stable 2.0.5 (#889) - static code optimizations - release build scripts update --- Makefile | 8 + agreement/actions.go | 1 + agreement/bundle.go | 12 +- agreement/cadaver.go | 1 + agreement/coservice.go | 1 + agreement/cryptoRequestContext.go | 1 + agreement/events.go | 1 + agreement/msgp_gen.go | 5646 +++++++++++++++++ agreement/msgp_gen_test.go | 1064 ++++ agreement/proposal.go | 4 + agreement/pseudonode.go | 1 + agreement/router.go | 1 + agreement/selector.go | 2 + agreement/trace.go | 1 + agreement/voteAuxiliary.go | 2 +- auction/messages.go | 12 +- auction/msgp_gen.go | 3408 ++++++++++ auction/msgp_gen_test.go | 754 +++ auction/tracker.go | 1 + auction/tracker_test.go | 2 +- buildnumber.dat | 2 +- cmd/algokey/multisig.go | 2 +- cmd/algokey/sign.go | 2 +- config/config.go | 19 + crypto/curve25519.go | 15 +- crypto/msgp_gen.go | 2171 +++++++ crypto/msgp_gen_test.go | 1436 +++++ crypto/multisig.go | 2 +- crypto/onetimesig.go | 32 +- crypto/vrf.go | 8 +- daemon/algod/api/client/restClient.go | 4 +- daemon/kmd/api/v1/handlers.go | 4 +- daemon/kmd/client/wrappers.go | 2 +- daemon/kmd/wallet/driver/ledger.go | 4 +- daemon/kmd/wallet/driver/sqlite.go | 3 +- data/basics/msgp_gen.go | 2084 ++++++ data/basics/msgp_gen_test.go | 258 + data/basics/sort.go | 27 + data/basics/units.go | 32 +- data/basics/userBalance.go | 8 +- data/bookkeeping/block.go | 8 +- data/bookkeeping/encoding_test.go | 2 +- data/bookkeeping/genesis.go | 9 +- data/bookkeeping/msgp_gen.go | 2200 +++++++ data/bookkeeping/msgp_gen_test.go | 382 ++ data/committee/common_test.go | 2 +- data/committee/credential.go | 2 +- data/committee/msgp_gen.go | 526 ++ data/committee/msgp_gen_test.go | 258 + data/hashable/message.go | 2 +- data/hashable/msgp_gen.go | 113 + data/hashable/msgp_gen_test.go | 72 + data/ledger.go | 8 - data/pools/feeTracker.go | 2 +- data/pools/transactionPool.go | 8 - data/transactions/aggregates.go | 1 + data/transactions/logic/eval.go | 5 +- data/transactions/logic/eval_test.go | 2 +- data/transactions/logicsig.go | 5 +- data/transactions/msgp_gen.go | 3636 +++++++++++ data/transactions/msgp_gen_test.go | 878 +++ data/transactions/signedtxn.go | 90 +- data/transactions/signedtxn_test.go | 7 +- data/transactions/transaction.go | 38 +- data/transactions/verify/txn_test.go | 2 +- data/txHandler.go | 1 - docker/releases/build_releases.sh | 60 +- go.mod | 11 +- go.sum | 27 + ledger/accountdb.go | 4 +- ledger/blockqueue.go | 4 +- ledger/eval.go | 4 +- libgoal/transactions.go | 15 - protocol/codec.go | 69 +- protocol/codec_tester.go | 210 + protocol/msgp_gen.go | 283 + protocol/msgp_gen_test.go | 3 + rpcs/ledgerService_test.go | 1 - rpcs/txSyncer.go | 1 - rpcs/txSyncer_test.go | 1 - scripts/buildhost/linux-arm.sh | 2 +- scripts/check_deps.sh | 1 + scripts/compute_branch_channel.sh | 7 +- scripts/configure_dev-deps.sh | 2 +- scripts/release/README.md | 107 +- scripts/release/archive/tag.sh | 19 + scripts/release/build/Jenkinsfile | 82 + scripts/release/build/deb/package.sh | 27 + scripts/release/build/rpm/build.sh | 41 + scripts/release/build/rpm/docker.sh | 16 + scripts/release/build/rpm/package.sh | 32 + scripts/release/build/rpm/sign.sh | 48 + scripts/release/build/stage/build/run.sh | 7 + scripts/release/build/stage/build/task.sh | 41 + scripts/release/build/stage/package/run.sh | 7 + scripts/release/build/stage/package/task.sh | 20 + scripts/release/build/stage/setup/run.sh | 13 + scripts/release/build/stage/sign/run.sh | 7 + scripts/release/build/stage/sign/task.sh | 51 + scripts/release/build/stage/upload/run.sh | 22 + scripts/release/build/stage/upload/task.sh | 66 + scripts/release/common/create.sh | 5 + scripts/release/common/delete.sh | 5 + .../release/common/docker/centos.Dockerfile | 8 + .../release/common/docker/setup.Dockerfile | 5 + scripts/release/common/ec2/shutdown.sh | 57 + scripts/release/common/ec2/start.sh | 142 + scripts/release/common/setup.sh | 132 + .../release/helper/centos-build.Dockerfile | 2 + scripts/release/helper/deb_test.sh | 8 +- scripts/release/prod/Jenkinsfile | 60 + scripts/release/prod/deb/snapshot.sh | 60 + .../{ => release/prod}/reverse_hex_timestamp | 0 scripts/release/prod/rpm/run_centos.sh | 12 + scripts/release/prod/rpm/snapshot.sh | 53 + scripts/release/prod/stage/setup/run.sh | 26 + scripts/release/prod/stage/snapshot.sh | 15 + scripts/release/prod/stage/sync/run.sh | 18 + scripts/release/socket.sh | 39 + scripts/release/test/Jenkinsfile | 47 + scripts/release/test/deb/run_ubuntu.sh | 69 + scripts/release/test/deb/testDebian.exp | 102 + scripts/release/test/deb/test_algorand.sh | 40 + scripts/release/test/deb/test_apt-get.sh | 28 + scripts/release/test/gpg-fake.sh | 91 + scripts/release/test/rpm/run_centos.sh | 32 + scripts/release/test/rpm/test_algorand.sh | 82 + scripts/release/test/stage/setup/run.sh | 27 + scripts/release/test/stage/test/run.sh | 18 + scripts/release/test/stage/test/task.sh | 23 + scripts/release/util/check_sig.sh | 42 + scripts/release/util/smoke_test.sh | 73 + scripts/release/util/test_package.sh | 132 + scripts/travis/after_build.sh | 5 + scripts/travis/build.sh | 8 + scripts/travis/run_tests.sh | 3 +- 136 files changed, 27786 insertions(+), 291 deletions(-) create mode 100644 agreement/msgp_gen.go create mode 100644 agreement/msgp_gen_test.go create mode 100644 auction/msgp_gen.go create mode 100644 auction/msgp_gen_test.go create mode 100644 crypto/msgp_gen.go create mode 100644 crypto/msgp_gen_test.go create mode 100644 data/basics/msgp_gen.go create mode 100644 data/basics/msgp_gen_test.go create mode 100644 data/basics/sort.go create mode 100644 data/bookkeeping/msgp_gen.go create mode 100644 data/bookkeeping/msgp_gen_test.go create mode 100644 data/committee/msgp_gen.go create mode 100644 data/committee/msgp_gen_test.go create mode 100644 data/hashable/msgp_gen.go create mode 100644 data/hashable/msgp_gen_test.go create mode 100644 data/transactions/msgp_gen.go create mode 100644 data/transactions/msgp_gen_test.go create mode 100644 protocol/codec_tester.go create mode 100644 protocol/msgp_gen.go create mode 100644 protocol/msgp_gen_test.go create mode 100755 scripts/release/archive/tag.sh create mode 100644 scripts/release/build/Jenkinsfile create mode 100755 scripts/release/build/deb/package.sh create mode 100755 scripts/release/build/rpm/build.sh create mode 100755 scripts/release/build/rpm/docker.sh create mode 100755 scripts/release/build/rpm/package.sh create mode 100755 scripts/release/build/rpm/sign.sh create mode 100755 scripts/release/build/stage/build/run.sh create mode 100755 scripts/release/build/stage/build/task.sh create mode 100755 scripts/release/build/stage/package/run.sh create mode 100755 scripts/release/build/stage/package/task.sh create mode 100755 scripts/release/build/stage/setup/run.sh create mode 100755 scripts/release/build/stage/sign/run.sh create mode 100755 scripts/release/build/stage/sign/task.sh create mode 100755 scripts/release/build/stage/upload/run.sh create mode 100755 scripts/release/build/stage/upload/task.sh create mode 100755 scripts/release/common/create.sh create mode 100755 scripts/release/common/delete.sh create mode 100644 scripts/release/common/docker/centos.Dockerfile create mode 100644 scripts/release/common/docker/setup.Dockerfile create mode 100755 scripts/release/common/ec2/shutdown.sh create mode 100755 scripts/release/common/ec2/start.sh create mode 100755 scripts/release/common/setup.sh create mode 100644 scripts/release/prod/Jenkinsfile create mode 100755 scripts/release/prod/deb/snapshot.sh rename scripts/{ => release/prod}/reverse_hex_timestamp (100%) create mode 100755 scripts/release/prod/rpm/run_centos.sh create mode 100755 scripts/release/prod/rpm/snapshot.sh create mode 100755 scripts/release/prod/stage/setup/run.sh create mode 100755 scripts/release/prod/stage/snapshot.sh create mode 100755 scripts/release/prod/stage/sync/run.sh create mode 100755 scripts/release/socket.sh create mode 100644 scripts/release/test/Jenkinsfile create mode 100755 scripts/release/test/deb/run_ubuntu.sh create mode 100644 scripts/release/test/deb/testDebian.exp create mode 100755 scripts/release/test/deb/test_algorand.sh create mode 100755 scripts/release/test/deb/test_apt-get.sh create mode 100755 scripts/release/test/gpg-fake.sh create mode 100755 scripts/release/test/rpm/run_centos.sh create mode 100755 scripts/release/test/rpm/test_algorand.sh create mode 100755 scripts/release/test/stage/setup/run.sh create mode 100755 scripts/release/test/stage/test/run.sh create mode 100755 scripts/release/test/stage/test/task.sh create mode 100755 scripts/release/util/check_sig.sh create mode 100755 scripts/release/util/smoke_test.sh create mode 100755 scripts/release/util/test_package.sh diff --git a/Makefile b/Makefile index 2ed6b6b8b9..da976915aa 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,8 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \ UNIT_TEST_SOURCES := $(sort $(shell GO111MODULE=off go list ./... | grep -v /go-algorand/test/ )) ALGOD_API_PACKAGES := $(sort $(shell GO111MODULE=off cd daemon/algod/api; go list ./... )) +MSGP_GENERATE := ./protocol ./crypto ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./auction ./agreement + default: build # tools @@ -80,6 +82,12 @@ prof: generate: deps PATH=$(GOPATH1)/bin:$$PATH go generate ./... +msgp: $(patsubst %,%/msgp_gen.go,$(MSGP_GENERATE)) + +%/msgp_gen.go: deps ALWAYS + $(GOPATH1)/bin/msgp -file ./$(@D) -o $@ 1>/dev/null +ALWAYS: + # build our fork of libsodium, placing artifacts into crypto/lib/ and crypto/include/ crypto/lib/libsodium.a: cd crypto/libsodium-fork && \ diff --git a/agreement/actions.go b/agreement/actions.go index 77742affcb..376a3ce151 100644 --- a/agreement/actions.go +++ b/agreement/actions.go @@ -26,6 +26,7 @@ import ( ) //go:generate stringer -type=actionType +//msgp:ignore actionType type actionType int const ( diff --git a/agreement/bundle.go b/agreement/bundle.go index fa4c430089..d64e5fa2aa 100644 --- a/agreement/bundle.go +++ b/agreement/bundle.go @@ -36,8 +36,8 @@ type unauthenticatedBundle struct { Step step `codec:"step"` Proposal proposalValue `codec:"prop"` - Votes []voteAuthenticator `codec:"vote"` - EquivocationVotes []equivocationVoteAuthenticator `codec:"eqv"` + Votes []voteAuthenticator `codec:"vote,allocbound=config.MaxVoteThreshold"` + EquivocationVotes []equivocationVoteAuthenticator `codec:"eqv,allocbound=config.MaxVoteThreshold"` } // bundle is a set of votes, all from the same round, period, and step, and from distinct senders, that reaches quorum. @@ -48,19 +48,23 @@ type bundle struct { U unauthenticatedBundle `codec:"u"` - Votes []vote `codec:"vote"` - EquivocationVotes []equivocationVote `codec:"eqv"` + Votes []vote `codec:"vote,allocbound=config.MaxVoteThreshold"` + EquivocationVotes []equivocationVote `codec:"eqv,allocbound=config.MaxVoteThreshold"` } // voteAuthenticators omit the Round, Period, Step, and Proposal for compression // and to simplify checking logic. type voteAuthenticator struct { + _struct struct{} `codec:""` // not omitempty + Sender basics.Address `codec:"snd"` Cred committee.UnauthenticatedCredential `codec:"cred"` Sig crypto.OneTimeSignature `codec:"sig,omitempty,omitemptycheckstruct"` } type equivocationVoteAuthenticator struct { + _struct struct{} `codec:""` // not omitempty + Sender basics.Address `codec:"snd"` Cred committee.UnauthenticatedCredential `codec:"cred"` Sigs [2]crypto.OneTimeSignature `codec:"sig,omitempty,omitemptycheckstruct"` diff --git a/agreement/cadaver.go b/agreement/cadaver.go index a8965322af..7c14dab618 100644 --- a/agreement/cadaver.go +++ b/agreement/cadaver.go @@ -27,6 +27,7 @@ import ( "github.com/algorand/go-algorand/protocol" ) +//msgp:ignore cadaverEntryType type cadaverEntryType int const ( diff --git a/agreement/coservice.go b/agreement/coservice.go index fe378a570f..5fa3dcf19c 100644 --- a/agreement/coservice.go +++ b/agreement/coservice.go @@ -32,6 +32,7 @@ const ( networkCoserviceType ) +//msgp:ignore coserviceType type coserviceType int type coserviceMonitor struct { diff --git a/agreement/cryptoRequestContext.go b/agreement/cryptoRequestContext.go index 3a5594564b..8a94ef7c8f 100644 --- a/agreement/cryptoRequestContext.go +++ b/agreement/cryptoRequestContext.go @@ -46,6 +46,7 @@ type roundRequestsContext struct { } // pendingRequests keeps the context for all pending requests +//msgp:ignore pendingRequestsContext type pendingRequestsContext map[round]roundRequestsContext func makePendingRequestsContext() pendingRequestsContext { diff --git a/agreement/events.go b/agreement/events.go index a34d856f4e..c28397a915 100644 --- a/agreement/events.go +++ b/agreement/events.go @@ -68,6 +68,7 @@ type externalEvent interface { // type of the implementing struct. // //go:generate stringer -type=eventType +//msgp:ignore eventType type eventType int const ( diff --git a/agreement/msgp_gen.go b/agreement/msgp_gen.go new file mode 100644 index 0000000000..cb534f001a --- /dev/null +++ b/agreement/msgp_gen.go @@ -0,0 +1,5646 @@ +package agreement + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/go-algorand/config" + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Certificate) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(6) + var zb0003Mask uint8 /* 7 bits */ + if len((*z).EquivocationVotes) == 0 { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).Period == 0 { + zb0003Len-- + zb0003Mask |= 0x4 + } + if (*z).Proposal.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x8 + } + if (*z).Round.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x10 + } + if (*z).Step == 0 { + zb0003Len-- + zb0003Mask |= 0x20 + } + if len((*z).Votes) == 0 { + zb0003Len-- + zb0003Mask |= 0x40 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "eqv" + o = append(o, 0xa3, 0x65, 0x71, 0x76) + if (*z).EquivocationVotes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).EquivocationVotes))) + } + for zb0002 := range (*z).EquivocationVotes { + o, err = (*z).EquivocationVotes[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "per" + o = append(o, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + } + if (zb0003Mask & 0x8) == 0 { // if not empty + // string "prop" + o = append(o, 0xa4, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).Proposal.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + } + if (zb0003Mask & 0x10) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0003Mask & 0x20) == 0 { // if not empty + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + } + if (zb0003Mask & 0x40) == 0 { // if not empty + // string "vote" + o = append(o, 0xa4, 0x76, 0x6f, 0x74, 0x65) + if (*z).Votes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Votes))) + } + for zb0001 := range (*z).Votes { + o, err = (*z).Votes[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + } + } + return +} + +func (_ *Certificate) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Certificate) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Certificate) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0005) + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0006) + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposal") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0007 int + var zb0008 bool + zb0007, zb0008, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0007 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0007), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0008 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0007 { + (*z).Votes = ((*z).Votes)[:zb0007] + } else { + (*z).Votes = make([]voteAuthenticator, zb0007) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0009 int + var zb0010 bool + zb0009, zb0010, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0009 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0009), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0010 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0009 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0009] + } else { + (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0009) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = Certificate{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0011 uint64 + zb0011, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0011) + } + case "step": + { + var zb0012 uint64 + zb0012, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0012) + } + case "prop": + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + case "vote": + var zb0013 int + var zb0014 bool + zb0013, zb0014, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Votes") + return + } + if zb0013 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0013), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "Votes") + return + } + if zb0014 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0013 { + (*z).Votes = ((*z).Votes)[:zb0013] + } else { + (*z).Votes = make([]voteAuthenticator, zb0013) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + case "eqv": + var zb0015 int + var zb0016 bool + zb0015, zb0016, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0015 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0015), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0016 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0015 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0015] + } else { + (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0015) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Certificate) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Certificate) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Certificate) Msgsize() (s int) { + s = 1 + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + (*z).Proposal.Msgsize() + 5 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Votes { + s += (*z).Votes[zb0001].Msgsize() + } + s += 4 + msgp.ArrayHeaderSize + for zb0002 := range (*z).EquivocationVotes { + s += (*z).EquivocationVotes[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Certificate) MsgIsZero() bool { + return ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) && ((*z).Proposal.MsgIsZero()) && (len((*z).Votes) == 0) && (len((*z).EquivocationVotes) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *bundle) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(3) + var zb0003Mask uint8 /* 4 bits */ + if len((*z).EquivocationVotes) == 0 { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).U.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x4 + } + if len((*z).Votes) == 0 { + zb0003Len-- + zb0003Mask |= 0x8 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "eqv" + o = append(o, 0xa3, 0x65, 0x71, 0x76) + if (*z).EquivocationVotes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).EquivocationVotes))) + } + for zb0002 := range (*z).EquivocationVotes { + o, err = (*z).EquivocationVotes[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "u" + o = append(o, 0xa1, 0x75) + o, err = (*z).U.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "U") + return + } + } + if (zb0003Mask & 0x8) == 0 { // if not empty + // string "vote" + o = append(o, 0xa4, 0x76, 0x6f, 0x74, 0x65) + if (*z).Votes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Votes))) + } + for zb0001 := range (*z).Votes { + o, err = (*z).Votes[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + } + } + return +} + +func (_ *bundle) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*bundle) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *bundle) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).U.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "U") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0005 int + var zb0006 bool + zb0005, zb0006, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0005 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0005), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0006 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0005 { + (*z).Votes = ((*z).Votes)[:zb0005] + } else { + (*z).Votes = make([]vote, zb0005) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0007 int + var zb0008 bool + zb0007, zb0008, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0007 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0007), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0008 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0007 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0007] + } else { + (*z).EquivocationVotes = make([]equivocationVote, zb0007) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = bundle{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "u": + bts, err = (*z).U.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "U") + return + } + case "vote": + var zb0009 int + var zb0010 bool + zb0009, zb0010, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Votes") + return + } + if zb0009 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0009), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "Votes") + return + } + if zb0010 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0009 { + (*z).Votes = ((*z).Votes)[:zb0009] + } else { + (*z).Votes = make([]vote, zb0009) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + case "eqv": + var zb0011 int + var zb0012 bool + zb0011, zb0012, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0011 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0011), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0012 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0011 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0011] + } else { + (*z).EquivocationVotes = make([]equivocationVote, zb0011) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *bundle) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*bundle) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *bundle) Msgsize() (s int) { + s = 1 + 2 + (*z).U.Msgsize() + 5 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Votes { + s += (*z).Votes[zb0001].Msgsize() + } + s += 4 + msgp.ArrayHeaderSize + for zb0002 := range (*z).EquivocationVotes { + s += (*z).EquivocationVotes[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *bundle) MsgIsZero() bool { + return ((*z).U.MsgIsZero()) && (len((*z).Votes) == 0) && (len((*z).EquivocationVotes) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *equivocationVote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(7) + var zb0003Mask uint8 /* 8 bits */ + if (*z).Cred.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).Period == 0 { + zb0003Len-- + zb0003Mask |= 0x4 + } + if ((*z).Proposals[0].MsgIsZero()) && ((*z).Proposals[1].MsgIsZero()) { + zb0003Len-- + zb0003Mask |= 0x8 + } + if (*z).Round.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x10 + } + if ((*z).Sigs[0].MsgIsZero()) && ((*z).Sigs[1].MsgIsZero()) { + zb0003Len-- + zb0003Mask |= 0x20 + } + if (*z).Sender.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x40 + } + if (*z).Step == 0 { + zb0003Len-- + zb0003Mask |= 0x80 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "per" + o = append(o, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + } + if (zb0003Mask & 0x8) == 0 { // if not empty + // string "props" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x70, 0x73) + o = msgp.AppendArrayHeader(o, 2) + for zb0001 := range (*z).Proposals { + o, err = (*z).Proposals[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0001) + return + } + } + } + if (zb0003Mask & 0x10) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0003Mask & 0x20) == 0 { // if not empty + // string "sigs" + o = append(o, 0xa4, 0x73, 0x69, 0x67, 0x73) + o = msgp.AppendArrayHeader(o, 2) + for zb0002 := range (*z).Sigs { + o, err = (*z).Sigs[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0002) + return + } + } + } + if (zb0003Mask & 0x40) == 0 { // if not empty + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + if (zb0003Mask & 0x80) == 0 { // if not empty + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + } + } + return +} + +func (_ *equivocationVote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*equivocationVote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *equivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0005) + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0006) + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0007 int + zb0007, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals") + return + } + if zb0007 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0007} + return + } + for zb0001 := 0; zb0001 < zb0007; zb0001++ { + bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0008 int + zb0008, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs") + return + } + if zb0008 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0008} + return + } + for zb0002 := 0; zb0002 < zb0008; zb0002++ { + bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = equivocationVote{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0009 uint64 + zb0009, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0009) + } + case "step": + { + var zb0010 uint64 + zb0010, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0010) + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "props": + var zb0011 int + zb0011, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals") + return + } + if zb0011 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0011} + return + } + for zb0001 := 0; zb0001 < zb0011; zb0001++ { + bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0001) + return + } + } + case "sigs": + var zb0012 int + zb0012, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs") + return + } + if zb0012 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0012} + return + } + for zb0002 := 0; zb0002 < zb0012; zb0002++ { + bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *equivocationVote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*equivocationVote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *equivocationVote) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + (*z).Cred.Msgsize() + 6 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Proposals { + s += (*z).Proposals[zb0001].Msgsize() + } + s += 5 + msgp.ArrayHeaderSize + for zb0002 := range (*z).Sigs { + s += (*z).Sigs[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *equivocationVote) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) && ((*z).Cred.MsgIsZero()) && (((*z).Proposals[0].MsgIsZero()) && ((*z).Proposals[1].MsgIsZero())) && (((*z).Sigs[0].MsgIsZero()) && ((*z).Sigs[1].MsgIsZero())) +} + +// MarshalMsg implements msgp.Marshaler +func (z *equivocationVoteAuthenticator) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(4) + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + // string "props" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x70, 0x73) + o = msgp.AppendArrayHeader(o, 2) + for zb0002 := range (*z).Proposals { + o, err = (*z).Proposals[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0002) + return + } + } + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o = msgp.AppendArrayHeader(o, 2) + for zb0001 := range (*z).Sigs { + o, err = (*z).Sigs[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0001) + return + } + } + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + return +} + +func (_ *equivocationVoteAuthenticator) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*equivocationVoteAuthenticator) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *equivocationVoteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0005 int + zb0005, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs") + return + } + if zb0005 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0005} + return + } + for zb0001 := 0; zb0001 < zb0005; zb0001++ { + bts, err = (*z).Sigs[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0006 int + zb0006, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals") + return + } + if zb0006 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0006} + return + } + for zb0002 := 0; zb0002 < zb0006; zb0002++ { + bts, err = (*z).Proposals[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = equivocationVoteAuthenticator{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "sig": + var zb0007 int + zb0007, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs") + return + } + if zb0007 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0007} + return + } + for zb0001 := 0; zb0001 < zb0007; zb0001++ { + bts, err = (*z).Sigs[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0001) + return + } + } + case "props": + var zb0008 int + zb0008, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals") + return + } + if zb0008 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0008} + return + } + for zb0002 := 0; zb0002 < zb0008; zb0002++ { + bts, err = (*z).Proposals[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *equivocationVoteAuthenticator) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*equivocationVoteAuthenticator) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *equivocationVoteAuthenticator) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 5 + (*z).Cred.Msgsize() + 4 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Sigs { + s += (*z).Sigs[zb0001].Msgsize() + } + s += 6 + msgp.ArrayHeaderSize + for zb0002 := range (*z).Proposals { + s += (*z).Proposals[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *equivocationVoteAuthenticator) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Cred.MsgIsZero()) && (((*z).Sigs[0].MsgIsZero()) && ((*z).Sigs[1].MsgIsZero())) && (((*z).Proposals[0].MsgIsZero()) && ((*z).Proposals[1].MsgIsZero())) +} + +// MarshalMsg implements msgp.Marshaler +func (z period) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendUint64(o, uint64(z)) + return +} + +func (_ period) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(period) + if !ok { + _, ok = (z).(*period) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *period) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 uint64 + zb0001, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = period(zb0001) + } + o = bts + return +} + +func (_ *period) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*period) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z period) Msgsize() (s int) { + s = msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z period) MsgIsZero() bool { + return z == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z *proposal) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(26) + var zb0001Mask uint32 /* 31 bits */ + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID == "" { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0 { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).unauthenticatedProposal.OriginalPeriod == 0 { + zb0001Len-- + zb0001Mask |= 0x2000 + } + if (*z).unauthenticatedProposal.OriginalProposer.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Branch.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x20000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100000 + } + if (*z).unauthenticatedProposal.SeedProof.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Seed.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter == 0 { + zb0001Len-- + zb0001Mask |= 0x800000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp == 0 { + zb0001Len-- + zb0001Mask |= 0x1000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2000000 + } + if (*z).unauthenticatedProposal.Block.Payset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x20000000 + } + // variable map header, size zb0001Len + o = msgp.AppendMapHeader(o, zb0001Len) + if zb0001Len != 0 { + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue) + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID) + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "nextbefore" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "nextproto" + o = append(o, 0xa9, 0x6e, 0x65, 0x78, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "nextswitch" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "nextyes" + o = append(o, 0xa7, 0x6e, 0x65, 0x78, 0x74, 0x79, 0x65, 0x73) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals) + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "oper" + o = append(o, 0xa4, 0x6f, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).unauthenticatedProposal.OriginalPeriod)) + } + if (zb0001Mask & 0x4000) == 0 { // if not empty + // string "oprop" + o = append(o, 0xa5, 0x6f, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).unauthenticatedProposal.OriginalProposer.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + } + if (zb0001Mask & 0x8000) == 0 { // if not empty + // string "prev" + o = append(o, 0xa4, 0x70, 0x72, 0x65, 0x76) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + } + if (zb0001Mask & 0x10000) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + } + if (zb0001Mask & 0x20000) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate) + } + if (zb0001Mask & 0x40000) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x80000) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x100000) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + if (zb0001Mask & 0x200000) == 0 { // if not empty + // string "sdpf" + o = append(o, 0xa4, 0x73, 0x64, 0x70, 0x66) + o, err = (*z).unauthenticatedProposal.SeedProof.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + } + if (zb0001Mask & 0x400000) == 0 { // if not empty + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + } + if (zb0001Mask & 0x800000) == 0 { // if not empty + // string "tc" + o = append(o, 0xa2, 0x74, 0x63) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter) + } + if (zb0001Mask & 0x1000000) == 0 { // if not empty + // string "ts" + o = append(o, 0xa2, 0x74, 0x73) + o = msgp.AppendInt64(o, (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp) + } + if (zb0001Mask & 0x2000000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + } + if (zb0001Mask & 0x4000000) == 0 { // if not empty + // string "txns" + o = append(o, 0xa4, 0x74, 0x78, 0x6e, 0x73) + o, err = (*z).unauthenticatedProposal.Block.Payset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + } + if (zb0001Mask & 0x8000000) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x10000000) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x20000000) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove) + } + } + return +} + +func (_ *proposal) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*proposal) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *proposal) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Branch") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnRoot") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TimeStamp") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolApprovals") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnCounter") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Payset") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SeedProof") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalPeriod") + return + } + (*z).unauthenticatedProposal.OriginalPeriod = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = proposal{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "prev": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + case "seed": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "txn": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + case "ts": + (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TimeStamp") + return + } + case "gen": + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "fees": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + case "proto": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + case "nextproto": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + case "nextyes": + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolApprovals") + return + } + case "nextbefore": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + case "nextswitch": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + case "upgradeprop": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + case "tc": + (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxnCounter") + return + } + case "txns": + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + case "sdpf": + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + case "oper": + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalPeriod") + return + } + (*z).unauthenticatedProposal.OriginalPeriod = period(zb0004) + } + case "oprop": + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *proposal) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*proposal) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *proposal) Msgsize() (s int) { + s = 3 + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.Round.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.Branch.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.Seed.Msgsize() + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.Msgsize() + 3 + msgp.Int64Size + 4 + msgp.StringPrefixSize + len((*z).unauthenticatedProposal.Block.BlockHeader.GenesisID) + 3 + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.Msgsize() + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.Msgsize() + 6 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.Msgsize() + 10 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.Msgsize() + 8 + msgp.Uint64Size + 11 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.Msgsize() + 11 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.Msgsize() + 12 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.Msgsize() + 13 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + 3 + msgp.Uint64Size + 5 + (*z).unauthenticatedProposal.Block.Payset.Msgsize() + 5 + (*z).unauthenticatedProposal.SeedProof.Msgsize() + 5 + msgp.Uint64Size + 6 + (*z).unauthenticatedProposal.OriginalProposer.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *proposal) MsgIsZero() bool { + return ((*z).unauthenticatedProposal.Block.BlockHeader.Round.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.Branch.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.Seed.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.GenesisID == "") && ((*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove == false) && ((*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter == 0) && ((*z).unauthenticatedProposal.Block.Payset.MsgIsZero()) && ((*z).unauthenticatedProposal.SeedProof.MsgIsZero()) && ((*z).unauthenticatedProposal.OriginalPeriod == 0) && ((*z).unauthenticatedProposal.OriginalProposer.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *proposalValue) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(4) + var zb0001Mask uint8 /* 5 bits */ + if (*z).BlockDigest.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).EncodingDigest.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).OriginalPeriod == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).OriginalProposer.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "dig" + o = append(o, 0xa3, 0x64, 0x69, 0x67) + o, err = (*z).BlockDigest.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "BlockDigest") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "encdig" + o = append(o, 0xa6, 0x65, 0x6e, 0x63, 0x64, 0x69, 0x67) + o, err = (*z).EncodingDigest.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "EncodingDigest") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "oper" + o = append(o, 0xa4, 0x6f, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).OriginalPeriod)) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "oprop" + o = append(o, 0xa5, 0x6f, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).OriginalProposer.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + } + } + return +} + +func (_ *proposalValue) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*proposalValue) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *proposalValue) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalPeriod") + return + } + (*z).OriginalPeriod = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockDigest.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BlockDigest") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).EncodingDigest.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EncodingDigest") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = proposalValue{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "oper": + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalPeriod") + return + } + (*z).OriginalPeriod = period(zb0004) + } + case "oprop": + bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + case "dig": + bts, err = (*z).BlockDigest.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "BlockDigest") + return + } + case "encdig": + bts, err = (*z).EncodingDigest.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "EncodingDigest") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *proposalValue) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*proposalValue) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *proposalValue) Msgsize() (s int) { + s = 1 + 5 + msgp.Uint64Size + 6 + (*z).OriginalProposer.Msgsize() + 4 + (*z).BlockDigest.Msgsize() + 7 + (*z).EncodingDigest.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *proposalValue) MsgIsZero() bool { + return ((*z).OriginalPeriod == 0) && ((*z).OriginalProposer.MsgIsZero()) && ((*z).BlockDigest.MsgIsZero()) && ((*z).EncodingDigest.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *proposerSeed) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "addr" + o = append(o, 0x82, 0xa4, 0x61, 0x64, 0x64, 0x72) + o, err = (*z).Addr.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Addr") + return + } + // string "vrf" + o = append(o, 0xa3, 0x76, 0x72, 0x66) + o, err = (*z).VRF.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VRF") + return + } + return +} + +func (_ *proposerSeed) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*proposerSeed) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *proposerSeed) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Addr.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Addr") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).VRF.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VRF") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = proposerSeed{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "addr": + bts, err = (*z).Addr.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Addr") + return + } + case "vrf": + bts, err = (*z).VRF.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VRF") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *proposerSeed) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*proposerSeed) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *proposerSeed) Msgsize() (s int) { + s = 1 + 5 + (*z).Addr.Msgsize() + 4 + (*z).VRF.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *proposerSeed) MsgIsZero() bool { + return ((*z).Addr.MsgIsZero()) && ((*z).VRF.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *rawVote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(5) + var zb0001Mask uint8 /* 6 bits */ + if (*z).Period == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Proposal.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).Sender.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).Step == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "per" + o = append(o, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "prop" + o = append(o, 0xa4, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).Proposal.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + } + } + return +} + +func (_ *rawVote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*rawVote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *rawVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0004) + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposal") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = rawVote{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0005) + } + case "step": + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0006) + } + case "prop": + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *rawVote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*rawVote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *rawVote) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + (*z).Proposal.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *rawVote) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) && ((*z).Proposal.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *seedInput) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "alpha" + o = append(o, 0x82, 0xa5, 0x61, 0x6c, 0x70, 0x68, 0x61) + o, err = (*z).Alpha.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Alpha") + return + } + // string "hist" + o = append(o, 0xa4, 0x68, 0x69, 0x73, 0x74) + o, err = (*z).History.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "History") + return + } + return +} + +func (_ *seedInput) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*seedInput) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *seedInput) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Alpha.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Alpha") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).History.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "History") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = seedInput{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "alpha": + bts, err = (*z).Alpha.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Alpha") + return + } + case "hist": + bts, err = (*z).History.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "History") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *seedInput) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*seedInput) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *seedInput) Msgsize() (s int) { + s = 1 + 6 + (*z).Alpha.Msgsize() + 5 + (*z).History.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *seedInput) MsgIsZero() bool { + return ((*z).Alpha.MsgIsZero()) && ((*z).History.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *selector) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 4 + // string "per" + o = append(o, 0x84, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + return +} + +func (_ *selector) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*selector) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *selector) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0004) + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = selector{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "seed": + bts, err = (*z).Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0005) + } + case "step": + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0006) + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *selector) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*selector) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *selector) Msgsize() (s int) { + s = 1 + 5 + (*z).Seed.Msgsize() + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *selector) MsgIsZero() bool { + return ((*z).Seed.MsgIsZero()) && ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z serializableErrorUnderlying) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ serializableErrorUnderlying) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(serializableErrorUnderlying) + if !ok { + _, ok = (z).(*serializableErrorUnderlying) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *serializableErrorUnderlying) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = serializableErrorUnderlying(zb0001) + } + o = bts + return +} + +func (_ *serializableErrorUnderlying) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*serializableErrorUnderlying) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z serializableErrorUnderlying) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z serializableErrorUnderlying) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z step) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendUint64(o, uint64(z)) + return +} + +func (_ step) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(step) + if !ok { + _, ok = (z).(*step) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *step) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 uint64 + zb0001, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = step(zb0001) + } + o = bts + return +} + +func (_ *step) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*step) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z step) Msgsize() (s int) { + s = msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z step) MsgIsZero() bool { + return z == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z *transmittedPayload) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(27) + var zb0001Mask uint32 /* 32 bits */ + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID == "" { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0 { + zb0001Len-- + zb0001Mask |= 0x2000 + } + if (*z).unauthenticatedProposal.OriginalPeriod == 0 { + zb0001Len-- + zb0001Mask |= 0x4000 + } + if (*z).unauthenticatedProposal.OriginalProposer.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Branch.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20000 + } + if (*z).PriorVote.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x80000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400000 + } + if (*z).unauthenticatedProposal.SeedProof.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.Seed.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter == 0 { + zb0001Len-- + zb0001Mask |= 0x2000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp == 0 { + zb0001Len-- + zb0001Mask |= 0x4000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000000 + } + if (*z).unauthenticatedProposal.Block.Payset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000000 + } + if (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x80000000 + } + // variable map header, size zb0001Len + o = msgp.AppendMapHeader(o, zb0001Len) + if zb0001Len != 0 { + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue) + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID) + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "nextbefore" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "nextproto" + o = append(o, 0xa9, 0x6e, 0x65, 0x78, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "nextswitch" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "nextyes" + o = append(o, 0xa7, 0x6e, 0x65, 0x78, 0x74, 0x79, 0x65, 0x73) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals) + } + if (zb0001Mask & 0x4000) == 0 { // if not empty + // string "oper" + o = append(o, 0xa4, 0x6f, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).unauthenticatedProposal.OriginalPeriod)) + } + if (zb0001Mask & 0x8000) == 0 { // if not empty + // string "oprop" + o = append(o, 0xa5, 0x6f, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).unauthenticatedProposal.OriginalProposer.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + } + if (zb0001Mask & 0x10000) == 0 { // if not empty + // string "prev" + o = append(o, 0xa4, 0x70, 0x72, 0x65, 0x76) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + } + if (zb0001Mask & 0x20000) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + } + if (zb0001Mask & 0x40000) == 0 { // if not empty + // string "pv" + o = append(o, 0xa2, 0x70, 0x76) + o, err = (*z).PriorVote.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "PriorVote") + return + } + } + if (zb0001Mask & 0x80000) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate) + } + if (zb0001Mask & 0x100000) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x200000) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x400000) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + if (zb0001Mask & 0x800000) == 0 { // if not empty + // string "sdpf" + o = append(o, 0xa4, 0x73, 0x64, 0x70, 0x66) + o, err = (*z).unauthenticatedProposal.SeedProof.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + } + if (zb0001Mask & 0x1000000) == 0 { // if not empty + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + } + if (zb0001Mask & 0x2000000) == 0 { // if not empty + // string "tc" + o = append(o, 0xa2, 0x74, 0x63) + o = msgp.AppendUint64(o, (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter) + } + if (zb0001Mask & 0x4000000) == 0 { // if not empty + // string "ts" + o = append(o, 0xa2, 0x74, 0x73) + o = msgp.AppendInt64(o, (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp) + } + if (zb0001Mask & 0x8000000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + } + if (zb0001Mask & 0x10000000) == 0 { // if not empty + // string "txns" + o = append(o, 0xa4, 0x74, 0x78, 0x6e, 0x73) + o, err = (*z).unauthenticatedProposal.Block.Payset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + } + if (zb0001Mask & 0x20000000) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x40000000) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x80000000) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove) + } + } + return +} + +func (_ *transmittedPayload) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*transmittedPayload) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *transmittedPayload) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Branch") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnRoot") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TimeStamp") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolApprovals") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnCounter") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Payset") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SeedProof") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalPeriod") + return + } + (*z).unauthenticatedProposal.OriginalPeriod = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).PriorVote.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PriorVote") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = transmittedPayload{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "prev": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + case "seed": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "txn": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + case "ts": + (*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TimeStamp") + return + } + case "gen": + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "fees": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + case "proto": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + case "nextproto": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + case "nextyes": + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolApprovals") + return + } + case "nextbefore": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + case "nextswitch": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + case "upgradeprop": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + case "tc": + (*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxnCounter") + return + } + case "txns": + bts, err = (*z).unauthenticatedProposal.Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + case "sdpf": + bts, err = (*z).unauthenticatedProposal.SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + case "oper": + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalPeriod") + return + } + (*z).unauthenticatedProposal.OriginalPeriod = period(zb0004) + } + case "oprop": + bts, err = (*z).unauthenticatedProposal.OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + case "pv": + bts, err = (*z).PriorVote.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "PriorVote") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *transmittedPayload) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*transmittedPayload) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *transmittedPayload) Msgsize() (s int) { + s = 3 + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.Round.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.Branch.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.Seed.Msgsize() + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.Msgsize() + 3 + msgp.Int64Size + 4 + msgp.StringPrefixSize + len((*z).unauthenticatedProposal.Block.BlockHeader.GenesisID) + 3 + (*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.Msgsize() + 5 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.Msgsize() + 4 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.Msgsize() + 6 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.Msgsize() + 10 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.Msgsize() + 8 + msgp.Uint64Size + 11 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.Msgsize() + 11 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.Msgsize() + 12 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.Msgsize() + 13 + (*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + 3 + msgp.Uint64Size + 5 + (*z).unauthenticatedProposal.Block.Payset.Msgsize() + 5 + (*z).unauthenticatedProposal.SeedProof.Msgsize() + 5 + msgp.Uint64Size + 6 + (*z).unauthenticatedProposal.OriginalProposer.Msgsize() + 3 + (*z).PriorVote.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *transmittedPayload) MsgIsZero() bool { + return ((*z).unauthenticatedProposal.Block.BlockHeader.Round.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.Branch.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.Seed.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.TxnRoot.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.TimeStamp == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.GenesisID == "") && ((*z).unauthenticatedProposal.Block.BlockHeader.GenesisHash.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.FeeSink.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsLevel == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRate == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsResidue == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero()) && ((*z).unauthenticatedProposal.Block.BlockHeader.UpgradeVote.UpgradeApprove == false) && ((*z).unauthenticatedProposal.Block.BlockHeader.TxnCounter == 0) && ((*z).unauthenticatedProposal.Block.Payset.MsgIsZero()) && ((*z).unauthenticatedProposal.SeedProof.MsgIsZero()) && ((*z).unauthenticatedProposal.OriginalPeriod == 0) && ((*z).unauthenticatedProposal.OriginalProposer.MsgIsZero()) && ((*z).PriorVote.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *unauthenticatedBundle) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(6) + var zb0003Mask uint8 /* 7 bits */ + if len((*z).EquivocationVotes) == 0 { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).Period == 0 { + zb0003Len-- + zb0003Mask |= 0x4 + } + if (*z).Proposal.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x8 + } + if (*z).Round.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x10 + } + if (*z).Step == 0 { + zb0003Len-- + zb0003Mask |= 0x20 + } + if len((*z).Votes) == 0 { + zb0003Len-- + zb0003Mask |= 0x40 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "eqv" + o = append(o, 0xa3, 0x65, 0x71, 0x76) + if (*z).EquivocationVotes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).EquivocationVotes))) + } + for zb0002 := range (*z).EquivocationVotes { + o, err = (*z).EquivocationVotes[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "per" + o = append(o, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + } + if (zb0003Mask & 0x8) == 0 { // if not empty + // string "prop" + o = append(o, 0xa4, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).Proposal.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + } + if (zb0003Mask & 0x10) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0003Mask & 0x20) == 0 { // if not empty + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + } + if (zb0003Mask & 0x40) == 0 { // if not empty + // string "vote" + o = append(o, 0xa4, 0x76, 0x6f, 0x74, 0x65) + if (*z).Votes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Votes))) + } + for zb0001 := range (*z).Votes { + o, err = (*z).Votes[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + } + } + return +} + +func (_ *unauthenticatedBundle) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedBundle) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *unauthenticatedBundle) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0005) + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0006) + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposal") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0007 int + var zb0008 bool + zb0007, zb0008, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0007 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0007), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "Votes") + return + } + if zb0008 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0007 { + (*z).Votes = ((*z).Votes)[:zb0007] + } else { + (*z).Votes = make([]voteAuthenticator, zb0007) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Votes", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0009 int + var zb0010 bool + zb0009, zb0010, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0009 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0009), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes") + return + } + if zb0010 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0009 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0009] + } else { + (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0009) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "EquivocationVotes", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = unauthenticatedBundle{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0011 uint64 + zb0011, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0011) + } + case "step": + { + var zb0012 uint64 + zb0012, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0012) + } + case "prop": + bts, err = (*z).Proposal.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposal") + return + } + case "vote": + var zb0013 int + var zb0014 bool + zb0013, zb0014, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Votes") + return + } + if zb0013 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0013), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "Votes") + return + } + if zb0014 { + (*z).Votes = nil + } else if (*z).Votes != nil && cap((*z).Votes) >= zb0013 { + (*z).Votes = ((*z).Votes)[:zb0013] + } else { + (*z).Votes = make([]voteAuthenticator, zb0013) + } + for zb0001 := range (*z).Votes { + bts, err = (*z).Votes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Votes", zb0001) + return + } + } + case "eqv": + var zb0015 int + var zb0016 bool + zb0015, zb0016, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0015 > config.MaxVoteThreshold { + err = msgp.ErrOverflow(uint64(zb0015), uint64(config.MaxVoteThreshold)) + err = msgp.WrapError(err, "EquivocationVotes") + return + } + if zb0016 { + (*z).EquivocationVotes = nil + } else if (*z).EquivocationVotes != nil && cap((*z).EquivocationVotes) >= zb0015 { + (*z).EquivocationVotes = ((*z).EquivocationVotes)[:zb0015] + } else { + (*z).EquivocationVotes = make([]equivocationVoteAuthenticator, zb0015) + } + for zb0002 := range (*z).EquivocationVotes { + bts, err = (*z).EquivocationVotes[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "EquivocationVotes", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *unauthenticatedBundle) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedBundle) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *unauthenticatedBundle) Msgsize() (s int) { + s = 1 + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + (*z).Proposal.Msgsize() + 5 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Votes { + s += (*z).Votes[zb0001].Msgsize() + } + s += 4 + msgp.ArrayHeaderSize + for zb0002 := range (*z).EquivocationVotes { + s += (*z).EquivocationVotes[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *unauthenticatedBundle) MsgIsZero() bool { + return ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) && ((*z).Proposal.MsgIsZero()) && (len((*z).Votes) == 0) && (len((*z).EquivocationVotes) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *unauthenticatedEquivocationVote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(7) + var zb0003Mask uint8 /* 8 bits */ + if (*z).Cred.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).Period == 0 { + zb0003Len-- + zb0003Mask |= 0x4 + } + if ((*z).Proposals[0].MsgIsZero()) && ((*z).Proposals[1].MsgIsZero()) { + zb0003Len-- + zb0003Mask |= 0x8 + } + if (*z).Round.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x10 + } + if ((*z).Sigs[0].MsgIsZero()) && ((*z).Sigs[1].MsgIsZero()) { + zb0003Len-- + zb0003Mask |= 0x20 + } + if (*z).Sender.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x40 + } + if (*z).Step == 0 { + zb0003Len-- + zb0003Mask |= 0x80 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "per" + o = append(o, 0xa3, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).Period)) + } + if (zb0003Mask & 0x8) == 0 { // if not empty + // string "props" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x70, 0x73) + o = msgp.AppendArrayHeader(o, 2) + for zb0001 := range (*z).Proposals { + o, err = (*z).Proposals[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0001) + return + } + } + } + if (zb0003Mask & 0x10) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0003Mask & 0x20) == 0 { // if not empty + // string "sigs" + o = append(o, 0xa4, 0x73, 0x69, 0x67, 0x73) + o = msgp.AppendArrayHeader(o, 2) + for zb0002 := range (*z).Sigs { + o, err = (*z).Sigs[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0002) + return + } + } + } + if (zb0003Mask & 0x40) == 0 { // if not empty + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + if (zb0003Mask & 0x80) == 0 { // if not empty + // string "step" + o = append(o, 0xa4, 0x73, 0x74, 0x65, 0x70) + o = msgp.AppendUint64(o, uint64((*z).Step)) + } + } + return +} + +func (_ *unauthenticatedEquivocationVote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedEquivocationVote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *unauthenticatedEquivocationVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0005 uint64 + zb0005, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Period") + return + } + (*z).Period = period(zb0005) + } + } + if zb0003 > 0 { + zb0003-- + { + var zb0006 uint64 + zb0006, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Step") + return + } + (*z).Step = step(zb0006) + } + } + if zb0003 > 0 { + zb0003-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0003 > 0 { + zb0003-- + var zb0007 int + zb0007, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals") + return + } + if zb0007 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0007} + return + } + for zb0001 := 0; zb0001 < zb0007; zb0001++ { + bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proposals", zb0001) + return + } + } + } + if zb0003 > 0 { + zb0003-- + var zb0008 int + zb0008, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs") + return + } + if zb0008 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0008} + return + } + for zb0002 := 0; zb0002 < zb0008; zb0002++ { + bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sigs", zb0002) + return + } + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = unauthenticatedEquivocationVote{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "per": + { + var zb0009 uint64 + zb0009, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Period") + return + } + (*z).Period = period(zb0009) + } + case "step": + { + var zb0010 uint64 + zb0010, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Step") + return + } + (*z).Step = step(zb0010) + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "props": + var zb0011 int + zb0011, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals") + return + } + if zb0011 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0011} + return + } + for zb0001 := 0; zb0001 < zb0011; zb0001++ { + bts, err = (*z).Proposals[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proposals", zb0001) + return + } + } + case "sigs": + var zb0012 int + zb0012, _, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs") + return + } + if zb0012 > 2 { + err = msgp.ArrayError{Wanted: 2, Got: zb0012} + return + } + for zb0002 := 0; zb0002 < zb0012; zb0002++ { + bts, err = (*z).Sigs[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sigs", zb0002) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *unauthenticatedEquivocationVote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedEquivocationVote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *unauthenticatedEquivocationVote) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 4 + (*z).Round.Msgsize() + 4 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + (*z).Cred.Msgsize() + 6 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Proposals { + s += (*z).Proposals[zb0001].Msgsize() + } + s += 5 + msgp.ArrayHeaderSize + for zb0002 := range (*z).Sigs { + s += (*z).Sigs[zb0002].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *unauthenticatedEquivocationVote) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Round.MsgIsZero()) && ((*z).Period == 0) && ((*z).Step == 0) && ((*z).Cred.MsgIsZero()) && (((*z).Proposals[0].MsgIsZero()) && ((*z).Proposals[1].MsgIsZero())) && (((*z).Sigs[0].MsgIsZero()) && ((*z).Sigs[1].MsgIsZero())) +} + +// MarshalMsg implements msgp.Marshaler +func (z *unauthenticatedProposal) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(26) + var zb0001Mask uint32 /* 30 bits */ + if (*z).Block.BlockHeader.RewardsState.RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).Block.BlockHeader.RewardsState.FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).Block.BlockHeader.RewardsState.RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).Block.BlockHeader.GenesisID == "" { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).Block.BlockHeader.GenesisHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0 { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).OriginalPeriod == 0 { + zb0001Len-- + zb0001Mask |= 0x2000 + } + if (*z).OriginalProposer.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4000 + } + if (*z).Block.BlockHeader.Branch.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000 + } + if (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000 + } + if (*z).Block.BlockHeader.RewardsState.RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x20000 + } + if (*z).Block.BlockHeader.Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000 + } + if (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80000 + } + if (*z).Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100000 + } + if (*z).SeedProof.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200000 + } + if (*z).Block.BlockHeader.Seed.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400000 + } + if (*z).Block.BlockHeader.TxnCounter == 0 { + zb0001Len-- + zb0001Mask |= 0x800000 + } + if (*z).Block.BlockHeader.TimeStamp == 0 { + zb0001Len-- + zb0001Mask |= 0x1000000 + } + if (*z).Block.BlockHeader.TxnRoot.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2000000 + } + if (*z).Block.Payset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4000000 + } + if (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000000 + } + if (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000000 + } + if (*z).Block.BlockHeader.UpgradeVote.UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x20000000 + } + // variable map header, size zb0001Len + o = msgp.AppendMapHeader(o, zb0001Len) + if zb0001Len != 0 { + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).Block.BlockHeader.RewardsState.RewardsLevel) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).Block.BlockHeader.RewardsState.FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).Block.BlockHeader.RewardsState.RewardsResidue) + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).Block.BlockHeader.GenesisID) + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).Block.BlockHeader.GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "nextbefore" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65) + o, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "nextproto" + o = append(o, 0xa9, 0x6e, 0x65, 0x78, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "nextswitch" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68) + o, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "nextyes" + o = append(o, 0xa7, 0x6e, 0x65, 0x78, 0x74, 0x79, 0x65, 0x73) + o = msgp.AppendUint64(o, (*z).Block.BlockHeader.UpgradeState.NextProtocolApprovals) + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "oper" + o = append(o, 0xa4, 0x6f, 0x70, 0x65, 0x72) + o = msgp.AppendUint64(o, uint64((*z).OriginalPeriod)) + } + if (zb0001Mask & 0x4000) == 0 { // if not empty + // string "oprop" + o = append(o, 0xa5, 0x6f, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).OriginalProposer.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + } + if (zb0001Mask & 0x8000) == 0 { // if not empty + // string "prev" + o = append(o, 0xa4, 0x70, 0x72, 0x65, 0x76) + o, err = (*z).Block.BlockHeader.Branch.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + } + if (zb0001Mask & 0x10000) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + } + if (zb0001Mask & 0x20000) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).Block.BlockHeader.RewardsState.RewardsRate) + } + if (zb0001Mask & 0x40000) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Block.BlockHeader.Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x80000) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x100000) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + if (zb0001Mask & 0x200000) == 0 { // if not empty + // string "sdpf" + o = append(o, 0xa4, 0x73, 0x64, 0x70, 0x66) + o, err = (*z).SeedProof.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + } + if (zb0001Mask & 0x400000) == 0 { // if not empty + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).Block.BlockHeader.Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + } + if (zb0001Mask & 0x800000) == 0 { // if not empty + // string "tc" + o = append(o, 0xa2, 0x74, 0x63) + o = msgp.AppendUint64(o, (*z).Block.BlockHeader.TxnCounter) + } + if (zb0001Mask & 0x1000000) == 0 { // if not empty + // string "ts" + o = append(o, 0xa2, 0x74, 0x73) + o = msgp.AppendInt64(o, (*z).Block.BlockHeader.TimeStamp) + } + if (zb0001Mask & 0x2000000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).Block.BlockHeader.TxnRoot.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + } + if (zb0001Mask & 0x4000000) == 0 { // if not empty + // string "txns" + o = append(o, 0xa4, 0x74, 0x78, 0x6e, 0x73) + o, err = (*z).Block.Payset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + } + if (zb0001Mask & 0x8000000) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x10000000) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x20000000) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).Block.BlockHeader.UpgradeVote.UpgradeApprove) + } + } + return +} + +func (_ *unauthenticatedProposal) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedProposal) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *unauthenticatedProposal) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Branch") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnRoot") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TimeStamp") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolApprovals") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnCounter") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Payset") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SeedProof") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 uint64 + zb0003, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalPeriod") + return + } + (*z).OriginalPeriod = period(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OriginalProposer") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = unauthenticatedProposal{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).Block.BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "prev": + bts, err = (*z).Block.BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + case "seed": + bts, err = (*z).Block.BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "txn": + bts, err = (*z).Block.BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + case "ts": + (*z).Block.BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TimeStamp") + return + } + case "gen": + (*z).Block.BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).Block.BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "fees": + bts, err = (*z).Block.BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).Block.BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).Block.BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).Block.BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + case "proto": + bts, err = (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + case "nextproto": + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + case "nextyes": + (*z).Block.BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolApprovals") + return + } + case "nextbefore": + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + case "nextswitch": + bts, err = (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + case "upgradeprop": + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).Block.BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + case "tc": + (*z).Block.BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxnCounter") + return + } + case "txns": + bts, err = (*z).Block.Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + case "sdpf": + bts, err = (*z).SeedProof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SeedProof") + return + } + case "oper": + { + var zb0004 uint64 + zb0004, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalPeriod") + return + } + (*z).OriginalPeriod = period(zb0004) + } + case "oprop": + bts, err = (*z).OriginalProposer.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "OriginalProposer") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *unauthenticatedProposal) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedProposal) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *unauthenticatedProposal) Msgsize() (s int) { + s = 3 + 4 + (*z).Block.BlockHeader.Round.Msgsize() + 5 + (*z).Block.BlockHeader.Branch.Msgsize() + 5 + (*z).Block.BlockHeader.Seed.Msgsize() + 4 + (*z).Block.BlockHeader.TxnRoot.Msgsize() + 3 + msgp.Int64Size + 4 + msgp.StringPrefixSize + len((*z).Block.BlockHeader.GenesisID) + 3 + (*z).Block.BlockHeader.GenesisHash.Msgsize() + 5 + (*z).Block.BlockHeader.RewardsState.FeeSink.Msgsize() + 4 + (*z).Block.BlockHeader.RewardsState.RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.Msgsize() + 6 + (*z).Block.BlockHeader.UpgradeState.CurrentProtocol.Msgsize() + 10 + (*z).Block.BlockHeader.UpgradeState.NextProtocol.Msgsize() + 8 + msgp.Uint64Size + 11 + (*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.Msgsize() + 11 + (*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.Msgsize() + 12 + (*z).Block.BlockHeader.UpgradeVote.UpgradePropose.Msgsize() + 13 + (*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + 3 + msgp.Uint64Size + 5 + (*z).Block.Payset.Msgsize() + 5 + (*z).SeedProof.Msgsize() + 5 + msgp.Uint64Size + 6 + (*z).OriginalProposer.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *unauthenticatedProposal) MsgIsZero() bool { + return ((*z).Block.BlockHeader.Round.MsgIsZero()) && ((*z).Block.BlockHeader.Branch.MsgIsZero()) && ((*z).Block.BlockHeader.Seed.MsgIsZero()) && ((*z).Block.BlockHeader.TxnRoot.MsgIsZero()) && ((*z).Block.BlockHeader.TimeStamp == 0) && ((*z).Block.BlockHeader.GenesisID == "") && ((*z).Block.BlockHeader.GenesisHash.MsgIsZero()) && ((*z).Block.BlockHeader.RewardsState.FeeSink.MsgIsZero()) && ((*z).Block.BlockHeader.RewardsState.RewardsPool.MsgIsZero()) && ((*z).Block.BlockHeader.RewardsState.RewardsLevel == 0) && ((*z).Block.BlockHeader.RewardsState.RewardsRate == 0) && ((*z).Block.BlockHeader.RewardsState.RewardsResidue == 0) && ((*z).Block.BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeState.NextProtocol.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeState.NextProtocolApprovals == 0) && ((*z).Block.BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero()) && ((*z).Block.BlockHeader.UpgradeVote.UpgradeApprove == false) && ((*z).Block.BlockHeader.TxnCounter == 0) && ((*z).Block.Payset.MsgIsZero()) && ((*z).SeedProof.MsgIsZero()) && ((*z).OriginalPeriod == 0) && ((*z).OriginalProposer.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *unauthenticatedVote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).Cred.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).R.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "r" + o = append(o, 0xa1, 0x72) + o, err = (*z).R.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "R") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *unauthenticatedVote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedVote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *unauthenticatedVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).R.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "R") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = unauthenticatedVote{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "r": + bts, err = (*z).R.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "R") + return + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *unauthenticatedVote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*unauthenticatedVote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *unauthenticatedVote) Msgsize() (s int) { + s = 1 + 2 + (*z).R.Msgsize() + 5 + (*z).Cred.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *unauthenticatedVote) MsgIsZero() bool { + return ((*z).R.MsgIsZero()) && ((*z).Cred.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *vote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).Cred.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).R.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "r" + o = append(o, 0xa1, 0x72) + o, err = (*z).R.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "R") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *vote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*vote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *vote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).R.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "R") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = vote{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "r": + bts, err = (*z).R.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "R") + return + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *vote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*vote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *vote) Msgsize() (s int) { + s = 1 + 2 + (*z).R.Msgsize() + 5 + (*z).Cred.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *vote) MsgIsZero() bool { + return ((*z).R.MsgIsZero()) && ((*z).Cred.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *voteAuthenticator) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + // string "cred" + o = append(o, 0xa4, 0x63, 0x72, 0x65, 0x64) + o, err = (*z).Cred.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + return +} + +func (_ *voteAuthenticator) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*voteAuthenticator) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *voteAuthenticator) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cred") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = voteAuthenticator{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "cred": + bts, err = (*z).Cred.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Cred") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *voteAuthenticator) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*voteAuthenticator) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *voteAuthenticator) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 5 + (*z).Cred.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *voteAuthenticator) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Cred.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} diff --git a/agreement/msgp_gen_test.go b/agreement/msgp_gen_test.go new file mode 100644 index 0000000000..84371a6391 --- /dev/null +++ b/agreement/msgp_gen_test.go @@ -0,0 +1,1064 @@ +package agreement + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalCertificate(t *testing.T) { + v := Certificate{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingCertificate(t *testing.T) { + protocol.RunEncodingTest(t, &Certificate{}) +} + +func BenchmarkMarshalMsgCertificate(b *testing.B) { + v := Certificate{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgCertificate(b *testing.B) { + v := Certificate{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalCertificate(b *testing.B) { + v := Certificate{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalbundle(t *testing.T) { + v := bundle{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingbundle(t *testing.T) { + protocol.RunEncodingTest(t, &bundle{}) +} + +func BenchmarkMarshalMsgbundle(b *testing.B) { + v := bundle{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgbundle(b *testing.B) { + v := bundle{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalbundle(b *testing.B) { + v := bundle{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalequivocationVote(t *testing.T) { + v := equivocationVote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingequivocationVote(t *testing.T) { + protocol.RunEncodingTest(t, &equivocationVote{}) +} + +func BenchmarkMarshalMsgequivocationVote(b *testing.B) { + v := equivocationVote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgequivocationVote(b *testing.B) { + v := equivocationVote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalequivocationVote(b *testing.B) { + v := equivocationVote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalequivocationVoteAuthenticator(t *testing.T) { + v := equivocationVoteAuthenticator{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingequivocationVoteAuthenticator(t *testing.T) { + protocol.RunEncodingTest(t, &equivocationVoteAuthenticator{}) +} + +func BenchmarkMarshalMsgequivocationVoteAuthenticator(b *testing.B) { + v := equivocationVoteAuthenticator{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgequivocationVoteAuthenticator(b *testing.B) { + v := equivocationVoteAuthenticator{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalequivocationVoteAuthenticator(b *testing.B) { + v := equivocationVoteAuthenticator{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalproposal(t *testing.T) { + v := proposal{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingproposal(t *testing.T) { + protocol.RunEncodingTest(t, &proposal{}) +} + +func BenchmarkMarshalMsgproposal(b *testing.B) { + v := proposal{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgproposal(b *testing.B) { + v := proposal{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalproposal(b *testing.B) { + v := proposal{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalproposalValue(t *testing.T) { + v := proposalValue{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingproposalValue(t *testing.T) { + protocol.RunEncodingTest(t, &proposalValue{}) +} + +func BenchmarkMarshalMsgproposalValue(b *testing.B) { + v := proposalValue{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgproposalValue(b *testing.B) { + v := proposalValue{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalproposalValue(b *testing.B) { + v := proposalValue{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalproposerSeed(t *testing.T) { + v := proposerSeed{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingproposerSeed(t *testing.T) { + protocol.RunEncodingTest(t, &proposerSeed{}) +} + +func BenchmarkMarshalMsgproposerSeed(b *testing.B) { + v := proposerSeed{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgproposerSeed(b *testing.B) { + v := proposerSeed{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalproposerSeed(b *testing.B) { + v := proposerSeed{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalrawVote(t *testing.T) { + v := rawVote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingrawVote(t *testing.T) { + protocol.RunEncodingTest(t, &rawVote{}) +} + +func BenchmarkMarshalMsgrawVote(b *testing.B) { + v := rawVote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgrawVote(b *testing.B) { + v := rawVote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalrawVote(b *testing.B) { + v := rawVote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalseedInput(t *testing.T) { + v := seedInput{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingseedInput(t *testing.T) { + protocol.RunEncodingTest(t, &seedInput{}) +} + +func BenchmarkMarshalMsgseedInput(b *testing.B) { + v := seedInput{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgseedInput(b *testing.B) { + v := seedInput{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalseedInput(b *testing.B) { + v := seedInput{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalselector(t *testing.T) { + v := selector{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingselector(t *testing.T) { + protocol.RunEncodingTest(t, &selector{}) +} + +func BenchmarkMarshalMsgselector(b *testing.B) { + v := selector{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgselector(b *testing.B) { + v := selector{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalselector(b *testing.B) { + v := selector{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshaltransmittedPayload(t *testing.T) { + v := transmittedPayload{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingtransmittedPayload(t *testing.T) { + protocol.RunEncodingTest(t, &transmittedPayload{}) +} + +func BenchmarkMarshalMsgtransmittedPayload(b *testing.B) { + v := transmittedPayload{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgtransmittedPayload(b *testing.B) { + v := transmittedPayload{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshaltransmittedPayload(b *testing.B) { + v := transmittedPayload{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalunauthenticatedBundle(t *testing.T) { + v := unauthenticatedBundle{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingunauthenticatedBundle(t *testing.T) { + protocol.RunEncodingTest(t, &unauthenticatedBundle{}) +} + +func BenchmarkMarshalMsgunauthenticatedBundle(b *testing.B) { + v := unauthenticatedBundle{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgunauthenticatedBundle(b *testing.B) { + v := unauthenticatedBundle{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalunauthenticatedBundle(b *testing.B) { + v := unauthenticatedBundle{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalunauthenticatedEquivocationVote(t *testing.T) { + v := unauthenticatedEquivocationVote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingunauthenticatedEquivocationVote(t *testing.T) { + protocol.RunEncodingTest(t, &unauthenticatedEquivocationVote{}) +} + +func BenchmarkMarshalMsgunauthenticatedEquivocationVote(b *testing.B) { + v := unauthenticatedEquivocationVote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgunauthenticatedEquivocationVote(b *testing.B) { + v := unauthenticatedEquivocationVote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalunauthenticatedEquivocationVote(b *testing.B) { + v := unauthenticatedEquivocationVote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalunauthenticatedProposal(t *testing.T) { + v := unauthenticatedProposal{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingunauthenticatedProposal(t *testing.T) { + protocol.RunEncodingTest(t, &unauthenticatedProposal{}) +} + +func BenchmarkMarshalMsgunauthenticatedProposal(b *testing.B) { + v := unauthenticatedProposal{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgunauthenticatedProposal(b *testing.B) { + v := unauthenticatedProposal{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalunauthenticatedProposal(b *testing.B) { + v := unauthenticatedProposal{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalunauthenticatedVote(t *testing.T) { + v := unauthenticatedVote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingunauthenticatedVote(t *testing.T) { + protocol.RunEncodingTest(t, &unauthenticatedVote{}) +} + +func BenchmarkMarshalMsgunauthenticatedVote(b *testing.B) { + v := unauthenticatedVote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgunauthenticatedVote(b *testing.B) { + v := unauthenticatedVote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalunauthenticatedVote(b *testing.B) { + v := unauthenticatedVote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalvote(t *testing.T) { + v := vote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingvote(t *testing.T) { + protocol.RunEncodingTest(t, &vote{}) +} + +func BenchmarkMarshalMsgvote(b *testing.B) { + v := vote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgvote(b *testing.B) { + v := vote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalvote(b *testing.B) { + v := vote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalvoteAuthenticator(t *testing.T) { + v := voteAuthenticator{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingvoteAuthenticator(t *testing.T) { + protocol.RunEncodingTest(t, &voteAuthenticator{}) +} + +func BenchmarkMarshalMsgvoteAuthenticator(b *testing.B) { + v := voteAuthenticator{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgvoteAuthenticator(b *testing.B) { + v := voteAuthenticator{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalvoteAuthenticator(b *testing.B) { + v := voteAuthenticator{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/agreement/proposal.go b/agreement/proposal.go index 38df0f8f6d..84cbfe7fa8 100644 --- a/agreement/proposal.go +++ b/agreement/proposal.go @@ -103,6 +103,8 @@ func (p proposal) u() unauthenticatedProposal { // A proposerSeed is a Hashable input to proposer seed derivation. type proposerSeed struct { + _struct struct{} `codec:""` // not omitempty + Addr basics.Address `codec:"addr"` VRF crypto.VrfOutput `codec:"vrf"` } @@ -114,6 +116,8 @@ func (s proposerSeed) ToBeHashed() (protocol.HashID, []byte) { // A seedInput is a Hashable input to seed rerandomization. type seedInput struct { + _struct struct{} `codec:""` // not omitempty + Alpha crypto.Digest `codec:"alpha"` History crypto.Digest `codec:"hist"` } diff --git a/agreement/pseudonode.go b/agreement/pseudonode.go index 735e884cb5..db7bf10ea2 100644 --- a/agreement/pseudonode.go +++ b/agreement/pseudonode.go @@ -115,6 +115,7 @@ type pseudonodeVerifier struct { incomingTasks chan pseudonodeTask } +//msgp:ignore verifiedCryptoResults type verifiedCryptoResults []asyncVerifyVoteResponse func makePseudonode(factory BlockFactory, validator BlockValidator, keys KeyManager, ledger Ledger, voteVerifier *AsyncVoteVerifier, log serviceLogger) pseudonode { diff --git a/agreement/router.go b/agreement/router.go index ea26462ed3..ba8d4092eb 100644 --- a/agreement/router.go +++ b/agreement/router.go @@ -19,6 +19,7 @@ package agreement // A stateMachineTag uniquely identifies the type of a state machine. // // Rounds, periods, and steps may be used to further identify different state machine instances of the same type. +//msgp:ignore stateMachineTag type stateMachineTag int //go:generate stringer -type=stateMachineTag diff --git a/agreement/selector.go b/agreement/selector.go index f081db1e2b..9d7c535c0d 100644 --- a/agreement/selector.go +++ b/agreement/selector.go @@ -28,6 +28,8 @@ import ( // A Selector is the input used to define proposers and members of voting // committees. type selector struct { + _struct struct{} `codec:""` // not omitempty + Seed committee.Seed `codec:"seed"` Round basics.Round `codec:"rnd"` Period period `codec:"per"` diff --git a/agreement/trace.go b/agreement/trace.go index cec9301f61..f343be96c6 100644 --- a/agreement/trace.go +++ b/agreement/trace.go @@ -29,6 +29,7 @@ import ( "github.com/algorand/go-algorand/logging/telemetryspec" ) +//msgp:ignore traceLevel type traceLevel int const ( diff --git a/agreement/voteAuxiliary.go b/agreement/voteAuxiliary.go index 2f03ad332d..c224b815c5 100644 --- a/agreement/voteAuxiliary.go +++ b/agreement/voteAuxiliary.go @@ -25,7 +25,7 @@ import ( type voteTrackerPeriod struct { // Make it explicit that we are serializing player fields for crash recovery; // we should probably adopt this convention over the rest of player at some point. - Cached nextThresholdStatusEvent `codec:"cached"` + Cached nextThresholdStatusEvent } func (t *voteTrackerPeriod) T() stateMachineTag { diff --git a/auction/messages.go b/auction/messages.go index 9c6a4419d7..ea9dcfbc93 100644 --- a/auction/messages.go +++ b/auction/messages.go @@ -74,7 +74,7 @@ type Deposit struct { // ToBeHashed implements the crypto.Hashable interface. func (d Deposit) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AuctionDeposit, protocol.Encode(d) + return protocol.AuctionDeposit, protocol.Encode(&d) } // WinningAddress returns the effective winning address @@ -129,7 +129,7 @@ type Bid struct { // ToBeHashed implements the crypto.Hashable interface. func (b Bid) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AuctionBid, protocol.Encode(b) + return protocol.AuctionBid, protocol.Encode(&b) } // SignedBid represents a signed bid by a bidder. @@ -184,12 +184,12 @@ type BidOutcomes struct { // Outcomes is a list of bid outcomes, one for every placed bid // in the auction. - Outcomes []BidderOutcome `codec:"outcomes"` + Outcomes []BidderOutcome `codec:"outcomes,allocbound=-"` } // ToBeHashed implements the crypto.Hashable interface. func (o BidOutcomes) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AuctionOutcomes, protocol.Encode(o) + return protocol.AuctionOutcomes, protocol.Encode(&o) } // Settlement describes the outcome of an auction. @@ -218,7 +218,7 @@ type Settlement struct { // ToBeHashed implements the crypto.Hashable interface. func (s Settlement) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AuctionSettlement, protocol.Encode(s) + return protocol.AuctionSettlement, protocol.Encode(&s) } // SignedSettlement is a settlement signed by the auction operator @@ -303,7 +303,7 @@ type Params struct { // ToBeHashed implements the crypto.Hashable interface. func (p Params) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AuctionParams, protocol.Encode(p) + return protocol.AuctionParams, protocol.Encode(&p) } // SignedParams is a signed statement by the auction operator attesting diff --git a/auction/msgp_gen.go b/auction/msgp_gen.go new file mode 100644 index 0000000000..2c8afc131a --- /dev/null +++ b/auction/msgp_gen.go @@ -0,0 +1,3408 @@ +package auction + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Bid) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(6) + var zb0001Mask uint8 /* 7 bits */ + if (*z).AuctionID == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).AuctionKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).BidderKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).BidCurrency == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).BidID == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).MaxPrice == 0 { + zb0001Len-- + zb0001Mask |= 0x40 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "aid" + o = append(o, 0xa3, 0x61, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).AuctionID) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "auc" + o = append(o, 0xa3, 0x61, 0x75, 0x63) + o, err = (*z).AuctionKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "bidder" + o = append(o, 0xa6, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72) + o, err = (*z).BidderKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "cur" + o = append(o, 0xa3, 0x63, 0x75, 0x72) + o = msgp.AppendUint64(o, (*z).BidCurrency) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "id" + o = append(o, 0xa2, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).BidID) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "price" + o = append(o, 0xa5, 0x70, 0x72, 0x69, 0x63, 0x65) + o = msgp.AppendUint64(o, (*z).MaxPrice) + } + } + return +} + +func (_ *Bid) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Bid) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Bid) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidderKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BidCurrency, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidCurrency") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).MaxPrice, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MaxPrice") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BidID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionID") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Bid{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "bidder": + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + case "cur": + (*z).BidCurrency, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "BidCurrency") + return + } + case "price": + (*z).MaxPrice, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "MaxPrice") + return + } + case "id": + (*z).BidID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "BidID") + return + } + case "auc": + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + case "aid": + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionID") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Bid) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Bid) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Bid) Msgsize() (s int) { + s = 1 + 7 + (*z).BidderKey.Msgsize() + 4 + msgp.Uint64Size + 6 + msgp.Uint64Size + 3 + msgp.Uint64Size + 4 + (*z).AuctionKey.Msgsize() + 4 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Bid) MsgIsZero() bool { + return ((*z).BidderKey.MsgIsZero()) && ((*z).BidCurrency == 0) && ((*z).MaxPrice == 0) && ((*z).BidID == 0) && ((*z).AuctionKey.MsgIsZero()) && ((*z).AuctionID == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *BidOutcomes) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(5) + var zb0002Mask uint8 /* 6 bits */ + if (*z).AuctionID == 0 { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).AuctionKey.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).Cleared == false { + zb0002Len-- + zb0002Mask |= 0x8 + } + if len((*z).Outcomes) == 0 { + zb0002Len-- + zb0002Mask |= 0x10 + } + if (*z).Price == 0 { + zb0002Len-- + zb0002Mask |= 0x20 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "aid" + o = append(o, 0xa3, 0x61, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).AuctionID) + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "auc" + o = append(o, 0xa3, 0x61, 0x75, 0x63) + o, err = (*z).AuctionKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "cleared" + o = append(o, 0xa7, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x65, 0x64) + o = msgp.AppendBool(o, (*z).Cleared) + } + if (zb0002Mask & 0x10) == 0 { // if not empty + // string "outcomes" + o = append(o, 0xa8, 0x6f, 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x73) + if (*z).Outcomes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Outcomes))) + } + for zb0001 := range (*z).Outcomes { + o, err = (*z).Outcomes[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Outcomes", zb0001) + return + } + } + } + if (zb0002Mask & 0x20) == 0 { // if not empty + // string "price" + o = append(o, 0xa5, 0x70, 0x72, 0x69, 0x63, 0x65) + o = msgp.AppendUint64(o, (*z).Price) + } + } + return +} + +func (_ *BidOutcomes) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*BidOutcomes) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BidOutcomes) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionKey") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionID") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Price, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Price") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Cleared, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cleared") + return + } + } + if zb0002 > 0 { + zb0002-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Outcomes") + return + } + if zb0005 { + (*z).Outcomes = nil + } else if (*z).Outcomes != nil && cap((*z).Outcomes) >= zb0004 { + (*z).Outcomes = ((*z).Outcomes)[:zb0004] + } else { + (*z).Outcomes = make([]BidderOutcome, zb0004) + } + for zb0001 := range (*z).Outcomes { + bts, err = (*z).Outcomes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Outcomes", zb0001) + return + } + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = BidOutcomes{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "auc": + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + case "aid": + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionID") + return + } + case "price": + (*z).Price, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Price") + return + } + case "cleared": + (*z).Cleared, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Cleared") + return + } + case "outcomes": + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Outcomes") + return + } + if zb0007 { + (*z).Outcomes = nil + } else if (*z).Outcomes != nil && cap((*z).Outcomes) >= zb0006 { + (*z).Outcomes = ((*z).Outcomes)[:zb0006] + } else { + (*z).Outcomes = make([]BidderOutcome, zb0006) + } + for zb0001 := range (*z).Outcomes { + bts, err = (*z).Outcomes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Outcomes", zb0001) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *BidOutcomes) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*BidOutcomes) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *BidOutcomes) Msgsize() (s int) { + s = 1 + 4 + (*z).AuctionKey.Msgsize() + 4 + msgp.Uint64Size + 6 + msgp.Uint64Size + 8 + msgp.BoolSize + 9 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Outcomes { + s += (*z).Outcomes[zb0001].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *BidOutcomes) MsgIsZero() bool { + return ((*z).AuctionKey.MsgIsZero()) && ((*z).AuctionID == 0) && ((*z).Price == 0) && ((*z).Cleared == false) && (len((*z).Outcomes) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *BidderOutcome) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(4) + var zb0001Mask uint8 /* 5 bits */ + if (*z).AlgosWon == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).BidID == 0 { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).BidderKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).WinningsAddress.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "alg" + o = append(o, 0xa3, 0x61, 0x6c, 0x67) + o = msgp.AppendUint64(o, (*z).AlgosWon) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "id" + o = append(o, 0xa2, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).BidID) + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "key" + o = append(o, 0xa3, 0x6b, 0x65, 0x79) + o, err = (*z).BidderKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "out" + o = append(o, 0xa3, 0x6f, 0x75, 0x74) + o, err = (*z).WinningsAddress.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "WinningsAddress") + return + } + } + } + return +} + +func (_ *BidderOutcome) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*BidderOutcome) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BidderOutcome) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidderKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AlgosWon, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AlgosWon") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).WinningsAddress.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "WinningsAddress") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BidID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidID") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = BidderOutcome{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "key": + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + case "alg": + (*z).AlgosWon, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AlgosWon") + return + } + case "out": + bts, err = (*z).WinningsAddress.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "WinningsAddress") + return + } + case "id": + (*z).BidID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "BidID") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *BidderOutcome) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*BidderOutcome) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *BidderOutcome) Msgsize() (s int) { + s = 1 + 4 + (*z).BidderKey.Msgsize() + 4 + msgp.Uint64Size + 4 + (*z).WinningsAddress.Msgsize() + 3 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *BidderOutcome) MsgIsZero() bool { + return ((*z).BidderKey.MsgIsZero()) && ((*z).AlgosWon == 0) && ((*z).WinningsAddress.MsgIsZero()) && ((*z).BidID == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Deposit) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(6) + var zb0001Mask uint8 /* 7 bits */ + if (*z).AuctionID == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).AuctionKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Currency == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).DepositID == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).BidderKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).WinningsAddress.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "aid" + o = append(o, 0xa3, 0x61, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).AuctionID) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "auc" + o = append(o, 0xa3, 0x61, 0x75, 0x63) + o, err = (*z).AuctionKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "cur" + o = append(o, 0xa3, 0x63, 0x75, 0x72) + o = msgp.AppendUint64(o, (*z).Currency) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "did" + o = append(o, 0xa3, 0x64, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).DepositID) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "key" + o = append(o, 0xa3, 0x6b, 0x65, 0x79) + o, err = (*z).BidderKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "out" + o = append(o, 0xa3, 0x6f, 0x75, 0x74) + o, err = (*z).WinningsAddress.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "WinningsAddress") + return + } + } + } + return +} + +func (_ *Deposit) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Deposit) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Deposit) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BidderKey") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).WinningsAddress.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "WinningsAddress") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Currency, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Currency") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionID") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).DepositID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "DepositID") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Deposit{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "key": + bts, err = (*z).BidderKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "BidderKey") + return + } + case "out": + bts, err = (*z).WinningsAddress.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "WinningsAddress") + return + } + case "cur": + (*z).Currency, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Currency") + return + } + case "auc": + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + case "aid": + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionID") + return + } + case "did": + (*z).DepositID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "DepositID") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Deposit) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Deposit) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Deposit) Msgsize() (s int) { + s = 1 + 4 + (*z).BidderKey.Msgsize() + 4 + (*z).WinningsAddress.Msgsize() + 4 + msgp.Uint64Size + 4 + (*z).AuctionKey.Msgsize() + 4 + msgp.Uint64Size + 4 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Deposit) MsgIsZero() bool { + return ((*z).BidderKey.MsgIsZero()) && ((*z).WinningsAddress.MsgIsZero()) && ((*z).Currency == 0) && ((*z).AuctionKey.MsgIsZero()) && ((*z).AuctionID == 0) && ((*z).DepositID == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *MasterInput) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(4) + var zb0001Mask uint8 /* 5 bits */ + if ((*z).SignedBid.Bid.MsgIsZero()) && ((*z).SignedBid.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x2 + } + if ((*z).SignedDeposit.Deposit.MsgIsZero()) && ((*z).SignedDeposit.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Round == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).Type == "" { + zb0001Len-- + zb0001Mask |= 0x10 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "b" + o = append(o, 0xa1, 0x62) + // omitempty: check for empty values + zb0002Len := uint32(2) + var zb0002Mask uint8 /* 3 bits */ + if (*z).SignedBid.Bid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).SignedBid.Sig.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x4 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "bid" + o = append(o, 0xa3, 0x62, 0x69, 0x64) + o, err = (*z).SignedBid.Bid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Bid") + return + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedBid.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Sig") + return + } + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "d" + o = append(o, 0xa1, 0x64) + // omitempty: check for empty values + zb0003Len := uint32(2) + var zb0003Mask uint8 /* 3 bits */ + if (*z).SignedDeposit.Deposit.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).SignedDeposit.Sig.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x4 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "dep" + o = append(o, 0xa3, 0x64, 0x65, 0x70) + o, err = (*z).SignedDeposit.Deposit.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Deposit") + return + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedDeposit.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Sig") + return + } + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o = msgp.AppendUint64(o, (*z).Round) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "t" + o = append(o, 0xa1, 0x74) + o = msgp.AppendString(o, string((*z).Type)) + } + } + return +} + +func (_ *MasterInput) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*MasterInput) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *MasterInput) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + (*z).Round, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 string + zb0003, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Type") + return + } + (*z).Type = NoteFieldType(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + if zb0004 > 0 { + zb0004-- + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array", "Deposit") + return + } + } + if zb0004 > 0 { + zb0004-- + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array", "Sig") + return + } + } + if zb0004 > 0 { + err = msgp.ErrTooManyArrayFields(zb0004) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + if zb0005 { + (*z).SignedDeposit = SignedDeposit{} + } + for zb0004 > 0 { + zb0004-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + switch string(field) { + case "dep": + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "Deposit") + return + } + case "sig": + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + } + } + } + } + if zb0001 > 0 { + zb0001-- + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + if zb0006 > 0 { + zb0006-- + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array", "Bid") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array", "Sig") + return + } + } + if zb0006 > 0 { + err = msgp.ErrTooManyArrayFields(zb0006) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + if zb0007 { + (*z).SignedBid = SignedBid{} + } + for zb0006 > 0 { + zb0006-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + switch string(field) { + case "bid": + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "Bid") + return + } + case "sig": + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + } + } + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = MasterInput{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + (*z).Round, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "t": + { + var zb0008 string + zb0008, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + (*z).Type = NoteFieldType(zb0008) + } + case "d": + var zb0009 int + var zb0010 bool + zb0009, zb0010, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0009, zb0010, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + if zb0009 > 0 { + zb0009-- + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array", "Deposit") + return + } + } + if zb0009 > 0 { + zb0009-- + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array", "Sig") + return + } + } + if zb0009 > 0 { + err = msgp.ErrTooManyArrayFields(zb0009) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + if zb0010 { + (*z).SignedDeposit = SignedDeposit{} + } + for zb0009 > 0 { + zb0009-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + switch string(field) { + case "dep": + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Deposit") + return + } + case "sig": + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + } + } + } + case "b": + var zb0011 int + var zb0012 bool + zb0011, zb0012, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0011, zb0012, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + if zb0011 > 0 { + zb0011-- + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array", "Bid") + return + } + } + if zb0011 > 0 { + zb0011-- + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array", "Sig") + return + } + } + if zb0011 > 0 { + err = msgp.ErrTooManyArrayFields(zb0011) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + if zb0012 { + (*z).SignedBid = SignedBid{} + } + for zb0011 > 0 { + zb0011-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + switch string(field) { + case "bid": + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Bid") + return + } + case "sig": + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + } + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *MasterInput) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*MasterInput) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *MasterInput) Msgsize() (s int) { + s = 1 + 4 + msgp.Uint64Size + 2 + msgp.StringPrefixSize + len(string((*z).Type)) + 2 + 1 + 4 + (*z).SignedDeposit.Deposit.Msgsize() + 4 + (*z).SignedDeposit.Sig.Msgsize() + 2 + 1 + 4 + (*z).SignedBid.Bid.Msgsize() + 4 + (*z).SignedBid.Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *MasterInput) MsgIsZero() bool { + return ((*z).Round == 0) && ((*z).Type == "") && (((*z).SignedDeposit.Deposit.MsgIsZero()) && ((*z).SignedDeposit.Sig.MsgIsZero())) && (((*z).SignedBid.Bid.MsgIsZero()) && ((*z).SignedBid.Sig.MsgIsZero())) +} + +// MarshalMsg implements msgp.Marshaler +func (z *NoteField) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(5) + var zb0001Mask uint8 /* 6 bits */ + if ((*z).SignedBid.Bid.MsgIsZero()) && ((*z).SignedBid.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x2 + } + if ((*z).SignedDeposit.Deposit.MsgIsZero()) && ((*z).SignedDeposit.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x4 + } + if ((*z).SignedParams.Params.MsgIsZero()) && ((*z).SignedParams.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x8 + } + if ((*z).SignedSettlement.Settlement.MsgIsZero()) && ((*z).SignedSettlement.Sig.MsgIsZero()) { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).Type == "" { + zb0001Len-- + zb0001Mask |= 0x20 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "b" + o = append(o, 0xa1, 0x62) + // omitempty: check for empty values + zb0002Len := uint32(2) + var zb0002Mask uint8 /* 3 bits */ + if (*z).SignedBid.Bid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).SignedBid.Sig.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x4 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "bid" + o = append(o, 0xa3, 0x62, 0x69, 0x64) + o, err = (*z).SignedBid.Bid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Bid") + return + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedBid.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Sig") + return + } + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "d" + o = append(o, 0xa1, 0x64) + // omitempty: check for empty values + zb0003Len := uint32(2) + var zb0003Mask uint8 /* 3 bits */ + if (*z).SignedDeposit.Deposit.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).SignedDeposit.Sig.MsgIsZero() { + zb0003Len-- + zb0003Mask |= 0x4 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "dep" + o = append(o, 0xa3, 0x64, 0x65, 0x70) + o, err = (*z).SignedDeposit.Deposit.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Deposit") + return + } + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedDeposit.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Sig") + return + } + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "p" + o = append(o, 0xa1, 0x70) + // omitempty: check for empty values + zb0004Len := uint32(2) + var zb0004Mask uint8 /* 3 bits */ + if (*z).SignedParams.Params.MsgIsZero() { + zb0004Len-- + zb0004Mask |= 0x2 + } + if (*z).SignedParams.Sig.MsgIsZero() { + zb0004Len-- + zb0004Mask |= 0x4 + } + // variable map header, size zb0004Len + o = append(o, 0x80|uint8(zb0004Len)) + if (zb0004Mask & 0x2) == 0 { // if not empty + // string "param" + o = append(o, 0xa5, 0x70, 0x61, 0x72, 0x61, 0x6d) + o, err = (*z).SignedParams.Params.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "Params") + return + } + } + if (zb0004Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedParams.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "Sig") + return + } + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "s" + o = append(o, 0xa1, 0x73) + // omitempty: check for empty values + zb0005Len := uint32(2) + var zb0005Mask uint8 /* 3 bits */ + if (*z).SignedSettlement.Settlement.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x2 + } + if (*z).SignedSettlement.Sig.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x4 + } + // variable map header, size zb0005Len + o = append(o, 0x80|uint8(zb0005Len)) + if (zb0005Mask & 0x2) == 0 { // if not empty + // string "settle" + o = append(o, 0xa6, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65) + o, err = (*z).SignedSettlement.Settlement.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "Settlement") + return + } + } + if (zb0005Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedSettlement.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "Sig") + return + } + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "t" + o = append(o, 0xa1, 0x74) + o = msgp.AppendString(o, string((*z).Type)) + } + } + return +} + +func (_ *NoteField) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*NoteField) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *NoteField) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + { + var zb0003 string + zb0003, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Type") + return + } + (*z).Type = NoteFieldType(zb0003) + } + } + if zb0001 > 0 { + zb0001-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + if zb0004 > 0 { + zb0004-- + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array", "Deposit") + return + } + } + if zb0004 > 0 { + zb0004-- + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array", "Sig") + return + } + } + if zb0004 > 0 { + err = msgp.ErrTooManyArrayFields(zb0004) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + if zb0005 { + (*z).SignedDeposit = SignedDeposit{} + } + for zb0004 > 0 { + zb0004-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + switch string(field) { + case "dep": + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "Deposit") + return + } + case "sig": + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedDeposit") + return + } + } + } + } + } + if zb0001 > 0 { + zb0001-- + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + if zb0006 > 0 { + zb0006-- + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array", "Bid") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array", "Sig") + return + } + } + if zb0006 > 0 { + err = msgp.ErrTooManyArrayFields(zb0006) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + if zb0007 { + (*z).SignedBid = SignedBid{} + } + for zb0006 > 0 { + zb0006-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + switch string(field) { + case "bid": + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "Bid") + return + } + case "sig": + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedBid") + return + } + } + } + } + } + if zb0001 > 0 { + zb0001-- + var zb0008 int + var zb0009 bool + zb0008, zb0009, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0008, zb0009, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement") + return + } + if zb0008 > 0 { + zb0008-- + bts, err = (*z).SignedSettlement.Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement", "struct-from-array", "Settlement") + return + } + } + if zb0008 > 0 { + zb0008-- + bts, err = (*z).SignedSettlement.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement", "struct-from-array", "Sig") + return + } + } + if zb0008 > 0 { + err = msgp.ErrTooManyArrayFields(zb0008) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement") + return + } + if zb0009 { + (*z).SignedSettlement = SignedSettlement{} + } + for zb0008 > 0 { + zb0008-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement") + return + } + switch string(field) { + case "settle": + bts, err = (*z).SignedSettlement.Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement", "Settlement") + return + } + case "sig": + bts, err = (*z).SignedSettlement.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedSettlement") + return + } + } + } + } + } + if zb0001 > 0 { + zb0001-- + var zb0010 int + var zb0011 bool + zb0010, zb0011, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0010, zb0011, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams") + return + } + if zb0010 > 0 { + zb0010-- + bts, err = (*z).SignedParams.Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams", "struct-from-array", "Params") + return + } + } + if zb0010 > 0 { + zb0010-- + bts, err = (*z).SignedParams.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams", "struct-from-array", "Sig") + return + } + } + if zb0010 > 0 { + err = msgp.ErrTooManyArrayFields(zb0010) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams") + return + } + if zb0011 { + (*z).SignedParams = SignedParams{} + } + for zb0010 > 0 { + zb0010-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams") + return + } + switch string(field) { + case "param": + bts, err = (*z).SignedParams.Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams", "Params") + return + } + case "sig": + bts, err = (*z).SignedParams.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SignedParams") + return + } + } + } + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = NoteField{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "t": + { + var zb0012 string + zb0012, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + (*z).Type = NoteFieldType(zb0012) + } + case "d": + var zb0013 int + var zb0014 bool + zb0013, zb0014, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0013, zb0014, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + if zb0013 > 0 { + zb0013-- + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array", "Deposit") + return + } + } + if zb0013 > 0 { + zb0013-- + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array", "Sig") + return + } + } + if zb0013 > 0 { + err = msgp.ErrTooManyArrayFields(zb0013) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + if zb0014 { + (*z).SignedDeposit = SignedDeposit{} + } + for zb0013 > 0 { + zb0013-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + switch string(field) { + case "dep": + bts, err = (*z).SignedDeposit.Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Deposit") + return + } + case "sig": + bts, err = (*z).SignedDeposit.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedDeposit") + return + } + } + } + } + case "b": + var zb0015 int + var zb0016 bool + zb0015, zb0016, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0015, zb0016, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + if zb0015 > 0 { + zb0015-- + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array", "Bid") + return + } + } + if zb0015 > 0 { + zb0015-- + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array", "Sig") + return + } + } + if zb0015 > 0 { + err = msgp.ErrTooManyArrayFields(zb0015) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + if zb0016 { + (*z).SignedBid = SignedBid{} + } + for zb0015 > 0 { + zb0015-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + switch string(field) { + case "bid": + bts, err = (*z).SignedBid.Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Bid") + return + } + case "sig": + bts, err = (*z).SignedBid.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedBid", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedBid") + return + } + } + } + } + case "s": + var zb0017 int + var zb0018 bool + zb0017, zb0018, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0017, zb0018, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement") + return + } + if zb0017 > 0 { + zb0017-- + bts, err = (*z).SignedSettlement.Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "struct-from-array", "Settlement") + return + } + } + if zb0017 > 0 { + zb0017-- + bts, err = (*z).SignedSettlement.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "struct-from-array", "Sig") + return + } + } + if zb0017 > 0 { + err = msgp.ErrTooManyArrayFields(zb0017) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedSettlement") + return + } + if zb0018 { + (*z).SignedSettlement = SignedSettlement{} + } + for zb0017 > 0 { + zb0017-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement") + return + } + switch string(field) { + case "settle": + bts, err = (*z).SignedSettlement.Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "Settlement") + return + } + case "sig": + bts, err = (*z).SignedSettlement.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedSettlement") + return + } + } + } + } + case "p": + var zb0019 int + var zb0020 bool + zb0019, zb0020, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0019, zb0020, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams") + return + } + if zb0019 > 0 { + zb0019-- + bts, err = (*z).SignedParams.Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "struct-from-array", "Params") + return + } + } + if zb0019 > 0 { + zb0019-- + bts, err = (*z).SignedParams.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "struct-from-array", "Sig") + return + } + } + if zb0019 > 0 { + err = msgp.ErrTooManyArrayFields(zb0019) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "SignedParams") + return + } + if zb0020 { + (*z).SignedParams = SignedParams{} + } + for zb0019 > 0 { + zb0019-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams") + return + } + switch string(field) { + case "param": + bts, err = (*z).SignedParams.Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "Params") + return + } + case "sig": + bts, err = (*z).SignedParams.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SignedParams", "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "SignedParams") + return + } + } + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *NoteField) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*NoteField) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *NoteField) Msgsize() (s int) { + s = 1 + 2 + msgp.StringPrefixSize + len(string((*z).Type)) + 2 + 1 + 4 + (*z).SignedDeposit.Deposit.Msgsize() + 4 + (*z).SignedDeposit.Sig.Msgsize() + 2 + 1 + 4 + (*z).SignedBid.Bid.Msgsize() + 4 + (*z).SignedBid.Sig.Msgsize() + 2 + 1 + 7 + (*z).SignedSettlement.Settlement.Msgsize() + 4 + (*z).SignedSettlement.Sig.Msgsize() + 2 + 1 + 6 + (*z).SignedParams.Params.Msgsize() + 4 + (*z).SignedParams.Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *NoteField) MsgIsZero() bool { + return ((*z).Type == "") && (((*z).SignedDeposit.Deposit.MsgIsZero()) && ((*z).SignedDeposit.Sig.MsgIsZero())) && (((*z).SignedBid.Bid.MsgIsZero()) && ((*z).SignedBid.Sig.MsgIsZero())) && (((*z).SignedSettlement.Settlement.MsgIsZero()) && ((*z).SignedSettlement.Sig.MsgIsZero())) && (((*z).SignedParams.Params.MsgIsZero()) && ((*z).SignedParams.Sig.MsgIsZero())) +} + +// MarshalMsg implements msgp.Marshaler +func (z NoteFieldType) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ NoteFieldType) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(NoteFieldType) + if !ok { + _, ok = (z).(*NoteFieldType) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *NoteFieldType) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = NoteFieldType(zb0001) + } + o = bts + return +} + +func (_ *NoteFieldType) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*NoteFieldType) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z NoteFieldType) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z NoteFieldType) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z *Params) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(12) + var zb0001Mask uint16 /* 13 bits */ + if (*z).AuctionID == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).AuctionKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).BankKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).PriceChunkRounds == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).DepositRound == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).DispensingKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).FirstRound == 0 { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).LastPrice == 0 { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).NumAlgos == 0 { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).MaxPriceMultiple == 0 { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).MinBidAlgos == 0 { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).NumChunks == 0 { + zb0001Len-- + zb0001Mask |= 0x1000 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "aid" + o = append(o, 0xa3, 0x61, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).AuctionID) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "auc" + o = append(o, 0xa3, 0x61, 0x75, 0x63) + o, err = (*z).AuctionKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "bank" + o = append(o, 0xa4, 0x62, 0x61, 0x6e, 0x6b) + o, err = (*z).BankKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "BankKey") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "chunkrnds" + o = append(o, 0xa9, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x72, 0x6e, 0x64, 0x73) + o = msgp.AppendUint64(o, (*z).PriceChunkRounds) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "depositrnd" + o = append(o, 0xaa, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x72, 0x6e, 0x64) + o = msgp.AppendUint64(o, (*z).DepositRound) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "dispense" + o = append(o, 0xa8, 0x64, 0x69, 0x73, 0x70, 0x65, 0x6e, 0x73, 0x65) + o, err = (*z).DispensingKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "DispensingKey") + return + } + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "firstrnd" + o = append(o, 0xa8, 0x66, 0x69, 0x72, 0x73, 0x74, 0x72, 0x6e, 0x64) + o = msgp.AppendUint64(o, (*z).FirstRound) + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "lastprice" + o = append(o, 0xa9, 0x6c, 0x61, 0x73, 0x74, 0x70, 0x72, 0x69, 0x63, 0x65) + o = msgp.AppendUint64(o, (*z).LastPrice) + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "maxalgos" + o = append(o, 0xa8, 0x6d, 0x61, 0x78, 0x61, 0x6c, 0x67, 0x6f, 0x73) + o = msgp.AppendUint64(o, (*z).NumAlgos) + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "maxmult" + o = append(o, 0xa7, 0x6d, 0x61, 0x78, 0x6d, 0x75, 0x6c, 0x74) + o = msgp.AppendUint64(o, (*z).MaxPriceMultiple) + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "minbidalgos" + o = append(o, 0xab, 0x6d, 0x69, 0x6e, 0x62, 0x69, 0x64, 0x61, 0x6c, 0x67, 0x6f, 0x73) + o = msgp.AppendUint64(o, (*z).MinBidAlgos) + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "numchunks" + o = append(o, 0xa9, 0x6e, 0x75, 0x6d, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x73) + o = msgp.AppendUint64(o, (*z).NumChunks) + } + } + return +} + +func (_ *Params) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Params) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Params) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BankKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "BankKey") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).DispensingKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "DispensingKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).LastPrice, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "LastPrice") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).DepositRound, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "DepositRound") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).FirstRound, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstRound") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).PriceChunkRounds, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PriceChunkRounds") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).NumChunks, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NumChunks") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).MaxPriceMultiple, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MaxPriceMultiple") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).NumAlgos, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NumAlgos") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).MinBidAlgos, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MinBidAlgos") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Params{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "auc": + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + case "aid": + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionID") + return + } + case "bank": + bts, err = (*z).BankKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "BankKey") + return + } + case "dispense": + bts, err = (*z).DispensingKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "DispensingKey") + return + } + case "lastprice": + (*z).LastPrice, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "LastPrice") + return + } + case "depositrnd": + (*z).DepositRound, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "DepositRound") + return + } + case "firstrnd": + (*z).FirstRound, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "FirstRound") + return + } + case "chunkrnds": + (*z).PriceChunkRounds, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "PriceChunkRounds") + return + } + case "numchunks": + (*z).NumChunks, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NumChunks") + return + } + case "maxmult": + (*z).MaxPriceMultiple, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "MaxPriceMultiple") + return + } + case "maxalgos": + (*z).NumAlgos, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NumAlgos") + return + } + case "minbidalgos": + (*z).MinBidAlgos, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "MinBidAlgos") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Params) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Params) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Params) Msgsize() (s int) { + s = 1 + 4 + (*z).AuctionKey.Msgsize() + 4 + msgp.Uint64Size + 5 + (*z).BankKey.Msgsize() + 9 + (*z).DispensingKey.Msgsize() + 10 + msgp.Uint64Size + 11 + msgp.Uint64Size + 9 + msgp.Uint64Size + 10 + msgp.Uint64Size + 10 + msgp.Uint64Size + 8 + msgp.Uint64Size + 9 + msgp.Uint64Size + 12 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Params) MsgIsZero() bool { + return ((*z).AuctionKey.MsgIsZero()) && ((*z).AuctionID == 0) && ((*z).BankKey.MsgIsZero()) && ((*z).DispensingKey.MsgIsZero()) && ((*z).LastPrice == 0) && ((*z).DepositRound == 0) && ((*z).FirstRound == 0) && ((*z).PriceChunkRounds == 0) && ((*z).NumChunks == 0) && ((*z).MaxPriceMultiple == 0) && ((*z).NumAlgos == 0) && ((*z).MinBidAlgos == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Settlement) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(5) + var zb0001Mask uint8 /* 6 bits */ + if (*z).AuctionID == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).AuctionKey.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Canceled == false { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).Cleared == false { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).OutcomesHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "aid" + o = append(o, 0xa3, 0x61, 0x69, 0x64) + o = msgp.AppendUint64(o, (*z).AuctionID) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "auc" + o = append(o, 0xa3, 0x61, 0x75, 0x63) + o, err = (*z).AuctionKey.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "canceled" + o = append(o, 0xa8, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64) + o = msgp.AppendBool(o, (*z).Canceled) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "cleared" + o = append(o, 0xa7, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x65, 0x64) + o = msgp.AppendBool(o, (*z).Cleared) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "outhash" + o = append(o, 0xa7, 0x6f, 0x75, 0x74, 0x68, 0x61, 0x73, 0x68) + o, err = (*z).OutcomesHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "OutcomesHash") + return + } + } + } + return +} + +func (_ *Settlement) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Settlement) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Settlement) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionKey") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AuctionID") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Cleared, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Cleared") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).OutcomesHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OutcomesHash") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Canceled, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Canceled") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Settlement{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "auc": + bts, err = (*z).AuctionKey.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionKey") + return + } + case "aid": + (*z).AuctionID, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AuctionID") + return + } + case "cleared": + (*z).Cleared, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Cleared") + return + } + case "outhash": + bts, err = (*z).OutcomesHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "OutcomesHash") + return + } + case "canceled": + (*z).Canceled, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Canceled") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Settlement) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Settlement) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Settlement) Msgsize() (s int) { + s = 1 + 4 + (*z).AuctionKey.Msgsize() + 4 + msgp.Uint64Size + 8 + msgp.BoolSize + 8 + (*z).OutcomesHash.Msgsize() + 9 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Settlement) MsgIsZero() bool { + return ((*z).AuctionKey.MsgIsZero()) && ((*z).AuctionID == 0) && ((*z).Cleared == false) && ((*z).OutcomesHash.MsgIsZero()) && ((*z).Canceled == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedBid) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).Bid.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "bid" + o = append(o, 0xa3, 0x62, 0x69, 0x64) + o, err = (*z).Bid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Bid") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *SignedBid) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedBid) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedBid) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Bid") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedBid{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "bid": + bts, err = (*z).Bid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Bid") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedBid) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedBid) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedBid) Msgsize() (s int) { + s = 1 + 4 + (*z).Bid.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedBid) MsgIsZero() bool { + return ((*z).Bid.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedDeposit) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).Deposit.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "dep" + o = append(o, 0xa3, 0x64, 0x65, 0x70) + o, err = (*z).Deposit.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Deposit") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *SignedDeposit) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedDeposit) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedDeposit) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Deposit") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedDeposit{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "dep": + bts, err = (*z).Deposit.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Deposit") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedDeposit) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedDeposit) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedDeposit) Msgsize() (s int) { + s = 1 + 4 + (*z).Deposit.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedDeposit) MsgIsZero() bool { + return ((*z).Deposit.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedParams) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).Params.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "param" + o = append(o, 0xa5, 0x70, 0x61, 0x72, 0x61, 0x6d) + o, err = (*z).Params.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Params") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *SignedParams) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedParams) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedParams) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Params") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedParams{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "param": + bts, err = (*z).Params.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Params") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedParams) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedParams) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedParams) Msgsize() (s int) { + s = 1 + 6 + (*z).Params.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedParams) MsgIsZero() bool { + return ((*z).Params.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedSettlement) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).Settlement.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "settle" + o = append(o, 0xa6, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65) + o, err = (*z).Settlement.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Settlement") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *SignedSettlement) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedSettlement) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedSettlement) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Settlement") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedSettlement{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "settle": + bts, err = (*z).Settlement.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Settlement") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedSettlement) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedSettlement) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedSettlement) Msgsize() (s int) { + s = 1 + 7 + (*z).Settlement.Msgsize() + 4 + (*z).Sig.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedSettlement) MsgIsZero() bool { + return ((*z).Settlement.MsgIsZero()) && ((*z).Sig.MsgIsZero()) +} diff --git a/auction/msgp_gen_test.go b/auction/msgp_gen_test.go new file mode 100644 index 0000000000..97056ad80a --- /dev/null +++ b/auction/msgp_gen_test.go @@ -0,0 +1,754 @@ +package auction + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalBid(t *testing.T) { + v := Bid{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBid(t *testing.T) { + protocol.RunEncodingTest(t, &Bid{}) +} + +func BenchmarkMarshalMsgBid(b *testing.B) { + v := Bid{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBid(b *testing.B) { + v := Bid{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBid(b *testing.B) { + v := Bid{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalBidOutcomes(t *testing.T) { + v := BidOutcomes{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBidOutcomes(t *testing.T) { + protocol.RunEncodingTest(t, &BidOutcomes{}) +} + +func BenchmarkMarshalMsgBidOutcomes(b *testing.B) { + v := BidOutcomes{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBidOutcomes(b *testing.B) { + v := BidOutcomes{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBidOutcomes(b *testing.B) { + v := BidOutcomes{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalBidderOutcome(t *testing.T) { + v := BidderOutcome{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBidderOutcome(t *testing.T) { + protocol.RunEncodingTest(t, &BidderOutcome{}) +} + +func BenchmarkMarshalMsgBidderOutcome(b *testing.B) { + v := BidderOutcome{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBidderOutcome(b *testing.B) { + v := BidderOutcome{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBidderOutcome(b *testing.B) { + v := BidderOutcome{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalDeposit(t *testing.T) { + v := Deposit{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingDeposit(t *testing.T) { + protocol.RunEncodingTest(t, &Deposit{}) +} + +func BenchmarkMarshalMsgDeposit(b *testing.B) { + v := Deposit{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgDeposit(b *testing.B) { + v := Deposit{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalDeposit(b *testing.B) { + v := Deposit{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalMasterInput(t *testing.T) { + v := MasterInput{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingMasterInput(t *testing.T) { + protocol.RunEncodingTest(t, &MasterInput{}) +} + +func BenchmarkMarshalMsgMasterInput(b *testing.B) { + v := MasterInput{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgMasterInput(b *testing.B) { + v := MasterInput{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalMasterInput(b *testing.B) { + v := MasterInput{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalNoteField(t *testing.T) { + v := NoteField{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingNoteField(t *testing.T) { + protocol.RunEncodingTest(t, &NoteField{}) +} + +func BenchmarkMarshalMsgNoteField(b *testing.B) { + v := NoteField{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgNoteField(b *testing.B) { + v := NoteField{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalNoteField(b *testing.B) { + v := NoteField{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalParams(t *testing.T) { + v := Params{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingParams(t *testing.T) { + protocol.RunEncodingTest(t, &Params{}) +} + +func BenchmarkMarshalMsgParams(b *testing.B) { + v := Params{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgParams(b *testing.B) { + v := Params{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalParams(b *testing.B) { + v := Params{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSettlement(t *testing.T) { + v := Settlement{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSettlement(t *testing.T) { + protocol.RunEncodingTest(t, &Settlement{}) +} + +func BenchmarkMarshalMsgSettlement(b *testing.B) { + v := Settlement{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSettlement(b *testing.B) { + v := Settlement{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSettlement(b *testing.B) { + v := Settlement{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedBid(t *testing.T) { + v := SignedBid{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedBid(t *testing.T) { + protocol.RunEncodingTest(t, &SignedBid{}) +} + +func BenchmarkMarshalMsgSignedBid(b *testing.B) { + v := SignedBid{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedBid(b *testing.B) { + v := SignedBid{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedBid(b *testing.B) { + v := SignedBid{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedDeposit(t *testing.T) { + v := SignedDeposit{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedDeposit(t *testing.T) { + protocol.RunEncodingTest(t, &SignedDeposit{}) +} + +func BenchmarkMarshalMsgSignedDeposit(b *testing.B) { + v := SignedDeposit{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedDeposit(b *testing.B) { + v := SignedDeposit{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedDeposit(b *testing.B) { + v := SignedDeposit{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedParams(t *testing.T) { + v := SignedParams{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedParams(t *testing.T) { + protocol.RunEncodingTest(t, &SignedParams{}) +} + +func BenchmarkMarshalMsgSignedParams(b *testing.B) { + v := SignedParams{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedParams(b *testing.B) { + v := SignedParams{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedParams(b *testing.B) { + v := SignedParams{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedSettlement(t *testing.T) { + v := SignedSettlement{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedSettlement(t *testing.T) { + protocol.RunEncodingTest(t, &SignedSettlement{}) +} + +func BenchmarkMarshalMsgSignedSettlement(b *testing.B) { + v := SignedSettlement{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedSettlement(b *testing.B) { + v := SignedSettlement{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedSettlement(b *testing.B) { + v := SignedSettlement{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/auction/tracker.go b/auction/tracker.go index a69dbfd576..8b1022904f 100644 --- a/auction/tracker.go +++ b/auction/tracker.go @@ -38,6 +38,7 @@ var ( ) // State represents the state of the auction +//msgp:ignore State type State int const ( diff --git a/auction/tracker_test.go b/auction/tracker_test.go index fd20fa0d46..41df8349c4 100644 --- a/auction/tracker_test.go +++ b/auction/tracker_test.go @@ -66,7 +66,7 @@ func genConfirmedTx(msg interface{}, round uint64, from, to basics.Address, Payment: &v1.PaymentTransactionType{ To: to.String(), }, - Note: protocol.Encode(nf), + Note: protocol.Encode(&nf), } } diff --git a/buildnumber.dat b/buildnumber.dat index b8626c4cff..7ed6ff82de 100644 --- a/buildnumber.dat +++ b/buildnumber.dat @@ -1 +1 @@ -4 +5 diff --git a/cmd/algokey/multisig.go b/cmd/algokey/multisig.go index c8bd31306d..d1a254176e 100644 --- a/cmd/algokey/multisig.go +++ b/cmd/algokey/multisig.go @@ -83,7 +83,7 @@ var multisigCmd = &cobra.Command{ os.Exit(1) } - outBytes = append(outBytes, protocol.Encode(stxn)...) + outBytes = append(outBytes, protocol.Encode(&stxn)...) } err = ioutil.WriteFile(multisigOutfile, outBytes, 0600) diff --git a/cmd/algokey/sign.go b/cmd/algokey/sign.go index c124a24475..26f7add144 100644 --- a/cmd/algokey/sign.go +++ b/cmd/algokey/sign.go @@ -71,7 +71,7 @@ var signCmd = &cobra.Command{ } stxn.Sig = key.Sign(stxn.Txn) - outBytes = append(outBytes, protocol.Encode(stxn)...) + outBytes = append(outBytes, protocol.Encode(&stxn)...) } err = ioutil.WriteFile(signOutfile, outBytes, 0600) diff --git a/config/config.go b/config/config.go index aee0349e9a..7d19108d54 100644 --- a/config/config.go +++ b/config/config.go @@ -243,6 +243,16 @@ type ConsensusParams struct { // consensus protocol. var Consensus map[protocol.ConsensusVersion]ConsensusParams +// MaxVoteThreshold is the largest threshold for a bundle over all supported +// consensus protocols, used for decoding purposes. +var MaxVoteThreshold int + +func maybeMaxVoteThreshold(t uint64) { + if int(t) > MaxVoteThreshold { + MaxVoteThreshold = int(t) + } +} + func init() { Consensus = make(map[protocol.ConsensusVersion]ConsensusParams) @@ -261,6 +271,15 @@ func init() { if err == nil { Protocol.SmallLambda = time.Duration(algoSmallLambda) * time.Millisecond } + + for _, p := range Consensus { + maybeMaxVoteThreshold(p.SoftCommitteeThreshold) + maybeMaxVoteThreshold(p.CertCommitteeThreshold) + maybeMaxVoteThreshold(p.NextCommitteeThreshold) + maybeMaxVoteThreshold(p.LateCommitteeThreshold) + maybeMaxVoteThreshold(p.RedoCommitteeThreshold) + maybeMaxVoteThreshold(p.DownCommitteeThreshold) + } } func initConsensusProtocols() { diff --git a/crypto/curve25519.go b/crypto/curve25519.go index 362d5a8356..23aa64447f 100644 --- a/crypto/curve25519.go +++ b/crypto/curve25519.go @@ -48,17 +48,22 @@ func init() { logging.Init() logging.Base().Fatal("failed to initialize libsodium!") } + + // Check sizes of structs + _ = [C.crypto_sign_ed25519_BYTES]byte(ed25519Signature{}) + _ = [C.crypto_sign_ed25519_PUBLICKEYBYTES]byte(ed25519PublicKey{}) + _ = [C.crypto_sign_ed25519_SECRETKEYBYTES]byte(ed25519PrivateKey{}) + _ = [C.crypto_sign_ed25519_SEEDBYTES]byte(ed25519Seed{}) } // A Seed holds the entropy needed to generate cryptographic keys. type Seed ed25519Seed /* Classical signatures */ - -type ed25519Signature [C.crypto_sign_ed25519_BYTES]byte -type ed25519PublicKey [C.crypto_sign_ed25519_PUBLICKEYBYTES]byte -type ed25519PrivateKey [C.crypto_sign_ed25519_SECRETKEYBYTES]byte -type ed25519Seed [C.crypto_sign_ed25519_SEEDBYTES]byte +type ed25519Signature [64]byte +type ed25519PublicKey [32]byte +type ed25519PrivateKey [64]byte +type ed25519Seed [32]byte // MasterDerivationKey is used to derive ed25519 keys for use in wallets type MasterDerivationKey [masterDerivationKeyLenBytes]byte diff --git a/crypto/msgp_gen.go b/crypto/msgp_gen.go new file mode 100644 index 0000000000..9b5de8349a --- /dev/null +++ b/crypto/msgp_gen.go @@ -0,0 +1,2171 @@ +package crypto + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + _ "runtime/cgo" + _ "unsafe" + + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Digest) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *Digest) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Digest) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Digest) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *Digest) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Digest) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Digest) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (DigestSize * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Digest) MsgIsZero() bool { + return (*z) == (Digest{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *MasterDerivationKey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *MasterDerivationKey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*MasterDerivationKey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *MasterDerivationKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *MasterDerivationKey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*MasterDerivationKey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *MasterDerivationKey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (masterDerivationKeyLenBytes * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *MasterDerivationKey) MsgIsZero() bool { + return (*z) == (MasterDerivationKey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *MultisigSig) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(3) + var zb0002Mask uint8 /* 4 bits */ + if len((*z).Subsigs) == 0 { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).Threshold == 0 { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).Version == 0 { + zb0002Len-- + zb0002Mask |= 0x8 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "subsig" + o = append(o, 0xa6, 0x73, 0x75, 0x62, 0x73, 0x69, 0x67) + if (*z).Subsigs == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Subsigs))) + } + for zb0001 := range (*z).Subsigs { + o, err = (*z).Subsigs[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Subsigs", zb0001) + return + } + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "thr" + o = append(o, 0xa3, 0x74, 0x68, 0x72) + o = msgp.AppendUint8(o, (*z).Threshold) + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "v" + o = append(o, 0xa1, 0x76) + o = msgp.AppendUint8(o, (*z).Version) + } + } + return +} + +func (_ *MultisigSig) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*MultisigSig) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *MultisigSig) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + (*z).Version, bts, err = msgp.ReadUint8Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Version") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Threshold, bts, err = msgp.ReadUint8Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Threshold") + return + } + } + if zb0002 > 0 { + zb0002-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Subsigs") + return + } + if zb0004 > maxMultisig { + err = msgp.ErrOverflow(uint64(zb0004), uint64(maxMultisig)) + err = msgp.WrapError(err, "struct-from-array", "Subsigs") + return + } + if zb0005 { + (*z).Subsigs = nil + } else if (*z).Subsigs != nil && cap((*z).Subsigs) >= zb0004 { + (*z).Subsigs = ((*z).Subsigs)[:zb0004] + } else { + (*z).Subsigs = make([]MultisigSubsig, zb0004) + } + for zb0001 := range (*z).Subsigs { + bts, err = (*z).Subsigs[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Subsigs", zb0001) + return + } + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = MultisigSig{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "v": + (*z).Version, bts, err = msgp.ReadUint8Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Version") + return + } + case "thr": + (*z).Threshold, bts, err = msgp.ReadUint8Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Threshold") + return + } + case "subsig": + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Subsigs") + return + } + if zb0006 > maxMultisig { + err = msgp.ErrOverflow(uint64(zb0006), uint64(maxMultisig)) + err = msgp.WrapError(err, "Subsigs") + return + } + if zb0007 { + (*z).Subsigs = nil + } else if (*z).Subsigs != nil && cap((*z).Subsigs) >= zb0006 { + (*z).Subsigs = ((*z).Subsigs)[:zb0006] + } else { + (*z).Subsigs = make([]MultisigSubsig, zb0006) + } + for zb0001 := range (*z).Subsigs { + bts, err = (*z).Subsigs[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Subsigs", zb0001) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *MultisigSig) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*MultisigSig) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *MultisigSig) Msgsize() (s int) { + s = 1 + 2 + msgp.Uint8Size + 4 + msgp.Uint8Size + 7 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Subsigs { + s += (*z).Subsigs[zb0001].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *MultisigSig) MsgIsZero() bool { + return ((*z).Version == 0) && ((*z).Threshold == 0) && (len((*z).Subsigs) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *MultisigSubsig) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0003Len := uint32(2) + var zb0003Mask uint8 /* 3 bits */ + if (*z).Key == (PublicKey{}) { + zb0003Len-- + zb0003Mask |= 0x2 + } + if (*z).Sig == (Signature{}) { + zb0003Len-- + zb0003Mask |= 0x4 + } + // variable map header, size zb0003Len + o = append(o, 0x80|uint8(zb0003Len)) + if zb0003Len != 0 { + if (zb0003Mask & 0x2) == 0 { // if not empty + // string "pk" + o = append(o, 0xa2, 0x70, 0x6b) + o = msgp.AppendBytes(o, ((*z).Key)[:]) + } + if (zb0003Mask & 0x4) == 0 { // if not empty + // string "s" + o = append(o, 0xa1, 0x73) + o = msgp.AppendBytes(o, ((*z).Sig)[:]) + } + } + return +} + +func (_ *MultisigSubsig) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*MultisigSubsig) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *MultisigSubsig) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0003 int + var zb0004 bool + zb0003, zb0004, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0003, zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 > 0 { + zb0003-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Key)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Key") + return + } + } + if zb0003 > 0 { + zb0003-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0003 > 0 { + err = msgp.ErrTooManyArrayFields(zb0003) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0004 { + (*z) = MultisigSubsig{} + } + for zb0003 > 0 { + zb0003-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "pk": + bts, err = msgp.ReadExactBytes(bts, ((*z).Key)[:]) + if err != nil { + err = msgp.WrapError(err, "Key") + return + } + case "s": + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *MultisigSubsig) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*MultisigSubsig) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *MultisigSubsig) Msgsize() (s int) { + s = 1 + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 2 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *MultisigSubsig) MsgIsZero() bool { + return ((*z).Key == (PublicKey{})) && ((*z).Sig == (Signature{})) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignature) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 6 + // string "p" + o = append(o, 0x86, 0xa1, 0x70) + o = msgp.AppendBytes(o, ((*z).PK)[:]) + // string "p1s" + o = append(o, 0xa3, 0x70, 0x31, 0x73) + o = msgp.AppendBytes(o, ((*z).PK1Sig)[:]) + // string "p2" + o = append(o, 0xa2, 0x70, 0x32) + o = msgp.AppendBytes(o, ((*z).PK2)[:]) + // string "p2s" + o = append(o, 0xa3, 0x70, 0x32, 0x73) + o = msgp.AppendBytes(o, ((*z).PK2Sig)[:]) + // string "ps" + o = append(o, 0xa2, 0x70, 0x73) + o = msgp.AppendBytes(o, ((*z).PKSigOld)[:]) + // string "s" + o = append(o, 0xa1, 0x73) + o = msgp.AppendBytes(o, ((*z).Sig)[:]) + return +} + +func (_ *OneTimeSignature) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignature) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignature) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0007 int + var zb0008 bool + zb0007, zb0008, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0007, zb0008, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK") + return + } + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigOld)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PKSigOld") + return + } + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK2") + return + } + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK1Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK1Sig") + return + } + } + if zb0007 > 0 { + zb0007-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK2Sig") + return + } + } + if zb0007 > 0 { + err = msgp.ErrTooManyArrayFields(zb0007) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0008 { + (*z) = OneTimeSignature{} + } + for zb0007 > 0 { + zb0007-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "s": + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "p": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "PK") + return + } + case "ps": + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigOld)[:]) + if err != nil { + err = msgp.WrapError(err, "PKSigOld") + return + } + case "p2": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2)[:]) + if err != nil { + err = msgp.WrapError(err, "PK2") + return + } + case "p1s": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK1Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "PK1Sig") + return + } + case "p2s": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "PK2Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *OneTimeSignature) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignature) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignature) Msgsize() (s int) { + s = 1 + 2 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 2 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 3 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 4 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 4 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignature) MsgIsZero() bool { + return ((*z).Sig == (ed25519Signature{})) && ((*z).PK == (ed25519PublicKey{})) && ((*z).PKSigOld == (ed25519Signature{})) && ((*z).PK2 == (ed25519PublicKey{})) && ((*z).PK1Sig == (ed25519Signature{})) && ((*z).PK2Sig == (ed25519Signature{})) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignatureSecrets) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0006Len := uint32(7) + var zb0006Mask uint16 /* 11 bits */ + if (*z).OneTimeSignatureSecretsPersistent.FirstBatch == 0 { + zb0006Len-- + zb0006Mask |= 0x1 + } + if (*z).OneTimeSignatureSecretsPersistent.OneTimeSignatureVerifier == (OneTimeSignatureVerifier{}) { + zb0006Len-- + zb0006Mask |= 0x2 + } + if len((*z).OneTimeSignatureSecretsPersistent.Batches) == 0 { + zb0006Len-- + zb0006Mask |= 0x4 + } + if (*z).OneTimeSignatureSecretsPersistent.FirstOffset == 0 { + zb0006Len-- + zb0006Mask |= 0x20 + } + if len((*z).OneTimeSignatureSecretsPersistent.Offsets) == 0 { + zb0006Len-- + zb0006Mask |= 0x80 + } + if (*z).OneTimeSignatureSecretsPersistent.OffsetsPK2 == (ed25519PublicKey{}) { + zb0006Len-- + zb0006Mask |= 0x100 + } + if (*z).OneTimeSignatureSecretsPersistent.OffsetsPK2Sig == (ed25519Signature{}) { + zb0006Len-- + zb0006Mask |= 0x200 + } + // variable map header, size zb0006Len + o = append(o, 0x80|uint8(zb0006Len)) + if zb0006Len != 0 { + if (zb0006Mask & 0x1) == 0 { // if not empty + // string "First" + o = append(o, 0xa5, 0x46, 0x69, 0x72, 0x73, 0x74) + o = msgp.AppendUint64(o, (*z).OneTimeSignatureSecretsPersistent.FirstBatch) + } + if (zb0006Mask & 0x2) == 0 { // if not empty + // string "OneTimeSignatureVerifier" + o = append(o, 0xb8, 0x4f, 0x6e, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72) + o = msgp.AppendBytes(o, ((*z).OneTimeSignatureSecretsPersistent.OneTimeSignatureVerifier)[:]) + } + if (zb0006Mask & 0x4) == 0 { // if not empty + // string "Sub" + o = append(o, 0xa3, 0x53, 0x75, 0x62) + if (*z).OneTimeSignatureSecretsPersistent.Batches == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).OneTimeSignatureSecretsPersistent.Batches))) + } + for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { + o, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Batches", zb0002) + return + } + } + } + if (zb0006Mask & 0x20) == 0 { // if not empty + // string "firstoff" + o = append(o, 0xa8, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6f, 0x66, 0x66) + o = msgp.AppendUint64(o, (*z).OneTimeSignatureSecretsPersistent.FirstOffset) + } + if (zb0006Mask & 0x80) == 0 { // if not empty + // string "offkeys" + o = append(o, 0xa7, 0x6f, 0x66, 0x66, 0x6b, 0x65, 0x79, 0x73) + if (*z).OneTimeSignatureSecretsPersistent.Offsets == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).OneTimeSignatureSecretsPersistent.Offsets))) + } + for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { + o, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Offsets", zb0003) + return + } + } + } + if (zb0006Mask & 0x100) == 0 { // if not empty + // string "offpk2" + o = append(o, 0xa6, 0x6f, 0x66, 0x66, 0x70, 0x6b, 0x32) + o = msgp.AppendBytes(o, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2)[:]) + } + if (zb0006Mask & 0x200) == 0 { // if not empty + // string "offpk2sig" + o = append(o, 0xa9, 0x6f, 0x66, 0x66, 0x70, 0x6b, 0x32, 0x73, 0x69, 0x67) + o = msgp.AppendBytes(o, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2Sig)[:]) + } + } + return +} + +func (_ *OneTimeSignatureSecrets) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSecrets) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignatureSecrets) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OneTimeSignatureVerifier)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OneTimeSignatureVerifier") + return + } + } + if zb0006 > 0 { + zb0006-- + (*z).OneTimeSignatureSecretsPersistent.FirstBatch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstBatch") + return + } + } + if zb0006 > 0 { + zb0006-- + var zb0008 int + var zb0009 bool + zb0008, zb0009, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batches") + return + } + if zb0009 { + (*z).OneTimeSignatureSecretsPersistent.Batches = nil + } else if (*z).OneTimeSignatureSecretsPersistent.Batches != nil && cap((*z).OneTimeSignatureSecretsPersistent.Batches) >= zb0008 { + (*z).OneTimeSignatureSecretsPersistent.Batches = ((*z).OneTimeSignatureSecretsPersistent.Batches)[:zb0008] + } else { + (*z).OneTimeSignatureSecretsPersistent.Batches = make([]ephemeralSubkey, zb0008) + } + for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { + bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batches", zb0002) + return + } + } + } + if zb0006 > 0 { + zb0006-- + (*z).OneTimeSignatureSecretsPersistent.FirstOffset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstOffset") + return + } + } + if zb0006 > 0 { + zb0006-- + var zb0010 int + var zb0011 bool + zb0010, zb0011, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Offsets") + return + } + if zb0011 { + (*z).OneTimeSignatureSecretsPersistent.Offsets = nil + } else if (*z).OneTimeSignatureSecretsPersistent.Offsets != nil && cap((*z).OneTimeSignatureSecretsPersistent.Offsets) >= zb0010 { + (*z).OneTimeSignatureSecretsPersistent.Offsets = ((*z).OneTimeSignatureSecretsPersistent.Offsets)[:zb0010] + } else { + (*z).OneTimeSignatureSecretsPersistent.Offsets = make([]ephemeralSubkey, zb0010) + } + for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { + bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Offsets", zb0003) + return + } + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OffsetsPK2") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OffsetsPK2Sig") + return + } + } + if zb0006 > 0 { + err = msgp.ErrTooManyArrayFields(zb0006) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0007 { + (*z) = OneTimeSignatureSecrets{} + } + for zb0006 > 0 { + zb0006-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "OneTimeSignatureVerifier": + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OneTimeSignatureVerifier)[:]) + if err != nil { + err = msgp.WrapError(err, "OneTimeSignatureVerifier") + return + } + case "First": + (*z).OneTimeSignatureSecretsPersistent.FirstBatch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "FirstBatch") + return + } + case "Sub": + var zb0012 int + var zb0013 bool + zb0012, zb0013, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Batches") + return + } + if zb0013 { + (*z).OneTimeSignatureSecretsPersistent.Batches = nil + } else if (*z).OneTimeSignatureSecretsPersistent.Batches != nil && cap((*z).OneTimeSignatureSecretsPersistent.Batches) >= zb0012 { + (*z).OneTimeSignatureSecretsPersistent.Batches = ((*z).OneTimeSignatureSecretsPersistent.Batches)[:zb0012] + } else { + (*z).OneTimeSignatureSecretsPersistent.Batches = make([]ephemeralSubkey, zb0012) + } + for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { + bts, err = (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Batches", zb0002) + return + } + } + case "firstoff": + (*z).OneTimeSignatureSecretsPersistent.FirstOffset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "FirstOffset") + return + } + case "offkeys": + var zb0014 int + var zb0015 bool + zb0014, zb0015, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Offsets") + return + } + if zb0015 { + (*z).OneTimeSignatureSecretsPersistent.Offsets = nil + } else if (*z).OneTimeSignatureSecretsPersistent.Offsets != nil && cap((*z).OneTimeSignatureSecretsPersistent.Offsets) >= zb0014 { + (*z).OneTimeSignatureSecretsPersistent.Offsets = ((*z).OneTimeSignatureSecretsPersistent.Offsets)[:zb0014] + } else { + (*z).OneTimeSignatureSecretsPersistent.Offsets = make([]ephemeralSubkey, zb0014) + } + for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { + bts, err = (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Offsets", zb0003) + return + } + } + case "offpk2": + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2)[:]) + if err != nil { + err = msgp.WrapError(err, "OffsetsPK2") + return + } + case "offpk2sig": + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "OffsetsPK2Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *OneTimeSignatureSecrets) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSecrets) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignatureSecrets) Msgsize() (s int) { + s = 1 + 25 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 6 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + for zb0002 := range (*z).OneTimeSignatureSecretsPersistent.Batches { + s += (*z).OneTimeSignatureSecretsPersistent.Batches[zb0002].Msgsize() + } + s += 9 + msgp.Uint64Size + 8 + msgp.ArrayHeaderSize + for zb0003 := range (*z).OneTimeSignatureSecretsPersistent.Offsets { + s += (*z).OneTimeSignatureSecretsPersistent.Offsets[zb0003].Msgsize() + } + s += 7 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 10 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignatureSecrets) MsgIsZero() bool { + return ((*z).OneTimeSignatureSecretsPersistent.OneTimeSignatureVerifier == (OneTimeSignatureVerifier{})) && ((*z).OneTimeSignatureSecretsPersistent.FirstBatch == 0) && (len((*z).OneTimeSignatureSecretsPersistent.Batches) == 0) && ((*z).OneTimeSignatureSecretsPersistent.FirstOffset == 0) && (len((*z).OneTimeSignatureSecretsPersistent.Offsets) == 0) && ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2 == (ed25519PublicKey{})) && ((*z).OneTimeSignatureSecretsPersistent.OffsetsPK2Sig == (ed25519Signature{})) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignatureSecretsPersistent) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0006Len := uint32(7) + var zb0006Mask uint8 /* 8 bits */ + if (*z).FirstBatch == 0 { + zb0006Len-- + zb0006Mask |= 0x1 + } + if (*z).OneTimeSignatureVerifier == (OneTimeSignatureVerifier{}) { + zb0006Len-- + zb0006Mask |= 0x2 + } + if len((*z).Batches) == 0 { + zb0006Len-- + zb0006Mask |= 0x4 + } + if (*z).FirstOffset == 0 { + zb0006Len-- + zb0006Mask |= 0x10 + } + if len((*z).Offsets) == 0 { + zb0006Len-- + zb0006Mask |= 0x20 + } + if (*z).OffsetsPK2 == (ed25519PublicKey{}) { + zb0006Len-- + zb0006Mask |= 0x40 + } + if (*z).OffsetsPK2Sig == (ed25519Signature{}) { + zb0006Len-- + zb0006Mask |= 0x80 + } + // variable map header, size zb0006Len + o = append(o, 0x80|uint8(zb0006Len)) + if zb0006Len != 0 { + if (zb0006Mask & 0x1) == 0 { // if not empty + // string "First" + o = append(o, 0xa5, 0x46, 0x69, 0x72, 0x73, 0x74) + o = msgp.AppendUint64(o, (*z).FirstBatch) + } + if (zb0006Mask & 0x2) == 0 { // if not empty + // string "OneTimeSignatureVerifier" + o = append(o, 0xb8, 0x4f, 0x6e, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72) + o = msgp.AppendBytes(o, ((*z).OneTimeSignatureVerifier)[:]) + } + if (zb0006Mask & 0x4) == 0 { // if not empty + // string "Sub" + o = append(o, 0xa3, 0x53, 0x75, 0x62) + if (*z).Batches == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Batches))) + } + for zb0002 := range (*z).Batches { + o, err = (*z).Batches[zb0002].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Batches", zb0002) + return + } + } + } + if (zb0006Mask & 0x10) == 0 { // if not empty + // string "firstoff" + o = append(o, 0xa8, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6f, 0x66, 0x66) + o = msgp.AppendUint64(o, (*z).FirstOffset) + } + if (zb0006Mask & 0x20) == 0 { // if not empty + // string "offkeys" + o = append(o, 0xa7, 0x6f, 0x66, 0x66, 0x6b, 0x65, 0x79, 0x73) + if (*z).Offsets == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Offsets))) + } + for zb0003 := range (*z).Offsets { + o, err = (*z).Offsets[zb0003].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Offsets", zb0003) + return + } + } + } + if (zb0006Mask & 0x40) == 0 { // if not empty + // string "offpk2" + o = append(o, 0xa6, 0x6f, 0x66, 0x66, 0x70, 0x6b, 0x32) + o = msgp.AppendBytes(o, ((*z).OffsetsPK2)[:]) + } + if (zb0006Mask & 0x80) == 0 { // if not empty + // string "offpk2sig" + o = append(o, 0xa9, 0x6f, 0x66, 0x66, 0x70, 0x6b, 0x32, 0x73, 0x69, 0x67) + o = msgp.AppendBytes(o, ((*z).OffsetsPK2Sig)[:]) + } + } + return +} + +func (_ *OneTimeSignatureSecretsPersistent) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSecretsPersistent) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignatureSecretsPersistent) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureVerifier)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OneTimeSignatureVerifier") + return + } + } + if zb0006 > 0 { + zb0006-- + (*z).FirstBatch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstBatch") + return + } + } + if zb0006 > 0 { + zb0006-- + var zb0008 int + var zb0009 bool + zb0008, zb0009, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batches") + return + } + if zb0009 { + (*z).Batches = nil + } else if (*z).Batches != nil && cap((*z).Batches) >= zb0008 { + (*z).Batches = ((*z).Batches)[:zb0008] + } else { + (*z).Batches = make([]ephemeralSubkey, zb0008) + } + for zb0002 := range (*z).Batches { + bts, err = (*z).Batches[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batches", zb0002) + return + } + } + } + if zb0006 > 0 { + zb0006-- + (*z).FirstOffset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstOffset") + return + } + } + if zb0006 > 0 { + zb0006-- + var zb0010 int + var zb0011 bool + zb0010, zb0011, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Offsets") + return + } + if zb0011 { + (*z).Offsets = nil + } else if (*z).Offsets != nil && cap((*z).Offsets) >= zb0010 { + (*z).Offsets = ((*z).Offsets)[:zb0010] + } else { + (*z).Offsets = make([]ephemeralSubkey, zb0010) + } + for zb0003 := range (*z).Offsets { + bts, err = (*z).Offsets[zb0003].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Offsets", zb0003) + return + } + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OffsetsPK2)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OffsetsPK2") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).OffsetsPK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "OffsetsPK2Sig") + return + } + } + if zb0006 > 0 { + err = msgp.ErrTooManyArrayFields(zb0006) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0007 { + (*z) = OneTimeSignatureSecretsPersistent{} + } + for zb0006 > 0 { + zb0006-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "OneTimeSignatureVerifier": + bts, err = msgp.ReadExactBytes(bts, ((*z).OneTimeSignatureVerifier)[:]) + if err != nil { + err = msgp.WrapError(err, "OneTimeSignatureVerifier") + return + } + case "First": + (*z).FirstBatch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "FirstBatch") + return + } + case "Sub": + var zb0012 int + var zb0013 bool + zb0012, zb0013, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Batches") + return + } + if zb0013 { + (*z).Batches = nil + } else if (*z).Batches != nil && cap((*z).Batches) >= zb0012 { + (*z).Batches = ((*z).Batches)[:zb0012] + } else { + (*z).Batches = make([]ephemeralSubkey, zb0012) + } + for zb0002 := range (*z).Batches { + bts, err = (*z).Batches[zb0002].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Batches", zb0002) + return + } + } + case "firstoff": + (*z).FirstOffset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "FirstOffset") + return + } + case "offkeys": + var zb0014 int + var zb0015 bool + zb0014, zb0015, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Offsets") + return + } + if zb0015 { + (*z).Offsets = nil + } else if (*z).Offsets != nil && cap((*z).Offsets) >= zb0014 { + (*z).Offsets = ((*z).Offsets)[:zb0014] + } else { + (*z).Offsets = make([]ephemeralSubkey, zb0014) + } + for zb0003 := range (*z).Offsets { + bts, err = (*z).Offsets[zb0003].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Offsets", zb0003) + return + } + } + case "offpk2": + bts, err = msgp.ReadExactBytes(bts, ((*z).OffsetsPK2)[:]) + if err != nil { + err = msgp.WrapError(err, "OffsetsPK2") + return + } + case "offpk2sig": + bts, err = msgp.ReadExactBytes(bts, ((*z).OffsetsPK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "OffsetsPK2Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *OneTimeSignatureSecretsPersistent) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSecretsPersistent) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignatureSecretsPersistent) Msgsize() (s int) { + s = 1 + 25 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 6 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + for zb0002 := range (*z).Batches { + s += (*z).Batches[zb0002].Msgsize() + } + s += 9 + msgp.Uint64Size + 8 + msgp.ArrayHeaderSize + for zb0003 := range (*z).Offsets { + s += (*z).Offsets[zb0003].Msgsize() + } + s += 7 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 10 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignatureSecretsPersistent) MsgIsZero() bool { + return ((*z).OneTimeSignatureVerifier == (OneTimeSignatureVerifier{})) && ((*z).FirstBatch == 0) && (len((*z).Batches) == 0) && ((*z).FirstOffset == 0) && (len((*z).Offsets) == 0) && ((*z).OffsetsPK2 == (ed25519PublicKey{})) && ((*z).OffsetsPK2Sig == (ed25519Signature{})) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignatureSubkeyBatchID) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 2 + // string "batch" + o = append(o, 0x82, 0xa5, 0x62, 0x61, 0x74, 0x63, 0x68) + o = msgp.AppendUint64(o, (*z).Batch) + // string "pk" + o = append(o, 0xa2, 0x70, 0x6b) + o = msgp.AppendBytes(o, ((*z).SubKeyPK)[:]) + return +} + +func (_ *OneTimeSignatureSubkeyBatchID) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSubkeyBatchID) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignatureSubkeyBatchID) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + bts, err = msgp.ReadExactBytes(bts, ((*z).SubKeyPK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SubKeyPK") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Batch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batch") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = OneTimeSignatureSubkeyBatchID{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "pk": + bts, err = msgp.ReadExactBytes(bts, ((*z).SubKeyPK)[:]) + if err != nil { + err = msgp.WrapError(err, "SubKeyPK") + return + } + case "batch": + (*z).Batch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Batch") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *OneTimeSignatureSubkeyBatchID) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSubkeyBatchID) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignatureSubkeyBatchID) Msgsize() (s int) { + s = 1 + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 6 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignatureSubkeyBatchID) MsgIsZero() bool { + return ((*z).SubKeyPK == (ed25519PublicKey{})) && ((*z).Batch == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignatureSubkeyOffsetID) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 3 + // string "batch" + o = append(o, 0x83, 0xa5, 0x62, 0x61, 0x74, 0x63, 0x68) + o = msgp.AppendUint64(o, (*z).Batch) + // string "off" + o = append(o, 0xa3, 0x6f, 0x66, 0x66) + o = msgp.AppendUint64(o, (*z).Offset) + // string "pk" + o = append(o, 0xa2, 0x70, 0x6b) + o = msgp.AppendBytes(o, ((*z).SubKeyPK)[:]) + return +} + +func (_ *OneTimeSignatureSubkeyOffsetID) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSubkeyOffsetID) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignatureSubkeyOffsetID) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + bts, err = msgp.ReadExactBytes(bts, ((*z).SubKeyPK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SubKeyPK") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Batch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Batch") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Offset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Offset") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = OneTimeSignatureSubkeyOffsetID{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "pk": + bts, err = msgp.ReadExactBytes(bts, ((*z).SubKeyPK)[:]) + if err != nil { + err = msgp.WrapError(err, "SubKeyPK") + return + } + case "batch": + (*z).Batch, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Batch") + return + } + case "off": + (*z).Offset, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Offset") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *OneTimeSignatureSubkeyOffsetID) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureSubkeyOffsetID) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignatureSubkeyOffsetID) Msgsize() (s int) { + s = 1 + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 6 + msgp.Uint64Size + 4 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignatureSubkeyOffsetID) MsgIsZero() bool { + return ((*z).SubKeyPK == (ed25519PublicKey{})) && ((*z).Batch == 0) && ((*z).Offset == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *OneTimeSignatureVerifier) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *OneTimeSignatureVerifier) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureVerifier) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *OneTimeSignatureVerifier) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *OneTimeSignatureVerifier) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*OneTimeSignatureVerifier) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *OneTimeSignatureVerifier) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *OneTimeSignatureVerifier) MsgIsZero() bool { + return (*z) == (OneTimeSignatureVerifier{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *PrivateKey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *PrivateKey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*PrivateKey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *PrivateKey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*PrivateKey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *PrivateKey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *PrivateKey) MsgIsZero() bool { + return (*z) == (PrivateKey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *PublicKey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *PublicKey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*PublicKey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *PublicKey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*PublicKey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *PublicKey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *PublicKey) MsgIsZero() bool { + return (*z) == (PublicKey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Seed) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *Seed) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Seed) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *Seed) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Seed) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Seed) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Seed) MsgIsZero() bool { + return (*z) == (Seed{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Signature) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *Signature) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Signature) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *Signature) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Signature) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Signature) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Signature) MsgIsZero() bool { + return (*z) == (Signature{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *VrfOutput) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *VrfOutput) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfOutput) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *VrfOutput) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *VrfOutput) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfOutput) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *VrfOutput) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *VrfOutput) MsgIsZero() bool { + return (*z) == (VrfOutput{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *VrfPrivkey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *VrfPrivkey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfPrivkey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *VrfPrivkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *VrfPrivkey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfPrivkey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *VrfPrivkey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *VrfPrivkey) MsgIsZero() bool { + return (*z) == (VrfPrivkey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *VrfProof) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *VrfProof) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfProof) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *VrfProof) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *VrfProof) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfProof) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *VrfProof) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (80 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *VrfProof) MsgIsZero() bool { + return (*z) == (VrfProof{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *VrfPubkey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *VrfPubkey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfPubkey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *VrfPubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *VrfPubkey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*VrfPubkey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *VrfPubkey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *VrfPubkey) MsgIsZero() bool { + return (*z) == (VrfPubkey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *ed25519PrivateKey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *ed25519PrivateKey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519PrivateKey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ed25519PrivateKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *ed25519PrivateKey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519PrivateKey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ed25519PrivateKey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ed25519PrivateKey) MsgIsZero() bool { + return (*z) == (ed25519PrivateKey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *ed25519PublicKey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *ed25519PublicKey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519PublicKey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ed25519PublicKey) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *ed25519PublicKey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519PublicKey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ed25519PublicKey) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ed25519PublicKey) MsgIsZero() bool { + return (*z) == (ed25519PublicKey{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *ed25519Seed) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *ed25519Seed) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519Seed) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ed25519Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *ed25519Seed) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519Seed) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ed25519Seed) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ed25519Seed) MsgIsZero() bool { + return (*z) == (ed25519Seed{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *ed25519Signature) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *ed25519Signature) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519Signature) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ed25519Signature) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *ed25519Signature) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ed25519Signature) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ed25519Signature) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ed25519Signature) MsgIsZero() bool { + return (*z) == (ed25519Signature{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *ephemeralSubkey) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 4 + // string "PK" + o = append(o, 0x84, 0xa2, 0x50, 0x4b) + o = msgp.AppendBytes(o, ((*z).PK)[:]) + // string "PKSig" + o = append(o, 0xa5, 0x50, 0x4b, 0x53, 0x69, 0x67) + o = msgp.AppendBytes(o, ((*z).PKSigOld)[:]) + // string "SK" + o = append(o, 0xa2, 0x53, 0x4b) + o = msgp.AppendBytes(o, ((*z).SK)[:]) + // string "sig2" + o = append(o, 0xa4, 0x73, 0x69, 0x67, 0x32) + o = msgp.AppendBytes(o, ((*z).PKSigNew)[:]) + return +} + +func (_ *ephemeralSubkey) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ephemeralSubkey) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ephemeralSubkey) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0005 int + var zb0006 bool + zb0005, zb0006, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0005, zb0006, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0005 > 0 { + zb0005-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = msgp.ReadExactBytes(bts, ((*z).SK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SK") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigOld)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PKSigOld") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigNew)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PKSigNew") + return + } + } + if zb0005 > 0 { + err = msgp.ErrTooManyArrayFields(zb0005) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 { + (*z) = ephemeralSubkey{} + } + for zb0005 > 0 { + zb0005-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "PK": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "PK") + return + } + case "SK": + bts, err = msgp.ReadExactBytes(bts, ((*z).SK)[:]) + if err != nil { + err = msgp.WrapError(err, "SK") + return + } + case "PKSig": + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigOld)[:]) + if err != nil { + err = msgp.WrapError(err, "PKSigOld") + return + } + case "sig2": + bts, err = msgp.ReadExactBytes(bts, ((*z).PKSigNew)[:]) + if err != nil { + err = msgp.WrapError(err, "PKSigNew") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *ephemeralSubkey) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ephemeralSubkey) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ephemeralSubkey) Msgsize() (s int) { + s = 1 + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 3 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 6 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 5 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ephemeralSubkey) MsgIsZero() bool { + return ((*z).PK == (ed25519PublicKey{})) && ((*z).SK == (ed25519PrivateKey{})) && ((*z).PKSigOld == (ed25519Signature{})) && ((*z).PKSigNew == (ed25519Signature{})) +} diff --git a/crypto/msgp_gen_test.go b/crypto/msgp_gen_test.go new file mode 100644 index 0000000000..6b4266149a --- /dev/null +++ b/crypto/msgp_gen_test.go @@ -0,0 +1,1436 @@ +package crypto + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalDigest(t *testing.T) { + v := Digest{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingDigest(t *testing.T) { + protocol.RunEncodingTest(t, &Digest{}) +} + +func BenchmarkMarshalMsgDigest(b *testing.B) { + v := Digest{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgDigest(b *testing.B) { + v := Digest{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalDigest(b *testing.B) { + v := Digest{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalMasterDerivationKey(t *testing.T) { + v := MasterDerivationKey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingMasterDerivationKey(t *testing.T) { + protocol.RunEncodingTest(t, &MasterDerivationKey{}) +} + +func BenchmarkMarshalMsgMasterDerivationKey(b *testing.B) { + v := MasterDerivationKey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgMasterDerivationKey(b *testing.B) { + v := MasterDerivationKey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalMasterDerivationKey(b *testing.B) { + v := MasterDerivationKey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalMultisigSig(t *testing.T) { + v := MultisigSig{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingMultisigSig(t *testing.T) { + protocol.RunEncodingTest(t, &MultisigSig{}) +} + +func BenchmarkMarshalMsgMultisigSig(b *testing.B) { + v := MultisigSig{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgMultisigSig(b *testing.B) { + v := MultisigSig{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalMultisigSig(b *testing.B) { + v := MultisigSig{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalMultisigSubsig(t *testing.T) { + v := MultisigSubsig{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingMultisigSubsig(t *testing.T) { + protocol.RunEncodingTest(t, &MultisigSubsig{}) +} + +func BenchmarkMarshalMsgMultisigSubsig(b *testing.B) { + v := MultisigSubsig{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgMultisigSubsig(b *testing.B) { + v := MultisigSubsig{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalMultisigSubsig(b *testing.B) { + v := MultisigSubsig{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignature(t *testing.T) { + v := OneTimeSignature{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignature(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignature{}) +} + +func BenchmarkMarshalMsgOneTimeSignature(b *testing.B) { + v := OneTimeSignature{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignature(b *testing.B) { + v := OneTimeSignature{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignature(b *testing.B) { + v := OneTimeSignature{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignatureSecrets(t *testing.T) { + v := OneTimeSignatureSecrets{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignatureSecrets(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignatureSecrets{}) +} + +func BenchmarkMarshalMsgOneTimeSignatureSecrets(b *testing.B) { + v := OneTimeSignatureSecrets{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignatureSecrets(b *testing.B) { + v := OneTimeSignatureSecrets{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignatureSecrets(b *testing.B) { + v := OneTimeSignatureSecrets{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignatureSecretsPersistent(t *testing.T) { + v := OneTimeSignatureSecretsPersistent{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignatureSecretsPersistent(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignatureSecretsPersistent{}) +} + +func BenchmarkMarshalMsgOneTimeSignatureSecretsPersistent(b *testing.B) { + v := OneTimeSignatureSecretsPersistent{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignatureSecretsPersistent(b *testing.B) { + v := OneTimeSignatureSecretsPersistent{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignatureSecretsPersistent(b *testing.B) { + v := OneTimeSignatureSecretsPersistent{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignatureSubkeyBatchID(t *testing.T) { + v := OneTimeSignatureSubkeyBatchID{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignatureSubkeyBatchID(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignatureSubkeyBatchID{}) +} + +func BenchmarkMarshalMsgOneTimeSignatureSubkeyBatchID(b *testing.B) { + v := OneTimeSignatureSubkeyBatchID{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignatureSubkeyBatchID(b *testing.B) { + v := OneTimeSignatureSubkeyBatchID{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignatureSubkeyBatchID(b *testing.B) { + v := OneTimeSignatureSubkeyBatchID{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignatureSubkeyOffsetID(t *testing.T) { + v := OneTimeSignatureSubkeyOffsetID{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignatureSubkeyOffsetID(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignatureSubkeyOffsetID{}) +} + +func BenchmarkMarshalMsgOneTimeSignatureSubkeyOffsetID(b *testing.B) { + v := OneTimeSignatureSubkeyOffsetID{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignatureSubkeyOffsetID(b *testing.B) { + v := OneTimeSignatureSubkeyOffsetID{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignatureSubkeyOffsetID(b *testing.B) { + v := OneTimeSignatureSubkeyOffsetID{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalOneTimeSignatureVerifier(t *testing.T) { + v := OneTimeSignatureVerifier{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingOneTimeSignatureVerifier(t *testing.T) { + protocol.RunEncodingTest(t, &OneTimeSignatureVerifier{}) +} + +func BenchmarkMarshalMsgOneTimeSignatureVerifier(b *testing.B) { + v := OneTimeSignatureVerifier{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgOneTimeSignatureVerifier(b *testing.B) { + v := OneTimeSignatureVerifier{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalOneTimeSignatureVerifier(b *testing.B) { + v := OneTimeSignatureVerifier{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalPrivateKey(t *testing.T) { + v := PrivateKey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingPrivateKey(t *testing.T) { + protocol.RunEncodingTest(t, &PrivateKey{}) +} + +func BenchmarkMarshalMsgPrivateKey(b *testing.B) { + v := PrivateKey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgPrivateKey(b *testing.B) { + v := PrivateKey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalPrivateKey(b *testing.B) { + v := PrivateKey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalPublicKey(t *testing.T) { + v := PublicKey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingPublicKey(t *testing.T) { + protocol.RunEncodingTest(t, &PublicKey{}) +} + +func BenchmarkMarshalMsgPublicKey(b *testing.B) { + v := PublicKey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgPublicKey(b *testing.B) { + v := PublicKey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalPublicKey(b *testing.B) { + v := PublicKey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSeed(t *testing.T) { + v := Seed{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSeed(t *testing.T) { + protocol.RunEncodingTest(t, &Seed{}) +} + +func BenchmarkMarshalMsgSeed(b *testing.B) { + v := Seed{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSeed(b *testing.B) { + v := Seed{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSeed(b *testing.B) { + v := Seed{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignature(t *testing.T) { + v := Signature{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignature(t *testing.T) { + protocol.RunEncodingTest(t, &Signature{}) +} + +func BenchmarkMarshalMsgSignature(b *testing.B) { + v := Signature{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignature(b *testing.B) { + v := Signature{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignature(b *testing.B) { + v := Signature{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalVrfOutput(t *testing.T) { + v := VrfOutput{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingVrfOutput(t *testing.T) { + protocol.RunEncodingTest(t, &VrfOutput{}) +} + +func BenchmarkMarshalMsgVrfOutput(b *testing.B) { + v := VrfOutput{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgVrfOutput(b *testing.B) { + v := VrfOutput{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalVrfOutput(b *testing.B) { + v := VrfOutput{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalVrfPrivkey(t *testing.T) { + v := VrfPrivkey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingVrfPrivkey(t *testing.T) { + protocol.RunEncodingTest(t, &VrfPrivkey{}) +} + +func BenchmarkMarshalMsgVrfPrivkey(b *testing.B) { + v := VrfPrivkey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgVrfPrivkey(b *testing.B) { + v := VrfPrivkey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalVrfPrivkey(b *testing.B) { + v := VrfPrivkey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalVrfProof(t *testing.T) { + v := VrfProof{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingVrfProof(t *testing.T) { + protocol.RunEncodingTest(t, &VrfProof{}) +} + +func BenchmarkMarshalMsgVrfProof(b *testing.B) { + v := VrfProof{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgVrfProof(b *testing.B) { + v := VrfProof{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalVrfProof(b *testing.B) { + v := VrfProof{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalVrfPubkey(t *testing.T) { + v := VrfPubkey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingVrfPubkey(t *testing.T) { + protocol.RunEncodingTest(t, &VrfPubkey{}) +} + +func BenchmarkMarshalMsgVrfPubkey(b *testing.B) { + v := VrfPubkey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgVrfPubkey(b *testing.B) { + v := VrfPubkey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalVrfPubkey(b *testing.B) { + v := VrfPubkey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshaled25519PrivateKey(t *testing.T) { + v := ed25519PrivateKey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodinged25519PrivateKey(t *testing.T) { + protocol.RunEncodingTest(t, &ed25519PrivateKey{}) +} + +func BenchmarkMarshalMsged25519PrivateKey(b *testing.B) { + v := ed25519PrivateKey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsged25519PrivateKey(b *testing.B) { + v := ed25519PrivateKey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshaled25519PrivateKey(b *testing.B) { + v := ed25519PrivateKey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshaled25519PublicKey(t *testing.T) { + v := ed25519PublicKey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodinged25519PublicKey(t *testing.T) { + protocol.RunEncodingTest(t, &ed25519PublicKey{}) +} + +func BenchmarkMarshalMsged25519PublicKey(b *testing.B) { + v := ed25519PublicKey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsged25519PublicKey(b *testing.B) { + v := ed25519PublicKey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshaled25519PublicKey(b *testing.B) { + v := ed25519PublicKey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshaled25519Seed(t *testing.T) { + v := ed25519Seed{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodinged25519Seed(t *testing.T) { + protocol.RunEncodingTest(t, &ed25519Seed{}) +} + +func BenchmarkMarshalMsged25519Seed(b *testing.B) { + v := ed25519Seed{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsged25519Seed(b *testing.B) { + v := ed25519Seed{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshaled25519Seed(b *testing.B) { + v := ed25519Seed{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshaled25519Signature(t *testing.T) { + v := ed25519Signature{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodinged25519Signature(t *testing.T) { + protocol.RunEncodingTest(t, &ed25519Signature{}) +} + +func BenchmarkMarshalMsged25519Signature(b *testing.B) { + v := ed25519Signature{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsged25519Signature(b *testing.B) { + v := ed25519Signature{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshaled25519Signature(b *testing.B) { + v := ed25519Signature{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalephemeralSubkey(t *testing.T) { + v := ephemeralSubkey{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingephemeralSubkey(t *testing.T) { + protocol.RunEncodingTest(t, &ephemeralSubkey{}) +} + +func BenchmarkMarshalMsgephemeralSubkey(b *testing.B) { + v := ephemeralSubkey{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgephemeralSubkey(b *testing.B) { + v := ephemeralSubkey{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalephemeralSubkey(b *testing.B) { + v := ephemeralSubkey{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/crypto/multisig.go b/crypto/multisig.go index 4c6ccf18a3..6a33674c38 100644 --- a/crypto/multisig.go +++ b/crypto/multisig.go @@ -38,7 +38,7 @@ type MultisigSig struct { Version uint8 `codec:"v"` Threshold uint8 `codec:"thr"` - Subsigs []MultisigSubsig `codec:"subsig"` + Subsigs []MultisigSubsig `codec:"subsig,allocbound=maxMultisig"` } // MultisigPreimageFromPKs makes an empty MultisigSig for a given preimage. It should be renamed. diff --git a/crypto/onetimesig.go b/crypto/onetimesig.go index a04dfd0d75..4c7851c134 100644 --- a/crypto/onetimesig.go +++ b/crypto/onetimesig.go @@ -36,6 +36,11 @@ import ( // secret-holder from signing a contradictory message in the future in the event // of a secret-key compromise. type OneTimeSignature struct { + // Unfortunately we forgot to mark this struct as omitempty at + // one point, and now it's hard to recover from that if we want + // to preserve encodings.. + _struct struct{} `codec:""` + // Sig is a signature of msg under the key PK. Sig ed25519Signature `codec:"s"` PK ed25519PublicKey `codec:"p"` @@ -57,6 +62,11 @@ type OneTimeSignature struct { // A OneTimeSignatureSubkeyBatchID identifies an ephemeralSubkey of a batch // for the purposes of signing it with the top-level master key. type OneTimeSignatureSubkeyBatchID struct { + // Unfortunately we forgot to mark this struct as omitempty at + // one point, and now it's hard to recover from that if we want + // to preserve encodings.. + _struct struct{} `codec:""` + SubKeyPK ed25519PublicKey `codec:"pk"` Batch uint64 `codec:"batch"` } @@ -65,12 +75,17 @@ type OneTimeSignatureSubkeyBatchID struct { // This is used to sign an intermediate subkey for a batch, in the new style // (contrast with OneTimeSignatureIdentifier.BatchBytes). func (batch OneTimeSignatureSubkeyBatchID) ToBeHashed() (protocol.HashID, []byte) { - return protocol.OneTimeSigKey1, protocol.Encode(batch) + return protocol.OneTimeSigKey1, protocol.Encode(&batch) } // A OneTimeSignatureSubkeyOffsetID identifies an ephemeralSubkey of a specific // offset within a batch, for the purposes of signing it with the batch subkey. type OneTimeSignatureSubkeyOffsetID struct { + // Unfortunately we forgot to mark this struct as omitempty at + // one point, and now it's hard to recover from that if we want + // to preserve encodings.. + _struct struct{} `codec:""` + SubKeyPK ed25519PublicKey `codec:"pk"` Batch uint64 `codec:"batch"` Offset uint64 `codec:"off"` @@ -79,7 +94,7 @@ type OneTimeSignatureSubkeyOffsetID struct { // ToBeHashed implements the Hashable interface for a OneTimeSignatureSubkeyOffsetID. // This is used to sign a subkey for a specific offset in a batch. func (off OneTimeSignatureSubkeyOffsetID) ToBeHashed() (protocol.HashID, []byte) { - return protocol.OneTimeSigKey2, protocol.Encode(off) + return protocol.OneTimeSigKey2, protocol.Encode(&off) } // A OneTimeSignatureIdentifier is an identifier under which a OneTimeSignature is @@ -117,6 +132,8 @@ type OneTimeSignatureVerifier ed25519PublicKey // OneTimeSignatureIdentifiers, protecting the integrity of the messages signed // under those identifiers. type OneTimeSignatureSecrets struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + OneTimeSignatureSecretsPersistent // We keep track of an RNG, used to generate additional randomness. @@ -132,18 +149,20 @@ type OneTimeSignatureSecrets struct { // OneTimeSignatureSecretsPersistent denotes the fields of a OneTimeSignatureSecrets // that get stored to persistent storage (through reflection on exported fields). type OneTimeSignatureSecretsPersistent struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + OneTimeSignatureVerifier // FirstBatch denotes the first batch whose subkey appears in Batches. // The odd `codec:` name is for backwards compatibility with previous // stored keys where we failed to give any explicit `codec:` name. FirstBatch uint64 `codec:"First"` - Batches []ephemeralSubkey `codec:"Sub"` + Batches []ephemeralSubkey `codec:"Sub,allocbound=-"` // FirstOffset denotes the first offset whose subkey appears in Offsets. // These subkeys correspond to batch FirstBatch-1. FirstOffset uint64 `codec:"firstoff"` - Offsets []ephemeralSubkey `codec:"offkeys"` + Offsets []ephemeralSubkey `codec:"offkeys,allocbound=-"` // When Offsets is non-empty, OffsetsPK2 is the intermediate-level public // key that can be used to verify signatures on the subkeys in Offsets, and @@ -156,6 +175,11 @@ type OneTimeSignatureSecretsPersistent struct { // An ephemeralSubkey produces OneTimeSignatures for messages and is deleted // after use. type ephemeralSubkey struct { + // Unfortunately we forgot to mark this struct as omitempty at + // one point, and now it's hard to recover from that if we want + // to preserve encodings.. + _struct struct{} `codec:""` + PK ed25519PublicKey SK ed25519PrivateKey diff --git a/crypto/vrf.go b/crypto/vrf.go index f1d8e13375..53a13a6a64 100644 --- a/crypto/vrf.go +++ b/crypto/vrf.go @@ -56,15 +56,15 @@ func GenerateVRFSecrets() *VRFSecrets { type ( // A VrfPrivkey is a private key used for producing VRF proofs. // Specifically, we use a 64-byte ed25519 private key (the latter 32-bytes are the precomputed public key) - VrfPrivkey [64]uint8 + VrfPrivkey [64]byte // A VrfPubkey is a public key that can be used to verify VRF proofs. - VrfPubkey [32]uint8 + VrfPubkey [32]byte // A VrfProof for a message can be generated with a secret key and verified against a public key, like a signature. // Proofs are malleable, however, for a given message and public key, the VRF output that can be computed from a proof is unique. - VrfProof [80]uint8 + VrfProof [80]byte // VrfOutput is a 64-byte pseudorandom value that can be computed from a VrfProof. // The VRF scheme guarantees that such output will be unique - VrfOutput [64]uint8 + VrfOutput [64]byte ) // VrfKeygenFromSeed deterministically generates a VRF keypair from 32 bytes of (secret) entropy. diff --git a/daemon/algod/api/client/restClient.go b/daemon/algod/api/client/restClient.go index d10579bb74..c5471d0c34 100644 --- a/daemon/algod/api/client/restClient.go +++ b/daemon/algod/api/client/restClient.go @@ -308,7 +308,7 @@ func (client RestClient) SuggestedParams() (response v1.TransactionParams, err e // SendRawTransaction gets a SignedTxn and broadcasts it to the network func (client RestClient) SendRawTransaction(txn transactions.SignedTxn) (response v1.TransactionID, err error) { - err = client.post(&response, "/transactions", protocol.Encode(txn)) + err = client.post(&response, "/transactions", protocol.Encode(&txn)) return } @@ -318,7 +318,7 @@ func (client RestClient) SendRawTransactionGroup(txgroup []transactions.SignedTx // which can be computed by the client anyway.. var enc []byte for _, tx := range txgroup { - enc = append(enc, protocol.Encode(tx)...) + enc = append(enc, protocol.Encode(&tx)...) } var response v1.TransactionID diff --git a/daemon/kmd/api/v1/handlers.go b/daemon/kmd/api/v1/handlers.go index a984da2c40..eabddaac67 100644 --- a/daemon/kmd/api/v1/handlers.go +++ b/daemon/kmd/api/v1/handlers.go @@ -1135,7 +1135,7 @@ func postMultisigTransactionSignHandler(ctx reqContext, w http.ResponseWriter, r // Build the response resp := kmdapi.APIV1POSTMultisigTransactionSignResponse{ - Multisig: protocol.Encode(msig), + Multisig: protocol.Encode(&msig), } // Return and encode the response @@ -1194,7 +1194,7 @@ func postMultisigProgramSignHandler(ctx reqContext, w http.ResponseWriter, r *ht // Build the response resp := kmdapi.APIV1POSTMultisigProgramSignResponse{ - Multisig: protocol.Encode(msig), + Multisig: protocol.Encode(&msig), } // Return and encode the response diff --git a/daemon/kmd/client/wrappers.go b/daemon/kmd/client/wrappers.go index 581f66675e..f52e96879d 100644 --- a/daemon/kmd/client/wrappers.go +++ b/daemon/kmd/client/wrappers.go @@ -198,7 +198,7 @@ func (kcl KMDClient) ExportMasterDerivationKey(walletHandle []byte, walletPasswo // SignTransaction wraps kmdapi.APIV1POSTTransactionSignRequest func (kcl KMDClient) SignTransaction(walletHandle, pw []byte, tx transactions.Transaction) (resp kmdapi.APIV1POSTTransactionSignResponse, err error) { - txBytes := protocol.Encode(tx) + txBytes := protocol.Encode(&tx) req := kmdapi.APIV1POSTTransactionSignRequest{ WalletHandleToken: string(walletHandle), WalletPassword: string(pw), diff --git a/daemon/kmd/wallet/driver/ledger.go b/daemon/kmd/wallet/driver/ledger.go index 0e4d777d99..4ebddf1885 100644 --- a/daemon/kmd/wallet/driver/ledger.go +++ b/daemon/kmd/wallet/driver/ledger.go @@ -288,7 +288,7 @@ func (lw *LedgerWallet) SignTransaction(tx transactions.Transaction, pw []byte) return nil, err } - return protocol.Encode(transactions.SignedTxn{ + return protocol.Encode(&transactions.SignedTxn{ Txn: tx, Sig: sig, }), nil @@ -393,7 +393,7 @@ func (lw *LedgerWallet) signTransactionHelper(tx transactions.Transaction) (sig func (lw *LedgerWallet) sendTransactionMsgpack(tx transactions.Transaction) (sig crypto.Signature, err error) { var reply []byte - tosend := protocol.Encode(tx) + tosend := protocol.Encode(&tx) p1 := ledgerP1first p2 := ledgerP2more diff --git a/daemon/kmd/wallet/driver/sqlite.go b/daemon/kmd/wallet/driver/sqlite.go index c9942f6017..4f80f8f49c 100644 --- a/daemon/kmd/wallet/driver/sqlite.go +++ b/daemon/kmd/wallet/driver/sqlite.go @@ -1110,7 +1110,8 @@ func (sw *SQLiteWallet) SignTransaction(tx transactions.Transaction, pw []byte) } // Sign the transaction - stx = protocol.Encode(tx.Sign(secrets)) + stxn := tx.Sign(secrets) + stx = protocol.Encode(&stxn) return } diff --git a/data/basics/msgp_gen.go b/data/basics/msgp_gen.go new file mode 100644 index 0000000000..f540d8b5d7 --- /dev/null +++ b/data/basics/msgp_gen.go @@ -0,0 +1,2084 @@ +package basics + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "sort" + + "github.com/algorand/go-algorand/crypto" + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *AccountData) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0005Len := uint32(11) + var zb0005Mask uint16 /* 12 bits */ + if (*z).MicroAlgos.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x2 + } + if len((*z).AssetParams) == 0 { + zb0005Len-- + zb0005Mask |= 0x4 + } + if len((*z).Assets) == 0 { + zb0005Len-- + zb0005Mask |= 0x8 + } + if (*z).RewardsBase == 0 { + zb0005Len-- + zb0005Mask |= 0x10 + } + if (*z).RewardedMicroAlgos.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x20 + } + if (*z).Status == 0 { + zb0005Len-- + zb0005Mask |= 0x40 + } + if (*z).SelectionID.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x80 + } + if (*z).VoteID.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x100 + } + if (*z).VoteFirstValid == 0 { + zb0005Len-- + zb0005Mask |= 0x200 + } + if (*z).VoteKeyDilution == 0 { + zb0005Len-- + zb0005Mask |= 0x400 + } + if (*z).VoteLastValid == 0 { + zb0005Len-- + zb0005Mask |= 0x800 + } + // variable map header, size zb0005Len + o = append(o, 0x80|uint8(zb0005Len)) + if zb0005Len != 0 { + if (zb0005Mask & 0x2) == 0 { // if not empty + // string "algo" + o = append(o, 0xa4, 0x61, 0x6c, 0x67, 0x6f) + o, err = (*z).MicroAlgos.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "MicroAlgos") + return + } + } + if (zb0005Mask & 0x4) == 0 { // if not empty + // string "apar" + o = append(o, 0xa4, 0x61, 0x70, 0x61, 0x72) + if (*z).AssetParams == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendMapHeader(o, uint32(len((*z).AssetParams))) + } + zb0001_keys := make([]AssetIndex, 0, len((*z).AssetParams)) + for zb0001 := range (*z).AssetParams { + zb0001_keys = append(zb0001_keys, zb0001) + } + sort.Sort(SortAssetIndex(zb0001_keys)) + for _, zb0001 := range zb0001_keys { + zb0002 := (*z).AssetParams[zb0001] + _ = zb0002 + o, err = zb0001.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + o, err = zb0002.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + } + } + if (zb0005Mask & 0x8) == 0 { // if not empty + // string "asset" + o = append(o, 0xa5, 0x61, 0x73, 0x73, 0x65, 0x74) + if (*z).Assets == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendMapHeader(o, uint32(len((*z).Assets))) + } + zb0003_keys := make([]AssetIndex, 0, len((*z).Assets)) + for zb0003 := range (*z).Assets { + zb0003_keys = append(zb0003_keys, zb0003) + } + sort.Sort(SortAssetIndex(zb0003_keys)) + for _, zb0003 := range zb0003_keys { + zb0004 := (*z).Assets[zb0003] + _ = zb0004 + o, err = zb0003.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + // omitempty: check for empty values + zb0006Len := uint32(2) + var zb0006Mask uint8 /* 3 bits */ + if zb0004.Amount == 0 { + zb0006Len-- + zb0006Mask |= 0x2 + } + if zb0004.Frozen == false { + zb0006Len-- + zb0006Mask |= 0x4 + } + // variable map header, size zb0006Len + o = append(o, 0x80|uint8(zb0006Len)) + if zb0006Len != 0 { + if (zb0006Mask & 0x2) == 0 { // if not empty + // string "a" + o = append(o, 0xa1, 0x61) + o = msgp.AppendUint64(o, zb0004.Amount) + } + if (zb0006Mask & 0x4) == 0 { // if not empty + // string "f" + o = append(o, 0xa1, 0x66) + o = msgp.AppendBool(o, zb0004.Frozen) + } + } + } + } + if (zb0005Mask & 0x10) == 0 { // if not empty + // string "ebase" + o = append(o, 0xa5, 0x65, 0x62, 0x61, 0x73, 0x65) + o = msgp.AppendUint64(o, (*z).RewardsBase) + } + if (zb0005Mask & 0x20) == 0 { // if not empty + // string "ern" + o = append(o, 0xa3, 0x65, 0x72, 0x6e) + o, err = (*z).RewardedMicroAlgos.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardedMicroAlgos") + return + } + } + if (zb0005Mask & 0x40) == 0 { // if not empty + // string "onl" + o = append(o, 0xa3, 0x6f, 0x6e, 0x6c) + o = msgp.AppendByte(o, byte((*z).Status)) + } + if (zb0005Mask & 0x80) == 0 { // if not empty + // string "sel" + o = append(o, 0xa3, 0x73, 0x65, 0x6c) + o, err = (*z).SelectionID.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SelectionID") + return + } + } + if (zb0005Mask & 0x100) == 0 { // if not empty + // string "vote" + o = append(o, 0xa4, 0x76, 0x6f, 0x74, 0x65) + o, err = (*z).VoteID.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteID") + return + } + } + if (zb0005Mask & 0x200) == 0 { // if not empty + // string "voteFst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x46, 0x73, 0x74) + o = msgp.AppendUint64(o, uint64((*z).VoteFirstValid)) + } + if (zb0005Mask & 0x400) == 0 { // if not empty + // string "voteKD" + o = append(o, 0xa6, 0x76, 0x6f, 0x74, 0x65, 0x4b, 0x44) + o = msgp.AppendUint64(o, (*z).VoteKeyDilution) + } + if (zb0005Mask & 0x800) == 0 { // if not empty + // string "voteLst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x4c, 0x73, 0x74) + o = msgp.AppendUint64(o, uint64((*z).VoteLastValid)) + } + } + return +} + +func (_ *AccountData) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AccountData) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AccountData) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0005 int + var zb0006 bool + zb0005, zb0006, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0005, zb0006, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0005 > 0 { + zb0005-- + { + var zb0007 byte + zb0007, bts, err = msgp.ReadByteBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Status") + return + } + (*z).Status = Status(zb0007) + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") + return + } + } + if zb0005 > 0 { + zb0005-- + (*z).RewardsBase, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsBase") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardedMicroAlgos") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).VoteID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteID") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).SelectionID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SelectionID") + return + } + } + if zb0005 > 0 { + zb0005-- + { + var zb0008 uint64 + zb0008, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") + return + } + (*z).VoteFirstValid = Round(zb0008) + } + } + if zb0005 > 0 { + zb0005-- + { + var zb0009 uint64 + zb0009, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") + return + } + (*z).VoteLastValid = Round(zb0009) + } + } + if zb0005 > 0 { + zb0005-- + (*z).VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteKeyDilution") + return + } + } + if zb0005 > 0 { + zb0005-- + var zb0010 int + var zb0011 bool + zb0010, zb0011, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + if zb0011 { + (*z).AssetParams = nil + } else if (*z).AssetParams == nil { + (*z).AssetParams = make(map[AssetIndex]AssetParams, zb0010) + } + for zb0010 > 0 { + var zb0001 AssetIndex + var zb0002 AssetParams + zb0010-- + bts, err = zb0001.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + bts, err = zb0002.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams", zb0001) + return + } + (*z).AssetParams[zb0001] = zb0002 + } + } + if zb0005 > 0 { + zb0005-- + var zb0012 int + var zb0013 bool + zb0012, zb0013, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets") + return + } + if zb0013 { + (*z).Assets = nil + } else if (*z).Assets == nil { + (*z).Assets = make(map[AssetIndex]AssetHolding, zb0012) + } + for zb0012 > 0 { + var zb0003 AssetIndex + var zb0004 AssetHolding + zb0012-- + bts, err = zb0003.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets") + return + } + var zb0014 int + var zb0015 bool + zb0014, zb0015, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0014, zb0015, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + if zb0014 > 0 { + zb0014-- + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array", "Amount") + return + } + } + if zb0014 > 0 { + zb0014-- + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array", "Frozen") + return + } + } + if zb0014 > 0 { + err = msgp.ErrTooManyArrayFields(zb0014) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + if zb0015 { + zb0004 = AssetHolding{} + } + for zb0014 > 0 { + zb0014-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + switch string(field) { + case "a": + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "Amount") + return + } + case "f": + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "Frozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + } + } + } + (*z).Assets[zb0003] = zb0004 + } + } + if zb0005 > 0 { + err = msgp.ErrTooManyArrayFields(zb0005) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 { + (*z) = AccountData{} + } + for zb0005 > 0 { + zb0005-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "onl": + { + var zb0016 byte + zb0016, bts, err = msgp.ReadByteBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Status") + return + } + (*z).Status = Status(zb0016) + } + case "algo": + bts, err = (*z).MicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "MicroAlgos") + return + } + case "ebase": + (*z).RewardsBase, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsBase") + return + } + case "ern": + bts, err = (*z).RewardedMicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardedMicroAlgos") + return + } + case "vote": + bts, err = (*z).VoteID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteID") + return + } + case "sel": + bts, err = (*z).SelectionID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SelectionID") + return + } + case "voteFst": + { + var zb0017 uint64 + zb0017, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteFirstValid") + return + } + (*z).VoteFirstValid = Round(zb0017) + } + case "voteLst": + { + var zb0018 uint64 + zb0018, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteLastValid") + return + } + (*z).VoteLastValid = Round(zb0018) + } + case "voteKD": + (*z).VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteKeyDilution") + return + } + case "apar": + var zb0019 int + var zb0020 bool + zb0019, zb0020, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + if zb0020 { + (*z).AssetParams = nil + } else if (*z).AssetParams == nil { + (*z).AssetParams = make(map[AssetIndex]AssetParams, zb0019) + } + for zb0019 > 0 { + var zb0001 AssetIndex + var zb0002 AssetParams + zb0019-- + bts, err = zb0001.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + bts, err = zb0002.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + (*z).AssetParams[zb0001] = zb0002 + } + case "asset": + var zb0021 int + var zb0022 bool + zb0021, zb0022, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets") + return + } + if zb0022 { + (*z).Assets = nil + } else if (*z).Assets == nil { + (*z).Assets = make(map[AssetIndex]AssetHolding, zb0021) + } + for zb0021 > 0 { + var zb0003 AssetIndex + var zb0004 AssetHolding + zb0021-- + bts, err = zb0003.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Assets") + return + } + var zb0023 int + var zb0024 bool + zb0023, zb0024, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0023, zb0024, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + if zb0023 > 0 { + zb0023-- + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array", "Amount") + return + } + } + if zb0023 > 0 { + zb0023-- + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array", "Frozen") + return + } + } + if zb0023 > 0 { + err = msgp.ErrTooManyArrayFields(zb0023) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + if zb0024 { + zb0004 = AssetHolding{} + } + for zb0023 > 0 { + zb0023-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + switch string(field) { + case "a": + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "Amount") + return + } + case "f": + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "Frozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + } + } + } + (*z).Assets[zb0003] = zb0004 + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AccountData) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AccountData) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AccountData) Msgsize() (s int) { + s = 1 + 4 + msgp.ByteSize + 5 + (*z).MicroAlgos.Msgsize() + 6 + msgp.Uint64Size + 4 + (*z).RewardedMicroAlgos.Msgsize() + 5 + (*z).VoteID.Msgsize() + 4 + (*z).SelectionID.Msgsize() + 8 + msgp.Uint64Size + 8 + msgp.Uint64Size + 7 + msgp.Uint64Size + 5 + msgp.MapHeaderSize + if (*z).AssetParams != nil { + for zb0001, zb0002 := range (*z).AssetParams { + _ = zb0001 + _ = zb0002 + s += 0 + zb0001.Msgsize() + zb0002.Msgsize() + } + } + s += 6 + msgp.MapHeaderSize + if (*z).Assets != nil { + for zb0003, zb0004 := range (*z).Assets { + _ = zb0003 + _ = zb0004 + s += 0 + zb0003.Msgsize() + 1 + 2 + msgp.Uint64Size + 2 + msgp.BoolSize + } + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AccountData) MsgIsZero() bool { + return ((*z).Status == 0) && ((*z).MicroAlgos.MsgIsZero()) && ((*z).RewardsBase == 0) && ((*z).RewardedMicroAlgos.MsgIsZero()) && ((*z).VoteID.MsgIsZero()) && ((*z).SelectionID.MsgIsZero()) && ((*z).VoteFirstValid == 0) && ((*z).VoteLastValid == 0) && ((*z).VoteKeyDilution == 0) && (len((*z).AssetParams) == 0) && (len((*z).Assets) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Address) MarshalMsg(b []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).MarshalMsg(b) +} +func (_ *Address) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Address) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Address) UnmarshalMsg(bts []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) +} +func (_ *Address) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Address) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Address) Msgsize() int { + return ((*(crypto.Digest))(z)).Msgsize() +} + +// MsgIsZero returns whether this is a zero value +func (z *Address) MsgIsZero() bool { + return ((*(crypto.Digest))(z)).MsgIsZero() +} + +// MarshalMsg implements msgp.Marshaler +func (z *AssetHolding) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).Amount == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Frozen == false { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "a" + o = append(o, 0xa1, 0x61) + o = msgp.AppendUint64(o, (*z).Amount) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "f" + o = append(o, 0xa1, 0x66) + o = msgp.AppendBool(o, (*z).Frozen) + } + } + return +} + +func (_ *AssetHolding) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetHolding) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetHolding) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + (*z).Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Amount") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Frozen") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = AssetHolding{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "a": + (*z).Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Amount") + return + } + case "f": + (*z).Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Frozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AssetHolding) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetHolding) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AssetHolding) Msgsize() (s int) { + s = 1 + 2 + msgp.Uint64Size + 2 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AssetHolding) MsgIsZero() bool { + return ((*z).Amount == 0) && ((*z).Frozen == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z AssetIndex) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendUint64(o, uint64(z)) + return +} + +func (_ AssetIndex) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(AssetIndex) + if !ok { + _, ok = (z).(*AssetIndex) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetIndex) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 uint64 + zb0001, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = AssetIndex(zb0001) + } + o = bts + return +} + +func (_ *AssetIndex) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetIndex) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z AssetIndex) Msgsize() (s int) { + s = msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z AssetIndex) MsgIsZero() bool { + return z == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z *AssetParams) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(11) + var zb0002Mask uint16 /* 12 bits */ + if (*z).MetadataHash == ([32]byte{}) { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).AssetName == "" { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).URL == "" { + zb0002Len-- + zb0002Mask |= 0x8 + } + if (*z).Clawback.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x10 + } + if (*z).Decimals == 0 { + zb0002Len-- + zb0002Mask |= 0x20 + } + if (*z).DefaultFrozen == false { + zb0002Len-- + zb0002Mask |= 0x40 + } + if (*z).Freeze.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x80 + } + if (*z).Manager.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x100 + } + if (*z).Reserve.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x200 + } + if (*z).Total == 0 { + zb0002Len-- + zb0002Mask |= 0x400 + } + if (*z).UnitName == "" { + zb0002Len-- + zb0002Mask |= 0x800 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "am" + o = append(o, 0xa2, 0x61, 0x6d) + o = msgp.AppendBytes(o, ((*z).MetadataHash)[:]) + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "an" + o = append(o, 0xa2, 0x61, 0x6e) + o = msgp.AppendString(o, (*z).AssetName) + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "au" + o = append(o, 0xa2, 0x61, 0x75) + o = msgp.AppendString(o, (*z).URL) + } + if (zb0002Mask & 0x10) == 0 { // if not empty + // string "c" + o = append(o, 0xa1, 0x63) + o, err = (*z).Clawback.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Clawback") + return + } + } + if (zb0002Mask & 0x20) == 0 { // if not empty + // string "dc" + o = append(o, 0xa2, 0x64, 0x63) + o = msgp.AppendUint32(o, (*z).Decimals) + } + if (zb0002Mask & 0x40) == 0 { // if not empty + // string "df" + o = append(o, 0xa2, 0x64, 0x66) + o = msgp.AppendBool(o, (*z).DefaultFrozen) + } + if (zb0002Mask & 0x80) == 0 { // if not empty + // string "f" + o = append(o, 0xa1, 0x66) + o, err = (*z).Freeze.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Freeze") + return + } + } + if (zb0002Mask & 0x100) == 0 { // if not empty + // string "m" + o = append(o, 0xa1, 0x6d) + o, err = (*z).Manager.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Manager") + return + } + } + if (zb0002Mask & 0x200) == 0 { // if not empty + // string "r" + o = append(o, 0xa1, 0x72) + o, err = (*z).Reserve.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Reserve") + return + } + } + if (zb0002Mask & 0x400) == 0 { // if not empty + // string "t" + o = append(o, 0xa1, 0x74) + o = msgp.AppendUint64(o, (*z).Total) + } + if (zb0002Mask & 0x800) == 0 { // if not empty + // string "un" + o = append(o, 0xa2, 0x75, 0x6e) + o = msgp.AppendString(o, (*z).UnitName) + } + } + return +} + +func (_ *AssetParams) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetParams) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetParams) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + (*z).Total, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Total") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Decimals, bts, err = msgp.ReadUint32Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Decimals") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).DefaultFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "DefaultFrozen") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).UnitName, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UnitName") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).AssetName, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetName") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).URL, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "URL") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = msgp.ReadExactBytes(bts, ((*z).MetadataHash)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MetadataHash") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Manager.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Manager") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Reserve.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Reserve") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Freeze.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Freeze") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Clawback.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Clawback") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = AssetParams{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "t": + (*z).Total, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Total") + return + } + case "dc": + (*z).Decimals, bts, err = msgp.ReadUint32Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Decimals") + return + } + case "df": + (*z).DefaultFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "DefaultFrozen") + return + } + case "un": + (*z).UnitName, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UnitName") + return + } + case "an": + (*z).AssetName, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetName") + return + } + case "au": + (*z).URL, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "URL") + return + } + case "am": + bts, err = msgp.ReadExactBytes(bts, ((*z).MetadataHash)[:]) + if err != nil { + err = msgp.WrapError(err, "MetadataHash") + return + } + case "m": + bts, err = (*z).Manager.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Manager") + return + } + case "r": + bts, err = (*z).Reserve.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Reserve") + return + } + case "f": + bts, err = (*z).Freeze.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Freeze") + return + } + case "c": + bts, err = (*z).Clawback.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Clawback") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AssetParams) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetParams) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AssetParams) Msgsize() (s int) { + s = 1 + 2 + msgp.Uint64Size + 3 + msgp.Uint32Size + 3 + msgp.BoolSize + 3 + msgp.StringPrefixSize + len((*z).UnitName) + 3 + msgp.StringPrefixSize + len((*z).AssetName) + 3 + msgp.StringPrefixSize + len((*z).URL) + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 2 + (*z).Manager.Msgsize() + 2 + (*z).Reserve.Msgsize() + 2 + (*z).Freeze.Msgsize() + 2 + (*z).Clawback.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AssetParams) MsgIsZero() bool { + return ((*z).Total == 0) && ((*z).Decimals == 0) && ((*z).DefaultFrozen == false) && ((*z).UnitName == "") && ((*z).AssetName == "") && ((*z).URL == "") && ((*z).MetadataHash == ([32]byte{})) && ((*z).Manager.MsgIsZero()) && ((*z).Reserve.MsgIsZero()) && ((*z).Freeze.MsgIsZero()) && ((*z).Clawback.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *BalanceRecord) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0005Len := uint32(12) + var zb0005Mask uint16 /* 14 bits */ + if (*z).Addr.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x4 + } + if (*z).AccountData.MicroAlgos.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x8 + } + if len((*z).AccountData.AssetParams) == 0 { + zb0005Len-- + zb0005Mask |= 0x10 + } + if len((*z).AccountData.Assets) == 0 { + zb0005Len-- + zb0005Mask |= 0x20 + } + if (*z).AccountData.RewardsBase == 0 { + zb0005Len-- + zb0005Mask |= 0x40 + } + if (*z).AccountData.RewardedMicroAlgos.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x80 + } + if (*z).AccountData.Status == 0 { + zb0005Len-- + zb0005Mask |= 0x100 + } + if (*z).AccountData.SelectionID.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x200 + } + if (*z).AccountData.VoteID.MsgIsZero() { + zb0005Len-- + zb0005Mask |= 0x400 + } + if (*z).AccountData.VoteFirstValid == 0 { + zb0005Len-- + zb0005Mask |= 0x800 + } + if (*z).AccountData.VoteKeyDilution == 0 { + zb0005Len-- + zb0005Mask |= 0x1000 + } + if (*z).AccountData.VoteLastValid == 0 { + zb0005Len-- + zb0005Mask |= 0x2000 + } + // variable map header, size zb0005Len + o = append(o, 0x80|uint8(zb0005Len)) + if zb0005Len != 0 { + if (zb0005Mask & 0x4) == 0 { // if not empty + // string "addr" + o = append(o, 0xa4, 0x61, 0x64, 0x64, 0x72) + o, err = (*z).Addr.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Addr") + return + } + } + if (zb0005Mask & 0x8) == 0 { // if not empty + // string "algo" + o = append(o, 0xa4, 0x61, 0x6c, 0x67, 0x6f) + o, err = (*z).AccountData.MicroAlgos.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "MicroAlgos") + return + } + } + if (zb0005Mask & 0x10) == 0 { // if not empty + // string "apar" + o = append(o, 0xa4, 0x61, 0x70, 0x61, 0x72) + if (*z).AccountData.AssetParams == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendMapHeader(o, uint32(len((*z).AccountData.AssetParams))) + } + zb0001_keys := make([]AssetIndex, 0, len((*z).AccountData.AssetParams)) + for zb0001 := range (*z).AccountData.AssetParams { + zb0001_keys = append(zb0001_keys, zb0001) + } + sort.Sort(SortAssetIndex(zb0001_keys)) + for _, zb0001 := range zb0001_keys { + zb0002 := (*z).AccountData.AssetParams[zb0001] + _ = zb0002 + o, err = zb0001.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + o, err = zb0002.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + } + } + if (zb0005Mask & 0x20) == 0 { // if not empty + // string "asset" + o = append(o, 0xa5, 0x61, 0x73, 0x73, 0x65, 0x74) + if (*z).AccountData.Assets == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendMapHeader(o, uint32(len((*z).AccountData.Assets))) + } + zb0003_keys := make([]AssetIndex, 0, len((*z).AccountData.Assets)) + for zb0003 := range (*z).AccountData.Assets { + zb0003_keys = append(zb0003_keys, zb0003) + } + sort.Sort(SortAssetIndex(zb0003_keys)) + for _, zb0003 := range zb0003_keys { + zb0004 := (*z).AccountData.Assets[zb0003] + _ = zb0004 + o, err = zb0003.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + // omitempty: check for empty values + zb0006Len := uint32(2) + var zb0006Mask uint8 /* 3 bits */ + if zb0004.Amount == 0 { + zb0006Len-- + zb0006Mask |= 0x2 + } + if zb0004.Frozen == false { + zb0006Len-- + zb0006Mask |= 0x4 + } + // variable map header, size zb0006Len + o = append(o, 0x80|uint8(zb0006Len)) + if zb0006Len != 0 { + if (zb0006Mask & 0x2) == 0 { // if not empty + // string "a" + o = append(o, 0xa1, 0x61) + o = msgp.AppendUint64(o, zb0004.Amount) + } + if (zb0006Mask & 0x4) == 0 { // if not empty + // string "f" + o = append(o, 0xa1, 0x66) + o = msgp.AppendBool(o, zb0004.Frozen) + } + } + } + } + if (zb0005Mask & 0x40) == 0 { // if not empty + // string "ebase" + o = append(o, 0xa5, 0x65, 0x62, 0x61, 0x73, 0x65) + o = msgp.AppendUint64(o, (*z).AccountData.RewardsBase) + } + if (zb0005Mask & 0x80) == 0 { // if not empty + // string "ern" + o = append(o, 0xa3, 0x65, 0x72, 0x6e) + o, err = (*z).AccountData.RewardedMicroAlgos.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardedMicroAlgos") + return + } + } + if (zb0005Mask & 0x100) == 0 { // if not empty + // string "onl" + o = append(o, 0xa3, 0x6f, 0x6e, 0x6c) + o = msgp.AppendByte(o, byte((*z).AccountData.Status)) + } + if (zb0005Mask & 0x200) == 0 { // if not empty + // string "sel" + o = append(o, 0xa3, 0x73, 0x65, 0x6c) + o, err = (*z).AccountData.SelectionID.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SelectionID") + return + } + } + if (zb0005Mask & 0x400) == 0 { // if not empty + // string "vote" + o = append(o, 0xa4, 0x76, 0x6f, 0x74, 0x65) + o, err = (*z).AccountData.VoteID.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteID") + return + } + } + if (zb0005Mask & 0x800) == 0 { // if not empty + // string "voteFst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x46, 0x73, 0x74) + o = msgp.AppendUint64(o, uint64((*z).AccountData.VoteFirstValid)) + } + if (zb0005Mask & 0x1000) == 0 { // if not empty + // string "voteKD" + o = append(o, 0xa6, 0x76, 0x6f, 0x74, 0x65, 0x4b, 0x44) + o = msgp.AppendUint64(o, (*z).AccountData.VoteKeyDilution) + } + if (zb0005Mask & 0x2000) == 0 { // if not empty + // string "voteLst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x4c, 0x73, 0x74) + o = msgp.AppendUint64(o, uint64((*z).AccountData.VoteLastValid)) + } + } + return +} + +func (_ *BalanceRecord) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*BalanceRecord) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BalanceRecord) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0005 int + var zb0006 bool + zb0005, zb0006, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0005, zb0006, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).Addr.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Addr") + return + } + } + if zb0005 > 0 { + zb0005-- + { + var zb0007 byte + zb0007, bts, err = msgp.ReadByteBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Status") + return + } + (*z).AccountData.Status = Status(zb0007) + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "MicroAlgos") + return + } + } + if zb0005 > 0 { + zb0005-- + (*z).AccountData.RewardsBase, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsBase") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardedMicroAlgos") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).AccountData.VoteID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteID") + return + } + } + if zb0005 > 0 { + zb0005-- + bts, err = (*z).AccountData.SelectionID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SelectionID") + return + } + } + if zb0005 > 0 { + zb0005-- + { + var zb0008 uint64 + zb0008, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteFirstValid") + return + } + (*z).AccountData.VoteFirstValid = Round(zb0008) + } + } + if zb0005 > 0 { + zb0005-- + { + var zb0009 uint64 + zb0009, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteLastValid") + return + } + (*z).AccountData.VoteLastValid = Round(zb0009) + } + } + if zb0005 > 0 { + zb0005-- + (*z).AccountData.VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteKeyDilution") + return + } + } + if zb0005 > 0 { + zb0005-- + var zb0010 int + var zb0011 bool + zb0010, zb0011, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + if zb0011 { + (*z).AccountData.AssetParams = nil + } else if (*z).AccountData.AssetParams == nil { + (*z).AccountData.AssetParams = make(map[AssetIndex]AssetParams, zb0010) + } + for zb0010 > 0 { + var zb0001 AssetIndex + var zb0002 AssetParams + zb0010-- + bts, err = zb0001.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + bts, err = zb0002.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams", zb0001) + return + } + (*z).AccountData.AssetParams[zb0001] = zb0002 + } + } + if zb0005 > 0 { + zb0005-- + var zb0012 int + var zb0013 bool + zb0012, zb0013, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets") + return + } + if zb0013 { + (*z).AccountData.Assets = nil + } else if (*z).AccountData.Assets == nil { + (*z).AccountData.Assets = make(map[AssetIndex]AssetHolding, zb0012) + } + for zb0012 > 0 { + var zb0003 AssetIndex + var zb0004 AssetHolding + zb0012-- + bts, err = zb0003.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets") + return + } + var zb0014 int + var zb0015 bool + zb0014, zb0015, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0014, zb0015, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + if zb0014 > 0 { + zb0014-- + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array", "Amount") + return + } + } + if zb0014 > 0 { + zb0014-- + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array", "Frozen") + return + } + } + if zb0014 > 0 { + err = msgp.ErrTooManyArrayFields(zb0014) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + if zb0015 { + zb0004 = AssetHolding{} + } + for zb0014 > 0 { + zb0014-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + switch string(field) { + case "a": + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "Amount") + return + } + case "f": + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003, "Frozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Assets", zb0003) + return + } + } + } + } + (*z).AccountData.Assets[zb0003] = zb0004 + } + } + if zb0005 > 0 { + err = msgp.ErrTooManyArrayFields(zb0005) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 { + (*z) = BalanceRecord{} + } + for zb0005 > 0 { + zb0005-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "addr": + bts, err = (*z).Addr.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Addr") + return + } + case "onl": + { + var zb0016 byte + zb0016, bts, err = msgp.ReadByteBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Status") + return + } + (*z).AccountData.Status = Status(zb0016) + } + case "algo": + bts, err = (*z).AccountData.MicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "MicroAlgos") + return + } + case "ebase": + (*z).AccountData.RewardsBase, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsBase") + return + } + case "ern": + bts, err = (*z).AccountData.RewardedMicroAlgos.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardedMicroAlgos") + return + } + case "vote": + bts, err = (*z).AccountData.VoteID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteID") + return + } + case "sel": + bts, err = (*z).AccountData.SelectionID.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SelectionID") + return + } + case "voteFst": + { + var zb0017 uint64 + zb0017, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteFirstValid") + return + } + (*z).AccountData.VoteFirstValid = Round(zb0017) + } + case "voteLst": + { + var zb0018 uint64 + zb0018, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteLastValid") + return + } + (*z).AccountData.VoteLastValid = Round(zb0018) + } + case "voteKD": + (*z).AccountData.VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteKeyDilution") + return + } + case "apar": + var zb0019 int + var zb0020 bool + zb0019, zb0020, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + if zb0020 { + (*z).AccountData.AssetParams = nil + } else if (*z).AccountData.AssetParams == nil { + (*z).AccountData.AssetParams = make(map[AssetIndex]AssetParams, zb0019) + } + for zb0019 > 0 { + var zb0001 AssetIndex + var zb0002 AssetParams + zb0019-- + bts, err = zb0001.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + bts, err = zb0002.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams", zb0001) + return + } + (*z).AccountData.AssetParams[zb0001] = zb0002 + } + case "asset": + var zb0021 int + var zb0022 bool + zb0021, zb0022, bts, err = msgp.ReadMapHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets") + return + } + if zb0022 { + (*z).AccountData.Assets = nil + } else if (*z).AccountData.Assets == nil { + (*z).AccountData.Assets = make(map[AssetIndex]AssetHolding, zb0021) + } + for zb0021 > 0 { + var zb0003 AssetIndex + var zb0004 AssetHolding + zb0021-- + bts, err = zb0003.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Assets") + return + } + var zb0023 int + var zb0024 bool + zb0023, zb0024, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0023, zb0024, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + if zb0023 > 0 { + zb0023-- + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array", "Amount") + return + } + } + if zb0023 > 0 { + zb0023-- + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array", "Frozen") + return + } + } + if zb0023 > 0 { + err = msgp.ErrTooManyArrayFields(zb0023) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + if zb0024 { + zb0004 = AssetHolding{} + } + for zb0023 > 0 { + zb0023-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + switch string(field) { + case "a": + zb0004.Amount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "Amount") + return + } + case "f": + zb0004.Frozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003, "Frozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err, "Assets", zb0003) + return + } + } + } + } + (*z).AccountData.Assets[zb0003] = zb0004 + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *BalanceRecord) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*BalanceRecord) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *BalanceRecord) Msgsize() (s int) { + s = 1 + 5 + (*z).Addr.Msgsize() + 4 + msgp.ByteSize + 5 + (*z).AccountData.MicroAlgos.Msgsize() + 6 + msgp.Uint64Size + 4 + (*z).AccountData.RewardedMicroAlgos.Msgsize() + 5 + (*z).AccountData.VoteID.Msgsize() + 4 + (*z).AccountData.SelectionID.Msgsize() + 8 + msgp.Uint64Size + 8 + msgp.Uint64Size + 7 + msgp.Uint64Size + 5 + msgp.MapHeaderSize + if (*z).AccountData.AssetParams != nil { + for zb0001, zb0002 := range (*z).AccountData.AssetParams { + _ = zb0001 + _ = zb0002 + s += 0 + zb0001.Msgsize() + zb0002.Msgsize() + } + } + s += 6 + msgp.MapHeaderSize + if (*z).AccountData.Assets != nil { + for zb0003, zb0004 := range (*z).AccountData.Assets { + _ = zb0003 + _ = zb0004 + s += 0 + zb0003.Msgsize() + 1 + 2 + msgp.Uint64Size + 2 + msgp.BoolSize + } + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *BalanceRecord) MsgIsZero() bool { + return ((*z).Addr.MsgIsZero()) && ((*z).AccountData.Status == 0) && ((*z).AccountData.MicroAlgos.MsgIsZero()) && ((*z).AccountData.RewardsBase == 0) && ((*z).AccountData.RewardedMicroAlgos.MsgIsZero()) && ((*z).AccountData.VoteID.MsgIsZero()) && ((*z).AccountData.SelectionID.MsgIsZero()) && ((*z).AccountData.VoteFirstValid == 0) && ((*z).AccountData.VoteLastValid == 0) && ((*z).AccountData.VoteKeyDilution == 0) && (len((*z).AccountData.AssetParams) == 0) && (len((*z).AccountData.Assets) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z Round) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendUint64(o, uint64(z)) + return +} + +func (_ Round) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Round) + if !ok { + _, ok = (z).(*Round) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Round) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 uint64 + zb0001, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = Round(zb0001) + } + o = bts + return +} + +func (_ *Round) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Round) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Round) Msgsize() (s int) { + s = msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z Round) MsgIsZero() bool { + return z == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z RoundInterval) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendUint64(o, uint64(z)) + return +} + +func (_ RoundInterval) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(RoundInterval) + if !ok { + _, ok = (z).(*RoundInterval) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *RoundInterval) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 uint64 + zb0001, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = RoundInterval(zb0001) + } + o = bts + return +} + +func (_ *RoundInterval) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*RoundInterval) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z RoundInterval) Msgsize() (s int) { + s = msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z RoundInterval) MsgIsZero() bool { + return z == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z Status) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendByte(o, byte(z)) + return +} + +func (_ Status) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Status) + if !ok { + _, ok = (z).(*Status) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Status) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 byte + zb0001, bts, err = msgp.ReadByteBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = Status(zb0001) + } + o = bts + return +} + +func (_ *Status) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Status) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Status) Msgsize() (s int) { + s = msgp.ByteSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z Status) MsgIsZero() bool { + return z == 0 +} diff --git a/data/basics/msgp_gen_test.go b/data/basics/msgp_gen_test.go new file mode 100644 index 0000000000..c6cce16926 --- /dev/null +++ b/data/basics/msgp_gen_test.go @@ -0,0 +1,258 @@ +package basics + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalAccountData(t *testing.T) { + v := AccountData{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAccountData(t *testing.T) { + protocol.RunEncodingTest(t, &AccountData{}) +} + +func BenchmarkMarshalMsgAccountData(b *testing.B) { + v := AccountData{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAccountData(b *testing.B) { + v := AccountData{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAccountData(b *testing.B) { + v := AccountData{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalAssetHolding(t *testing.T) { + v := AssetHolding{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAssetHolding(t *testing.T) { + protocol.RunEncodingTest(t, &AssetHolding{}) +} + +func BenchmarkMarshalMsgAssetHolding(b *testing.B) { + v := AssetHolding{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAssetHolding(b *testing.B) { + v := AssetHolding{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAssetHolding(b *testing.B) { + v := AssetHolding{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalAssetParams(t *testing.T) { + v := AssetParams{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAssetParams(t *testing.T) { + protocol.RunEncodingTest(t, &AssetParams{}) +} + +func BenchmarkMarshalMsgAssetParams(b *testing.B) { + v := AssetParams{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAssetParams(b *testing.B) { + v := AssetParams{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAssetParams(b *testing.B) { + v := AssetParams{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalBalanceRecord(t *testing.T) { + v := BalanceRecord{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBalanceRecord(t *testing.T) { + protocol.RunEncodingTest(t, &BalanceRecord{}) +} + +func BenchmarkMarshalMsgBalanceRecord(b *testing.B) { + v := BalanceRecord{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBalanceRecord(b *testing.B) { + v := BalanceRecord{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBalanceRecord(b *testing.B) { + v := BalanceRecord{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/data/basics/sort.go b/data/basics/sort.go new file mode 100644 index 0000000000..cbceca5936 --- /dev/null +++ b/data/basics/sort.go @@ -0,0 +1,27 @@ +// Copyright (C) 2019-2020 Algorand, Inc. +// This file is part of go-algorand +// +// go-algorand is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// go-algorand is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with go-algorand. If not, see . + +package basics + +// SortAssetIndex implements sorting by AssetIndex keys for +// canonical encoding of maps in msgpack format. +//msgp:ignore SortAssetIndex +//msgp:sort AssetIndex SortAssetIndex +type SortAssetIndex []AssetIndex + +func (a SortAssetIndex) Len() int { return len(a) } +func (a SortAssetIndex) Less(i, j int) bool { return a[i] < a[j] } +func (a SortAssetIndex) Swap(i, j int) { a[i], a[j] = a[j], a[i] } diff --git a/data/basics/units.go b/data/basics/units.go index bc12bfefb3..23feb02531 100644 --- a/data/basics/units.go +++ b/data/basics/units.go @@ -17,9 +17,11 @@ package basics import ( + "github.com/algorand/go-codec/codec" + "github.com/algorand/msgp/msgp" + "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/crypto" - "github.com/algorand/go-codec/codec" ) // RoundInterval is a number of rounds @@ -56,6 +58,11 @@ func (a MicroAlgos) RewardUnits(proto config.ConsensusParams) uint64 { return a.Raw / proto.RewardUnit } +// We generate our own encoders and decoders for MicroAlgos +// because we want it to appear as an integer, even though +// we represent it as a single-element struct. +//msgp:ignore MicroAlgos + // CodecEncodeSelf implements codec.Selfer to encode MicroAlgos as a simple int func (a MicroAlgos) CodecEncodeSelf(enc *codec.Encoder) { enc.MustEncode(a.Raw) @@ -66,6 +73,29 @@ func (a *MicroAlgos) CodecDecodeSelf(dec *codec.Decoder) { dec.MustDecode(&a.Raw) } +// MarshalMsg implements msgp.Marshaler +func (a MicroAlgos) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, msgp.Uint64Size) + o = msgp.AppendUint64(o, a.Raw) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (a *MicroAlgos) UnmarshalMsg(bts []byte) (o []byte, err error) { + a.Raw, o, err = msgp.ReadUint64Bytes(bts) + return +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (a MicroAlgos) Msgsize() (s int) { + return msgp.Uint64Size +} + +// MsgIsZero returns whether this is a zero value +func (a MicroAlgos) MsgIsZero() bool { + return a.Raw == 0 +} + // Round represents a protocol round index type Round uint64 diff --git a/data/basics/userBalance.go b/data/basics/userBalance.go index 1796c72c62..b1ebf9ba6f 100644 --- a/data/basics/userBalance.go +++ b/data/basics/userBalance.go @@ -118,7 +118,7 @@ type AccountData struct { // NOTE: do not modify this value in-place in existing AccountData // structs; allocate a copy and modify that instead. AccountData // is expected to have copy-by-value semantics. - AssetParams map[AssetIndex]AssetParams `codec:"apar"` + AssetParams map[AssetIndex]AssetParams `codec:"apar,allocbound=-"` // Assets is the set of assets that can be held by this // account. Assets (i.e., slots in this map) are explicitly @@ -135,7 +135,7 @@ type AccountData struct { // NOTE: do not modify this value in-place in existing AccountData // structs; allocate a copy and modify that instead. AccountData // is expected to have copy-by-value semantics. - Assets map[AssetIndex]AssetHolding `codec:"asset"` + Assets map[AssetIndex]AssetHolding `codec:"asset,allocbound=-"` } // AccountDetail encapsulates meaningful details about a given account, for external consumption @@ -174,6 +174,8 @@ type AssetLocator struct { // AssetHolding describes an asset held by an account. type AssetHolding struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + Amount uint64 `codec:"a"` Frozen bool `codec:"f"` } @@ -302,5 +304,5 @@ type BalanceRecord struct { // ToBeHashed implements the crypto.Hashable interface func (u BalanceRecord) ToBeHashed() (protocol.HashID, []byte) { - return protocol.BalanceRecord, protocol.Encode(u) + return protocol.BalanceRecord, protocol.Encode(&u) } diff --git a/data/bookkeeping/block.go b/data/bookkeeping/block.go index e6119262bc..cf95982877 100644 --- a/data/bookkeeping/block.go +++ b/data/bookkeeping/block.go @@ -126,6 +126,8 @@ type ( // RewardsState represents the global parameters controlling the rate // at which accounts accrue rewards. RewardsState struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + // The FeeSink accepts transaction fees. It can only spend to // the incentive pool. FeeSink basics.Address `codec:"fees"` @@ -154,6 +156,8 @@ type ( // UpgradeVote represents the vote of the block proposer with // respect to protocol upgrades. UpgradeVote struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + // UpgradePropose indicates a proposed upgrade UpgradePropose protocol.ConsensusVersion `codec:"upgradeprop"` @@ -168,6 +172,7 @@ type ( // strictly speaking, computable from the history of all UpgradeVotes // but we keep it in the block for explicitness and convenience // (instead of materializing it separately, like balances). + //msgp:ignore UpgradeState UpgradeState struct { CurrentProtocol protocol.ConsensusVersion `codec:"proto"` NextProtocol protocol.ConsensusVersion `codec:"nextproto"` @@ -191,7 +196,7 @@ func (bh BlockHeader) Hash() BlockHash { // ToBeHashed implements the crypto.Hashable interface func (bh BlockHeader) ToBeHashed() (protocol.HashID, []byte) { - return protocol.BlockHeader, protocol.Encode(bh) + return protocol.BlockHeader, protocol.Encode(&bh) } // Digest returns a cryptographic digest summarizing the Block. @@ -631,7 +636,6 @@ func (bh BlockHeader) DecodeSignedTxn(stb transactions.SignedTxnInBlock) (transa } } - st.ResetCaches() return st, ad, nil } diff --git a/data/bookkeeping/encoding_test.go b/data/bookkeeping/encoding_test.go index 9be938a976..43149a8dd8 100644 --- a/data/bookkeeping/encoding_test.go +++ b/data/bookkeeping/encoding_test.go @@ -54,7 +54,7 @@ func TestBlockWithTxnEncoding(t *testing.T) { }, }, } - enc := protocol.Encode(b) + enc := protocol.Encode(&b) var b2 Block err := protocol.Decode(enc, &b2) diff --git a/data/bookkeeping/genesis.go b/data/bookkeeping/genesis.go index c34c56bd74..af7c2f6b72 100644 --- a/data/bookkeeping/genesis.go +++ b/data/bookkeeping/genesis.go @@ -47,7 +47,7 @@ type Genesis struct { Proto protocol.ConsensusVersion `codec:"proto"` // Allocation determines the initial accounts and their state. - Allocation []GenesisAllocation `codec:"alloc"` + Allocation []GenesisAllocation `codec:"alloc,allocbound=-"` // RewardsPool is the address of the rewards pool. RewardsPool string `codec:"rwd"` @@ -86,6 +86,11 @@ func (genesis Genesis) ID() string { // representing, and is purely informational. State is the initial // account state. type GenesisAllocation struct { + // Unfortunately we forgot to specify omitempty, and now + // this struct must be encoded without omitempty for the + // Address, Comment, and State fields.. + _struct struct{} `codec:""` + Address string `codec:"addr"` Comment string `codec:"comment"` State basics.AccountData `codec:"state"` @@ -93,5 +98,5 @@ type GenesisAllocation struct { // ToBeHashed impements the crypto.Hashable interface. func (genesis Genesis) ToBeHashed() (protocol.HashID, []byte) { - return protocol.Genesis, protocol.Encode(genesis) + return protocol.Genesis, protocol.Encode(&genesis) } diff --git a/data/bookkeeping/msgp_gen.go b/data/bookkeeping/msgp_gen.go new file mode 100644 index 0000000000..8d6b873653 --- /dev/null +++ b/data/bookkeeping/msgp_gen.go @@ -0,0 +1,2200 @@ +package bookkeeping + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/go-algorand/crypto" + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Block) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(23) + var zb0001Mask uint32 /* 26 bits */ + if (*z).BlockHeader.RewardsState.RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).BlockHeader.RewardsState.FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).BlockHeader.RewardsState.RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).BlockHeader.GenesisID == "" { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).BlockHeader.GenesisHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).BlockHeader.UpgradeState.NextProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).BlockHeader.UpgradeState.NextProtocolApprovals == 0 { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).BlockHeader.Branch.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2000 + } + if (*z).BlockHeader.RewardsState.RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x4000 + } + if (*z).BlockHeader.Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000 + } + if (*z).BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000 + } + if (*z).BlockHeader.RewardsState.RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20000 + } + if (*z).BlockHeader.Seed.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000 + } + if (*z).BlockHeader.TxnCounter == 0 { + zb0001Len-- + zb0001Mask |= 0x80000 + } + if (*z).BlockHeader.TimeStamp == 0 { + zb0001Len-- + zb0001Mask |= 0x100000 + } + if (*z).BlockHeader.TxnRoot.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200000 + } + if (*z).Payset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400000 + } + if (*z).BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800000 + } + if (*z).BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000000 + } + if (*z).BlockHeader.UpgradeVote.UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x2000000 + } + // variable map header, size zb0001Len + o = msgp.AppendMapHeader(o, zb0001Len) + if zb0001Len != 0 { + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).BlockHeader.RewardsState.RewardsLevel) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).BlockHeader.RewardsState.FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).BlockHeader.RewardsState.RewardsResidue) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).BlockHeader.GenesisID) + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).BlockHeader.GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "nextbefore" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65) + o, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "nextproto" + o = append(o, 0xa9, 0x6e, 0x65, 0x78, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).BlockHeader.UpgradeState.NextProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "nextswitch" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68) + o, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "nextyes" + o = append(o, 0xa7, 0x6e, 0x65, 0x78, 0x74, 0x79, 0x65, 0x73) + o = msgp.AppendUint64(o, (*z).BlockHeader.UpgradeState.NextProtocolApprovals) + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "prev" + o = append(o, 0xa4, 0x70, 0x72, 0x65, 0x76) + o, err = (*z).BlockHeader.Branch.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + } + if (zb0001Mask & 0x4000) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).BlockHeader.RewardsState.RewardsRate) + } + if (zb0001Mask & 0x8000) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).BlockHeader.Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x10000) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x20000) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).BlockHeader.RewardsState.RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + if (zb0001Mask & 0x40000) == 0 { // if not empty + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).BlockHeader.Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + } + if (zb0001Mask & 0x80000) == 0 { // if not empty + // string "tc" + o = append(o, 0xa2, 0x74, 0x63) + o = msgp.AppendUint64(o, (*z).BlockHeader.TxnCounter) + } + if (zb0001Mask & 0x100000) == 0 { // if not empty + // string "ts" + o = append(o, 0xa2, 0x74, 0x73) + o = msgp.AppendInt64(o, (*z).BlockHeader.TimeStamp) + } + if (zb0001Mask & 0x200000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).BlockHeader.TxnRoot.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + } + if (zb0001Mask & 0x400000) == 0 { // if not empty + // string "txns" + o = append(o, 0xa4, 0x74, 0x78, 0x6e, 0x73) + o, err = (*z).Payset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + } + if (zb0001Mask & 0x800000) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x1000000) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x2000000) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).BlockHeader.UpgradeVote.UpgradeApprove) + } + } + return +} + +func (_ *Block) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Block) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Branch") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnRoot") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TimeStamp") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolApprovals") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnCounter") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Payset") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Block{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).BlockHeader.Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "prev": + bts, err = (*z).BlockHeader.Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + case "seed": + bts, err = (*z).BlockHeader.Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "txn": + bts, err = (*z).BlockHeader.TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + case "ts": + (*z).BlockHeader.TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TimeStamp") + return + } + case "gen": + (*z).BlockHeader.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).BlockHeader.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "fees": + bts, err = (*z).BlockHeader.RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).BlockHeader.RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).BlockHeader.RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).BlockHeader.RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).BlockHeader.RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).BlockHeader.RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + case "proto": + bts, err = (*z).BlockHeader.UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + case "nextproto": + bts, err = (*z).BlockHeader.UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + case "nextyes": + (*z).BlockHeader.UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolApprovals") + return + } + case "nextbefore": + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + case "nextswitch": + bts, err = (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + case "upgradeprop": + bts, err = (*z).BlockHeader.UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).BlockHeader.UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).BlockHeader.UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + case "tc": + (*z).BlockHeader.TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxnCounter") + return + } + case "txns": + bts, err = (*z).Payset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Payset") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Block) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Block) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Block) Msgsize() (s int) { + s = 3 + 4 + (*z).BlockHeader.Round.Msgsize() + 5 + (*z).BlockHeader.Branch.Msgsize() + 5 + (*z).BlockHeader.Seed.Msgsize() + 4 + (*z).BlockHeader.TxnRoot.Msgsize() + 3 + msgp.Int64Size + 4 + msgp.StringPrefixSize + len((*z).BlockHeader.GenesisID) + 3 + (*z).BlockHeader.GenesisHash.Msgsize() + 5 + (*z).BlockHeader.RewardsState.FeeSink.Msgsize() + 4 + (*z).BlockHeader.RewardsState.RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).BlockHeader.RewardsState.RewardsRecalculationRound.Msgsize() + 6 + (*z).BlockHeader.UpgradeState.CurrentProtocol.Msgsize() + 10 + (*z).BlockHeader.UpgradeState.NextProtocol.Msgsize() + 8 + msgp.Uint64Size + 11 + (*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.Msgsize() + 11 + (*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.Msgsize() + 12 + (*z).BlockHeader.UpgradeVote.UpgradePropose.Msgsize() + 13 + (*z).BlockHeader.UpgradeVote.UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + 3 + msgp.Uint64Size + 5 + (*z).Payset.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Block) MsgIsZero() bool { + return ((*z).BlockHeader.Round.MsgIsZero()) && ((*z).BlockHeader.Branch.MsgIsZero()) && ((*z).BlockHeader.Seed.MsgIsZero()) && ((*z).BlockHeader.TxnRoot.MsgIsZero()) && ((*z).BlockHeader.TimeStamp == 0) && ((*z).BlockHeader.GenesisID == "") && ((*z).BlockHeader.GenesisHash.MsgIsZero()) && ((*z).BlockHeader.RewardsState.FeeSink.MsgIsZero()) && ((*z).BlockHeader.RewardsState.RewardsPool.MsgIsZero()) && ((*z).BlockHeader.RewardsState.RewardsLevel == 0) && ((*z).BlockHeader.RewardsState.RewardsRate == 0) && ((*z).BlockHeader.RewardsState.RewardsResidue == 0) && ((*z).BlockHeader.RewardsState.RewardsRecalculationRound.MsgIsZero()) && ((*z).BlockHeader.UpgradeState.CurrentProtocol.MsgIsZero()) && ((*z).BlockHeader.UpgradeState.NextProtocol.MsgIsZero()) && ((*z).BlockHeader.UpgradeState.NextProtocolApprovals == 0) && ((*z).BlockHeader.UpgradeState.NextProtocolVoteBefore.MsgIsZero()) && ((*z).BlockHeader.UpgradeState.NextProtocolSwitchOn.MsgIsZero()) && ((*z).BlockHeader.UpgradeVote.UpgradePropose.MsgIsZero()) && ((*z).BlockHeader.UpgradeVote.UpgradeDelay.MsgIsZero()) && ((*z).BlockHeader.UpgradeVote.UpgradeApprove == false) && ((*z).BlockHeader.TxnCounter == 0) && ((*z).Payset.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *BlockHash) MarshalMsg(b []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).MarshalMsg(b) +} +func (_ *BlockHash) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*BlockHash) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BlockHash) UnmarshalMsg(bts []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) +} +func (_ *BlockHash) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*BlockHash) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *BlockHash) Msgsize() int { + return ((*(crypto.Digest))(z)).Msgsize() +} + +// MsgIsZero returns whether this is a zero value +func (z *BlockHash) MsgIsZero() bool { + return ((*(crypto.Digest))(z)).MsgIsZero() +} + +// MarshalMsg implements msgp.Marshaler +func (z *BlockHeader) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(22) + var zb0001Mask uint32 /* 25 bits */ + if (*z).RewardsState.RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).RewardsState.FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).RewardsState.RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).GenesisID == "" { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).GenesisHash.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).UpgradeState.NextProtocolVoteBefore.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).UpgradeState.NextProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).UpgradeState.NextProtocolSwitchOn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).UpgradeState.NextProtocolApprovals == 0 { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).Branch.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).UpgradeState.CurrentProtocol.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2000 + } + if (*z).RewardsState.RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x4000 + } + if (*z).Round.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8000 + } + if (*z).RewardsState.RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10000 + } + if (*z).RewardsState.RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20000 + } + if (*z).Seed.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40000 + } + if (*z).TxnCounter == 0 { + zb0001Len-- + zb0001Mask |= 0x80000 + } + if (*z).TimeStamp == 0 { + zb0001Len-- + zb0001Mask |= 0x100000 + } + if (*z).TxnRoot.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200000 + } + if (*z).UpgradeVote.UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400000 + } + if (*z).UpgradeVote.UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800000 + } + if (*z).UpgradeVote.UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x1000000 + } + // variable map header, size zb0001Len + o = msgp.AppendMapHeader(o, zb0001Len) + if zb0001Len != 0 { + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).RewardsState.RewardsLevel) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).RewardsState.FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).RewardsState.RewardsResidue) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).GenesisID) + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "nextbefore" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65) + o, err = (*z).UpgradeState.NextProtocolVoteBefore.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "nextproto" + o = append(o, 0xa9, 0x6e, 0x65, 0x78, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).UpgradeState.NextProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "nextswitch" + o = append(o, 0xaa, 0x6e, 0x65, 0x78, 0x74, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68) + o, err = (*z).UpgradeState.NextProtocolSwitchOn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "nextyes" + o = append(o, 0xa7, 0x6e, 0x65, 0x78, 0x74, 0x79, 0x65, 0x73) + o = msgp.AppendUint64(o, (*z).UpgradeState.NextProtocolApprovals) + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "prev" + o = append(o, 0xa4, 0x70, 0x72, 0x65, 0x76) + o, err = (*z).Branch.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).UpgradeState.CurrentProtocol.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + } + if (zb0001Mask & 0x4000) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).RewardsState.RewardsRate) + } + if (zb0001Mask & 0x8000) == 0 { // if not empty + // string "rnd" + o = append(o, 0xa3, 0x72, 0x6e, 0x64) + o, err = (*z).Round.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + } + if (zb0001Mask & 0x10000) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).RewardsState.RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x20000) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).RewardsState.RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + if (zb0001Mask & 0x40000) == 0 { // if not empty + // string "seed" + o = append(o, 0xa4, 0x73, 0x65, 0x65, 0x64) + o, err = (*z).Seed.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + } + if (zb0001Mask & 0x80000) == 0 { // if not empty + // string "tc" + o = append(o, 0xa2, 0x74, 0x63) + o = msgp.AppendUint64(o, (*z).TxnCounter) + } + if (zb0001Mask & 0x100000) == 0 { // if not empty + // string "ts" + o = append(o, 0xa2, 0x74, 0x73) + o = msgp.AppendInt64(o, (*z).TimeStamp) + } + if (zb0001Mask & 0x200000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).TxnRoot.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + } + if (zb0001Mask & 0x400000) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).UpgradeVote.UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x800000) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).UpgradeVote.UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x1000000) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).UpgradeVote.UpgradeApprove) + } + } + return +} + +func (_ *BlockHeader) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*BlockHeader) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *BlockHeader) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Round") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Branch") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Seed") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnRoot") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TimeStamp") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CurrentProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocol") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolApprovals") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolVoteBefore") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "NextProtocolSwitchOn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxnCounter") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = BlockHeader{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rnd": + bts, err = (*z).Round.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Round") + return + } + case "prev": + bts, err = (*z).Branch.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Branch") + return + } + case "seed": + bts, err = (*z).Seed.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Seed") + return + } + case "txn": + bts, err = (*z).TxnRoot.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxnRoot") + return + } + case "ts": + (*z).TimeStamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TimeStamp") + return + } + case "gen": + (*z).GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "fees": + bts, err = (*z).RewardsState.FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).RewardsState.RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).RewardsState.RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).RewardsState.RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).RewardsState.RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).RewardsState.RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + case "proto": + bts, err = (*z).UpgradeState.CurrentProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CurrentProtocol") + return + } + case "nextproto": + bts, err = (*z).UpgradeState.NextProtocol.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocol") + return + } + case "nextyes": + (*z).UpgradeState.NextProtocolApprovals, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolApprovals") + return + } + case "nextbefore": + bts, err = (*z).UpgradeState.NextProtocolVoteBefore.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolVoteBefore") + return + } + case "nextswitch": + bts, err = (*z).UpgradeState.NextProtocolSwitchOn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "NextProtocolSwitchOn") + return + } + case "upgradeprop": + bts, err = (*z).UpgradeVote.UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).UpgradeVote.UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).UpgradeVote.UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + case "tc": + (*z).TxnCounter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxnCounter") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *BlockHeader) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*BlockHeader) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *BlockHeader) Msgsize() (s int) { + s = 3 + 4 + (*z).Round.Msgsize() + 5 + (*z).Branch.Msgsize() + 5 + (*z).Seed.Msgsize() + 4 + (*z).TxnRoot.Msgsize() + 3 + msgp.Int64Size + 4 + msgp.StringPrefixSize + len((*z).GenesisID) + 3 + (*z).GenesisHash.Msgsize() + 5 + (*z).RewardsState.FeeSink.Msgsize() + 4 + (*z).RewardsState.RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).RewardsState.RewardsRecalculationRound.Msgsize() + 6 + (*z).UpgradeState.CurrentProtocol.Msgsize() + 10 + (*z).UpgradeState.NextProtocol.Msgsize() + 8 + msgp.Uint64Size + 11 + (*z).UpgradeState.NextProtocolVoteBefore.Msgsize() + 11 + (*z).UpgradeState.NextProtocolSwitchOn.Msgsize() + 12 + (*z).UpgradeVote.UpgradePropose.Msgsize() + 13 + (*z).UpgradeVote.UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + 3 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *BlockHeader) MsgIsZero() bool { + return ((*z).Round.MsgIsZero()) && ((*z).Branch.MsgIsZero()) && ((*z).Seed.MsgIsZero()) && ((*z).TxnRoot.MsgIsZero()) && ((*z).TimeStamp == 0) && ((*z).GenesisID == "") && ((*z).GenesisHash.MsgIsZero()) && ((*z).RewardsState.FeeSink.MsgIsZero()) && ((*z).RewardsState.RewardsPool.MsgIsZero()) && ((*z).RewardsState.RewardsLevel == 0) && ((*z).RewardsState.RewardsRate == 0) && ((*z).RewardsState.RewardsResidue == 0) && ((*z).RewardsState.RewardsRecalculationRound.MsgIsZero()) && ((*z).UpgradeState.CurrentProtocol.MsgIsZero()) && ((*z).UpgradeState.NextProtocol.MsgIsZero()) && ((*z).UpgradeState.NextProtocolApprovals == 0) && ((*z).UpgradeState.NextProtocolVoteBefore.MsgIsZero()) && ((*z).UpgradeState.NextProtocolSwitchOn.MsgIsZero()) && ((*z).UpgradeVote.UpgradePropose.MsgIsZero()) && ((*z).UpgradeVote.UpgradeDelay.MsgIsZero()) && ((*z).UpgradeVote.UpgradeApprove == false) && ((*z).TxnCounter == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Genesis) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(8) + var zb0002Mask uint16 /* 9 bits */ + if len((*z).Allocation) == 0 { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).Comment == "" { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).FeeSink == "" { + zb0002Len-- + zb0002Mask |= 0x8 + } + if (*z).SchemaID == "" { + zb0002Len-- + zb0002Mask |= 0x10 + } + if (*z).Network.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x20 + } + if (*z).Proto.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x40 + } + if (*z).RewardsPool == "" { + zb0002Len-- + zb0002Mask |= 0x80 + } + if (*z).Timestamp == 0 { + zb0002Len-- + zb0002Mask |= 0x100 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "alloc" + o = append(o, 0xa5, 0x61, 0x6c, 0x6c, 0x6f, 0x63) + if (*z).Allocation == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Allocation))) + } + for zb0001 := range (*z).Allocation { + o, err = (*z).Allocation[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Allocation", zb0001) + return + } + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "comment" + o = append(o, 0xa7, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74) + o = msgp.AppendString(o, (*z).Comment) + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o = msgp.AppendString(o, (*z).FeeSink) + } + if (zb0002Mask & 0x10) == 0 { // if not empty + // string "id" + o = append(o, 0xa2, 0x69, 0x64) + o = msgp.AppendString(o, (*z).SchemaID) + } + if (zb0002Mask & 0x20) == 0 { // if not empty + // string "network" + o = append(o, 0xa7, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b) + o, err = (*z).Network.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Network") + return + } + } + if (zb0002Mask & 0x40) == 0 { // if not empty + // string "proto" + o = append(o, 0xa5, 0x70, 0x72, 0x6f, 0x74, 0x6f) + o, err = (*z).Proto.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proto") + return + } + } + if (zb0002Mask & 0x80) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o = msgp.AppendString(o, (*z).RewardsPool) + } + if (zb0002Mask & 0x100) == 0 { // if not empty + // string "timestamp" + o = append(o, 0xa9, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70) + o = msgp.AppendInt64(o, (*z).Timestamp) + } + } + return +} + +func (_ *Genesis) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Genesis) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Genesis) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + (*z).SchemaID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SchemaID") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Network.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Network") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Proto.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proto") + return + } + } + if zb0002 > 0 { + zb0002-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Allocation") + return + } + if zb0005 { + (*z).Allocation = nil + } else if (*z).Allocation != nil && cap((*z).Allocation) >= zb0004 { + (*z).Allocation = ((*z).Allocation)[:zb0004] + } else { + (*z).Allocation = make([]GenesisAllocation, zb0004) + } + for zb0001 := range (*z).Allocation { + bts, err = (*z).Allocation[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Allocation", zb0001) + return + } + } + } + if zb0002 > 0 { + zb0002-- + (*z).RewardsPool, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).FeeSink, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Timestamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Timestamp") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Comment, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Comment") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = Genesis{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "id": + (*z).SchemaID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "SchemaID") + return + } + case "network": + bts, err = (*z).Network.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Network") + return + } + case "proto": + bts, err = (*z).Proto.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proto") + return + } + case "alloc": + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Allocation") + return + } + if zb0007 { + (*z).Allocation = nil + } else if (*z).Allocation != nil && cap((*z).Allocation) >= zb0006 { + (*z).Allocation = ((*z).Allocation)[:zb0006] + } else { + (*z).Allocation = make([]GenesisAllocation, zb0006) + } + for zb0001 := range (*z).Allocation { + bts, err = (*z).Allocation[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Allocation", zb0001) + return + } + } + case "rwd": + (*z).RewardsPool, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "fees": + (*z).FeeSink, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "timestamp": + (*z).Timestamp, bts, err = msgp.ReadInt64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Timestamp") + return + } + case "comment": + (*z).Comment, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Comment") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Genesis) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Genesis) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Genesis) Msgsize() (s int) { + s = 1 + 3 + msgp.StringPrefixSize + len((*z).SchemaID) + 8 + (*z).Network.Msgsize() + 6 + (*z).Proto.Msgsize() + 6 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Allocation { + s += (*z).Allocation[zb0001].Msgsize() + } + s += 4 + msgp.StringPrefixSize + len((*z).RewardsPool) + 5 + msgp.StringPrefixSize + len((*z).FeeSink) + 10 + msgp.Int64Size + 8 + msgp.StringPrefixSize + len((*z).Comment) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Genesis) MsgIsZero() bool { + return ((*z).SchemaID == "") && ((*z).Network.MsgIsZero()) && ((*z).Proto.MsgIsZero()) && (len((*z).Allocation) == 0) && ((*z).RewardsPool == "") && ((*z).FeeSink == "") && ((*z).Timestamp == 0) && ((*z).Comment == "") +} + +// MarshalMsg implements msgp.Marshaler +func (z *GenesisAllocation) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // map header, size 3 + // string "addr" + o = append(o, 0x83, 0xa4, 0x61, 0x64, 0x64, 0x72) + o = msgp.AppendString(o, (*z).Address) + // string "comment" + o = append(o, 0xa7, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74) + o = msgp.AppendString(o, (*z).Comment) + // string "state" + o = append(o, 0xa5, 0x73, 0x74, 0x61, 0x74, 0x65) + o, err = (*z).State.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "State") + return + } + return +} + +func (_ *GenesisAllocation) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*GenesisAllocation) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *GenesisAllocation) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + (*z).Address, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Address") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Comment, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Comment") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).State.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "State") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = GenesisAllocation{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "addr": + (*z).Address, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Address") + return + } + case "comment": + (*z).Comment, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Comment") + return + } + case "state": + bts, err = (*z).State.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "State") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *GenesisAllocation) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*GenesisAllocation) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *GenesisAllocation) Msgsize() (s int) { + s = 1 + 5 + msgp.StringPrefixSize + len((*z).Address) + 8 + msgp.StringPrefixSize + len((*z).Comment) + 6 + (*z).State.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *GenesisAllocation) MsgIsZero() bool { + return ((*z).Address == "") && ((*z).Comment == "") && ((*z).State.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *RewardsState) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(6) + var zb0001Mask uint8 /* 7 bits */ + if (*z).RewardsLevel == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).FeeSink.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).RewardsResidue == 0 { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).RewardsRate == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).RewardsRecalculationRound.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).RewardsPool.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "earn" + o = append(o, 0xa4, 0x65, 0x61, 0x72, 0x6e) + o = msgp.AppendUint64(o, (*z).RewardsLevel) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "fees" + o = append(o, 0xa4, 0x66, 0x65, 0x65, 0x73) + o, err = (*z).FeeSink.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "frac" + o = append(o, 0xa4, 0x66, 0x72, 0x61, 0x63) + o = msgp.AppendUint64(o, (*z).RewardsResidue) + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "rate" + o = append(o, 0xa4, 0x72, 0x61, 0x74, 0x65) + o = msgp.AppendUint64(o, (*z).RewardsRate) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "rwcalr" + o = append(o, 0xa6, 0x72, 0x77, 0x63, 0x61, 0x6c, 0x72) + o, err = (*z).RewardsRecalculationRound.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "rwd" + o = append(o, 0xa3, 0x72, 0x77, 0x64) + o, err = (*z).RewardsPool.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + } + } + return +} + +func (_ *RewardsState) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*RewardsState) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *RewardsState) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FeeSink") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsPool") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsLevel") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRate") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsResidue") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RewardsRecalculationRound") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = RewardsState{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "fees": + bts, err = (*z).FeeSink.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FeeSink") + return + } + case "rwd": + bts, err = (*z).RewardsPool.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsPool") + return + } + case "earn": + (*z).RewardsLevel, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsLevel") + return + } + case "rate": + (*z).RewardsRate, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRate") + return + } + case "frac": + (*z).RewardsResidue, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsResidue") + return + } + case "rwcalr": + bts, err = (*z).RewardsRecalculationRound.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RewardsRecalculationRound") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *RewardsState) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*RewardsState) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *RewardsState) Msgsize() (s int) { + s = 1 + 5 + (*z).FeeSink.Msgsize() + 4 + (*z).RewardsPool.Msgsize() + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint64Size + 7 + (*z).RewardsRecalculationRound.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *RewardsState) MsgIsZero() bool { + return ((*z).FeeSink.MsgIsZero()) && ((*z).RewardsPool.MsgIsZero()) && ((*z).RewardsLevel == 0) && ((*z).RewardsRate == 0) && ((*z).RewardsResidue == 0) && ((*z).RewardsRecalculationRound.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *UpgradeVote) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).UpgradeDelay.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).UpgradePropose.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).UpgradeApprove == false { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "upgradedelay" + o = append(o, 0xac, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x64, 0x65, 0x6c, 0x61, 0x79) + o, err = (*z).UpgradeDelay.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "upgradeprop" + o = append(o, 0xab, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x70) + o, err = (*z).UpgradePropose.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "upgradeyes" + o = append(o, 0xaa, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x65, 0x73) + o = msgp.AppendBool(o, (*z).UpgradeApprove) + } + } + return +} + +func (_ *UpgradeVote) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*UpgradeVote) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *UpgradeVote) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradePropose") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeDelay") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "UpgradeApprove") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = UpgradeVote{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "upgradeprop": + bts, err = (*z).UpgradePropose.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradePropose") + return + } + case "upgradedelay": + bts, err = (*z).UpgradeDelay.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeDelay") + return + } + case "upgradeyes": + (*z).UpgradeApprove, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "UpgradeApprove") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *UpgradeVote) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*UpgradeVote) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *UpgradeVote) Msgsize() (s int) { + s = 1 + 12 + (*z).UpgradePropose.Msgsize() + 13 + (*z).UpgradeDelay.Msgsize() + 11 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *UpgradeVote) MsgIsZero() bool { + return ((*z).UpgradePropose.MsgIsZero()) && ((*z).UpgradeDelay.MsgIsZero()) && ((*z).UpgradeApprove == false) +} diff --git a/data/bookkeeping/msgp_gen_test.go b/data/bookkeeping/msgp_gen_test.go new file mode 100644 index 0000000000..05a75ab839 --- /dev/null +++ b/data/bookkeeping/msgp_gen_test.go @@ -0,0 +1,382 @@ +package bookkeeping + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalBlock(t *testing.T) { + v := Block{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBlock(t *testing.T) { + protocol.RunEncodingTest(t, &Block{}) +} + +func BenchmarkMarshalMsgBlock(b *testing.B) { + v := Block{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBlock(b *testing.B) { + v := Block{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBlock(b *testing.B) { + v := Block{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalBlockHeader(t *testing.T) { + v := BlockHeader{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingBlockHeader(t *testing.T) { + protocol.RunEncodingTest(t, &BlockHeader{}) +} + +func BenchmarkMarshalMsgBlockHeader(b *testing.B) { + v := BlockHeader{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgBlockHeader(b *testing.B) { + v := BlockHeader{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalBlockHeader(b *testing.B) { + v := BlockHeader{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalGenesis(t *testing.T) { + v := Genesis{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingGenesis(t *testing.T) { + protocol.RunEncodingTest(t, &Genesis{}) +} + +func BenchmarkMarshalMsgGenesis(b *testing.B) { + v := Genesis{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgGenesis(b *testing.B) { + v := Genesis{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalGenesis(b *testing.B) { + v := Genesis{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalGenesisAllocation(t *testing.T) { + v := GenesisAllocation{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingGenesisAllocation(t *testing.T) { + protocol.RunEncodingTest(t, &GenesisAllocation{}) +} + +func BenchmarkMarshalMsgGenesisAllocation(b *testing.B) { + v := GenesisAllocation{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgGenesisAllocation(b *testing.B) { + v := GenesisAllocation{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalGenesisAllocation(b *testing.B) { + v := GenesisAllocation{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalRewardsState(t *testing.T) { + v := RewardsState{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingRewardsState(t *testing.T) { + protocol.RunEncodingTest(t, &RewardsState{}) +} + +func BenchmarkMarshalMsgRewardsState(b *testing.B) { + v := RewardsState{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgRewardsState(b *testing.B) { + v := RewardsState{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalRewardsState(b *testing.B) { + v := RewardsState{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalUpgradeVote(t *testing.T) { + v := UpgradeVote{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingUpgradeVote(t *testing.T) { + protocol.RunEncodingTest(t, &UpgradeVote{}) +} + +func BenchmarkMarshalMsgUpgradeVote(b *testing.B) { + v := UpgradeVote{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgUpgradeVote(b *testing.B) { + v := UpgradeVote{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalUpgradeVote(b *testing.B) { + v := UpgradeVote{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/data/committee/common_test.go b/data/committee/common_test.go index 542884a665..bbd8c6d29d 100644 --- a/data/committee/common_test.go +++ b/data/committee/common_test.go @@ -171,7 +171,7 @@ type AgreementSelector struct { // ToBeHashed implements the crypto.Hashable interface. func (sel AgreementSelector) ToBeHashed() (protocol.HashID, []byte) { - return protocol.AgreementSelector, protocol.Encode(sel) + return protocol.AgreementSelector, protocol.Encode(&sel) } // CommitteeSize returns the size of the committee, diff --git a/data/committee/credential.go b/data/committee/credential.go index 5d8168fe27..2d5dfe2ef8 100644 --- a/data/committee/credential.go +++ b/data/committee/credential.go @@ -185,5 +185,5 @@ func (cred Credential) lowestOutput() *big.Int { } func (cred hashableCredential) ToBeHashed() (protocol.HashID, []byte) { - return protocol.Credential, protocol.Encode(cred) + return protocol.Credential, protocol.Encode(&cred) } diff --git a/data/committee/msgp_gen.go b/data/committee/msgp_gen.go new file mode 100644 index 0000000000..845cbcfe34 --- /dev/null +++ b/data/committee/msgp_gen.go @@ -0,0 +1,526 @@ +package committee + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Credential) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(5) + var zb0001Mask uint8 /* 7 bits */ + if (*z).DomainSeparationEnabled == false { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).VrfOut.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).Hashable.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).UnauthenticatedCredential.Proof.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).Weight == 0 { + zb0001Len-- + zb0001Mask |= 0x40 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "ds" + o = append(o, 0xa2, 0x64, 0x73) + o = msgp.AppendBool(o, (*z).DomainSeparationEnabled) + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "h" + o = append(o, 0xa1, 0x68) + o, err = (*z).VrfOut.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VrfOut") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "hc" + o = append(o, 0xa2, 0x68, 0x63) + o, err = (*z).Hashable.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Hashable") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "pf" + o = append(o, 0xa2, 0x70, 0x66) + o, err = (*z).UnauthenticatedCredential.Proof.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proof") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "wt" + o = append(o, 0xa2, 0x77, 0x74) + o = msgp.AppendUint64(o, (*z).Weight) + } + } + return +} + +func (_ *Credential) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Credential) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Credential) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + (*z).Weight, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Weight") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).VrfOut.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VrfOut") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).DomainSeparationEnabled, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "DomainSeparationEnabled") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Hashable.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Hashable") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proof") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Credential{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "wt": + (*z).Weight, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Weight") + return + } + case "h": + bts, err = (*z).VrfOut.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VrfOut") + return + } + case "ds": + (*z).DomainSeparationEnabled, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "DomainSeparationEnabled") + return + } + case "hc": + bts, err = (*z).Hashable.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Hashable") + return + } + case "pf": + bts, err = (*z).UnauthenticatedCredential.Proof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proof") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Credential) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Credential) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Credential) Msgsize() (s int) { + s = 1 + 3 + msgp.Uint64Size + 2 + (*z).VrfOut.Msgsize() + 3 + msgp.BoolSize + 3 + (*z).Hashable.Msgsize() + 3 + (*z).UnauthenticatedCredential.Proof.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Credential) MsgIsZero() bool { + return ((*z).Weight == 0) && ((*z).VrfOut.MsgIsZero()) && ((*z).DomainSeparationEnabled == false) && ((*z).Hashable.MsgIsZero()) && ((*z).UnauthenticatedCredential.Proof.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Seed) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendBytes(o, (*z)[:]) + return +} + +func (_ *Seed) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Seed) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Seed) UnmarshalMsg(bts []byte) (o []byte, err error) { + bts, err = msgp.ReadExactBytes(bts, (*z)[:]) + if err != nil { + err = msgp.WrapError(err) + return + } + o = bts + return +} + +func (_ *Seed) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Seed) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Seed) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Seed) MsgIsZero() bool { + return (*z) == (Seed{}) +} + +// MarshalMsg implements msgp.Marshaler +func (z *UnauthenticatedCredential) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(1) + var zb0001Mask uint8 /* 2 bits */ + if (*z).Proof.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "pf" + o = append(o, 0xa2, 0x70, 0x66) + o, err = (*z).Proof.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Proof") + return + } + } + } + return +} + +func (_ *UnauthenticatedCredential) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*UnauthenticatedCredential) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *UnauthenticatedCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Proof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Proof") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = UnauthenticatedCredential{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "pf": + bts, err = (*z).Proof.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Proof") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *UnauthenticatedCredential) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*UnauthenticatedCredential) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *UnauthenticatedCredential) Msgsize() (s int) { + s = 1 + 3 + (*z).Proof.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *UnauthenticatedCredential) MsgIsZero() bool { + return ((*z).Proof.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *hashableCredential) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).Iter == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Member.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).RawOut.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "i" + o = append(o, 0xa1, 0x69) + o = msgp.AppendUint64(o, (*z).Iter) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "m" + o = append(o, 0xa1, 0x6d) + o, err = (*z).Member.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Member") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "v" + o = append(o, 0xa1, 0x76) + o, err = (*z).RawOut.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "RawOut") + return + } + } + } + return +} + +func (_ *hashableCredential) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*hashableCredential) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *hashableCredential) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).RawOut.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "RawOut") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Member.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Member") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Iter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Iter") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = hashableCredential{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "v": + bts, err = (*z).RawOut.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "RawOut") + return + } + case "m": + bts, err = (*z).Member.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Member") + return + } + case "i": + (*z).Iter, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "Iter") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *hashableCredential) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*hashableCredential) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *hashableCredential) Msgsize() (s int) { + s = 1 + 2 + (*z).RawOut.Msgsize() + 2 + (*z).Member.Msgsize() + 2 + msgp.Uint64Size + return +} + +// MsgIsZero returns whether this is a zero value +func (z *hashableCredential) MsgIsZero() bool { + return ((*z).RawOut.MsgIsZero()) && ((*z).Member.MsgIsZero()) && ((*z).Iter == 0) +} diff --git a/data/committee/msgp_gen_test.go b/data/committee/msgp_gen_test.go new file mode 100644 index 0000000000..cdbad86c93 --- /dev/null +++ b/data/committee/msgp_gen_test.go @@ -0,0 +1,258 @@ +package committee + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalCredential(t *testing.T) { + v := Credential{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingCredential(t *testing.T) { + protocol.RunEncodingTest(t, &Credential{}) +} + +func BenchmarkMarshalMsgCredential(b *testing.B) { + v := Credential{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgCredential(b *testing.B) { + v := Credential{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalCredential(b *testing.B) { + v := Credential{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSeed(t *testing.T) { + v := Seed{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSeed(t *testing.T) { + protocol.RunEncodingTest(t, &Seed{}) +} + +func BenchmarkMarshalMsgSeed(b *testing.B) { + v := Seed{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSeed(b *testing.B) { + v := Seed{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSeed(b *testing.B) { + v := Seed{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalUnauthenticatedCredential(t *testing.T) { + v := UnauthenticatedCredential{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingUnauthenticatedCredential(t *testing.T) { + protocol.RunEncodingTest(t, &UnauthenticatedCredential{}) +} + +func BenchmarkMarshalMsgUnauthenticatedCredential(b *testing.B) { + v := UnauthenticatedCredential{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgUnauthenticatedCredential(b *testing.B) { + v := UnauthenticatedCredential{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalUnauthenticatedCredential(b *testing.B) { + v := UnauthenticatedCredential{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalhashableCredential(t *testing.T) { + v := hashableCredential{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodinghashableCredential(t *testing.T) { + protocol.RunEncodingTest(t, &hashableCredential{}) +} + +func BenchmarkMarshalMsghashableCredential(b *testing.B) { + v := hashableCredential{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsghashableCredential(b *testing.B) { + v := hashableCredential{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalhashableCredential(b *testing.B) { + v := hashableCredential{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/data/hashable/message.go b/data/hashable/message.go index 95e14c9b8a..558a143f5b 100644 --- a/data/hashable/message.go +++ b/data/hashable/message.go @@ -28,5 +28,5 @@ type Message struct { // ToBeHashed implements the crypto.Hashable interface func (msg Message) ToBeHashed() (protocol.HashID, []byte) { - return protocol.Message, protocol.Encode(msg) + return protocol.Message, protocol.Encode(&msg) } diff --git a/data/hashable/msgp_gen.go b/data/hashable/msgp_gen.go new file mode 100644 index 0000000000..4322867649 --- /dev/null +++ b/data/hashable/msgp_gen.go @@ -0,0 +1,113 @@ +package hashable + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *Message) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(1) + var zb0001Mask uint8 /* 2 bits */ + if (*z).Message == "" { + zb0001Len-- + zb0001Mask |= 0x2 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "msg" + o = append(o, 0xa3, 0x6d, 0x73, 0x67) + o = msgp.AppendString(o, (*z).Message) + } + } + return +} + +func (_ *Message) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Message) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + (*z).Message, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Message") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = Message{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "msg": + (*z).Message, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Message") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Message) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Message) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Message) Msgsize() (s int) { + s = 1 + 4 + msgp.StringPrefixSize + len((*z).Message) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Message) MsgIsZero() bool { + return ((*z).Message == "") +} diff --git a/data/hashable/msgp_gen_test.go b/data/hashable/msgp_gen_test.go new file mode 100644 index 0000000000..3a3617154a --- /dev/null +++ b/data/hashable/msgp_gen_test.go @@ -0,0 +1,72 @@ +package hashable + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalMessage(t *testing.T) { + v := Message{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingMessage(t *testing.T) { + protocol.RunEncodingTest(t, &Message{}) +} + +func BenchmarkMarshalMsgMessage(b *testing.B) { + v := Message{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgMessage(b *testing.B) { + v := Message{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalMessage(b *testing.B) { + v := Message{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/data/ledger.go b/data/ledger.go index f1ca591912..bbfefdc059 100644 --- a/data/ledger.go +++ b/data/ledger.go @@ -372,7 +372,6 @@ func (l *Ledger) AssemblePayset(pool *pools.TransactionPool, eval *ledger.BlockE for _, txn := range txgroup { fee := txn.Txn.Fee.Raw encodedLen := txn.GetEncodedLength() - priority := uint64(txn.PtrPriority()) stats.IncludedCount++ totalFees += fee @@ -383,8 +382,6 @@ func (l *Ledger) AssemblePayset(pool *pools.TransactionPool, eval *ledger.BlockE stats.MaxFee = fee stats.MinLength = encodedLen stats.MaxLength = encodedLen - stats.MinPriority = priority - stats.MaxPriority = priority } else { if fee < stats.MinFee { stats.MinFee = fee @@ -396,11 +393,6 @@ func (l *Ledger) AssemblePayset(pool *pools.TransactionPool, eval *ledger.BlockE } else if encodedLen > stats.MaxLength { stats.MaxLength = encodedLen } - if priority < stats.MinPriority { - stats.MinPriority = priority - } else if priority > stats.MaxPriority { - stats.MaxPriority = priority - } } stats.TotalLength += uint64(encodedLen) } diff --git a/data/pools/feeTracker.go b/data/pools/feeTracker.go index 44c7853f56..dde629f7b9 100644 --- a/data/pools/feeTracker.go +++ b/data/pools/feeTracker.go @@ -67,7 +67,7 @@ func (ft *FeeTracker) EstimateFee() basics.MicroAlgos { // ProcessBlock takes a block and update the current suggested fee func (ft *FeeTracker) ProcessBlock(block bookkeeping.Block) { // If the block is less than half full, drive the suggested fee down rapidly. Suggested Fee may fall to zero, but algod API client will be responsible for submitting transactions with at least MinTxnFee - if len(protocol.Encode(block.Payset)) < config.Consensus[block.CurrentProtocol].MaxTxnBytesPerBlock/2 { + if len(protocol.Encode(&block.Payset)) < config.Consensus[block.CurrentProtocol].MaxTxnBytesPerBlock/2 { ft.add(1.0) return } diff --git a/data/pools/transactionPool.go b/data/pools/transactionPool.go index fe108e448b..efc4c6bc95 100644 --- a/data/pools/transactionPool.go +++ b/data/pools/transactionPool.go @@ -231,10 +231,6 @@ func (pool *TransactionPool) Test(txgroup []transactions.SignedTxn) error { return err } - for i := range txgroup { - txgroup[i].InitCaches() - } - pool.mu.Lock() defer pool.mu.Unlock() @@ -327,10 +323,6 @@ func (pool *TransactionPool) Remember(txgroup []transactions.SignedTxn, verifyPa return err } - for i := range txgroup { - txgroup[i].InitCaches() - } - pool.mu.Lock() defer pool.mu.Unlock() diff --git a/data/transactions/aggregates.go b/data/transactions/aggregates.go index 006e8b559f..4658b3bd59 100644 --- a/data/transactions/aggregates.go +++ b/data/transactions/aggregates.go @@ -24,6 +24,7 @@ import ( type ( // A Payset represents a common, unforgeable, consistent, ordered set of SignedTxn objects. + //msgp:allocbound Payset 100000 Payset []SignedTxnInBlock ) diff --git a/data/transactions/logic/eval.go b/data/transactions/logic/eval.go index 0ef3ec15c1..94465a38a0 100644 --- a/data/transactions/logic/eval.go +++ b/data/transactions/logic/eval.go @@ -44,9 +44,6 @@ import ( // EvalMaxVersion is the max version we can interpret and run const EvalMaxVersion = 1 -// EvalMaxArgs is the maximum number of arguments to an LSig -const EvalMaxArgs = 255 - // EvalMaxScratchSize is the maximum number of scratch slots. const EvalMaxScratchSize = 255 @@ -194,7 +191,7 @@ func Eval(program []byte, params EvalParams) (pass bool, err error) { err = errLogicSignNotSupported return } - if params.Txn.Lsig.Args != nil && len(params.Txn.Lsig.Args) > EvalMaxArgs { + if params.Txn.Lsig.Args != nil && len(params.Txn.Lsig.Args) > transactions.EvalMaxArgs { err = errTooManyArgs return } diff --git a/data/transactions/logic/eval_test.go b/data/transactions/logic/eval_test.go index fc228fe45e..c314879afe 100644 --- a/data/transactions/logic/eval_test.go +++ b/data/transactions/logic/eval_test.go @@ -64,7 +64,7 @@ func TestTooManyArgs(t *testing.T) { require.NoError(t, err) var txn transactions.SignedTxn txn.Lsig.Logic = program - args := [EvalMaxArgs + 1][]byte{} + args := [transactions.EvalMaxArgs + 1][]byte{} txn.Lsig.Args = args[:] sb := strings.Builder{} pass, err := Eval(program, defaultEvalParams(&sb, &txn)) diff --git a/data/transactions/logicsig.go b/data/transactions/logicsig.go index b5c19078fb..675847131e 100644 --- a/data/transactions/logicsig.go +++ b/data/transactions/logicsig.go @@ -22,6 +22,9 @@ import ( "github.com/algorand/go-algorand/crypto" ) +// EvalMaxArgs is the maximum number of arguments to an LSig +const EvalMaxArgs = 255 + // LogicSig contains logic for validating a transaction. // LogicSig is signed by an account, allowing delegation of operations. // OR @@ -36,7 +39,7 @@ type LogicSig struct { Msig crypto.MultisigSig `codec:"msig"` // Args are not signed, but checked by Logic - Args [][]byte `codec:"arg"` + Args [][]byte `codec:"arg,allocbound=EvalMaxArgs"` } // Blank returns true if there is no content in this LogicSig diff --git a/data/transactions/msgp_gen.go b/data/transactions/msgp_gen.go new file mode 100644 index 0000000000..b59a4327f6 --- /dev/null +++ b/data/transactions/msgp_gen.go @@ -0,0 +1,3636 @@ +package transactions + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/go-algorand/crypto" + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z *ApplyData) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(4) + var zb0001Mask uint8 /* 5 bits */ + if (*z).ClosingAmount.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).CloseRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).ReceiverRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).SenderRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "ca" + o = append(o, 0xa2, 0x63, 0x61) + o, err = (*z).ClosingAmount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "rc" + o = append(o, 0xa2, 0x72, 0x63) + o, err = (*z).CloseRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "rr" + o = append(o, 0xa2, 0x72, 0x72) + o, err = (*z).ReceiverRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "rs" + o = append(o, 0xa2, 0x72, 0x73) + o, err = (*z).SenderRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + } + } + return +} + +func (_ *ApplyData) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*ApplyData) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ApplyData) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SenderRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CloseRewards") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = ApplyData{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "ca": + bts, err = (*z).ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + case "rs": + bts, err = (*z).SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + case "rr": + bts, err = (*z).ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + case "rc": + bts, err = (*z).CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *ApplyData) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ApplyData) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *ApplyData) Msgsize() (s int) { + s = 1 + 3 + (*z).ClosingAmount.Msgsize() + 3 + (*z).SenderRewards.Msgsize() + 3 + (*z).ReceiverRewards.Msgsize() + 3 + (*z).CloseRewards.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *ApplyData) MsgIsZero() bool { + return ((*z).ClosingAmount.MsgIsZero()) && ((*z).SenderRewards.MsgIsZero()) && ((*z).ReceiverRewards.MsgIsZero()) && ((*z).CloseRewards.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *AssetConfigTxnFields) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(2) + var zb0001Mask uint8 /* 3 bits */ + if (*z).AssetParams.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).ConfigAsset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "apar" + o = append(o, 0xa4, 0x61, 0x70, 0x61, 0x72) + o, err = (*z).AssetParams.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "caid" + o = append(o, 0xa4, 0x63, 0x61, 0x69, 0x64) + o, err = (*z).ConfigAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ConfigAsset") + return + } + } + } + return +} + +func (_ *AssetConfigTxnFields) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetConfigTxnFields) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetConfigTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AssetParams.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = AssetConfigTxnFields{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "caid": + bts, err = (*z).ConfigAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ConfigAsset") + return + } + case "apar": + bts, err = (*z).AssetParams.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AssetConfigTxnFields) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetConfigTxnFields) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AssetConfigTxnFields) Msgsize() (s int) { + s = 1 + 5 + (*z).ConfigAsset.Msgsize() + 5 + (*z).AssetParams.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AssetConfigTxnFields) MsgIsZero() bool { + return ((*z).ConfigAsset.MsgIsZero()) && ((*z).AssetParams.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *AssetFreezeTxnFields) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).AssetFrozen == false { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).FreezeAccount.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).FreezeAsset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "afrz" + o = append(o, 0xa4, 0x61, 0x66, 0x72, 0x7a) + o = msgp.AppendBool(o, (*z).AssetFrozen) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "fadd" + o = append(o, 0xa4, 0x66, 0x61, 0x64, 0x64) + o, err = (*z).FreezeAccount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FreezeAccount") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "faid" + o = append(o, 0xa4, 0x66, 0x61, 0x69, 0x64) + o, err = (*z).FreezeAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FreezeAsset") + return + } + } + } + return +} + +func (_ *AssetFreezeTxnFields) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetFreezeTxnFields) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetFreezeTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).FreezeAccount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FreezeAccount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).FreezeAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FreezeAsset") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AssetFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetFrozen") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = AssetFreezeTxnFields{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "fadd": + bts, err = (*z).FreezeAccount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FreezeAccount") + return + } + case "faid": + bts, err = (*z).FreezeAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FreezeAsset") + return + } + case "afrz": + (*z).AssetFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetFrozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AssetFreezeTxnFields) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetFreezeTxnFields) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AssetFreezeTxnFields) Msgsize() (s int) { + s = 1 + 5 + (*z).FreezeAccount.Msgsize() + 5 + (*z).FreezeAsset.Msgsize() + 5 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AssetFreezeTxnFields) MsgIsZero() bool { + return ((*z).FreezeAccount.MsgIsZero()) && ((*z).FreezeAsset.MsgIsZero()) && ((*z).AssetFrozen == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z *AssetTransferTxnFields) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(5) + var zb0001Mask uint8 /* 6 bits */ + if (*z).AssetAmount == 0 { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).AssetCloseTo.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).AssetReceiver.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).AssetSender.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).XferAsset.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "aamt" + o = append(o, 0xa4, 0x61, 0x61, 0x6d, 0x74) + o = msgp.AppendUint64(o, (*z).AssetAmount) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "aclose" + o = append(o, 0xa6, 0x61, 0x63, 0x6c, 0x6f, 0x73, 0x65) + o, err = (*z).AssetCloseTo.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetCloseTo") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "arcv" + o = append(o, 0xa4, 0x61, 0x72, 0x63, 0x76) + o, err = (*z).AssetReceiver.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetReceiver") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "asnd" + o = append(o, 0xa4, 0x61, 0x73, 0x6e, 0x64) + o, err = (*z).AssetSender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetSender") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "xaid" + o = append(o, 0xa4, 0x78, 0x61, 0x69, 0x64) + o, err = (*z).XferAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "XferAsset") + return + } + } + } + return +} + +func (_ *AssetTransferTxnFields) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetTransferTxnFields) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *AssetTransferTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).XferAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "XferAsset") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).AssetAmount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetAmount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AssetSender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetSender") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AssetReceiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetReceiver") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).AssetCloseTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetCloseTo") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = AssetTransferTxnFields{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "xaid": + bts, err = (*z).XferAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "XferAsset") + return + } + case "aamt": + (*z).AssetAmount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetAmount") + return + } + case "asnd": + bts, err = (*z).AssetSender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetSender") + return + } + case "arcv": + bts, err = (*z).AssetReceiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetReceiver") + return + } + case "aclose": + bts, err = (*z).AssetCloseTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetCloseTo") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *AssetTransferTxnFields) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*AssetTransferTxnFields) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *AssetTransferTxnFields) Msgsize() (s int) { + s = 1 + 5 + (*z).XferAsset.Msgsize() + 5 + msgp.Uint64Size + 5 + (*z).AssetSender.Msgsize() + 5 + (*z).AssetReceiver.Msgsize() + 7 + (*z).AssetCloseTo.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *AssetTransferTxnFields) MsgIsZero() bool { + return ((*z).XferAsset.MsgIsZero()) && ((*z).AssetAmount == 0) && ((*z).AssetSender.MsgIsZero()) && ((*z).AssetReceiver.MsgIsZero()) && ((*z).AssetCloseTo.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Header) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(9) + var zb0002Mask uint16 /* 10 bits */ + if (*z).Fee.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x2 + } + if (*z).FirstValid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).GenesisID == "" { + zb0002Len-- + zb0002Mask |= 0x8 + } + if (*z).GenesisHash.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x10 + } + if (*z).Group.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x20 + } + if (*z).LastValid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x40 + } + if (*z).Lease == ([32]byte{}) { + zb0002Len-- + zb0002Mask |= 0x80 + } + if len((*z).Note) == 0 { + zb0002Len-- + zb0002Mask |= 0x100 + } + if (*z).Sender.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x200 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "fee" + o = append(o, 0xa3, 0x66, 0x65, 0x65) + o, err = (*z).Fee.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Fee") + return + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "fv" + o = append(o, 0xa2, 0x66, 0x76) + o, err = (*z).FirstValid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FirstValid") + return + } + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).GenesisID) + } + if (zb0002Mask & 0x10) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0002Mask & 0x20) == 0 { // if not empty + // string "grp" + o = append(o, 0xa3, 0x67, 0x72, 0x70) + o, err = (*z).Group.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Group") + return + } + } + if (zb0002Mask & 0x40) == 0 { // if not empty + // string "lv" + o = append(o, 0xa2, 0x6c, 0x76) + o, err = (*z).LastValid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "LastValid") + return + } + } + if (zb0002Mask & 0x80) == 0 { // if not empty + // string "lx" + o = append(o, 0xa2, 0x6c, 0x78) + o = msgp.AppendBytes(o, ((*z).Lease)[:]) + } + if (zb0002Mask & 0x100) == 0 { // if not empty + // string "note" + o = append(o, 0xa4, 0x6e, 0x6f, 0x74, 0x65) + o = msgp.AppendBytes(o, (*z).Note) + } + if (zb0002Mask & 0x200) == 0 { // if not empty + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + } + return +} + +func (_ *Header) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Header) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Header) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Fee.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Fee") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).FirstValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstValid") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).LastValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "LastValid") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Note, bts, err = msgp.ReadBytesBytes(bts, (*z).Note) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Note") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Group.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Group") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Lease)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Lease") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = Header{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "snd": + bts, err = (*z).Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "fee": + bts, err = (*z).Fee.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Fee") + return + } + case "fv": + bts, err = (*z).FirstValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FirstValid") + return + } + case "lv": + bts, err = (*z).LastValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "LastValid") + return + } + case "note": + (*z).Note, bts, err = msgp.ReadBytesBytes(bts, (*z).Note) + if err != nil { + err = msgp.WrapError(err, "Note") + return + } + case "gen": + (*z).GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "grp": + bts, err = (*z).Group.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Group") + return + } + case "lx": + bts, err = msgp.ReadExactBytes(bts, ((*z).Lease)[:]) + if err != nil { + err = msgp.WrapError(err, "Lease") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Header) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Header) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Header) Msgsize() (s int) { + s = 1 + 4 + (*z).Sender.Msgsize() + 4 + (*z).Fee.Msgsize() + 3 + (*z).FirstValid.Msgsize() + 3 + (*z).LastValid.Msgsize() + 5 + msgp.BytesPrefixSize + len((*z).Note) + 4 + msgp.StringPrefixSize + len((*z).GenesisID) + 3 + (*z).GenesisHash.Msgsize() + 4 + (*z).Group.Msgsize() + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Header) MsgIsZero() bool { + return ((*z).Sender.MsgIsZero()) && ((*z).Fee.MsgIsZero()) && ((*z).FirstValid.MsgIsZero()) && ((*z).LastValid.MsgIsZero()) && (len((*z).Note) == 0) && ((*z).GenesisID == "") && ((*z).GenesisHash.MsgIsZero()) && ((*z).Group.MsgIsZero()) && ((*z).Lease == ([32]byte{})) +} + +// MarshalMsg implements msgp.Marshaler +func (z *KeyregTxnFields) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(6) + var zb0001Mask uint8 /* 7 bits */ + if (*z).Nonparticipation == false { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).SelectionPK.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).VoteFirst.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).VoteKeyDilution == 0 { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).VotePK.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).VoteLast.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "nonpart" + o = append(o, 0xa7, 0x6e, 0x6f, 0x6e, 0x70, 0x61, 0x72, 0x74) + o = msgp.AppendBool(o, (*z).Nonparticipation) + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "selkey" + o = append(o, 0xa6, 0x73, 0x65, 0x6c, 0x6b, 0x65, 0x79) + o, err = (*z).SelectionPK.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SelectionPK") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "votefst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x66, 0x73, 0x74) + o, err = (*z).VoteFirst.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteFirst") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "votekd" + o = append(o, 0xa6, 0x76, 0x6f, 0x74, 0x65, 0x6b, 0x64) + o = msgp.AppendUint64(o, (*z).VoteKeyDilution) + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "votekey" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x6b, 0x65, 0x79) + o, err = (*z).VotePK.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VotePK") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "votelst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x6c, 0x73, 0x74) + o, err = (*z).VoteLast.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteLast") + return + } + } + } + return +} + +func (_ *KeyregTxnFields) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*KeyregTxnFields) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *KeyregTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).VotePK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VotePK") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SelectionPK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SelectionPK") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).VoteFirst.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteFirst") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).VoteLast.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteLast") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteKeyDilution") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).Nonparticipation, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Nonparticipation") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = KeyregTxnFields{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "votekey": + bts, err = (*z).VotePK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VotePK") + return + } + case "selkey": + bts, err = (*z).SelectionPK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SelectionPK") + return + } + case "votefst": + bts, err = (*z).VoteFirst.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteFirst") + return + } + case "votelst": + bts, err = (*z).VoteLast.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteLast") + return + } + case "votekd": + (*z).VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteKeyDilution") + return + } + case "nonpart": + (*z).Nonparticipation, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Nonparticipation") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *KeyregTxnFields) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*KeyregTxnFields) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *KeyregTxnFields) Msgsize() (s int) { + s = 1 + 8 + (*z).VotePK.Msgsize() + 7 + (*z).SelectionPK.Msgsize() + 8 + (*z).VoteFirst.Msgsize() + 8 + (*z).VoteLast.Msgsize() + 7 + msgp.Uint64Size + 8 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *KeyregTxnFields) MsgIsZero() bool { + return ((*z).VotePK.MsgIsZero()) && ((*z).SelectionPK.MsgIsZero()) && ((*z).VoteFirst.MsgIsZero()) && ((*z).VoteLast.MsgIsZero()) && ((*z).VoteKeyDilution == 0) && ((*z).Nonparticipation == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z *LogicSig) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(4) + var zb0002Mask uint8 /* 5 bits */ + if len((*z).Args) == 0 { + zb0002Len-- + zb0002Mask |= 0x2 + } + if len((*z).Logic) == 0 { + zb0002Len-- + zb0002Mask |= 0x4 + } + if (*z).Msig.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x8 + } + if (*z).Sig.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x10 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "arg" + o = append(o, 0xa3, 0x61, 0x72, 0x67) + if (*z).Args == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).Args))) + } + for zb0001 := range (*z).Args { + o = msgp.AppendBytes(o, (*z).Args[zb0001]) + } + } + if (zb0002Mask & 0x4) == 0 { // if not empty + // string "l" + o = append(o, 0xa1, 0x6c) + o = msgp.AppendBytes(o, (*z).Logic) + } + if (zb0002Mask & 0x8) == 0 { // if not empty + // string "msig" + o = append(o, 0xa4, 0x6d, 0x73, 0x69, 0x67) + o, err = (*z).Msig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + } + if (zb0002Mask & 0x10) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + } + return +} + +func (_ *LogicSig) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*LogicSig) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *LogicSig) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + (*z).Logic, bts, err = msgp.ReadBytesBytes(bts, (*z).Logic) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Logic") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Msig") + return + } + } + if zb0002 > 0 { + zb0002-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Args") + return + } + if zb0004 > EvalMaxArgs { + err = msgp.ErrOverflow(uint64(zb0004), uint64(EvalMaxArgs)) + err = msgp.WrapError(err, "struct-from-array", "Args") + return + } + if zb0005 { + (*z).Args = nil + } else if (*z).Args != nil && cap((*z).Args) >= zb0004 { + (*z).Args = ((*z).Args)[:zb0004] + } else { + (*z).Args = make([][]byte, zb0004) + } + for zb0001 := range (*z).Args { + (*z).Args[zb0001], bts, err = msgp.ReadBytesBytes(bts, (*z).Args[zb0001]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Args", zb0001) + return + } + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = LogicSig{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "l": + (*z).Logic, bts, err = msgp.ReadBytesBytes(bts, (*z).Logic) + if err != nil { + err = msgp.WrapError(err, "Logic") + return + } + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "msig": + bts, err = (*z).Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + case "arg": + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Args") + return + } + if zb0006 > EvalMaxArgs { + err = msgp.ErrOverflow(uint64(zb0006), uint64(EvalMaxArgs)) + err = msgp.WrapError(err, "Args") + return + } + if zb0007 { + (*z).Args = nil + } else if (*z).Args != nil && cap((*z).Args) >= zb0006 { + (*z).Args = ((*z).Args)[:zb0006] + } else { + (*z).Args = make([][]byte, zb0006) + } + for zb0001 := range (*z).Args { + (*z).Args[zb0001], bts, err = msgp.ReadBytesBytes(bts, (*z).Args[zb0001]) + if err != nil { + err = msgp.WrapError(err, "Args", zb0001) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *LogicSig) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*LogicSig) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *LogicSig) Msgsize() (s int) { + s = 1 + 2 + msgp.BytesPrefixSize + len((*z).Logic) + 4 + (*z).Sig.Msgsize() + 5 + (*z).Msig.Msgsize() + 4 + msgp.ArrayHeaderSize + for zb0001 := range (*z).Args { + s += msgp.BytesPrefixSize + len((*z).Args[zb0001]) + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *LogicSig) MsgIsZero() bool { + return (len((*z).Logic) == 0) && ((*z).Sig.MsgIsZero()) && ((*z).Msig.MsgIsZero()) && (len((*z).Args) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z MinFeeError) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ MinFeeError) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(MinFeeError) + if !ok { + _, ok = (z).(*MinFeeError) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *MinFeeError) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = MinFeeError(zb0001) + } + o = bts + return +} + +func (_ *MinFeeError) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*MinFeeError) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z MinFeeError) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z MinFeeError) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z *PaymentTxnFields) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(3) + var zb0001Mask uint8 /* 4 bits */ + if (*z).Amount.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).CloseRemainderTo.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Receiver.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "amt" + o = append(o, 0xa3, 0x61, 0x6d, 0x74) + o, err = (*z).Amount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Amount") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "close" + o = append(o, 0xa5, 0x63, 0x6c, 0x6f, 0x73, 0x65) + o, err = (*z).CloseRemainderTo.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CloseRemainderTo") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "rcv" + o = append(o, 0xa3, 0x72, 0x63, 0x76) + o, err = (*z).Receiver.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Receiver") + return + } + } + } + return +} + +func (_ *PaymentTxnFields) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*PaymentTxnFields) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *PaymentTxnFields) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Receiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Receiver") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Amount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Amount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).CloseRemainderTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CloseRemainderTo") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = PaymentTxnFields{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "rcv": + bts, err = (*z).Receiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Receiver") + return + } + case "amt": + bts, err = (*z).Amount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Amount") + return + } + case "close": + bts, err = (*z).CloseRemainderTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CloseRemainderTo") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *PaymentTxnFields) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*PaymentTxnFields) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *PaymentTxnFields) Msgsize() (s int) { + s = 1 + 4 + (*z).Receiver.Msgsize() + 4 + (*z).Amount.Msgsize() + 6 + (*z).CloseRemainderTo.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *PaymentTxnFields) MsgIsZero() bool { + return ((*z).Receiver.MsgIsZero()) && ((*z).Amount.MsgIsZero()) && ((*z).CloseRemainderTo.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z Payset) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + if z == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len(z))) + } + for za0001 := range z { + o, err = z[za0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, za0001) + return + } + } + return +} + +func (_ Payset) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Payset) + if !ok { + _, ok = (z).(*Payset) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Payset) UnmarshalMsg(bts []byte) (o []byte, err error) { + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 100000 { + err = msgp.ErrOverflow(uint64(zb0002), uint64(100000)) + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = nil + } else if (*z) != nil && cap((*z)) >= zb0002 { + (*z) = (*z)[:zb0002] + } else { + (*z) = make(Payset, zb0002) + } + for zb0001 := range *z { + bts, err = (*z)[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, zb0001) + return + } + } + o = bts + return +} + +func (_ *Payset) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Payset) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Payset) Msgsize() (s int) { + s = msgp.ArrayHeaderSize + for za0001 := range z { + s += z[za0001].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z Payset) MsgIsZero() bool { + return len(z) == 0 +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedTxn) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(4) + var zb0001Mask uint8 /* 5 bits */ + if (*z).Lsig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2 + } + if (*z).Msig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x4 + } + if (*z).Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).Txn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x2) == 0 { // if not empty + // string "lsig" + o = append(o, 0xa4, 0x6c, 0x73, 0x69, 0x67) + o, err = (*z).Lsig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + } + if (zb0001Mask & 0x4) == 0 { // if not empty + // string "msig" + o = append(o, 0xa4, 0x6d, 0x73, 0x69, 0x67) + o, err = (*z).Msig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + } + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).Txn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + } + } + return +} + +func (_ *SignedTxn) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxn) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedTxn) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Msig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Lsig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Txn") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedTxn{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "sig": + bts, err = (*z).Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "msig": + bts, err = (*z).Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + case "lsig": + bts, err = (*z).Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + case "txn": + bts, err = (*z).Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedTxn) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxn) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedTxn) Msgsize() (s int) { + s = 1 + 4 + (*z).Sig.Msgsize() + 5 + (*z).Msig.Msgsize() + 5 + (*z).Lsig.Msgsize() + 4 + (*z).Txn.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedTxn) MsgIsZero() bool { + return ((*z).Sig.MsgIsZero()) && ((*z).Msig.MsgIsZero()) && ((*z).Lsig.MsgIsZero()) && ((*z).Txn.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedTxnInBlock) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(10) + var zb0001Mask uint16 /* 14 bits */ + if (*z).SignedTxnWithAD.ApplyData.ClosingAmount.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).HasGenesisHash == false { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).HasGenesisID == false { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).SignedTxnWithAD.SignedTxn.Lsig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).SignedTxnWithAD.SignedTxn.Msig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).SignedTxnWithAD.ApplyData.CloseRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + if (*z).SignedTxnWithAD.ApplyData.SenderRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x800 + } + if (*z).SignedTxnWithAD.SignedTxn.Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x1000 + } + if (*z).SignedTxnWithAD.SignedTxn.Txn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x2000 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "ca" + o = append(o, 0xa2, 0x63, 0x61) + o, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "hgh" + o = append(o, 0xa3, 0x68, 0x67, 0x68) + o = msgp.AppendBool(o, (*z).HasGenesisHash) + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "hgi" + o = append(o, 0xa3, 0x68, 0x67, 0x69) + o = msgp.AppendBool(o, (*z).HasGenesisID) + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "lsig" + o = append(o, 0xa4, 0x6c, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "msig" + o = append(o, 0xa4, 0x6d, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxnWithAD.SignedTxn.Msig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "rc" + o = append(o, 0xa2, 0x72, 0x63) + o, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "rr" + o = append(o, 0xa2, 0x72, 0x72) + o, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + } + if (zb0001Mask & 0x800) == 0 { // if not empty + // string "rs" + o = append(o, 0xa2, 0x72, 0x73) + o, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + } + if (zb0001Mask & 0x1000) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxnWithAD.SignedTxn.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + if (zb0001Mask & 0x2000) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).SignedTxnWithAD.SignedTxn.Txn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + } + } + return +} + +func (_ *SignedTxnInBlock) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxnInBlock) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedTxnInBlock) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Msig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Lsig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Txn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SenderRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CloseRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).HasGenesisID, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "HasGenesisID") + return + } + } + if zb0001 > 0 { + zb0001-- + (*z).HasGenesisHash, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "HasGenesisHash") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedTxnInBlock{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "sig": + bts, err = (*z).SignedTxnWithAD.SignedTxn.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "msig": + bts, err = (*z).SignedTxnWithAD.SignedTxn.Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + case "lsig": + bts, err = (*z).SignedTxnWithAD.SignedTxn.Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + case "txn": + bts, err = (*z).SignedTxnWithAD.SignedTxn.Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + case "ca": + bts, err = (*z).SignedTxnWithAD.ApplyData.ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + case "rs": + bts, err = (*z).SignedTxnWithAD.ApplyData.SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + case "rr": + bts, err = (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + case "rc": + bts, err = (*z).SignedTxnWithAD.ApplyData.CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + case "hgi": + (*z).HasGenesisID, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "HasGenesisID") + return + } + case "hgh": + (*z).HasGenesisHash, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "HasGenesisHash") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedTxnInBlock) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxnInBlock) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedTxnInBlock) Msgsize() (s int) { + s = 1 + 4 + (*z).SignedTxnWithAD.SignedTxn.Sig.Msgsize() + 5 + (*z).SignedTxnWithAD.SignedTxn.Msig.Msgsize() + 5 + (*z).SignedTxnWithAD.SignedTxn.Lsig.Msgsize() + 4 + (*z).SignedTxnWithAD.SignedTxn.Txn.Msgsize() + 3 + (*z).SignedTxnWithAD.ApplyData.ClosingAmount.Msgsize() + 3 + (*z).SignedTxnWithAD.ApplyData.SenderRewards.Msgsize() + 3 + (*z).SignedTxnWithAD.ApplyData.ReceiverRewards.Msgsize() + 3 + (*z).SignedTxnWithAD.ApplyData.CloseRewards.Msgsize() + 4 + msgp.BoolSize + 4 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedTxnInBlock) MsgIsZero() bool { + return ((*z).SignedTxnWithAD.SignedTxn.Sig.MsgIsZero()) && ((*z).SignedTxnWithAD.SignedTxn.Msig.MsgIsZero()) && ((*z).SignedTxnWithAD.SignedTxn.Lsig.MsgIsZero()) && ((*z).SignedTxnWithAD.SignedTxn.Txn.MsgIsZero()) && ((*z).SignedTxnWithAD.ApplyData.ClosingAmount.MsgIsZero()) && ((*z).SignedTxnWithAD.ApplyData.SenderRewards.MsgIsZero()) && ((*z).SignedTxnWithAD.ApplyData.ReceiverRewards.MsgIsZero()) && ((*z).SignedTxnWithAD.ApplyData.CloseRewards.MsgIsZero()) && ((*z).HasGenesisID == false) && ((*z).HasGenesisHash == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z *SignedTxnWithAD) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0001Len := uint32(8) + var zb0001Mask uint16 /* 11 bits */ + if (*z).ApplyData.ClosingAmount.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x8 + } + if (*z).SignedTxn.Lsig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x10 + } + if (*z).SignedTxn.Msig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x20 + } + if (*z).ApplyData.CloseRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x40 + } + if (*z).ApplyData.ReceiverRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x80 + } + if (*z).ApplyData.SenderRewards.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x100 + } + if (*z).SignedTxn.Sig.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x200 + } + if (*z).SignedTxn.Txn.MsgIsZero() { + zb0001Len-- + zb0001Mask |= 0x400 + } + // variable map header, size zb0001Len + o = append(o, 0x80|uint8(zb0001Len)) + if zb0001Len != 0 { + if (zb0001Mask & 0x8) == 0 { // if not empty + // string "ca" + o = append(o, 0xa2, 0x63, 0x61) + o, err = (*z).ApplyData.ClosingAmount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + } + if (zb0001Mask & 0x10) == 0 { // if not empty + // string "lsig" + o = append(o, 0xa4, 0x6c, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxn.Lsig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + } + if (zb0001Mask & 0x20) == 0 { // if not empty + // string "msig" + o = append(o, 0xa4, 0x6d, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxn.Msig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + } + if (zb0001Mask & 0x40) == 0 { // if not empty + // string "rc" + o = append(o, 0xa2, 0x72, 0x63) + o, err = (*z).ApplyData.CloseRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + } + if (zb0001Mask & 0x80) == 0 { // if not empty + // string "rr" + o = append(o, 0xa2, 0x72, 0x72) + o, err = (*z).ApplyData.ReceiverRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + } + if (zb0001Mask & 0x100) == 0 { // if not empty + // string "rs" + o = append(o, 0xa2, 0x72, 0x73) + o, err = (*z).ApplyData.SenderRewards.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + } + if (zb0001Mask & 0x200) == 0 { // if not empty + // string "sig" + o = append(o, 0xa3, 0x73, 0x69, 0x67) + o, err = (*z).SignedTxn.Sig.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + } + if (zb0001Mask & 0x400) == 0 { // if not empty + // string "txn" + o = append(o, 0xa3, 0x74, 0x78, 0x6e) + o, err = (*z).SignedTxn.Txn.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + } + } + return +} + +func (_ *SignedTxnWithAD) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxnWithAD) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *SignedTxnWithAD) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0001 int + var zb0002 bool + zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxn.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxn.Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Msig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxn.Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Lsig") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).SignedTxn.Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Txn") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ClosingAmount") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SenderRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ReceiverRewards") + return + } + } + if zb0001 > 0 { + zb0001-- + bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CloseRewards") + return + } + } + if zb0001 > 0 { + err = msgp.ErrTooManyArrayFields(zb0001) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 { + (*z) = SignedTxnWithAD{} + } + for zb0001 > 0 { + zb0001-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "sig": + bts, err = (*z).SignedTxn.Sig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "msig": + bts, err = (*z).SignedTxn.Msig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Msig") + return + } + case "lsig": + bts, err = (*z).SignedTxn.Lsig.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Lsig") + return + } + case "txn": + bts, err = (*z).SignedTxn.Txn.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Txn") + return + } + case "ca": + bts, err = (*z).ApplyData.ClosingAmount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ClosingAmount") + return + } + case "rs": + bts, err = (*z).ApplyData.SenderRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SenderRewards") + return + } + case "rr": + bts, err = (*z).ApplyData.ReceiverRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ReceiverRewards") + return + } + case "rc": + bts, err = (*z).ApplyData.CloseRewards.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CloseRewards") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *SignedTxnWithAD) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*SignedTxnWithAD) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *SignedTxnWithAD) Msgsize() (s int) { + s = 1 + 4 + (*z).SignedTxn.Sig.Msgsize() + 5 + (*z).SignedTxn.Msig.Msgsize() + 5 + (*z).SignedTxn.Lsig.Msgsize() + 4 + (*z).SignedTxn.Txn.Msgsize() + 3 + (*z).ApplyData.ClosingAmount.Msgsize() + 3 + (*z).ApplyData.SenderRewards.Msgsize() + 3 + (*z).ApplyData.ReceiverRewards.Msgsize() + 3 + (*z).ApplyData.CloseRewards.Msgsize() + return +} + +// MsgIsZero returns whether this is a zero value +func (z *SignedTxnWithAD) MsgIsZero() bool { + return ((*z).SignedTxn.Sig.MsgIsZero()) && ((*z).SignedTxn.Msig.MsgIsZero()) && ((*z).SignedTxn.Lsig.MsgIsZero()) && ((*z).SignedTxn.Txn.MsgIsZero()) && ((*z).ApplyData.ClosingAmount.MsgIsZero()) && ((*z).ApplyData.SenderRewards.MsgIsZero()) && ((*z).ApplyData.ReceiverRewards.MsgIsZero()) && ((*z).ApplyData.CloseRewards.MsgIsZero()) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Transaction) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(29) + var zb0002Mask uint64 /* 36 bits */ + if (*z).AssetTransferTxnFields.AssetAmount == 0 { + zb0002Len-- + zb0002Mask |= 0x80 + } + if (*z).AssetTransferTxnFields.AssetCloseTo.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x100 + } + if (*z).AssetFreezeTxnFields.AssetFrozen == false { + zb0002Len-- + zb0002Mask |= 0x200 + } + if (*z).PaymentTxnFields.Amount.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x400 + } + if (*z).AssetConfigTxnFields.AssetParams.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x800 + } + if (*z).AssetTransferTxnFields.AssetReceiver.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x1000 + } + if (*z).AssetTransferTxnFields.AssetSender.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x2000 + } + if (*z).AssetConfigTxnFields.ConfigAsset.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x4000 + } + if (*z).PaymentTxnFields.CloseRemainderTo.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x8000 + } + if (*z).AssetFreezeTxnFields.FreezeAccount.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x10000 + } + if (*z).AssetFreezeTxnFields.FreezeAsset.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x20000 + } + if (*z).Header.Fee.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x40000 + } + if (*z).Header.FirstValid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x80000 + } + if (*z).Header.GenesisID == "" { + zb0002Len-- + zb0002Mask |= 0x100000 + } + if (*z).Header.GenesisHash.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x200000 + } + if (*z).Header.Group.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x400000 + } + if (*z).Header.LastValid.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x800000 + } + if (*z).Header.Lease == ([32]byte{}) { + zb0002Len-- + zb0002Mask |= 0x1000000 + } + if (*z).KeyregTxnFields.Nonparticipation == false { + zb0002Len-- + zb0002Mask |= 0x2000000 + } + if len((*z).Header.Note) == 0 { + zb0002Len-- + zb0002Mask |= 0x4000000 + } + if (*z).PaymentTxnFields.Receiver.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x8000000 + } + if (*z).KeyregTxnFields.SelectionPK.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x10000000 + } + if (*z).Header.Sender.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x20000000 + } + if (*z).Type.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x40000000 + } + if (*z).KeyregTxnFields.VoteFirst.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x80000000 + } + if (*z).KeyregTxnFields.VoteKeyDilution == 0 { + zb0002Len-- + zb0002Mask |= 0x100000000 + } + if (*z).KeyregTxnFields.VotePK.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x200000000 + } + if (*z).KeyregTxnFields.VoteLast.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x400000000 + } + if (*z).AssetTransferTxnFields.XferAsset.MsgIsZero() { + zb0002Len-- + zb0002Mask |= 0x800000000 + } + // variable map header, size zb0002Len + o = msgp.AppendMapHeader(o, zb0002Len) + if zb0002Len != 0 { + if (zb0002Mask & 0x80) == 0 { // if not empty + // string "aamt" + o = append(o, 0xa4, 0x61, 0x61, 0x6d, 0x74) + o = msgp.AppendUint64(o, (*z).AssetTransferTxnFields.AssetAmount) + } + if (zb0002Mask & 0x100) == 0 { // if not empty + // string "aclose" + o = append(o, 0xa6, 0x61, 0x63, 0x6c, 0x6f, 0x73, 0x65) + o, err = (*z).AssetTransferTxnFields.AssetCloseTo.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetCloseTo") + return + } + } + if (zb0002Mask & 0x200) == 0 { // if not empty + // string "afrz" + o = append(o, 0xa4, 0x61, 0x66, 0x72, 0x7a) + o = msgp.AppendBool(o, (*z).AssetFreezeTxnFields.AssetFrozen) + } + if (zb0002Mask & 0x400) == 0 { // if not empty + // string "amt" + o = append(o, 0xa3, 0x61, 0x6d, 0x74) + o, err = (*z).PaymentTxnFields.Amount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Amount") + return + } + } + if (zb0002Mask & 0x800) == 0 { // if not empty + // string "apar" + o = append(o, 0xa4, 0x61, 0x70, 0x61, 0x72) + o, err = (*z).AssetConfigTxnFields.AssetParams.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + } + if (zb0002Mask & 0x1000) == 0 { // if not empty + // string "arcv" + o = append(o, 0xa4, 0x61, 0x72, 0x63, 0x76) + o, err = (*z).AssetTransferTxnFields.AssetReceiver.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetReceiver") + return + } + } + if (zb0002Mask & 0x2000) == 0 { // if not empty + // string "asnd" + o = append(o, 0xa4, 0x61, 0x73, 0x6e, 0x64) + o, err = (*z).AssetTransferTxnFields.AssetSender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "AssetSender") + return + } + } + if (zb0002Mask & 0x4000) == 0 { // if not empty + // string "caid" + o = append(o, 0xa4, 0x63, 0x61, 0x69, 0x64) + o, err = (*z).AssetConfigTxnFields.ConfigAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "ConfigAsset") + return + } + } + if (zb0002Mask & 0x8000) == 0 { // if not empty + // string "close" + o = append(o, 0xa5, 0x63, 0x6c, 0x6f, 0x73, 0x65) + o, err = (*z).PaymentTxnFields.CloseRemainderTo.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "CloseRemainderTo") + return + } + } + if (zb0002Mask & 0x10000) == 0 { // if not empty + // string "fadd" + o = append(o, 0xa4, 0x66, 0x61, 0x64, 0x64) + o, err = (*z).AssetFreezeTxnFields.FreezeAccount.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FreezeAccount") + return + } + } + if (zb0002Mask & 0x20000) == 0 { // if not empty + // string "faid" + o = append(o, 0xa4, 0x66, 0x61, 0x69, 0x64) + o, err = (*z).AssetFreezeTxnFields.FreezeAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FreezeAsset") + return + } + } + if (zb0002Mask & 0x40000) == 0 { // if not empty + // string "fee" + o = append(o, 0xa3, 0x66, 0x65, 0x65) + o, err = (*z).Header.Fee.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Fee") + return + } + } + if (zb0002Mask & 0x80000) == 0 { // if not empty + // string "fv" + o = append(o, 0xa2, 0x66, 0x76) + o, err = (*z).Header.FirstValid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "FirstValid") + return + } + } + if (zb0002Mask & 0x100000) == 0 { // if not empty + // string "gen" + o = append(o, 0xa3, 0x67, 0x65, 0x6e) + o = msgp.AppendString(o, (*z).Header.GenesisID) + } + if (zb0002Mask & 0x200000) == 0 { // if not empty + // string "gh" + o = append(o, 0xa2, 0x67, 0x68) + o, err = (*z).Header.GenesisHash.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + } + if (zb0002Mask & 0x400000) == 0 { // if not empty + // string "grp" + o = append(o, 0xa3, 0x67, 0x72, 0x70) + o, err = (*z).Header.Group.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Group") + return + } + } + if (zb0002Mask & 0x800000) == 0 { // if not empty + // string "lv" + o = append(o, 0xa2, 0x6c, 0x76) + o, err = (*z).Header.LastValid.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "LastValid") + return + } + } + if (zb0002Mask & 0x1000000) == 0 { // if not empty + // string "lx" + o = append(o, 0xa2, 0x6c, 0x78) + o = msgp.AppendBytes(o, ((*z).Header.Lease)[:]) + } + if (zb0002Mask & 0x2000000) == 0 { // if not empty + // string "nonpart" + o = append(o, 0xa7, 0x6e, 0x6f, 0x6e, 0x70, 0x61, 0x72, 0x74) + o = msgp.AppendBool(o, (*z).KeyregTxnFields.Nonparticipation) + } + if (zb0002Mask & 0x4000000) == 0 { // if not empty + // string "note" + o = append(o, 0xa4, 0x6e, 0x6f, 0x74, 0x65) + o = msgp.AppendBytes(o, (*z).Header.Note) + } + if (zb0002Mask & 0x8000000) == 0 { // if not empty + // string "rcv" + o = append(o, 0xa3, 0x72, 0x63, 0x76) + o, err = (*z).PaymentTxnFields.Receiver.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Receiver") + return + } + } + if (zb0002Mask & 0x10000000) == 0 { // if not empty + // string "selkey" + o = append(o, 0xa6, 0x73, 0x65, 0x6c, 0x6b, 0x65, 0x79) + o, err = (*z).KeyregTxnFields.SelectionPK.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "SelectionPK") + return + } + } + if (zb0002Mask & 0x20000000) == 0 { // if not empty + // string "snd" + o = append(o, 0xa3, 0x73, 0x6e, 0x64) + o, err = (*z).Header.Sender.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + } + if (zb0002Mask & 0x40000000) == 0 { // if not empty + // string "type" + o = append(o, 0xa4, 0x74, 0x79, 0x70, 0x65) + o, err = (*z).Type.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + } + if (zb0002Mask & 0x80000000) == 0 { // if not empty + // string "votefst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x66, 0x73, 0x74) + o, err = (*z).KeyregTxnFields.VoteFirst.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteFirst") + return + } + } + if (zb0002Mask & 0x100000000) == 0 { // if not empty + // string "votekd" + o = append(o, 0xa6, 0x76, 0x6f, 0x74, 0x65, 0x6b, 0x64) + o = msgp.AppendUint64(o, (*z).KeyregTxnFields.VoteKeyDilution) + } + if (zb0002Mask & 0x200000000) == 0 { // if not empty + // string "votekey" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x6b, 0x65, 0x79) + o, err = (*z).KeyregTxnFields.VotePK.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VotePK") + return + } + } + if (zb0002Mask & 0x400000000) == 0 { // if not empty + // string "votelst" + o = append(o, 0xa7, 0x76, 0x6f, 0x74, 0x65, 0x6c, 0x73, 0x74) + o, err = (*z).KeyregTxnFields.VoteLast.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "VoteLast") + return + } + } + if (zb0002Mask & 0x800000000) == 0 { // if not empty + // string "xaid" + o = append(o, 0xa4, 0x78, 0x61, 0x69, 0x64) + o, err = (*z).AssetTransferTxnFields.XferAsset.MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "XferAsset") + return + } + } + } + return +} + +func (_ *Transaction) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Transaction) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Type.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Type") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sender") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.Fee.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Fee") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.FirstValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FirstValid") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.LastValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "LastValid") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Header.Note, bts, err = msgp.ReadBytesBytes(bts, (*z).Header.Note) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Note") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).Header.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisID") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "GenesisHash") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).Header.Group.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Group") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Header.Lease)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Lease") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VotePK") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "SelectionPK") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteFirst") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteLast") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).KeyregTxnFields.VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "VoteKeyDilution") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).KeyregTxnFields.Nonparticipation, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Nonparticipation") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Receiver") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Amount") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "CloseRemainderTo") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "ConfigAsset") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetParams") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "XferAsset") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).AssetTransferTxnFields.AssetAmount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetAmount") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetSender") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetReceiver") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetCloseTo") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FreezeAccount") + return + } + } + if zb0002 > 0 { + zb0002-- + bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "FreezeAsset") + return + } + } + if zb0002 > 0 { + zb0002-- + (*z).AssetFreezeTxnFields.AssetFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "AssetFrozen") + return + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = Transaction{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "type": + bts, err = (*z).Type.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Type") + return + } + case "snd": + bts, err = (*z).Header.Sender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Sender") + return + } + case "fee": + bts, err = (*z).Header.Fee.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Fee") + return + } + case "fv": + bts, err = (*z).Header.FirstValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FirstValid") + return + } + case "lv": + bts, err = (*z).Header.LastValid.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "LastValid") + return + } + case "note": + (*z).Header.Note, bts, err = msgp.ReadBytesBytes(bts, (*z).Header.Note) + if err != nil { + err = msgp.WrapError(err, "Note") + return + } + case "gen": + (*z).Header.GenesisID, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisID") + return + } + case "gh": + bts, err = (*z).Header.GenesisHash.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "GenesisHash") + return + } + case "grp": + bts, err = (*z).Header.Group.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Group") + return + } + case "lx": + bts, err = msgp.ReadExactBytes(bts, ((*z).Header.Lease)[:]) + if err != nil { + err = msgp.WrapError(err, "Lease") + return + } + case "votekey": + bts, err = (*z).KeyregTxnFields.VotePK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VotePK") + return + } + case "selkey": + bts, err = (*z).KeyregTxnFields.SelectionPK.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "SelectionPK") + return + } + case "votefst": + bts, err = (*z).KeyregTxnFields.VoteFirst.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteFirst") + return + } + case "votelst": + bts, err = (*z).KeyregTxnFields.VoteLast.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "VoteLast") + return + } + case "votekd": + (*z).KeyregTxnFields.VoteKeyDilution, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "VoteKeyDilution") + return + } + case "nonpart": + (*z).KeyregTxnFields.Nonparticipation, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "Nonparticipation") + return + } + case "rcv": + bts, err = (*z).PaymentTxnFields.Receiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Receiver") + return + } + case "amt": + bts, err = (*z).PaymentTxnFields.Amount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "Amount") + return + } + case "close": + bts, err = (*z).PaymentTxnFields.CloseRemainderTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "CloseRemainderTo") + return + } + case "caid": + bts, err = (*z).AssetConfigTxnFields.ConfigAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "ConfigAsset") + return + } + case "apar": + bts, err = (*z).AssetConfigTxnFields.AssetParams.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetParams") + return + } + case "xaid": + bts, err = (*z).AssetTransferTxnFields.XferAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "XferAsset") + return + } + case "aamt": + (*z).AssetTransferTxnFields.AssetAmount, bts, err = msgp.ReadUint64Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetAmount") + return + } + case "asnd": + bts, err = (*z).AssetTransferTxnFields.AssetSender.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetSender") + return + } + case "arcv": + bts, err = (*z).AssetTransferTxnFields.AssetReceiver.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetReceiver") + return + } + case "aclose": + bts, err = (*z).AssetTransferTxnFields.AssetCloseTo.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "AssetCloseTo") + return + } + case "fadd": + bts, err = (*z).AssetFreezeTxnFields.FreezeAccount.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FreezeAccount") + return + } + case "faid": + bts, err = (*z).AssetFreezeTxnFields.FreezeAsset.UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "FreezeAsset") + return + } + case "afrz": + (*z).AssetFreezeTxnFields.AssetFrozen, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "AssetFrozen") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *Transaction) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Transaction) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Transaction) Msgsize() (s int) { + s = 3 + 5 + (*z).Type.Msgsize() + 4 + (*z).Header.Sender.Msgsize() + 4 + (*z).Header.Fee.Msgsize() + 3 + (*z).Header.FirstValid.Msgsize() + 3 + (*z).Header.LastValid.Msgsize() + 5 + msgp.BytesPrefixSize + len((*z).Header.Note) + 4 + msgp.StringPrefixSize + len((*z).Header.GenesisID) + 3 + (*z).Header.GenesisHash.Msgsize() + 4 + (*z).Header.Group.Msgsize() + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 8 + (*z).KeyregTxnFields.VotePK.Msgsize() + 7 + (*z).KeyregTxnFields.SelectionPK.Msgsize() + 8 + (*z).KeyregTxnFields.VoteFirst.Msgsize() + 8 + (*z).KeyregTxnFields.VoteLast.Msgsize() + 7 + msgp.Uint64Size + 8 + msgp.BoolSize + 4 + (*z).PaymentTxnFields.Receiver.Msgsize() + 4 + (*z).PaymentTxnFields.Amount.Msgsize() + 6 + (*z).PaymentTxnFields.CloseRemainderTo.Msgsize() + 5 + (*z).AssetConfigTxnFields.ConfigAsset.Msgsize() + 5 + (*z).AssetConfigTxnFields.AssetParams.Msgsize() + 5 + (*z).AssetTransferTxnFields.XferAsset.Msgsize() + 5 + msgp.Uint64Size + 5 + (*z).AssetTransferTxnFields.AssetSender.Msgsize() + 5 + (*z).AssetTransferTxnFields.AssetReceiver.Msgsize() + 7 + (*z).AssetTransferTxnFields.AssetCloseTo.Msgsize() + 5 + (*z).AssetFreezeTxnFields.FreezeAccount.Msgsize() + 5 + (*z).AssetFreezeTxnFields.FreezeAsset.Msgsize() + 5 + msgp.BoolSize + return +} + +// MsgIsZero returns whether this is a zero value +func (z *Transaction) MsgIsZero() bool { + return ((*z).Type.MsgIsZero()) && ((*z).Header.Sender.MsgIsZero()) && ((*z).Header.Fee.MsgIsZero()) && ((*z).Header.FirstValid.MsgIsZero()) && ((*z).Header.LastValid.MsgIsZero()) && (len((*z).Header.Note) == 0) && ((*z).Header.GenesisID == "") && ((*z).Header.GenesisHash.MsgIsZero()) && ((*z).Header.Group.MsgIsZero()) && ((*z).Header.Lease == ([32]byte{})) && ((*z).KeyregTxnFields.VotePK.MsgIsZero()) && ((*z).KeyregTxnFields.SelectionPK.MsgIsZero()) && ((*z).KeyregTxnFields.VoteFirst.MsgIsZero()) && ((*z).KeyregTxnFields.VoteLast.MsgIsZero()) && ((*z).KeyregTxnFields.VoteKeyDilution == 0) && ((*z).KeyregTxnFields.Nonparticipation == false) && ((*z).PaymentTxnFields.Receiver.MsgIsZero()) && ((*z).PaymentTxnFields.Amount.MsgIsZero()) && ((*z).PaymentTxnFields.CloseRemainderTo.MsgIsZero()) && ((*z).AssetConfigTxnFields.ConfigAsset.MsgIsZero()) && ((*z).AssetConfigTxnFields.AssetParams.MsgIsZero()) && ((*z).AssetTransferTxnFields.XferAsset.MsgIsZero()) && ((*z).AssetTransferTxnFields.AssetAmount == 0) && ((*z).AssetTransferTxnFields.AssetSender.MsgIsZero()) && ((*z).AssetTransferTxnFields.AssetReceiver.MsgIsZero()) && ((*z).AssetTransferTxnFields.AssetCloseTo.MsgIsZero()) && ((*z).AssetFreezeTxnFields.FreezeAccount.MsgIsZero()) && ((*z).AssetFreezeTxnFields.FreezeAsset.MsgIsZero()) && ((*z).AssetFreezeTxnFields.AssetFrozen == false) +} + +// MarshalMsg implements msgp.Marshaler +func (z *TxGroup) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0002Len := uint32(1) + var zb0002Mask uint8 /* 2 bits */ + if len((*z).TxGroupHashes) == 0 { + zb0002Len-- + zb0002Mask |= 0x2 + } + // variable map header, size zb0002Len + o = append(o, 0x80|uint8(zb0002Len)) + if zb0002Len != 0 { + if (zb0002Mask & 0x2) == 0 { // if not empty + // string "txlist" + o = append(o, 0xa6, 0x74, 0x78, 0x6c, 0x69, 0x73, 0x74) + if (*z).TxGroupHashes == nil { + o = msgp.AppendNil(o) + } else { + o = msgp.AppendArrayHeader(o, uint32(len((*z).TxGroupHashes))) + } + for zb0001 := range (*z).TxGroupHashes { + o, err = (*z).TxGroupHashes[zb0001].MarshalMsg(o) + if err != nil { + err = msgp.WrapError(err, "TxGroupHashes", zb0001) + return + } + } + } + } + return +} + +func (_ *TxGroup) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*TxGroup) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *TxGroup) UnmarshalMsg(bts []byte) (o []byte, err error) { + var field []byte + _ = field + var zb0002 int + var zb0003 bool + zb0002, zb0003, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0002 > 0 { + zb0002-- + var zb0004 int + var zb0005 bool + zb0004, zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxGroupHashes") + return + } + if zb0005 { + (*z).TxGroupHashes = nil + } else if (*z).TxGroupHashes != nil && cap((*z).TxGroupHashes) >= zb0004 { + (*z).TxGroupHashes = ((*z).TxGroupHashes)[:zb0004] + } else { + (*z).TxGroupHashes = make([]crypto.Digest, zb0004) + } + for zb0001 := range (*z).TxGroupHashes { + bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "TxGroupHashes", zb0001) + return + } + } + } + if zb0002 > 0 { + err = msgp.ErrTooManyArrayFields(zb0002) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0003 { + (*z) = TxGroup{} + } + for zb0002 > 0 { + zb0002-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "txlist": + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "TxGroupHashes") + return + } + if zb0007 { + (*z).TxGroupHashes = nil + } else if (*z).TxGroupHashes != nil && cap((*z).TxGroupHashes) >= zb0006 { + (*z).TxGroupHashes = ((*z).TxGroupHashes)[:zb0006] + } else { + (*z).TxGroupHashes = make([]crypto.Digest, zb0006) + } + for zb0001 := range (*z).TxGroupHashes { + bts, err = (*z).TxGroupHashes[zb0001].UnmarshalMsg(bts) + if err != nil { + err = msgp.WrapError(err, "TxGroupHashes", zb0001) + return + } + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (_ *TxGroup) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*TxGroup) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *TxGroup) Msgsize() (s int) { + s = 1 + 7 + msgp.ArrayHeaderSize + for zb0001 := range (*z).TxGroupHashes { + s += (*z).TxGroupHashes[zb0001].Msgsize() + } + return +} + +// MsgIsZero returns whether this is a zero value +func (z *TxGroup) MsgIsZero() bool { + return (len((*z).TxGroupHashes) == 0) +} + +// MarshalMsg implements msgp.Marshaler +func (z *Txid) MarshalMsg(b []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).MarshalMsg(b) +} +func (_ *Txid) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*Txid) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Txid) UnmarshalMsg(bts []byte) ([]byte, error) { + return ((*(crypto.Digest))(z)).UnmarshalMsg(bts) +} +func (_ *Txid) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Txid) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *Txid) Msgsize() int { + return ((*(crypto.Digest))(z)).Msgsize() +} + +// MsgIsZero returns whether this is a zero value +func (z *Txid) MsgIsZero() bool { + return ((*(crypto.Digest))(z)).MsgIsZero() +} diff --git a/data/transactions/msgp_gen_test.go b/data/transactions/msgp_gen_test.go new file mode 100644 index 0000000000..6def5d1e62 --- /dev/null +++ b/data/transactions/msgp_gen_test.go @@ -0,0 +1,878 @@ +package transactions + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "testing" + + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/msgp/msgp" +) + +func TestMarshalUnmarshalApplyData(t *testing.T) { + v := ApplyData{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingApplyData(t *testing.T) { + protocol.RunEncodingTest(t, &ApplyData{}) +} + +func BenchmarkMarshalMsgApplyData(b *testing.B) { + v := ApplyData{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgApplyData(b *testing.B) { + v := ApplyData{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalApplyData(b *testing.B) { + v := ApplyData{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalAssetConfigTxnFields(t *testing.T) { + v := AssetConfigTxnFields{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAssetConfigTxnFields(t *testing.T) { + protocol.RunEncodingTest(t, &AssetConfigTxnFields{}) +} + +func BenchmarkMarshalMsgAssetConfigTxnFields(b *testing.B) { + v := AssetConfigTxnFields{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAssetConfigTxnFields(b *testing.B) { + v := AssetConfigTxnFields{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAssetConfigTxnFields(b *testing.B) { + v := AssetConfigTxnFields{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalAssetFreezeTxnFields(t *testing.T) { + v := AssetFreezeTxnFields{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAssetFreezeTxnFields(t *testing.T) { + protocol.RunEncodingTest(t, &AssetFreezeTxnFields{}) +} + +func BenchmarkMarshalMsgAssetFreezeTxnFields(b *testing.B) { + v := AssetFreezeTxnFields{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAssetFreezeTxnFields(b *testing.B) { + v := AssetFreezeTxnFields{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAssetFreezeTxnFields(b *testing.B) { + v := AssetFreezeTxnFields{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalAssetTransferTxnFields(t *testing.T) { + v := AssetTransferTxnFields{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingAssetTransferTxnFields(t *testing.T) { + protocol.RunEncodingTest(t, &AssetTransferTxnFields{}) +} + +func BenchmarkMarshalMsgAssetTransferTxnFields(b *testing.B) { + v := AssetTransferTxnFields{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgAssetTransferTxnFields(b *testing.B) { + v := AssetTransferTxnFields{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalAssetTransferTxnFields(b *testing.B) { + v := AssetTransferTxnFields{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalHeader(t *testing.T) { + v := Header{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingHeader(t *testing.T) { + protocol.RunEncodingTest(t, &Header{}) +} + +func BenchmarkMarshalMsgHeader(b *testing.B) { + v := Header{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgHeader(b *testing.B) { + v := Header{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalHeader(b *testing.B) { + v := Header{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalKeyregTxnFields(t *testing.T) { + v := KeyregTxnFields{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingKeyregTxnFields(t *testing.T) { + protocol.RunEncodingTest(t, &KeyregTxnFields{}) +} + +func BenchmarkMarshalMsgKeyregTxnFields(b *testing.B) { + v := KeyregTxnFields{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgKeyregTxnFields(b *testing.B) { + v := KeyregTxnFields{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalKeyregTxnFields(b *testing.B) { + v := KeyregTxnFields{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalLogicSig(t *testing.T) { + v := LogicSig{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingLogicSig(t *testing.T) { + protocol.RunEncodingTest(t, &LogicSig{}) +} + +func BenchmarkMarshalMsgLogicSig(b *testing.B) { + v := LogicSig{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgLogicSig(b *testing.B) { + v := LogicSig{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalLogicSig(b *testing.B) { + v := LogicSig{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalPaymentTxnFields(t *testing.T) { + v := PaymentTxnFields{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingPaymentTxnFields(t *testing.T) { + protocol.RunEncodingTest(t, &PaymentTxnFields{}) +} + +func BenchmarkMarshalMsgPaymentTxnFields(b *testing.B) { + v := PaymentTxnFields{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgPaymentTxnFields(b *testing.B) { + v := PaymentTxnFields{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalPaymentTxnFields(b *testing.B) { + v := PaymentTxnFields{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalPayset(t *testing.T) { + v := Payset{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingPayset(t *testing.T) { + protocol.RunEncodingTest(t, &Payset{}) +} + +func BenchmarkMarshalMsgPayset(b *testing.B) { + v := Payset{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgPayset(b *testing.B) { + v := Payset{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalPayset(b *testing.B) { + v := Payset{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedTxn(t *testing.T) { + v := SignedTxn{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedTxn(t *testing.T) { + protocol.RunEncodingTest(t, &SignedTxn{}) +} + +func BenchmarkMarshalMsgSignedTxn(b *testing.B) { + v := SignedTxn{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedTxn(b *testing.B) { + v := SignedTxn{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedTxn(b *testing.B) { + v := SignedTxn{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedTxnInBlock(t *testing.T) { + v := SignedTxnInBlock{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedTxnInBlock(t *testing.T) { + protocol.RunEncodingTest(t, &SignedTxnInBlock{}) +} + +func BenchmarkMarshalMsgSignedTxnInBlock(b *testing.B) { + v := SignedTxnInBlock{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedTxnInBlock(b *testing.B) { + v := SignedTxnInBlock{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedTxnInBlock(b *testing.B) { + v := SignedTxnInBlock{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalSignedTxnWithAD(t *testing.T) { + v := SignedTxnWithAD{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingSignedTxnWithAD(t *testing.T) { + protocol.RunEncodingTest(t, &SignedTxnWithAD{}) +} + +func BenchmarkMarshalMsgSignedTxnWithAD(b *testing.B) { + v := SignedTxnWithAD{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgSignedTxnWithAD(b *testing.B) { + v := SignedTxnWithAD{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalSignedTxnWithAD(b *testing.B) { + v := SignedTxnWithAD{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalTransaction(t *testing.T) { + v := Transaction{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingTransaction(t *testing.T) { + protocol.RunEncodingTest(t, &Transaction{}) +} + +func BenchmarkMarshalMsgTransaction(b *testing.B) { + v := Transaction{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgTransaction(b *testing.B) { + v := Transaction{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalTransaction(b *testing.B) { + v := Transaction{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + +func TestMarshalUnmarshalTxGroup(t *testing.T) { + v := TxGroup{} + bts, err := v.MarshalMsg(nil) + if err != nil { + t.Fatal(err) + } + 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 TestRandomizedEncodingTxGroup(t *testing.T) { + protocol.RunEncodingTest(t, &TxGroup{}) +} + +func BenchmarkMarshalMsgTxGroup(b *testing.B) { + v := TxGroup{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgTxGroup(b *testing.B) { + v := TxGroup{} + bts := make([]byte, 0, v.Msgsize()) + bts, _ = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts, _ = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalTxGroup(b *testing.B) { + v := TxGroup{} + bts, _ := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} diff --git a/data/transactions/signedtxn.go b/data/transactions/signedtxn.go index c41ed37f81..85542c43a8 100644 --- a/data/transactions/signedtxn.go +++ b/data/transactions/signedtxn.go @@ -20,27 +20,13 @@ import ( "errors" "github.com/algorand/go-algorand/crypto" - "github.com/algorand/go-algorand/data/basics" - "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/protocol" ) // SignedTxn wraps a transaction and a signature. // It exposes a Verify() method that verifies the signature and checks that the // underlying transaction is well-formed. -// For performance, it also caches the Txid of the underlying transaction on creation. // TODO: update this documentation now that there's multisig -// -// Never instantiate a SignedTxn directly (other than inside the transactions -// package), and after creating a SignedTxn never modify its Txn field. -// Otherwise the cached Txid will be incorrect. Instead use txn.Sign to sign -// a normal transaction or use UnmarshalBinary / protocol.Decode to deserialize -// a SignedTxn from the network. These correctly cache the Txid and furthermore -// ensure the underlying Transaction is non-nil. -// -// Assuming these guidelines are followed, any SignedTxn object is guaranteed -// to have a non-nil Txn field, and calling signedtxn.ID() will return that -// transaction's correct Txid. type SignedTxn struct { _struct struct{} `codec:",omitempty,omitemptyarray"` @@ -48,10 +34,6 @@ type SignedTxn struct { Msig crypto.MultisigSig `codec:"msig"` Lsig LogicSig `codec:"lsig"` Txn Transaction `codec:"txn"` - - // The length of the encoded SignedTxn, used for computing the - // transaction's priority in the transaction pool. - cachedEncodingLen int } // SignedTxnInBlock is how a signed transaction is encoded in a block. @@ -72,41 +54,6 @@ type SignedTxnWithAD struct { ApplyData } -// TxnPriority represents the pool priority of a transaction. -type TxnPriority uint64 - -// maxTxnBytesForPriority is a scaling factor for computing fee-per-byte -// priority values with integer arithmetic without worrying too much about -// rounding effects. Specifically, this constant should be larger than -// any legitimate transaction that we expect to be stored in the transaction -// pool. Transactions of greater length will have a computed priority of 0. -const maxTxnBytesForPriority = 1 << 20 - -// LessThan compares two TxnPriority values -func (a TxnPriority) LessThan(b TxnPriority) bool { - return a < b -} - -// Mul multiplies a TxnPriority by a scalar, with saturation on overflow -func (a TxnPriority) Mul(b uint64) TxnPriority { - return TxnPriority(basics.MulSaturate(uint64(a), b)) -} - -// InitCaches initializes caches inside of SignedTxn. -func (s *SignedTxn) InitCaches() { - if s.cachedEncodingLen == 0 { - s.cachedEncodingLen = s.computeEncodingLen() - } - - s.Txn.InitCaches() -} - -// ResetCaches clears cached state in this SignedTxn. -func (s *SignedTxn) ResetCaches() { - s.cachedEncodingLen = 0 - s.Txn.ResetCaches() -} - // ID returns the Txid (i.e., hash) of the underlying transaction. func (s SignedTxn) ID() Txid { return s.Txn.ID() @@ -119,41 +66,9 @@ func (s SignedTxn) ID() Txid { func (s SignedTxnInBlock) ID() { } -func (s SignedTxn) computeEncodingLen() int { - return len(protocol.Encode(&s)) -} - // GetEncodedLength returns the length in bytes of the encoded transaction -func (s SignedTxn) GetEncodedLength() (encodingLen int) { - encodingLen = s.cachedEncodingLen - if encodingLen == 0 { - encodingLen = s.computeEncodingLen() - } - return -} - -// Priority returns the pool priority of this signed transaction. -func (s SignedTxn) Priority() TxnPriority { - return s.PtrPriority() -} - -// PtrPriority returns the pool priority of this signed transaction. -func (s *SignedTxn) PtrPriority() TxnPriority { - encodingLen := s.GetEncodedLength() - - // Sanity-checking guard against divide-by-zero, even though - // we should never get an empty encoding. - if encodingLen == 0 { - logging.Base().Panic("bug: SignedTxn.encodingLen is zero") - } - - // To deal with rounding errors in integer division when dividing - // by the encodingLen, we scale up the TxnPriority value by a - // multiplicative factor that's much larger than the max legitimate - // encodingLen. Here, we pick 2^20 (1 MByte). Transactions over - // that size will get a priority of 0, which is reasonable given - // that transactions should never be that large. - return TxnPriority(basics.MulSaturate(s.Txn.TxFee().Raw, uint64(maxTxnBytesForPriority/encodingLen))) +func (s SignedTxn) GetEncodedLength() int { + return len(protocol.Encode(&s)) } // AssembleSignedTxn assembles a multisig-signed transaction from a transaction an optional sig, and an optional multisig. @@ -167,6 +82,5 @@ func AssembleSignedTxn(txn Transaction, sig crypto.Signature, msig crypto.Multis Sig: sig, Msig: msig, } - s.InitCaches() return s, nil } diff --git a/data/transactions/signedtxn_test.go b/data/transactions/signedtxn_test.go index dbc7923295..30170ac5e8 100644 --- a/data/transactions/signedtxn_test.go +++ b/data/transactions/signedtxn_test.go @@ -39,8 +39,8 @@ func TestEncoding(t *testing.T) { ids[stxn2.ID()] = true require.Len(t, ids, 2, "Signed payment and signed key reg have the same Txid -- either domain separation or txid caching is broken") - paymentBytes := protocol.Encode(stxn1) - keyRegBytes := protocol.Encode(stxn2) + paymentBytes := protocol.Encode(&stxn1) + keyRegBytes := protocol.Encode(&stxn2) bytes := make(map[crypto.Digest]bool) bytes[crypto.Hash(paymentBytes)] = true @@ -68,9 +68,8 @@ func TestDecodeNil(t *testing.T) { var st SignedTxn err := protocol.Decode(nilEncoding, &st) if err == nil { - // These two functions used to panic when run on a zero value of SignedTxn. + // This function used to panic when run on a zero value of SignedTxn. st.ID() - st.Priority() } } diff --git a/data/transactions/transaction.go b/data/transactions/transaction.go index 14e1e3206a..e9e0f02dc9 100644 --- a/data/transactions/transaction.go +++ b/data/transactions/transaction.go @@ -111,14 +111,6 @@ type Transaction struct { AssetConfigTxnFields AssetTransferTxnFields AssetFreezeTxnFields - - // The transaction's Txid is computed when we decode, - // and cached here, to avoid needlessly recomputing it. - cachedTxid Txid - - // The valid flag indicates if this transaction was - // correctly decoded. - valid bool } // ApplyData contains information about the transaction's execution. @@ -143,43 +135,22 @@ type TxGroup struct { // together, sequentially, in a block in order for the group to be // valid. Each hash in the list is a hash of a transaction with // the `Group` field omitted. - TxGroupHashes []crypto.Digest `codec:"txlist"` + TxGroupHashes []crypto.Digest `codec:"txlist,allocbound=-"` } // ToBeHashed implements the crypto.Hashable interface. func (tg TxGroup) ToBeHashed() (protocol.HashID, []byte) { - return protocol.TxGroup, protocol.Encode(tg) + return protocol.TxGroup, protocol.Encode(&tg) } // ToBeHashed implements the crypto.Hashable interface. func (tx Transaction) ToBeHashed() (protocol.HashID, []byte) { - return protocol.Transaction, protocol.Encode(tx) -} - -func (tx *Transaction) computeID() Txid { - return Txid(crypto.HashObj(tx)) -} - -// InitCaches initializes caches inside of Transaction. -func (tx *Transaction) InitCaches() { - if !tx.valid { - tx.cachedTxid = tx.computeID() - tx.valid = true - } -} - -// ResetCaches clears caches inside of Transaction, if the Transaction was modified. -func (tx *Transaction) ResetCaches() { - tx.valid = false + return protocol.Transaction, protocol.Encode(&tx) } // ID returns the Txid (i.e., hash) of the transaction. -// For efficiency this is precomputed when the Transaction is created. func (tx Transaction) ID() Txid { - if tx.valid { - return tx.cachedTxid - } - return tx.computeID() + return Txid(crypto.HashObj(tx)) } // Sign signs a transaction using a given Account's secrets. @@ -190,7 +161,6 @@ func (tx Transaction) Sign(secrets *crypto.SignatureSecrets) SignedTxn { Txn: tx, Sig: sig, } - s.InitCaches() return s } diff --git a/data/transactions/verify/txn_test.go b/data/transactions/verify/txn_test.go index 121e733288..cac466aab6 100644 --- a/data/transactions/verify/txn_test.go +++ b/data/transactions/verify/txn_test.go @@ -111,7 +111,7 @@ func TestTxnValidationEncodeDecode(t *testing.T) { t.Errorf("signed transaction %#v did not verify", txn) } - x := protocol.Encode(txn) + x := protocol.Encode(&txn) var signedTx transactions.SignedTxn protocol.Decode(x, &signedTx) diff --git a/data/txHandler.go b/data/txHandler.go index b3fb24ae8f..b2d7c2287c 100644 --- a/data/txHandler.go +++ b/data/txHandler.go @@ -267,7 +267,6 @@ func (handler *TxHandler) processIncomingTxn(rawmsg network.IncomingMessage) net func (handler *TxHandler) checkAlreadyCommitted(tx *txBacklogMsg) (processingDone bool) { txids := make([]transactions.Txid, len(tx.unverifiedTxGroup)) for i := range tx.unverifiedTxGroup { - tx.unverifiedTxGroup[i].Txn.InitCaches() txids[i] = tx.unverifiedTxGroup[i].ID() } logging.Base().Debugf("got a tx group with IDs %v", txids) diff --git a/docker/releases/build_releases.sh b/docker/releases/build_releases.sh index c944dc1dda..c6d4171a71 100755 --- a/docker/releases/build_releases.sh +++ b/docker/releases/build_releases.sh @@ -4,27 +4,37 @@ # e.g. `docker login` # Login name is "algorand". -# To build both images, one could run: -# -# $ ./build_releases.sh -# $ ./build_releases.sh testnet -# -# or -# -# for name in {mainnet,testnet} -# do -# ./build_releases.sh $name -# done - GREEN_FG=$(tput setaf 2 2>/dev/null) RED_FG=$(tput setaf 1 2>/dev/null) END_FG_COLOR=$(tput sgr0 2>/dev/null) -# Default to "mainnet". -NAME=${1:-mainnet} -NETWORK= +# These are reasonable defaults. +NETWORK=mainnet +NAME=stable +DEPLOY=true + +while [ "$1" != "" ]; do + case "$1" in + --name) + shift + NAME="${1-stable}" + ;; + --network) + shift + NETWORK="$1" + ;; + --no-deploy) + DEPLOY=false + ;; + *) + echo "Unknown option" "$1" + exit 1 + ;; + esac + shift +done -if [[ ! "$NAME" =~ ^mainnet$|^testnet$ ]] +if [[ ! "$NETWORK" =~ ^mainnet$|^testnet$ ]] then echo "$RED_FG[$0]$END_FG_COLOR Network values must be either \`mainnet\` or \`testnet\`." exit 1 @@ -39,15 +49,10 @@ build_image () { IFS='' read -r -d '' DOCKERFILE < 1 { @@ -497,7 +496,7 @@ func (eval *BlockEvaluator) transactionGroup(txgroup []transactions.SignedTxnWit txibs = append(txibs, txib) if eval.validate { - groupTxBytes += len(protocol.Encode(txib)) + groupTxBytes += len(protocol.Encode(&txib)) if eval.blockTxBytes+groupTxBytes > eval.proto.MaxTxnBytesPerBlock { return ErrNoSpace } @@ -512,7 +511,6 @@ func (eval *BlockEvaluator) transactionGroup(txgroup []transactions.SignedTxnWit if !txad.SignedTxn.Txn.Group.IsZero() { txWithoutGroup := txad.SignedTxn.Txn txWithoutGroup.Group = crypto.Digest{} - txWithoutGroup.ResetCaches() group.TxGroupHashes = append(group.TxGroupHashes, crypto.HashObj(txWithoutGroup)) } else if len(txgroup) > 1 { diff --git a/libgoal/transactions.go b/libgoal/transactions.go index 65a838614b..63a0ed1fd9 100644 --- a/libgoal/transactions.go +++ b/libgoal/transactions.go @@ -183,8 +183,6 @@ func (c *Client) MakeUnsignedGoOnlineTx(address string, part *account.Participat var genHash crypto.Digest copy(genHash[:], params.GenesisHash) goOnlineTransaction.GenesisHash = genHash - // Recompute the TXID - goOnlineTransaction.ResetCaches() } // Default to the suggested fee, if the caller didn't supply it @@ -196,8 +194,6 @@ func (c *Client) MakeUnsignedGoOnlineTx(address string, part *account.Participat if goOnlineTransaction.Fee.Raw < cparams.MinTxnFee { goOnlineTransaction.Fee.Raw = cparams.MinTxnFee } - // Recompute the TXID - goOnlineTransaction.ResetCaches() } return goOnlineTransaction, nil } @@ -243,8 +239,6 @@ func (c *Client) MakeUnsignedGoOfflineTx(address string, firstValid, lastValid, var genHash crypto.Digest copy(genHash[:], params.GenesisHash) goOfflineTransaction.GenesisHash = genHash - // Recompute the TXID - goOfflineTransaction.ResetCaches() } // Default to the suggested fee, if the caller didn't supply it @@ -255,8 +249,6 @@ func (c *Client) MakeUnsignedGoOfflineTx(address string, firstValid, lastValid, if goOfflineTransaction.Fee.Raw < cparams.MinTxnFee { goOfflineTransaction.Fee.Raw = cparams.MinTxnFee } - // Recompute the TXID - goOfflineTransaction.ResetCaches() } return goOfflineTransaction, nil } @@ -301,8 +293,6 @@ func (c *Client) MakeUnsignedBecomeNonparticipatingTx(address string, firstValid var genHash crypto.Digest copy(genHash[:], params.GenesisHash) becomeNonparticipatingTransaction.GenesisHash = genHash - // Recompute the TXID - becomeNonparticipatingTransaction.ResetCaches() } becomeNonparticipatingTransaction.KeyregTxnFields.Nonparticipation = true @@ -314,8 +304,6 @@ func (c *Client) MakeUnsignedBecomeNonparticipatingTx(address string, firstValid if becomeNonparticipatingTransaction.Fee.Raw < cparams.MinTxnFee { becomeNonparticipatingTransaction.Fee.Raw = cparams.MinTxnFee } - // Recompute the TXID - becomeNonparticipatingTransaction.ResetCaches() } return becomeNonparticipatingTransaction, nil } @@ -367,9 +355,6 @@ func (c *Client) FillUnsignedTxTemplate(sender string, firstValid, lastValid, fe } } - // Recompute the TXID - tx.ResetCaches() - return tx, nil } diff --git a/protocol/codec.go b/protocol/codec.go index cc5f087e51..6407e07db3 100644 --- a/protocol/codec.go +++ b/protocol/codec.go @@ -17,10 +17,12 @@ package protocol import ( + "fmt" "io" "sync" "github.com/algorand/go-codec/codec" + "github.com/algorand/msgp/msgp" ) // CodecHandle is used to instantiate msgpack encoders and decoders @@ -80,8 +82,9 @@ var codecStreamPool = sync.Pool{ const initEncodeBufSize = 256 -// Encode returns a msgpack-encoded byte buffer for a given object -func Encode(obj interface{}) []byte { +// EncodeReflect returns a msgpack-encoded byte buffer for a given object, +// using reflection. +func EncodeReflect(obj interface{}) []byte { codecBytes := codecBytesPool.Get().(*codecBytes) codecBytes.buf = make([]byte, initEncodeBufSize) codecBytes.enc.ResetBytes(&codecBytes.buf) @@ -94,6 +97,26 @@ func Encode(obj interface{}) []byte { return res } +// EncodeMsgp returns a msgpack-encoded byte buffer, requiring +// that we pre-generated the code for doing so using msgp. +func EncodeMsgp(obj msgp.Marshaler) []byte { + res, err := obj.MarshalMsg(nil) + if err != nil { + panic(err) + } + + return res +} + +// Encode returns a msgpack-encoded byte buffer for a given object. +func Encode(obj interface{}) []byte { + msgp, ok := obj.(msgp.Marshaler) + if ok && msgp.CanMarshalMsg(msgp) { + return EncodeMsgp(msgp) + } + return EncodeReflect(obj) +} + // CountingWriter is an implementation of io.Writer that tracks the number // of bytes written (but discards the actual bytes). type CountingWriter struct { @@ -132,13 +155,49 @@ func EncodeJSON(obj interface{}) []byte { return b } -// Decode attempts to decode a msgpack-encoded byte buffer into an -// object instance pointed to by objptr -func Decode(b []byte, objptr interface{}) error { +// DecodeReflect attempts to decode a msgpack-encoded byte buffer +// into an object instance pointed to by objptr, using reflection. +func DecodeReflect(b []byte, objptr interface{}) error { dec := codec.NewDecoderBytes(b, CodecHandle) return dec.Decode(objptr) } +// DecodeMsgp attempts to decode a msgpack-encoded byte buffer into +// an object instance pointed to by objptr, requiring that we pre- +// generated the code for doing so using msgp. +func DecodeMsgp(b []byte, objptr msgp.Unmarshaler) (err error) { + defer func() { + if x := recover(); x != nil { + err = fmt.Errorf("DecodeMsgp: %v", x) + } + }() + + var rem []byte + rem, err = objptr.UnmarshalMsg(b) + if err != nil { + return err + } + + // go-codec compat: allow remaining bytes, because go-codec allows it too + if false { + if len(rem) != 0 { + return fmt.Errorf("decoding left %d remaining bytes", len(rem)) + } + } + + return nil +} + +// Decode attempts to decode a msgpack-encoded byte buffer +// into an object instance pointed to by objptr. +func Decode(b []byte, objptr interface{}) error { + msgp, ok := objptr.(msgp.Unmarshaler) + if ok && msgp.CanUnmarshalMsg(msgp) { + return DecodeMsgp(b, msgp) + } + return DecodeReflect(b, objptr) +} + // DecodeStream is like Decode but reads from an io.Reader instead. func DecodeStream(r io.Reader, objptr interface{}) error { dec := codec.NewDecoder(r, CodecHandle) diff --git a/protocol/codec_tester.go b/protocol/codec_tester.go new file mode 100644 index 0000000000..dd19b63c0d --- /dev/null +++ b/protocol/codec_tester.go @@ -0,0 +1,210 @@ +// Copyright (C) 2019-2020 Algorand, Inc. +// This file is part of go-algorand +// +// go-algorand is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// go-algorand is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with go-algorand. If not, see . + +package protocol + +import ( + "fmt" + "io/ioutil" + "math/rand" + "reflect" + "testing" + + "github.com/algorand/msgp/msgp" + "github.com/stretchr/testify/require" +) + +const debugCodecTester = false + +type msgpMarshalUnmarshal interface { + msgp.Marshaler + msgp.Unmarshaler +} + +func oneOf(n int) bool { + return (rand.Int() % n) == 0 +} + +// RandomizeObject returns a random object of the same type as template +func RandomizeObject(template interface{}) (interface{}, error) { + tt := reflect.TypeOf(template) + if tt.Kind() != reflect.Ptr { + return nil, fmt.Errorf("RandomizeObject: must be ptr") + } + + v := reflect.New(tt.Elem()) + err := randomizeValue(v.Elem()) + return v.Interface(), err +} + +func randomizeValue(v reflect.Value) error { + if oneOf(5) { + // Leave zero value + return nil + } + + switch v.Kind() { + case reflect.Uint, reflect.Uintptr, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + v.SetUint(rand.Uint64()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + v.SetInt(int64(rand.Uint64())) + case reflect.String: + var buf []byte + len := rand.Int() % 64 + for i := 0; i < len; i++ { + buf = append(buf, byte(rand.Uint32())) + } + v.SetString(string(buf)) + case reflect.Struct: + st := v.Type() + for i := 0; i < v.NumField(); i++ { + f := st.Field(i) + if f.PkgPath != "" && !f.Anonymous { + // unexported + continue + } + + err := randomizeValue(v.Field(i)) + if err != nil { + return err + } + } + case reflect.Array: + for i := 0; i < v.Len(); i++ { + err := randomizeValue(v.Index(i)) + if err != nil { + return err + } + } + case reflect.Slice: + l := rand.Int() % 32 + s := reflect.MakeSlice(v.Type(), l, l) + for i := 0; i < l; i++ { + err := randomizeValue(s.Index(i)) + if err != nil { + return err + } + } + v.Set(s) + case reflect.Bool: + v.SetBool(rand.Uint32()%2 == 0) + case reflect.Map: + mt := v.Type() + v.Set(reflect.MakeMap(mt)) + l := rand.Int() % 32 + for i := 0; i < l; i++ { + mk := reflect.New(mt.Key()) + err := randomizeValue(mk.Elem()) + if err != nil { + return err + } + + mv := reflect.New(mt.Elem()) + err = randomizeValue(mv.Elem()) + if err != nil { + return err + } + + v.SetMapIndex(mk.Elem(), mv.Elem()) + } + default: + return fmt.Errorf("unsupported object kind %v", v.Kind()) + } + return nil +} + +// EncodingTest tests that our two msgpack codecs (msgp and go-codec) +// agree on encodings and decodings of random values of the type of +// template, returning an error if there is a mismatch. +func EncodingTest(template msgpMarshalUnmarshal) error { + v0, err := RandomizeObject(template) + if err != nil { + return err + } + + if debugCodecTester { + ioutil.WriteFile("/tmp/v0", []byte(fmt.Sprintf("%#v", v0)), 0666) + } + + e1 := EncodeMsgp(v0.(msgp.Marshaler)) + e2 := EncodeReflect(v0) + + // for debug, write out the encodings to a file + if debugCodecTester { + ioutil.WriteFile("/tmp/e1", e1, 0666) + ioutil.WriteFile("/tmp/e2", e2, 0666) + } + + if !reflect.DeepEqual(e1, e2) { + return fmt.Errorf("encoding mismatch for %v: %v != %v", v0, e1, e2) + } + + v1 := reflect.New(reflect.TypeOf(template).Elem()).Interface().(msgpMarshalUnmarshal) + v2 := reflect.New(reflect.TypeOf(template).Elem()).Interface().(msgpMarshalUnmarshal) + + err = DecodeMsgp(e1, v1) + if err != nil { + return err + } + + err = DecodeReflect(e1, v2) + if err != nil { + return err + } + + if debugCodecTester { + ioutil.WriteFile("/tmp/v1", []byte(fmt.Sprintf("%#v", v1)), 0666) + ioutil.WriteFile("/tmp/v2", []byte(fmt.Sprintf("%#v", v2)), 0666) + } + + // At this point, it might be that v differs from v1 and v2, + // because there are multiple representations (e.g., an empty + // byte slice could be either nil or a zero-length slice). + // But we require that the msgp codec match the behavior of + // go-codec. + + if !reflect.DeepEqual(v1, v2) { + return fmt.Errorf("decoding mismatch") + } + + // Finally, check that the value encodes back to the same encoding. + + ee1 := EncodeMsgp(v1) + ee2 := EncodeReflect(v1) + + if debugCodecTester { + ioutil.WriteFile("/tmp/ee1", ee1, 0666) + ioutil.WriteFile("/tmp/ee2", ee2, 0666) + } + + if !reflect.DeepEqual(e1, ee1) { + return fmt.Errorf("re-encoding mismatch: e1 != ee1") + } + if !reflect.DeepEqual(e1, ee2) { + return fmt.Errorf("re-encoding mismatch: e1 != ee2") + } + + return nil +} + +// RunEncodingTest runs several iterations of encoding/decoding +// consistency testing of object type specified by template. +func RunEncodingTest(t *testing.T, template msgpMarshalUnmarshal) { + for i := 0; i < 1000; i++ { + err := EncodingTest(template) + require.NoError(t, err) + } +} diff --git a/protocol/msgp_gen.go b/protocol/msgp_gen.go new file mode 100644 index 0000000000..2961c4fc72 --- /dev/null +++ b/protocol/msgp_gen.go @@ -0,0 +1,283 @@ +package protocol + +// Code generated by github.com/algorand/msgp DO NOT EDIT. + +import ( + "github.com/algorand/msgp/msgp" +) + +// MarshalMsg implements msgp.Marshaler +func (z ConsensusVersion) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ ConsensusVersion) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(ConsensusVersion) + if !ok { + _, ok = (z).(*ConsensusVersion) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *ConsensusVersion) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = ConsensusVersion(zb0001) + } + o = bts + return +} + +func (_ *ConsensusVersion) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*ConsensusVersion) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z ConsensusVersion) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z ConsensusVersion) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z Error) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ Error) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Error) + if !ok { + _, ok = (z).(*Error) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Error) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = Error(zb0001) + } + o = bts + return +} + +func (_ *Error) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Error) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Error) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z Error) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z HashID) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ HashID) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(HashID) + if !ok { + _, ok = (z).(*HashID) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *HashID) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = HashID(zb0001) + } + o = bts + return +} + +func (_ *HashID) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*HashID) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z HashID) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z HashID) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z NetworkID) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ NetworkID) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(NetworkID) + if !ok { + _, ok = (z).(*NetworkID) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *NetworkID) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = NetworkID(zb0001) + } + o = bts + return +} + +func (_ *NetworkID) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*NetworkID) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z NetworkID) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z NetworkID) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z Tag) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ Tag) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(Tag) + if !ok { + _, ok = (z).(*Tag) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *Tag) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = Tag(zb0001) + } + o = bts + return +} + +func (_ *Tag) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*Tag) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z Tag) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z Tag) MsgIsZero() bool { + return z == "" +} + +// MarshalMsg implements msgp.Marshaler +func (z TxType) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendString(o, string(z)) + return +} + +func (_ TxType) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(TxType) + if !ok { + _, ok = (z).(*TxType) + } + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *TxType) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 string + zb0001, bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = TxType(zb0001) + } + o = bts + return +} + +func (_ *TxType) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*TxType) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z TxType) Msgsize() (s int) { + s = msgp.StringPrefixSize + len(string(z)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z TxType) MsgIsZero() bool { + return z == "" +} diff --git a/protocol/msgp_gen_test.go b/protocol/msgp_gen_test.go new file mode 100644 index 0000000000..4e0876303a --- /dev/null +++ b/protocol/msgp_gen_test.go @@ -0,0 +1,3 @@ +package protocol + +// Code generated by github.com/algorand/msgp DO NOT EDIT. diff --git a/rpcs/ledgerService_test.go b/rpcs/ledgerService_test.go index f70c4fab53..c23d71863e 100644 --- a/rpcs/ledgerService_test.go +++ b/rpcs/ledgerService_test.go @@ -334,7 +334,6 @@ func TestGetBlockMocked(t *testing.T) { signedtx := transactions.SignedTxn{ Txn: tx, } - signedtx.InitCaches() var b bookkeeping.Block prev, err := ledgerA.Block(ledgerA.LastRound()) diff --git a/rpcs/txSyncer.go b/rpcs/txSyncer.go index 6686ba72a7..db0acef0f0 100644 --- a/rpcs/txSyncer.go +++ b/rpcs/txSyncer.go @@ -137,7 +137,6 @@ func (syncer *TxSyncer) syncFromClient(client TxSyncClient) error { for _, txgroup := range txgroups { var txnsInFilter int for i := range txgroup { - txgroup[i].InitCaches() txID := txgroup[i].ID() if filter.Test(txID[:]) { // we just found a transaction that shouldn't have been diff --git a/rpcs/txSyncer_test.go b/rpcs/txSyncer_test.go index ecb523f49a..9498d51030 100644 --- a/rpcs/txSyncer_test.go +++ b/rpcs/txSyncer_test.go @@ -55,7 +55,6 @@ func makeMockPendingTxAggregate(txCount int) mockPendingTxAggregate { }, } stx := tx.Sign(sk) - stx.InitCaches() mock.txns[i] = stx } return mock diff --git a/scripts/buildhost/linux-arm.sh b/scripts/buildhost/linux-arm.sh index 70f5dadb3d..d65770f419 100755 --- a/scripts/buildhost/linux-arm.sh +++ b/scripts/buildhost/linux-arm.sh @@ -19,7 +19,7 @@ cd ${TMPPATH} AWS_REGION="us-west-2" # this is the private AMI that contains the RasPI VM running on port 5022 -AWS_LINUX_AMI="ami-092a4cbb66cbd47f7" +AWS_LINUX_AMI="ami-06819013739d79715" AWS_INSTANCE_TYPE="i3.xlarge" INSTANCE_NUMBER=$RANDOM diff --git a/scripts/check_deps.sh b/scripts/check_deps.sh index 5d95ca5d44..d61f49c93a 100755 --- a/scripts/check_deps.sh +++ b/scripts/check_deps.sh @@ -33,6 +33,7 @@ GO_DEPS=( "$GO_BIN/golint" "$GO_BIN/stringer" "$GO_BIN/swagger" + "$GO_BIN/msgp" ) check_deps() { diff --git a/scripts/compute_branch_channel.sh b/scripts/compute_branch_channel.sh index 98c79a5720..f1366d463f 100755 --- a/scripts/compute_branch_channel.sh +++ b/scripts/compute_branch_channel.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash # If enlistment isn't clean, it's 'dev' -./scripts/check_clean_enlistment.sh -if [ $? -ne 0 ]; then +CWD=$(cd "$(dirname "$0")" && pwd -P) + +if ! "$CWD"/check_clean_enlistment.sh +then echo "dev" exit 0 fi @@ -18,3 +20,4 @@ elif [ "$1" = "rel/beta" ]; then else echo "dev" fi + diff --git a/scripts/configure_dev-deps.sh b/scripts/configure_dev-deps.sh index 6b4dad873e..6aa1caf853 100755 --- a/scripts/configure_dev-deps.sh +++ b/scripts/configure_dev-deps.sh @@ -14,4 +14,4 @@ function install_go_module { install_go_module golang.org/x/lint/golint install_go_module golang.org/x/tools/cmd/stringer install_go_module github.com/go-swagger/go-swagger/cmd/swagger - +install_go_module github.com/algorand/msgp diff --git a/scripts/release/README.md b/scripts/release/README.md index cb38e2b72e..76cde8097c 100644 --- a/scripts/release/README.md +++ b/scripts/release/README.md @@ -1,25 +1,79 @@ -## Jenkins Release Build +## Shared Directory Structure Pattern + +The `release/` directory will have a structure that looks like the following: + + release/ + build/ + test/ + prod/ + ... + common/ + # scripts common to all builds {.sh,.md,Dockerfile,etc} + +Each subdirectory of `release/` represents a build pipeline and is self-contained. In other words, it will have its own `Jenkinsfile` and whatever else it needs to perform its job. + +The pattern is the following (all subdirecties of `release/` will follow this pattern): + + test/ // Maps to "test" build pipeline. + Jenkinsfile + stage/ + setup/ // Maps to "setup" stage in Jenkinsfile. + run.sh + task.sh + test/ // Maps to "test" stage in Jenkinsfile. + run.sh + task.sh + deb/ + *.sh + testDebian.exp + rpm/ + *.sh + +The `Jenkinsfile` is self-explanatory, so I'll gloss over it. `stage/` will contain directories that directly map to a defined stage in the `Jenkinsfile`. Each directory will contain two files: + +1. run.sh +1. task.sh + +`run.sh` will be the script called in the `Jenkinsfile` and contains any `aws cli` commands. `task.sh` is then initiated by `run.sh` and contains the logic for the particular build stage. -The `Jenkinsfile` uses the pipeline module to define its build stages. Currently, they are: +The `rpm` and `deb` directories will contain scripts that are relevant to their respective packaging formats. + +You may rely on this pattern, and this makes any troubleshooting relatively straightforward as you know where to find the code that executes a particular task due to setting reasonable expectations. + +## Build Outcomes + +This section briefly describes the expected outcomes of the current build pipelines. + +1. build + + The result of running this job will be to put the build artifacts and their detached signatures in the staging `algorand-builds` bucket. + + In addition, the build logs will be placed into the AWS S3 bucket`algorand-builds/build-logs/channel`. -1. create ec2 instance -1. setup ec2 instance -1. build and package 1. test -1. sign -1. upload -1. delete ec2 instance -The only thing that is not automated is pre-setting the `gpg-agent` with the passphrase of the private key. Build execution pauses at the beginning of the `sign` stage to allow for this manual process. See below for details. + Download the `deb` and `rpm` packages from staging and test. + +1. prod + + Copy the build artifacts and their detached signatures from `algorand-builds` to the production `algorand-dev-deb-repo` bucket. The [releases page] links to this location. + + In addition, local snapshots are used by Debian-based (`aptly`) and RHEL-based tooling to deploy the respective packages to `algorand-releases`. These are the packages which can then by downloaded by `apt` and `yum`. + +## Jenkins Release Build + +Each `Jenkinsfile` uses the pipeline module to define its build stages. Depending upon the pipeline, the stages will be different. The build job is parameterized with sensible defaults except for the Git hash, which is blank and can vary for each job. ## Workflow -Take a look at the Jenkins build configuration. This will set the build in motion by downloading the project from GitHub. +Take a look at each Jenkins build configuration in the Jenkins server UI. This will set the build in motion by downloading the project from GitHub. ## Setting up the Forwarded Connection +The only thing that is not automated is pre-setting the `gpg-agent` with the passphrase of the private key. Build execution pauses at the beginning of the `sign` stage of the `build` pipeline to allow for this manual process. + To complete this step, you will need to do the following: 1. Download the `ReleaseBuildInstanceKey.pem` certificate from the appropriate Jenkins workspace and `chmod 400` on it or GPG will complain. Move this to the `$GOPATH/src/github/algorand/go-algorand/scripts/release/controller` directory. @@ -34,12 +88,6 @@ To complete this step, you will need to do the following: echo foo | gpg -u rpm@algorand.com --clearsign - Or, simply list the secret keys: - - gpg --list-secret-keys - - If nothing is listed, then logout and re-establish the connection. - If there are any errors or if you are prompted for the passphrase, log out and run the above command again. Stay logged in! @@ -50,19 +98,13 @@ This is all of the manual work that needs to be done. > You may be wondering why it's necessary to automate the GPG bits. Well, this is to circumvent the need to somehow get the private key onto the remote machine, which we definitely don't want to do. See [this explanation]. -## Build Artifacts - -The result of running this job will be to put the build artifacts and their detached signatures in the AWS `algorand-dev-deb-repo` bucket. The location will depend on the type of artifact, of course. - -In addition, the build logs will be placed into the AWS `algorand-devops-misc` S3 bucket under `buildlog`. - ## Notes -- All of the `aws ...` commands are now kicked off by Jenkins by shelling out to a script in the `stages` directory that is named after the relevant build stage. These scripts in `stages` simply call the appropriate script in the `controller` directory. +- All of the `aws ...` commands are now kicked off by Jenkins by shelling out to a script in the `stages` directory that is named after the relevant build stage. - An ec2 instance is created and deleted by the `*_ec2_instance.sh` scripts in `release/`. Any pertinent information, such as the instance name and security group ID, are stored in the sub-directory `release/tmp`. This information is used by the shutdown script and then removed on a successful shutdown. -## Troublshooting +## Troubleshooting If testing on a server, you will get bad creds errors if your system's clock is off by even a couple minutes. Examples like the following will alert you to the problem: @@ -80,5 +122,22 @@ You may also try reconfiguring your `tzdata` package: $ sudo dpkg-reconfigure tzdata +--- + +If you are getting errors such as the following, it means that `gpg` has not been able to connect to the `gpg-agent` and therefore is attempting to get the passphrase from the user by raising a pinentry program: + + echo wat | gpg -u dev@algorand.com --clearsign + -----BEGIN PGP SIGNED MESSAGE----- + Hash: SHA512 + + wat + gpg: signing failed: Inappropriate ioctl for device + gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device + +The failure is saying that there is no terminal attached to the session and so no program can be raised. + +> Note that it is not necessary to set a terminal to successfully enable remote signing! Do not attempt to "fix" this by setting the `GPG_TTY` environment variable!! + [this explanation]: https://stackoverflow.com/questions/30058030/how-to-use-gpg-signing-key-on-a-remote-server +[releases page]: https://releases.algorand.com/ diff --git a/scripts/release/archive/tag.sh b/scripts/release/archive/tag.sh new file mode 100755 index 0000000000..228f63630f --- /dev/null +++ b/scripts/release/archive/tag.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# TODO: Ensure params are sent! +TAG=$1 +BRANCH=${2:-rel/stable} + +pushd "${HOME}"/go/src/github.com/algorand/go-algorand || exit +git checkout "${BRANCH}" + +# TODO +# There should be a discussion about what we actually want in the git tag text. +# For now, just use the Unix timestamp. +git tag -s -u dev@algorand.com "${TAG}" -m "Genesis Timestamp: $(date +%s)" +git tag --verify "${TAG}" + +git push -n --tags +git push --force --tags +popd + diff --git a/scripts/release/build/Jenkinsfile b/scripts/release/build/Jenkinsfile new file mode 100644 index 0000000000..d5bdde05cb --- /dev/null +++ b/scripts/release/build/Jenkinsfile @@ -0,0 +1,82 @@ +def REGION = "us-west-1" +def AMI = "ami-0dd655843c87b6930" +def TYPE = "t2.2xlarge" + +pipeline { + environment { + AWS_ACCESS_KEY_ID = credentials("prod-s3-aws-access-key-id") + AWS_SECRET_ACCESS_KEY = credentials("prod-s3-aws-secret-access-key") + } + + agent { + dockerfile { + filename 'scripts/release/common/docker/setup.Dockerfile' + /* + args '-v /etc/passwd:/etc/passwd' + */ + } + } + + /* + triggers { + cron('* * * * *') + } + */ + + stages { + stage("create ec2 instance") { + steps { + sh script: "scripts/release/common/create.sh ${REGION} ${AMI} ${TYPE}" + } + } + + stage("setup") { + steps { + sh script: "scripts/release/build/stage/setup/run.sh ${env.GIT_BRANCH}" + } + } + + stage("build") { + steps { + sh script: "scripts/release/build/stage/build/run.sh" + } + } + + stage("package") { + steps { + sh script: "scripts/release/build/stage/package/run.sh" + } + } + + stage("sign") { + steps { + input "Forward gpg-agent" + sh script: "scripts/release/build/stage/sign/run.sh" + } + } + + stage("upload") { + steps { + script { + sh script: "scripts/release/build/stage/upload/run.sh ${env.GIT_BRANCH}" + } + } + } + + stage("delete ec2 instance") { + steps { + sh script: "scripts/release/common/delete.sh ${REGION}" + } + } + + stage("trigger test job") { + steps { + build job: 'test-packages', + parameters: [ + string(name: 'branch', value: env.GIT_BRANCH) + ] + } + } + } +} + diff --git a/scripts/release/build/deb/package.sh b/scripts/release/build/deb/package.sh new file mode 100755 index 0000000000..9b6152999e --- /dev/null +++ b/scripts/release/build/deb/package.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +echo +date "+build_release begin PACKAGE DEB stage %Y%m%d_%H%M%S" +echo + +. "${HOME}"/build_env + +set -ex + +export BUILD_DEB=1 +export NO_BUILD=1 +export GOPATH="${HOME}"/go +export PATH="${GOPATH}":/usr/local/go/bin:"${PATH}" +pushd "${REPO_ROOT}" +./scripts/build_packages.sh "${PLATFORM}" +popd + +# build docker release package +cd "${REPO_ROOT}"/docker/release +sg docker "./build_algod_docker.sh ${HOME}/node_pkg/node_${CHANNEL}_${OS}-${ARCH}_${FULLVERSION}.tar.gz" + +echo +date "+build_release end PACKAGE DEB stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/rpm/build.sh b/scripts/release/build/rpm/build.sh new file mode 100755 index 0000000000..45810ca98b --- /dev/null +++ b/scripts/release/build/rpm/build.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +echo +date "+build_release start BUILD CENTOS DOCKER stage %Y%m%d_%H%M%S" +echo + +set -ex + +export HOME=/root + +. "${HOME}"/subhome/build_env + +GIT_REPO_PATH=https://github.com/algorand/go-algorand +mkdir -p "${HOME}/go/src/github.com/algorand" +cd "${HOME}/go/src/github.com/algorand" && git clone --single-branch --branch "${BRANCH}" "${GIT_REPO_PATH}" go-algorand + +# Get golang 1.12 and build its own copy of go-algorand. +cd "${HOME}" +python3 "${HOME}/go/src/github.com/algorand/go-algorand/scripts/get_latest_go.py" --version-prefix=1.12 +bash -c "cd /usr/local && tar zxf ${HOME}/go*.tar.gz" + +GOPATH=$(/usr/local/go/bin/go env GOPATH) +export PATH=${HOME}/gpgbin:${GOPATH}/bin:/usr/local/go/bin:${PATH} +export GOPATH + +REPO_DIR=/root/go/src/github.com/algorand/go-algorand + +# Build! +"${REPO_DIR}"/scripts/configure_dev-deps.sh +cd "${REPO_DIR}" +make crypto/lib/libsodium.a +make build + +# Copy binaries to the host for use in the packaging stage. +cp "${GOPATH}"/bin/* /root/subhome/go/bin/ + +echo +date "+build_release end BUILD CENTOS DOCKER stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/rpm/docker.sh b/scripts/release/build/rpm/docker.sh new file mode 100755 index 0000000000..ab748b50f3 --- /dev/null +++ b/scripts/release/build/rpm/docker.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +echo +date "+build_release begin PACKAGE RPM stage %Y%m%d_%H%M%S" +echo + +. "${HOME}/build_env" +set -ex + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh" + +echo +date "+build_release end PACKAGE RPM stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/rpm/package.sh b/scripts/release/build/rpm/package.sh new file mode 100755 index 0000000000..8aa0685ad2 --- /dev/null +++ b/scripts/release/build/rpm/package.sh @@ -0,0 +1,32 @@ +#!/bin/bash -e + +# build_rpm.sh - Build a .deb package for one platform. +# +# Syntax: build_rpm.sh +# +# Examples: scripts/build_rpm.sh /tmp + +set -ex + +cd "$(dirname "$0")"/.. +export GOPATH=$HOME/subhome/go +export REPO_DIR=${HOME}/subhome/go/src/github.com/algorand/go-algorand + +echo "Building RPM package" + +DEFAULT_RELEASE_NETWORK=$("$REPO_DIR/scripts/compute_branch_release_network.sh" "${DEFAULTNETWORK}") +export DEFAULT_RELEASE_NETWORK + +RPMTMP=$(mktemp -d 2>/dev/null || mktemp -d -t "rpmtmp") +trap 'rm -rf ${RPMTMP}' 0 + +TEMPDIR=$(mktemp -d) +trap 'rm -rf $TEMPDIR' 0 +< "$REPO_DIR/installer/rpm/algorand.spec" sed -e s,@VER@,"${FULLVERSION}", > "${TEMPDIR}/algorand.spec" + +#rpmbuild --define "_rpmdir ${OUTDIR}" --define "RELEASE_GENESIS_PROCESS x${RELEASE_GENESIS_PROCESS}" --define "LICENSE_FILE $REPO_DIR/COPYING" -bb "${TEMPDIR}/algorand.spec" +rpmbuild --define "_rpmdir ${RPMTMP}" --define "RELEASE_GENESIS_PROCESS x${RELEASE_GENESIS_PROCESS}" --define "LICENSE_FILE $REPO_DIR/COPYING" -bb "${TEMPDIR}/algorand.spec" + +mkdir -p /root/subhome/node_pkg +cp -p "${RPMTMP}"/*/*.rpm /root/subhome/node_pkg + diff --git a/scripts/release/build/rpm/sign.sh b/scripts/release/build/rpm/sign.sh new file mode 100755 index 0000000000..756d914f00 --- /dev/null +++ b/scripts/release/build/rpm/sign.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# shellcheck disable=2012 +# sign centos rpm from inside docker + +set -ex + +export HOME=/root +export GOPATH=${HOME}/go +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} + +cd ${HOME} && tar jxf /root/subhome/gnupg*.tar.bz2 + +export PATH="${HOME}/gnupg2/bin:${PATH}" +export LD_LIBRARY_PATH=${HOME}/gnupg2/lib + +umask 0077 +mkdir -p ~/.gnupg +umask 0022 + +touch "${HOME}/.gnupg/gpg.conf" +if grep -q no-autostart "${HOME}/.gnupg/gpg.conf"; then + echo "" +else + echo "no-autostart" >> "${HOME}/.gnupg/gpg.conf" +fi +rm -f ${HOME}/.gnupg/S.gpg-agent +(cd ~/.gnupg && ln -s /root/S.gpg-agent S.gpg-agent) + +gpg --import /root/keys/dev.pub +gpg --import /root/keys/rpm.pub +rpmkeys --import /root/keys/rpm.pub +echo "wat" | gpg -u rpm@algorand.com --clearsign + +cat <"${HOME}/.rpmmacros" +%_gpg_name Algorand RPM +%__gpg ${HOME}/gnupg2/bin/gpg +%__gpg_check_password_cmd true +EOF + +cat <"${HOME}/rpmsign.py" +import rpm +import sys +rpm.addSign(sys.argv[1], '') +EOF + +NEWEST_RPM=$(ls -t /root/subhome/node_pkg/*rpm | head -1) +python2 "${HOME}/rpmsign.py" "${NEWEST_RPM}" + diff --git a/scripts/release/build/stage/build/run.sh b/scripts/release/build/stage/build/run.sh new file mode 100755 index 0000000000..87245ee664 --- /dev/null +++ b/scripts/release/build/stage/build/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/build/task.sh + diff --git a/scripts/release/build/stage/build/task.sh b/scripts/release/build/stage/build/task.sh new file mode 100755 index 0000000000..a10955979f --- /dev/null +++ b/scripts/release/build/stage/build/task.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +set -ex + +echo +date "+build_release begin BUILD stage %Y%m%d_%H%M%S" +echo + +. "${HOME}/build_env" + +export GOPATH=${HOME}/go +export PATH=${HOME}/gpgbin:${GOPATH}/bin:/usr/local/go/bin:${PATH} + +cd "${REPO_ROOT}" +# tell underlying 'build' scripts we already built +export NO_BUILD=true + +# Update version file for this build +if [ ! -z "${BUILD_NUMBER}" ]; then + echo "using externally set BUILD_NUMBER=${BUILD_NUMBER} without incrementing" +else + if [ -e "${REPO_ROOT}"/buildnumber.dat ] + then + BUILD_NUMBER=$(cat "${REPO_ROOT}"/buildnumber.dat) + else + BUILD_NUMBER=0 + fi + + echo ${BUILD_NUMBER} > "${REPO_ROOT}"/buildnumber.dat +fi + +# Run RPM build in Centos7 Docker container +sg docker "docker build -t algocentosbuild - < $HOME/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile" + +sg docker "docker run --rm --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/build.sh" + +echo +date "+build_release end BUILD stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/stage/package/run.sh b/scripts/release/build/stage/package/run.sh new file mode 100755 index 0000000000..08e7ed86e1 --- /dev/null +++ b/scripts/release/build/stage/package/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/package/task.sh + diff --git a/scripts/release/build/stage/package/task.sh b/scripts/release/build/stage/package/task.sh new file mode 100755 index 0000000000..eebe44f92b --- /dev/null +++ b/scripts/release/build/stage/package/task.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +set -ex + +echo +date "+build_release begin PACKAGE stage %Y%m%d_%H%M%S" +echo + +. "${HOME}/build_env" + +# Order matters (deb -> rpm)! +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/build/deb/package.sh + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh" + +echo +date "+build_release end PACKAGE stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/stage/setup/run.sh b/scripts/release/build/stage/setup/run.sh new file mode 100755 index 0000000000..2cb79accb9 --- /dev/null +++ b/scripts/release/build/stage/setup/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# shellcheck disable=2029 + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. +INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) +BRANCH="$1" + +aws s3 cp s3://algorand-devops-misc/tools/gnupg2.2.9_centos7_amd64.tar.bz2 . +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r scripts/release/common/setup.sh gnupg2.2.9_centos7_amd64.tar.bz2 ubuntu@"$INSTANCE": +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash setup.sh "$BRANCH" + diff --git a/scripts/release/build/stage/sign/run.sh b/scripts/release/build/stage/sign/run.sh new file mode 100755 index 0000000000..7fd86557e8 --- /dev/null +++ b/scripts/release/build/stage/sign/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$(cat scripts/release/common/ec2/tmp/instance)" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/sign/task.sh + diff --git a/scripts/release/build/stage/sign/task.sh b/scripts/release/build/stage/sign/task.sh new file mode 100755 index 0000000000..e02a77afb4 --- /dev/null +++ b/scripts/release/build/stage/sign/task.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# shellcheck disable=1090,2129,2035 + +set -ex + +echo +date "+build_release begin SIGN stage %Y%m%d_%H%M%S" +echo + +. "${HOME}/build_env" + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/sign.sh" + +pushd "${REPO_ROOT}" +git archive --prefix="algorand-${FULLVERSION}/" "${BRANCH}" | gzip > "${PKG_ROOT}/algorand_${CHANNEL}_source_${FULLVERSION}.tar.gz" +popd + +cd "${PKG_ROOT}" || exit +for i in *.tar.gz *.deb +do + gpg -u "${SIGNING_KEY_ADDR}" --detach-sign "${i}" +done + +for i in *.rpm +do + gpg -u rpm@algorand.com --detach-sign "${i}" +done + +HASHFILE=hashes_${CHANNEL}_${OS}_${ARCH}_${FULLVERSION} +rm -f "${HASHFILE}" +touch "${HASHFILE}" + +# For an explanation of the "-- *.tar.gz" below +# see https://github.com/koalaman/shellcheck/wiki/SC2035 +md5sum *.tar.gz *.deb *.rpm >> "${HASHFILE}" +shasum -a 256 *.tar.gz *.deb *.rpm >> "${HASHFILE}" +shasum -a 512 *.tar.gz *.deb *.rpm >> "${HASHFILE}" + +if [ -z "${SIGNING_KEY_ADDR}" ] +then + echo "no signing key addr" + SIGNING_KEY_ADDR=dev@algorand.com +fi + +gpg -u "${SIGNING_KEY_ADDR}" --detach-sign "${HASHFILE}" +gpg -u "${SIGNING_KEY_ADDR}" --clearsign "${HASHFILE}" + +echo +date "+build_release end SIGN stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/build/stage/upload/run.sh b/scripts/release/build/stage/upload/run.sh new file mode 100755 index 0000000000..c96d2d9158 --- /dev/null +++ b/scripts/release/build/stage/upload/run.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. + +#BUCKET_LOCATION="$2" +INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) +BUILD_ENV=$(ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" cat /home/ubuntu/build_env) +CHANNEL=$(sed -n 's/.*CHANNEL=\(.*\)/\1/p' <<< "$BUILD_ENV") +FULLVERSION=$(sed -n 's/.*FULLVERSION=\(.*\)/\1/p' <<< "$BUILD_ENV") + +rm -rf pkg && mkdir -p pkg/"$FULLVERSION" + +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash go/src/github.com/algorand/go-algorand/scripts/release/build/stage/upload/task.sh +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r ubuntu@"$INSTANCE":~/node_pkg/* pkg/"$FULLVERSION"/ + +# Create the buildlog file. +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no ubuntu@"$INSTANCE":~/build_status_"$CHANNEL"_*.asc.gz pkg/"$FULLVERSION" +#aws s3 sync --exclude dev* --exclude master* --exclude nightly* --exclude stable* --acl public-read pkg/"$FULLVERSION" s3://"$BUCKET_LOCATION"/"$CHANNEL"/"$FULLVERSION"/ +aws s3 sync --exclude dev* --exclude master* --exclude nightly* --exclude stable* --acl public-read pkg/"$FULLVERSION" s3://ben-test-2.0.3/"$CHANNEL"/"$FULLVERSION"/ + diff --git a/scripts/release/build/stage/upload/task.sh b/scripts/release/build/stage/upload/task.sh new file mode 100755 index 0000000000..bfb53dbf0d --- /dev/null +++ b/scripts/release/build/stage/upload/task.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# shellcheck disable=1090,2129 +# AWS_EFS_MOUNT= NFS to mount for `aptly` persistent state and scratch storage + +set -ex + +echo +date "+build_release begin UPLOAD stage %Y%m%d_%H%M%S" +echo + +. "${HOME}/build_env" + +cd "${PKG_ROOT}" + +cd "${HOME}" +STATUSFILE=build_status_${CHANNEL}_${FULLVERSION} + +echo "ami-id:" > "${STATUSFILE}" +curl --silent http://169.254.169.254/latest/meta-data/ami-id >> "${STATUSFILE}" + +############################################################ + +cat <>"${STATUSFILE}" + +go version: +EOF + +/usr/local/go/bin/go version >>"${STATUSFILE}" + + +############################################################ + +cat <>"${STATUSFILE}" + +go env: +EOF + +/usr/local/go/bin/go env >>"${STATUSFILE}" + +############################################################ + +cat <>"${STATUSFILE}" + +build_env: +EOF + +cat <"${HOME}"/build_env >> "${STATUSFILE}" + +############################################################ + +cat <>"${STATUSFILE}" + +dpkg-l: +EOF + +############################################################ + +# Note this file is scp'd in stage/upload.sh +dpkg -l >> "${STATUSFILE}" +gpg --clearsign "${STATUSFILE}" +gzip "${STATUSFILE}".asc > "${HOME}"/node_pkg/"${STATUSFILE}".asc.gz + +echo +date "+build_release end UPLOAD stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/common/create.sh b/scripts/release/common/create.sh new file mode 100755 index 0000000000..d614054b0c --- /dev/null +++ b/scripts/release/common/create.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Path(s) are relative to the root of the Jenkins workspace. +scripts/release/common/ec2/start.sh "$1" "$2" "$3" + diff --git a/scripts/release/common/delete.sh b/scripts/release/common/delete.sh new file mode 100755 index 0000000000..c394404f8e --- /dev/null +++ b/scripts/release/common/delete.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Path(s) are relative to the root of the Jenkins workspace. +scripts/release/common/ec2/shutdown.sh "$1" + diff --git a/scripts/release/common/docker/centos.Dockerfile b/scripts/release/common/docker/centos.Dockerfile new file mode 100644 index 0000000000..c36cdd5974 --- /dev/null +++ b/scripts/release/common/docker/centos.Dockerfile @@ -0,0 +1,8 @@ +FROM centos:7 + +WORKDIR /root +RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum install -y autoconf awscli git gnupg2 nfs-utils python36 sqlite3 boost-devel expect jq libtool gcc-c++ libstdc++-devel libstdc++-static rpmdevtools createrepo rpm-sign bzip2 which ShellCheck + +ENTRYPOINT ["/bin/bash"] + diff --git a/scripts/release/common/docker/setup.Dockerfile b/scripts/release/common/docker/setup.Dockerfile new file mode 100644 index 0000000000..d68331b62c --- /dev/null +++ b/scripts/release/common/docker/setup.Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y awscli jq ssh +#RUN adduser --uid $(grep jenkins /etc/passwd | awk -F: '{ print $3 }') ubuntu +RUN adduser --uid 111 ubuntu + diff --git a/scripts/release/common/ec2/shutdown.sh b/scripts/release/common/ec2/shutdown.sh new file mode 100755 index 0000000000..8cc312eeb4 --- /dev/null +++ b/scripts/release/common/ec2/shutdown.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# shellcheck disable=2164 + +AWS_REGION="$1" +GREEN_FG=$(echo -en "\e[32m") +YELLOW_FG=$(echo -en "\e[33m") +END_FG_COLOR=$(echo -en "\e[39m") +REPO_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" + +if [ "$AWS_REGION" = "" ] +then + echo "Missing AWS_REGION argument" + exit 1 +fi + +pushd "$REPO_ROOT"/tmp > /dev/null +SGID=$(cat sgid) +INSTANCE_ID=$(cat instance-id) +KEY_NAME=$(cat key-name) +popd > /dev/null + +echo "$YELLOW_FG[$0]$END_FG_COLOR: Waiting for instance to terminate." +end=$((SECONDS+1200)) +PRIOR_INSTANCE_STATE= +while [ $SECONDS -lt $end ] +do + aws ec2 terminate-instances --instance-ids "$INSTANCE_ID" --region "$AWS_REGION" > "$REPO_ROOT"/tmp/instance.json + INSTANCE_CODE=$(< "$REPO_ROOT"/tmp/instance.json jq '.TerminatingInstances[].CurrentState.Code') + INSTANCE_STATE=$(< "$REPO_ROOT"/tmp/instance.json jq '.TerminatingInstances[].CurrentState.Name') + + if [ "$INSTANCE_CODE" = "48" ] + then + echo "$GREEN_FG[$0]$END_FG_COLOR: Instance terminated." + break + fi + + if [ "$INSTANCE_STATE" != "$PRIOR_INSTANCE_STATE" ] + then + echo "$YELLOW_FG[$0]$END_FG_COLOR: Instance is in state $INSTANCE_STATE..." + PRIOR_INSTANCE_STATE="$INSTANCE_STATE" + fi + + sleep 5s +done + +if [ "$KEY_NAME" != "" ] +then + aws ec2 delete-key-pair --key-name "$KEY_NAME" --region "$AWS_REGION" +fi + +if [ "$SGID" != "" ] +then + aws ec2 delete-security-group --group-id "$SGID" --region "$AWS_REGION" +fi + +rm -rf BuilderInstanceKey.pem "$REPO_ROOT"/tmp + diff --git a/scripts/release/common/ec2/start.sh b/scripts/release/common/ec2/start.sh new file mode 100755 index 0000000000..20f86562e5 --- /dev/null +++ b/scripts/release/common/ec2/start.sh @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +# shellcheck disable=2164 + +AWS_REGION="$1" +AWS_AMI="$2" +AWS_INSTANCE_TYPE="$3" +INSTANCE_NUMBER=$RANDOM +KEY_NAME="ReleaseBuildInstanceKey_$INSTANCE_NUMBER" +KEY_NAME_FILE="ReleaseBuildInstanceKey.pem" +SECURITY_GROUP_NAME="ReleaseBuildMachineSSH_$INSTANCE_NUMBER" +CIDR="0.0.0.0/0" +RED_FG=$(echo -en "\e[31m") +GREEN_FG=$(echo -en "\e[32m") +YELLOW_FG=$(echo -en "\e[33m") +END_FG_COLOR=$(echo -en "\e[39m") +REPO_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" + +cleanup () { + rm -rf "$REPO_ROOT"/tmp +} + +delete_local_key () { + rm -f "$KEY_NAME_FILE" +} + +delete_key_pair () { + if ! aws ec2 delete-key-pair --key-name "$KEY_NAME" --region "$AWS_REGION" + then + exit 1 + echo "$RED_FG[$0]$END_FG_COLOR: Key pair was not deleted!" + fi +} + +delete_security_group () { + if ! aws ec2 delete-security-group --group-id "$SGID" --region "$AWS_REGION" + then + exit 1 + echo "$RED_FG[$0]$END_FG_COLOR: Security group was not deleted!" + fi +} + +manage_instance_info () { + pushd "$REPO_ROOT"/tmp > /dev/null + rm instance*.json + echo "$SGID" > sgid + echo "$INSTANCE_NAME" > instance + echo "$INSTANCE_ID" > instance-id + echo "$KEY_NAME" > key-name + popd > /dev/null + echo "$GREEN_FG[$0]$END_FG_COLOR: Created $REPO_ROOT/tmp/ dir containing instance information." +} + +if ! SGID=$(aws ec2 create-security-group --group-name "$SECURITY_GROUP_NAME" --description "Security Group for ephemeral build machine to allow port 22" --region "$AWS_REGION" | jq -r '.GroupId') +then + exit 1 +fi + +for port in {22,5022} +do + if ! aws ec2 authorize-security-group-ingress --group-name "$SECURITY_GROUP_NAME" --protocol tcp --port $port --cidr "$CIDR" --region "$AWS_REGION" + then + delete_security_group + echo "$RED_FG[$0]$END_FG_COLOR: There was a problem opening port $port!" + exit 1 + fi +done + +delete_local_key +if ! aws ec2 create-key-pair --key-name "$KEY_NAME" --region "$AWS_REGION" | jq -r '.KeyMaterial' > "$KEY_NAME_FILE" +then + echo "$RED_FG[$0]$END_FG_COLOR: There was a problem creating the key pair!" + delete_security_group + delete_local_key + exit 1 +else + chmod 400 "$KEY_NAME_FILE" +fi + +mkdir -p "$REPO_ROOT/tmp" + +if ! aws ec2 run-instances --image-id "$AWS_AMI" --key-name "$KEY_NAME" --security-groups "$SECURITY_GROUP_NAME" --instance-type "$AWS_INSTANCE_TYPE" --tag-specifications "ResourceType=instance,Tags=[{Key=\"Name\",Value=\"Release_Build_Ephemeral_${INSTANCE_NUMBER}\"}, {Key=\"For\",Value=\"Release_Build_Ephemeral\"}]" --block-device-mappings '{ "DeviceName": "/dev/sda1", "Ebs": { "VolumeSize": 40 } }' --count 1 --region "$AWS_REGION" > "$REPO_ROOT"/tmp/instance.json +then + echo "$RED_FG[$0]$END_FG_COLOR: There was a problem launching the instance! Deleting the security group and the key pair!" + delete_key_pair + delete_security_group + delete_local_key + cleanup + exit 1 +fi + +INSTANCE_ID=$(< "$REPO_ROOT"/tmp/instance.json jq -r '.Instances[].InstanceId') + +echo "$YELLOW_FG[$0]$END_FG_COLOR: Waiting for instance to start." +end=$((SECONDS+90)) +PRIOR_INSTANCE_STATE= +while [ $SECONDS -lt $end ] +do + aws ec2 describe-instance-status --instance-id "$INSTANCE_ID" --region "$AWS_REGION" --include-all-instances > "$REPO_ROOT"/tmp/instance2.json + INSTANCE_CODE=$(< "$REPO_ROOT"/tmp/instance2.json jq '.InstanceStatuses[].InstanceState.Code') + INSTANCE_STATE=$(< "$REPO_ROOT"/tmp/instance2.json jq '.InstanceStatuses[].InstanceState.Name') + + if [ "$INSTANCE_CODE" == "16" ] + then + echo "$GREEN_FG[$0]$END_FG_COLOR: Instance started." + break + fi + + if [ "$INSTANCE_STATE" != "$PRIOR_INSTANCE_STATE" ] + then + echo "$YELLOW_FG[$0]$END_FG_COLOR: Instance is in state $INSTANCE_STATE..." + PRIOR_INSTANCE_STATE="$INSTANCE_STATE" +# else +# cat "$REPO_ROOT"/tmp/instance2.json + fi + + sleep 1s +done + +aws ec2 describe-instances --region "$AWS_REGION" --instance-id "$INSTANCE_ID" > "$REPO_ROOT"/tmp/instance2.json +INSTANCE_NAME=$(< "$REPO_ROOT"/tmp/instance2.json jq -r '.Reservations[].Instances[].PublicDnsName') +echo "$GREEN_FG[$0]$END_FG_COLOR: Instance name = $INSTANCE_NAME" + +manage_instance_info + +echo "$YELLOW_FG[$0]$END_FG_COLOR: Waiting for SSH connection" +end=$((SECONDS+90)) +while [ $SECONDS -lt $end ] +do + if ssh -i "$KEY_NAME_FILE" -o "StrictHostKeyChecking no" "ubuntu@$INSTANCE_NAME" "uname" + then + echo "$GREEN_FG[$0]$END_FG_COLOR: SSH connection ready" + exit 0 + fi + + sleep 1s +done + +echo "$RED_FG[$0]$END_FG_COLOR: Unable to establish SSH connection" +delete_local_key +cleanup +exit 1 + diff --git a/scripts/release/common/setup.sh b/scripts/release/common/setup.sh new file mode 100755 index 0000000000..069258b279 --- /dev/null +++ b/scripts/release/common/setup.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash + +set -ex + +if [ -z "${BUILDTIMESTAMP}" ]; then + date "+%Y%m%d_%H%M%S" > "${HOME}/buildtimestamp" + BUILDTIMESTAMP=$(cat "${HOME}/buildtimestamp") + export BUILDTIMESTAMP + echo run "${0}" with output to "${HOME}/buildlog_${BUILDTIMESTAMP}" + (bash "${0}" "${1}" 2>&1) | tee "${HOME}/buildlog_${BUILDTIMESTAMP}" + exit 0 +fi + +echo +date "+build_release begin SETUP stage %Y%m%d_%H%M%S" +echo + +sudo apt-get update +sudo apt-get upgrade -y +sudo apt-get install -y build-essential automake autoconf awscli docker.io git gpg nfs-common python3 rpm sqlite3 python3-boto3 g++ libtool rng-tools +sudo rngd -r /dev/urandom + +#umask 0077 +mkdir -p "${HOME}"/{.gnupg,dummyaptly,dummyrepo,go,gpgbin,keys,node_pkg,prodrepo} +mkdir -p "${HOME}"/go/bin + +BRANCH=${1:-"master"} +export BRANCH + +# Check out +mkdir -p "${HOME}/go/src/github.com/algorand" +cd "${HOME}/go/src/github.com/algorand" && git clone --single-branch --branch "${BRANCH}" https://github.com/algorand/go-algorand go-algorand +# TODO: if we are checking out a release tag, `git tag --verify` it + +export DEBIAN_FRONTEND=noninteractive + +# Install latest Go +cd "${HOME}" +python3 "${HOME}/go/src/github.com/algorand/go-algorand/scripts/get_latest_go.py" --version-prefix=1.12 +# $HOME will be interpreted by the outer shell to create the string passed to sudo bash +sudo bash -c "cd /usr/local && tar zxf ${HOME}/go*.tar.gz" + +GOPATH=$(/usr/local/go/bin/go env GOPATH) +export PATH=${HOME}/gpgbin:${GOPATH}/bin:/usr/local/go/bin:${PATH} +export GOPATH + +cat << EOF > "${HOME}/gpgbin/remote_gpg_socket" +export GOPATH=\${HOME}/go +export PATH=\${HOME}/gpgbin:${GOPATH}/bin:/usr/local/go/bin:${PATH} +gpgconf --list-dirs | grep agent-socket | awk -F: '{ print \$2 }' +EOF + +chmod +x "${HOME}/gpgbin/remote_gpg_socket" + +# This real name and email must precisely match GPG key +git config --global user.name "Algorand developers" +git config --global user.email dev@algorand.com + +# configure GnuPG to rely on forwarded remote gpg-agent +umask 0077 +touch "${HOME}/.gnupg/gpg.conf" +if grep -q no-autostart "${HOME}/.gnupg/gpg.conf"; then + echo "" +else + echo "no-autostart" >> "${HOME}/.gnupg/gpg.conf" +fi + +if [ -f "${HOME}/key.gpg" ]; then + gpg --import "${HOME}/key.gpg" +fi +# we had a tight umask for gpg setup, but need wider for git clone below +umask 0002 + +# allow ssh to clobber unix domain sockets for gpg-agent forwarding +if grep -q ^StreamLocalBindUnlink /etc/ssh/sshd_config; then + echo already have StreamLocalBindUnlink sshd config +else + sudo bash -c "echo 'StreamLocalBindUnlink yes' >> /etc/ssh/sshd_config" + sudo systemctl restart sshd +fi + +sudo usermod -a -G docker ubuntu +sg docker "docker pull centos:7" +sg docker "docker pull ubuntu:18.04" + +cat << EOF >> "${HOME}/.bashrc" +export EDITOR=vi +EOF + +cat << EOF >> "${HOME}/.profile" +export GOPATH=\${HOME}/go +export PATH=\${HOME}/gpgbin:\${GOPATH}/bin:/usr/local/go/bin:\${PATH} +EOF + +# Install aptly for building debian repo +mkdir -p "$GOPATH/src/github.com/aptly-dev" +cd "$GOPATH/src/github.com/aptly-dev" +git clone https://github.com/aptly-dev/aptly +cd aptly && git fetch + +# As of 2019-06-06 release tag v1.3.0 is 2018-May, GnuPG 2 support was added in October but they haven't tagged a new release yet. Hash below seems to work so far. +# 2019-07-06 v1.4.0 +git checkout v1.4.0 +make install + +REPO_ROOT="${GOPATH}"/src/github.com/algorand/go-algorand +PLATFORM=$("${REPO_ROOT}"/scripts/osarchtype.sh) +PLATFORM_SPLIT=(${PLATFORM//\// }) + +# a bash user might `source build_env` to manually continue a broken build +cat << EOF > "${HOME}"/build_env +export BRANCH=${BRANCH} +export CHANNEL=$("${GOPATH}"/src/github.com/algorand/go-algorand/scripts/compute_branch_channel.sh "${BRANCH}") +export DEFAULTNETWORK=$(PATH=${PATH} "${REPO_ROOT}"/scripts/compute_branch_network.sh) +export DC_IP=$(curl --silent http://169.254.169.254/latest/meta-data/local-ipv4) +export FULLVERSION=$("${GOPATH}"/src/github.com/algorand/go-algorand/scripts/compute_build_number.sh -f) +export PKG_ROOT=${HOME}/node_pkg +export PLATFORM=${PLATFORM} +export OS=${PLATFORM_SPLIT[0]} +export ARCH=${PLATFORM_SPLIT[1]} +export REPO_ROOT=${REPO_ROOT} +export RELEASE_GENESIS_PROCESS=true +export VARIATIONS=base +EOF + +# strip leading 'export ' for docker --env-file +sed 's/^export //g' < "${HOME}"/build_env > "${HOME}"/build_env_docker + +echo +date "+build_release end SETUP stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/helper/centos-build.Dockerfile b/scripts/release/helper/centos-build.Dockerfile index 6cea7767e1..c36cdd5974 100644 --- a/scripts/release/helper/centos-build.Dockerfile +++ b/scripts/release/helper/centos-build.Dockerfile @@ -1,6 +1,8 @@ FROM centos:7 + WORKDIR /root RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm RUN yum install -y autoconf awscli git gnupg2 nfs-utils python36 sqlite3 boost-devel expect jq libtool gcc-c++ libstdc++-devel libstdc++-static rpmdevtools createrepo rpm-sign bzip2 which ShellCheck ENTRYPOINT ["/bin/bash"] + diff --git a/scripts/release/helper/deb_test.sh b/scripts/release/helper/deb_test.sh index edef42b3b7..e177ccb3cc 100755 --- a/scripts/release/helper/deb_test.sh +++ b/scripts/release/helper/deb_test.sh @@ -2,14 +2,14 @@ #set -xv -echo "deb_test starting within docker container" +echo "test_apt-get starting within docker container" export GOPATH=${HOME}/go export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} apt-get update apt-get install -y gnupg2 curl software-properties-common python3 -apt-key add /stuff/key.pub +apt-key add /root/keys/dev.pub add-apt-repository -y "deb [trusted=yes] http://${DC_IP}:8111/ stable main" apt-get update apt-get install -y algorand @@ -18,11 +18,11 @@ apt-get install -y expect algod -v echo "starting test of algod with expect script testDebian.exp" -OUTPUT=$(expect -d /workdir/testDebian.exp /var/lib/algorand /testdata) +OUTPUT=$(expect -d /workdir/deb/testDebian.exp /var/lib/algorand /testdata) STATUS=$? echo "$OUTPUT" -echo "deb_test completed with status: " $STATUS +echo "test_apt-get completed with status: " $STATUS exit $STATUS diff --git a/scripts/release/prod/Jenkinsfile b/scripts/release/prod/Jenkinsfile new file mode 100644 index 0000000000..3425dc2a60 --- /dev/null +++ b/scripts/release/prod/Jenkinsfile @@ -0,0 +1,60 @@ +pipeline { + parameters { + string defaultValue: 'master', description: 'Release to deploy to production', name: 'branch', trim: true + string defaultValue: 'stable', description: 'Staged channel which should be deployed to production.', name: 'channel', trim: true + string defaultValue: '', description: 'Release to deploy to production', name: 'release', trim: true + string defaultValue: 'ben-test-2.0.3', description: 'Staging location', name: 'bucket_location_staging', trim: true + string defaultValue: 'algorand-dev-deb-repo/releases', description: 'Production location', name: 'bucket_location_prod', trim: true + + // AWS + string defaultValue: 'us-west-1', description: 'AWS Region', name: 'region', trim: true + string defaultValue: 'ami-0dd655843c87b6930', description: 'Amazon Machine Image (default: Ubuntu Server 18.04 LTS, 8 vCPUs, 32 GB RAM', name: 'ami', trim: true + string defaultValue: 't2.2xlarge', description: 'Instance Type', name: 'type', trim: true + } + + environment { + AWS_ACCESS_KEY_ID = credentials("prod-s3-aws-access-key-id") + AWS_SECRET_ACCESS_KEY = credentials("prod-s3-aws-secret-access-key") + } + + agent any + + stages { + stage("sync staging and production buckets") { + steps { + sh script: "scripts/release/prod/stage/sync/run.sh ${params.bucket_location_staging} ${params.bucket_location_prod} ${params.channel} ${params.release}" + } + } + + stage("create ec2 instance") { + steps { + sh script: "scripts/release/common/create.sh ${params.region} ${params.ami} ${params.type}" + } + } + + stage("setup") { + steps { + script { + if (params.channel == null || params.channel == "") { + error("Missing required parameter [channel].") + } + } + + sh script: "scripts/release/prod/stage/setup/run.sh ${params.bucket_location_staging} ${params.branch} ${params.channel} ${params.release}" + } + } + + stage("snapshot") { + steps { + input "Forward GPG agent" + } + } + + stage("delete ec2 instance") { + steps { + sh script: "scripts/release/common/delete.sh ${params.region}" + } + } + } +} + diff --git a/scripts/release/prod/deb/snapshot.sh b/scripts/release/prod/deb/snapshot.sh new file mode 100755 index 0000000000..facba08810 --- /dev/null +++ b/scripts/release/prod/deb/snapshot.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +set -ex + +cat <"${HOME}"/.aptly.conf +{ + "rootDir": "${HOME}/aptly", + "downloadConcurrency": 4, + "downloadSpeedLimit": 0, + "architectures": [], + "dependencyFollowSuggests": false, + "dependencyFollowRecommends": false, + "dependencyFollowAllVariants": false, + "dependencyFollowSource": false, + "dependencyVerboseResolve": false, + "gpgDisableSign": false, + "gpgDisableVerify": false, + "gpgProvider": "gpg", + "downloadSourcePackages": false, + "skipLegacyPool": true, + "ppaDistributorID": "ubuntu", + "ppaCodename": "", + "skipContentsPublishing": false, + "FileSystemPublishEndpoints": {}, + "S3PublishEndpoints": { + "ben-test-2.0.3": { + "region":"us-east-1", + "bucket":"ben-test-2.0.3", + "acl":"public-read", + "prefix":"deb" + } + }, + "SwiftPublishEndpoints": {} +} +EOF + +# "S3PublishEndpoints": { +# "algorand-releases": { +# "region":"us-east-1", +# "bucket":"algorand-releases", +# "acl":"public-read", +# "prefix":"deb" +# }, +# "algorand-dev-deb-repo": { +# "region":"us-east-1", +# "bucket":"algorand-dev-deb-repo", +# "acl":"public-read", +# "prefix":"deb" +# } +# }, + +# Creates ~/aptly/db +"$HOME"/go/bin/aptly -config="${HOME}"/.aptly.conf repo create -distribution=stable -component=main algorand +# Creates ~/aptly/pool +"$HOME"/go/bin/aptly -config="${HOME}"/.aptly.conf repo add algorand "${HOME}"/node_pkg/*.deb +SNAPSHOT=algorand-$(date +%Y%m%d_%H%M%S) +"$HOME"/go/bin/aptly -config="${HOME}"/.aptly.conf snapshot create "${SNAPSHOT}" from repo algorand +# Creates ~/aptly/public +"$HOME"/go/bin/aptly -config="${HOME}"/.aptly.conf publish snapshot -gpg-key=dev@algorand.com -origin=Algorand -label=Algorand "${SNAPSHOT}" "s3:ben-test-2.0.3:" + diff --git a/scripts/reverse_hex_timestamp b/scripts/release/prod/reverse_hex_timestamp similarity index 100% rename from scripts/reverse_hex_timestamp rename to scripts/release/prod/reverse_hex_timestamp diff --git a/scripts/release/prod/rpm/run_centos.sh b/scripts/release/prod/rpm/run_centos.sh new file mode 100755 index 0000000000..c8a80236e4 --- /dev/null +++ b/scripts/release/prod/rpm/run_centos.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +set -ex + +. "${HOME}"/build_env + +# Run RPM build in Centos7 Docker container +sg docker "docker build -t algocentosbuild - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile" + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/prodrepo,dst=/root/prodrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/prod/rpm/snapshot.sh" + diff --git a/scripts/release/prod/rpm/snapshot.sh b/scripts/release/prod/rpm/snapshot.sh new file mode 100755 index 0000000000..29c4202cca --- /dev/null +++ b/scripts/release/prod/rpm/snapshot.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# shellcheck disable=2012 + +set -ex + +cd /root && tar jxf /root/subhome/gnupg*.tar.bz2 +export PATH=/root/gnupg2/bin:"${PATH}" +export LD_LIBRARY_PATH=/root/gnupg2/lib + +umask 0077 +mkdir -p /root/.gnupg +umask 0022 +touch /root/.gnupg/gpg.conf + +if grep -q no-autostart /root/.gnupg/gpg.conf +then + echo "" +else + echo "no-autostart" >> /root/.gnupg/gpg.conf +fi + +rm -f /root/.gnupg/S.gpg-agent +cd /root/.gnupg && ln -s /root/S.gpg-agent S.gpg-agent + +gpg --import /root/keys/dev.pub +gpg --import /root/keys/rpm.pub +rpmkeys --import /root/keys/rpm.pub +echo "wat" | gpg -u rpm@algorand.com --clearsign + +cat < /root/.rpmmacros +%_gpg_name Algorand RPM +%__gpg /root/gnupg2/bin/gpg +%__gpg_check_password_cmd true +EOF + +cat < /root/rpmsign.py +import rpm +import sys +rpm.addSign(sys.argv[1], '') +EOF + +NEWEST_RPM=$(ls -t /root/subhome/node_pkg/*.rpm | head -1) +python2 /root/rpmsign.py "${NEWEST_RPM}" + +cp -p "${NEWEST_RPM}" /root/prodrepo +createrepo --database /root/prodrepo +rm -f /root/prodrepo/repodata/repomd.xml.asc +gpg -u rpm@algorand.com --detach-sign --armor /root/prodrepo/repodata/repomd.xml + +aws s3 sync --quiet /root/prodrepo/ s3://ben-test-2.0.3/rpm/stable/ + +echo CENTOS_DOCKER_SNAPSHOT_OK + diff --git a/scripts/release/prod/stage/setup/run.sh b/scripts/release/prod/stage/setup/run.sh new file mode 100755 index 0000000000..dcfe9f8067 --- /dev/null +++ b/scripts/release/prod/stage/setup/run.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# shellcheck disable=2029 + +# Path(s) are relative to the root of the Jenkins workspace. +INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) +#BUCKET="$1" +BRANCH="$1" + +BUILD_ENV=$(ssh -i ReleaseBuildInstanceKey.pem -o -A ubuntu@"$INSTANCE" cat build_env) +CHANNEL=$(sed -n 's/.*CHANNEL=\(.*\)/\1/p' <<< "$BUILD_ENV") +FULLVERSION=$(sed -n 's/.*FULLVERSION=\(.*\)/\1/p' <<< "$BUILD_ENV") + +rm -rf pkg +mkdir -p pkg/"$FULLVERSION" + +aws s3 sync s3://"$BUCKET"/"$CHANNEL"/"$FULLVERSION" pkg/ --exclude "*" --include "*.deb" --include "*.rpm" +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" mkdir node_pkg +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r pkg/* ubuntu@"$INSTANCE":~/node_pkg/ + +aws s3 cp s3://algorand-devops-misc/tools/gnupg2.2.9_centos7_amd64.tar.bz2 . +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r gnupg2.2.9_centos7_amd64.tar.bz2 ubuntu@"$INSTANCE": + +#scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r scripts/release/prod/stage/setup/task.sh ubuntu@"$INSTANCE": +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r scripts/release/common/setup.sh ubuntu@"$INSTANCE": +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash setup.sh "$BRANCH" "$CHANNEL" "$FULLVERSION" + diff --git a/scripts/release/prod/stage/snapshot.sh b/scripts/release/prod/stage/snapshot.sh new file mode 100755 index 0000000000..bccaf3d5a1 --- /dev/null +++ b/scripts/release/prod/stage/snapshot.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +echo +date "+build_release begin SNAPSHOT stage %Y%m%d_%H%M%S" +echo + +set -ex + +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/prod/deb/snapshot.sh +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/prod/rpm/run_centos.sh + +echo +date "+build_release end SNAPSHOT stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/prod/stage/sync/run.sh b/scripts/release/prod/stage/sync/run.sh new file mode 100755 index 0000000000..c492a509bb --- /dev/null +++ b/scripts/release/prod/stage/sync/run.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# shellcheck disable=2029 + +# Path(s) are relative to the root of the Jenkins workspace. +STAGING="$1" +PROD="$2" +RSTAMP=$(scripts/release/prod/reverse_hex_timestamp) + +BUILD_ENV=$(ssh -i ReleaseBuildInstanceKey.pem -o -A ubuntu@"$INSTANCE" cat build_env) +CHANNEL=$(sed -n 's/.*CHANNEL=\(.*\)/\1/p' <<< "$BUILD_ENV") +RELEASE=$(sed -n 's/.*FULLVERSION=\(.*\)/\1/p' <<< "$BUILD_ENV") + +if ! aws s3 sync s3://"$STAGING"/"$CHANNEL"/"$RELEASE" s3://"$PROD"/"$CHANNEL"/"$RSTAMP"_"$RELEASE" +then + echo There was a problem syncing the staging and production buckets! + exit 1 +fi + diff --git a/scripts/release/socket.sh b/scripts/release/socket.sh new file mode 100755 index 0000000000..d0ec004fd2 --- /dev/null +++ b/scripts/release/socket.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# TODO: ssh-keyscan? +# -o StrictHostKeyChecking=no suppresses the (yes/no) new key ssh question. +# This lessens the security, but it may be acceptable in this case. + +if [ -z "$1" ] +then + echo Missing \`instance\` variable. + exit 1 +fi + +INSTANCE=$1 +gpgp=$(find /usr/lib/gnupg{2,,1} -type f -name gpg-preset-passphrase 2> /dev/null) + +# Here we need to grab the signing subkey, hence `tail -1`. +KEYGRIP=$(gpg -K --with-keygrip --textmode dev@algorand.com | grep Keygrip | tail -1 | awk '{ print $3 }') +echo "enter dev@ password" +$gpgp --verbose --preset "$KEYGRIP" + +KEYGRIP=$(gpg -K --with-keygrip --textmode rpm@algorand.com | grep Keygrip | head -1 | awk '{ print $3 }') +echo "enter rpm@ password" +$gpgp --verbose --preset "$KEYGRIP" + +REMOTE_GPG_SOCKET=$(ssh -o StrictHostKeyChecking=no -i ReleaseBuildInstanceKey.pem ubuntu@"$INSTANCE" gpgbin/remote_gpg_socket) +LOCAL_GPG_SOCKET=$(gpgconf --list-dirs | grep agent-socket | awk -F: '{ print $2 }') + +gpg --export -a dev@algorand.com > /tmp/dev.pub +gpg --export -a rpm@algorand.com > /tmp/rpm.pub + +scp -o StrictHostKeyChecking=no -i ReleaseBuildInstanceKey.pem -p /tmp/{dev,rpm}.pub ubuntu@"$INSTANCE":~/keys/ +ssh -o StrictHostKeyChecking=no -i ReleaseBuildInstanceKey.pem ubuntu@"$INSTANCE" << EOF + gpg --import keys/dev.pub + gpg --import keys/rpm.pub + echo "SIGNING_KEY_ADDR=dev@algorand.com" >> build_env +EOF + +ssh -o StrictHostKeyChecking=no -i ReleaseBuildInstanceKey.pem -A -R "$REMOTE_GPG_SOCKET:$LOCAL_GPG_SOCKET" ubuntu@"$INSTANCE" + diff --git a/scripts/release/test/Jenkinsfile b/scripts/release/test/Jenkinsfile new file mode 100644 index 0000000000..4b83d7f7e6 --- /dev/null +++ b/scripts/release/test/Jenkinsfile @@ -0,0 +1,47 @@ +def REGION = "us-west-1" +def AMI = "ami-0dd655843c87b6930" +def TYPE = "t2.2xlarge" + +pipeline { + parameters { + string defaultValue: 'master', description: 'Branch name or tag name.', name: 'branch', trim: true + } + + environment { + AWS_ACCESS_KEY_ID = credentials("prod-s3-aws-access-key-id") + AWS_SECRET_ACCESS_KEY = credentials("prod-s3-aws-secret-access-key") + } + + agent { + dockerfile { + filename 'scripts/release/common/docker/setup.Dockerfile' + } + } + + stages { + stage("create ec2 instance") { + steps { + sh script: "scripts/release/common/create.sh ${REGION} ${AMI} ${TYPE}" + } + } + + stage("setup") { + steps { + sh script: "scripts/release/test/stage/setup/run.sh ${params.branch}" + } + } + + stage("test") { + steps { + sh script: "scripts/release/test/stage/test/run.sh ${params.branch}" + } + } + + stage("delete ec2 instance") { + steps { + sh script: "scripts/release/common/delete.sh ${REGION}" + } + } + } +} + diff --git a/scripts/release/test/deb/run_ubuntu.sh b/scripts/release/test/deb/run_ubuntu.sh new file mode 100755 index 0000000000..0ea99246eb --- /dev/null +++ b/scripts/release/test/deb/run_ubuntu.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# +# This script exists to give a trap atexit context for killing the httpd so that we're not waiting on that + +set -ex + +cat <"${HOME}"/dummyaptly.conf +{ + "rootDir": "${HOME}/dummyaptly", + "downloadConcurrency": 4, + "downloadSpeedLimit": 0, + "architectures": [], + "dependencyFollowSuggests": false, + "dependencyFollowRecommends": false, + "dependencyFollowAllVariants": false, + "dependencyFollowSource": false, + "dependencyVerboseResolve": false, + "gpgDisableSign": false, + "gpgDisableVerify": false, + "gpgProvider": "gpg", + "downloadSourcePackages": false, + "skipLegacyPool": true, + "ppaDistributorID": "ubuntu", + "ppaCodename": "", + "skipContentsPublishing": false, + "FileSystemPublishEndpoints": {}, + "S3PublishEndpoints": {}, + "SwiftPublishEndpoints": {} +} +EOF + +# Creates ~/dummyaptly/db +"$HOME"/go/bin/aptly -config="${HOME}"/dummyaptly.conf repo create -distribution=stable -component=main algodummy +# Creates ~/dummyaptly/pool +"$HOME"/go/bin/aptly -config="${HOME}"/dummyaptly.conf repo add algodummy "${HOME}"/node_pkg/*.deb +SNAPSHOT=algodummy-$(date +%Y%m%d_%H%M%S) +"$HOME"/go/bin/aptly -config="${HOME}"/dummyaptly.conf snapshot create "${SNAPSHOT}" from repo algodummy +# Creates ~/dummyaptly/public +"$HOME"/go/bin/aptly -config="${HOME}"/dummyaptly.conf publish snapshot -origin=Algorand -label=Algorand "${SNAPSHOT}" + +(cd "${HOME}"/dummyaptly/public && python3 "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/httpd.py --pid "${HOME}"/phttpd.pid) & +trap "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/kill_httpd.sh 0 + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome --mount type=bind,src=${HOME}/go,dst=/root/go --mount type=bind,src=/usr/local/go,dst=/usr/local/go ubuntu:16.04 bash /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/test/deb/test_algorand.sh" + +export DC_IP + +echo "Starting start_docker_debian_test.sh" +GOPATH=${HOME}/go +TEST_NAME="DebianTest" +echo "start docker test: " $TEST_NAME + +echo "DC_IP: $DC_IP" +STATUS=0 + +# run the docker container +sg docker "docker run --rm --env-file ${HOME}/build_env_docker \ + --mount type=bind,src=${GOPATH}/src/github.com/algorand/go-algorand/scripts/release/test,dst=/workdir \ + --mount type=bind,src=${GOPATH}/src/github.com/algorand/go-algorand/test/e2e-go/cli/goal/expect,dst=/expectdir \ + --mount type=bind,src=${GOPATH}/src/github.com/algorand/go-algorand/test/testdata,dst=/testdata \ + --mount type=bind,src=${HOME}/keys,dst=/root/keys \ + debian:stable bash /workdir/deb/test_apt-get.sh" + +STATUS=$? + +echo "start_docker_debian_test completed with status: " $STATUS + +exit $STATUS + diff --git a/scripts/release/test/deb/testDebian.exp b/scripts/release/test/deb/testDebian.exp new file mode 100644 index 0000000000..663b396b2c --- /dev/null +++ b/scripts/release/test/deb/testDebian.exp @@ -0,0 +1,102 @@ +#!/usr/bin/expect -f +set err 0 +log_user 1 + +if { [catch { + set TEST_ALGO_DIR [lindex $argv 0] + set TEST_DATA_DIR [lindex $argv 1] + + puts "TEST_ALGO_DIR: $TEST_ALGO_DIR" + puts "TEST_DATA_DIR: $TEST_DATA_DIR" + + set TIME_STAMP [clock seconds] + + set TEST_ROOT_DIR $TEST_ALGO_DIR/root + set TEST_PRIMARY_NODE_DIR $TEST_ROOT_DIR/Primary/ + set NETWORK_NAME test_net_expect_$TIME_STAMP + set NETWORK_TEMPLATE "$TEST_DATA_DIR/nettemplates/TwoNodes50Each.json" + + set ::GLOBAL_TEST_ALGO_DIR $TEST_ALGO_DIR + set ::GLOBAL_TEST_ROOT_DIR $TEST_ROOT_DIR + set ::GLOBAL_NETWORK_NAME $NETWORK_NAME + + + puts "deb_setup starting" + + + set WORKDIR_LS_OUTPUT [ eval exec ls /workdir ] + puts "workdir ls output: $WORKDIR_LS_OUTPUT" + + source /expectdir/goalExpectCommon.exp + + # Create network + ::AlgorandGoal::StartNetwork $NETWORK_NAME $NETWORK_TEMPLATE $TEST_ALGO_DIR $TEST_ROOT_DIR + + set TEST_ROOT_DIR_LS_OUTPUT [ eval exec ls $TEST_ROOT_DIR ] + puts "TEST_ROOT_DIR_LS_OUTPUT ls output: $TEST_ROOT_DIR_LS_OUTPUT" + + set PRIMARY_NODE_ADDRESS [ ::AlgorandGoal::GetAlgodNetworkAddress $TEST_PRIMARY_NODE_DIR ] + puts "Primary Node Address: $PRIMARY_NODE_ADDRESS" + + set PRIMARY_WALLET_NAME unencrypted-default-wallet + + # Determine primary account + set PRIMARY_ACCOUNT_ADDRESS [::AlgorandGoal::GetHighestFundedAccountForWallet $PRIMARY_WALLET_NAME $TEST_PRIMARY_NODE_DIR] + + # Check the balance of the primary account + set PRIMARY_ACCOUNT_BALANCE [::AlgorandGoal::GetAccountBalance $PRIMARY_WALLET_NAME $PRIMARY_ACCOUNT_ADDRESS $TEST_PRIMARY_NODE_DIR] + puts "Primary Account Balance: $PRIMARY_ACCOUNT_BALANCE" + + # Check the rewards of the primary account + set PRIMARY_ACCOUNT_EARNINGS [::AlgorandGoal::GetAccountRewards $PRIMARY_WALLET_NAME $PRIMARY_ACCOUNT_ADDRESS $TEST_PRIMARY_NODE_DIR] + puts "Primary Account Rewards: $PRIMARY_ACCOUNT_EARNINGS" + + # Create wallet #1 + set WALLET_1_NAME Wallet_1_$TIME_STAMP + set WALLET_1_PASSWORD 1234 + set WALLET_1_PASSPHRASE [::AlgorandGoal::CreateWallet $WALLET_1_NAME $WALLET_1_PASSWORD $TEST_PRIMARY_NODE_DIR] + puts "WALLET_1_PASSPHRASE: $WALLET_1_PASSPHRASE" + ::AlgorandGoal::VerifyWallet $WALLET_1_NAME $TEST_PRIMARY_NODE_DIR + + # Associate a new account with the wallet + set ACCOUNT_1_ADDRESS [::AlgorandGoal::CreateAccountForWallet $WALLET_1_NAME $WALLET_1_PASSWORD $TEST_PRIMARY_NODE_DIR] + ::AlgorandGoal::VerifyAccount $WALLET_1_NAME $WALLET_1_PASSWORD $ACCOUNT_1_ADDRESS $TEST_PRIMARY_NODE_DIR + + # Create wallet #2 + set WALLET_2_NAME Wallet_2_$TIME_STAMP + set WALLET_2_PASSWORD 12345678 + set WALLET_2_PASSPHRASE [::AlgorandGoal::CreateWallet $WALLET_2_NAME $WALLET_2_PASSWORD $TEST_PRIMARY_NODE_DIR] + puts "WALLET_2_PASSPHRASE: $WALLET_2_PASSPHRASE" + ::AlgorandGoal::VerifyWallet $WALLET_2_NAME $TEST_PRIMARY_NODE_DIR + + # Associate a new account with the wallet + set ACCOUNT_2_ADDRESS [::AlgorandGoal::CreateAccountForWallet $WALLET_2_NAME $WALLET_2_PASSWORD $TEST_PRIMARY_NODE_DIR] + ::AlgorandGoal::VerifyAccount $WALLET_2_NAME $WALLET_2_PASSWORD $ACCOUNT_2_ADDRESS $TEST_PRIMARY_NODE_DIR + + # Check the balance of the account + ::AlgorandGoal::WaitForAccountBalance $WALLET_1_NAME $ACCOUNT_1_ADDRESS 0 $TEST_PRIMARY_NODE_DIR + + # Check to make sure that the transfer is reflected in the to account + ::AlgorandGoal::WaitForAccountBalance $WALLET_2_NAME $ACCOUNT_2_ADDRESS 0 $TEST_PRIMARY_NODE_DIR + + # Check the balance of the primary account + set NEW_ACCOUNT_1_BALANCE [::AlgorandGoal::GetAccountBalance $WALLET_1_NAME $ACCOUNT_1_ADDRESS $TEST_PRIMARY_NODE_DIR] + puts "New Account 1 Balance: $NEW_ACCOUNT_1_BALANCE" + + # Check that the from account balance is updated to reflect the transfer and transaction fee + if { $NEW_ACCOUNT_1_BALANCE != 0 } then { puts "Account 1 is not correct, expected 0 , but received $NEW_ACCOUNT_1_BALANCE " ; exit 1 } + + # Delete an account + ::AlgorandGoal::DeleteAccount $WALLET_1_NAME $ACCOUNT_1_ADDRESS + + # Shutdown the network + ::AlgorandGoal::StopNetwork $NETWORK_NAME $TEST_ALGO_DIR $TEST_ROOT_DIR + + puts "Basic Goal Test Successful" + + exit 0 + +} EXCEPTION ] } { + puts "Exception: $EXCEPTION" + exit 1 +} diff --git a/scripts/release/test/deb/test_algorand.sh b/scripts/release/test/deb/test_algorand.sh new file mode 100755 index 0000000000..ad117da066 --- /dev/null +++ b/scripts/release/test/deb/test_algorand.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -ex + +export GOPATH=${HOME}/go +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} + +apt-get update +apt-get install -y gnupg2 curl software-properties-common python3 + +apt-get install -y /root/subhome/node_pkg/*.deb +algod -v + +mkdir -p /root/testnode +cp -p /var/lib/algorand/genesis/testnet/genesis.json /root/testnode + +goal node start -d /root/testnode +goal node wait -d /root/testnode -w 120 +goal node stop -d /root/testnode + +apt-key add /root/keys/dev.pub +apt-key add /root/keys/rpm.pub +add-apt-repository "deb http://${DC_IP}:8111/ stable main" +apt-get update +apt-get install -y algorand +algod -v +# check that the installed version is now the current version +algod -v | grep -q "${FULLVERSION}.${CHANNEL}" + +if [ ! -d /root/testnode ]; then + mkdir -p /root/testnode + cp -p /var/lib/algorand/genesis/testnet/genesis.json /root/testnode +fi + +goal node start -d /root/testnode +goal node wait -d /root/testnode -w 120 +goal node stop -d /root/testnode + +echo UBUNTU_DOCKER_TEST_OK + diff --git a/scripts/release/test/deb/test_apt-get.sh b/scripts/release/test/deb/test_apt-get.sh new file mode 100755 index 0000000000..e177ccb3cc --- /dev/null +++ b/scripts/release/test/deb/test_apt-get.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +#set -xv + +echo "test_apt-get starting within docker container" + +export GOPATH=${HOME}/go +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} + +apt-get update +apt-get install -y gnupg2 curl software-properties-common python3 +apt-key add /root/keys/dev.pub +add-apt-repository -y "deb [trusted=yes] http://${DC_IP}:8111/ stable main" +apt-get update +apt-get install -y algorand +apt-get install -y expect + +algod -v + +echo "starting test of algod with expect script testDebian.exp" +OUTPUT=$(expect -d /workdir/deb/testDebian.exp /var/lib/algorand /testdata) +STATUS=$? +echo "$OUTPUT" + +echo "test_apt-get completed with status: " $STATUS + +exit $STATUS + diff --git a/scripts/release/test/gpg-fake.sh b/scripts/release/test/gpg-fake.sh new file mode 100755 index 0000000000..756f108fcf --- /dev/null +++ b/scripts/release/test/gpg-fake.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# shellcheck disable=2012 + +set -ex + +echo +date "+build_release begin GPG SETUP stage %Y%m%d_%H%M%S" +echo + +cat <"${HOME}/gpgbin/remote_gpg_socket" +export GOPATH=\${HOME}/go +export PATH=\${HOME}/gpgbin:${GOPATH}/bin:/usr/local/go/bin:${PATH} +gpgconf --list-dirs | grep agent-socket | awk -F: '{ print \$2 }' +EOF + +chmod +x "${HOME}/gpgbin/remote_gpg_socket" + +# This real name and email must precisely match GPG key +git config --global user.name "Algorand developers" +git config --global user.email dev@algorand.com + +# configure GnuPG to rely on forwarded remote gpg-agent +umask 0077 +touch "${HOME}/.gnupg/gpg.conf" +if grep -q no-autostart "${HOME}/.gnupg/gpg.conf"; then + echo "" +else + echo "no-autostart" >> "${HOME}/.gnupg/gpg.conf" +fi + +umask 0002 + +gpgconf --launch gpg-agent + +GNUPGHOME="${HOME}"/.gnupg +gpgconf --kill gpg-agent +chmod 700 "${GNUPGHOME}" + +cat > "${GNUPGHOME}"/keygenscript < "${GNUPGHOME}"/rpmkeygenscript < "${GNUPGHOME}"/gpg-agent.conf +# Only needed for gpg < 2.1.17 (https://wiki.gnupg.org/AgentForwarding) +#extra-socket "${HOME}"/S.gpg-agent.extra +# Enable unattended daemon mode. +allow-preset-passphrase +# Cache password 30 days. +default-cache-ttl 2592000 +max-cache-ttl 2592000 +EOF + +# Added 2020-01-20 +gpgconf --launch gpg-agent + +gpg --gen-key --batch "${GNUPGHOME}"/keygenscript +gpg --gen-key --batch "${GNUPGHOME}"/rpmkeygenscript +gpg --export -a dev@algorand.com > "${HOME}/keys/dev.pub" +gpg --export -a rpm@algorand.com > "${HOME}/keys/rpm.pub" + +gpgconf --kill gpg-agent +gpgconf --launch gpg-agent + +gpgp=$(ls /usr/lib/gnupg{2,,1}/gpg-preset-passphrase | head -1) +for name in {dev,rpm} +do + KEYGRIP=$(gpg -K --with-keygrip --textmode "$name"@algorand.com | grep Keygrip | head -1 | awk '{ print $3 }') + echo foogorand | "${gpgp}" --verbose --preset "${KEYGRIP}" +done + +echo +date "+build_release end GPG SETUP stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/test/rpm/run_centos.sh b/scripts/release/test/rpm/run_centos.sh new file mode 100755 index 0000000000..0277bc5e3b --- /dev/null +++ b/scripts/release/test/rpm/run_centos.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# shellcheck disable=1090 + +set -ex + +. "${HOME}"/build_env + +echo +date "+build_release begin TEST stage %Y%m%d_%H%M%S" +echo + +# Run RPM build in Centos7 Docker container +sg docker "docker build -t algocentosbuild - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile" + +cat <"${HOME}"/dummyrepo/algodummy.repo +[algodummy] +name=Algorand +baseurl=http://${DC_IP}:8111/ +enabled=1 +gpgcheck=1 +gpgkey=https://releases.algorand.com/rpm/rpm_algorand.pub +EOF + +cd "${HOME}"/dummyrepo && python3 "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/httpd.py --pid "${HOME}"/phttpd.pid & +trap "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/kill_httpd.sh 0 + +sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/dummyrepo,dst=/root/dummyrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/test/rpm/test_algorand.sh" + +echo +date "+build_release end TEST stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/test/rpm/test_algorand.sh b/scripts/release/test/rpm/test_algorand.sh new file mode 100755 index 0000000000..57c774a124 --- /dev/null +++ b/scripts/release/test/rpm/test_algorand.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# shellcheck disable=1090,2012 + +set -ex + +export HOME=/root + +cd "${HOME}" && tar jxf "${HOME}"/subhome/gnupg*.tar.bz2 +export PATH="${HOME}/gnupg2/bin:${PATH}" +export LD_LIBRARY_PATH=${HOME}/gnupg2/lib + +umask 0077 +mkdir -p "${HOME}/.gnupg" +umask 0022 +touch "${HOME}/.gnupg/gpg.conf" + +if grep -q no-autostart "${HOME}/.gnupg/gpg.conf" +then + echo "" +else + echo "no-autostart" >> "${HOME}/.gnupg/gpg.conf" +fi + +rm -f ${HOME}/.gnupg/S.gpg-agent +cd "${HOME}"/.gnupg && ln -s "${HOME}"/S.gpg-agent S.gpg-agent + +gpg --import /root/keys/dev.pub +gpg --import /root/keys/rpm.pub +rpmkeys --import /root/keys/rpm.pub +echo "wat" | gpg -u rpm@algorand.com --clearsign + +cat <"${HOME}/.rpmmacros" +%_gpg_name Algorand RPM +%__gpg ${HOME}/gnupg2/bin/gpg +%__gpg_check_password_cmd true +EOF + +cat <"${HOME}/rpmsign.py" +import rpm +import sys +rpm.addSign(sys.argv[1], '') +EOF + +NEWEST_RPM=$(ls -t /root/subhome/node_pkg/*.rpm | head -1) +python2 "${HOME}/rpmsign.py" "${NEWEST_RPM}" + +cp -p "${NEWEST_RPM}" /root/dummyrepo +createrepo --database /root/dummyrepo +rm -f /root/dummyrepo/repodata/repomd.xml.asc +gpg -u rpm@algorand.com --detach-sign --armor /root/dummyrepo/repodata/repomd.xml + +OLDRPM=$(ls -t /root/subhome/node_pkg/*.rpm | head -1) +if [ -f "${OLDRPM}" ]; then + yum install -y "${OLDRPM}" + algod -v + + mkdir -p /root/testnode + cp -p /var/lib/algorand/genesis/testnet/genesis.json /root/testnode + + goal node start -d /root/testnode + goal node wait -d /root/testnode -w 120 + goal node stop -d /root/testnode +fi + +yum-config-manager --add-repo "http://${DC_IP}:8111/algodummy.repo" + +yum install -y algorand +algod -v +# check that the installed version is now the current version +algod -v | grep -q "${FULLVERSION}.${CHANNEL}" + +if [ ! -d /root/testnode ]; then + mkdir -p /root/testnode + cp -p /var/lib/algorand/genesis/testnet/genesis.json /root/testnode +fi + +goal node start -d /root/testnode +goal node wait -d /root/testnode -w 120 +goal node stop -d /root/testnode + +echo CENTOS_DOCKER_TEST_OK + diff --git a/scripts/release/test/stage/setup/run.sh b/scripts/release/test/stage/setup/run.sh new file mode 100755 index 0000000000..c2f905cdb2 --- /dev/null +++ b/scripts/release/test/stage/setup/run.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# shellcheck disable=2029 + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. +INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) +BRANCH="$1" + +aws s3 cp s3://algorand-devops-misc/tools/gnupg2.2.9_centos7_amd64.tar.bz2 . +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r gnupg2.2.9_centos7_amd64.tar.bz2 ubuntu@"$INSTANCE": + +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r scripts/release/common/setup.sh ubuntu@"$INSTANCE": +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash setup.sh "$BRANCH" + +BUILD_ENV=$(ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" cat build_env) +CHANNEL=$(sed -n 's/.*CHANNEL=\(.*\)/\1/p' <<< "$BUILD_ENV") +RELEASE=$(sed -n 's/.*FULLVERSION=\(.*\)/\1/p' <<< "$BUILD_ENV") + +rm -rf pkg/* && mkdir -p pkg/"$FULLVERSION" + +#aws s3 sync s3://"$BUCKET"/"$CHANNEL"/"$RELEASE" pkg/ --exclude "*" --include "*.deb" --include "*.rpm" +aws s3 sync s3://ben-test-2.0.3/"$CHANNEL"/"$RELEASE" pkg/ --exclude "*" --include "*.deb" --include "*.rpm" + +# Upload the packages and their signatures. +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no -r pkg/* ubuntu@"$INSTANCE":~/node_pkg/ + diff --git a/scripts/release/test/stage/test/run.sh b/scripts/release/test/stage/test/run.sh new file mode 100755 index 0000000000..24e6c41fd1 --- /dev/null +++ b/scripts/release/test/stage/test/run.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -ex + +# Path(s) are relative to the root of the Jenkins workspace. + +INSTANCE=$(cat scripts/release/common/ec2/tmp/instance) +BUILD_ENV=$(ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" cat build_env) +CHANNEL=$(sed -n 's/.*CHANNEL=\(.*\)/\1/p' <<< "$BUILD_ENV") +RELEASE=$(sed -n 's/.*FULLVERSION=\(.*\)/\1/p' <<< "$BUILD_ENV") + +rm -rf ./*.deb ./*.rpm +python3 scripts/get_current_installers.py "s3://ben-test-2.0.3/$CHANNEL/$RELEASE" + +# Copy previous installers into ~. +scp -i ReleaseBuildInstanceKey.pem -o StrictHostKeyChecking=no ./*.deb ubuntu@"$INSTANCE": +ssh -i ReleaseBuildInstanceKey.pem -A ubuntu@"$INSTANCE" bash go/src/github.com/algorand/go-algorand/scripts/release/test/stage/test/task.sh + diff --git a/scripts/release/test/stage/test/task.sh b/scripts/release/test/stage/test/task.sh new file mode 100755 index 0000000000..1e6ac52d1b --- /dev/null +++ b/scripts/release/test/stage/test/task.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Create and export the fake keys used by the local test repos. + +set -ex + +echo +date "+build_release begin TEST stage %Y%m%d_%H%M%S" +echo + +echo Setup GPG +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/test/gpg-fake.sh + +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/test/deb/run_ubuntu.sh +date "+build_release done testing ubuntu %Y%m%d_%H%M%S" + +"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/test/rpm/run_centos.sh +date "+build_release done testing centos %Y%m%d_%H%M%S" + +echo +date "+build_release end TEST stage %Y%m%d_%H%M%S" +echo + diff --git a/scripts/release/util/check_sig.sh b/scripts/release/util/check_sig.sh new file mode 100755 index 0000000000..fdbe45426c --- /dev/null +++ b/scripts/release/util/check_sig.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# shellcheck disable=2045 + +if [ $# -ne 1 ] +then + echo "Usage: $0 " + exit 1 +fi + +GREEN_FG=$(tput setaf 2 2>/dev/null) +RED_FG=$(tput setaf 1 2>/dev/null) +END_FG_COLOR=$(tput sgr0 2>/dev/null) +RETVAL=0 + +pushd "$1" > /dev/null + +for file in $(ls ./*.{gz,deb,rpm}) +do + key_id=dev@algorand.com + + # Check the filename extension. + if [ "${file##*.}" == "rpm" ] + then + key_id=rpm@algorand.com + fi + + if ! gpg -u "$key_id" --verify "$file".sig "$file" + then + echo -e "$RED_FG[$0]$END_FG_COLOR Could not verify signature for $file" + RETVAL=1 + fi +done + +popd > /dev/null + +if [ $RETVAL -eq 0 ] +then + echo -e "$GREEN_FG[$0]$END_FG_COLOR All signatures have been verified as good." +fi + +exit $RETVAL + diff --git a/scripts/release/util/smoke_test.sh b/scripts/release/util/smoke_test.sh new file mode 100755 index 0000000000..5f9b595e88 --- /dev/null +++ b/scripts/release/util/smoke_test.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# This is currently used by `test_package.sh`. +# It is copied into a docker image at build time and then invoked at run time. + +GREEN_FG=$(tput setaf 2 2>/dev/null) +RED_FG=$(tput setaf 1 2>/dev/null) +YELLOW_FG=$(tput setaf 3 2>/dev/null) +END_FG_COLOR=$(tput sgr0 2>/dev/null) + +BRANCH= +CHANNEL=stable +HASH= +RELEASE= + +while [ "$1" != "" ]; do + case "$1" in + -b) + shift + BRANCH="$1" + ;; + -c) + shift + CHANNEL="$1" + ;; + -h) + shift + HASH="$1" + ;; + -r) + shift + RELEASE="$1" + ;; + *) + echo "Unknown option" "$1" + exit 1 + ;; + esac + shift +done + +if [ -z "$BRANCH" ] || [ -z "$HASH" ] || [ -z "$RELEASE" ] +then + echo "$YELLOW_FG[Usage]$END_FG_COLOR $0 -b BRANCH -c CHANNEL -h HASH -r RELEASE" + exit 1 +fi + +echo "[$0] Testing: algod -v" +if < /etc/os-release grep Ubuntu > /dev/null +then + dpkg -i ./*.deb +else + yum install ./*.rpm -y +fi + +STR=$(algod -v) +SHORT_HASH=${HASH:0:8} + +# We're looking for a line that looks like the following: +# +# 2.0.4.stable [rel/stable] (commit #729b125a) +# +# Since we're passing in the full hash, we won't using the closing paren. +# Use a regex over the multi-line string. +if [[ "$STR" =~ .*"$RELEASE.$CHANNEL [$BRANCH] (commit #$SHORT_HASH)".* ]] +then + echo "$GREEN_FG[$0]$END_FG_COLOR The result of \`algod -v\` is a correct match." + exit 0 +fi + +echo "$RED_FG[$0]$END_FG_COLOR The result of \`algod -v\` is an incorrect match." +exit 1 + diff --git a/scripts/release/util/test_package.sh b/scripts/release/util/test_package.sh new file mode 100755 index 0000000000..2b6672d52d --- /dev/null +++ b/scripts/release/util/test_package.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash + +# TODO: use `trap` instead of cleanup function? + +GREEN_FG=$(tput setaf 2 2>/dev/null) +RED_FG=$(tput setaf 1 2>/dev/null) +TEAL_FG=$(tput setaf 6 2>/dev/null) +YELLOW_FG=$(tput setaf 3 2>/dev/null) +END_FG_COLOR=$(tput sgr0 2>/dev/null) + +# TODO: The following error happens on centos:8 +# +# Error: +# Problem: conflicting requests +# - nothing provides yum-cron needed by algorand-2.0.4-1.x86_64 +# (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) +# smoke_test.sh: line 47: algod: command not found + +OS_LIST=( + centos:7 +# centos:8 + fedora:28 + ubuntu:16.04 + ubuntu:18.04 +) + +BRANCH= +CHANNEL=stable +HASH= +RELEASE= +FAILED=() + +while [ "$1" != "" ]; do + case "$1" in + -b) + shift + BRANCH="$1" + ;; + -c) + shift + CHANNEL="$1" + ;; + -h) + shift + HASH="$1" + ;; + -r) + shift + RELEASE="$1" + ;; + *) + echo "$RED_FG[$0]$END_FG_COLOR Unknown option $1" + exit 1 + ;; + esac + shift +done + +if [ -z "$BRANCH" ] || [ -z "$HASH" ] || [ -z "$RELEASE" ] +then + echo "$YELLOW_FG[Usage]$END_FG_COLOR $0 -b BRANCH -c CHANNEL -h HASH -r RELEASE" + exit 1 +fi + +build_images () { + # We'll use this simple tokenized Dockerfile. + # https://serverfault.com/a/72511 + IFS='' read -r -d '' TOKENIZED < Dockerfile + if ! docker build -t "${item}-smoke-test" . + then + FAILED+=("$item") + fi + done +} + +run_images () { + for item in ${OS_LIST[*]} + do + echo "$TEAL_FG[$0]$END_FG_COLOR Running ${item}-test..." + if ! docker run --rm --name algorand -t "${item}-smoke-test" bash smoke_test.sh -b "$BRANCH" -c "$CHANNEL" -h "$HASH" -r "$RELEASE" + then + FAILED+=("$item") + fi + done +} + +cleanup() { + rm -f Dockerfile +} + +check_failures() { + if [ "${#FAILED[@]}" -gt 0 ] + then + echo -e "\n$RED_FG[$0]$END_FG_COLOR The following images could not be $1:" + + for failed in ${FAILED[*]} + do + echo " - $failed" + done + + echo + + cleanup + exit 1 + fi +} + +build_images +check_failures built +echo "$GREEN_FG[$0]$END_FG_COLOR Builds completed with no failures." + +run_images +check_failures verified +echo "$GREEN_FG[$0]$END_FG_COLOR Runs completed with no failures." + +cleanup + diff --git a/scripts/travis/after_build.sh b/scripts/travis/after_build.sh index cbe2609e56..dc095da927 100755 --- a/scripts/travis/after_build.sh +++ b/scripts/travis/after_build.sh @@ -10,10 +10,15 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" OS=$("${SCRIPTPATH}/../ostype.sh") +ARCH=$("${SCRIPTPATH}/../archtype.sh") if [[ "${OS}" == "darwin" ]]; then # do not run these on darwin exit; fi; +if [[ "${ARCH}" == "arm64" ]]; then + # do not run these on arm64 + exit; +fi; if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [[ "${TRAVIS_BRANCH}" =~ ^rel/ ]]; then if [ "${BUILD_TYPE}" != "integration" ]; then diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 06ce8f7368..ddf54989cb 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -64,6 +64,13 @@ if [ "${OS}-${ARCH}" = "linux-arm" ]; then fi if [ "${MAKE_DEBUG_OPTION}" != "" ]; then + # Force re-generation of msgpack encoders/decoders with msgp. If this re-generated code + # does not match the checked-in code, some structs may have been added or updated without + # refreshing the generated codecs. The enlistment check below will error out, if so. + # we want to have that only on system where we have some debugging abilities. Platforms that do not support + # debugging ( i.e. arm ) are also usually under powered and making this extra step + # would be very costly there. + make msgp make build build-race else make build @@ -74,6 +81,7 @@ echo Checking Enlistment... if [[ -n $(git status --porcelain) ]]; then echo Enlistment is dirty - did you forget to run make? git status -s + git diff exit 1 else echo Enlistment is clean diff --git a/scripts/travis/run_tests.sh b/scripts/travis/run_tests.sh index 24b77081e1..7d8937084e 100755 --- a/scripts/travis/run_tests.sh +++ b/scripts/travis/run_tests.sh @@ -4,6 +4,7 @@ set -e SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" OS=$("${SCRIPTPATH}/../ostype.sh") +ARCH=$("${SCRIPTPATH}/../archtype.sh") if [ "${BUILD_TYPE}" = "integration" ]; then # Run short tests when doing pull requests; leave the long testing for nightly runs. @@ -15,7 +16,7 @@ if [ "${BUILD_TYPE}" = "integration" ]; then export SHORTTEST ./test/scripts/run_integration_tests.sh elif [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [[ "${TRAVIS_BRANCH}" =~ ^rel/ ]]; then - if [[ "${OS}" != "darwin" ]]; then + if [ "${OS}" != "darwin" ] && [ "${ARCH}" != "arm64" ]; then make fulltest -j4 fi else