From f145dfd14d12956176b48b80c50d6cb44a93ca49 Mon Sep 17 00:00:00 2001 From: hazim Date: Thu, 18 Apr 2024 18:45:44 +1000 Subject: [PATCH] Add support for validation rule OP-080 (#394) --- 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)