transaction: drop Issue TX support

This commit is contained in:
Roman Khimov 2020-06-05 12:28:36 +03:00
parent f445f7c602
commit 169c5ae775
22 changed files with 8 additions and 141 deletions

View file

@ -19,7 +19,6 @@ ProtocolConfiguration:
- seed4.neo.org:10333
- seed5.neo.org:10333
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: false

View file

@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -9,7 +9,6 @@ ProtocolConfiguration:
SeedList:
- 172.200.0.1:20333
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

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

View file

@ -19,7 +19,6 @@ ProtocolConfiguration:
- seed4t.neo.org:20333
- seed5t.neo.org:20333
SystemFee:
IssueTransaction: 5
RegisterTransaction: 100
VerifyBlocks: true
VerifyTransactions: false

View file

@ -14,7 +14,6 @@ ProtocolConfiguration:
- 127.0.0.1:20335
- 127.0.0.1:20336
SystemFee:
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
VerifyTransactions: true

View file

@ -60,8 +60,6 @@ ProtocolConfiguration:
- 127.0.0.1:20335
- 127.0.0.1:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
ApplicationConfiguration:

View file

@ -47,7 +47,6 @@ type (
// SystemFee fees related to system.
SystemFee struct {
IssueTransaction int64 `yaml:"IssueTransaction"`
RegisterTransaction int64 `yaml:"RegisterTransaction"`
}
@ -74,8 +73,6 @@ func (n NetMode) String() string {
// TryGetValue returns the system fee base on transaction type.
func (s SystemFee) TryGetValue(txType transaction.TXType) util.Fixed8 {
switch txType {
case transaction.IssueType:
return util.Fixed8FromInt64(s.IssueTransaction)
case transaction.RegisterType:
return util.Fixed8FromInt64(s.RegisterTransaction)
default:

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/dbft/crypto"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/stretchr/testify/require"
)
@ -44,7 +45,7 @@ func TestNeoBlock_Setters(t *testing.T) {
b.Block.PrevHash = util.Uint256{9, 8, 7}
require.Equal(t, util.Uint256{9, 8, 7}, b.PrevHash())
txx := []block.Transaction{transaction.NewIssueTX()}
txx := []block.Transaction{transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1)}
b.SetTransactions(txx)
require.Equal(t, txx, b.Transactions())
}

View file

@ -5,6 +5,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/stretchr/testify/assert"
)
@ -84,7 +85,7 @@ func newDumbBlock() *Block {
Nonce: 1111,
},
Transactions: []*transaction.Transaction{
transaction.NewIssueTX(),
transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0),
},
}
}

View file

@ -643,19 +643,6 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
if err != nil {
return err
}
case *transaction.IssueTX:
for _, res := range bc.GetTransactionResults(tx) {
if res.Amount < 0 {
asset, err := cache.GetAssetState(res.AssetID)
if asset == nil || err != nil {
return fmt.Errorf("issue failed: no asset %s or error %s", res.AssetID, err)
}
asset.Available -= res.Amount
if err := cache.PutAssetState(asset); err != nil {
return err
}
}
}
case *transaction.InvocationTX:
systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx)
v := SpawnVM(systemInterop)
@ -1437,27 +1424,9 @@ func (bc *Blockchain) verifyResults(t *transaction.Transaction, results []*trans
return errors.New("tx destroys non-utility token")
}
switch t.Type {
case transaction.IssueType:
for _, r := range resultsIssue {
if r.AssetID == UtilityTokenID() {
return errors.New("issue tx issues utility tokens")
}
asset, err := bc.dao.GetAssetState(r.AssetID)
if asset == nil || err != nil {
return errors.New("invalid asset in issue tx")
}
if asset.Available < r.Amount {
return errors.New("trying to issue more than available")
}
}
break
default:
if len(resultsIssue) > 0 {
return errors.New("non issue/miner/claim tx issues tokens")
}
break
}
return nil
}
@ -1547,16 +1516,6 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
hashes[c.Account] = true
}
switch t.Type {
case transaction.IssueType:
for _, res := range refsAndOutsToResults(references, t.Outputs) {
if res.Amount < 0 {
asset, err := bc.dao.GetAssetState(res.AssetID)
if asset == nil || err != nil {
return nil, errors.New("invalid asset in issue tx")
}
hashes[asset.Issuer] = true
}
}
case transaction.RegisterType:
reg := t.Data.(*transaction.RegisterTX)
hashes[reg.Owner.GetScriptHash()] = true

View file

@ -220,7 +220,7 @@ func TestGetCurrentHeaderHeight_Store(t *testing.T) {
func TestStoreAsTransaction(t *testing.T) {
dao := NewSimple(storage.NewMemoryStore())
tx := transaction.NewIssueTX()
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1)
hash := tx.Hash()
err := dao.StoreAsTransaction(tx, 0)
require.NoError(t, err)

View file

@ -138,7 +138,7 @@ func newDumbBlock() *block.Block {
Nonce: 1111,
},
Transactions: []*transaction.Transaction{
{Type: transaction.IssueType},
transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0),
},
}
}

