Skip to content

Commit

Permalink
transaction: drop Enrollment and State types
Browse files Browse the repository at this point in the history
They're completely replaced now by the NEO native contract voting system.
  • Loading branch information
roman-khimov committed Apr 27, 2020
1 parent e4e84e7 commit 5c9e3e5
Show file tree
Hide file tree
Showing 18 changed files with 6 additions and 415 deletions.
1 change: 0 additions & 1 deletion config/protocol.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ProtocolConfiguration:
- seed9.ngd.network:10333
- seed10.ngd.network:10333
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.privnet.docker.four.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.privnet.docker.one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.privnet.docker.single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ProtocolConfiguration:
SeedList:
- 172.200.0.1:20333
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.privnet.docker.three.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.privnet.docker.two.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ProtocolConfiguration:
- 172.200.0.3:20335
- 172.200.0.4:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ProtocolConfiguration:
- seed9.ngd.network:20333
- seed10.ngd.network:20333
SystemFee:
EnrollmentTransaction: 10
IssueTransaction: 5
RegisterTransaction: 100
VerifyBlocks: true
Expand Down
1 change: 0 additions & 1 deletion config/protocol.unit_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ProtocolConfiguration:
- 127.0.0.1:20335
- 127.0.0.1:20336
SystemFee:
EnrollmentTransaction: 1000
IssueTransaction: 500
RegisterTransaction: 10000
VerifyBlocks: true
Expand Down
7 changes: 2 additions & 5 deletions pkg/config/protocol_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ type (

// SystemFee fees related to system.
SystemFee struct {
EnrollmentTransaction int64 `yaml:"EnrollmentTransaction"`
IssueTransaction int64 `yaml:"IssueTransaction"`
RegisterTransaction int64 `yaml:"RegisterTransaction"`
IssueTransaction int64 `yaml:"IssueTransaction"`
RegisterTransaction int64 `yaml:"RegisterTransaction"`
}

// NetMode describes the mode the blockchain will operate on.
Expand All @@ -75,8 +74,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.EnrollmentType:
return util.Fixed8FromInt64(s.EnrollmentTransaction)
case transaction.IssueType:
return util.Fixed8FromInt64(s.IssueTransaction)
case transaction.RegisterType:
Expand Down
102 changes: 0 additions & 102 deletions pkg/core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,23 +831,6 @@ func processOutputs(tx *transaction.Transaction, dao *dao.Cached) error {
return nil
}

func (bc *Blockchain) processAccountStateDescriptor(descriptor *transaction.StateDescriptor, t *transaction.Transaction, dao *dao.Cached) error {
hash, err := util.Uint160DecodeBytesBE(descriptor.Key)
if err != nil {
return err
}

if descriptor.Field == "Votes" {
votes := keys.PublicKeys{}
if err := votes.DecodeBytes(descriptor.Value); err != nil {
return err
}
ic := bc.newInteropContext(trigger.Application, dao, nil, t)
return bc.contracts.NEO.VoteInternal(ic, hash, votes)
}
return nil
}

// persist flushes current in-memory Store contents to the persistent storage.
func (bc *Blockchain) persist() error {
var (
Expand Down Expand Up @@ -1268,63 +1251,6 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e
if inv.Gas.FractionalValue() != 0 {
return errors.New("invocation gas can only be integer")
}
case transaction.StateType:
stx := t.Data.(*transaction.StateTX)
for _, desc := range stx.Descriptors {
switch desc.Type {
case transaction.Account:
if desc.Field != "Votes" {
return errors.New("bad field in account descriptor")
}
votes := keys.PublicKeys{}
err := votes.DecodeBytes(desc.Value)
if err != nil {
return err
}
if len(votes) > native.MaxValidatorsVoted {
return errors.New("voting candidate limit exceeded")
}
hash, err := util.Uint160DecodeBytesBE(desc.Key)
if err != nil {
return err
}
account, err := bc.dao.GetAccountStateOrNew(hash)
if err != nil {
return err
}
if account.IsFrozen {
return errors.New("account is frozen")
}
if votes.Len() > 0 {
balance := account.GetBalanceValues()[GoverningTokenID()]
if balance == 0 {
return errors.New("no governing tokens available to vote")
}
validators, err := bc.GetEnrollments()
if err != nil {
return err
}
for _, k := range votes {
var isRegistered bool
for i := range validators {
if k.Equal(validators[i].Key) {
isRegistered = true
break
}
}
if !isRegistered {
return errors.New("vote for unregistered validator")
}
}
}
case transaction.Validator:
if desc.Field != "Registered" {
return errors.New("bad field in validator descriptor")
}
default:
return errors.New("bad descriptor type")
}
}
}

return bc.verifyTxWitnesses(t, block)
Expand Down Expand Up @@ -1662,9 +1588,6 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
for i := range refs {
hashes[refs[i].Out.ScriptHash] = true
}
case transaction.EnrollmentType:
etx := t.Data.(*transaction.EnrollmentTX)
hashes[etx.PublicKey.GetScriptHash()] = true
case transaction.IssueType:
for _, res := range refsAndOutsToResults(references, t.Outputs) {
if res.Amount < 0 {
Expand All @@ -1678,31 +1601,6 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
case transaction.RegisterType:
reg := t.Data.(*transaction.RegisterTX)
hashes[reg.Owner.GetScriptHash()] = true
case transaction.StateType:
stx := t.Data.(*transaction.StateTX)
for _, desc := range stx.Descriptors {
switch desc.Type {
case transaction.Account:
if desc.Field != "Votes" {
return nil, errors.New("bad account state descriptor")
}
hash, err := util.Uint160DecodeBytesBE(desc.Key)
if err != nil {
return nil, err
}
hashes[hash] = true
case transaction.Validator:
if desc.Field != "Registered" {
return nil, errors.New("bad validator state descriptor")
}
key := &keys.PublicKey{}
err := key.DecodeBytes(desc.Key)
if err != nil {
return nil, err
}
hashes[key.GetScriptHash()] = true
}
}
}
// convert hashes to []util.Uint160
hashesResult := make([]util.Uint160, 0, len(hashes))
Expand Down
43 changes: 0 additions & 43 deletions pkg/core/transaction/enrollment.go

This file was deleted.

17 changes: 0 additions & 17 deletions pkg/core/transaction/enrollment_test.go

This file was deleted.

37 changes: 0 additions & 37 deletions pkg/core/transaction/state.go

This file was deleted.

81 changes: 0 additions & 81 deletions pkg/core/transaction/state_descriptor.go

This file was deleted.

Loading

0 comments on commit 5c9e3e5

Please sign in to comment.