Skip to content

Commit

Permalink
config: block deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kroggen committed Jun 1, 2024
1 parent 07a5428 commit 86c17e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func (ctx *ServerContext) GetDefaultMempoolConfig() *MempoolConfig {
FadeoutPeriod: types.DefaultEvictPeriod,
VerifierNumber: runtime.NumCPU(),
DumpFilePath: ctx.ExpandPathEnv("$HOME/mempool.dump"),
BlockDeploy: false,
Blacklist: nil,
}
}
Expand Down
2 changes: 2 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type MempoolConfig struct {
FadeoutPeriod int `mapstructure:"fadeoutperiod" description:"time period for evict transactions(in hour)"`
VerifierNumber int `mapstructure:"verifiers" description:"number of concurrent verifier"`
DumpFilePath string `mapstructure:"dumpfilepath" description:"file path for recording mempool at process termintation"`
BlockDeploy bool `mapstructure:"blockdeploy" description:"block the deployment of new contracts"`
Blacklist []string `mapstructure:"blacklist" description:"List of account addresses or ids to be blocked"`
}

Expand Down Expand Up @@ -259,6 +260,7 @@ enablefadeout = {{.Mempool.EnableFadeout}}
fadeoutperiod = {{.Mempool.FadeoutPeriod}}
verifiers = {{.Mempool.VerifierNumber}}
dumpfilepath = "{{.Mempool.DumpFilePath}}"
blockdeploy = {{.Mempool.BlockDeploy}}
blacklist = [{{range .Mempool.Blacklist}}
"{{.}}", {{end}}
]
Expand Down
5 changes: 5 additions & 0 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type MemPool struct {
isPublic bool
whitelist *whitelistConf
blacklist *blacklistConf
blockDeploy bool
// followings are for test
testConfig bool
deadtx int
Expand Down Expand Up @@ -103,6 +104,7 @@ func NewMemPoolService(cfg *cfg.Config, cs *chain.ChainService) *MemPool {
status: initial,
verifier: nil,
quit: make(chan bool),
blockDeploy: cfg.Mempool.BlockDeploy,
}
actor.BaseComponent = component.NewBaseComponent(message.MemPoolSvc, actor, log.NewLogger("mempool"))
if cfg.Mempool.EnableFadeout == false {
Expand Down Expand Up @@ -666,6 +668,9 @@ func (mp *MemPool) validateTx(tx types.Transaction, account types.Address) error
if tx.GetBody().GetRecipient() != nil {
return types.ErrTxInvalidRecipient
}
if mp.blockDeploy {
return types.ErrTxInvalidType
}
case types.TxType_GOVERNANCE:
id := tx.GetBody().GetRecipient()
aergoState, err := mp.getAccountState(id)
Expand Down

0 comments on commit 86c17e2

Please sign in to comment.