View file

@ -353,17 +353,6 @@ func (mp *Pool) checkTxConflicts(tx *transaction.Transaction, fee Feer) bool {
if !mp.checkBalanceAndUpdate(tx, fee) {
return false
}
switch tx.Type {
case transaction.IssueType:
// It's a hack, because technically we could check for
// available asset amount, but these transactions are so rare
// that no one really cares about this restriction.
for i := range mp.verifiedTxes {
if mp.verifiedTxes[i].txn.Type == transaction.IssueType {
return false
}
}
}
return true
}

View file

@ -129,29 +129,6 @@ func TestMemPoolVerifyInputs(t *testing.T) {
require.Error(t, mp.Add(tx3, &FeerStub{}))
}
func TestMemPoolVerifyIssue(t *testing.T) {
mp := NewMemPool(50)
tx1 := newIssueTX()
require.Equal(t, true, mp.Verify(tx1, &FeerStub{}))
require.NoError(t, mp.Add(tx1, &FeerStub{}))
tx2 := newIssueTX()
require.Equal(t, false, mp.Verify(tx2, &FeerStub{}))
require.Error(t, mp.Add(tx2, &FeerStub{}))
}
func newIssueTX() *transaction.Transaction {
tx := transaction.NewIssueTX()
tx.Outputs = []transaction.Output{
{
AssetID: random.Uint256(),
Amount: util.Fixed8FromInt64(42),
ScriptHash: random.Uint160(),
},
}
return tx
}
func TestOverCapacity(t *testing.T) {
var fs = &FeerStub{lowPriority: true}
const mempoolSize = 10

View file

@ -1,35 +0,0 @@
package transaction
import (
"math/rand"
"github.com/nspcc-dev/neo-go/pkg/io"
)
// IssueTX represents a issue transaction.
// This TX has not special attributes.
type IssueTX struct{}
// NewIssueTX creates Transaction of IssueType type.
func NewIssueTX() *Transaction {
return &Transaction{
Type: IssueType,
Version: 0,
Nonce: rand.Uint32(),
Data: &IssueTX{},
Attributes: []Attribute{},
Cosigners: []Cosigner{},
Inputs: []Input{},
Outputs: []Output{},
Scripts: []Witness{},
Trimmed: false,
}
}
// DecodeBinary implements Serializable interface.
func (tx *IssueTX) DecodeBinary(r *io.BinReader) {
}
// EncodeBinary implements Serializable interface.
func (tx *IssueTX) EncodeBinary(w *io.BinWriter) {
}

View file

@ -179,9 +179,6 @@ func (t *Transaction) decodeData(r *io.BinReader) {
case RegisterType:
t.Data = &RegisterTX{}
t.Data.(*RegisterTX).DecodeBinary(r)
case IssueType:
t.Data = &IssueTX{}
t.Data.(*IssueTX).DecodeBinary(r)
default:
r.Err = fmt.Errorf("invalid TX type %x", t.Type)
}
@ -387,8 +384,6 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
Owner: tx.Asset.Owner,
Admin: admin,
}
case IssueType:
t.Data = &IssueTX{}
}
if t.Hash() != tx.TxID {
return errors.New("txid doesn't match transaction hash")

View file

@ -11,7 +11,6 @@ type TXType uint8
// Constants for all valid transaction types.
const (
IssueType TXType = 0x01
RegisterType TXType = 0x40
InvocationType TXType = 0xd1
)
@ -19,8 +18,6 @@ const (
// String implements the stringer interface.
func (t TXType) String() string {
switch t {
case IssueType:
return "IssueTransaction"
case RegisterType:
return "RegisterTransaction"
case InvocationType:
@ -49,8 +46,6 @@ func (t *TXType) UnmarshalJSON(data []byte) error {
// TXTypeFromString searches for TXType by string name.
func TXTypeFromString(jsonString string) (TXType, error) {
switch jsonString = strings.TrimSpace(jsonString); jsonString {
case "IssueTransaction":
return IssueType, nil
case "RegisterTransaction":
return RegisterType, nil
case "InvocationTransaction":

View file

@ -23,7 +23,6 @@ func GetHash(t Transaction) []byte {
// GetType returns the type of the given transaction. Possible values:
// MinerTransaction = 0x00
// IssueTransaction = 0x01
// EnrollmentTransaction = 0x20
// RegisterTransaction = 0x40
// StateType = 0x90