diff --git a/hook/sfcodes.h b/hook/sfcodes.h index 131e74bb1..efa8e0961 100644 --- a/hook/sfcodes.h +++ b/hook/sfcodes.h @@ -15,8 +15,7 @@ #define sfHookEmitCount ((1U << 16U) + 18U) #define sfHookExecutionIndex ((1U << 16U) + 19U) #define sfHookApiVersion ((1U << 16U) + 20U) -#define sfHookStateScale ((1U << 16U) + 21U) -#define sfHookStateCapacity ((1U << 16U) + 22U) +#define sfHookStateCapacity ((1U << 16U) + 21U) #define sfNetworkID ((2U << 16U) + 1U) #define sfFlags ((2U << 16U) + 2U) #define sfSourceTag ((2U << 16U) + 3U) diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index 632f518a2..904288ca8 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -354,7 +354,6 @@ extern SF_UINT16 const sfHookStateChangeCount; extern SF_UINT16 const sfHookEmitCount; extern SF_UINT16 const sfHookExecutionIndex; extern SF_UINT16 const sfHookApiVersion; -extern SF_UINT16 const sfHookStateScale; extern SF_UINT16 const sfHookStateCapacity; // 32-bit integers (common) diff --git a/src/ripple/protocol/impl/SField.cpp b/src/ripple/protocol/impl/SField.cpp index 92aefb9b7..9721ab5d7 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/ripple/protocol/impl/SField.cpp @@ -102,8 +102,7 @@ CONSTRUCT_TYPED_SFIELD(sfHookStateChangeCount, "HookStateChangeCount", UINT16, CONSTRUCT_TYPED_SFIELD(sfHookEmitCount, "HookEmitCount", UINT16, 18); CONSTRUCT_TYPED_SFIELD(sfHookExecutionIndex, "HookExecutionIndex", UINT16, 19); CONSTRUCT_TYPED_SFIELD(sfHookApiVersion, "HookApiVersion", UINT16, 20); -CONSTRUCT_TYPED_SFIELD(sfHookStateScale, "HookStateScale", UINT16, 21); -CONSTRUCT_TYPED_SFIELD(sfHookStateCapacity, "HookStateCapacity", UINT16, 22); +CONSTRUCT_TYPED_SFIELD(sfHookStateCapacity, "HookStateCapacity", UINT16, 21); // 32-bit integers (common) CONSTRUCT_TYPED_SFIELD(sfNetworkID, "NetworkID", UINT32, 1); diff --git a/src/test/app/SetHook_test.cpp b/src/test/app/SetHook_test.cpp index 966f04094..aafe8a078 100644 --- a/src/test/app/SetHook_test.cpp +++ b/src/test/app/SetHook_test.cpp @@ -997,111 +997,6 @@ public: BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == (fixNS ? 1 : 2)); BEAST_EXPECT(!(env.le("alice")->isFieldPresent(sfHookStateCount))); } - - if (env.current()->rules().enabled(featureExtendedHookState)) - { - // Test hook with scaled state data - TestHook scaled_state_wasm = wasm[ - R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t - read_len, int64_t error_code); extern int64_t rollback - (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set (uint32_t read_ptr, uint32_t - read_len, uint32_t kread_ptr, uint32_t kread_len); - - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - extern int64_t slot_set(uint32_t, uint32_t, uint32_t); - extern int64_t slot_subfield(uint32_t, uint32_t, uint32_t); - extern int64_t slot(uint32_t, uint32_t, uint32_t); - extern int64_t hook_account(uint32_t, uint32_t); - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - - #define SBUF(x) x, sizeof(x) - #define TOO_BIG -3 - #define DOESNT_EXIST -5 - #define KEYLET_ACCOUNT 3 - - #define sfHookStateScale ((1U << 16U) + 21U) - - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x,sizeof(#x),__LINE__) - int64_t hook(uint32_t reserved ) - { - _g(1,1); - - uint8_t hook_acc[20]; - ASSERT(hook_account(hook_acc, 20) == 20); - uint8_t account_keylet[34]; - ASSERT(util_keylet(account_keylet, 34, KEYLET_ACCOUNT, - hook_acc, 20, 0,0,0,0) == 34); - - ASSERT(slot_set(account_keylet, 34, 1) == 1); - slot_subfield(1, sfHookStateScale, 2); - int64_t scale = slot(0,0,2); - - if (scale == 5) { - ASSERT(state_set(0, 256, SBUF("test1")) == 256); - ASSERT(state_set(0, 256*2, SBUF("test2")) == 256*2); - ASSERT(state_set(0, 256*3, SBUF("test3")) == 256*3); - ASSERT(state_set(0, 256*4, SBUF("test4")) == 256*4); - ASSERT(state_set(0, 256*5, SBUF("test5")) == 256*5); - ASSERT(state_set(0, 256*5+1, SBUF("test")) == TOO_BIG); - accept(0,0,scale); - } - rollback(0,0,scale); - } - )[test.hook]"]; - - HASH_WASM(scaled_state); - BEAST_EXPECT(!env.le(carol)->isFieldPresent(sfHookStateCount)); - - // Install hook on carol - Json::Value jv = - ripple::test::jtx::hook(carol, {{hso(scaled_state_wasm)}}, 0); - jv[jss::Hooks][0U][jss::Hook][jss::HookNamespace] = ns_str; - jv[jss::Hooks][0U][jss::Hook][jss::HookOn] = - to_string(UINT256_BIT[ttACCOUNT_SET]); - env(jv, M("Create scaled state hook"), HSFEE, ter(tesSUCCESS)); - env.close(); - - BEAST_EXPECT((*env.le(carol))[sfOwnerCount] == 1); - BEAST_EXPECT(!env.le(carol)->isFieldPresent(sfHookStateCount)); - - { - // HookStateScale => 5 - Json::Value jv = noop(carol); - jv[sfHookStateScale.fieldName] = 5; - env(jv, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(carol))[sfOwnerCount] == 1); - BEAST_EXPECT(!env.le(carol)->isFieldPresent(sfHookStateCount)); - - Json::Value invoke = invoke::invoke(carol); - env(invoke, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(carol))[sfOwnerCount] == 26); - BEAST_EXPECT((*env.le(carol))[sfHookStateCount] == 5); - } - - // Delete namespace to clean up state - Json::Value iv; - iv[jss::Flags] = hsfNSDELETE; - iv[jss::HookNamespace] = ns_str; - jv[jss::Hooks][0U][jss::Hook] = iv; - env(jv, M("Delete namespace"), HSFEE); - env.close(); - - // Verify state cleanup - BEAST_EXPECT( - (*env.le(carol))[sfOwnerCount] == features[fixNSDelete] ? 1 - : 26); - BEAST_EXPECT(!env.le(carol)->isFieldPresent(sfHookStateCount)); - } } void @@ -9234,8 +9129,9 @@ public: params[0U][jss::HookParameter][jss::HookParameterName] = strHex(std::string("SIZE")); params[0U][jss::HookParameter][jss::HookParameterValue] = - features[featureExtendedHookState] ? "0108" /* 2049 */ - : "0101" /* 257 */; + features[featureExtendedHookState] + ? "0110" /* 4097 - exceeds 4096 max */ + : "0101" /* 257 */; payJv1[jss::HookParameters] = params; } env(payJv1, @@ -9259,8 +9155,9 @@ public: params[0U][jss::HookParameter][jss::HookParameterName] = strHex(std::string("SIZE")); params[0U][jss::HookParameter][jss::HookParameterValue] = - features[featureExtendedHookState] ? "0108" /* 2049 */ - : "0101" /* 257 */; + features[featureExtendedHookState] + ? "0110" /* 4097 - exceeds 4096 max */ + : "0101" /* 257 */; payJv2[jss::HookParameters] = params; } env(payJv2, M("test state_set 1"), fee(XRP(1))); @@ -9905,210 +9802,6 @@ public: BEAST_EXPECT((*env.le("frank"))[sfOwnerCount] == 260); } - if (env.current()->rules().enabled(featureExtendedHookState)) - { - // Test hook with scaled state data - TestHook scaled_state_wasm = wasm[ - R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t - read_len, int64_t error_code); extern int64_t rollback - (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set (uint32_t read_ptr, uint32_t - read_len, uint32_t kread_ptr, uint32_t kread_len); - - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - extern int64_t slot_set(uint32_t, uint32_t, uint32_t); - extern int64_t slot_subfield(uint32_t, uint32_t, uint32_t); - extern int64_t slot(uint32_t, uint32_t, uint32_t); - extern int64_t hook_account(uint32_t, uint32_t); - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - - #define SBUF(x) x, sizeof(x) - #define TOO_BIG -3 - #define DOESNT_EXIST -5 - #define KEYLET_ACCOUNT 3 - - #define sfHookStateScale ((1U << 16U) + 21U) - - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x,sizeof(#x),__LINE__) - int64_t hook(uint32_t reserved ) - { - _g(1,1); - - uint8_t hook_acc[20]; - ASSERT(hook_account(hook_acc, 20) == 20); - uint8_t account_keylet[34]; - ASSERT(util_keylet(account_keylet, 34, KEYLET_ACCOUNT, - hook_acc, 20, 0,0,0,0) == 34); - - ASSERT(slot_set(account_keylet, 34, 1) == 1); - slot_subfield(1, sfHookStateScale, 2); - int64_t scale = slot(0,0,2); - - if (scale == DOESNT_EXIST) { - ASSERT(state_set(0, 256, SBUF("test0")) == 256); - ASSERT(state_set(0, 257, SBUF("test")) == TOO_BIG); - accept(0,0,scale); - } - if (scale == 2) { - ASSERT(state_set(0, 256, SBUF("test1")) == 256); - ASSERT(state_set(0, 256*2, SBUF("test2")) == 256*2); - ASSERT(state_set(0, 256*2+1, SBUF("test")) == - TOO_BIG); accept(0,0,scale); - } - if (scale == 5) { - ASSERT(state_set(0, 256, SBUF("test3")) == 256); - ASSERT(state_set(0, 256*5, SBUF("test4")) == 256*5); - ASSERT(state_set(0, 256*5+1, SBUF("test")) == - TOO_BIG); accept(0,0,scale); - } - rollback(0,0,scale); - } - )[test.hook]"]; - - HASH_WASM(scaled_state); - BEAST_EXPECT(!env.le(gary)->isFieldPresent(sfHookStateCount)); - - // Install hook on carol - Json::Value jv = - ripple::test::jtx::hook(gary, {{hso(scaled_state_wasm)}}, 0); - // jv[jss::Hooks][0U][jss::Hook][jss::HookNamespace] = ns_str; - jv[jss::Hooks][0U][jss::Hook][jss::HookOn] = - to_string(UINT256_BIT[ttACCOUNT_SET]); - env(jv, M("Create scaled state hook"), HSFEE, ter(tesSUCCESS)); - env.close(); - - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 1); - BEAST_EXPECT(!env.le(gary)->isFieldPresent(sfHookStateCount)); - - { - // no HookStateScale - Json::Value invoke = invoke::invoke(gary); - env(invoke, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 2); - BEAST_EXPECT((*env.le(gary))[sfHookStateCount] == 1); - } - - { - // HookStateScale => 2 - Json::Value jv = noop(gary); - jv[sfHookStateScale.fieldName] = 2; - env(jv, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 3); - BEAST_EXPECT((*env.le(gary))[sfHookStateCount] == 1); - - Json::Value invoke = invoke::invoke(gary); - env(invoke, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 7); - BEAST_EXPECT((*env.le(gary))[sfHookStateCount] == 3); - } - { - // HookStateScale => 5 - Json::Value jv = noop(gary); - jv[sfHookStateScale.fieldName] = 5; - env(jv, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 16); - BEAST_EXPECT((*env.le(gary))[sfHookStateCount] == 3); - - Json::Value invoke = invoke::invoke(gary); - env(invoke, HSFEE); - env.close(); - BEAST_EXPECT((*env.le(gary))[sfOwnerCount] == 26); - BEAST_EXPECT((*env.le(gary))[sfHookStateCount] == 5); - } - } - - { - bool extHookStateEnabled = features[featureExtendedHookState]; - // tests for set_state_cache - if (extHookStateEnabled) - { - TestHook extended_state_reserve_hook = wasm[R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set ( - uint32_t read_ptr, - uint32_t read_len, - uint32_t kread_ptr, - uint32_t kread_len - ); - extern int64_t state_foreign_set ( - uint32_t read_ptr, - uint32_t read_len, - uint32_t kread_ptr, - uint32_t kread_len, - uint32_t nread_ptr, - uint32_t nread_len, - uint32_t aread_ptr, - uint32_t aread_len - ); - extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); - #define RESERVE_INSUFFICIENT -38 - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x, sizeof(#x), __LINE__); - #define ASSERT_EQUAL(x, y)\ - if (!(x == y))\ - rollback((uint32_t)#x, sizeof(#x), x); - int64_t hook(uint32_t reserved) - { - _g(1,1); - { - // 1. first account for StateMap - ASSERT_EQUAL(state_set(0, 1, "1", 1), RESERVE_INSUFFICIENT); - // 2. first namespace for StateMap - ASSERT_EQUAL(state_foreign_set(0, 1, "1", 1, "1", 32, 0, 0), RESERVE_INSUFFICIENT); - // 3. first statekey for StateMap - ASSERT_EQUAL(state_set(0, 1, "2", 1), RESERVE_INSUFFICIENT); - // 4. existing statedata - ASSERT_EQUAL(state_set(0, 1, "1", 1), RESERVE_INSUFFICIENT); - } - accept(0,0,0); - } - )[test.hook]"]; - - // install the hook on gary - Json::Value jv = hso(extended_state_reserve_hook, overrideFlag); - jv[jss::HookOn] = - "fffffffffffffffffffffffffffffffffffffff7ffffffffffffffffff" - "bfffff"; // only invoke high - env(ripple::test::jtx::hook(hank, {{jv}}, 0), HSFEE); - env.close(); - - Json::Value jv1 = noop(hank); - jv1[sfHookStateScale.fieldName] = 8; - env(jv1, HSFEE); - env.close(); - - auto const caller = Account{"caller"}; - env.fund(XRP(10000), caller); - env.close(); - auto const payAmount = env.balance(hank) - - (env.current()->fees().accountReserve(1 + 8)) - - drops(1); // 8 + Hook - // reduce hank's balance - env(pay(hank, Account{"master"}, payAmount), fee(XRP(1))); - env.close(); - - // invoke the hook from alice - Json::Value invokeJv5 = invoke::invoke(caller, hank, ""); - env(invokeJv5, M("test state_set 15"), fee(XRP(1))); - env.close(); - } - } - // RH TODO: // check state can be set on emit callback // check namespacing provides for non-collision of same key @@ -13969,14 +13662,21 @@ public: } void - testWithFeatures(FeatureBitset features) + testWithFeaturesFast(FeatureBitset features) { test_high_water_mark_capacity(features); + test_state(features); // + test_state_foreign(features); // + test_state_foreign_set(features); // + test_state_foreign_set_max(features); // + test_state_set(features); // } void - testWithFeaturesX(FeatureBitset features) + testWithFeatures(FeatureBitset features) { + test_high_water_mark_capacity(features); + testHooksOwnerDir(features); testHooksDisabled(features); testTxStructure(features); diff --git a/src/test/app/SetHook_wasm.h b/src/test/app/SetHook_wasm.h index 17420fd09..d5bfccab5 100644 --- a/src/test/app/SetHook_wasm.h +++ b/src/test/app/SetHook_wasm.h @@ -10,187 +10,6 @@ namespace ripple { namespace test { std::map> wasm = { /* ==== WASM: 0 ==== */ - {R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t - read_len, int64_t error_code); extern int64_t rollback - (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set (uint32_t read_ptr, uint32_t - read_len, uint32_t kread_ptr, uint32_t kread_len); - - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - extern int64_t slot_set(uint32_t, uint32_t, uint32_t); - extern int64_t slot_subfield(uint32_t, uint32_t, uint32_t); - extern int64_t slot(uint32_t, uint32_t, uint32_t); - extern int64_t hook_account(uint32_t, uint32_t); - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - - #define SBUF(x) x, sizeof(x) - #define TOO_BIG -3 - #define DOESNT_EXIST -5 - #define KEYLET_ACCOUNT 3 - - #define sfHookStateScale ((1U << 16U) + 21U) - - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x,sizeof(#x),__LINE__) - int64_t hook(uint32_t reserved ) - { - _g(1,1); - - uint8_t hook_acc[20]; - ASSERT(hook_account(hook_acc, 20) == 20); - uint8_t account_keylet[34]; - ASSERT(util_keylet(account_keylet, 34, KEYLET_ACCOUNT, - hook_acc, 20, 0,0,0,0) == 34); - - ASSERT(slot_set(account_keylet, 34, 1) == 1); - slot_subfield(1, sfHookStateScale, 2); - int64_t scale = slot(0,0,2); - - if (scale == 5) { - ASSERT(state_set(0, 256, SBUF("test1")) == 256); - ASSERT(state_set(0, 256*2, SBUF("test2")) == 256*2); - ASSERT(state_set(0, 256*3, SBUF("test3")) == 256*3); - ASSERT(state_set(0, 256*4, SBUF("test4")) == 256*4); - ASSERT(state_set(0, 256*5, SBUF("test5")) == 256*5); - ASSERT(state_set(0, 256*5+1, SBUF("test")) == TOO_BIG); - accept(0,0,scale); - } - rollback(0,0,scale); - } - )[test.hook]", - { - 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x35U, - 0x07U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU, - 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, - 0x60U, 0x09U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, - 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, - 0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x01U, - 0x7FU, 0x01U, 0x7EU, 0x02U, 0x89U, 0x01U, 0x09U, 0x03U, 0x65U, 0x6EU, - 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, - 0x0CU, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x61U, 0x63U, 0x63U, 0x6FU, - 0x75U, 0x6EU, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, - 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, - 0x03U, 0x65U, 0x6EU, 0x76U, 0x0BU, 0x75U, 0x74U, 0x69U, 0x6CU, 0x5FU, - 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x00U, 0x03U, 0x03U, 0x65U, - 0x6EU, 0x76U, 0x08U, 0x73U, 0x6CU, 0x6FU, 0x74U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0DU, 0x73U, 0x6CU, - 0x6FU, 0x74U, 0x5FU, 0x73U, 0x75U, 0x62U, 0x66U, 0x69U, 0x65U, 0x6CU, - 0x64U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x04U, 0x73U, 0x6CU, - 0x6FU, 0x74U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x09U, 0x73U, - 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x00U, 0x05U, - 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, - 0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x06U, 0x05U, 0x03U, 0x01U, - 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xC0U, 0x8BU, - 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xBDU, 0x0BU, 0x0BU, 0x7FU, 0x00U, - 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xC0U, 0x8BU, 0x04U, - 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, - 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x09U, 0x0AU, 0x81U, 0x84U, - 0x00U, 0x01U, 0xFDU, 0x83U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU, - 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0xD0U, 0x00U, 0x6BU, - 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, - 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, - 0x40U, 0x20U, 0x01U, 0x41U, 0x30U, 0x6AU, 0x41U, 0x14U, 0x10U, 0x81U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x14U, 0x51U, 0x0DU, 0x00U, 0x41U, - 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x21U, 0x42U, 0x22U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, - 0x01U, 0x41U, 0x22U, 0x41U, 0x03U, 0x20U, 0x01U, 0x41U, 0x30U, 0x6AU, - 0x41U, 0x14U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, - 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x22U, 0x51U, 0x0DU, - 0x00U, 0x41U, 0xA1U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0xCDU, 0x00U, - 0x42U, 0x25U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, - 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x22U, 0x41U, 0x01U, 0x10U, 0x84U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x01U, 0x51U, 0x0DU, 0x00U, 0x41U, - 0xEEU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x25U, 0x42U, 0x27U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x41U, - 0x95U, 0x80U, 0x04U, 0x41U, 0x02U, 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x02U, - 0x10U, 0x86U, 0x80U, 0x80U, 0x80U, 0x00U, 0x22U, 0x02U, 0x42U, 0x05U, - 0x52U, 0x0DU, 0x00U, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, 0x02U, - 0x41U, 0x93U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x02U, 0x51U, 0x0DU, 0x00U, - 0x41U, 0x99U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x28U, 0x42U, 0x2CU, - 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, - 0x41U, 0x00U, 0x41U, 0x80U, 0x04U, 0x41U, 0xC1U, 0x89U, 0x80U, 0x80U, - 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, - 0x80U, 0x04U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xC7U, 0x89U, 0x80U, 0x80U, - 0x00U, 0x41U, 0x2CU, 0x42U, 0x2DU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, 0x06U, - 0x41U, 0xF3U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x06U, 0x51U, 0x0DU, 0x00U, - 0x41U, 0xF9U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x2EU, - 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, - 0x41U, 0x00U, 0x41U, 0x80U, 0x08U, 0x41U, 0xA5U, 0x8AU, 0x80U, 0x80U, - 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, - 0x80U, 0x08U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xABU, 0x8AU, 0x80U, 0x80U, - 0x00U, 0x41U, 0x2CU, 0x42U, 0x2FU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, 0x0AU, - 0x41U, 0xD7U, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x0AU, 0x51U, 0x0DU, 0x00U, - 0x41U, 0xDDU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x30U, - 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, - 0x41U, 0x00U, 0x41U, 0x81U, 0x0AU, 0x41U, 0x89U, 0x8BU, 0x80U, 0x80U, - 0x00U, 0x41U, 0x05U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, - 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x8EU, 0x8BU, 0x80U, 0x80U, 0x00U, - 0x41U, 0x2FU, 0x42U, 0x31U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x05U, 0x10U, 0x88U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, - 0x20U, 0x02U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, - 0x01U, 0x41U, 0xD0U, 0x00U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x20U, 0x02U, 0x0BU, 0x0BU, 0xC5U, 0x03U, 0x01U, 0x00U, 0x41U, - 0x80U, 0x08U, 0x0BU, 0xBDU, 0x03U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, - 0x61U, 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, 0x74U, 0x28U, 0x68U, 0x6FU, - 0x6FU, 0x6BU, 0x5FU, 0x61U, 0x63U, 0x63U, 0x2CU, 0x20U, 0x32U, 0x30U, - 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x30U, 0x00U, 0x75U, 0x74U, - 0x69U, 0x6CU, 0x5FU, 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x28U, - 0x61U, 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, 0x74U, 0x5FU, 0x6BU, 0x65U, - 0x79U, 0x6CU, 0x65U, 0x74U, 0x2CU, 0x20U, 0x33U, 0x34U, 0x2CU, 0x20U, - 0x4BU, 0x45U, 0x59U, 0x4CU, 0x45U, 0x54U, 0x5FU, 0x41U, 0x43U, 0x43U, - 0x4FU, 0x55U, 0x4EU, 0x54U, 0x2CU, 0x20U, 0x68U, 0x6FU, 0x6FU, 0x6BU, - 0x5FU, 0x61U, 0x63U, 0x63U, 0x2CU, 0x20U, 0x32U, 0x30U, 0x2CU, 0x20U, - 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x33U, 0x34U, 0x00U, 0x73U, 0x6CU, 0x6FU, 0x74U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x61U, 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, - 0x74U, 0x5FU, 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x2CU, 0x20U, - 0x33U, 0x34U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, - 0x31U, 0x00U, 0x74U, 0x65U, 0x73U, 0x74U, 0x31U, 0x00U, 0x73U, 0x74U, - 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, - 0x20U, 0x32U, 0x35U, 0x36U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, - 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x31U, 0x22U, 0x29U, 0x29U, - 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x32U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2AU, 0x32U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, - 0x74U, 0x65U, 0x73U, 0x74U, 0x32U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x32U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x33U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2AU, 0x33U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, - 0x74U, 0x65U, 0x73U, 0x74U, 0x33U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x33U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x34U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2AU, 0x34U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, - 0x74U, 0x65U, 0x73U, 0x74U, 0x34U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x34U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x35U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2AU, 0x35U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, - 0x74U, 0x65U, 0x73U, 0x74U, 0x35U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x35U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, - 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, - 0x35U, 0x2BU, 0x31U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, - 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, - }}, - - /* ==== WASM: 1 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32) (result i64))) @@ -240,7 +59,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 2 ==== */ + /* ==== WASM: 1 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32) (result i64))) @@ -294,7 +113,7 @@ std::map> wasm = { 0x14U, 0x10U, 0x00U, 0x1AU, 0x0CU, 0x00U, 0x0BU, 0x0BU, }}, - /* ==== WASM: 3 ==== */ + /* ==== WASM: 2 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -361,7 +180,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x20U, 0x02U, 0x0BU, }}, - /* ==== WASM: 4 ==== */ + /* ==== WASM: 3 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -467,7 +286,7 @@ std::map> wasm = { 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x03U, 0x0BU, }}, - /* ==== WASM: 5 ==== */ + /* ==== WASM: 4 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -542,7 +361,7 @@ std::map> wasm = { 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x05U, 0x0BU, }}, - /* ==== WASM: 6 ==== */ + /* ==== WASM: 5 ==== */ {R"[test.hook]( #include extern int32_t _g(uint32_t, uint32_t); @@ -1159,7 +978,7 @@ std::map> wasm = { 0x78U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 7 ==== */ + /* ==== WASM: 6 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1264,7 +1083,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 8 ==== */ + /* ==== WASM: 7 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1361,7 +1180,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 9 ==== */ + /* ==== WASM: 8 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1484,7 +1303,7 @@ std::map> wasm = { 0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U, }}, - /* ==== WASM: 10 ==== */ + /* ==== WASM: 9 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1564,7 +1383,7 @@ std::map> wasm = { 0x54U, 0x00U, }}, - /* ==== WASM: 11 ==== */ + /* ==== WASM: 10 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1609,7 +1428,7 @@ std::map> wasm = { 0x30U, 0x00U, }}, - /* ==== WASM: 12 ==== */ + /* ==== WASM: 11 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1928,7 +1747,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 13 ==== */ + /* ==== WASM: 12 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -2714,7 +2533,7 @@ std::map> wasm = { 0x37U, 0x36U, 0x33U, 0x4CU, 0x4CU, 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 14 ==== */ + /* ==== WASM: 13 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3104,7 +2923,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 15 ==== */ + /* ==== WASM: 14 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3285,7 +3104,7 @@ std::map> wasm = { 0x38U, 0x4CU, 0x4CU, 0x29U, 0x00U, }}, - /* ==== WASM: 16 ==== */ + /* ==== WASM: 15 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3474,7 +3293,7 @@ std::map> wasm = { 0x29U, 0x00U, }}, - /* ==== WASM: 17 ==== */ + /* ==== WASM: 16 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3713,7 +3532,7 @@ std::map> wasm = { 0x00U, 0x42U, 0x00U, 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 18 ==== */ + /* ==== WASM: 17 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -4415,7 +4234,7 @@ std::map> wasm = { 0x38U, 0x35U, 0x35U, 0x32U, 0x55U, 0x29U, 0x00U, }}, - /* ==== WASM: 19 ==== */ + /* ==== WASM: 18 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5760,7 +5579,7 @@ std::map> wasm = { 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 20 ==== */ + /* ==== WASM: 19 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5862,7 +5681,7 @@ std::map> wasm = { 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 21 ==== */ + /* ==== WASM: 20 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5905,7 +5724,7 @@ std::map> wasm = { 0x00U, 0x0BU, }}, - /* ==== WASM: 22 ==== */ + /* ==== WASM: 21 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6053,7 +5872,7 @@ std::map> wasm = { 0x34U, 0x34U, 0x4CU, 0x4CU, 0x2CU, 0x20U, 0x33U, 0x29U, 0x00U, }}, - /* ==== WASM: 23 ==== */ + /* ==== WASM: 22 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6381,7 +6200,7 @@ std::map> wasm = { 0x38U, 0x34U, 0x39U, 0x30U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 24 ==== */ + /* ==== WASM: 23 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6586,7 +6405,7 @@ std::map> wasm = { 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 25 ==== */ + /* ==== WASM: 24 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -7270,7 +7089,7 @@ std::map> wasm = { 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 26 ==== */ + /* ==== WASM: 25 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -7565,7 +7384,7 @@ std::map> wasm = { 0x32U, 0x34U, 0x31U, 0x36U, 0x55U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 27 ==== */ + /* ==== WASM: 26 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8278,7 +8097,7 @@ std::map> wasm = { 0x31U, 0x33U, 0x33U, 0x38U, 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 28 ==== */ + /* ==== WASM: 27 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8363,7 +8182,7 @@ std::map> wasm = { 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x30U, 0x00U, }}, - /* ==== WASM: 29 ==== */ + /* ==== WASM: 28 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8425,7 +8244,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 30 ==== */ + /* ==== WASM: 29 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8502,7 +8321,7 @@ std::map> wasm = { 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 31 ==== */ + /* ==== WASM: 30 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8579,7 +8398,7 @@ std::map> wasm = { 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 32 ==== */ + /* ==== WASM: 31 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8836,7 +8655,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 33 ==== */ + /* ==== WASM: 32 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8994,7 +8813,7 @@ std::map> wasm = { 0x04U, 0x00U, 0x00U, }}, - /* ==== WASM: 34 ==== */ + /* ==== WASM: 33 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9347,7 +9166,7 @@ std::map> wasm = { 0x00U, 0x2AU, 0x04U, 0x00U, 0x00U, 0x31U, 0x04U, 0x00U, 0x00U, }}, - /* ==== WASM: 35 ==== */ + /* ==== WASM: 34 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9380,7 +9199,7 @@ std::map> wasm = { 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 36 ==== */ + /* ==== WASM: 35 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9607,7 +9426,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 37 ==== */ + /* ==== WASM: 36 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9638,7 +9457,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 38 ==== */ + /* ==== WASM: 37 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9949,7 +9768,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 39 ==== */ + /* ==== WASM: 38 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10026,7 +9845,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 40 ==== */ + /* ==== WASM: 39 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10060,7 +9879,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 41 ==== */ + /* ==== WASM: 40 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10147,7 +9966,7 @@ std::map> wasm = { 0x32U, 0x00U, }}, - /* ==== WASM: 42 ==== */ + /* ==== WASM: 41 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10181,7 +10000,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 43 ==== */ + /* ==== WASM: 42 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10321,7 +10140,7 @@ std::map> wasm = { 0x54U, 0x5FU, 0x4DU, 0x45U, 0x54U, 0x00U, }}, - /* ==== WASM: 44 ==== */ + /* ==== WASM: 43 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10511,7 +10330,7 @@ std::map> wasm = { 0x31U, 0x34U, 0x00U, }}, - /* ==== WASM: 45 ==== */ + /* ==== WASM: 44 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10665,7 +10484,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 46 ==== */ + /* ==== WASM: 45 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10826,7 +10645,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 47 ==== */ + /* ==== WASM: 46 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10983,7 +10802,7 @@ std::map> wasm = { 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 48 ==== */ + /* ==== WASM: 47 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11068,7 +10887,7 @@ std::map> wasm = { 0x74U, 0x79U, 0x70U, 0x65U, 0x28U, 0x29U, 0x00U, }}, - /* ==== WASM: 49 ==== */ + /* ==== WASM: 48 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11325,7 +11144,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 50 ==== */ + /* ==== WASM: 49 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11563,7 +11382,7 @@ std::map> wasm = { 0x3EU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 51 ==== */ + /* ==== WASM: 50 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11659,7 +11478,7 @@ std::map> wasm = { 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 52 ==== */ + /* ==== WASM: 51 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11769,7 +11588,7 @@ std::map> wasm = { 0x20U, 0x31U, 0x00U, }}, - /* ==== WASM: 53 ==== */ + /* ==== WASM: 52 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11899,7 +11718,7 @@ std::map> wasm = { 0x30U, 0x30U, 0x30U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 54 ==== */ + /* ==== WASM: 53 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12173,7 +11992,7 @@ std::map> wasm = { 0x30U, 0x00U, }}, - /* ==== WASM: 55 ==== */ + /* ==== WASM: 54 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12310,7 +12129,7 @@ std::map> wasm = { 0x2CU, 0x20U, 0x73U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x00U, }}, - /* ==== WASM: 56 ==== */ + /* ==== WASM: 55 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12604,7 +12423,7 @@ std::map> wasm = { 0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 57 ==== */ + /* ==== WASM: 56 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12838,7 +12657,7 @@ std::map> wasm = { 0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 58 ==== */ + /* ==== WASM: 57 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13134,7 +12953,7 @@ std::map> wasm = { 0x2CU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 59 ==== */ + /* ==== WASM: 58 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13338,7 +13157,7 @@ std::map> wasm = { 0x6EU, 0x74U, 0x32U, 0x22U, 0x20U, 0x2BU, 0x20U, 0x69U, 0x29U, 0x00U, }}, - /* ==== WASM: 60 ==== */ + /* ==== WASM: 59 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13455,7 +13274,7 @@ std::map> wasm = { 0x69U, 0x29U, 0x00U, }}, - /* ==== WASM: 61 ==== */ + /* ==== WASM: 60 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13564,7 +13383,7 @@ std::map> wasm = { 0x6EU, 0x74U, 0x65U, 0x6EU, 0x74U, 0x32U, 0x22U, 0x29U, 0x00U, }}, - /* ==== WASM: 62 ==== */ + /* ==== WASM: 61 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13837,7 +13656,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 63 ==== */ + /* ==== WASM: 62 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -14056,7 +13875,7 @@ std::map> wasm = { 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 64 ==== */ + /* ==== WASM: 63 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14168,7 +13987,7 @@ std::map> wasm = { 0x58U, 0x49U, 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 65 ==== */ + /* ==== WASM: 64 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -14304,7 +14123,7 @@ std::map> wasm = { 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 66 ==== */ + /* ==== WASM: 65 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14440,7 +14259,7 @@ std::map> wasm = { 0x49U, 0x47U, 0x00U, }}, - /* ==== WASM: 67 ==== */ + /* ==== WASM: 66 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14579,7 +14398,7 @@ std::map> wasm = { 0x66U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, 0x00U, }}, - /* ==== WASM: 68 ==== */ + /* ==== WASM: 67 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14691,7 +14510,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 69 ==== */ + /* ==== WASM: 68 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14785,7 +14604,7 @@ std::map> wasm = { 0x61U, 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 70 ==== */ + /* ==== WASM: 69 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14918,7 +14737,7 @@ std::map> wasm = { 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 71 ==== */ + /* ==== WASM: 70 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15006,7 +14825,7 @@ std::map> wasm = { 0x61U, 0x74U, 0x61U, 0x29U, 0x00U, }}, - /* ==== WASM: 72 ==== */ + /* ==== WASM: 71 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -15117,326 +14936,7 @@ std::map> wasm = { 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 73 ==== */ - {R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t - read_len, int64_t error_code); extern int64_t rollback - (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set (uint32_t read_ptr, uint32_t - read_len, uint32_t kread_ptr, uint32_t kread_len); - - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - extern int64_t slot_set(uint32_t, uint32_t, uint32_t); - extern int64_t slot_subfield(uint32_t, uint32_t, uint32_t); - extern int64_t slot(uint32_t, uint32_t, uint32_t); - extern int64_t hook_account(uint32_t, uint32_t); - extern int64_t util_keylet(uint32_t, uint32_t, uint32_t, - uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); - - #define SBUF(x) x, sizeof(x) - #define TOO_BIG -3 - #define DOESNT_EXIST -5 - #define KEYLET_ACCOUNT 3 - - #define sfHookStateScale ((1U << 16U) + 21U) - - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x,sizeof(#x),__LINE__) - int64_t hook(uint32_t reserved ) - { - _g(1,1); - - uint8_t hook_acc[20]; - ASSERT(hook_account(hook_acc, 20) == 20); - uint8_t account_keylet[34]; - ASSERT(util_keylet(account_keylet, 34, KEYLET_ACCOUNT, - hook_acc, 20, 0,0,0,0) == 34); - - ASSERT(slot_set(account_keylet, 34, 1) == 1); - slot_subfield(1, sfHookStateScale, 2); - int64_t scale = slot(0,0,2); - - if (scale == DOESNT_EXIST) { - ASSERT(state_set(0, 256, SBUF("test0")) == 256); - ASSERT(state_set(0, 257, SBUF("test")) == TOO_BIG); - accept(0,0,scale); - } - if (scale == 2) { - ASSERT(state_set(0, 256, SBUF("test1")) == 256); - ASSERT(state_set(0, 256*2, SBUF("test2")) == 256*2); - ASSERT(state_set(0, 256*2+1, SBUF("test")) == - TOO_BIG); accept(0,0,scale); - } - if (scale == 5) { - ASSERT(state_set(0, 256, SBUF("test3")) == 256); - ASSERT(state_set(0, 256*5, SBUF("test4")) == 256*5); - ASSERT(state_set(0, 256*5+1, SBUF("test")) == - TOO_BIG); accept(0,0,scale); - } - rollback(0,0,scale); - } - )[test.hook]", - { - 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x35U, - 0x07U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU, - 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, - 0x60U, 0x09U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, - 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, - 0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x01U, - 0x7FU, 0x01U, 0x7EU, 0x02U, 0x89U, 0x01U, 0x09U, 0x03U, 0x65U, 0x6EU, - 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, - 0x0CU, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x61U, 0x63U, 0x63U, 0x6FU, - 0x75U, 0x6EU, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, - 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, - 0x03U, 0x65U, 0x6EU, 0x76U, 0x0BU, 0x75U, 0x74U, 0x69U, 0x6CU, 0x5FU, - 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x00U, 0x03U, 0x03U, 0x65U, - 0x6EU, 0x76U, 0x08U, 0x73U, 0x6CU, 0x6FU, 0x74U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0DU, 0x73U, 0x6CU, - 0x6FU, 0x74U, 0x5FU, 0x73U, 0x75U, 0x62U, 0x66U, 0x69U, 0x65U, 0x6CU, - 0x64U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x04U, 0x73U, 0x6CU, - 0x6FU, 0x74U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x09U, 0x73U, - 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x00U, 0x05U, - 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, - 0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x06U, 0x05U, 0x03U, 0x01U, - 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0x90U, 0x8CU, - 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x8FU, 0x0CU, 0x0BU, 0x7FU, 0x00U, - 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x90U, 0x8CU, 0x04U, - 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, - 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x09U, 0x0AU, 0x82U, 0x85U, - 0x00U, 0x01U, 0xFEU, 0x84U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x02U, 0x7EU, - 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0xD0U, 0x00U, 0x6BU, - 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, - 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, - 0x40U, 0x20U, 0x01U, 0x41U, 0x30U, 0x6AU, 0x41U, 0x14U, 0x10U, 0x81U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x14U, 0x51U, 0x0DU, 0x00U, 0x41U, - 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x21U, 0x42U, 0x22U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, - 0x01U, 0x41U, 0x22U, 0x41U, 0x03U, 0x20U, 0x01U, 0x41U, 0x30U, 0x6AU, - 0x41U, 0x14U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, - 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x22U, 0x51U, 0x0DU, - 0x00U, 0x41U, 0xA1U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0xCDU, 0x00U, - 0x42U, 0x25U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, - 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x22U, 0x41U, 0x01U, 0x10U, 0x84U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x01U, 0x51U, 0x0DU, 0x00U, 0x41U, - 0xEEU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x25U, 0x42U, 0x27U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x41U, - 0x95U, 0x80U, 0x04U, 0x41U, 0x02U, 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x02U, - 0x10U, 0x86U, 0x80U, 0x80U, 0x80U, 0x00U, 0x22U, 0x02U, 0x42U, 0x05U, - 0x7CU, 0x22U, 0x03U, 0x42U, 0x0AU, 0x56U, 0x0DU, 0x00U, 0x02U, 0x40U, - 0x02U, 0x40U, 0x02U, 0x40U, 0x02U, 0x40U, 0x20U, 0x03U, 0xA7U, 0x0EU, - 0x0BU, 0x00U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x01U, 0x04U, - 0x04U, 0x02U, 0x00U, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, - 0x02U, 0x41U, 0x93U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, - 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x02U, 0x51U, 0x0DU, - 0x00U, 0x41U, 0x99U, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x28U, 0x42U, - 0x2CU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x42U, - 0x7BU, 0x21U, 0x03U, 0x41U, 0x00U, 0x41U, 0x81U, 0x02U, 0x41U, 0xC1U, - 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x05U, 0x10U, 0x87U, 0x80U, 0x80U, - 0x80U, 0x00U, 0x42U, 0x7DU, 0x51U, 0x0DU, 0x02U, 0x41U, 0xC6U, 0x89U, - 0x80U, 0x80U, 0x00U, 0x41U, 0x2BU, 0x42U, 0x2DU, 0x10U, 0x82U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x0CU, 0x02U, 0x0BU, 0x02U, 0x40U, 0x41U, - 0x00U, 0x41U, 0x80U, 0x02U, 0x41U, 0xF1U, 0x89U, 0x80U, 0x80U, 0x00U, - 0x41U, 0x06U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, - 0x02U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xF7U, 0x89U, 0x80U, 0x80U, 0x00U, - 0x41U, 0x28U, 0x42U, 0x31U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, 0x04U, 0x41U, - 0x9FU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x04U, 0x51U, 0x0DU, 0x00U, 0x41U, - 0xA5U, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x32U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x42U, 0x02U, 0x21U, - 0x03U, 0x41U, 0x00U, 0x41U, 0x81U, 0x04U, 0x41U, 0xC1U, 0x89U, 0x80U, - 0x80U, 0x00U, 0x41U, 0x05U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x42U, 0x7DU, 0x51U, 0x0DU, 0x01U, 0x41U, 0xD1U, 0x8AU, 0x80U, 0x80U, - 0x00U, 0x41U, 0x2FU, 0x42U, 0x34U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x0CU, 0x01U, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, - 0x80U, 0x02U, 0x41U, 0x80U, 0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, - 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x80U, 0x02U, 0x51U, - 0x0DU, 0x00U, 0x41U, 0x86U, 0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x28U, - 0x42U, 0x37U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, - 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x80U, 0x0AU, 0x41U, 0xAEU, 0x8BU, - 0x80U, 0x80U, 0x00U, 0x41U, 0x06U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x42U, 0x80U, 0x0AU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xB4U, 0x8BU, - 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x38U, 0x10U, 0x82U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x42U, 0x05U, 0x21U, 0x03U, 0x41U, - 0x00U, 0x41U, 0x81U, 0x0AU, 0x41U, 0xC1U, 0x89U, 0x80U, 0x80U, 0x00U, - 0x41U, 0x05U, 0x10U, 0x87U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7DU, - 0x51U, 0x0DU, 0x00U, 0x41U, 0xE0U, 0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, - 0x2FU, 0x42U, 0x3AU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, - 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x20U, 0x03U, 0x10U, 0x88U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x20U, - 0x02U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, - 0x41U, 0xD0U, 0x00U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x20U, 0x02U, 0x0BU, 0x0BU, 0x97U, 0x04U, 0x01U, 0x00U, 0x41U, 0x80U, - 0x08U, 0x0BU, 0x8FU, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x61U, - 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, 0x74U, 0x28U, 0x68U, 0x6FU, 0x6FU, - 0x6BU, 0x5FU, 0x61U, 0x63U, 0x63U, 0x2CU, 0x20U, 0x32U, 0x30U, 0x29U, - 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x30U, 0x00U, 0x75U, 0x74U, 0x69U, - 0x6CU, 0x5FU, 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x28U, 0x61U, - 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, 0x74U, 0x5FU, 0x6BU, 0x65U, 0x79U, - 0x6CU, 0x65U, 0x74U, 0x2CU, 0x20U, 0x33U, 0x34U, 0x2CU, 0x20U, 0x4BU, - 0x45U, 0x59U, 0x4CU, 0x45U, 0x54U, 0x5FU, 0x41U, 0x43U, 0x43U, 0x4FU, - 0x55U, 0x4EU, 0x54U, 0x2CU, 0x20U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, - 0x61U, 0x63U, 0x63U, 0x2CU, 0x20U, 0x32U, 0x30U, 0x2CU, 0x20U, 0x30U, - 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, - 0x20U, 0x33U, 0x34U, 0x00U, 0x73U, 0x6CU, 0x6FU, 0x74U, 0x5FU, 0x73U, - 0x65U, 0x74U, 0x28U, 0x61U, 0x63U, 0x63U, 0x6FU, 0x75U, 0x6EU, 0x74U, - 0x5FU, 0x6BU, 0x65U, 0x79U, 0x6CU, 0x65U, 0x74U, 0x2CU, 0x20U, 0x33U, - 0x34U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, - 0x00U, 0x74U, 0x65U, 0x73U, 0x74U, 0x30U, 0x00U, 0x73U, 0x74U, 0x61U, - 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, - 0x32U, 0x35U, 0x36U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, - 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x30U, 0x22U, 0x29U, 0x29U, 0x20U, - 0x3DU, 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x00U, 0x74U, 0x65U, 0x73U, - 0x74U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x37U, 0x2CU, 0x20U, - 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, - 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, - 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, 0x74U, 0x65U, 0x73U, 0x74U, 0x31U, - 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, - 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2CU, 0x20U, 0x53U, - 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x31U, - 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x00U, 0x74U, 0x65U, 0x73U, 0x74U, 0x32U, 0x00U, 0x73U, 0x74U, 0x61U, - 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, - 0x32U, 0x35U, 0x36U, 0x2AU, 0x32U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, - 0x46U, 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x32U, 0x22U, 0x29U, - 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x32U, - 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, - 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x32U, 0x2BU, - 0x31U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, 0x74U, - 0x65U, 0x73U, 0x74U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, - 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x33U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, 0x74U, 0x65U, - 0x73U, 0x74U, 0x33U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, - 0x32U, 0x35U, 0x36U, 0x00U, 0x74U, 0x65U, 0x73U, 0x74U, 0x34U, 0x00U, - 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, - 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, 0x2AU, 0x35U, 0x2CU, 0x20U, - 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, - 0x34U, 0x22U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x35U, - 0x36U, 0x2AU, 0x35U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x36U, - 0x2AU, 0x35U, 0x2BU, 0x31U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, - 0x28U, 0x22U, 0x74U, 0x65U, 0x73U, 0x74U, 0x22U, 0x29U, 0x29U, 0x20U, - 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, - 0x00U, - }}, - - /* ==== WASM: 74 ==== */ - {R"[test.hook]( - #include - extern int32_t _g (uint32_t id, uint32_t maxiter); - extern int64_t accept (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - extern int64_t state_set ( - uint32_t read_ptr, - uint32_t read_len, - uint32_t kread_ptr, - uint32_t kread_len - ); - extern int64_t state_foreign_set ( - uint32_t read_ptr, - uint32_t read_len, - uint32_t kread_ptr, - uint32_t kread_len, - uint32_t nread_ptr, - uint32_t nread_len, - uint32_t aread_ptr, - uint32_t aread_len - ); - extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); - #define RESERVE_INSUFFICIENT -38 - #define ASSERT(x)\ - if (!(x))\ - rollback((uint32_t)#x, sizeof(#x), __LINE__); - #define ASSERT_EQUAL(x, y)\ - if (!(x == y))\ - rollback((uint32_t)#x, sizeof(#x), x); - int64_t hook(uint32_t reserved) - { - _g(1,1); - { - // 1. first account for StateMap - ASSERT_EQUAL(state_set(0, 1, "1", 1), RESERVE_INSUFFICIENT); - // 2. first namespace for StateMap - ASSERT_EQUAL(state_foreign_set(0, 1, "1", 1, "1", 32, 0, 0), RESERVE_INSUFFICIENT); - // 3. first statekey for StateMap - ASSERT_EQUAL(state_set(0, 1, "2", 1), RESERVE_INSUFFICIENT); - // 4. existing statedata - ASSERT_EQUAL(state_set(0, 1, "1", 1), RESERVE_INSUFFICIENT); - } - accept(0,0,0); - } - )[test.hook]", - { - 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x27U, - 0x05U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x04U, 0x7FU, - 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, - 0x01U, 0x7EU, 0x60U, 0x08U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, - 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, - 0x4EU, 0x05U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, - 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x09U, 0x73U, 0x74U, 0x61U, 0x74U, - 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, - 0x76U, 0x08U, 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, - 0x00U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x11U, 0x73U, 0x74U, 0x61U, - 0x74U, 0x65U, 0x5FU, 0x66U, 0x6FU, 0x72U, 0x65U, 0x69U, 0x67U, 0x6EU, - 0x5FU, 0x73U, 0x65U, 0x74U, 0x00U, 0x03U, 0x03U, 0x65U, 0x6EU, 0x76U, - 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, 0x03U, - 0x02U, 0x01U, 0x04U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, - 0x05U, 0x7FU, 0x01U, 0x41U, 0xF0U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, - 0x41U, 0xE3U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, - 0x7FU, 0x00U, 0x41U, 0xF0U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, - 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, - 0x6BU, 0x00U, 0x05U, 0x0AU, 0xA6U, 0x82U, 0x00U, 0x01U, 0xA2U, 0x82U, - 0x00U, 0x01U, 0x01U, 0x7EU, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, - 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x10U, - 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x5AU, 0x51U, 0x0DU, 0x00U, - 0x41U, 0x82U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x18U, 0x41U, 0x00U, - 0x41U, 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, - 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, - 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x01U, - 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U, 0x80U, - 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x20U, 0x41U, 0x00U, 0x41U, 0x00U, - 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x5AU, 0x51U, 0x0DU, - 0x00U, 0x41U, 0x9AU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2FU, 0x41U, - 0x00U, 0x41U, 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, - 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x20U, 0x41U, - 0x00U, 0x41U, 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, - 0x00U, 0x41U, 0x01U, 0x41U, 0xC9U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, - 0x01U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x5AU, 0x51U, - 0x0DU, 0x00U, 0x41U, 0xCBU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x18U, - 0x41U, 0x00U, 0x41U, 0x01U, 0x41U, 0xC9U, 0x88U, 0x80U, 0x80U, 0x00U, - 0x41U, 0x01U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, 0x82U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, - 0x41U, 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, - 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x5AU, 0x51U, 0x0DU, - 0x00U, 0x41U, 0x82U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x18U, 0x41U, - 0x00U, 0x41U, 0x01U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, - 0x01U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, 0x82U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, - 0x00U, 0x10U, 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, - 0x0BU, 0x0BU, 0x6AU, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x63U, - 0x31U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x2CU, 0x20U, 0x22U, 0x31U, - 0x22U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, - 0x65U, 0x5FU, 0x66U, 0x6FU, 0x72U, 0x65U, 0x69U, 0x67U, 0x6EU, 0x5FU, - 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x2CU, 0x20U, - 0x22U, 0x31U, 0x22U, 0x2CU, 0x20U, 0x31U, 0x2CU, 0x20U, 0x22U, 0x31U, - 0x22U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, - 0x30U, 0x29U, 0x00U, 0x32U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, - 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x2CU, - 0x20U, 0x22U, 0x32U, 0x22U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x00U, - }}, - - /* ==== WASM: 75 ==== */ + /* ==== WASM: 72 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16048,7 +15548,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 76 ==== */ + /* ==== WASM: 73 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16398,7 +15898,7 @@ std::map> wasm = { 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 77 ==== */ + /* ==== WASM: 74 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16534,7 +16034,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 78 ==== */ + /* ==== WASM: 75 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16707,7 +16207,7 @@ std::map> wasm = { 0x54U, 0x5FU, 0x45U, 0x58U, 0x49U, 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 79 ==== */ + /* ==== WASM: 76 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16855,7 +16355,7 @@ std::map> wasm = { 0x30U, 0x00U, 0x22U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 80 ==== */ + /* ==== WASM: 77 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16952,7 +16452,7 @@ std::map> wasm = { 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 81 ==== */ + /* ==== WASM: 78 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17011,7 +16511,7 @@ std::map> wasm = { 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 82 ==== */ + /* ==== WASM: 79 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17070,7 +16570,7 @@ std::map> wasm = { 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 83 ==== */ + /* ==== WASM: 80 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -18899,7 +18399,7 @@ std::map> wasm = { 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 84 ==== */ + /* ==== WASM: 81 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -20179,7 +19679,7 @@ std::map> wasm = { 0x29U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x30U, 0x20U, 0x29U, 0x29U, 0x00U, }}, - /* ==== WASM: 85 ==== */ + /* ==== WASM: 82 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -23112,7 +22612,7 @@ std::map> wasm = { 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 86 ==== */ + /* ==== WASM: 83 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -25077,7 +24577,7 @@ std::map> wasm = { 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 87 ==== */ + /* ==== WASM: 84 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -25362,7 +24862,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 88 ==== */ + /* ==== WASM: 85 ==== */ {R"[test.hook]( #include extern int32_t _g(uint32_t, uint32_t); @@ -25949,7 +25449,7 @@ std::map> wasm = { 0x4EU, 0x5FU, 0x46U, 0x41U, 0x49U, 0x4CU, 0x55U, 0x52U, 0x45U, 0x00U, }}, - /* ==== WASM: 89 ==== */ + /* ==== WASM: 86 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26050,7 +25550,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 90 ==== */ + /* ==== WASM: 87 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26201,7 +25701,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 91 ==== */ + /* ==== WASM: 88 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26281,7 +25781,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 92 ==== */ + /* ==== WASM: 89 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26422,7 +25922,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 93 ==== */ + /* ==== WASM: 90 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26603,7 +26103,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 94 ==== */ + /* ==== WASM: 91 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -27084,7 +26584,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 95 ==== */ + /* ==== WASM: 92 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -27353,7 +26853,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 96 ==== */ + /* ==== WASM: 93 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -27432,7 +26932,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 97 ==== */ + /* ==== WASM: 94 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -27496,7 +26996,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 98 ==== */ + /* ==== WASM: 95 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -27892,7 +27392,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 99 ==== */ + /* ==== WASM: 96 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -28223,7 +27723,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 100 ==== */ + /* ==== WASM: 97 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -28341,7 +27841,7 @@ std::map> wasm = { 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 101 ==== */ + /* ==== WASM: 98 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -28370,7 +27870,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 102 ==== */ + /* ==== WASM: 99 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -28402,7 +27902,7 @@ std::map> wasm = { 0x20U, 0x52U, 0x65U, 0x6AU, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x00U, }}, - /* ==== WASM: 103 ==== */ + /* ==== WASM: 100 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32 i64) (result i64))) @@ -28429,7 +27929,7 @@ std::map> wasm = { 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x00U, 0x0BU, }}, - /* ==== WASM: 104 ==== */ + /* ==== WASM: 101 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32) (result i32))) @@ -28482,7 +27982,7 @@ std::map> wasm = { 0x00U, 0x1AU, 0x0BU, }}, - /* ==== WASM: 105 ==== */ + /* ==== WASM: 102 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -35125,7 +34625,7 @@ std::map> wasm = { 0x39U, 0x30U, 0x31U, 0x32U, 0x33U, 0x00U, }}, - /* ==== WASM: 106 ==== */ + /* ==== WASM: 103 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -35171,7 +34671,7 @@ std::map> wasm = { 0x0BU, 0x06U, 0x76U, 0x61U, 0x6CU, 0x75U, 0x65U, 0x00U, }}, - /* ==== WASM: 107 ==== */ + /* ==== WASM: 104 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); diff --git a/src/test/app/build_test_hooks.py b/src/test/app/build_test_hooks.py index 2610754d7..343600cc8 100644 --- a/src/test/app/build_test_hooks.py +++ b/src/test/app/build_test_hooks.py @@ -15,6 +15,7 @@ import os import re import subprocess import sys +import tempfile from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from typing import Dict, List, Optional, Tuple @@ -329,36 +330,68 @@ std::map> wasm = { #endif """ - def __init__(self, logger: logging.Logger, output_file: Path): + def __init__(self, logger: logging.Logger, output_file: Path, cache_dir: Path): self.logger = logger self.output_file = output_file + self.cache_dir = cache_dir - def write_block(self, out, counter: int, source: str, bytecode: bytes) -> None: - """Write a single compiled block.""" - out.write(f'/* ==== WASM: {counter} ==== */\n') - out.write('{ R"[test.hook](') - out.write(source) - out.write(')[test.hook]",\n{\n') - out.write(OutputFormatter.bytes_to_cpp_array(bytecode)) - out.write('\n}},\n\n') + def _get_clang_format_cache_file(self, content_hash: str) -> Path: + """Get cache file path for formatted output.""" + return self.cache_dir / f"formatted_{content_hash}.h" - def write(self, compiled_blocks: Dict[int, Tuple[str, bytes]]) -> None: - """Write all compiled blocks to output file.""" + def _format_content(self, unformatted_content: str) -> str: + """Format content using clang-format via temp file.""" + with tempfile.NamedTemporaryFile(mode='w', suffix='.h', delete=False) as tmp: + tmp.write(unformatted_content) + tmp_path = tmp.name + + try: + subprocess.run(['clang-format', '-i', tmp_path], check=True) + with open(tmp_path, 'r') as f: + return f.read() + finally: + os.unlink(tmp_path) + + def write(self, compiled_blocks: Dict[int, Tuple[str, bytes]], force_write: bool = False) -> None: + """Write all compiled blocks to output file, only if changed.""" + # Build unformatted content + unformatted = [] + unformatted.append(self.HEADER) + for counter in sorted(compiled_blocks.keys()): + source, bytecode = compiled_blocks[counter] + unformatted.append(f'/* ==== WASM: {counter} ==== */\n') + unformatted.append('{ R"[test.hook](') + unformatted.append(source) + unformatted.append(')[test.hook]",\n{\n') + unformatted.append(OutputFormatter.bytes_to_cpp_array(bytecode)) + unformatted.append('\n}},\n\n') + unformatted.append(self.FOOTER) + unformatted_content = ''.join(unformatted) + + # Hash the unformatted content + content_hash = hashlib.sha256(unformatted_content.encode('utf-8')).hexdigest() + cache_file = self._get_clang_format_cache_file(content_hash) + + # Get formatted content (from cache or by formatting) + if cache_file.exists(): + self.logger.info("Using cached clang-format output") + formatted_content = cache_file.read_text() + else: + self.logger.info("Formatting with clang-format") + formatted_content = self._format_content(unformatted_content) + cache_file.write_text(formatted_content) + self.logger.debug(f"Cached formatted output: {content_hash[:16]}...") + + # Check if we need to write (compare with existing file) + if not force_write and self.output_file.exists(): + existing_content = self.output_file.read_text() + if existing_content == formatted_content: + self.logger.info(f"Output unchanged, skipping write to avoid triggering rebuild") + return + + # Write the file self.logger.info(f"Writing {self.output_file}") - - with open(self.output_file, 'w') as out: - out.write(self.HEADER) - - for counter in sorted(compiled_blocks.keys()): - source, bytecode = compiled_blocks[counter] - self.write_block(out, counter, source, bytecode) - - out.write(self.FOOTER) - - def format_with_clang(self) -> None: - """Format output file with clang-format.""" - self.logger.info("Formatting with clang-format") - subprocess.run(['clang-format', '-i', str(self.output_file)], check=True) + self.output_file.write_text(formatted_content) class TestHookBuilder: @@ -376,7 +409,7 @@ class TestHookBuilder: self.cache = CompilationCache(self.logger) self.compiler = WasmCompiler(self.logger, self.wasm_dir, self.cache) self.extractor = SourceExtractor(self.logger, self.input_file) - self.writer = OutputWriter(self.logger, self.output_file) + self.writer = OutputWriter(self.logger, self.output_file, self.cache.cache_dir) def _setup_logging(self) -> logging.Logger: """Setup logging with specified level.""" @@ -463,6 +496,7 @@ class TestHookBuilder: self.logger.info("Configuration:") self.logger.info(f" Workers: {workers} (CPU count: {os.cpu_count()})") self.logger.info(f" Log level: {self.args.log_level.upper()}") + self.logger.info(f" Force write: {self.args.force_write}") self.logger.info(f" Input: {self.input_file}") self.logger.info(f" Output: {self.output_file}") self.logger.info(f" Cache: {self.cache.cache_dir}") @@ -477,8 +511,7 @@ class TestHookBuilder: blocks = self.extractor.extract() compiled = self.compile_all_blocks(blocks) - self.writer.write(compiled) - self.writer.format_with_clang() + self.writer.write(compiled, force_write=self.args.force_write) self.logger.info(f"Successfully generated {self.output_file}") @@ -494,6 +527,7 @@ Examples: %(prog)s --log-level=debug # Build with DEBUG logging %(prog)s -j 4 # Build with 4 workers %(prog)s -j 1 # Build sequentially + %(prog)s --force-write # Always write output (trigger rebuild) """ ) @@ -512,6 +546,12 @@ Examples: help='Parallel workers (default: CPU count)' ) + parser.add_argument( + '--force-write', + action='store_true', + help='Always write output file even if unchanged (triggers rebuild)' + ) + return parser