diff --git a/insomnia_workspace.json b/insomnia_workspace.json index 6ab0353c8f..5d2ffd7240 100644 --- a/insomnia_workspace.json +++ b/insomnia_workspace.json @@ -1,18 +1,23 @@ { "_type": "export", "__export_format": 4, - "__export_date": "2020-09-21T12:39:47.334Z", - "__export_source": "insomnia.desktop.app:v2020.3.3", + "__export_date": "2020-09-28T17:05:07.127Z", + "__export_source": "insomnia.desktop.app:v2020.4.1", "resources": [ { "_id": "req_cd0078ce4a034ebdbdf7dc9e20e78a29", - "authentication": {}, + "parentId": "fld_2b54cbb84e244284b3ef752c5f805376", + "modified": 1600249644998, + "created": 1600249397450, + "url": "{{ node_url }}", + "name": "qa_mineBlocks", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"qa_mineBlocks\", \n \"params\": [1, true],\n \"id\": 1\n}" }, - "created": 1600249397450, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -25,53 +30,53 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150156.9297, - "method": "POST", - "modified": 1600249644998, - "name": "qa_mineBlocks", - "parameters": [], - "parentId": "fld_2b54cbb84e244284b3ef752c5f805376", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "fld_2b54cbb84e244284b3ef752c5f805376", + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1600249374160, "created": 1600249374160, + "name": "QA", "description": "", "environment": {}, "environmentPropertyOrder": null, "metaSortKey": -1600249374160, - "modified": 1600249374160, - "name": "QA", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "_type": "request_group" }, { "_id": "wrk_097d43914a4d4aea8b6f73f647921182", - "created": 1552662762769, - "description": "", + "parentId": null, "modified": 1599825617921, + "created": 1552662762769, "name": "Mantis", - "parentId": null, + "description": "", "scope": null, "_type": "workspace" }, { "_id": "req_6197fefa1e1448a89f30712ec12295f8", - "authentication": {}, + "parentId": "fld_2b54cbb84e244284b3ef752c5f805376", + "modified": 1600249571669, + "created": 1600249491560, + "url": "{{ node_url }}", + "name": "qa_getPendingTransactions", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"qa_getPendingTransactions\", \n \"params\": [],\n \"id\": 1\n}" }, - "created": 1600249491560, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -84,31 +89,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150156.832, - "method": "POST", - "modified": 1600249571669, - "name": "qa_getPendingTransactions", - "parameters": [], - "parentId": "fld_2b54cbb84e244284b3ef752c5f805376", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_dd6e5c718f974407bb79fe3c953b7106", - "authentication": {}, + "parentId": "fld_72829b866f0441e184e0d1a2030f8220", + "modified": 1599825736386, + "created": 1599825723950, + "url": "{{ node_url }}", + "name": "personal_newAccount", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"personal_newAccount\", \n \"params\": [\"12345678\"],\n \"id\": 1\n}" }, - "created": 1599825723950, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -121,43 +126,43 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150156.7344, - "method": "POST", - "modified": 1599825736386, - "name": "personal_newAccount", - "parameters": [], - "parentId": "fld_72829b866f0441e184e0d1a2030f8220", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "fld_72829b866f0441e184e0d1a2030f8220", + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1599825702694, "created": 1599825702694, + "name": "Personal", "description": "", "environment": {}, "environmentPropertyOrder": null, "metaSortKey": -1599825702694, - "modified": 1599825702694, - "name": "Personal", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "_type": "request_group" }, { - "_id": "req_105cb28c6f774eadbf099a28617a6d1f", - "authentication": {}, + "_id": "req_b47c93b7db864ccba4ef8b9ea4f2c101", + "parentId": "fld_72829b866f0441e184e0d1a2030f8220", + "modified": 1600875893860, + "created": 1600875628490, + "url": "{{ node_url }}", + "name": "personal_sendTransaction", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"debug_listPeersInfo\", \n \"params\": [],\n \"id\": 1\n}" + "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"personal_sendTransaction\", \n \"params\": [{\n\t\t\"from\": \"$address\",\n\t\t\"data\": \"6080604052348015600f57600080fd5b50609e8061001e6000396000f3fe608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063fc0e74d1146044575b600080fd5b348015604f57600080fd5b5060566058565b005b600073ffffffffffffffffffffffffffffffffffffffff16fffea165627a7a72305820a976be5f8d63b79a56bb1244dd07b0ef1abd13c682f86e5462c71e8cbbfa79320029\",\n\t\t\"value\": \"0x0\",\n\t\t\"gasLimit\": \"0x166f5777\",\n\t\t\"gasPrice\": \"0x0\"\n\t}, \"12345678\"],\n \"id\": 1\n}" }, - "created": 1553869501399, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -170,87 +175,166 @@ "value": "no-cache" } ], + "authentication": {}, + "metaSortKey": -1552939150156.0508, "isPrivate": false, - "metaSortKey": -1552939150157.125, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_0185846496ad4bab9d52ec29b8052c5c", + "parentId": "fld_72829b866f0441e184e0d1a2030f8220", + "modified": 1600875607946, + "created": 1600875587412, + "url": "{{ node_url }}", + "name": "personal_unlockAccount", + "description": "", "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"personal_unlockAccount\", \n \"params\": [\"$address\", \"12345678\"],\n \"id\": 1\n}" + }, + "parameters": [], + "headers": [ + { + "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", + "name": "Content-Type", + "value": "application/json" + }, + { + "id": "pair_088edc31f5e04f20a16b465a673871bb", + "name": "Cache-Control", + "value": "no-cache" + } + ], + "authentication": {}, + "metaSortKey": -1552939150155.3672, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_105cb28c6f774eadbf099a28617a6d1f", + "parentId": "fld_f75b249a780c4b5e97a0a2980ad1d4b8", "modified": 1566369370577, + "created": 1553869501399, + "url": "{{ node_url }}", "name": "debug_listPeersInfo", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"debug_listPeersInfo\", \n \"params\": [],\n \"id\": 1\n}" + }, "parameters": [], - "parentId": "fld_f75b249a780c4b5e97a0a2980ad1d4b8", + "headers": [ + { + "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", + "name": "Content-Type", + "value": "application/json" + }, + { + "id": "pair_088edc31f5e04f20a16b465a673871bb", + "name": "Cache-Control", + "value": "no-cache" + } + ], + "authentication": {}, + "metaSortKey": -1552939150157.125, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "fld_f75b249a780c4b5e97a0a2980ad1d4b8", + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1580406808158, "created": 1553869483792, + "name": "Debug", "description": "", "environment": {}, "environmentPropertyOrder": null, "metaSortKey": -1553869483792, - "modified": 1580406808158, - "name": "Debug", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "_type": "request_group" }, { - "_id": "req_0ff71c4f648c4d3782612e9c53179321", - "authentication": {}, + "_id": "req_b60c1a4f9d604d868910f967c6a070d7", + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1600691932451, + "created": 1600691926224, + "url": "{{ node_url }}", + "name": "eth_chainId", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_chainId\", \n\t\"params\": [],\n \"id\": 1\n}" }, - "created": 1600691926224, - "description": "", + "parameters": [], "headers": [ { "id": "pair_c33a6ada19dd4aa8b75527639519f427", "name": "Content-Type", "value": "application/json" + }, + { + "id": "pair_088edc31f5e04f20a16b465a673871bb", + "name": "Cache-Control", + "value": "no-cache" } ], + "authentication": {}, + "metaSortKey": -1565685344804, "isPrivate": false, - "metaSortKey": -1600691926224, - "method": "POST", - "modified": 1600691932451, - "name": "eth_chainId", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{node_url}}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1599825661277, "created": 1552939140291, + "name": "Eth", "description": "", "environment": {}, "environmentPropertyOrder": null, "metaSortKey": -1552939140292, - "modified": 1599825661277, - "name": "Eth", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "_type": "request_group" }, { - "_id": "req_b60c1a4f9d604d868910f967c6a070d7", - "authentication": {}, + "_id": "req_97fa82439e3e46bfb8ee26400af6215d", + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1573216252176, + "created": 1552939150179, + "url": "{{ node_url }}", + "name": "eth_getBlockByNumber (get latest block)", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByNumber\", \n\t\"params\": [\"latest\", true],\n \"id\": 1\n}" }, - "created": 1570730266922, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -263,31 +347,31 @@ "value": "no-cache" } ], + "authentication": {}, + "metaSortKey": -1565685344791.5, "isPrivate": false, - "metaSortKey": -1565685344804, - "method": "POST", - "modified": 1573216252176, - "name": "eth_getBlockByNumber (get latest block)", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { - "_id": "req_97fa82439e3e46bfb8ee26400af6215d", - "authentication": {}, + "_id": "req_37ff379315d84ec2acf828c8ff27e31d", + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825902802, + "created": 1573216166361, + "url": "{{ node_url }}", + "name": "eth_getBlockByNumber", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByNumber\", \n\t\"params\": [\"0x6\", true],\n \"id\": 1\n}" }, - "created": 1552939150179, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -300,31 +384,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1565685344791.5, - "method": "POST", - "modified": 1599825902802, - "name": "eth_getBlockByNumber", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_eb7e7cc907c1418dafd9f2e23efa28cd", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1570133555400, + "created": 1570133539625, + "url": "{{ node_url }}", + "name": "eth_protocolVersion", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_protocolVersion\", \n\t\"params\": [],\n \"id\": 1\n}" }, - "created": 1570133539625, - "description": "", + "parameters": [], "headers": [ { "id": "pair_76cd4cbd61404c5f8248b3ec90f2ae07", @@ -332,31 +416,31 @@ "value": "application/json" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1565685344779, - "method": "POST", - "modified": 1570133555400, - "name": "eth_protocolVersion", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_f8b418fc0e37401c8166f0b0273b9df0", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825889791, + "created": 1565685344729, + "url": "{{ node_url }}", + "name": "eth_getNonce", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getTransactionCount\", \n\t\"params\": [\"$address\", \"latest\"],\n \"id\": 1\n}" }, - "created": 1565685344729, - "description": "", + "parameters": [], "headers": [ { "id": "pair_76cd4cbd61404c5f8248b3ec90f2ae07", @@ -364,31 +448,31 @@ "value": "application/json" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1565685344729, - "method": "POST", - "modified": 1599825889791, - "name": "eth_getNonce", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_2034d05a112d45618f94f061dfb85c1e", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825884356, + "created": 1573656184339, + "url": "{{ node_url }}", + "name": "eth_getCode", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getCode\", \n\t\"params\": [\"$address\", \"latest\"],\n \"id\": 1\n}" }, - "created": 1573656184339, - "description": "", + "parameters": [], "headers": [ { "id": "pair_76cd4cbd61404c5f8248b3ec90f2ae07", @@ -396,31 +480,31 @@ "value": "application/json" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1565457623961.5, - "method": "POST", - "modified": 1599825884356, - "name": "eth_getCode", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_02c0c2a541ef4fa89129da240eea3054", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825899842, + "created": 1573652476586, + "url": "{{ node_url }}", + "name": "eth_getStorageAt", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getStorageAt\", \n\t\"params\": [\"$address\", \"0\", \"latest\"],\n \"id\": 1\n}" }, - "created": 1573652476586, - "description": "", + "parameters": [], "headers": [ { "id": "pair_76cd4cbd61404c5f8248b3ec90f2ae07", @@ -428,31 +512,31 @@ "value": "application/json" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1565229903194, - "method": "POST", - "modified": 1599825899842, - "name": "eth_getStorageAt", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": false, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": false, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_c5fdcb0e4a6f4b5da3bb68d2cc236e0d", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1566369387323, + "created": 1553865545629, + "url": "{{ node_url }}", + "name": "eth_call", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\", \n \"params\": [{\"from\": \"0x0000000000000000000000000000000000000000\"},\"latest\"],\n \"id\": 1\n}" }, - "created": 1553865545629, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -465,31 +549,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150166.5, - "method": "POST", - "modified": 1566369387323, - "name": "eth_call", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_0baf45afc1014ca4b814a5fe2c1623c0", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1566369392085, + "created": 1553869425689, + "url": "{{ node_url }}", + "name": "eth_getWork", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getWork\", \n \"params\": [],\n \"id\": 1\n}" }, - "created": 1553869425689, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -502,31 +586,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150160.25, - "method": "POST", - "modified": 1566369392085, - "name": "eth_getWork", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_056e84d22c8e498b868eef70ff9cb27d", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1566369401143, + "created": 1553806228056, + "url": "{{ node_url }}", + "name": "eth_getBlockByHash", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\", \n\t\"params\": [\"0x7b42b3e569fe867bc2267f4213cfafe0793fa94753a1629c1efeee838f3aa569\", true],\n \"id\": 1\n}" }, - "created": 1553806228056, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -539,31 +623,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552939150154, - "method": "POST", - "modified": 1566369401143, - "name": "eth_getBlockByHash", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_7770f112c5cb4fc4a0f2d7fea4f6166e", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825954655, + "created": 1554490202940, + "url": "{{ node_url }}", + "name": "eth_getTransactionByHash", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getTransactionByHash\", \n\t\"params\": [\"0x926db397ed35bedee660fe5bf6879679fa71f1fe8c27823f7f6a1e5d96a49b94\"],\n \"id\": 1\n}" }, - "created": 1554490202940, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -576,31 +660,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552766867330.875, - "method": "POST", - "modified": 1599825954655, - "name": "eth_getTransactionByHash", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_2af48bb22c004b4faf58a2d19954b872", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825962625, + "created": 1554488485885, + "url": "{{ node_url }}", + "name": "eth_getTransactionReceipt", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getTransactionReceipt\", \n\t\"params\": [\"0x926db397ed35bedee660fe5bf6879679fa71f1fe8c27823f7f6a1e5d96a49b94\"],\n \"id\": 1\n}" }, - "created": 1554488485885, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -613,31 +697,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552732410766.25, - "method": "POST", - "modified": 1599825962625, - "name": "eth_getTransactionReceipt", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_71950018809a482da79fc927070de862", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825973333, + "created": 1576585718979, + "url": "{{ node_url }}", + "name": "eth_getBalance", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBalance\", \n\t\"params\": [\n\t\t\"$address\", \"$hexBlockNumber\"\n\t],\n \"id\": 1\n}" }, - "created": 1576585718979, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -650,31 +734,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552732410716.25, - "method": "POST", - "modified": 1599825973333, - "name": "eth_getBalance", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_579a127b434b4ac7aa51ee6c93f04630", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825980741, + "created": 1576678912496, + "url": "{{ node_url }}", + "name": "eth_getLogs", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getLogs\", \n\t\"params\": [{\n\t\t\"from_block\": \"earliest\", \n\t\t\"to_block\": \"latest\",\n\t\t\"address\":\"$address\"\n\t}],\n \"id\": 1\n}" }, - "created": 1576678912496, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -687,31 +771,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552697615936.625, - "method": "POST", - "modified": 1599825980741, - "name": "eth_getLogs", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_ba739cbbb7704ca5a56b85a4a54461d4", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1599825990271, + "created": 1576679268522, + "url": "{{ node_url }}", + "name": "eth_newFilter", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_newFilter\", \n\t\"params\": [{\n\t\t\"from_block\": \"earliest\",\n\t\t\"to_block\": \"latest\", \n\t\t\"address\":\"$address\"\n\t}],\n \"id\": 1\n}" }, - "created": 1576679268522, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -724,31 +808,31 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552680218546.8125, - "method": "POST", - "modified": 1599825990271, - "name": "eth_newFilter", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "req_6ea302a10ad94d91bc468a6b5de100e0", - "authentication": {}, + "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "modified": 1576781874557, + "created": 1576679570457, + "url": "{{ node_url }}", + "name": "eth_getFilterLogs", + "description": "", + "method": "POST", "body": { "mimeType": "application/json", "text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_getFilterLogs\", \n\t\"params\": [\"$newFilterResponse\"],\n \"id\": 1\n}" }, - "created": 1576679570457, - "description": "", + "parameters": [], "headers": [ { "id": "pair_9f4d6a9dde554cd384487e04fa3b21aa", @@ -761,71 +845,60 @@ "value": "no-cache" } ], - "isPrivate": false, + "authentication": {}, "metaSortKey": -1552671519851.9062, - "method": "POST", - "modified": 1576781874557, - "name": "eth_getFilterLogs", - "parameters": [], - "parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1", + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, "settingDisableRenderRequestBody": false, "settingEncodeUrl": true, - "settingFollowRedirects": "global", "settingRebuildPath": true, - "settingSendCookies": true, - "settingStoreCookies": true, - "url": "{{ node_url }}", + "settingFollowRedirects": "global", "_type": "request" }, { "_id": "env_ee4c8118750744559d3b1020845fe5d4", - "color": null, + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1552663132622, "created": 1552662762810, + "name": "New Environment", "data": {}, "dataPropertyOrder": null, + "color": null, "isPrivate": false, "metaSortKey": 1552662762810, - "modified": 1552663132622, - "name": "New Environment", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "_type": "environment" }, { "_id": "jar_58c53fc81ace48f7a26358d5677d4280", - "cookies": [], - "created": 1552662762812, + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", "modified": 1552662762812, + "created": 1552662762812, "name": "Default Jar", - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "cookies": [], "_type": "cookie_jar" }, { "_id": "spc_fdaf789c47cc409da097e11e2c0120e5", - "contentType": "yaml", - "contents": "", + "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "modified": 1592230124247, "created": 1592230124247, "fileName": "Mantis", - "modified": 1592230124247, - "parentId": "wrk_097d43914a4d4aea8b6f73f647921182", + "contents": "", + "contentType": "yaml", "_type": "api_spec" }, { "_id": "env_2e1a8d7b5f3649308cb3c524e84a3f33", - "color": null, + "parentId": "env_ee4c8118750744559d3b1020845fe5d4", + "modified": 1599825641645, "created": 1552663140073, - "data": { - "node_url": "http://127.0.0.1:8546" - }, - "dataPropertyOrder": { - "&": [ - "node_url" - ] - }, + "name": "Develop", + "data": { "node_url": "http://127.0.0.1:8546" }, + "dataPropertyOrder": { "&": ["node_url"] }, + "color": null, "isPrivate": false, "metaSortKey": 1552663140073, - "modified": 1599825641645, - "name": "Develop", - "parentId": "env_ee4c8118750744559d3b1020845fe5d4", "_type": "environment" } ] diff --git a/src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainTestConfig.scala b/src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainTestConfig.scala index 2e220a5c44..727beb2cff 100644 --- a/src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainTestConfig.scala +++ b/src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainTestConfig.scala @@ -43,7 +43,8 @@ object BlockchainTestConfig { atlantisBlockNumber = Long.MaxValue, aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) val FrontierConfig = BaseBlockchainConfig.copy( diff --git a/src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala b/src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala index 0b66cac52f..dceeec132e 100644 --- a/src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala +++ b/src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala @@ -2,7 +2,7 @@ package io.iohk.ethereum.txExecTest import java.util.concurrent.Executors -import io.iohk.ethereum.domain.{BlockchainImpl, Receipt, UInt256} +import io.iohk.ethereum.domain.{Address, BlockchainImpl, Receipt, UInt256} import io.iohk.ethereum.ledger._ import io.iohk.ethereum.txExecTest.util.FixtureProvider import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig} @@ -45,7 +45,8 @@ class ECIP1017Test extends AnyFlatSpec with Matchers { aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, petersburgBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(4)) diff --git a/src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala b/src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala index cded37e99a..8d07674d6a 100644 --- a/src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala +++ b/src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala @@ -2,7 +2,7 @@ package io.iohk.ethereum.txExecTest import java.util.concurrent.Executors -import io.iohk.ethereum.domain.{BlockchainImpl, Receipt, UInt256} +import io.iohk.ethereum.domain.{Address, BlockchainImpl, Receipt, UInt256} import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation} import io.iohk.ethereum.txExecTest.util.FixtureProvider import io.iohk.ethereum.utils.{BlockchainConfig, MonetaryPolicyConfig} @@ -44,7 +44,8 @@ class ForksTest extends AnyFlatSpec with Matchers { aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, petersburgBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) val noErrors = a[Right[_, Seq[Receipt]]] diff --git a/src/main/resources/chains/etc-chain.conf b/src/main/resources/chains/etc-chain.conf index 660b2ec1d2..ad06a2a7de 100644 --- a/src/main/resources/chains/etc-chain.conf +++ b/src/main/resources/chains/etc-chain.conf @@ -80,6 +80,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/resources/chains/eth-chain.conf b/src/main/resources/chains/eth-chain.conf index ebd13204ad..53b24ce0a8 100644 --- a/src/main/resources/chains/eth-chain.conf +++ b/src/main/resources/chains/eth-chain.conf @@ -80,6 +80,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/resources/chains/mordor-chain.conf b/src/main/resources/chains/mordor-chain.conf index 167861fd10..91fc559f97 100644 --- a/src/main/resources/chains/mordor-chain.conf +++ b/src/main/resources/chains/mordor-chain.conf @@ -80,6 +80,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/resources/chains/ropsten-chain.conf b/src/main/resources/chains/ropsten-chain.conf index a9881d7959..d506d37f5b 100644 --- a/src/main/resources/chains/ropsten-chain.conf +++ b/src/main/resources/chains/ropsten-chain.conf @@ -83,6 +83,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/resources/chains/test-chain.conf b/src/main/resources/chains/test-chain.conf index 78790561c5..06f07065f7 100644 --- a/src/main/resources/chains/test-chain.conf +++ b/src/main/resources/chains/test-chain.conf @@ -80,6 +80,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/resources/chains/testnet-internal-chain.conf b/src/main/resources/chains/testnet-internal-chain.conf index c5f5311663..88441ce207 100644 --- a/src/main/resources/chains/testnet-internal-chain.conf +++ b/src/main/resources/chains/testnet-internal-chain.conf @@ -80,6 +80,7 @@ # Proto-treasury fork block number (ETC only, but deactivated for now) # https://ecips.ethereumclassic.org/ECIPs/ecip-1098 + treasury-address = "0011223344556677889900112233445566778899" ecip1098-block-number = "1000000000000000000" # DAO fork configuration (Ethereum HF/Classic split) diff --git a/src/main/scala/io/iohk/ethereum/ledger/BlockPreparator.scala b/src/main/scala/io/iohk/ethereum/ledger/BlockPreparator.scala index aef57d6930..91f9ad46be 100644 --- a/src/main/scala/io/iohk/ethereum/ledger/BlockPreparator.scala +++ b/src/main/scala/io/iohk/ethereum/ledger/BlockPreparator.scala @@ -6,6 +6,7 @@ import io.iohk.ethereum.domain.UInt256._ import io.iohk.ethereum.domain._ import io.iohk.ethereum.ledger.BlockExecutionError.{StateBeforeFailure, TxsExecutionError} import io.iohk.ethereum.ledger.Ledger._ +import io.iohk.ethereum.ledger.BlockPreparator._ import io.iohk.ethereum.utils.{BlockchainConfig, Logger} import io.iohk.ethereum.vm.{PC => _, _} @@ -38,33 +39,66 @@ class BlockPreparator( ) /** - * This function updates state in order to pay rewards based on YP section 11.3 + * This function updates the state in order to pay rewards based on YP section 11.3 and with the required + * modifications due to ECIP1097: + * 1. Reward for block is distributed as: + * a. If treasury is disabled or it's has been selfdestructed: + * Pay 100% of it to the miner + * b. If a. isn't true and the miner opted out: + * Pay 80% of it to the miner + * Never generate the 20% else + * c. If a. isn't true and the miner opted in: + * Pay 80% of it to the miner + * Pay 20% of it to the treasury contract + * 2. Miner is payed a reward for the inclusion of ommers + * 3. Ommers's miners are payed a reward for their inclusion in this block * - * @param block - * @param worldStateProxy - * @return + * @param block the block being processed + * @param worldStateProxy the initial state + * @return the state after paying the apropiate reward to who corresponds */ private[ledger] def payBlockReward(block: Block, worldStateProxy: InMemoryWorldStateProxy): InMemoryWorldStateProxy = { - def getAccountToPay(address: Address, ws: InMemoryWorldStateProxy): Account = - ws.getAccount(address).getOrElse(Account.empty(blockchainConfig.accountStartNonce)) - val blockNumber = block.header.number + val minerRewardForBlock = blockRewardCalculator.calculateMiningRewardForBlock(blockNumber) + val minerRewardForOmmers = blockRewardCalculator.calculateMiningRewardForOmmers(blockNumber, block.body.uncleNodesList.size) + val minerAddress = Address(block.header.beneficiary) - val minerAccount = getAccountToPay(minerAddress, worldStateProxy) - val minerReward = blockRewardCalculator.calcBlockMinerReward(blockNumber, block.body.uncleNodesList.size) + val treasuryAddress = blockchainConfig.treasuryAddress + val existsTreasuryContract = worldStateProxy.getAccount(treasuryAddress).isDefined - val afterMinerReward = worldStateProxy.saveAccount(minerAddress, minerAccount.increaseBalance(UInt256(minerReward))) - log.debug(s"Paying block $blockNumber reward of $minerReward to miner with account address $minerAddress") + val worldAfterPayingBlockReward = + if (block.header.treasuryOptOut.isEmpty || !existsTreasuryContract) { + val minerReward = minerRewardForOmmers + minerRewardForBlock + val worldAfterMinerReward = increaseAccountBalance(minerAddress, UInt256(minerReward))(worldStateProxy) + log.debug(s"Paying block $blockNumber reward of $minerReward to miner with address $minerAddress") - block.body.uncleNodesList.foldLeft(afterMinerReward) { (ws, ommer) => - val ommerAddress = Address(ommer.beneficiary) - val account = getAccountToPay(ommerAddress, ws) + worldAfterMinerReward + } else if (block.header.treasuryOptOut.get) { + val minerReward = minerRewardForOmmers + minerRewardForBlock * MinerRewardPercentageAfterECIP1098 / 100 + val worldAfterMinerReward = increaseAccountBalance(minerAddress, UInt256(minerReward))(worldStateProxy) + log.debug(s"Paying block $blockNumber reward of $minerReward to miner with address $minerAddress, miner opted-out of treasury") + + worldAfterMinerReward + } else { + val minerReward = minerRewardForOmmers + minerRewardForBlock * MinerRewardPercentageAfterECIP1098 / 100 + val worldAfterMinerReward = increaseAccountBalance(minerAddress, UInt256(minerReward))(worldStateProxy) + + val treasuryReward = minerRewardForBlock * TreasuryRewardPercentageAfterECIP1098 / 100 + val worldAfterTreasuryReward = increaseAccountBalance(treasuryAddress, UInt256(treasuryReward))(worldAfterMinerReward) + + log.debug(s"Paying block $blockNumber reward of $minerReward to miner with address $minerAddress" + + s"paying treasury reward of $treasuryReward to treasury with address $treasuryAddress") - val ommerReward = blockRewardCalculator.calcOmmerMinerReward(blockNumber, ommer.number) + worldAfterTreasuryReward + } + + block.body.uncleNodesList.foldLeft(worldAfterPayingBlockReward) { (ws, ommer) => + val ommerAddress = Address(ommer.beneficiary) + val ommerReward = blockRewardCalculator.calculateOmmerRewardForInclusion(blockNumber, ommer.number) log.debug(s"Paying block $blockNumber reward of $ommerReward to ommer with account address $ommerAddress") - ws.saveAccount(ommerAddress, account.increaseBalance(UInt256(ommerReward))) + increaseAccountBalance(ommerAddress, UInt256(ommerReward))(ws) } } @@ -120,13 +154,16 @@ class BlockPreparator( } } + private[ledger] def increaseAccountBalance(address: Address, value: UInt256)(world: InMemoryWorldStateProxy): InMemoryWorldStateProxy = { + val account = world.getAccount(address).getOrElse(Account.empty(blockchainConfig.accountStartNonce)).increaseBalance(value) + world.saveAccount(address, account) + } + private[ledger] def pay(address: Address, value: UInt256, withTouch: Boolean)(world: InMemoryWorldStateProxy): InMemoryWorldStateProxy = { if (world.isZeroValueTransferToNonExistentAccount(address, value)) { world } else { - val account = world.getAccount(address).getOrElse(Account.empty(blockchainConfig.accountStartNonce)).increaseBalance(value) - val savedWorld = world.saveAccount(address, account) - + val savedWorld = increaseAccountBalance(address, value)(world) if (withTouch) savedWorld.touchAccounts(address) else savedWorld } } @@ -320,3 +357,8 @@ class BlockPreparator( } } } + +object BlockPreparator { + val TreasuryRewardPercentageAfterECIP1098 = 20 + val MinerRewardPercentageAfterECIP1098 = 100 - TreasuryRewardPercentageAfterECIP1098 +} diff --git a/src/main/scala/io/iohk/ethereum/ledger/BlockRewardCalculator.scala b/src/main/scala/io/iohk/ethereum/ledger/BlockRewardCalculator.scala index 16c85d9f39..a2d5d97ced 100644 --- a/src/main/scala/io/iohk/ethereum/ledger/BlockRewardCalculator.scala +++ b/src/main/scala/io/iohk/ethereum/ledger/BlockRewardCalculator.scala @@ -44,33 +44,44 @@ class BlockRewardCalculator(config: MonetaryPolicyConfig, byzantiumBlockNumber: val firstEraOmmerMiningRewardDenom: BigInt = 8 - def calcBlockMinerReward(blockNumber: BigInt, ommersCount: Int): BigInt = { - val baseReward = calcMinerBaseReward(blockNumber) - val ommersReward = calcMinerRewardPerOmmer(blockNumber) * ommersCount - baseReward + ommersReward + /** + * Calculates the miner reward for the block, that is, without considering the ommers included + * + * @param blockNumber of the mined block + * @return miner reward for the block + */ + def calculateMiningRewardForBlock(blockNumber: BigInt): BigInt = { + val era = eraNumber(blockNumber) + val eraMultiplier = rewardReductionRateNumer.pow(era) + val eraDivisor = rewardReductionRateDenom.pow(era) + newBlockReward(blockNumber) * eraMultiplier / eraDivisor } - def calcOmmerMinerReward(blockNumber: BigInt, ommerNumber: BigInt): BigInt = { + /** + * Calculates the miner reward for the ommers included on the block + * + * @param blockNumber of the mined block + * @param ommersCount the number of ommers on the block + * @return miner reward for the block ommers + */ + def calculateMiningRewardForOmmers(blockNumber: BigInt, ommersCount: Int): BigInt = + calculateMiningRewardPerOmmer(blockNumber) * ommersCount + + /** + * Calculates the ommers reward for the ommers included on the block + * + * @param blockNumber of the mined block + * @param ommerNumber the block number of the ommer + * @return ommer reward + */ + def calculateOmmerRewardForInclusion(blockNumber: BigInt, ommerNumber: BigInt): BigInt = { val era = eraNumber(blockNumber) if (era == 0) { val number = firstEraOmmerMiningRewardMaxNumer - (blockNumber - ommerNumber - 1) (newBlockReward(blockNumber) * number) / firstEraOmmerMiningRewardDenom } else - calcMinerBaseReward(blockNumber) * ommerMiningRewardNumer / ommerMiningRewardDenom - } - - /** - * Calculates the miner base reward (without considering the ommers included) - * - * @param blockNumber mined block - * @return miner base reward - */ - private def calcMinerBaseReward(blockNumber: BigInt): BigInt = { - val era = eraNumber(blockNumber) - val eraMultiplier = rewardReductionRateNumer.pow(era) - val eraDivisor = rewardReductionRateDenom.pow(era) - newBlockReward(blockNumber) * eraMultiplier / eraDivisor + calculateMiningRewardForBlock(blockNumber) * ommerMiningRewardNumer / ommerMiningRewardDenom } /** @@ -79,8 +90,8 @@ class BlockRewardCalculator(config: MonetaryPolicyConfig, byzantiumBlockNumber: * @param blockNumber mined block * @return reward given to the miner for each ommer included */ - private def calcMinerRewardPerOmmer(blockNumber: BigInt): BigInt = { - calcMinerBaseReward(blockNumber) * ommerInclusionRewardNumer / ommerInclusionRewardDenom + private def calculateMiningRewardPerOmmer(blockNumber: BigInt): BigInt = { + calculateMiningRewardForBlock(blockNumber) * ommerInclusionRewardNumer / ommerInclusionRewardDenom } /** era number counting from 0 */ diff --git a/src/main/scala/io/iohk/ethereum/utils/BlockchainConfig.scala b/src/main/scala/io/iohk/ethereum/utils/BlockchainConfig.scala index efee6e5d62..13b2572db7 100644 --- a/src/main/scala/io/iohk/ethereum/utils/BlockchainConfig.scala +++ b/src/main/scala/io/iohk/ethereum/utils/BlockchainConfig.scala @@ -1,7 +1,7 @@ package io.iohk.ethereum.utils import akka.util.ByteString -import io.iohk.ethereum.domain.UInt256 +import io.iohk.ethereum.domain.{Address, UInt256} import io.iohk.ethereum.utils.NumericUtils._ import scala.collection.JavaConverters._ @@ -25,6 +25,7 @@ case class BlockchainConfig( aghartaBlockNumber: BigInt, phoenixBlockNumber: BigInt, petersburgBlockNumber: BigInt, + treasuryAddress: Address, ecip1098BlockNumber: BigInt, maxCodeSize: Option[BigInt], @@ -72,6 +73,7 @@ object BlockchainConfig { val aghartaBlockNumber: BigInt = BigInt(blockchainConfig.getString("agharta-block-number")) val phoenixBlockNumber: BigInt = BigInt(blockchainConfig.getString("phoenix-block-number")) val petersburgBlockNumber: BigInt = BigInt(blockchainConfig.getString("petersburg-block-number")) + val treasuryAddress = Address(blockchainConfig.getString("treasury-address")) val ecip1098BlockNumber: BigInt = BigInt(blockchainConfig.getString("ecip1098-block-number")) val maxCodeSize: Option[BigInt] = Try(BigInt(blockchainConfig.getString("max-code-size"))).toOption @@ -117,6 +119,7 @@ object BlockchainConfig { aghartaBlockNumber = aghartaBlockNumber, phoenixBlockNumber = phoenixBlockNumber, petersburgBlockNumber = petersburgBlockNumber, + treasuryAddress = treasuryAddress, ecip1098BlockNumber = ecip1098BlockNumber, maxCodeSize = maxCodeSize, diff --git a/src/test/scala/io/iohk/ethereum/consensus/BlockGeneratorSpec.scala b/src/test/scala/io/iohk/ethereum/consensus/BlockGeneratorSpec.scala index 4affae457f..60ebc7f522 100644 --- a/src/test/scala/io/iohk/ethereum/consensus/BlockGeneratorSpec.scala +++ b/src/test/scala/io/iohk/ethereum/consensus/BlockGeneratorSpec.scala @@ -221,7 +221,8 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, petersburgBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) override lazy val blockExecution = @@ -490,7 +491,8 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, petersburgBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) override lazy val blockchainConfig = baseBlockchainConfig diff --git a/src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala b/src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala index 28d6e0414f..da9b3b93d8 100644 --- a/src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala +++ b/src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala @@ -431,7 +431,8 @@ class BlockHeaderValidatorSpec aghartaBlockNumber = Long.MaxValue, phoenixBlockNumber = Long.MaxValue, petersburgBlockNumber = Long.MaxValue, - ecip1098BlockNumber = Long.MaxValue + ecip1098BlockNumber = Long.MaxValue, + treasuryAddress = Address(0) ) } diff --git a/src/test/scala/io/iohk/ethereum/jsonrpc/EthServiceSpec.scala b/src/test/scala/io/iohk/ethereum/jsonrpc/EthServiceSpec.scala index 976d3d6190..c8a597c851 100644 --- a/src/test/scala/io/iohk/ethereum/jsonrpc/EthServiceSpec.scala +++ b/src/test/scala/io/iohk/ethereum/jsonrpc/EthServiceSpec.scala @@ -976,38 +976,6 @@ class EthServiceSpec override lazy val ledger = mock[Ledger] override lazy val stxLedger = mock[StxLedger] - override lazy val blockchainConfig = BlockchainConfig( - ethCompatibleStorage = true, - //unused - eip155BlockNumber = 0, - chainId = 0x03.toByte, - networkId = 1, - maxCodeSize = None, - eip161BlockNumber = 0, - frontierBlockNumber = 0, - homesteadBlockNumber = 0, - eip150BlockNumber = 0, - eip160BlockNumber = 0, - eip106BlockNumber = 0, - byzantiumBlockNumber = 0, - constantinopleBlockNumber = 0, - istanbulBlockNumber = 0, - difficultyBombPauseBlockNumber = 0, - difficultyBombContinueBlockNumber = 0, - difficultyBombRemovalBlockNumber = 0, - customGenesisFileOpt = None, - accountStartNonce = UInt256.Zero, - monetaryPolicyConfig = MonetaryPolicyConfig(0, 0, 0, 0), - daoForkConfig = None, - bootstrapNodes = Set(), - gasTieBreaker = false, - atlantisBlockNumber = 0, - aghartaBlockNumber = 0, - phoenixBlockNumber = 0, - petersburgBlockNumber = 0, - ecip1098BlockNumber = 0 - ) - override lazy val consensus: TestConsensus = buildTestConsensus().withBlockGenerator(blockGenerator) override implicit lazy val system = ActorSystem("EthServiceSpec_System") diff --git a/src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala b/src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala index 6ecdde1a44..c83b25ef0c 100644 --- a/src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala +++ b/src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala @@ -427,7 +427,8 @@ class PersonalServiceSpec aghartaBlockNumber = 0, phoenixBlockNumber = 0, petersburgBlockNumber = 0, - ecip1098BlockNumber = 0 + ecip1098BlockNumber = 0, + treasuryAddress = Address(0) ) val wallet = Wallet(address, prvKey) diff --git a/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorOps.scala b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorOps.scala new file mode 100644 index 0000000000..631b65d1a4 --- /dev/null +++ b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorOps.scala @@ -0,0 +1,12 @@ +package io.iohk.ethereum.ledger + +object BlockRewardCalculatorOps { + + implicit class BlockRewardCalculatorWithMinerReward(calculator: BlockRewardCalculator) { + def calculateMiningReward(blockNumber: BigInt, numberOfOmmers: Int): BigInt = { + val rewardForBlock = calculator.calculateMiningRewardForBlock(blockNumber) + val rewardForOmmers = calculator.calculateMiningRewardForOmmers(blockNumber, numberOfOmmers) + rewardForBlock + rewardForOmmers + } + } +} diff --git a/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorSpec.scala b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorSpec.scala index 02983f75c0..db0654e6d5 100644 --- a/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorSpec.scala +++ b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardCalculatorSpec.scala @@ -1,6 +1,7 @@ package io.iohk.ethereum.ledger import io.iohk.ethereum.utils.MonetaryPolicyConfig +import io.iohk.ethereum.ledger.BlockRewardCalculatorOps._ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers @@ -124,8 +125,8 @@ class BlockRewardCalculatorSpec extends AnyFlatSpec with Matchers with ScalaChec ) => val calculator = new BlockRewardCalculator(config, byzantiumBlockNumber, constantinopleBlockNumber) - val blockReward = calculator.calcBlockMinerReward(blockNumber, ommersNumbers.size) - val ommersRewards = ommersNumbers.map(calculator.calcOmmerMinerReward(blockNumber, _)) + val blockReward = calculator.calculateMiningReward(blockNumber, ommersNumbers.size) + val ommersRewards = ommersNumbers.map(calculator.calculateOmmerRewardForInclusion(blockNumber, _)) blockReward shouldEqual expectedBlockReward ommersRewards shouldEqual expectedOmmersRewards @@ -198,9 +199,9 @@ class BlockRewardCalculatorSpec extends AnyFlatSpec with Matchers with ScalaChec (config, blockNumber, expectedBlockReward, expectedWinnerOneUncleReward, expectedWinnerTwoUnclesReward) => val calculator = new BlockRewardCalculator(config, byzantiumBlockNumber, constantinopleBlockNumber) - val blockReward = calculator.calcBlockMinerReward(blockNumber, 0) - val winnerOneUncleReward = calculator.calcBlockMinerReward(blockNumber, 1) - val winnerTwoUnclesReward = calculator.calcBlockMinerReward(blockNumber, 2) + val blockReward = calculator.calculateMiningReward(blockNumber, 0) + val winnerOneUncleReward = calculator.calculateMiningReward(blockNumber, 1) + val winnerTwoUnclesReward = calculator.calculateMiningReward(blockNumber, 2) blockReward shouldEqual expectedBlockReward winnerOneUncleReward shouldEqual expectedWinnerOneUncleReward @@ -424,7 +425,7 @@ class BlockRewardCalculatorSpec extends AnyFlatSpec with Matchers with ScalaChec forAll(ecip1039table) { (config, blockNumber, expectedWinnerTwoUnclesReward) => val calculator = new BlockRewardCalculator(config, byzantiumBlockNumber, constantinopleBlockNumber) - val winnerTwoUnclesReward = calculator.calcBlockMinerReward(blockNumber, 2) + val winnerTwoUnclesReward = calculator.calculateMiningReward(blockNumber, 2) winnerTwoUnclesReward shouldEqual expectedWinnerTwoUnclesReward } diff --git a/src/test/scala/io/iohk/ethereum/ledger/BlockRewardSpec.scala b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardSpec.scala index d42ded5cb2..29c02ac468 100644 --- a/src/test/scala/io/iohk/ethereum/ledger/BlockRewardSpec.scala +++ b/src/test/scala/io/iohk/ethereum/ledger/BlockRewardSpec.scala @@ -4,19 +4,18 @@ import io.iohk.ethereum.Fixtures import io.iohk.ethereum.Mocks.MockVM import io.iohk.ethereum.blockchain.sync.EphemBlockchainTestSetup import io.iohk.ethereum.domain._ +import io.iohk.ethereum.ledger.BlockPreparator._ import io.iohk.ethereum.ledger.Ledger.VMImpl +import io.iohk.ethereum.ledger.BlockRewardCalculatorOps._ import io.iohk.ethereum.utils.Config -import io.iohk.ethereum.utils.Config.SyncConfig import org.scalamock.scalatest.MockFactory import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers +import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { +class BlockRewardSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks with MockFactory { - val blockchainConfig = Config.blockchains.blockchainConfig - val syncConfig = SyncConfig(Config.config) - - "Reward Calculation" should "pay to the miner if no ommers included" in new TestSetup { + it should "pay to the miner if no ommers included" in new TestSetup { val block = sampleBlock(validAccountAddress, Seq(validAccountAddress2, validAccountAddress3)) val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldState) val beforeExecutionBalance: BigInt = worldState.getGuaranteedAccount(Address(block.header.beneficiary)).balance @@ -24,14 +23,15 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { } // scalastyle:off magic.number - "Reward" should "be paid to the miner even if the account doesn't exist" in new TestSetup { + it should "be paid to the miner even if the account doesn't exist" in new TestSetup { val block = sampleBlock(Address(0xdeadbeef)) val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldState) - val expectedReward = UInt256(consensus.blockPreparator.blockRewardCalculator.calcBlockMinerReward(block.header.number, 0)) + val expectedRewardAsBigInt = consensus.blockPreparator.blockRewardCalculator.calculateMiningReward(block.header.number, 0) + val expectedReward = UInt256(expectedRewardAsBigInt) afterRewardWorldState.getGuaranteedAccount(Address(block.header.beneficiary)).balance shouldEqual expectedReward } - "Reward Calculation" should "be paid if ommers are included in block" in new TestSetup { + it should "be paid if ommers are included in block" in new TestSetup { val block = sampleBlock(validAccountAddress, Seq(validAccountAddress2, validAccountAddress3)) val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldState) @@ -47,7 +47,7 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { uncleBalance2 shouldEqual (beforeExecutionBalance3 + ommerFiveBlocksDifferenceReward) } - "Reward" should "be paid if ommers are included in block even if accounts don't exist" in new TestSetup { + it should "be paid if ommers are included in block even if accounts don't exist" in new TestSetup { val block = sampleBlock(Address(0xdeadbeef), Seq(Address(0x1111), Address(0x2222))) val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldState) afterRewardWorldState.getGuaranteedAccount(Address(block.header.beneficiary)).balance shouldEqual minerTwoOmmersReward @@ -55,7 +55,7 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { afterRewardWorldState.getGuaranteedAccount(Address(block.body.uncleNodesList(1).beneficiary)).balance shouldEqual ommerFiveBlocksDifferenceReward } - "Reward Calculation" should "be calculated correctly after byzantium fork" in new TestSetup { + it should "be calculated correctly after byzantium fork" in new TestSetup { val block: Block = sampleBlockAfterByzantium(validAccountAddress) val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldState) val address = Address(block.header.beneficiary) @@ -63,7 +63,7 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { afterRewardWorldState.getGuaranteedAccount(address).balance shouldEqual beforeExecutionBalance + afterByzantiumNewBlockReward } - "Reward Calculation" should "be calculated correctly if ommers are included in block after byzantium fork " in new TestSetup { + it should "be calculated correctly if ommers are included in block after byzantium fork " in new TestSetup { val block: Block = sampleBlockAfterByzantium(validAccountAddress4, Seq(validAccountAddress5, validAccountAddress6)) val minerAddress = Address(block.header.beneficiary) @@ -86,6 +86,46 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { afterRewardWorldState.getGuaranteedAccount(ommer2Address).balance shouldEqual (beforeExecutionBalance3 + ommersRewards) } + it should "correctly distribute block reward according to ECIP1098" in new TestSetup { + val blockReward = consensus.blockPreparator.blockRewardCalculator.calculateMiningRewardForBlock(sampleBlockNumber) + + val table = Table[Option[Boolean], Boolean, BigInt, BigInt]( + ("miner opts-out", "contract deployed", "miner reward", "treasury reward"), + // ECIP1098 not activated + (None, true, blockReward, 0), + (None, false, blockReward, 0), + + // ECIP1098 previously activated but contract destroyed + (Some(true), false, blockReward, 0), + (Some(false), false, blockReward, 0), + + // ECIP1098 activated with contract in place + (Some(false), true, MinerRewardPercentageAfterECIP1098 * blockReward / 100, TreasuryRewardPercentageAfterECIP1098 * blockReward / 100), + (Some(true), true, MinerRewardPercentageAfterECIP1098 * blockReward / 100, 0) + ) + + forAll(table) { case (minerOptsOut, contractDeployed, minerReward, treasuryReward) => + val minerAddress = validAccountAddress + val block = sampleBlock(minerAddress, Nil, minerOptsOut) + + val worldBeforeExecution = + if(contractDeployed) worldState + else { + val worldWithoutTreasury = worldState.deleteAccount(treasuryAddress) + InMemoryWorldStateProxy.persistState(worldWithoutTreasury) + } + + val beforeExecutionMinerBalance: BigInt = worldBeforeExecution.getAccount(minerAddress).fold(UInt256.Zero)(_.balance) + val beforeExecutionTreasuryBalance: BigInt = worldBeforeExecution.getAccount(treasuryAddress).fold(UInt256.Zero)(_.balance) + + val afterRewardWorldState: InMemoryWorldStateProxy = consensus.blockPreparator.payBlockReward(block, worldBeforeExecution) + val afterExecutionMinerBalance = afterRewardWorldState.getAccount(minerAddress).fold(UInt256.Zero)(_.balance) + val afterExecutionTreasuryBalance = afterRewardWorldState.getAccount(treasuryAddress).fold(UInt256.Zero)(_.balance) + + afterExecutionMinerBalance shouldEqual (beforeExecutionMinerBalance + minerReward) + afterExecutionTreasuryBalance shouldEqual (beforeExecutionTreasuryBalance + treasuryReward) + } + } // scalastyle:off magic.number trait TestSetup extends EphemBlockchainTestSetup { @@ -96,7 +136,6 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { override lazy val ledger: LedgerImpl = newLedger() //- cake overrides - val validAccountAddress = Address(0xababab) // 11250603 val validAccountAddress2 = Address(0xcdcdcd) // 13487565 val validAccountAddress3 = Address(0xefefef) // 15724527 @@ -105,6 +144,10 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { val validAccountAddress5 = Address("0x29a2241af64e2223") // 3000000000002236963 val validAccountAddress6 = Address("0x29a2241af6704445") // 3000000000004473925 + val treasuryAddress = validAccountAddress2 + val baseBlockchainConfig = Config.blockchains.blockchainConfig + override lazy val blockchainConfig = baseBlockchainConfig.copy(treasuryAddress = treasuryAddress) + val minerTwoOmmersReward = BigInt("5312500000000000000") val ommerFiveBlocksDifferenceReward = BigInt("1875000000000000000") val afterByzantiumNewBlockReward: BigInt = BigInt(10).pow(18) * 3 @@ -119,9 +162,10 @@ class BlockRewardSpec extends AnyFlatSpec with Matchers with MockFactory { .saveAccount(validAccountAddress6, Account(balance = 20)) // We don't care for this tests if block is not valid - def sampleBlock(minerAddress: Address, ommerMiners: Seq[Address] = Nil): Block = { + val sampleBlockNumber = 10 + def sampleBlock(minerAddress: Address, ommerMiners: Seq[Address] = Nil, treasuryOptOut: Option[Boolean] = None): Block = { Block( - header = Fixtures.Blocks.Genesis.header.copy(beneficiary = minerAddress.bytes, number = 10), + header = Fixtures.Blocks.Genesis.header.copy(beneficiary = minerAddress.bytes, number = sampleBlockNumber, treasuryOptOut = treasuryOptOut), body = Fixtures.Blocks.Genesis.body.copy( uncleNodesList = ommerMiners.map{ address => Fixtures.Blocks.Genesis.header.copy(beneficiary = address.bytes, number = 5) diff --git a/src/test/scala/io/iohk/ethereum/ledger/LedgerSpec.scala b/src/test/scala/io/iohk/ethereum/ledger/LedgerSpec.scala index a05d896507..613f1dee91 100644 --- a/src/test/scala/io/iohk/ethereum/ledger/LedgerSpec.scala +++ b/src/test/scala/io/iohk/ethereum/ledger/LedgerSpec.scala @@ -11,6 +11,7 @@ import io.iohk.ethereum.consensus.validators.{Validators, _} import io.iohk.ethereum.domain._ import io.iohk.ethereum.ledger.BlockExecutionError.{ValidationAfterExecError, ValidationBeforeExecError} import io.iohk.ethereum.ledger.Ledger.{BlockResult, VMImpl} +import io.iohk.ethereum.ledger.BlockRewardCalculatorOps._ import io.iohk.ethereum.vm._ import java.util.concurrent.Executors import org.bouncycastle.crypto.AsymmetricCipherKeyPair @@ -51,12 +52,12 @@ class LedgerSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matchers forAll(table) { (ommersSize, ommersBlockDifference) => val ommersAddresses = (0 until ommersSize).map(i => Address(i.toByte +: Hex.decode("10"))) - val blockReward = ledger.blockRewardCalculator.calcBlockMinerReward(validBlockHeader.number, ommersSize) + val blockReward = ledger.blockRewardCalculator.calculateMiningReward(validBlockHeader.number, ommersSize) val changes = Seq( minerAddress -> UpdateBalance(UInt256(blockReward)) ) ++ ommersAddresses.map { ommerAddress => - val ommerReward = ledger.blockRewardCalculator.calcOmmerMinerReward( + val ommerReward = ledger.blockRewardCalculator.calculateOmmerRewardForInclusion( validBlockHeader.number, validBlockHeader.number - ommersBlockDifference ) @@ -109,11 +110,7 @@ class LedgerSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matchers ) ) - val blockReward: BigInt = new BlockRewardCalculator( - blockchainConfig.monetaryPolicyConfig, - blockchainConfig.byzantiumBlockNumber, - blockchainConfig.constantinopleBlockNumber - ).calcBlockMinerReward(validBlockHeader.number, 0) + val blockReward: BigInt = ledger.blockRewardCalculator.calculateMiningReward(validBlockHeader.number, 0) val changes = Seq( minerAddress -> UpdateBalance(UInt256(blockReward)) // Paying miner for block processing @@ -155,11 +152,7 @@ class LedgerSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matchers ) ) - val blockReward: BigInt = new BlockRewardCalculator( - blockchainConfig.monetaryPolicyConfig, - blockchainConfig.byzantiumBlockNumber, - blockchainConfig.constantinopleBlockNumber - ).calcBlockMinerReward(validBlockHeader.number, 0) + val blockReward: BigInt = ledger.blockRewardCalculator.calculateMiningReward(validBlockHeader.number, 0) val changes = Seq(minerAddress -> UpdateBalance(UInt256(blockReward))) //Paying miner for block processing val correctStateRoot: ByteString = applyChanges(validBlockParentHeader.stateRoot, blockchainStorages, changes) @@ -269,7 +262,7 @@ class LedgerSpec extends AnyFlatSpec with ScalaCheckPropertyChecks with Matchers // Check world InMemoryWorldStateProxy.persistState(resultingWorldState).stateRootHash shouldBe expectedStateRootTx2 - val blockReward = ledger.blockRewardCalculator.calcBlockMinerReward(block.header.number, 0) + val blockReward: BigInt = ledger.blockRewardCalculator.calculateMiningReward(block.header.number, 0) val changes = Seq( minerAddress -> UpdateBalance(UInt256(blockReward)) ) diff --git a/src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala b/src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala index 53610bc379..337c2f1284 100644 --- a/src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala +++ b/src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala @@ -131,7 +131,8 @@ trait ScenarioSetup extends EphemBlockchainTestSetup { aghartaBlockNumber = 0, phoenixBlockNumber = 0, petersburgBlockNumber = 0, - ecip1098BlockNumber = 0 + ecip1098BlockNumber = 0, + treasuryAddress = Address(0) ) override lazy val stxLedger = new StxLedger(blockchain, blockchainConfig, consensus.blockPreparator)