@@ -245,6 +245,20 @@ namespace wavm_host_module {
245
245
interface.top ()->eeiSelfDestruct (addressOffset);
246
246
}
247
247
248
+ // the host module is called 'bignum'
249
+ DEFINE_INTRINSIC_MODULE (bignum)
250
+
251
+ // host functions follow
252
+ DEFINE_INTRINSIC_FUNCTION (bignum, " mul256" , void , mul256, U32 a, U32 b, U32 ret)
253
+ {
254
+ interface.top ()->mul256 (a, b, ret);
255
+ }
256
+
257
+ DEFINE_INTRINSIC_FUNCTION (bignum, " umulmod256" , void , umulmod246, U32 a, U32 b, U32 mod, U32 ret)
258
+ {
259
+ interface.top ()->umulmod256 (a, b, mod, ret);
260
+ }
261
+
248
262
// this is needed for resolving names of imported host functions
249
263
struct HeraWavmResolver : Runtime::Resolver {
250
264
HashMap<string, Runtime::ModuleInstance*> moduleNameToInstanceMap;
@@ -345,10 +359,14 @@ ExecutionResult WavmEngine::internalExecute(
345
359
Runtime::GCPointer<Runtime::ModuleInstance> ethereumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (ethereum), " ethereum" , {});
346
360
heraAssert (ethereumHostModule, " Failed to create host module." );
347
361
362
+ Runtime::GCPointer<Runtime::ModuleInstance> bignumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (bignum), " bignum" , {});
363
+ heraAssert (bignumHostModule, " Failed to create host module." );
364
+
348
365
// prepare contract module to resolve links against host module
349
366
wavm_host_module::HeraWavmResolver resolver;
350
367
// TODO: move this into the constructor?
351
368
resolver.moduleNameToInstanceMap .set (" ethereum" , ethereumHostModule);
369
+ resolver.moduleNameToInstanceMap .set (" bignum" , bignumHostModule);
352
370
Runtime::LinkResult linkResult = Runtime::linkModule (moduleIR, resolver);
353
371
ensureCondition (linkResult.success , ContractValidationFailure, " Couldn't link contract against host module." );
354
372
@@ -453,7 +471,7 @@ void WavmEngine::verifyContract(vector<uint8_t> const& code)
453
471
454
472
for (auto const & import: moduleIR.functions .imports ) {
455
473
#if HERA_DEBUGGING
456
- if (import.moduleName == " debug" )
474
+ if (import.moduleName == " debug" || import. moduleName == " bignum " )
457
475
continue ;
458
476
#endif
459
477
0 commit comments