Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Add support for validation rule OP-080 (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
hazim-j authored Apr 18, 2024
1 parent 85e227c commit f145dfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/entrypoint/simulation/simulateutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ var (
"BASEFEE",
"BLOCKHASH",
"NUMBER",
"SELFBALANCE",
"BALANCE",
"ORIGIN",
"GAS",
"CREATE",
"COINBASE",
"SELFDESTRUCT",
)

// List of opcodes not allowed during validation for unstaked entities.
bannedUnstakedOpCodes = mapset.NewSet(
"SELFBALANCE",
"BALANCE",
)

revertOpCode = "REVERT"
returnOpCode = "RETURN"

Expand Down
4 changes: 4 additions & 0 deletions pkg/entrypoint/simulation/tracevalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func TraceSimulateValidation(in *TraceInput) (*TraceOutput, error) {
if bannedOpCodes.Contains(opcode) {
return nil, fmt.Errorf("%s uses banned opcode: %s", title, opcode)
}

if !entity.IsStaked && bannedUnstakedOpCodes.Contains(opcode) {
return nil, fmt.Errorf("unstaked %s uses banned opcode: %s", title, opcode)
}
}

ic.Add(entity.Address)
Expand Down

0 comments on commit f145dfd

Please sign in to comment.