@@ -274,7 +274,16 @@ protected static void OnSysCall(ExecutionEngine engine, Instruction instruction)
274274 {
275275 if ( engine is ApplicationEngine app )
276276 {
277- app . OnSysCall ( GetInteropDescriptor ( instruction . TokenU32 ) ) ;
277+ var interop = GetInteropDescriptor ( instruction . TokenU32 ) ;
278+
279+ if ( interop ? . Hardfork != null && ! app . IsHardforkEnabled ( interop . Hardfork . Value ) )
280+ {
281+ // The syscall is not active
282+
283+ throw new KeyNotFoundException ( ) ;
284+ }
285+
286+ app . OnSysCall ( interop ) ;
278287 }
279288 else
280289 {
@@ -691,19 +700,20 @@ private static Block CreateDummyBlock(IReadOnlyStore snapshot, ProtocolSettings
691700 } ;
692701 }
693702
694- private static InteropDescriptor Register ( string name , string handler , long fixedPrice , CallFlags requiredCallFlags )
703+ private static InteropDescriptor Register ( string name , string handler , long fixedPrice , CallFlags requiredCallFlags , Hardfork ? hardfork = null )
695704 {
696705 var flags = BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . Static ;
697- MethodInfo method = typeof ( ApplicationEngine ) . GetMethod ( handler , flags )
706+ var method = typeof ( ApplicationEngine ) . GetMethod ( handler , flags )
698707 ?? typeof ( ApplicationEngine ) . GetProperty ( handler , flags ) . GetMethod ;
699- InteropDescriptor descriptor = new ( )
708+ var descriptor = new InteropDescriptor ( )
700709 {
701710 Name = name ,
702711 Handler = method ,
712+ Hardfork = hardfork ,
703713 FixedPrice = fixedPrice ,
704714 RequiredCallFlags = requiredCallFlags
705715 } ;
706- services ??= new Dictionary < uint , InteropDescriptor > ( ) ;
716+ services ??= [ ] ;
707717 services . Add ( descriptor . Hash , descriptor ) ;
708718 return descriptor ;
709719 }
0 commit comments