diff --git a/pkg/core/state/contract.go b/pkg/core/state/contract.go index cd17f23b0..1ad7703ed 100644 --- a/pkg/core/state/contract.go +++ b/pkg/core/state/contract.go @@ -93,12 +93,16 @@ func (c *Contract) FromStackItem(item stackitem.Item) error { if err != nil { return err } - c.NEF, err = nef.FileFromBytes(bytes) + skipCheck := false + if c.UpdateCounter > 0 { + skipCheck = true + } + c.NEF, err = nef.FileFromBytes(bytes, skipCheck) if err != nil { return err } m := new(manifest.Manifest) - err = m.FromStackItem(arr[4]) + err = m.FromStackItem(arr[4], skipCheck) if err != nil { return err } diff --git a/pkg/smartcontract/manifest/manifest.go b/pkg/smartcontract/manifest/manifest.go index 3f5ac8417..bfde4dcd3 100644 --- a/pkg/smartcontract/manifest/manifest.go +++ b/pkg/smartcontract/manifest/manifest.go @@ -206,13 +206,13 @@ func extraToStackItem(rawExtra []byte) stackitem.Item { } // FromStackItem converts stackitem.Item to Manifest. -func (m *Manifest) FromStackItem(item stackitem.Item) error { +func (m *Manifest) FromStackItem(item stackitem.Item, skipCheck ...bool) error { var err error if item.Type() != stackitem.StructT { return errors.New("invalid Manifest stackitem type") } str := item.Value().([]stackitem.Item) - if len(str) != 8 { + if (len(skipCheck) == 0 || !skipCheck[0]) && len(str) != 8 { return errors.New("invalid stackitem length") } m.Name, err = stackitem.ToString(str[0]) diff --git a/pkg/smartcontract/nef/nef.go b/pkg/smartcontract/nef/nef.go index 9d8091210..2aa1050e0 100644 --- a/pkg/smartcontract/nef/nef.go +++ b/pkg/smartcontract/nef/nef.go @@ -184,9 +184,9 @@ func (n File) bytes(checkSize bool) ([]byte, error) { } // FileFromBytes returns a NEF File deserialized from the given bytes. -func FileFromBytes(source []byte) (File, error) { +func FileFromBytes(source []byte, skipCheck ...bool) (File, error) { result := File{} - if len(source) > stackitem.MaxSize { + if len(source) > stackitem.MaxSize && (len(skipCheck) == 0 || !skipCheck[0]) { return result, fmt.Errorf("invalid NEF file size: expected %d at max, got %d", stackitem.MaxSize, len(source)) } r := io.NewBinReaderFromBuf(source)