*: drop Publish transaction type

It shouldn't be used even in NEO 2 as it was substituted by contract
deployment interop functions.
This commit is contained in:
Roman Khimov 2020-04-16 14:40:20 +03:00
parent e29d881901
commit 4912e4f425
17 changed files with 0 additions and 269 deletions

View file

@ -26,7 +26,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: false

View file

@ -17,7 +17,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -17,7 +17,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -11,7 +11,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -17,7 +17,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -17,7 +17,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -17,7 +17,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -26,7 +26,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 10
IssueTransaction: 5
PublishTransaction: 5
RegisterTransaction: 100
VerifyBlocks: true
VerifyTransactions: false

View file

@ -16,7 +16,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -62,7 +62,6 @@ ProtocolConfiguration:
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
PublishTransaction: 500
RegisterTransaction: 10000
ApplicationConfiguration:

View file

@ -49,7 +49,6 @@ type (
SystemFee struct {
EnrollmentTransaction int64 `yaml:"EnrollmentTransaction"`
IssueTransaction int64 `yaml:"IssueTransaction"`
PublishTransaction int64 `yaml:"PublishTransaction"`
RegisterTransaction int64 `yaml:"RegisterTransaction"`
}
@ -80,8 +79,6 @@ func (s SystemFee) TryGetValue(txType transaction.TXType) util.Fixed8 {
return util.Fixed8FromInt64(s.EnrollmentTransaction)
case transaction.IssueType:
return util.Fixed8FromInt64(s.IssueTransaction)
case transaction.PublishType:
return util.Fixed8FromInt64(s.PublishTransaction)
case transaction.RegisterType:
return util.Fixed8FromInt64(s.RegisterTransaction)
default:

View file

@ -19,7 +19,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm"
@ -637,25 +636,6 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
if err := processStateTX(cache, t); err != nil {
return err
}
case *transaction.PublishTX:
var properties smartcontract.PropertyState
if t.NeedStorage {
properties |= smartcontract.HasStorage
}
contract := &state.Contract{
Script: t.Script,
ParamList: t.ParamList,
ReturnType: t.ReturnType,
Properties: properties,
Name: t.Name,
CodeVersion: t.CodeVersion,
Author: t.Author,
Email: t.Email,
Description: t.Description,
}
if err := cache.PutContractState(contract); err != nil {
return err
}
case *transaction.InvocationTX:
systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx)
v := SpawnVM(systemInterop)

View file

@ -13,8 +13,6 @@ var (
rawClaimTX = "020004bc67ba325d6412ff4c55b10f7e9afb54bbb2228d201b37363c3d697ac7c198f70300591cd454d7318d2087c0196abfbbd1573230380672f0f0cd004dcb4857e58cbd010031bcfbed573f5318437e95edd603922a4455ff3326a979fdd1c149a84c4cb0290000b51eb6159c58cac4fe23d90e292ad2bcb7002b0da2c474e81e1889c0649d2c490000000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c603b555f00000000005d9de59d99c0d1f6ed1496444473f4a0b538302f014140456349cec43053009accdb7781b0799c6b591c812768804ab0a0b56b5eae7a97694227fcd33e70899c075848b2cee8fae733faac6865b484d3f7df8949e2aadb232103945fae1ed3c31d778f149192b76734fcc951b400ba3598faa81ff92ebe477eacac"
// https://neotracker.io/tx/fe4b3af60677204c57e573a57bdc97bc5059b05ad85b1474f84431f88d910f64
rawInvocationTX = "d101590400b33f7114839c33710da24cf8e7d536b8d244f3991cf565c8146063795d3b9b3cd55aef026eae992b91063db0db53c1087472616e7366657267c5cc1cb5392019e2cc4e6d6b5ea54c8d4b6d11acf166cb072961424c54f6000000000000000001206063795d3b9b3cd55aef026eae992b91063db0db0000014140c6a131c55ca38995402dff8e92ac55d89cbed4b98dfebbcb01acbc01bd78fa2ce2061be921b8999a9ab79c2958875bccfafe7ce1bbbaf1f56580815ea3a4feed232102d41ddce2c97be4c9aa571b8a32cbc305aa29afffbcae71b0ef568db0e93929aaac"
// https://neoscan-testnet.io/transaction/5467A1FC8723CEFFA8E5EE59399B02EEA1DF6FBAA53768C6704B90B960D223FA
rawPublishTX = "d000fd3f01746b4c04000000004c04000000004c040000000061681e416e745368617265732e426c6f636b636861696e2e476574486569676874681d416e745368617265732e426c6f636b636861696e2e476574426c6f636b744c0400000000948c6c766b947275744c0402000000936c766b9479744c0400000000948c6c766b9479681d416e745368617265732e4865616465722e47657454696d657374616d70a0744c0401000000948c6c766b947275744c0401000000948c6c766b9479641b004c0400000000744c0402000000948c6c766b947275623000744c0401000000936c766b9479744c0400000000936c766b9479ac744c0402000000948c6c766b947275620300744c0402000000948c6c766b947961748c6c766b946d748c6c766b946d748c6c766b946d746c768c6b946d746c768c6b946d746c768c6b946d6c75660302050001044c6f636b0c312e302d70726576696577310a4572696b205a68616e67126572696b40616e747368617265732e6f7267234c6f636b20796f75722061737365747320756e74696c20612074696d657374616d702e00014e23ac4c4851f93407d4c59e1673171f39859db9e7cac72540cd3cc1ae0cca87000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c6000ebcaaa0d00000067f97110a66136d38badc7b9f88eab013027ce49014140c298da9f06d5687a0bb87ea3bba188b7dcc91b9667ea5cb71f6fdefe388f42611df29be9b2d6288655b9f2188f46796886afc3b37d8b817599365d9e161ecfb62321034b44ed9c8a88fb2497b6b57206cc08edd42c5614bd1fee790e5b795dee0f4e11ac"
)
func decodeTransaction(rawTX string, t *testing.T) *Transaction {

View file

@ -1,101 +0,0 @@
package transaction
import (
"math/rand"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util"
)
// PublishTX represents a publish transaction.
// NOTE: This is deprecated and should no longer be used.
type PublishTX struct {
Script []byte
ParamList []smartcontract.ParamType
ReturnType smartcontract.ParamType
NeedStorage bool
Name string
CodeVersion string
Author string
Email string
Description string
Version uint8 // Version of the parent struct Transaction. Used in reading NeedStorage flag.
}
// NewPublishTX creates Transaction of PublishType type.
func NewPublishTX(publish *PublishTX) *Transaction {
return &Transaction{
Type: PublishType,
Version: 0,
Nonce: rand.Uint32(),
Data: publish,
Attributes: []Attribute{},
Inputs: []Input{},
Outputs: []Output{},
Scripts: []Witness{},
Trimmed: false,
}
}
// DecodeBinary implements Serializable interface.
func (tx *PublishTX) DecodeBinary(br *io.BinReader) {
tx.Script = br.ReadVarBytes()
lenParams := br.ReadVarUint()
tx.ParamList = make([]smartcontract.ParamType, lenParams)
for i := 0; i < int(lenParams); i++ {
tx.ParamList[i] = smartcontract.ParamType(br.ReadB())
}
tx.ReturnType = smartcontract.ParamType(br.ReadB())
if tx.Version >= 1 {
tx.NeedStorage = br.ReadBool()
} else {
tx.NeedStorage = false
}
tx.Name = br.ReadString()
tx.CodeVersion = br.ReadString()
tx.Author = br.ReadString()
tx.Email = br.ReadString()
tx.Description = br.ReadString()
}
// EncodeBinary implements Serializable interface.
func (tx *PublishTX) EncodeBinary(bw *io.BinWriter) {
bw.WriteVarBytes(tx.Script)
bw.WriteVarUint(uint64(len(tx.ParamList)))
for _, param := range tx.ParamList {
bw.WriteB(byte(param))
}
bw.WriteB(byte(tx.ReturnType))
if tx.Version >= 1 {
bw.WriteBool(tx.NeedStorage)
}
bw.WriteString(tx.Name)
bw.WriteString(tx.CodeVersion)
bw.WriteString(tx.Author)
bw.WriteString(tx.Email)
bw.WriteString(tx.Description)
}
// publishedContract is a JSON wrapper for PublishTransaction
type publishedContract struct {
Code publishedCode `json:"code"`
NeedStorage bool `json:"needstorage,omitempty"`
Name string `json:"name,omitempty"`
CodeVersion string `json:"version,omitempty"`
Author string `json:"author,omitempty"`
Email string `json:"email,omitempty"`
Description string `json:"description,omitempty"`
}
// publishedCode is a JSON wrapper for PublishTransaction Code
type publishedCode struct {
Hash util.Uint160 `json:"hash,omitempty"`
Script string `json:"script,omitempty"`
ParamList []smartcontract.ParamType `json:"parameters,omitempty"`
ReturnType smartcontract.ParamType `json:"returntype,omitempty"`
}

View file

@ -162,9 +162,6 @@ func (t *Transaction) decodeData(r *io.BinReader) {
case EnrollmentType:
t.Data = &EnrollmentTX{}
t.Data.(*EnrollmentTX).DecodeBinary(r)
case PublishType:
t.Data = &PublishTX{Version: t.Version}
t.Data.(*PublishTX).DecodeBinary(r)
case StateType:
t.Data = &StateTX{}
t.Data.(*StateTX).DecodeBinary(r)
@ -281,7 +278,6 @@ type transactionJSON struct {
PublicKey *keys.PublicKey `json:"pubkey,omitempty"`
Script string `json:"script,omitempty"`
Gas util.Fixed8 `json:"gas,omitempty"`
Contract *publishedContract `json:"contract,omitempty"`
Asset *registeredAsset `json:"asset,omitempty"`
Descriptors []*StateDescriptor `json:"descriptors,omitempty"`
}
@ -308,22 +304,6 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
case InvocationType:
tx.Script = hex.EncodeToString(t.Data.(*InvocationTX).Script)
tx.Gas = t.Data.(*InvocationTX).Gas
case PublishType:
transaction := t.Data.(*PublishTX)
tx.Contract = &publishedContract{
Code: publishedCode{
Hash: hash.Hash160(transaction.Script),
Script: hex.EncodeToString(transaction.Script),
ParamList: transaction.ParamList,
ReturnType: transaction.ReturnType,
},
NeedStorage: transaction.NeedStorage,
Name: transaction.Name,
CodeVersion: transaction.CodeVersion,
Author: transaction.Author,
Email: transaction.Email,
Description: transaction.Description,
}
case RegisterType:
transaction := *t.Data.(*RegisterTX)
tx.Asset = &registeredAsset{
@ -375,23 +355,6 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
Gas: tx.Gas,
Version: tx.Version,
}
case PublishType:
bytes, err := hex.DecodeString(tx.Contract.Code.Script)
if err != nil {
return err
}
t.Data = &PublishTX{
Script: bytes,
ParamList: tx.Contract.Code.ParamList,
ReturnType: tx.Contract.Code.ReturnType,
NeedStorage: tx.Contract.NeedStorage,
Name: tx.Contract.Name,
CodeVersion: tx.Contract.CodeVersion,
Author: tx.Contract.Author,
Email: tx.Contract.Email,
Description: tx.Contract.Description,
Version: tx.Version,
}
case RegisterType:
admin, err := address.StringToUint160(tx.Asset.Admin)
if err != nil {

View file

@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -100,62 +99,6 @@ func TestNewInvocationTX(t *testing.T) {
testserdes.EncodeDecodeBinary(t, tx, new(Transaction))
}
// TODO NEO3.0: Update binary
/*
func TestDecodePublishTX(t *testing.T) {
expectedTXData := &PublishTX{}
expectedTXData.Name = "Lock"
expectedTXData.Author = "Erik Zhang"
expectedTXData.Email = "erik@antshares.org"
expectedTXData.Description = "Lock your assets until a timestamp."
expectedTXData.CodeVersion = "1.0-preview1"
expectedTXData.NeedStorage = false
expectedTXData.ReturnType = 1
paramList := []smartcontract.ParamType{
smartcontract.IntegerType,
smartcontract.ByteArrayType,
smartcontract.SignatureType,
}
expectedTXData.ParamList = paramList
expectedTXData.Script = []uint8{0x74, 0x6b, 0x4c, 0x4, 0x0, 0x0, 0x0, 0x0, 0x4c, 0x4, 0x0, 0x0, 0x0, 0x0, 0x4c, 0x4,
0x0, 0x0, 0x0, 0x0, 0x61, 0x68, 0x1e, 0x41, 0x6e, 0x74, 0x53, 0x68, 0x61, 0x72, 0x65, 0x73, 0x2e, 0x42, 0x6c,
0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74,
0x68, 0x1d, 0x41, 0x6e, 0x74, 0x53, 0x68, 0x61, 0x72, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63,
0x68, 0x61, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x74, 0x4c, 0x4, 0x0, 0x0, 0x0,
0x0, 0x94, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x72, 0x75, 0x74, 0x4c, 0x4, 0x2, 0x0, 0x0, 0x0, 0x93, 0x6c, 0x76,
0x6b, 0x94, 0x79, 0x74, 0x4c, 0x4, 0x0, 0x0, 0x0, 0x0, 0x94, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x79, 0x68, 0x1d,
0x41, 0x6e, 0x74, 0x53, 0x68, 0x61, 0x72, 0x65, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x47,
0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0xa0, 0x74, 0x4c, 0x4, 0x1, 0x0, 0x0, 0x0,
0x94, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x72, 0x75, 0x74, 0x4c, 0x4, 0x1, 0x0, 0x0, 0x0, 0x94, 0x8c, 0x6c, 0x76,
0x6b, 0x94, 0x79, 0x64, 0x1b, 0x0, 0x4c, 0x4, 0x0, 0x0, 0x0, 0x0, 0x74, 0x4c, 0x4, 0x2, 0x0, 0x0, 0x0, 0x94,
0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x72, 0x75, 0x62, 0x30, 0x0, 0x74, 0x4c, 0x4, 0x1, 0x0, 0x0, 0x0, 0x93, 0x6c,
0x76, 0x6b, 0x94, 0x79, 0x74, 0x4c, 0x4, 0x0, 0x0, 0x0, 0x0, 0x93, 0x6c, 0x76, 0x6b, 0x94, 0x79, 0xac, 0x74,
0x4c, 0x4, 0x2, 0x0, 0x0, 0x0, 0x94, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x72, 0x75, 0x62, 0x3, 0x0, 0x74, 0x4c, 0x4,
0x2, 0x0, 0x0, 0x0, 0x94, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x79, 0x61, 0x74, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x6d,
0x74, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x6d, 0x74, 0x8c, 0x6c, 0x76, 0x6b, 0x94, 0x6d, 0x74, 0x6c, 0x76, 0x8c,
0x6b, 0x94, 0x6d, 0x74, 0x6c, 0x76, 0x8c, 0x6b, 0x94, 0x6d, 0x74, 0x6c, 0x76, 0x8c, 0x6b, 0x94, 0x6d, 0x6c,
0x75, 0x66}
expectedTX := &Transaction{}
expectedTX.Type = PublishType
expectedTX.Version = 0
expectedTX.Data = expectedTXData
actualTX := decodeTransaction(rawPublishTX, t)
assert.Equal(t, expectedTX.Data, actualTX.Data)
assert.Equal(t, expectedTX.Type, actualTX.Type)
assert.Equal(t, expectedTX.Version, actualTX.Version)
data, err := testserdes.EncodeBinary(actualTX)
assert.NoError(t, err)
assert.Equal(t, rawPublishTX, hex.EncodeToString(data))
}
*/
func TestEncodingTXWithNoData(t *testing.T) {
_, err := testserdes.EncodeBinary(new(Transaction))
require.Error(t, err)
@ -264,40 +207,6 @@ func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) {
testserdes.MarshalUnmarshalJSON(t, tx, new(Transaction))
}
func TestMarshalUnmarshalJSONPublishTX(t *testing.T) {
tx := &Transaction{
Type: PublishType,
Version: 5,
Data: &PublishTX{
Script: []byte{1, 2, 3, 4},
ParamList: []smartcontract.ParamType{smartcontract.IntegerType, smartcontract.Hash160Type},
ReturnType: smartcontract.BoolType,
NeedStorage: true,
Name: "Name",
CodeVersion: "1.0",
Author: "Author",
Email: "Email",
Description: "Description",
Version: 5,
},
Attributes: []Attribute{},
Inputs: []Input{{
PrevHash: util.Uint256{5, 6, 7, 8},
PrevIndex: uint16(12),
}},
Outputs: []Output{{
AssetID: util.Uint256{1, 2, 3},
Amount: util.Fixed8FromInt64(1),
ScriptHash: util.Uint160{1, 2, 3},
Position: 0,
}},
Scripts: []Witness{},
Trimmed: false,
}
testserdes.MarshalUnmarshalJSON(t, tx, new(Transaction))
}
func TestMarshalUnmarshalJSONRegisterTX(t *testing.T) {
tx := &Transaction{
Type: RegisterType,

View file

@ -20,7 +20,6 @@ const (
ContractType TXType = 0x80
StateType TXType = 0x90
AgencyType TXType = 0xb0
PublishType TXType = 0xd0
InvocationType TXType = 0xd1
)
@ -45,8 +44,6 @@ func (t TXType) String() string {
return "StateTransaction"
case AgencyType:
return "AgencyTransaction"
case PublishType:
return "PublishTransaction"
case InvocationType:
return "InvocationTransaction"
default:
@ -91,8 +88,6 @@ func TXTypeFromString(jsonString string) (TXType, error) {
return StateType, nil
case "AgencyTransaction":
return AgencyType, nil
case "PublishTransaction":
return PublishType, nil
case "InvocationTransaction":
return InvocationType, nil
default: