From 24b7a03224f1cfc9e5d9275a33167df902379684 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 17 Jul 2025 12:37:41 -0400 Subject: [PATCH] feat: add more keylet host functions (#5522) --- src/test/app/Escrow_test.cpp | 88 ++++++- src/test/app/wasm_fixtures/fixtures.cpp | 241 +++++++++++++++++ src/test/app/wasm_fixtures/fixtures.h | 2 + src/test/unit_test/SuiteJournal.h | 2 + src/xrpld/app/misc/WasmHostFunc.h | 67 +++++ src/xrpld/app/misc/WasmHostFuncImpl.cpp | 115 ++++++++ src/xrpld/app/misc/WasmHostFuncImpl.h | 40 ++- src/xrpld/app/misc/WasmHostFuncWrapper.cpp | 292 ++++++++++++++++++++- src/xrpld/app/misc/WasmHostFuncWrapper.h | 101 +++++++ src/xrpld/app/misc/WasmVM.cpp | 12 +- src/xrpld/app/tx/detail/Escrow.cpp | 2 +- 11 files changed, 945 insertions(+), 17 deletions(-) diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 1ade21eb59..b3409ed14f 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -2263,23 +2263,11 @@ struct Escrow_test : public beast::unit_test::suite // TODO: create wasm module for all host functions static auto wasmHex = allHostFunctionsHex; - // let sender = get_tx_account_id(); - // let owner = get_current_escrow_account_id(); - // let dest = get_current_escrow_destination(); - // let dest_balance = get_account_balance(dest); - // let escrow_data = get_current_escrow_data(); - // let ed_str = String::from_utf8(escrow_data).unwrap(); - // let threshold_balance = ed_str.parse::().unwrap(); - // let pl_time = host_lib::getParentLedgerTime(); - // let e_time = get_current_escrow_finish_after(); - // sender == owner && dest_balance <= threshold_balance && - // pl_time >= e_time Account const alice{"alice"}; Account const carol{"carol"}; { - // basic FinishFunction situation Env env(*this); // create escrow env.fund(XRP(5000), alice, carol); @@ -2350,6 +2338,81 @@ struct Escrow_test : public beast::unit_test::suite } } + void + testKeyletHostFunctions() + { + testcase("Test all keylet host functions"); + + using namespace jtx; + using namespace std::chrono; + + // TODO: create wasm module for all host functions + static auto wasmHex = keyletHostFunctions; + + Account const alice{"alice"}; + Account const carol{"carol"}; + + { + Env env(*this); + env.fund(XRP(5000), alice, carol); + } + + { + Env env{*this}; + env.fund(XRP(5000), alice, carol); + + BEAST_EXPECT(env.seq(alice) == 4); + BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 0); + + // base objects that need to be created first + auto const tokenId = + token::getNextID(env, alice, 0, tfTransferable); + env(token::mint(alice, 0u), txflags(tfTransferable)); + env(trust(alice, carol["USD"](1'000'000))); + env.close(); + BEAST_EXPECT(env.seq(alice) == 6); + BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 2); + + // set up a bunch of objects to check their keylets + env(check::create(alice, carol, XRP(100))); + env(credentials::create(alice, alice, "termsandconditions")); + env(delegate::set(alice, carol, {"TrustSet"})); + env(deposit::auth(alice, carol)); + env(did::set(alice), did::data("alice_did")); + env(escrow::create(alice, carol, XRP(100)), + escrow::finish_time(env.now() + 100s)); + env(token::createOffer(carol, tokenId, XRP(100)), + token::owner(alice)); + env(create(alice, carol, XRP(1000), 100s, alice.pk())); + env(signers(alice, 1, {{carol, 1}})); + env(ticket::create(alice, 1)); + env.close(); + + BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 11); + if (BEAST_EXPECTS( + env.seq(alice) == 16, std::to_string(env.seq(alice)))) + { + auto const seq = env.seq(alice); + XRPAmount txnFees = env.current()->fees().base + 1000; + env(escrow::create(alice, carol, XRP(1000)), + escrow::finish_function(wasmHex), + escrow::finish_time(env.now() + 2s), + escrow::cancel_time(env.now() + 100s), + fee(txnFees)); + env.close(); + env.close(); + env.close(); + + auto const allowance = 1'000'000; + + env(escrow::finish(carol, alice, seq), + escrow::comp_allowance(allowance), + fee(txnFees)); + env.close(); + } + } + } + void testWithFeats(FeatureBitset features) { @@ -2371,6 +2434,7 @@ struct Escrow_test : public beast::unit_test::suite // TODO: Update module with new host functions testAllHostFunctions(); + testKeyletHostFunctions(); } public: diff --git a/src/test/app/wasm_fixtures/fixtures.cpp b/src/test/app/wasm_fixtures/fixtures.cpp index 146c4338a0..c2dab9252a 100644 --- a/src/test/app/wasm_fixtures/fixtures.cpp +++ b/src/test/app/wasm_fixtures/fixtures.cpp @@ -11756,3 +11756,244 @@ extern std::string const opcCallPerfTest = "84afdf0021004494b768e11b6c9b42210141d1e3c6012102024003401000" "200041016b220041004a0d000b0b41010f0b0b01017f1001210220020f0b" "0b0e01004180080b07623a2025660a00"; + +extern std::string const keyletHostFunctions = + "0061736d01000000015b0c60057f7f7f7f7f017f60037f7f7f017f60037f7f7e017f60047f" + "7f7f7f017f60087f7f7f7f7f7f7f7f017f60067f7f7f7f7f7f017f60077f7f7f7f7f7f7f01" + "7f60057f7f7f7f7f006000017f60000060037f7f7f0060027f7f0002c6031108686f73745f" + "6c6962057472616365000008686f73745f6c69621063616368655f6c65646765725f6f626a" + "000108686f73745f6c69620974726163655f6e756d000208686f73745f6c6962146765745f" + "6c65646765725f6f626a5f6669656c64000308686f73745f6c69621c6765745f6375727265" + "6e745f6c65646765725f6f626a5f6669656c64000108686f73745f6c69620e6163636f756e" + "745f6b65796c6574000308686f73745f6c69620b6c696e655f6b65796c6574000408686f73" + "745f6c69620c636865636b5f6b65796c6574000008686f73745f6c69621163726564656e74" + "69616c5f6b65796c6574000408686f73745f6c69620f64656c65676174655f6b65796c6574" + "000508686f73745f6c6962166465706f7369745f707265617574685f6b65796c6574000508" + "686f73745f6c69620a6469645f6b65796c6574000308686f73745f6c69620d657363726f77" + "5f6b65796c6574000008686f73745f6c6962106e66745f6f666665725f6b65796c65740000" + "08686f73745f6c69620e7061796368616e5f6b65796c6574000608686f73745f6c69620e73" + "69676e6572735f6b65796c6574000308686f73745f6c69620d7469636b65745f6b65796c65" + "740000030d0c0708090a0a0a0b0b0b0a0b0b05030100110619037f01418080c0000b7f0041" + "f989c0000b7f0041808ac0000b073e05066d656d6f727902000d6f626a6563745f65786973" + "747300110666696e69736800120a5f5f646174615f656e6403010b5f5f686561705f626173" + "6503020a94270c9a0603017f037e037f23808080800041f0006b2205248080808000024002" + "40024020012d00000d00200541186a200141196a290000370300200541106a200141116a29" + "0000370300200541086a200141096a29000037030020052001290001370300200220032005" + "412041011080808080001a20054120410010818080800022014101480d0102400240024002" + "4020040d00418b80c08000410f428580141082808080001a200541d0006a41186a42003703" + "00200541d0006a41106a4200370300200541d0006a41086a42003703002005420037035020" + "0141858014200541d0006a412010838080800022014120470d01200541206a41086a200541" + "d0006a410f6a22012900002206370300200541206a41106a200541e7006a22042900002207" + "370300200541206a41186a200541ef006a22032d000022023a000020052005290057220837" + "032020052f015021092005280152210a20052d0056210b2001200637000020042007370000" + "200320023a00002005200b3a00562005200a360152200520093b015020052008370057419a" + "80c08000410c200541d0006a412041011080808080001a0c030b418b80c08000410f2004ac" + "1082808080001a200541e0006a4100360200200541d8006a42003703002005420037035020" + "012004200541d0006a411410838080800022014114460d0141a680c0800041152001417f20" + "01417f481b2201ac1082808080001a200041013a0000200020013602040c050b41a680c080" + "0041152001417f2001417f481b2201ac1082808080001a200041013a000020002001360204" + "0c040b200541226a20052d00523a0000200520052900573703402005200541d0006a410c6a" + "290000370045200541206a410c6a2005290045370000200520052f01503b01202005200528" + "005336002320052005290340370027419a80c08000410c200541206a411441011080808080" + "001a0b20004180023b01000c020b41c280c08000411620012802042201ac1082808080001a" + "200041013a0000200020013602040c010b41bb80c0800041072001ac1082808080001a2000" + "41013a0000200041783602040b200541f0006a2480808080000bd21201067f238080808000" + "4190046b220024808080800041d880c0800041234100410041001080808080001a20004180" + "046a22014100360200200041f8036a22024200370300200042003703f00302400240024002" + "4041818020200041f0036a411410848080800022034114470d00200041046a41026a20002d" + "00f2033a0000200020002900f7033703502000200041f0036a410c6a220329000037005520" + "0041046a410c6a2000290055370000200020002f01f0033b0104200020002800f303360007" + "2000200029035037000b41fb80c08000410a200041046a411441011080808080001a200141" + "0036020020024200370300200042003703f00341838020200041f0036a4114108480808000" + "22014114470d01200041186a41026a20002d00f2033a0000200020002900f7033703502000" + "2003290000370055200041186a410c6a2000290055370000200020002f01f0033b01182000" + "20002800f30336001b2000200029035037001f418581c08000410e200041186a4114410110" + "80808080001a20004188046a2202420037030020004180046a22034200370300200041f803" + "6a22044200370300200042003703f003200041046a4114200041f0036a4120108580808000" + "22014120460d02024002402001417f4a0d00200020013602300c010b2000417f3602300b41" + "0121010c030b418080c08000410b2003417f2003417f481bac1082808080001a1093808080" + "00000b418080c08000410b2001417f2001417f481bac1082808080001a109380808000000b" + "200041c5006a20022903003700002000413d6a2003290300370000200041356a2004290300" + "370000200020002903f00337002d410021010b200020013a002c200041f0036a2000412c6a" + "419381c080004107418180201091808080000240024020002d00f0030d00024020002d00f1" + "030d00419a81c0800041364100410041001080808080001a0c010b4100210141d081c08000" + "41354100410041001080808080001a200041de006a41c4003a0000200041d0006a41086a41" + "00360200200041e3006a41003a0000200041d5a6013b015c20004200370350200041003600" + "5f20004188046a2203420037030020004180046a22044200370300200041f0036a41086a22" + "054200370300200042003703f00302400240200041046a4114200041186a4114200041d000" + "6a4114200041f0036a412010868080800022024120460d00024002402002417f4a0d002000" + "20023602680c010b2000417f3602680b410121010c010b200041fd006a2003290300370000" + "200041f5006a2004290300370000200041ed006a2005290300370000200020002903f00337" + "00650b200020013a0064200041f0036a200041e4006a418582c08000410941001091808080" + "0020002d00f0030d00024020002d00f1030d00418e82c08000413a41004100410010808080" + "80001a0c010b4100210141c882c0800041394100410041001080808080001a20004188046a" + "2203420037030020004180046a22044200370300200041f8036a2205420037030020004200" + "3703f00302400240200041046a41144106200041f0036a412010878080800022024120460d" + "00024002402002417f4a0d002000200236028c010c010b2000417f36028c010b410121010c" + "010b200041a1016a200329030037000020004199016a200429030037000020004191016a20" + "05290300370000200020002903f003370089010b200020013a008801200041f0036a200041" + "88016a418183c0800041054181802010918080800020002d00f0030d00024020002d00f103" + "0d00419a81c0800041364100410041001080808080001a0c010b41d081c080004135410041" + "0041001080808080001a200041ac016a200041046a200041046a109480808000200041f003" + "6a200041ac016a419883c08000410a4198802010918080800020002d00f0030d0002402000" + "2d00f1030d0041a283c08000413b4100410041001080808080001a0c010b41dd83c0800041" + "3a4100410041001080808080001a200041d0016a200041046a200041186a10958080800020" + "0041f0036a200041d0016a419784c0800041084181802010918080800020002d00f0030d00" + "024020002d00f1030d00419f84c0800041394100410041001080808080001a0c010b41d884" + "c0800041384100410041001080808080001a200041f4016a200041046a200041186a109680" + "808000200041f0036a200041f4016a419784c0800041084181802010918080800020002d00" + "f0030d00024020002d00f1030d00419f84c0800041394100410041001080808080001a0c01" + "0b41d884c0800041384100410041001080808080001a20004198026a200041046a10978080" + "8000200041f0036a20004198026a419381c0800041074181802010918080800020002d00f0" + "030d00024020002d00f1030d00419a81c0800041364100410041001080808080001a0c010b" + "41d081c0800041354100410041001080808080001a200041bc026a200041046a1098808080" + "00200041f0036a200041bc026a419085c0800041064181802010918080800020002d00f003" + "0d00024020002d00f1030d00419685c0800041374100410041001080808080001a0c010b41" + "cd85c0800041364100410041001080808080001a200041e0026a200041186a109980808000" + "200041f0036a200041e0026a418386c08000410c4182802010918080800020002d00f0030d" + "00024020002d00f1030d00418f86c08000413d4100410041001080808080001a0c010b41cc" + "86c08000413c4100410041001080808080001a20004184036a200041046a200041186a109a" + "80808000200041f0036a20004184036a418887c08000410a4181802010918080800020002d" + "00f0030d00024020002d00f1030d00419287c08000413b4100410041001080808080001a0c" + "010b41cd87c08000413a4100410041001080808080001a200041a8036a200041046a109b80" + "808000200041f0036a200041a8036a418788c08000410a410010918080800020002d00f003" + "0d00024020002d00f1030d00419188c08000413b4100410041001080808080001a0c010b41" + "cc88c08000413a4100410041001080808080001a200041cc036a200041046a109c80808000" + "200041f0036a200041cc036a418689c0800041064181802010918080800020002d00f0030d" + "00024020002d00f1030d00418c89c0800041374100410041001080808080001a0c010b41c3" + "89c0800041364100410041001080808080001a410121010c010b410021010b20004190046a" + "24808080800020010b0300000bd10101047f23808080800041206b22032480808080002003" + "41186a22044200370300200341106a22054200370300200341086a22064200370300200342" + "00370300024002402001411420024114418683c08000411220034120108880808000220241" + "20460d00024002402002417f4a0d00200020023602040c010b2000417f3602040b41012102" + "0c010b20002003290300370001200041196a2004290300370000200041116a200529030037" + "0000200041096a2006290300370000410021020b200020023a0000200341206a2480808080" + "000bc90101047f23808080800041206b2203248080808000200341186a2204420037030020" + "0341106a22054200370300200341086a220642003703002003420037030002400240200141" + "14200241142003412010898080800022024120460d00024002402002417f4a0d0020002002" + "3602040c010b2000417f3602040b410121020c010b20002003290300370001200041196a20" + "04290300370000200041116a2005290300370000200041096a200629030037000041002102" + "0b200020023a0000200341206a2480808080000bc90101047f23808080800041206b220324" + "8080808000200341186a22044200370300200341106a22054200370300200341086a220642" + "003703002003420037030002400240200141142002411420034120108a8080800022024120" + "460d00024002402002417f4a0d00200020023602040c010b2000417f3602040b410121020c" + "010b20002003290300370001200041196a2004290300370000200041116a20052903003700" + "00200041096a2006290300370000410021020b200020023a0000200341206a248080808000" + "0bc50101047f23808080800041206b2202248080808000200241186a220342003703002002" + "41106a22044200370300200241086a22054200370300200242003703000240024020014114" + "20024120108b8080800022014120460d00024002402001417f4a0d00200020013602040c01" + "0b2000417f3602040b410121010c010b20002002290300370001200041196a200329030037" + "0000200041116a2004290300370000200041096a2005290300370000410021010b20002001" + "3a0000200241206a2480808080000bc70101047f23808080800041206b2202248080808000" + "200241186a22034200370300200241106a22044200370300200241086a2205420037030020" + "0242003703000240024020014114410b20024120108c8080800022014120460d0002400240" + "2001417f4a0d00200020013602040c010b2000417f3602040b410121010c010b2000200229" + "0300370001200041196a2003290300370000200041116a2004290300370000200041096a20" + "05290300370000410021010b200020013a0000200241206a2480808080000bc70101047f23" + "808080800041206b2202248080808000200241186a22034200370300200241106a22044200" + "370300200241086a2205420037030020024200370300024002402001411441042002412010" + "8d8080800022014120460d00024002402001417f4a0d00200020013602040c010b2000417f" + "3602040b410121010c010b20002002290300370001200041196a2003290300370000200041" + "116a2004290300370000200041096a2005290300370000410021010b200020013a00002002" + "41206a2480808080000bcb0101047f23808080800041206b2203248080808000200341186a" + "22044200370300200341106a22054200370300200341086a22064200370300200342003703" + "00024002402001411420024114410c20034120108e8080800022024120460d000240024020" + "02417f4a0d00200020023602040c010b2000417f3602040b410121020c010b200020032903" + "00370001200041196a2004290300370000200041116a2005290300370000200041096a2006" + "290300370000410021020b200020023a0000200341206a2480808080000bc50101047f2380" + "8080800041206b2202248080808000200241186a22034200370300200241106a2204420037" + "0300200241086a2205420037030020024200370300024002402001411420024120108f8080" + "800022014120460d00024002402001417f4a0d00200020013602040c010b2000417f360204" + "0b410121010c010b20002002290300370001200041196a2003290300370000200041116a20" + "04290300370000200041096a2005290300370000410021010b200020013a0000200241206a" + "2480808080000bc70101047f23808080800041206b2202248080808000200241186a220342" + "00370300200241106a22044200370300200241086a22054200370300200242003703000240" + "024020014114410f2002412010908080800022014120460d00024002402001417f4a0d0020" + "0020013602040c010b2000417f3602040b410121010c010b20002002290300370001200041" + "196a2003290300370000200041116a2004290300370000200041096a200529030037000041" + "0021010b200020013a0000200241206a2480808080000b0b830a0100418080c0000bf90965" + "72726f725f636f64653d47657474696e67206669656c643a204669656c6420646174613a20" + "4572726f722067657474696e67206669656c643a204572726f723a204572726f7220676574" + "74696e67206b65796c65743a202424242424205354415254494e47205741534d2045584543" + "5554494f4e20242424242420204163636f756e743a202044657374696e6174696f6e3a4163" + "636f756e742020436865636b206f626a65637420646f6573206e6f742065786973742c2061" + "626f7274696e6720657363726f772066696e6973682e2020436865636b206f626a65637420" + "6578697374732c2070726f63656564696e67207769746820657363726f772066696e697368" + "2e54727573746c696e65202054727573746c696e65206f626a65637420646f6573206e6f74" + "2065786973742c2061626f7274696e6720657363726f772066696e6973682e202054727573" + "746c696e65206f626a656374206578697374732c2070726f63656564696e67207769746820" + "657363726f772066696e6973682e436865636b7465726d73616e64636f6e646974696f6e73" + "43726564656e7469616c202043726564656e7469616c206f626a65637420646f6573206e6f" + "742065786973742c2061626f7274696e6720657363726f772066696e6973682e2020437265" + "64656e7469616c206f626a656374206578697374732c2070726f63656564696e6720776974" + "6820657363726f772066696e6973682e44656c6567617465202044656c6567617465206f62" + "6a65637420646f6573206e6f742065786973742c2061626f7274696e6720657363726f7720" + "66696e6973682e202044656c6567617465206f626a656374206578697374732c2070726f63" + "656564696e67207769746820657363726f772066696e6973682e457363726f772020457363" + "726f77206f626a65637420646f6573206e6f742065786973742c2061626f7274696e672065" + "7363726f772066696e6973682e2020457363726f77206f626a656374206578697374732c20" + "70726f63656564696e67207769746820657363726f772066696e6973682e4e46546f6b656e" + "4f6666657220204e46546f6b656e4f66666572206f626a65637420646f6573206e6f742065" + "786973742c2061626f7274696e6720657363726f772066696e6973682e20204e46546f6b65" + "6e4f66666572206f626a656374206578697374732c2070726f63656564696e672077697468" + "20657363726f772066696e6973682e5061794368616e6e656c20205061794368616e6e656c" + "206f626a65637420646f6573206e6f742065786973742c2061626f7274696e672065736372" + "6f772066696e6973682e20205061794368616e6e656c206f626a656374206578697374732c" + "2070726f63656564696e67207769746820657363726f772066696e6973682e5369676e6572" + "4c69737420205369676e65724c697374206f626a65637420646f6573206e6f742065786973" + "742c2061626f7274696e6720657363726f772066696e6973682e20205369676e65724c6973" + "74206f626a656374206578697374732c2070726f63656564696e6720776974682065736372" + "6f772066696e6973682e5469636b657420205469636b6574206f626a65637420646f657320" + "6e6f742065786973742c2061626f7274696e6720657363726f772066696e6973682e202054" + "69636b6574206f626a656374206578697374732c2070726f63656564696e67207769746820" + "657363726f772066696e6973682e00ad0d046e616d650014136b65796c65745f6578616d70" + "6c652e7761736d01ef0c1d002b5f5a4e387872706c5f73746434686f737435747261636531" + "3768356563663766653133666438643166354501375f5a4e387872706c5f73746434686f73" + "74313663616368655f6c65646765725f6f626a313768373838623636346237363634616165" + "3145022f5f5a4e387872706c5f73746434686f73743974726163655f6e756d313768653639" + "3463616436386330376633386345033b5f5a4e387872706c5f73746434686f737432306765" + "745f6c65646765725f6f626a5f6669656c6431376838373939646530383866396236356339" + "4504435f5a4e387872706c5f73746434686f737432386765745f63757272656e745f6c6564" + "6765725f6f626a5f6669656c64313768346239313763353864363137613961394505355f5a" + "4e387872706c5f73746434686f737431346163636f756e745f6b65796c6574313768616233" + "363663616435383039376261304506325f5a4e387872706c5f73746434686f737431316c69" + "6e655f6b65796c6574313768653466386161383862646663633464664507335f5a4e387872" + "706c5f73746434686f73743132636865636b5f6b65796c6574313768333165356538343139" + "326131633631654508385f5a4e387872706c5f73746434686f7374313763726564656e7469" + "616c5f6b65796c6574313768643731653739346561383463373839644509365f5a4e387872" + "706c5f73746434686f7374313564656c65676174655f6b65796c6574313768323639663430" + "63643739663834373237450a3d5f5a4e387872706c5f73746434686f737432326465706f73" + "69745f707265617574685f6b65796c65743137686161306631646338616233346634623745" + "0b315f5a4e387872706c5f73746434686f737431306469645f6b65796c6574313768313866" + "61393935616436326331313139450c345f5a4e387872706c5f73746434686f737431336573" + "63726f775f6b65796c657431376838373464316235373266376333326437450d375f5a4e38" + "7872706c5f73746434686f737431366e66745f6f666665725f6b65796c6574313768663931" + "35393838643961386466633863450e355f5a4e387872706c5f73746434686f737431347061" + "796368616e5f6b65796c657431376862373435373234653534336539333565450f355f5a4e" + "387872706c5f73746434686f737431347369676e6572735f6b65796c657431376866646335" + "3536343961633961626465304510345f5a4e387872706c5f73746434686f73743133746963" + "6b65745f6b65796c65743137683164393432633034663234386362666545110d6f626a6563" + "745f657869737473120666696e69736813305f5a4e34636f72653970616e69636b696e6739" + "70616e69635f666d74313768623931626164616365366565383238374514465f5a4e387872" + "706c5f73746434636f7265357479706573376b65796c657473313763726564656e7469616c" + "5f6b65796c6574313768353839343033303564323939613236354515445f5a4e387872706c" + "5f73746434636f7265357479706573376b65796c657473313564656c65676174655f6b6579" + "6c65743137686665363134666163326238656437626445164b5f5a4e387872706c5f737464" + "34636f7265357479706573376b65796c65747332326465706f7369745f707265617574685f" + "6b65796c65743137683634303539316533346337323839363645173f5f5a4e387872706c5f" + "73746434636f7265357479706573376b65796c65747331306469645f6b65796c6574313768" + "326538323337313938626638373463634518425f5a4e387872706c5f73746434636f726535" + "7479706573376b65796c6574733133657363726f775f6b65796c6574313768363462336265" + "663061333138383233634519455f5a4e387872706c5f73746434636f726535747970657337" + "6b65796c65747331366e66745f6f666665725f6b65796c6574313768633833353933386361" + "63306465646263451a435f5a4e387872706c5f73746434636f7265357479706573376b6579" + "6c65747331347061796368616e5f6b65796c65743137683332396231633338396165343162" + "3638451b435f5a4e387872706c5f73746434636f7265357479706573376b65796c65747331" + "347369676e6572735f6b65796c657431376839633832313566396330386134636565451c42" + "5f5a4e387872706c5f73746434636f7265357479706573376b65796c65747331337469636b" + "65745f6b65796c65743137683366303138626436663561373338326645071201000f5f5f73" + "7461636b5f706f696e746572090a0100072e726f64617461004d0970726f64756365727302" + "086c616e6775616765010452757374000c70726f6365737365642d6279010572757374631d" + "312e38352e31202834656231363132353020323032352d30332d31352900490f7461726765" + "745f6665617475726573042b0a6d756c746976616c75652b0f6d757461626c652d676c6f62" + "616c732b0f7265666572656e63652d74797065732b087369676e2d657874"; diff --git a/src/test/app/wasm_fixtures/fixtures.h b/src/test/app/wasm_fixtures/fixtures.h index d1c689a016..aa560580ff 100644 --- a/src/test/app/wasm_fixtures/fixtures.h +++ b/src/test/app/wasm_fixtures/fixtures.h @@ -60,3 +60,5 @@ extern std::string const reqNonexistentField; extern std::string const hfPerfTest; extern std::string const opcCallPerfTest; + +extern std::string const keyletHostFunctions; diff --git a/src/test/unit_test/SuiteJournal.h b/src/test/unit_test/SuiteJournal.h index b5c59f3d29..d56c297b0a 100644 --- a/src/test/unit_test/SuiteJournal.h +++ b/src/test/unit_test/SuiteJournal.h @@ -94,6 +94,8 @@ SuiteJournalSink::writeAlways( return "FTL:"; }(); + static std::mutex log_mutex; + std::lock_guard lock(log_mutex); suite_.log << s << partition_ << text << std::endl; } diff --git a/src/xrpld/app/misc/WasmHostFunc.h b/src/xrpld/app/misc/WasmHostFunc.h index b507d6fe69..00f89a4ac7 100644 --- a/src/xrpld/app/misc/WasmHostFunc.h +++ b/src/xrpld/app/misc/WasmHostFunc.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace ripple { @@ -183,6 +184,12 @@ struct HostFunctions return Unexpected(HostFunctionError::INTERNAL); } + virtual Expected + checkKeylet(AccountID const& account, std::uint32_t seq) + { + return Unexpected(HostFunctionError::INTERNAL); + } + virtual Expected credentialKeylet( AccountID const& subject, @@ -192,18 +199,78 @@ struct HostFunctions return Unexpected(HostFunctionError::INTERNAL); } + virtual Expected + didKeylet(AccountID const& account) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + delegateKeylet(AccountID const& account, AccountID const& authorize) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + depositPreauthKeylet(AccountID const& account, AccountID const& authorize) + { + return Unexpected(HostFunctionError::INTERNAL); + } + virtual Expected escrowKeylet(AccountID const& account, std::uint32_t seq) { return Unexpected(HostFunctionError::INTERNAL); } + virtual Expected + lineKeylet( + AccountID const& account1, + AccountID const& account2, + Currency const& currency) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + nftOfferKeylet(AccountID const& account, std::uint32_t seq) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + offerKeylet(AccountID const& account, std::uint32_t seq) + { + return Unexpected(HostFunctionError::INTERNAL); + } + virtual Expected oracleKeylet(AccountID const& account, std::uint32_t docId) { return Unexpected(HostFunctionError::INTERNAL); } + virtual Expected + paychanKeylet( + AccountID const& account, + AccountID const& destination, + std::uint32_t seq) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + signersKeylet(AccountID const& account) + { + return Unexpected(HostFunctionError::INTERNAL); + } + + virtual Expected + ticketKeylet(AccountID const& account, std::uint32_t seq) + { + return Unexpected(HostFunctionError::INTERNAL); + } + virtual Expected getNFT(AccountID const& account, uint256 const& nftId) { diff --git a/src/xrpld/app/misc/WasmHostFuncImpl.cpp b/src/xrpld/app/misc/WasmHostFuncImpl.cpp index 6c7ae43d91..e35af622d4 100644 --- a/src/xrpld/app/misc/WasmHostFuncImpl.cpp +++ b/src/xrpld/app/misc/WasmHostFuncImpl.cpp @@ -419,6 +419,15 @@ WasmHostFunctionsImpl::accountKeylet(AccountID const& account) return Bytes{keylet.key.begin(), keylet.key.end()}; } +Expected +WasmHostFunctionsImpl::checkKeylet(AccountID const& account, std::uint32_t seq) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::check(account, seq); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + Expected WasmHostFunctionsImpl::credentialKeylet( AccountID const& subject, @@ -437,6 +446,41 @@ WasmHostFunctionsImpl::credentialKeylet( return Bytes{keylet.key.begin(), keylet.key.end()}; } +Expected +WasmHostFunctionsImpl::didKeylet(AccountID const& account) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::did(account); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::delegateKeylet( + AccountID const& account, + AccountID const& authorize) +{ + if (!account || !authorize) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + if (account == authorize) + return Unexpected(HostFunctionError::INVALID_PARAMS); + auto const keylet = keylet::delegate(account, authorize); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::depositPreauthKeylet( + AccountID const& account, + AccountID const& authorize) +{ + if (!account || !authorize) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + if (account == authorize) + return Unexpected(HostFunctionError::INVALID_PARAMS); + auto const keylet = keylet::depositPreauth(account, authorize); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + Expected WasmHostFunctionsImpl::escrowKeylet(AccountID const& account, std::uint32_t seq) { @@ -446,6 +490,43 @@ WasmHostFunctionsImpl::escrowKeylet(AccountID const& account, std::uint32_t seq) return Bytes{keylet.key.begin(), keylet.key.end()}; } +Expected +WasmHostFunctionsImpl::lineKeylet( + AccountID const& account1, + AccountID const& account2, + Currency const& currency) +{ + if (!account1 || !account2) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + if (account1 == account2) + return Unexpected(HostFunctionError::INVALID_PARAMS); + if (currency.isZero()) + return Unexpected(HostFunctionError::INVALID_PARAMS); + + auto const keylet = keylet::line(account1, account2, currency); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::nftOfferKeylet( + AccountID const& account, + std::uint32_t seq) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::nftoffer(account, seq); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::offerKeylet(AccountID const& account, std::uint32_t seq) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::offer(account, seq); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + Expected WasmHostFunctionsImpl::oracleKeylet( AccountID const& account, @@ -457,6 +538,40 @@ WasmHostFunctionsImpl::oracleKeylet( return Bytes{keylet.key.begin(), keylet.key.end()}; } +Expected +WasmHostFunctionsImpl::paychanKeylet( + AccountID const& account, + AccountID const& destination, + std::uint32_t seq) +{ + if (!account || !destination) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + if (account == destination) + return Unexpected(HostFunctionError::INVALID_PARAMS); + if (seq == 0) + return Unexpected(HostFunctionError::INVALID_PARAMS); + auto const keylet = keylet::payChan(account, destination, seq); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::signersKeylet(AccountID const& account) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::signers(account); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + +Expected +WasmHostFunctionsImpl::ticketKeylet(AccountID const& account, std::uint32_t seq) +{ + if (!account) + return Unexpected(HostFunctionError::INVALID_ACCOUNT); + auto const keylet = keylet::ticket(account, seq); + return Bytes{keylet.key.begin(), keylet.key.end()}; +} + Expected WasmHostFunctionsImpl::getNFT(AccountID const& account, uint256 const& nftId) { diff --git a/src/xrpld/app/misc/WasmHostFuncImpl.h b/src/xrpld/app/misc/WasmHostFuncImpl.h index 58bf4c194a..a22097ed6b 100644 --- a/src/xrpld/app/misc/WasmHostFuncImpl.h +++ b/src/xrpld/app/misc/WasmHostFuncImpl.h @@ -114,17 +114,55 @@ public: Expected accountKeylet(AccountID const& account) override; + Expected + checkKeylet(AccountID const& account, std::uint32_t seq) override; + Expected credentialKeylet( AccountID const& subject, AccountID const& issuer, Slice const& credentialType) override; + Expected + didKeylet(AccountID const& account) override; + + Expected + delegateKeylet(AccountID const& account, AccountID const& authorize) + override; + + Expected + depositPreauthKeylet(AccountID const& account, AccountID const& authorize) + override; + Expected escrowKeylet(AccountID const& account, std::uint32_t seq) override; Expected - oracleKeylet(AccountID const& account, std::uint32_t documentId) override; + lineKeylet( + AccountID const& account1, + AccountID const& account2, + Currency const& currency) override; + + Expected + nftOfferKeylet(AccountID const& account, std::uint32_t seq) override; + + Expected + offerKeylet(AccountID const& account, std::uint32_t seq) override; + + Expected + oracleKeylet(AccountID const& account, std::uint32_t docId) override; + + Expected + paychanKeylet( + AccountID const& account, + AccountID const& destination, + std::uint32_t seq) override; + + Expected + signersKeylet(AccountID const& account) override; + + Expected + ticketKeylet(AccountID const& account, std::uint32_t seq) override; Expected getNFT(AccountID const& account, uint256 const& nftId) override; diff --git a/src/xrpld/app/misc/WasmHostFuncWrapper.cpp b/src/xrpld/app/misc/WasmHostFuncWrapper.cpp index f1de9b2235..c2b321e85a 100644 --- a/src/xrpld/app/misc/WasmHostFuncWrapper.cpp +++ b/src/xrpld/app/misc/WasmHostFuncWrapper.cpp @@ -146,6 +146,17 @@ getDataAccountID(IW const* rt, wasm_val_vec_t const* params, int32_t& i) return AccountID::fromVoid(r->data()); } +template +static Expected +getDataCurrency(IW const* rt, wasm_val_vec_t const* params, int32_t& i) +{ + auto const r = getDataSlice(rt, params, i); + if (!r || (r->size() != Currency::bytes)) + return Unexpected(HostFunctionError::INVALID_PARAMS); + + return Currency::fromVoid(r->data()); +} + template Expected getDataString(IW const* rt, wasm_val_vec_t const* params, int32_t& i) @@ -642,6 +653,32 @@ accountKeylet_wrap( return returnResult(rt, params, results, hf->accountKeylet(*acc), index); } +wasm_trap_t* +checkKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const seq = getDataInt32(rt, params, index); + if (!seq) + { + return hfResult(results, seq.error()); + } + + return returnResult( + rt, params, results, hf->checkKeylet(acc.value(), *seq), index); +} + wasm_trap_t* credentialKeylet_wrap( void* env, @@ -678,6 +715,82 @@ credentialKeylet_wrap( index); } +wasm_trap_t* +delegateKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const authorize = getDataAccountID(rt, params, index); + if (!authorize) + { + return hfResult(results, authorize.error()); + } + + return returnResult( + rt, + params, + results, + hf->delegateKeylet(acc.value(), authorize.value()), + index); +} + +wasm_trap_t* +depositPreauthKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const authorize = getDataAccountID(rt, params, index); + if (!authorize) + { + return hfResult(results, authorize.error()); + } + + return returnResult( + rt, + params, + results, + hf->depositPreauthKeylet(acc.value(), authorize.value()), + index); +} + +wasm_trap_t* +didKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + return returnResult(rt, params, results, hf->didKeylet(acc.value()), index); +} + wasm_trap_t* escrowKeylet_wrap( void* env, @@ -705,7 +818,43 @@ escrowKeylet_wrap( } wasm_trap_t* -oracleKeylet_wrap( +lineKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc1 = getDataAccountID(rt, params, index); + if (!acc1) + { + return hfResult(results, acc1.error()); + } + + auto const acc2 = getDataAccountID(rt, params, index); + if (!acc2) + { + return hfResult(results, acc2.error()); + } + + auto const currency = getDataCurrency(rt, params, index); + if (!currency) + { + return hfResult(results, currency.error()); + } + + return returnResult( + rt, + params, + results, + hf->lineKeylet(acc1.value(), acc2.value(), currency.value()), + index); +} + +wasm_trap_t* +nftOfferKeylet_wrap( void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) @@ -725,8 +874,147 @@ oracleKeylet_wrap( { return hfResult(results, seq.error()); } + return returnResult( - rt, params, results, hf->oracleKeylet(*acc, *seq), index); + rt, + params, + results, + hf->nftOfferKeylet(acc.value(), seq.value()), + index); +} + +wasm_trap_t* +offerKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const seq = getDataInt32(rt, params, index); + if (!seq) + { + return hfResult(results, seq.error()); + } + + return returnResult( + rt, params, results, hf->offerKeylet(acc.value(), seq.value()), index); +} + +wasm_trap_t* +oracleKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const documentId = getDataInt32(rt, params, index); + if (!documentId) + { + return hfResult(results, documentId.error()); + } + return returnResult( + rt, params, results, hf->oracleKeylet(*acc, *documentId), index); +} + +wasm_trap_t* +paychanKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const dest = getDataAccountID(rt, params, index); + if (!dest) + { + return hfResult(results, dest.error()); + } + + auto const seq = getDataInt32(rt, params, index); + if (!seq) + { + return hfResult(results, seq.error()); + } + + return returnResult( + rt, + params, + results, + hf->paychanKeylet(acc.value(), dest.value(), seq.value()), + index); +} + +wasm_trap_t* +signersKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + return returnResult( + rt, params, results, hf->signersKeylet(acc.value()), index); +} + +wasm_trap_t* +ticketKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results) +{ + auto* hf = reinterpret_cast(env); + auto const* rt = reinterpret_cast(hf->getRT()); + int index = 0; + + auto const acc = getDataAccountID(rt, params, index); + if (!acc) + { + return hfResult(results, acc.error()); + } + + auto const seq = getDataInt32(rt, params, index); + if (!seq) + { + return hfResult(results, seq.error()); + } + + return returnResult( + rt, params, results, hf->ticketKeylet(acc.value(), seq.value()), index); + ; } wasm_trap_t* diff --git a/src/xrpld/app/misc/WasmHostFuncWrapper.h b/src/xrpld/app/misc/WasmHostFuncWrapper.h index ac0cb88e49..93b681009d 100644 --- a/src/xrpld/app/misc/WasmHostFuncWrapper.h +++ b/src/xrpld/app/misc/WasmHostFuncWrapper.h @@ -169,6 +169,14 @@ accountKeylet_wrap( wasm_val_vec_t const* params, wasm_val_vec_t* results); +using checkKeylet_proto = + int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); +wasm_trap_t* +checkKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + using credentialKeylet_proto = int32_t( uint8_t const*, int32_t, @@ -184,6 +192,39 @@ credentialKeylet_wrap( wasm_val_vec_t const* params, wasm_val_vec_t* results); +using delegateKeylet_proto = int32_t( + uint8_t const*, + int32_t, + uint8_t const*, + int32_t, + uint8_t*, + int32_t); +wasm_trap_t* +delegateKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using depositPreauthKeylet_proto = int32_t( + uint8_t const*, + int32_t, + uint8_t const*, + int32_t, + uint8_t*, + int32_t); +wasm_trap_t* +depositPreauthKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using didKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); +wasm_trap_t* +didKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + using escrowKeylet_proto = int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); wasm_trap_t* @@ -192,6 +233,37 @@ escrowKeylet_wrap( wasm_val_vec_t const* params, wasm_val_vec_t* results); +using lineKeylet_proto = int32_t( + uint8_t const*, + int32_t, + uint8_t const*, + int32_t, + uint8_t const*, + int32_t, + uint8_t*, + int32_t); +wasm_trap_t* +lineKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using nftOfferKeylet_proto = + int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); +wasm_trap_t* +nftOfferKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using offerKeylet_proto = + int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); +wasm_trap_t* +offerKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + using oracleKeylet_proto = int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); wasm_trap_t* @@ -200,6 +272,35 @@ oracleKeylet_wrap( wasm_val_vec_t const* params, wasm_val_vec_t* results); +using paychanKeylet_proto = int32_t( + uint8_t const*, + int32_t, + uint8_t const*, + int32_t, + int32_t, + uint8_t*, + int32_t); +wasm_trap_t* +paychanKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using signersKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); +wasm_trap_t* +signersKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + +using ticketKeylet_proto = + int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t); +wasm_trap_t* +ticketKeylet_wrap( + void* env, + wasm_val_vec_t const* params, + wasm_val_vec_t* results); + using getNFT_proto = int32_t( uint8_t const*, int32_t, diff --git a/src/xrpld/app/misc/WasmVM.cpp b/src/xrpld/app/misc/WasmVM.cpp index 3f7d61c349..c9badfe460 100644 --- a/src/xrpld/app/misc/WasmVM.cpp +++ b/src/xrpld/app/misc/WasmVM.cpp @@ -61,10 +61,20 @@ createWasmImport(HostFunctions* hfs) WASM_IMPORT_FUNC2(i, updateData, "update_data", hfs, 1000); WASM_IMPORT_FUNC2(i, computeSha512HalfHash, "compute_sha512_half", hfs, 2000); WASM_IMPORT_FUNC2(i, accountKeylet, "account_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, checkKeylet, "check_keylet", hfs, 350); WASM_IMPORT_FUNC2(i, credentialKeylet, "credential_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, delegateKeylet, "delegate_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, depositPreauthKeylet, "deposit_preauth_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, didKeylet, "did_keylet", hfs, 350); WASM_IMPORT_FUNC2(i, escrowKeylet, "escrow_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, lineKeylet, "line_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, nftOfferKeylet, "nft_offer_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, offerKeylet, "offer_keylet", hfs, 350); WASM_IMPORT_FUNC2(i, oracleKeylet, "oracle_keylet", hfs, 350); - WASM_IMPORT_FUNC2(i, getNFT, "get_NFT", hfs, 1000); + WASM_IMPORT_FUNC2(i, paychanKeylet, "paychan_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, signersKeylet, "signers_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, ticketKeylet, "ticket_keylet", hfs, 350); + WASM_IMPORT_FUNC2(i, getNFT, "get_nft", hfs, 1000); WASM_IMPORT_FUNC (i, trace, hfs, 500); WASM_IMPORT_FUNC2(i, traceNum, "trace_num", hfs, 500); diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/xrpld/app/tx/detail/Escrow.cpp index e9a7c78c7f..a82aa39999 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/xrpld/app/tx/detail/Escrow.cpp @@ -233,7 +233,7 @@ EscrowCreate::preflight(PreflightContext const& ctx) } HostFunctions mock; - auto const re = preflightEscrowWasm(code, "finish", {}, &mock); + auto const re = preflightEscrowWasm(code, "finish", {}, &mock, ctx.j); if (!isTesSuccess(re)) { JLOG(ctx.j.debug()) << "EscrowCreate.FinishFunction bad WASM";