-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile Against Official Repo #20
Comments
Hey @ctrlshp! Thanks for your note. Ordinarily you can reach me at [email protected] but this is a fine location for this topic, and it may benefit others in future as well. If you want to do Monero address validation in the browser, mymonero-core-js can handle that handily with decode_address. However the entire build may be a bit heavy for you since it contains other things. One open issue we have is a way to select what methods and code are needed to strip that down. But the JS to do addr validation itself is quite straightforward – you can find it in the history of mymonero-core-js. Here's a list of the changes I made to Monero official. I stripped it down considerably - and then made these modifications: https://github.com/mymonero/monero-core-custom/blob/master/changes%20when%20upgrading%20monero%20src.txt Paul |
(Of course, having these in patches would be better. The real goal is to improve Monero sourcecode so as to allow it to be embedded properly as a library but I fear that is a long ways off since the people doing the majority of development on Monero are only really interested in simplewallet and the daemon. Nevertheless, libraryfying Monero source code would greatly benefit those applications as well, not to mention the stability and clarity of the code. But that argument does not seem effective to them for some reason!) |
Hi Paul. Thanks for your reply. I browsed through the diffs that you provided. I'm not sure I understand : did you submit a PR for these and it was rejected ? Are they otherwise breaking non-emscripten monero-core use cases like the cli executables and daemons ? For sure, I agree with you that it would be much better to have them merged with the official branch. I also agree that it doesn't make sense for the monero-core code base to keep on ingesting new functionnality forever (like the new Bimessage-based MMS system, ZeroMQ, etc.) and not extract the real "core" code into a new libmonero project of some kind. I think that, in the coming days/weeks what I will do is this :
I'll be sending questions to the email you provided above, unless they are issues that warrant PRs and stuff, in which case I'll be asking them here as well. Thanks again for taking the time to answer my questions and also putting the effort in the MyMonero wallet and keeping it all open source. It's awesome ! |
P.-S. : and after those 3 steps, I'll have a clearer idea about this whole libmonero thing, and I'll most likely want to investigate this further. But for now, I'll stick to try to understand what you did and if it works for me. |
Totally agree that the core code needs to be extracted. It's not sustainable. Been saying this for a long time. This is just a fact of software entropy. My pleasure to assist. Thank you very much for your interest! |
By the way please note that the PR i made for 13 word support is a bit different than the version that I have got in monero-core-custom -- the one in core-custom is probably a bit better, and incorporates some recent changes to monero-core. |
I think I might have changed the word "coerce" as well 😅 |
Got it (I think 😎). I will fork everything to my Github account and commit there so you can see what I'm doing. |
oh hey I forgot to say happy holidays back, thanks! |
Hello. I didn't get the chance to look at this until today. I tested the address_and_keys_from_seed example from the README in a simple Node.JS index.js (attached here). Besides the
That's it for now. This is exciting. I didn't expect it to work right away ! ;-) Thanks! |
It didn't want my .js attachment. Here it is in plaintext : const mymonero = require("./MyMoneroCoreBridge")(); const nettype_utils = require("./cryptonote_utils/nettype"); mymonero.then(monero_utils => { |
Hey @ctrlshp ,
Best |
As for #3, could you make an issue on mymonero-core-cpp for whichever one of us gets around to it? |
Hi Paul ! I didn't mean to rush either of us into anything just yet, ha ! I might indeed try it (no. 3) myself after I'm done exploring your work. Only then can I maybe pretend to know what is the best course of action. What is certain now is that both of our business interests overlap quite a bit over everything JavaScript Monero. Open source collaboration of some magnitude seems to be in order here. And I feel it's only right I eventually contribute something back to the Monero software ecosystem. But I don't want it to be garbage, so I might be a little slow compared to a seasoned Monero contributor like you. Now that I have tried Node.JS, I will see if I'm having the same kind of success in the browser. That's what I'll do whenever I can in the next couple of days. Please note that I will have to include this into transpiled TypeScript code, so I don't think it's going to be as straightforward as NodeJs. We'll see. Speaking of browser and my nos. 2 and 4, since I will not want to, on top of the Monero Emscripten stuff, include cryptographic primitive javascript libraries (Keccak, elliptic curve and BigInteger arithmetics and such), I would like to expose those from monero-core. I didn't see them made available in your bridge nor in the mymonero-core-cpp C++ proxy code. Did I overlook anything ? Also, do you think I can avoid to including what I assume is redundant code like tweetnacl-js to do the kind of encryption-decryption-signing-verification that I'm sure is the behind the basic Monero operations ? Good night ! |
Hey @ctrlshp Have to say I am quite possibly far from a seasoned Monero contributor but I appreciate your kind words :) I know a little. Happy to help where I can. Most of my experience comes from software engineering, application-, and library dev itself. All in all, we can collaborate over time, so no worries about getting things exactly perfect. Re: TypeScript, that just gets compiled down to vanilla aiui so it should end up being basically the same. I know that MyCryptoHQ has done some TypeScript work based on the old pre-bulletproofs mymonero-core-js before we began to move the majority of the core-js impl into C++. So you may find some inspiration and help there. Though I hear the project was given up on for internal planning reasons and they're interested in moving to the emscripten version. So your TypeScript work may end up being quite interesting to them. There is no way to do BigInteger operations in JS-land exposed via C++ without using e.g. JSBigInt. The C++ just uses uint64s but no such thing exists in JS. As for tweetnacl I'd suggest bridging to C++ and doing it within the C++ (compiled to WASM). We do expose a variety of utility functions via the bridge code so if you find anything missing just let me know and we can figure out how to bridge it! Best regards Paul |
Hello ! Integrating this into a web TypeScript project is a very humbling process for me, right now. Lol. I got it to work, but it's a hack. I am able to load the WASM file if the Also, I didn't find anything relevant in the public MyCryptoHQ code. Good evening ! |
MyMoneroCoreCpp_WASM.js is generated by mymonero-core-js config lines such as https://github.com/mymonero/mymonero-core-js/blob/529fc93194d166a3e7d2430e3b083252aea4fde9/CMakeLists.txt#L136 and https://github.com/mymonero/mymonero-core-js/blob/529fc93194d166a3e7d2430e3b083252aea4fde9/CMakeLists.txt#L190 etc …… and this gets run via this: https://github.com/mymonero/mymonero-core-js/blob/master/bin/build-emcpp.sh (by way of archive-emcpp.sh) - instructions in readme at https://github.com/mymonero/mymonero-core-js#building-mymonerocorecpp-from-scratch hope this helps! I'd have to dig for MyCryptoHQ's fork of mymonero-core-js … I'm not sure why it's not available You should never have to include MyMoneroCoreCpp_WASM directly - it's taken care of by MyMoneroCoreBridge, fwiw. |
Thanks for your pointers. I made a gist of my last attempt so you can see what I mean. This would require to complete the I think I found the MyCryptoHQ code you were talking about. Based on what I can see, they didn't use Take care. |
Hello ! Just to let you know that I couldn't wait the end of the week to try this. So I bundled everything into a This will only work for the Web, of course, so I want to see how it translates to a TypeScript NodeJS environment (within the Serverless framework) and how to reuse the same type definitions there. Then, I might want to find a way to include |
I'm more or less ok with using npm but I'm not crazy about it as a point of failure. It's not much worse than pointing directly to the git repo of course, but then again, it's not much better, and convenience is somewhat an enemy of safety in this case (as a critical crypto repo). Open to suggestions and other points of view. I'm not very familiar with TypeScript, so I can't weigh in on the types field. If it doesn't affect anything related to the vanilla code and if it's properly implemented then yep I'll merge it. MyCryptoHQ didn't use MyMoneroCoreBridge b/c they did that work at the beginning of 2018 before we made a bunch of simplifications and refactors. |
re: npm, I'm just trying to find a convenient way to a) distribute mymonero-core-js and b) have the type definitions follow along. Another possible solution is to leave the whole mymonero-core-js project as it is and commit the type definitions alone to the DefinitelyTyped project. For now, when I'm done with the NodeJS integration and the type definitions themselves, I'll send you a PR for a |
I was just gonna say as well, how about we commit everything to the repo? Or, we could do them as releases. In any case, npm still works by pointing to the repo so, agreed, we can add things to package.json and go from there. |
Yes, that's the plan. I'll fork On top of the types, I think I need to find a way to pass a custom location for the |
Hi, First of all, congrats for your website launch, it looks goooooood. So I tested mymonero-core-js as a npm plugin package with type definitions in a Serverless AWS Lambda context. It works as-is. But my lambda went from a <1s cold-start to a >15s cold-start. The execution time per se is fine with <1s from <100ms, I can live with that. But the cold-start time makes it unusable in my current production use cases. I will stick with the current wallet+monerod RPC VPS infrastructure for the time being. I still needed a replacement for the regex that I currently use to validate the Monero refund address on the browser client side. In this scenario, refactoring mymonero-core, both C++ and JavaScript (with ES6) for modularity, would solve the two problems currently preventing me from using it for simple address validation : 1) it would make it compabible with the Rollup bundler I currently use and 2) such modules would allow targeted imports of only the required code, so if they are done correctly, I should be able to bundle only the code required for a So I haven't been able to integrate your mymonero-core code into my stuff for these two things. I still hope to be able to use it some day for 100% serverless address generation and/or payment verification via remote full node monerod RPC access to the blockchain. I have looked at Emsripten options such as However, I have more urgent things to do before I can work on this again. My time frame is end of February. But before that, planning for the long term, I will initiate a conversation with you regarding multisig, on the issue about that. |
The startup time can be significantly reduced by us implementing the system which selects only the core-cpp code which is needed by the custom core-js build. |
Excellent progress otherwise though. Glad to hear. |
Hi @ctrlshp. You might find this helpful: https://github.com/mymonero/monero/commits/core-custom-mymonero It is a branch with content identical to that in The automatic merge still leaves a bit of work to be done, however. This is still a work in progress, and any suggestions to improve this process would be most welcome. In the meantime, I am able to merge newer master commits with the following extra steps:
As scary as all that might sound, it was actually pretty easy to do such a merge, especially compared to the alternative of doing it manually. As an example, here is a merge I've made into this branch of a slightly more recent upstream On a final note, because both of these branches are based on the upstream Monero repository, cloning them will require as much space as that -- around 300MB at present. If you already have a Monero clone locally, you can check these branches out there to avoid downloading a second copy. If you don't want to mess with your existing Monero working directory, you can use the I hope this helps you at least a little bit. Please don't hesitate to let me know if you have any questions about any of it! |
Hi @ndorf sorry for the delay. Thanks for that. Will look into it very soon. |
Closing this now |
Hello, I'm interested in your work because I would like to run Monero address form validation in the browser and also a subaddress wallet in NodeJS and I would like to do that by compiling the official Monero C++ code into JavaScript with Emscripten.
I didn't know how to reach you, so I opened an issue here to ask my questions I hope you don't mind. Do not hesitate to let me know the preferred way to contact you for this, if Github doesn't suit you.
Here is my first question : could mymonero-core-cpp be compiled directly from the official Monero CPP repository ? If not what are the modification in monero-core-custom that are necessary from the official code to make it work ?
Thanks ! Merry Christmas and happy New Year.
The text was updated successfully, but these errors were encountered: