From dc351f10edb97be6e5feb424bb73aef35c350759 Mon Sep 17 00:00:00 2001 From: hazim-j Date: Thu, 18 Apr 2024 16:38:47 +0800 Subject: [PATCH] Add support for valudation rule OP-080 --- pkg/entrypoint/simulation/simulateutils.go | 8 ++++++-- pkg/entrypoint/simulation/tracevalidation.go | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/entrypoint/simulation/simulateutils.go b/pkg/entrypoint/simulation/simulateutils.go index c01cfcd0..1849113c 100644 --- a/pkg/entrypoint/simulation/simulateutils.go +++ b/pkg/entrypoint/simulation/simulateutils.go @@ -25,8 +25,6 @@ var ( "BASEFEE", "BLOCKHASH", "NUMBER", - "SELFBALANCE", - "BALANCE", "ORIGIN", "GAS", "CREATE", @@ -34,6 +32,12 @@ var ( "SELFDESTRUCT", ) + // List of opcodes not allowed during validation for unstaked entities. + bannedUnstakedOpCodes = mapset.NewSet( + "SELFBALANCE", + "BALANCE", + ) + revertOpCode = "REVERT" returnOpCode = "RETURN" diff --git a/pkg/entrypoint/simulation/tracevalidation.go b/pkg/entrypoint/simulation/tracevalidation.go index 7e32a8bb..d798ccf1 100644 --- a/pkg/entrypoint/simulation/tracevalidation.go +++ b/pkg/entrypoint/simulation/tracevalidation.go @@ -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)