From 28a325efe6f3628ebde7ef335b609882dc5cef78 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Fri, 13 Dec 2019 00:00:20 +0100 Subject: [PATCH] soft fail messages that cause precomitted sectors map to become too large --- api/cbor_gen.go | 2 +- chain/actors/actor_miner.go | 4 ++++ chain/actors/cbor_gen.go | 10 +++++++++- chain/blocksync/cbor_gen.go | 2 +- chain/deals/cbor_gen.go | 2 +- chain/types/cbor_gen.go | 2 +- go.mod | 2 +- go.sum | 2 ++ paych/cbor_gen.go | 2 +- retrieval/cbor_gen.go | 2 +- storage/cbor_gen.go | 2 +- 11 files changed, 23 insertions(+), 9 deletions(-) diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 7e1192037..8d309a6cc 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -9,7 +9,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index 3360f5e25..59ccf0b2a 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -264,6 +264,10 @@ func (sma StorageMinerActor) PreCommitSector(act *types.Actor, vmctx types.VMCon ReceivedEpoch: vmctx.BlockHeight(), } + if len(self.PreCommittedSectors) > 4096 { + return nil, aerrors.New(5, "too many precommitted sectors") + } + nstate, err := vmctx.Storage().Put(self) if err != nil { return nil, err diff --git a/chain/actors/cbor_gen.go b/chain/actors/cbor_gen.go index 83582a44b..0629d0b49 100644 --- a/chain/actors/cbor_gen.go +++ b/chain/actors/cbor_gen.go @@ -12,7 +12,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf @@ -204,6 +204,10 @@ func (t *StorageMinerActorState) MarshalCBOR(w io.Writer) error { // t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map) { + if len(t.PreCommittedSectors) > 4096 { + return xerrors.Errorf("cannot marshal t.PreCommittedSectors map too large") + } + if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.PreCommittedSectors))); err != nil { return err } @@ -1979,6 +1983,10 @@ func (t *PaymentChannelActorState) MarshalCBOR(w io.Writer) error { // t.LaneStates (map[string]*actors.LaneState) (map) { + if len(t.LaneStates) > 4096 { + return xerrors.Errorf("cannot marshal t.LaneStates map too large") + } + if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.LaneStates))); err != nil { return err } diff --git a/chain/blocksync/cbor_gen.go b/chain/blocksync/cbor_gen.go index 8e2627cb7..341125bfd 100644 --- a/chain/blocksync/cbor_gen.go +++ b/chain/blocksync/cbor_gen.go @@ -10,7 +10,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/chain/deals/cbor_gen.go b/chain/deals/cbor_gen.go index 5d175fc72..1251267f5 100644 --- a/chain/deals/cbor_gen.go +++ b/chain/deals/cbor_gen.go @@ -11,7 +11,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 5bf2ffce8..57001aa16 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -10,7 +10,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/go.mod b/go.mod index 942e2f284..9919fd624 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect github.com/stretchr/testify v1.4.0 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba - github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa + github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d go.opencensus.io v0.22.1 diff --git a/go.sum b/go.sum index 45d7afb48..dfe738c50 100644 --- a/go.sum +++ b/go.sum @@ -590,6 +590,8 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d h1:NRa/Vs7+ github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa h1:iuIvC21JR4TcHtdCtkXz2jG8KCAK9ZJQQQxbDkFxkNE= github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= +github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a h1:xc8sbWMwBsvi8OrxFZR8zxw/fdCneHBLFDJJaV14eaE= +github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= diff --git a/paych/cbor_gen.go b/paych/cbor_gen.go index b281bc755..abe1d135f 100644 --- a/paych/cbor_gen.go +++ b/paych/cbor_gen.go @@ -9,7 +9,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/retrieval/cbor_gen.go b/retrieval/cbor_gen.go index f7a6279a9..3bf65c60e 100644 --- a/retrieval/cbor_gen.go +++ b/retrieval/cbor_gen.go @@ -8,7 +8,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf diff --git a/storage/cbor_gen.go b/storage/cbor_gen.go index 94a0bfb0d..43262ad2b 100644 --- a/storage/cbor_gen.go +++ b/storage/cbor_gen.go @@ -8,7 +8,7 @@ import ( xerrors "golang.org/x/xerrors" ) -/* This file was generated by github.com/whyrusleeping/cbor-gen */ +// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. var _ = xerrors.Errorf