diff --git a/pkg/core/native/management.go b/pkg/core/native/management.go index de167ab82..083829570 100644 --- a/pkg/core/native/management.go +++ b/pkg/core/native/management.go @@ -322,6 +322,9 @@ func (m *Management) Update(d dao.DAO, hash util.Uint160, neff *nef.File, manif } // if manifest was provided, update the contract manifest if manif != nil { + if manif.Name != contract.Manifest.Name { + return nil, errors.New("contract name can't be changed") + } if !manif.IsValid(contract.Hash) { return nil, errors.New("invalid manifest for this contract") } diff --git a/pkg/core/native_management_test.go b/pkg/core/native_management_test.go index 359bd4c2f..11c2742fa 100644 --- a/pkg/core/native_management_test.go +++ b/pkg/core/native_management_test.go @@ -375,6 +375,17 @@ func TestContractUpdate(t *testing.T) { checkFAULTState(t, res) }) + t.Run("change name", func(t *testing.T) { + var badManifest = cs1.Manifest + badManifest.Name += "tail" + manifB, err := json.Marshal(badManifest) + require.NoError(t, err) + + res, err := invokeContractMethod(bc, 10_00000000, cs1.Hash, "update", nef1b, manifB) + require.NoError(t, err) + checkFAULTState(t, res) + }) + cs1.NEF.Script = append(cs1.NEF.Script, byte(opcode.RET)) cs1.NEF.Checksum = cs1.NEF.CalculateChecksum() nef1b, err = cs1.NEF.Bytes()