Discussions
Correct working wasm not being validated
Hey there, as you might have known, I'm working on <https://github.com/9oelM/hooks-rs> which is a Rust project that compiles Rust code into hook-compatible wasm. And I was working on some XFL support for one of my pull requests at <https://github.com/9oelM/hooks-rs/pull/11> with an integration test containing the problematic hook.
While testing, I came across a very strange behavior of XRPL node when it validates hooks. Basically, if I add a bit more code that is supposed to be functional and working like any other code, it will suddenly stop the node from validating the hook.
The preliminary observation (could be totally wrong) is that if I add too many block statements in the wasm file... the node will not validate my hook? The issue contains all the payloads and the details so please check it out. I've been wrestling with this for a while but couldn't really find meaningful solutions.
I know it sounds like a rough summary and it is, so please do have a thorough read of the code and the Github issue: <https://github.com/9oelM/hooks-rs/issues/12>
Posted by 9oelm 3 months ago
Hooks testnet examples, docker image rippled node initialization
Attempting to play with rippled/hooks for first time. Using direction from following repo: <https://github.com/XRPL-Labs/xrpld-hooks/tree/hooks-ssvm>
After running container, seems like rippled node is running, but network state is disconnected when queried. Attempting to run/install any of the included example hooks results in : disconnecter, code: 1000, and RippledNotInitializedError.
Any chance someone could point me in the right direction here?
Posted by Jamie Collison 4 months ago
is hook execution atomic from another?
Hi there,
I just have a question about the execution of the hook.
So the first question would be: can the same hook that belongs to the same hook account execute concurrently if it receives multiple transactions from different accounts within a short time period, or at least start at different times and end at different times, but still have an overlap of the time in which they are executed?
If the answer to the first question is no, you don't have to answer the next question because it is the premise of the next question. The next question goes like this:
Let's say you mutate a state by using `state_set` in your hook.
And you invoke the hook many times within a short period of time by sending several transactions to the hook for which it is installed to be invoked upon.
Then is the mutation of the state always atomic? For example:
```
#include "hookapi.h"
int64_t hook(uint32_t reserved) {
uint8_t key[32] = {0};
int64_t count[1];
int64_t state_read_result = state(SBUF(count), key, 32);
if (state_read_result == DOESNT_EXIST) {
count[0] = 0;
if (state_set(SBUF(count), key, 32) <= 0) {
rollback(SBUF("failed to set count"), -2);
}
} else if (state_read_result <= 0) {
rollback(SBUF("failed to read state"), -1);
} else {
count[0] += 1;
if (state_set(SBUF(count), key, 32) <= 0) {
rollback(SBUF("failed to set count"), -2);
}
}
accept(SBUF(count), 1);
_g(1,
1); // every hook needs to import guard function and use it at least once
// unreachable
return 0;
}
```
And let's say 100 different accounts invoke the hook approximately within the same second, and the hook runs for those people approximately within the same time range. I am asking if it is possible that the `count[0]` is NOT `100` after all of successful 100 executions.
I was designing some vault stuff using `state` and came to a conclusion that state mutation has to be atomic in order for all the hooks to be secure. But I couldn't find that in any of the documents, so I just wanted to confirm.
KP
Posted by KP 4 months ago
When XRPL HOOKS will be ready to use for Rust?
When XRPL HOOKS will be ready to use for Rust? If it is available where can I get the documentation to get started? Is this HOOKS can perform all smart contract functionalities on Ripple chain?
Posted by Tarun Jaiswal 4 months ago
hooks languages?
"typically hooks are written in c"
I see all the examples and docs are in c. You prefer people to write in c? How do the examples compare/port over to other languages for hooks?
Posted by Hooks Question 6 months ago
Is there a code example to how to blackist ongoing tx address ?
1. I would like to know If I can block the incomming transaction addr is a blacklisted one
2. How can I know if a particular addr already made a sucessful tx with me.
Do I need to create a list , and how do I map and filter to them.
Note : I am not from the C background, mostly javascript and java. please help
Thank you.
Posted by watchDhog69 about 1 year ago
About "inline functions"
Hi
there is a question that has been in my mind for some time.
https://github.com/XRPL-Labs/xrpld-hooks/discussions/57
I ask the question again here, because I think it is an important one.
about "C inline functions" and the compiler option to force compile "always inline".
There is a possibility to enable this functionality?
Inline functions, I know, can be an alternative to the awful macros.
recursion is not possible with inline functions
and the benefit could be a programming style very similar to javascript and solidity.
thank you
Posted by f1f47a23 about 1 year ago
EmitGeneration field value looks wrong
Hi
In 3 chained transactions test,
where the 1st ordinary payment txn triggers the 2nd emitted,
and the 2nd triggers the 3rd,
I see that the 2 emitted transactions have
the EmitGeneration field = 2(the 2nd) and 4(the 3rd)
1st txn
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/D8868FF6761DACA9A704A98D9CD3225BC82E914B507364ECA4D273F919C4712B
2nd emitted txn triggered by the 1st
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/47CDEC6EBA4AAEA9E640643C4A6ACAFF09E63DBE093138F10847EA407509ACE7
3rd emitted txn triggered by the 2nd
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/AF372886C4A3297A0137B43D6C3C823180A69779F060228D27C33F5DE015906F
But, according to the documentation, I should see values of 1 and 2
https://xrpl-hooks.readme.io/docs/emitted-transactions#emitdetails-block
fields are filled by etxn_details()
etxn_reserve always = 1
EmitBurden always = "1" seems correct
Posted by f1f47a23 about 1 year ago
trace(...) doesn't log the value string
While running blacklist.c (hooks-v2) I noticed that the trace() function
shows the message but not the value.
for example at line 43
trace(SBUF("Memo: "), memo_ptr, memo_len, 1);
it logs only "Memo :"
I tried several cases in others places but had the same result.
As a workaround, I suppose, it could work by concat message+value
Posted by f1f47a23 over 1 year ago
Improved error messaging when hooks don't conform to the engine contract?
I'm hoping to start a discussion orbiting around the error messages that the XRPL engine is returning when someone new (like me) is fumbling through all of this.
I understand that _g is required from the documentation's perspective. However the error message we get back from the engine isn't helpful for seeing this is the problem when you don't include it.
For instance if we don't include _g as an import you get a "Malformed transaction" error from the XRPL engine. Not super helpful for someone "down in the weeds" trying to learn.
Interestingly if you include _g but don't use it in your hook you get a "temBAD_SIGNATURE" error from the engine. Again, not super helpful because it leads you down the path of "debugging" how you signed the transaction. I wonder if it could be a more clear about the reason for the "Bad Signature"?
Any thoughts?
Posted by Jay Grissom about 2 years ago