Skip to content

[SC] Local call log serialization#662

Closed
rowandh wants to merge 6 commits intostratisproject:release/1.2.0.0from
rowandh:feature/local-call-log-serialization
Closed

[SC] Local call log serialization#662
rowandh wants to merge 6 commits intostratisproject:release/1.2.0.0from
rowandh:feature/local-call-log-serialization

Conversation

@rowandh
Copy link
Contributor

@rowandh rowandh commented Aug 12, 2021

See #661.

@rowandh rowandh requested review from YakupIpek and fassadlr August 12, 2021 05:13
@rowandh
Copy link
Contributor Author

rowandh commented Aug 12, 2021

@mrtpain would appreciate your input into whether this resolves #661!

@fassadlr
Copy link
Contributor

@rowandh it looks good. Just need @mrtpain to comment 👍

Also, I see the windows build was cancelled?

@rowandh
Copy link
Contributor Author

rowandh commented Aug 12, 2021

Strange, looks like the build died. Will kick it off again.

Copy link
Contributor

@fassadlr fassadlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge if CI passes

@mrtpain
Copy link

mrtpain commented Aug 12, 2021

Pulled down and tested locally, only remaining thing I noticed is return values. A method returning bool returns "return": "00" for false or "return": "01" for true. Didn't check other response types. cc @rowandh @fassadlr Thanks for the quick turnaround on this

@rowandh
Copy link
Contributor Author

rowandh commented Aug 13, 2021

@mrtpain the return value should be fixed now, could you please check once more and confirm?

@mrtpain
Copy link

mrtpain commented Aug 13, 2021

@rowandh 🥳 thanks all is good now 👍

@mrtpain
Copy link

mrtpain commented Aug 15, 2021

Actually, seems Address and Uint256 are returning {} from the return property. I don't have anything using UInt128 but guessing that too.

@rowandh
Copy link
Contributor Author

rowandh commented Aug 16, 2021

@mrtpain should be fixed now

@mrtpain
Copy link

mrtpain commented Aug 16, 2021

Thanks @rowandh all good now.

Somewhat related: recent versions of FN output the event in logs. This is helpful to have so clients don't need to deserialize topics, but I wonder, what would happen if I output a contract log that had an Event property already?

"log": {
    "event": "CollectMiningRewardsLog",
    "miner": "PPQdeXdjWDBzVLUjgWwi4mFP4Y1mhuNcRu",
    "amount": "2541009128850074"
}

Currently we are deserializing the first topic to get our event names. We can remove a package dependency if we can rely on the log.event property but wondering about the potential conflict outlined above.

@rowandh
Copy link
Contributor Author

rowandh commented Aug 17, 2021

Thanks @rowandh all good now.

Somewhat related: recent versions of FN output the event in logs. This is helpful to have so clients don't need to deserialize topics, but I wonder, what would happen if I output a contract log that had an Event property already?

"log": {
    "event": "CollectMiningRewardsLog",
    "miner": "PPQdeXdjWDBzVLUjgWwi4mFP4Y1mhuNcRu",
    "amount": "2541009128850074"
}

Currently we are deserializing the first topic to get our event names. We can remove a package dependency if we can rely on the log.event property but wondering about the potential conflict outlined above.

Good point, a log property named Event would replace the event name. We should be nesting the actual log data, something like this:

"log": {
    "event": "CollectMiningRewardsLog",
    "data": {
        "miner": "PPQdeXdjWDBzVLUjgWwi4mFP4Y1mhuNcRu",
        "amount": "2541009128850074"
   }
}

@mrtpain
Copy link

mrtpain commented Aug 20, 2021

On another note, @rowandh, transactions with internal CRS transfers I believe either aren't implemented fully (intentionally) or may have a bug.

We are able to successfully broadcast transactions that return errors during a local call. These contract errors are pointing to a 0 CRS amount in Message.Value.

https://github.com/Opdex/opdex-v1-core/blob/main/src/Contracts/Routers/OpdexRouter.cs#L228

That line is throwing during local calls but the same payload sent for an actual transaction is successful. (Note that is a public method but in our scenario of calling Router.AddLiquidity it is being called from within other methods).

Along with the error that we receive in the local call response, we can also see the list of internal transfers showing a 0 amount.

@drmathias
Copy link
Contributor

@rowandh We're getting a 500 response making a local call to this method, when running the full node built from this branch. The request body is below.

{
  "walletName": "{{wallet_name}}",
  "accountName": "{{wallet_account}}",
  "contractAddress": "{{market_deployer}}",
  "methodName": "CreateStandardMarket",
  "amount": "0",
  "feeAmount": ".001",
  "password": "{{wallet_password}}",
  "gasPrice": 100,
  "gasLimit": 250000,
  "sender": "{{wallet_address}}",
  "parameters": [
    "9#{{wallet_address}}", // market owner
    "5#3", // fee
    "1#True", // authPoolCreators
    "1#True", // authProviders
    "1#False", // authTraders
    "1#True" // enableMarketFee
  ]
}

Had a go at debugging locally and it seems to be failing to map the log responses.

@YakupIpek
Copy link
Contributor

@rowandh We're getting a 500 response making a local call to this method, when running the full node built from this branch. The request body is below.

