Skip to content

Commit

Permalink
remove nightly condition for alt_bn256
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp committed Apr 19, 2024
1 parent 2fb8105 commit c7d73ab
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
6 changes: 0 additions & 6 deletions packages/near-sdk-js/builder/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@ static JSValue near_uint8array_to_utf8_string(JSContext *ctx, JSValueConst this_
return JS_NewStringLen(ctx, (const char *)data_ptr, data_len);
}

#ifdef NIGHTLY
static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
{
uint64_t register_id;
Expand Down Expand Up @@ -1104,7 +1103,6 @@ static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_va
ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr);
return JS_NewBigUint64(ctx, ret);
}
#endif

static void js_add_near_host_functions(JSContext* ctx) {
JSValue global_obj, env;
Expand Down Expand Up @@ -1165,13 +1163,9 @@ static void js_add_near_host_functions(JSContext* ctx) {
JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2));
JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2));
JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1));
#ifdef NIGHTLY
// as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet
// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet.
JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2));
JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2));
JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1));
#endif

JS_SetPropertyStr(ctx, env, "latin1_string_to_uint8array", JS_NewCFunction(ctx, near_latin1_string_to_uint8array, "latin1_string_to_uint8array", 1));
JS_SetPropertyStr(ctx, env, "utf8_string_to_uint8array", JS_NewCFunction(ctx, near_utf8_string_to_uint8array, "utf8_string_to_uint8array", 1));
Expand Down
4 changes: 1 addition & 3 deletions tests/__tests__/test_math_api.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,4 @@ test("ecrecover", async (t) => {
);
});

// As of Jun 24, 2022, near-sandbox is using 97c0410de519ecaca369aaee26f0ca5eb9e7de06, in which alt_bn256 is still
// under nightly protocol feature. As near-sandbox is built without nightly protocol feature, alt_bn256 operations
// cannot be tested yet
// TODO add test for alt_bn256 functions

0 comments on commit c7d73ab

Please sign in to comment.