@@ -249,6 +249,20 @@ namespace wavm_host_module {
249
249
interface.top ()->eeiSelfDestruct (addressOffset);
250
250
}
251
251
252
+ // the host module is called 'bignum'
253
+ DEFINE_INTRINSIC_MODULE (bignum)
254
+
255
+ // host functions follow
256
+ DEFINE_INTRINSIC_FUNCTION (bignum, " mul256" , void , mul256, U32 a, U32 b, U32 ret)
257
+ {
258
+ interface.top ()->mul256 (a, b, ret);
259
+ }
260
+
261
+ DEFINE_INTRINSIC_FUNCTION (bignum, " umulmod256" , void , umulmod246, U32 a, U32 b, U32 mod, U32 ret)
262
+ {
263
+ interface.top ()->umulmod256 (a, b, mod, ret);
264
+ }
265
+
252
266
// this is needed for resolving names of imported host functions
253
267
struct HeraWavmResolver : Runtime::Resolver {
254
268
HashMap<string, Runtime::ModuleInstance*> moduleNameToInstanceMap;
@@ -349,10 +363,14 @@ ExecutionResult WavmEngine::internalExecute(
349
363
Runtime::GCPointer<Runtime::ModuleInstance> ethereumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (ethereum), " ethereum" , {});
350
364
heraAssert (ethereumHostModule, " Failed to create host module." );
351
365
366
+ Runtime::GCPointer<Runtime::ModuleInstance> bignumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (bignum), " bignum" , {});
367
+ heraAssert (bignumHostModule, " Failed to create host module." );
368
+
352
369
// prepare contract module to resolve links against host module
353
370
wavm_host_module::HeraWavmResolver resolver;
354
371
// TODO: move this into the constructor?
355
372
resolver.moduleNameToInstanceMap .set (" ethereum" , ethereumHostModule);
373
+ resolver.moduleNameToInstanceMap .set (" bignum" , bignumHostModule);
356
374
Runtime::LinkResult linkResult = Runtime::linkModule (moduleIR, resolver);
357
375
ensureCondition (linkResult.success , ContractValidationFailure, " Couldn't link contract against host module." );
358
376
@@ -457,7 +475,7 @@ void WavmEngine::verifyContract(bytes_view code)
457
475
458
476
for (auto const & import : moduleIR.functions .imports ) {
459
477
#if HERA_DEBUGGING
460
- if (import .moduleName == " debug" )
478
+ if (import .moduleName == " debug" || import . moduleName == " bignum " )
461
479
continue ;
462
480
#endif
463
481
0 commit comments