0

I am creating an Node app that interacts with the Ethereum block chain via azimuth-js. There are multiple methods that must be run in sequence (creating an unsigned transaction, signing it, sending it, etc.) because making the actual blockchain transaction. I am sequencing these with an AWS Step Function with the particular steps executing code in AWS Lambdas.

The strict size limit on Lambdas requires relatively finely-grained splitting out, and I want to do so anyway for visualization purposes. Most of the Azimuth methods I'm using require the passing in the contracts object created by initContractsPartial. This is very large, and it exceeds the limit of what can directly be passed as output and input between Step Function steps. According to this Stack Overflow answer, the best solution is to store data in an S3 bucket and pull from there.

I have done so, using JSON.stringify before upload. But when I pull it out, the methods that were in the object are gone. Previously, the methods object was of the following form (with certain sensitive numbers removed):

methods: {
  escapeRequestsIndexes: [Function: bound _createTxObject],
  <SOME_NUMBERS_HERE>: [Function: bound _createTxObject],
  'escapeRequestsIndexes(uint32,uint32)': [Function: bound _createTxObject],
  votingFor: [Function: bound _createTxObject],
  <SOME_NUMBERS_HERE>: [Function: bound _createTxObject],
  'votingFor(address,uint256)': [Function: bound _createTxObject],
  ...
}

After pulling it from the S3 bucket, this has become:

methods: {}

It seems that JSON.stringify evaluates them before stringification and that makes them vanish. Specifically, the object that contains a JSON object of the methods is now an empty object. Non-function parts of the original larger object are fine.

I have tried other methods of getting it into S3-ready form, such as creating a Buffer or using fs to create a file I then upload, but the same thing always happens.

I have not been able to find a solution online. How can I achieve my goals?

223seneca
  • 1,136
  • 3
  • 19
  • 47
  • This doesn't actually have anything to do with AWS, does it? – Parsifal Jul 28 '20 at 13:23
  • It does in the sense that restrictions on Step Functions and Lambdas and S3 buckets are placing me in this situation. I'm definitely sticking with the first two, although workarounds involving an alternative to S3 buckets are welcome. But you are correct in the sense that how `JSON.stringify` works is the immediate obstacle. – 223seneca Jul 28 '20 at 13:25
  • As you've tagged this question, it will be ignored by anyone with the necessary knowledge (JavaScript/Node) to help you. And in general, you'll get better responses by writing a focused question without irrelevant detail. – Parsifal Jul 28 '20 at 13:36
  • Good point about the additional tags. Definitely an oversight on my part. As for the level of detail, I considered that closely and given the potential for taking a completely different angle to achieve my aims within AWS (for example, an alternative to using S3 like this), I determined that including this level of detail is optimal. – 223seneca Jul 28 '20 at 13:37

0 Answers0