Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable finish voting #665

Merged
merged 3 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/contract_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/idena-network/idena-go/deferredtx"
"github.com/idena-network/idena-go/subscriptions"
"github.com/idena-network/idena-go/vm"
"github.com/idena-network/idena-go/vm/embedded"
"github.com/idena-network/idena-go/vm/env"
"github.com/idena-network/idena-go/vm/helpers"
"github.com/pkg/errors"
Expand Down Expand Up @@ -316,6 +317,10 @@ func (api *ContractApi) Deploy(ctx context.Context, args DeployArgs) (common.Has
}

func (api *ContractApi) Call(ctx context.Context, args CallArgs) (common.Hash, error) {
if args.Method == embedded.FinishVotingMethod {
return common.Hash{}, errors.New("finishVoting is temporary disabled")
}

tx, err := api.buildCallContractTx(args)
if err != nil {
return common.Hash{}, err
Expand Down
6 changes: 3 additions & 3 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,10 @@ func (chain *Blockchain) applyDelegationSwitch(appState *appstate.AppState, bloc
for idx := range delegations {
delegation := delegations[idx]
if delegation.Delegatee.IsEmpty() {
delegatee :=appState.State.Delegatee(delegation.Delegator)
delegatee := appState.State.Delegatee(delegation.Delegator)
appState.IdentityState.RemoveDelegatee(delegation.Delegator)
appState.State.RemoveDelegatee(delegation.Delegator)
if delegatee!=nil {
if delegatee != nil {
undelegations = append(undelegations, &state.Delegation{Delegator: delegation.Delegator, Delegatee: *delegatee})
}
} else {
Expand All @@ -1255,7 +1255,7 @@ func (chain *Blockchain) applyDelegationSwitch(appState *appstate.AppState, bloc
return undelegations
}

func (chain *Blockchain) switchPoolsToOffline(appState *appstate.AppState, undelegations []*state.Delegation, block *types.Block) {
func (chain *Blockchain) switchPoolsToOffline(appState *appstate.AppState, undelegations []*state.Delegation, block *types.Block) {
if !block.Header.Flags().HasFlag(types.IdentityUpdate) {
return
}
Expand Down
9 changes: 9 additions & 0 deletions core/mempool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mempool

import (
"github.com/deckarep/golang-set"
"github.com/idena-network/idena-go/blockchain/attachments"
"github.com/idena-network/idena-go/blockchain/fee"
"github.com/idena-network/idena-go/blockchain/types"
"github.com/idena-network/idena-go/blockchain/validation"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/idena-network/idena-go/events"
"github.com/idena-network/idena-go/log"
"github.com/idena-network/idena-go/stats/collector"
"github.com/idena-network/idena-go/vm/embedded"
"github.com/pkg/errors"
"sort"
"sync"
Expand Down Expand Up @@ -216,6 +218,13 @@ func (pool *TxPool) Add(tx *types.Transaction) error {

sender, _ := types.Sender(tx)

if tx.Type == types.CallContract {
attachment := attachments.ParseCallContractAttachment(tx)
if attachment != nil && attachment.Method == embedded.FinishVotingMethod {
return errors.New("finishVoting is temporary disabled")
}
}

if pool.isSyncing && sender != pool.coinbase {
pool.addDeferredTx(tx)

Expand Down
3 changes: 2 additions & 1 deletion vm/embedded/oraclevoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func NewOracleVotingContract2(ctx env.CallContext, e env.Env, statsCollector col
env.NewMap([]byte("allVotes"), e, ctx),
}
}
const FinishVotingMethod = "finishVoting"

func (f *OracleVoting2) Call(method string, args ...[]byte) error {
switch method {
Expand All @@ -47,7 +48,7 @@ func (f *OracleVoting2) Call(method string, args ...[]byte) error {
return f.sendVoteProof(args...)
case "sendVote":
return f.sendVote(args...)
case "finishVoting":
case FinishVotingMethod:
return f.finishVoting(args...)
case "prolongVoting":
return f.prolongVoting(args...)
Expand Down