Skip to content
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

Webhook triggered even if conditions evaluation is False #2881

Closed
Moustikitos opened this issue Aug 18, 2019 · 7 comments
Closed

Webhook triggered even if conditions evaluation is False #2881

Moustikitos opened this issue Aug 18, 2019 · 7 comments

Comments

@Moustikitos
Copy link

I deployed a listener using ark-core webhook :

{
    "target": "http://144.202.75.170:5001/forger/logSomething", 
    "enabled": true, 
    "event": "transaction.applied", 
    "token": "9a83155f9ea8998f1ab0d0a952f7c213xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
    "conditions": [
        {
            "key": "amount", 
            "condition": "gte", 
            "value": "2500000000"
        }, 
        {
            "key": "vendorField", 
            "condition": "regexp", 
            "value": "^arky.*$"
        }
    ], 
    "id": "143e37f6-6eca-46ec-8099-ace9b09e7413"
}

The transactions bellow triggerred this webhook (I provide the log from my app to see token authorization match) :
https://explorer.ark.io:8443/api/transactions/f1aa4f28eeed5565a450ba83fd511fc0e506472c12f9fa98da9e6209ec165e70

>>> data autorized - 9a83155f9ea8998f1ab0d0a952f7c213
2019-08-18 19:12 +00:00: >>> Data received :
2019-08-18 19:12 +00:00: {
2019-08-18 19:12 +00:00:   "amount": "681877755", 
2019-08-18 19:12 +00:00:   "blockId": "b8bc0d18f2c6b5442976d1921300674bad90939bd7c786791dfd7cd081f0c63e", 
2019-08-18 19:12 +00:00:   "expiration": 0, 
2019-08-18 19:12 +00:00:   "fee": "2011076", 
2019-08-18 19:12 +00:00:   "id": "f1aa4f28eeed5565a450ba83fd511fc0e506472c12f9fa98da9e6209ec165e70", 
2019-08-18 19:12 +00:00:   "network": 23, 
2019-08-18 19:12 +00:00:   "recipientId": "AYaZAUGmfZ3hx8p9LWez5mYjLowBAyXu3x", 
2019-08-18 19:12 +00:00:   "senderPublicKey": "03d77805a7e23f8d413c3fd2202b610341d80443c047826790a4094c76749b5df4", 
2019-08-18 19:12 +00:00:   "sequence": 0, 
2019-08-18 19:12 +00:00:   "signature": "30440220661af7e736165ffc79e576c1a3fab55b05a639b0a45efa667064073b8c56bb640220726879ed59dd147b4822b7094849706a0b807611df8c747593e49126b33ea893", 
2019-08-18 19:12 +00:00:   "timestamp": 76054315, 
2019-08-18 19:12 +00:00:   "type": 0, 
2019-08-18 19:12 +00:00:   "version": 1
2019-08-18 19:12 +00:00: }
2019-08-18 19:12 +00:00: >>> logSomething response:
2019-08-18 19:12 +00:00: {"success": true}

https://explorer.ark.io:8443/api/transactions/d1da70d8d5805b952571ae0776702f39dee4771a3f5498596fd15fec2cc6a698