{
  "walletName": "{{wallet_name}}",
  "accountName": "{{wallet_account}}",
  "contractAddress": "{{market_deployer}}",
  "methodName": "CreateStandardMarket",
  "amount": "0",
  "feeAmount": ".001",
  "password": "{{wallet_password}}",
  "gasPrice": 100,
  "gasLimit": 250000,
  "sender": "{{wallet_address}}",
  "parameters": [
    "9#{{wallet_address}}", // market owner
    "5#3", // fee
    "1#True", // authPoolCreators
    "1#True", // authProviders
    "1#False", // authTraders
    "1#True" // enableMarketFee
  ]
}

Had a go at debugging locally and it seems to be failing to map the log responses.

Is this on testnet, mainnet or in localchain(devmode) ? Can you be sure that wallet_address is belong to one of your wallet addresses ?

@mrtpain
Copy link

mrtpain commented Aug 31, 2021

@YakupIpek

@rowandh We're getting a 500 response making a local call to this method, when running the full node built from this branch. The request body is below.

{
  "walletName": "{{wallet_name}}",
  "accountName": "{{wallet_account}}",
  "contractAddress": "{{market_deployer}}",
  "methodName": "CreateStandardMarket",
  "amount": "0",
  "feeAmount": ".001",
  "password": "{{wallet_password}}",
  "gasPrice": 100,
  "gasLimit": 250000,
  "sender": "{{wallet_address}}",
  "parameters": [
    "9#{{wallet_address}}", // market owner
    "5#3", // fee
    "1#True", // authPoolCreators
    "1#True", // authProviders
    "1#False", // authTraders
    "1#True" // enableMarketFee
  ]
}

Had a go at debugging locally and it seems to be failing to map the log responses.

Is this on testnet, mainnet or in localchain(devmode) ? Can you be sure that wallet_address is belong to one of your wallet addresses ?

This is our local network (devnet) running from this branch. Our payload is all correct.

We can switch the endooint from smartcontracts/local-call to smartcontractwallet/call and it works fine. Also we can change just the parameters and method to CreateStakingMarket method with a local call and it works as expected.

So far it seems that it's a problem with something happening in this method specifically that is uncaught as the FN returns 500 error with no body, I do not think the error is getting caught but throwing all the way out.

Also local calls that involve CRS transfers and use of Message.Value in contract always have it as 0 and the local call tx returns failures due to it.

@StratisIain StratisIain changed the base branch from release/1.1.0.0 to release/1.0.9.6 September 2, 2021 07:20
@rowandh rowandh closed this Sep 4, 2021
@rowandh rowandh force-pushed the feature/local-call-log-serialization branch from 6536b6b to a7c2ccd Compare September 4, 2021 02:52
@rowandh rowandh reopened this Sep 4, 2021
@rowandh
Copy link
Contributor Author

rowandh commented Sep 4, 2021

Will merge these changes in to release/1.0.9.6 and address the new issues with separate PRs.

@rowandh rowandh changed the base branch from release/1.0.9.6 to master September 6, 2021 01:21
@rowandh rowandh changed the base branch from master to release/1.0.9.6 September 6, 2021 01:21
rowandh added a commit that referenced this pull request Oct 6, 2021
@rowandh rowandh changed the base branch from release/1.0.9.6 to release/1.1.0.0 October 21, 2021 00:36
@rowandh rowandh changed the base branch from release/1.1.0.0 to release/1.0.9.6 October 21, 2021 00:36
@rowandh rowandh force-pushed the feature/local-call-log-serialization branch from 9ccf879 to ae7099c Compare October 21, 2021 00:39
@rowandh rowandh changed the base branch from release/1.0.9.6 to release/1.1.0.0 October 21, 2021 00:39
@rowandh
Copy link
Contributor Author

rowandh commented Oct 21, 2021

f9b3e80 resolves zero amount local calls (#662 (comment))
ae7099c resolves the issue deserializing addresses (#662 (comment))
f7f278a resolves nesting event data (#662 (comment))

@rowandh rowandh changed the base branch from release/1.1.0.0 to release/1.2.0.0 October 21, 2021 19:10
@mrtpain
Copy link

mrtpain commented Oct 23, 2021

These changes worked for us and are in use in our Dev and public Testnet environments 🙌

fassadlr pushed a commit that referenced this pull request Dec 1, 2021
rowandh added a commit that referenced this pull request Dec 2, 2021
fassadlr pushed a commit to fassadlr/StratisFullNode that referenced this pull request Dec 2, 2021
rowandh added a commit that referenced this pull request Dec 2, 2021
* Fix serialization and add tests

* PR #662 Local call log serialization

* Fix zero local call message value

* Fix issue where local call contract address was unable to be found in state tree

* Nest deserialized log data

* Fix test

* Merge branch 'hotfix/param' into release/1.1.0.0-opdex

* Fix Tests

* Merge pull request #801 from rowandh/opdex

Opdex

Co-authored-by: Rowan de Haas <rowandh@users.noreply.github.com>
@fassadlr
Copy link
Contributor

@rowandh I believe this fix was merged to release/1.1.1.0... can you confirm? If so it was also then merge to 1.2 already.

@rowandh rowandh closed this Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants