diff --git a/api/contract_api.go b/api/contract_api.go index 49ea209d..f5283d75 100644 --- a/api/contract_api.go +++ b/api/contract_api.go @@ -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" @@ -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 diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 6b07dd54..c5641e42 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -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 { @@ -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 } diff --git a/core/mempool/txpool.go b/core/mempool/txpool.go index c96d6c87..034a3f49 100644 --- a/core/mempool/txpool.go +++ b/core/mempool/txpool.go @@ -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" @@ -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" @@ -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) diff --git a/vm/embedded/oraclevoting.go b/vm/embedded/oraclevoting.go index fc511a9d..882eae41 100644 --- a/vm/embedded/oraclevoting.go +++ b/vm/embedded/oraclevoting.go @@ -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 { @@ -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...)