2019-08-18 19:30 +00:00: >>> Data received :
2019-08-18 19:30 +00:00: {
2019-08-18 19:30 +00:00:   "amount": "56695861", 
2019-08-18 19:30 +00:00:   "blockId": "2570b880127dc1c48951e7deebd9964294ac6e8ef67ad10998c2d71517c1ae8e", 
2019-08-18 19:30 +00:00:   "expiration": 0, 
2019-08-18 19:30 +00:00:   "fee": "1500000", 
2019-08-18 19:30 +00:00:   "id": "d1da70d8d5805b952571ae0776702f39dee4771a3f5498596fd15fec2cc6a698", 
2019-08-18 19:30 +00:00:   "network": 23, 
2019-08-18 19:30 +00:00:   "recipientId": "AQ9K7USynPxYezhHJmgtHLQeao7Vg3rxL8", 
2019-08-18 19:30 +00:00:   "secondSignature": "304402207430d77c5988f8322fd0b36d3bf78eb874016af771bd02da412597913bef859f0220665e2ec133f1f1e0543ffdef6496507926273ed21301b77ec228230df6a7adbd", 
2019-08-18 19:30 +00:00:   "senderPublicKey": "0371e0dabfd774b4f53fb9c5386a31ee4b3cb951529f18fdb5b8b7e21dbfb4b885", 
2019-08-18 19:30 +00:00:   "sequence": 32, 
2019-08-18 19:30 +00:00:   "signature": "3045022100c8991fd00fc708145734e4236458e05b14ad98856ba49ef1065adf436f900afe02204987ef913aec2aae23b1206c76b960f8cb6c09537c83b9983d055f887a5f9152", 
2019-08-18 19:30 +00:00:   "timestamp": 76054929, 
2019-08-18 19:30 +00:00:   "type": 0, 
2019-08-18 19:30 +00:00:   "vendorField": "arkship - Profit sharing, thank you!\"", 
2019-08-18 19:30 +00:00:   "vendorFieldHex": "61726b73686970202d2050726f6669742073686172696e672c207468616e6b20796f752122", 
2019-08-18 19:30 +00:00:   "version": 1
2019-08-18 19:30 +00:00: }
2019-08-18 19:30 +00:00: >>> logSomething response:
2019-08-18 19:30 +00:00: {"success": true}

Expected Behavior

In thoses transactions, amount <= "2500000000" and their vendorFields do not match the re ^arky.*$ so they should never have triggered the webhook POST.

Context

Testing my ark-listener project :
https://github.com/Moustikitos/ark-listener

Ideas

The reasons I see is that the amount comparison is done using string (see python example). I got no idea about why the regexp did not work well.

>>> # example of string amount comparison in python
>>> "2500000000" > "681877755"
False
>>> "2500000000" < "681877755"
True
@ghost
Copy link

ghost commented Aug 18, 2019

Thanks for opening this issue! A maintainer will review this in the next few days and explicitly select labels so you know what's going on.

If no reviewer appears after a week, a reminder will be sent out.

@Moustikitos
Copy link
Author

If multiple conditions are linked each-other with a boolean or operator then the only issue is with the amount comparison...

@Moustikitos
Copy link
Author

Moustikitos commented Aug 19, 2019

I also found other tricky behaviour :

  • {"amount", "eq", "0"} does not trigger even if a vote transaction is applied
    I have no explanation

  • {"type", "eq", "3"} does not trigger even if a vote transaction is applied
    Webhook stores values as string and type is an int in provided data.

Webhook stored on relay node : value = "3" (string)

      "conditions": [
        {
          "value": "3",
          "condition": "eq",
          "key": "type"
        }
      ],
      "target": "http://144.202.75.170:5001/ark_delegate/voteRefund",
      "event": "transaction.applied",
      "enabled": true,
      "token": "...",
      "id": "1ef0ba25-dbaf-4d44-b7a3-5a1abbf02201"

payload received : type = 0 (int)

