Skip to content

Commit

Permalink
Added DEBUG logs to executor in order to track allow and block lists (#…
Browse files Browse the repository at this point in the history
…1664)

* Added DEBUG level log lines when the transaction or deployment allowlists are applied to reject a transaction

* Added blank lines for linting
  • Loading branch information
jp-imx authored Jun 27, 2023
1 parent cbe6b84 commit 1ab1a31
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ func (t *Transition) run(contract *runtime.Contract, host runtime.Host) *runtime
if contract.Caller != contracts.SystemCaller {
role := t.txnAllowList.GetRole(contract.Caller)
if !role.Enabled() {
t.logger.Debug(
"Failing transaction. Caller is not in the transaction allowlist",
"contract.Caller", contract.Caller,
"contract.Address", contract.Address,
)

return &runtime.ExecutionResult{
GasLeft: 0,
Err: runtime.ErrNotAuth,
Expand All @@ -702,6 +708,12 @@ func (t *Transition) run(contract *runtime.Contract, host runtime.Host) *runtime
if contract.Caller != contracts.SystemCaller {
role := t.txnBlockList.GetRole(contract.Caller)
if role == addresslist.EnabledRole {
t.logger.Debug(
"Failing transaction. Caller is in the transaction blocklist",
"contract.Caller", contract.Caller,
"contract.Address", contract.Address,
)

return &runtime.ExecutionResult{
GasLeft: 0,
Err: runtime.ErrNotAuth,
Expand Down Expand Up @@ -848,6 +860,12 @@ func (t *Transition) applyCreate(c *runtime.Contract, host runtime.Host) *runtim
role := t.deploymentAllowList.GetRole(c.Caller)

if !role.Enabled() {
t.logger.Debug(
"Failing contract deployment. Caller is not in the deployment allowlist",
"contract.Caller", c.Caller,
"contract.Address", c.Address,
)

return &runtime.ExecutionResult{
GasLeft: 0,
Err: runtime.ErrNotAuth,
Expand All @@ -857,6 +875,12 @@ func (t *Transition) applyCreate(c *runtime.Contract, host runtime.Host) *runtim
role := t.deploymentBlockList.GetRole(c.Caller)

if role == addresslist.EnabledRole {
t.logger.Debug(
"Failing contract deployment. Caller is in the deployment blocklist",
"contract.Caller", c.Caller,
"contract.Address", c.Address,
)

return &runtime.ExecutionResult{
GasLeft: 0,
Err: runtime.ErrNotAuth,
Expand Down

0 comments on commit 1ab1a31

Please sign in to comment.