2019-08-19 00:01 +00:00: >>> Data received :
2019-08-19 00:01 +00:00: {
2019-08-19 00:01 +00:00:   "amount": "3567000", 
2019-08-19 00:01 +00:00:   "blockId": "769d0ad7a516061985e2f4bd69488db1998e0177d69b57fae70a820b67e23cb3", 
2019-08-19 00:01 +00:00:   "expiration": 0, 
2019-08-19 00:01 +00:00:   "fee": "30000", 
2019-08-19 00:01 +00:00:   "id": "1591a95f45df7a1f26ff3fcf3dff64c54cbc5f07fbd8fa74e924a776381e696b", 
2019-08-19 00:01 +00:00:   "network": 23, 
2019-08-19 00:01 +00:00:   "recipientId": "AXLXwf77FHtKVaC9sPLU1A8ZHjgGgoTDy5", 
2019-08-19 00:01 +00:00:   "secondSignature": "3045022100db266274dafd24a4ca41f1f72cf4f38dac77c8acfda4f21c94d9a88413b1cf4b02200787f67456365be1360465f4fc8f8d6df0f641f4037153d0f8b5ccc41df4b05a", 
2019-08-19 00:01 +00:00:   "senderPublicKey": "0386d5a3cd292ffaa9a3b73c556453326780e092015141efaed347c4c50c7886bb", 
2019-08-19 00:01 +00:00:   "sequence": 13, 
2019-08-19 00:01 +00:00:   "signature": "3045022100b4e14136b5a6207ba73a5755fab84da6816f19dd316783b8345396df4b374b8202200b449674e117076d17a0d46f1774c70d2d0793e9ae3936f246ca43da4b05fb87", 
2019-08-19 00:01 +00:00:   "timestamp": 76070563, 
2019-08-19 00:01 +00:00:   "type": 0, 
2019-08-19 00:01 +00:00:   "vendorField": "https://ark.land/payments - Thank you for your support!", 
2019-08-19 00:01 +00:00:   "vendorFieldHex": "68747470733a2f2f61726b2e6c616e642f7061796d656e7473202d205468616e6b20796f7520666f7220796f757220737570706f727421", 
2019-08-19 00:01 +00:00:   "version": 1
2019-08-19 00:01 +00:00: }

@ghost
Copy link

ghost commented Aug 21, 2019

This issue or pull request needs further investigation. Please wait for further information, thank you.

@faustbrian
Copy link
Contributor

#2887 - Will be release on mainnet sometime next week.

@ghost
Copy link

ghost commented Aug 23, 2019

This issue has been closed. If you wish to re-open it please provide additional information.

@Moustikitos
Copy link
Author

I deployed a webhook using the condition type eq 3 and nothing is triggered.

Using an amount eq 0-based-webhook, I caught a vote transaction:

2019-10-06 04:43 +00:00: {
2019-10-06 04:43 +00:00:   "amount": "0", 
2019-10-06 04:43 +00:00:   "asset": {
2019-10-06 04:43 +00:00:     "votes": [
2019-10-06 04:43 +00:00:       "+021f277f1e7a48c88f9c02988f06ca63d6f1781471f78dba49d58bab85eb3964c6"
2019-10-06 04:43 +00:00:     ]
2019-10-06 04:43 +00:00:   }, 
2019-10-06 04:43 +00:00:   "blockId": "34b45174342f37d4c5449e0035e0bf28506af242f20c16c8642d40afefbecd45", 
2019-10-06 04:43 +00:00:   "fee": "100000000", 
2019-10-06 04:43 +00:00:   "id": "bf192ed044563f846bf3d8e0621a9da1380e3a04995e6e7bb9614d7f7875319b", 
2019-10-06 04:43 +00:00:   "network": 23, 
2019-10-06 04:43 +00:00:   "recipientId": "AeHsYn1r33b8463w5NwLmJVehm2juCQPZW", 
2019-10-06 04:43 +00:00:   "senderPublicKey": "0398675076fef0c72ecfab8baeddefa820b674b1bc861598c16d41a070c730eb1d", 
2019-10-06 04:43 +00:00:   "sequence": 0, 
2019-10-06 04:43 +00:00:   "signature": "3044022065cbe21b1dd16e8bfcd7ff7121ea5c8f646523585e1766ce095d5328d6b2853302200a7d84ddc74558f2d3cca9613ca716358430d9995340be157e87fefc0eddec98", 
2019-10-06 04:43 +00:00:   "timestamp": 80235774, 
2019-10-06 04:43 +00:00:   "type": 3, 
2019-10-06 04:43 +00:00:   "version": 1
2019-10-06 04:43 +00:00: }

In sent data, type type is an int and it is register as a str in the webhook database, could be the bug like in the amount comparison...

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

No branches or pull requests

2 participants