Merge branch 'master' into auth-bft

This commit is contained in:
keorn
2016-11-25 10:51:06 +00:00
138 changed files with 5226 additions and 1070 deletions

View File

@@ -21,8 +21,8 @@
"genesis": {
"seal": {
"generic": {
"fields": 1,
"rlp": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"
"fields": 2,
"rlp": "0x200"
}
},
"difficulty": "0x20000",

View File

@@ -8,7 +8,7 @@
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d",
"registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
"homesteadTransition": 0,
"eip150Transition": 0,
"eip155Transition": 10,
@@ -47,258 +47,258 @@
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "0", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "0", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "0", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0000000000000000000000000000000000000000": { "balance": "1" },
"0000000000000000000000000000000000000005": { "balance": "1" },
"0000000000000000000000000000000000000006": { "balance": "1" },
"0000000000000000000000000000000000000007": { "balance": "1" },
"0000000000000000000000000000000000000008": { "balance": "1" },
"0000000000000000000000000000000000000009": { "balance": "1" },
"000000000000000000000000000000000000000a": { "balance": "0" },
"000000000000000000000000000000000000000b": { "balance": "0" },
"000000000000000000000000000000000000000c": { "balance": "0" },
"000000000000000000000000000000000000000d": { "balance": "0" },
"000000000000000000000000000000000000000e": { "balance": "0" },
"000000000000000000000000000000000000000f": { "balance": "0" },
"0000000000000000000000000000000000000010": { "balance": "0" },
"0000000000000000000000000000000000000011": { "balance": "0" },
"0000000000000000000000000000000000000012": { "balance": "0" },
"0000000000000000000000000000000000000013": { "balance": "0" },
"0000000000000000000000000000000000000014": { "balance": "0" },
"0000000000000000000000000000000000000015": { "balance": "0" },
"0000000000000000000000000000000000000016": { "balance": "0" },
"0000000000000000000000000000000000000017": { "balance": "0" },
"0000000000000000000000000000000000000018": { "balance": "0" },
"0000000000000000000000000000000000000019": { "balance": "0" },
"000000000000000000000000000000000000001a": { "balance": "0" },
"000000000000000000000000000000000000001b": { "balance": "0" },
"000000000000000000000000000000000000001c": { "balance": "0" },
"000000000000000000000000000000000000001d": { "balance": "0" },
"000000000000000000000000000000000000001e": { "balance": "0" },
"000000000000000000000000000000000000001f": { "balance": "0" },
"0000000000000000000000000000000000000020": { "balance": "0" },
"0000000000000000000000000000000000000021": { "balance": "0" },
"0000000000000000000000000000000000000022": { "balance": "0" },
"0000000000000000000000000000000000000023": { "balance": "0" },
"0000000000000000000000000000000000000024": { "balance": "0" },
"0000000000000000000000000000000000000025": { "balance": "0" },
"0000000000000000000000000000000000000026": { "balance": "0" },
"0000000000000000000000000000000000000027": { "balance": "0" },
"0000000000000000000000000000000000000028": { "balance": "0" },
"0000000000000000000000000000000000000029": { "balance": "0" },
"000000000000000000000000000000000000002a": { "balance": "0" },
"000000000000000000000000000000000000002b": { "balance": "0" },
"000000000000000000000000000000000000002c": { "balance": "0" },
"000000000000000000000000000000000000002d": { "balance": "0" },
"000000000000000000000000000000000000002e": { "balance": "0" },
"000000000000000000000000000000000000002f": { "balance": "0" },
"0000000000000000000000000000000000000030": { "balance": "0" },
"0000000000000000000000000000000000000031": { "balance": "0" },
"0000000000000000000000000000000000000032": { "balance": "0" },
"0000000000000000000000000000000000000033": { "balance": "0" },
"0000000000000000000000000000000000000034": { "balance": "0" },
"0000000000000000000000000000000000000035": { "balance": "0" },
"0000000000000000000000000000000000000036": { "balance": "0" },
"0000000000000000000000000000000000000037": { "balance": "0" },
"0000000000000000000000000000000000000038": { "balance": "0" },
"0000000000000000000000000000000000000039": { "balance": "0" },
"000000000000000000000000000000000000003a": { "balance": "0" },
"000000000000000000000000000000000000003b": { "balance": "0" },
"000000000000000000000000000000000000003c": { "balance": "0" },
"000000000000000000000000000000000000003d": { "balance": "0" },
"000000000000000000000000000000000000003e": { "balance": "0" },
"000000000000000000000000000000000000003f": { "balance": "0" },
"0000000000000000000000000000000000000040": { "balance": "0" },
"0000000000000000000000000000000000000041": { "balance": "0" },
"0000000000000000000000000000000000000042": { "balance": "0" },
"0000000000000000000000000000000000000043": { "balance": "0" },
"0000000000000000000000000000000000000044": { "balance": "0" },
"0000000000000000000000000000000000000045": { "balance": "0" },
"0000000000000000000000000000000000000046": { "balance": "0" },
"0000000000000000000000000000000000000047": { "balance": "0" },
"0000000000000000000000000000000000000048": { "balance": "0" },
"0000000000000000000000000000000000000049": { "balance": "0" },
"000000000000000000000000000000000000004a": { "balance": "0" },
"000000000000000000000000000000000000004b": { "balance": "0" },
"000000000000000000000000000000000000004c": { "balance": "0" },
"000000000000000000000000000000000000004d": { "balance": "0" },
"000000000000000000000000000000000000004e": { "balance": "0" },
"000000000000000000000000000000000000004f": { "balance": "0" },
"0000000000000000000000000000000000000050": { "balance": "0" },
"0000000000000000000000000000000000000051": { "balance": "0" },
"0000000000000000000000000000000000000052": { "balance": "0" },
"0000000000000000000000000000000000000053": { "balance": "0" },
"0000000000000000000000000000000000000054": { "balance": "0" },
"0000000000000000000000000000000000000055": { "balance": "0" },
"0000000000000000000000000000000000000056": { "balance": "0" },
"0000000000000000000000000000000000000057": { "balance": "0" },
"0000000000000000000000000000000000000058": { "balance": "0" },
"0000000000000000000000000000000000000059": { "balance": "0" },
"000000000000000000000000000000000000005a": { "balance": "0" },
"000000000000000000000000000000000000005b": { "balance": "0" },
"000000000000000000000000000000000000005c": { "balance": "0" },
"000000000000000000000000000000000000005d": { "balance": "0" },
"000000000000000000000000000000000000005e": { "balance": "0" },
"000000000000000000000000000000000000005f": { "balance": "0" },
"0000000000000000000000000000000000000060": { "balance": "0" },
"0000000000000000000000000000000000000061": { "balance": "0" },
"0000000000000000000000000000000000000062": { "balance": "0" },
"0000000000000000000000000000000000000063": { "balance": "0" },
"0000000000000000000000000000000000000064": { "balance": "0" },
"0000000000000000000000000000000000000065": { "balance": "0" },
"0000000000000000000000000000000000000066": { "balance": "0" },
"0000000000000000000000000000000000000067": { "balance": "0" },
"0000000000000000000000000000000000000068": { "balance": "0" },
"0000000000000000000000000000000000000069": { "balance": "0" },
"000000000000000000000000000000000000006a": { "balance": "0" },
"000000000000000000000000000000000000006b": { "balance": "0" },
"000000000000000000000000000000000000006c": { "balance": "0" },
"000000000000000000000000000000000000006d": { "balance": "0" },
"000000000000000000000000000000000000006e": { "balance": "0" },
"000000000000000000000000000000000000006f": { "balance": "0" },
"0000000000000000000000000000000000000070": { "balance": "0" },
"0000000000000000000000000000000000000071": { "balance": "0" },
"0000000000000000000000000000000000000072": { "balance": "0" },
"0000000000000000000000000000000000000073": { "balance": "0" },
"0000000000000000000000000000000000000074": { "balance": "0" },
"0000000000000000000000000000000000000075": { "balance": "0" },
"0000000000000000000000000000000000000076": { "balance": "0" },
"0000000000000000000000000000000000000077": { "balance": "0" },
"0000000000000000000000000000000000000078": { "balance": "0" },
"0000000000000000000000000000000000000079": { "balance": "0" },
"000000000000000000000000000000000000007a": { "balance": "0" },
"000000000000000000000000000000000000007b": { "balance": "0" },
"000000000000000000000000000000000000007c": { "balance": "0" },
"000000000000000000000000000000000000007d": { "balance": "0" },
"000000000000000000000000000000000000007e": { "balance": "0" },
"000000000000000000000000000000000000007f": { "balance": "0" },
"0000000000000000000000000000000000000080": { "balance": "0" },
"0000000000000000000000000000000000000081": { "balance": "0" },
"0000000000000000000000000000000000000082": { "balance": "0" },
"0000000000000000000000000000000000000083": { "balance": "0" },
"0000000000000000000000000000000000000084": { "balance": "0" },
"0000000000000000000000000000000000000085": { "balance": "0" },
"0000000000000000000000000000000000000086": { "balance": "0" },
"0000000000000000000000000000000000000087": { "balance": "0" },
"0000000000000000000000000000000000000088": { "balance": "0" },
"0000000000000000000000000000000000000089": { "balance": "0" },
"000000000000000000000000000000000000008a": { "balance": "0" },
"000000000000000000000000000000000000008b": { "balance": "0" },
"000000000000000000000000000000000000008c": { "balance": "0" },
"000000000000000000000000000000000000008d": { "balance": "0" },
"000000000000000000000000000000000000008e": { "balance": "0" },
"000000000000000000000000000000000000008f": { "balance": "0" },
"0000000000000000000000000000000000000090": { "balance": "0" },
"0000000000000000000000000000000000000091": { "balance": "0" },
"0000000000000000000000000000000000000092": { "balance": "0" },
"0000000000000000000000000000000000000093": { "balance": "0" },
"0000000000000000000000000000000000000094": { "balance": "0" },
"0000000000000000000000000000000000000095": { "balance": "0" },
"0000000000000000000000000000000000000096": { "balance": "0" },
"0000000000000000000000000000000000000097": { "balance": "0" },
"0000000000000000000000000000000000000098": { "balance": "0" },
"0000000000000000000000000000000000000099": { "balance": "0" },
"000000000000000000000000000000000000009a": { "balance": "0" },
"000000000000000000000000000000000000009b": { "balance": "0" },
"000000000000000000000000000000000000009c": { "balance": "0" },
"000000000000000000000000000000000000009d": { "balance": "0" },
"000000000000000000000000000000000000009e": { "balance": "0" },
"000000000000000000000000000000000000009f": { "balance": "0" },
"00000000000000000000000000000000000000a0": { "balance": "0" },
"00000000000000000000000000000000000000a1": { "balance": "0" },
"00000000000000000000000000000000000000a2": { "balance": "0" },
"00000000000000000000000000000000000000a3": { "balance": "0" },
"00000000000000000000000000000000000000a4": { "balance": "0" },
"00000000000000000000000000000000000000a5": { "balance": "0" },
"00000000000000000000000000000000000000a6": { "balance": "0" },
"00000000000000000000000000000000000000a7": { "balance": "0" },
"00000000000000000000000000000000000000a8": { "balance": "0" },
"00000000000000000000000000000000000000a9": { "balance": "0" },
"00000000000000000000000000000000000000aa": { "balance": "0" },
"00000000000000000000000000000000000000ab": { "balance": "0" },
"00000000000000000000000000000000000000ac": { "balance": "0" },
"00000000000000000000000000000000000000ad": { "balance": "0" },
"00000000000000000000000000000000000000ae": { "balance": "0" },
"00000000000000000000000000000000000000af": { "balance": "0" },
"00000000000000000000000000000000000000b0": { "balance": "0" },
"00000000000000000000000000000000000000b1": { "balance": "0" },
"00000000000000000000000000000000000000b2": { "balance": "0" },
"00000000000000000000000000000000000000b3": { "balance": "0" },
"00000000000000000000000000000000000000b4": { "balance": "0" },
"00000000000000000000000000000000000000b5": { "balance": "0" },
"00000000000000000000000000000000000000b6": { "balance": "0" },
"00000000000000000000000000000000000000b7": { "balance": "0" },
"00000000000000000000000000000000000000b8": { "balance": "0" },
"00000000000000000000000000000000000000b9": { "balance": "0" },
"00000000000000000000000000000000000000ba": { "balance": "0" },
"00000000000000000000000000000000000000bb": { "balance": "0" },
"00000000000000000000000000000000000000bc": { "balance": "0" },
"00000000000000000000000000000000000000bd": { "balance": "0" },
"00000000000000000000000000000000000000be": { "balance": "0" },
"00000000000000000000000000000000000000bf": { "balance": "0" },
"00000000000000000000000000000000000000c0": { "balance": "0" },
"00000000000000000000000000000000000000c1": { "balance": "0" },
"00000000000000000000000000000000000000c2": { "balance": "0" },
"00000000000000000000000000000000000000c3": { "balance": "0" },
"00000000000000000000000000000000000000c4": { "balance": "0" },
"00000000000000000000000000000000000000c5": { "balance": "0" },
"00000000000000000000000000000000000000c6": { "balance": "0" },
"00000000000000000000000000000000000000c7": { "balance": "0" },
"00000000000000000000000000000000000000c8": { "balance": "0" },
"00000000000000000000000000000000000000c9": { "balance": "0" },
"00000000000000000000000000000000000000ca": { "balance": "0" },
"00000000000000000000000000000000000000cb": { "balance": "0" },
"00000000000000000000000000000000000000cc": { "balance": "0" },
"00000000000000000000000000000000000000cd": { "balance": "0" },
"00000000000000000000000000000000000000ce": { "balance": "0" },
"00000000000000000000000000000000000000cf": { "balance": "0" },
"00000000000000000000000000000000000000d0": { "balance": "0" },
"00000000000000000000000000000000000000d1": { "balance": "0" },
"00000000000000000000000000000000000000d2": { "balance": "0" },
"00000000000000000000000000000000000000d3": { "balance": "0" },
"00000000000000000000000000000000000000d4": { "balance": "0" },
"00000000000000000000000000000000000000d5": { "balance": "0" },
"00000000000000000000000000000000000000d6": { "balance": "0" },
"00000000000000000000000000000000000000d7": { "balance": "0" },
"00000000000000000000000000000000000000d8": { "balance": "0" },
"00000000000000000000000000000000000000d9": { "balance": "0" },
"0000000000000000000000000000000000000000": { "balance": "1" },
"0000000000000000000000000000000000000005": { "balance": "1" },
"0000000000000000000000000000000000000006": { "balance": "1" },
"0000000000000000000000000000000000000007": { "balance": "1" },
"0000000000000000000000000000000000000008": { "balance": "1" },
"0000000000000000000000000000000000000009": { "balance": "1" },
"000000000000000000000000000000000000000a": { "balance": "0" },
"000000000000000000000000000000000000000b": { "balance": "0" },
"000000000000000000000000000000000000000c": { "balance": "0" },
"000000000000000000000000000000000000000d": { "balance": "0" },
"000000000000000000000000000000000000000e": { "balance": "0" },
"000000000000000000000000000000000000000f": { "balance": "0" },
"0000000000000000000000000000000000000010": { "balance": "0" },
"0000000000000000000000000000000000000011": { "balance": "0" },
"0000000000000000000000000000000000000012": { "balance": "0" },
"0000000000000000000000000000000000000013": { "balance": "0" },
"0000000000000000000000000000000000000014": { "balance": "0" },
"0000000000000000000000000000000000000015": { "balance": "0" },
"0000000000000000000000000000000000000016": { "balance": "0" },
"0000000000000000000000000000000000000017": { "balance": "0" },
"0000000000000000000000000000000000000018": { "balance": "0" },
"0000000000000000000000000000000000000019": { "balance": "0" },
"000000000000000000000000000000000000001a": { "balance": "0" },
"000000000000000000000000000000000000001b": { "balance": "0" },
"000000000000000000000000000000000000001c": { "balance": "0" },
"000000000000000000000000000000000000001d": { "balance": "0" },
"000000000000000000000000000000000000001e": { "balance": "0" },
"000000000000000000000000000000000000001f": { "balance": "0" },
"0000000000000000000000000000000000000020": { "balance": "0" },
"0000000000000000000000000000000000000021": { "balance": "0" },
"0000000000000000000000000000000000000022": { "balance": "0" },
"0000000000000000000000000000000000000023": { "balance": "0" },
"0000000000000000000000000000000000000024": { "balance": "0" },
"0000000000000000000000000000000000000025": { "balance": "0" },
"0000000000000000000000000000000000000026": { "balance": "0" },
"0000000000000000000000000000000000000027": { "balance": "0" },
"0000000000000000000000000000000000000028": { "balance": "0" },
"0000000000000000000000000000000000000029": { "balance": "0" },
"000000000000000000000000000000000000002a": { "balance": "0" },
"000000000000000000000000000000000000002b": { "balance": "0" },
"000000000000000000000000000000000000002c": { "balance": "0" },
"000000000000000000000000000000000000002d": { "balance": "0" },
"000000000000000000000000000000000000002e": { "balance": "0" },
"000000000000000000000000000000000000002f": { "balance": "0" },
"0000000000000000000000000000000000000030": { "balance": "0" },
"0000000000000000000000000000000000000031": { "balance": "0" },
"0000000000000000000000000000000000000032": { "balance": "0" },
"0000000000000000000000000000000000000033": { "balance": "0" },
"0000000000000000000000000000000000000034": { "balance": "0" },
"0000000000000000000000000000000000000035": { "balance": "0" },
"0000000000000000000000000000000000000036": { "balance": "0" },
"0000000000000000000000000000000000000037": { "balance": "0" },
"0000000000000000000000000000000000000038": { "balance": "0" },
"0000000000000000000000000000000000000039": { "balance": "0" },
"000000000000000000000000000000000000003a": { "balance": "0" },
"000000000000000000000000000000000000003b": { "balance": "0" },
"000000000000000000000000000000000000003c": { "balance": "0" },
"000000000000000000000000000000000000003d": { "balance": "0" },
"000000000000000000000000000000000000003e": { "balance": "0" },
"000000000000000000000000000000000000003f": { "balance": "0" },
"0000000000000000000000000000000000000040": { "balance": "0" },
"0000000000000000000000000000000000000041": { "balance": "0" },
"0000000000000000000000000000000000000042": { "balance": "0" },
"0000000000000000000000000000000000000043": { "balance": "0" },
"0000000000000000000000000000000000000044": { "balance": "0" },
"0000000000000000000000000000000000000045": { "balance": "0" },
"0000000000000000000000000000000000000046": { "balance": "0" },
"0000000000000000000000000000000000000047": { "balance": "0" },
"0000000000000000000000000000000000000048": { "balance": "0" },
"0000000000000000000000000000000000000049": { "balance": "0" },
"000000000000000000000000000000000000004a": { "balance": "0" },
"000000000000000000000000000000000000004b": { "balance": "0" },
"000000000000000000000000000000000000004c": { "balance": "0" },
"000000000000000000000000000000000000004d": { "balance": "0" },
"000000000000000000000000000000000000004e": { "balance": "0" },
"000000000000000000000000000000000000004f": { "balance": "0" },
"0000000000000000000000000000000000000050": { "balance": "0" },
"0000000000000000000000000000000000000051": { "balance": "0" },
"0000000000000000000000000000000000000052": { "balance": "0" },
"0000000000000000000000000000000000000053": { "balance": "0" },
"0000000000000000000000000000000000000054": { "balance": "0" },
"0000000000000000000000000000000000000055": { "balance": "0" },
"0000000000000000000000000000000000000056": { "balance": "0" },
"0000000000000000000000000000000000000057": { "balance": "0" },
"0000000000000000000000000000000000000058": { "balance": "0" },
"0000000000000000000000000000000000000059": { "balance": "0" },
"000000000000000000000000000000000000005a": { "balance": "0" },
"000000000000000000000000000000000000005b": { "balance": "0" },
"000000000000000000000000000000000000005c": { "balance": "0" },
"000000000000000000000000000000000000005d": { "balance": "0" },
"000000000000000000000000000000000000005e": { "balance": "0" },
"000000000000000000000000000000000000005f": { "balance": "0" },
"0000000000000000000000000000000000000060": { "balance": "0" },
"0000000000000000000000000000000000000061": { "balance": "0" },
"0000000000000000000000000000000000000062": { "balance": "0" },
"0000000000000000000000000000000000000063": { "balance": "0" },
"0000000000000000000000000000000000000064": { "balance": "0" },
"0000000000000000000000000000000000000065": { "balance": "0" },
"0000000000000000000000000000000000000066": { "balance": "0" },
"0000000000000000000000000000000000000067": { "balance": "0" },
"0000000000000000000000000000000000000068": { "balance": "0" },
"0000000000000000000000000000000000000069": { "balance": "0" },
"000000000000000000000000000000000000006a": { "balance": "0" },
"000000000000000000000000000000000000006b": { "balance": "0" },
"000000000000000000000000000000000000006c": { "balance": "0" },
"000000000000000000000000000000000000006d": { "balance": "0" },
"000000000000000000000000000000000000006e": { "balance": "0" },
"000000000000000000000000000000000000006f": { "balance": "0" },
"0000000000000000000000000000000000000070": { "balance": "0" },
"0000000000000000000000000000000000000071": { "balance": "0" },
"0000000000000000000000000000000000000072": { "balance": "0" },
"0000000000000000000000000000000000000073": { "balance": "0" },
"0000000000000000000000000000000000000074": { "balance": "0" },
"0000000000000000000000000000000000000075": { "balance": "0" },
"0000000000000000000000000000000000000076": { "balance": "0" },
"0000000000000000000000000000000000000077": { "balance": "0" },
"0000000000000000000000000000000000000078": { "balance": "0" },
"0000000000000000000000000000000000000079": { "balance": "0" },
"000000000000000000000000000000000000007a": { "balance": "0" },
"000000000000000000000000000000000000007b": { "balance": "0" },
"000000000000000000000000000000000000007c": { "balance": "0" },
"000000000000000000000000000000000000007d": { "balance": "0" },
"000000000000000000000000000000000000007e": { "balance": "0" },
"000000000000000000000000000000000000007f": { "balance": "0" },
"0000000000000000000000000000000000000080": { "balance": "0" },
"0000000000000000000000000000000000000081": { "balance": "0" },
"0000000000000000000000000000000000000082": { "balance": "0" },
"0000000000000000000000000000000000000083": { "balance": "0" },
"0000000000000000000000000000000000000084": { "balance": "0" },
"0000000000000000000000000000000000000085": { "balance": "0" },
"0000000000000000000000000000000000000086": { "balance": "0" },
"0000000000000000000000000000000000000087": { "balance": "0" },
"0000000000000000000000000000000000000088": { "balance": "0" },
"0000000000000000000000000000000000000089": { "balance": "0" },
"000000000000000000000000000000000000008a": { "balance": "0" },
"000000000000000000000000000000000000008b": { "balance": "0" },
"000000000000000000000000000000000000008c": { "balance": "0" },
"000000000000000000000000000000000000008d": { "balance": "0" },
"000000000000000000000000000000000000008e": { "balance": "0" },
"000000000000000000000000000000000000008f": { "balance": "0" },
"0000000000000000000000000000000000000090": { "balance": "0" },
"0000000000000000000000000000000000000091": { "balance": "0" },
"0000000000000000000000000000000000000092": { "balance": "0" },
"0000000000000000000000000000000000000093": { "balance": "0" },
"0000000000000000000000000000000000000094": { "balance": "0" },
"0000000000000000000000000000000000000095": { "balance": "0" },
"0000000000000000000000000000000000000096": { "balance": "0" },
"0000000000000000000000000000000000000097": { "balance": "0" },
"0000000000000000000000000000000000000098": { "balance": "0" },
"0000000000000000000000000000000000000099": { "balance": "0" },
"000000000000000000000000000000000000009a": { "balance": "0" },
"000000000000000000000000000000000000009b": { "balance": "0" },
"000000000000000000000000000000000000009c": { "balance": "0" },
"000000000000000000000000000000000000009d": { "balance": "0" },
"000000000000000000000000000000000000009e": { "balance": "0" },
"000000000000000000000000000000000000009f": { "balance": "0" },
"00000000000000000000000000000000000000a0": { "balance": "0" },
"00000000000000000000000000000000000000a1": { "balance": "0" },
"00000000000000000000000000000000000000a2": { "balance": "0" },
"00000000000000000000000000000000000000a3": { "balance": "0" },
"00000000000000000000000000000000000000a4": { "balance": "0" },
"00000000000000000000000000000000000000a5": { "balance": "0" },
"00000000000000000000000000000000000000a6": { "balance": "0" },
"00000000000000000000000000000000000000a7": { "balance": "0" },
"00000000000000000000000000000000000000a8": { "balance": "0" },
"00000000000000000000000000000000000000a9": { "balance": "0" },
"00000000000000000000000000000000000000aa": { "balance": "0" },
"00000000000000000000000000000000000000ab": { "balance": "0" },
"00000000000000000000000000000000000000ac": { "balance": "0" },
"00000000000000000000000000000000000000ad": { "balance": "0" },
"00000000000000000000000000000000000000ae": { "balance": "0" },
"00000000000000000000000000000000000000af": { "balance": "0" },
"00000000000000000000000000000000000000b0": { "balance": "0" },
"00000000000000000000000000000000000000b1": { "balance": "0" },
"00000000000000000000000000000000000000b2": { "balance": "0" },
"00000000000000000000000000000000000000b3": { "balance": "0" },
"00000000000000000000000000000000000000b4": { "balance": "0" },
"00000000000000000000000000000000000000b5": { "balance": "0" },
"00000000000000000000000000000000000000b6": { "balance": "0" },
"00000000000000000000000000000000000000b7": { "balance": "0" },
"00000000000000000000000000000000000000b8": { "balance": "0" },
"00000000000000000000000000000000000000b9": { "balance": "0" },
"00000000000000000000000000000000000000ba": { "balance": "0" },
"00000000000000000000000000000000000000bb": { "balance": "0" },
"00000000000000000000000000000000000000bc": { "balance": "0" },
"00000000000000000000000000000000000000bd": { "balance": "0" },
"00000000000000000000000000000000000000be": { "balance": "0" },
"00000000000000000000000000000000000000bf": { "balance": "0" },
"00000000000000000000000000000000000000c0": { "balance": "0" },
"00000000000000000000000000000000000000c1": { "balance": "0" },
"00000000000000000000000000000000000000c2": { "balance": "0" },
"00000000000000000000000000000000000000c3": { "balance": "0" },
"00000000000000000000000000000000000000c4": { "balance": "0" },
"00000000000000000000000000000000000000c5": { "balance": "0" },
"00000000000000000000000000000000000000c6": { "balance": "0" },
"00000000000000000000000000000000000000c7": { "balance": "0" },
"00000000000000000000000000000000000000c8": { "balance": "0" },
"00000000000000000000000000000000000000c9": { "balance": "0" },
"00000000000000000000000000000000000000ca": { "balance": "0" },
"00000000000000000000000000000000000000cb": { "balance": "0" },
"00000000000000000000000000000000000000cc": { "balance": "0" },
"00000000000000000000000000000000000000cd": { "balance": "0" },
"00000000000000000000000000000000000000ce": { "balance": "0" },
"00000000000000000000000000000000000000cf": { "balance": "0" },
"00000000000000000000000000000000000000d0": { "balance": "0" },
"00000000000000000000000000000000000000d1": { "balance": "0" },
"00000000000000000000000000000000000000d2": { "balance": "0" },
"00000000000000000000000000000000000000d3": { "balance": "0" },
"00000000000000000000000000000000000000d4": { "balance": "0" },
"00000000000000000000000000000000000000d5": { "balance": "0" },
"00000000000000000000000000000000000000d6": { "balance": "0" },
"00000000000000000000000000000000000000d7": { "balance": "0" },
"00000000000000000000000000000000000000d8": { "balance": "0" },
"00000000000000000000000000000000000000d9": { "balance": "0" },
"00000000000000000000000000000000000000da": { "balance": "0" },
"00000000000000000000000000000000000000db": { "balance": "0" },
"00000000000000000000000000000000000000dc": { "balance": "0" },
"00000000000000000000000000000000000000dd": { "balance": "0" },
"00000000000000000000000000000000000000de": { "balance": "0" },
"00000000000000000000000000000000000000df": { "balance": "0" },
"00000000000000000000000000000000000000e0": { "balance": "0" },
"00000000000000000000000000000000000000e1": { "balance": "0" },
"00000000000000000000000000000000000000e2": { "balance": "0" },
"00000000000000000000000000000000000000e3": { "balance": "0" },
"00000000000000000000000000000000000000e4": { "balance": "0" },
"00000000000000000000000000000000000000e5": { "balance": "0" },
"00000000000000000000000000000000000000e6": { "balance": "0" },
"00000000000000000000000000000000000000e7": { "balance": "0" },
"00000000000000000000000000000000000000e8": { "balance": "0" },
"00000000000000000000000000000000000000e9": { "balance": "0" },
"00000000000000000000000000000000000000ea": { "balance": "0" },
"00000000000000000000000000000000000000eb": { "balance": "0" },
"00000000000000000000000000000000000000ec": { "balance": "0" },
"00000000000000000000000000000000000000ed": { "balance": "0" },
"00000000000000000000000000000000000000ee": { "balance": "0" },
"00000000000000000000000000000000000000ef": { "balance": "0" },
"00000000000000000000000000000000000000f0": { "balance": "0" },
"00000000000000000000000000000000000000f1": { "balance": "0" },
"00000000000000000000000000000000000000f2": { "balance": "0" },
"00000000000000000000000000000000000000f3": { "balance": "0" },
"00000000000000000000000000000000000000f4": { "balance": "0" },
"00000000000000000000000000000000000000f5": { "balance": "0" },
"00000000000000000000000000000000000000f6": { "balance": "0" },
"00000000000000000000000000000000000000f7": { "balance": "0" },
"00000000000000000000000000000000000000f8": { "balance": "0" },
"00000000000000000000000000000000000000f9": { "balance": "0" },
"00000000000000000000000000000000000000fa": { "balance": "0" },
"00000000000000000000000000000000000000fb": { "balance": "0" },
"00000000000000000000000000000000000000fc": { "balance": "0" },
"00000000000000000000000000000000000000fd": { "balance": "0" },
"00000000000000000000000000000000000000fe": { "balance": "0" },
"00000000000000000000000000000000000000ff": { "balance": "0" },
"00000000000000000000000000000000000000db": { "balance": "0" },
"00000000000000000000000000000000000000dc": { "balance": "0" },
"00000000000000000000000000000000000000dd": { "balance": "0" },
"00000000000000000000000000000000000000de": { "balance": "0" },
"00000000000000000000000000000000000000df": { "balance": "0" },
"00000000000000000000000000000000000000e0": { "balance": "0" },
"00000000000000000000000000000000000000e1": { "balance": "0" },
"00000000000000000000000000000000000000e2": { "balance": "0" },
"00000000000000000000000000000000000000e3": { "balance": "0" },
"00000000000000000000000000000000000000e4": { "balance": "0" },
"00000000000000000000000000000000000000e5": { "balance": "0" },
"00000000000000000000000000000000000000e6": { "balance": "0" },
"00000000000000000000000000000000000000e7": { "balance": "0" },
"00000000000000000000000000000000000000e8": { "balance": "0" },
"00000000000000000000000000000000000000e9": { "balance": "0" },
"00000000000000000000000000000000000000ea": { "balance": "0" },
"00000000000000000000000000000000000000eb": { "balance": "0" },
"00000000000000000000000000000000000000ec": { "balance": "0" },
"00000000000000000000000000000000000000ed": { "balance": "0" },
"00000000000000000000000000000000000000ee": { "balance": "0" },
"00000000000000000000000000000000000000ef": { "balance": "0" },
"00000000000000000000000000000000000000f0": { "balance": "0" },
"00000000000000000000000000000000000000f1": { "balance": "0" },
"00000000000000000000000000000000000000f2": { "balance": "0" },
"00000000000000000000000000000000000000f3": { "balance": "0" },
"00000000000000000000000000000000000000f4": { "balance": "0" },
"00000000000000000000000000000000000000f5": { "balance": "0" },
"00000000000000000000000000000000000000f6": { "balance": "0" },
"00000000000000000000000000000000000000f7": { "balance": "0" },
"00000000000000000000000000000000000000f8": { "balance": "0" },
"00000000000000000000000000000000000000f9": { "balance": "0" },
"00000000000000000000000000000000000000fa": { "balance": "0" },
"00000000000000000000000000000000000000fb": { "balance": "0" },
"00000000000000000000000000000000000000fc": { "balance": "0" },
"00000000000000000000000000000000000000fd": { "balance": "0" },
"00000000000000000000000000000000000000fe": { "balance": "0" },
"00000000000000000000000000000000000000ff": { "balance": "0" },
"874b54a8bd152966d63f706bae1ffeb0411921e5": { "balance": "1000000000000000000000000000000" }
}
}

View File

@@ -11,9 +11,9 @@
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x00006d6f7264656e",
"mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578"
"generic": {
"fields": 0,
"rlp": "0x0"
}
},
"difficulty": "0x20000",

View File

@@ -276,14 +276,20 @@ impl AccountProvider {
}
/// Returns `true` if the password for `account` is `password`. `false` if not.
pub fn test_password(&self, account: &Address, password: String) -> Result<bool, Error> {
match self.sstore.sign(account, &password, &Default::default()) {
pub fn test_password(&self, account: &Address, password: &str) -> Result<bool, Error> {
match self.sstore.sign(account, password, &Default::default()) {
Ok(_) => Ok(true),
Err(SSError::InvalidPassword) => Ok(false),
Err(e) => Err(Error::SStore(e)),
}
}
/// Permanently removes an account.
pub fn kill_account(&self, account: &Address, password: &str) -> Result<(), Error> {
try!(self.sstore.remove_account(account, &password));
Ok(())
}
/// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given.
pub fn change_password(&self, account: &Address, password: String, new_password: String) -> Result<(), Error> {
self.sstore.change_password(account, &password, &new_password).map_err(Error::SStore)

View File

@@ -141,7 +141,7 @@ pub trait BlockProvider {
fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockNumber, to_block: BlockNumber) -> Vec<BlockNumber>;
/// Returns logs matching given filter.
fn logs<F>(&self, mut blocks: Vec<BlockNumber>, matches: F, limit: Option<usize>) -> Vec<LocalizedLogEntry>
fn logs<F>(&self, blocks: Vec<BlockNumber>, matches: F, limit: Option<usize>) -> Vec<LocalizedLogEntry>
where F: Fn(&LogEntry) -> bool, Self: Sized;
}

View File

@@ -256,8 +256,8 @@ impl Engine for AuthorityRound {
/// Check if the signature belongs to the correct proposer.
fn verify_block_unordered(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> {
let header_step = try!(header_step(header));
// Give one step slack if step is lagging, double vote is still not possible.
let header_step = try!(header_step(header));
// Give one step slack if step is lagging, double vote is still not possible.
if header_step <= self.step() + 1 {
let proposer_signature = try!(header_signature(header));
let ok_sig = try!(verify_address(self.step_proposer(header_step), &proposer_signature, &header.bare_hash()));
@@ -423,13 +423,13 @@ mod tests {
let engine = Spec::new_test_round().engine;
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
let mut step = UNIX_EPOCH.elapsed().unwrap().as_secs();
let time = UNIX_EPOCH.elapsed().unwrap().as_secs();
// Two authorities.
let mut step = time - time % 2;
header.set_seal(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]);
let first_ok = engine.verify_block_seal(&header).is_ok();
assert!(engine.verify_block_seal(&header).is_err());
step = step + 1;
header.set_seal(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]);
let second_ok = engine.verify_block_seal(&header).is_ok();
assert!(first_ok ^ second_ok);
assert!(engine.verify_block_seal(&header).is_ok());
}
}

View File

@@ -577,29 +577,29 @@ impl Miner {
let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into();
let best_block_header: Header = ::rlp::decode(&chain.best_block_header());
transactions.into_iter()
.filter(|tx| match self.engine.verify_transaction_basic(tx, &best_block_header) {
Ok(()) => true,
.map(|tx| {
match self.engine.verify_transaction_basic(&tx, &best_block_header) {
Err(e) => {
debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e);
false
}
}
)
.map(|tx| {
let origin = accounts.as_ref().and_then(|accounts| {
tx.sender().ok().and_then(|sender| match accounts.contains(&sender) {
true => Some(TransactionOrigin::Local),
false => None,
})
}).unwrap_or(default_origin);
match origin {
TransactionOrigin::Local | TransactionOrigin::RetractedBlock => {
transaction_queue.add(tx, origin, &fetch_account, &gas_required)
Err(e)
},
Ok(()) => {
let origin = accounts.as_ref().and_then(|accounts| {
tx.sender().ok().and_then(|sender| match accounts.contains(&sender) {
true => Some(TransactionOrigin::Local),
false => None,
})
}).unwrap_or(default_origin);
match origin {
TransactionOrigin::Local | TransactionOrigin::RetractedBlock => {
transaction_queue.add(tx, origin, &fetch_account, &gas_required)
},
TransactionOrigin::External => {
transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required)
}
}
},
TransactionOrigin::External => {
transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required)
}
}
})
.collect()

View File

@@ -128,6 +128,9 @@ impl<T> TraceDB<T> where T: DatabaseExtras {
/// Creates new instance of `TraceDB`.
pub fn new(config: Config, tracesdb: Arc<Database>, extras: Arc<T>) -> Self {
let mut batch = DBTransaction::new(&tracesdb);
let genesis = extras.block_hash(0)
.expect("Genesis block is always inserted upon extras db creation qed");
batch.write(db::COL_TRACE, &genesis, &FlatBlockTraces::default());
batch.put(db::COL_TRACE, b"version", TRACE_DB_VER);
tracesdb.write(batch).expect("failed to update version");
@@ -413,8 +416,12 @@ mod tests {
struct NoopExtras;
impl DatabaseExtras for NoopExtras {
fn block_hash(&self, _block_number: BlockNumber) -> Option<H256> {
unimplemented!();
fn block_hash(&self, block_number: BlockNumber) -> Option<H256> {
if block_number == 0 {
Some(H256::default())
} else {
unimplemented!()
}
}
fn transaction_hash(&self, _block_number: BlockNumber, _tx_position: usize) -> Option<H256> {
@@ -581,35 +588,21 @@ mod tests {
let db = Arc::new(Database::open(&DatabaseConfig::with_columns(::db::NUM_COLUMNS), temp.as_str()).unwrap());
let mut config = Config::default();
config.enabled = true;
let block_0 = H256::from(0xa1);
let block_1 = H256::from(0xa2);
let tx_0 = H256::from(0xff);
let tx_1 = H256::from(0xaf);
let block_1 = H256::from(0xa1);
let block_2 = H256::from(0xa2);
let tx_1 = H256::from(0xff);
let tx_2 = H256::from(0xaf);
let mut extras = Extras::default();
extras.block_hashes.insert(0, block_0.clone());
extras.block_hashes.insert(0, H256::default());
extras.block_hashes.insert(1, block_1.clone());
extras.transaction_hashes.insert(0, vec![tx_0.clone()]);
extras.block_hashes.insert(2, block_2.clone());
extras.transaction_hashes.insert(1, vec![tx_1.clone()]);
extras.transaction_hashes.insert(2, vec![tx_2.clone()]);
let tracedb = TraceDB::new(config, db.clone(), Arc::new(extras));
// import block 0
let request = create_simple_import_request(0, block_0.clone());
let mut batch = DBTransaction::new(&db);
tracedb.import(&mut batch, request);
db.write(batch).unwrap();
let filter = Filter {
range: (0..0),
from_address: AddressesFilter::from(vec![Address::from(1)]),
to_address: AddressesFilter::from(vec![]),
};
let traces = tracedb.filter(&filter);
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
// import block 1
let request = create_simple_import_request(1, block_1.clone());
let mut batch = DBTransaction::new(&db);
@@ -617,38 +610,56 @@ mod tests {
db.write(batch).unwrap();
let filter = Filter {
range: (0..1),
range: (1..1),
from_address: AddressesFilter::from(vec![Address::from(1)]),
to_address: AddressesFilter::from(vec![]),
};
let traces = tracedb.filter(&filter);
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
// import block 2
let request = create_simple_import_request(2, block_2.clone());
let mut batch = DBTransaction::new(&db);
tracedb.import(&mut batch, request);
db.write(batch).unwrap();
let filter = Filter {
range: (1..2),
from_address: AddressesFilter::from(vec![Address::from(1)]),
to_address: AddressesFilter::from(vec![]),
};
let traces = tracedb.filter(&filter);
assert_eq!(traces.len(), 2);
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
assert_eq!(traces[1], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
assert_eq!(traces[1], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
let traces = tracedb.block_traces(0).unwrap();
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
assert!(tracedb.block_traces(0).is_some(), "Genesis trace should be always present.");
let traces = tracedb.block_traces(1).unwrap();
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
assert_eq!(None, tracedb.block_traces(2));
let traces = tracedb.transaction_traces(0, 0).unwrap();
let traces = tracedb.block_traces(2).unwrap();
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
assert_eq!(None, tracedb.block_traces(3));
let traces = tracedb.transaction_traces(1, 0).unwrap();
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
assert_eq!(None, tracedb.transaction_traces(1, 1));
let traces = tracedb.transaction_traces(2, 0).unwrap();
assert_eq!(traces.len(), 1);
assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
assert_eq!(None, tracedb.transaction_traces(2, 1));
assert_eq!(tracedb.trace(0, 0, vec![]).unwrap(), create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
assert_eq!(tracedb.trace(2, 0, vec![]).unwrap(), create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
}
#[test]
@@ -660,8 +671,10 @@ mod tests {
let block_0 = H256::from(0xa1);
let tx_0 = H256::from(0xff);
extras.block_hashes.insert(0, block_0.clone());
extras.transaction_hashes.insert(0, vec![tx_0.clone()]);
extras.block_hashes.insert(0, H256::default());
extras.transaction_hashes.insert(0, vec![]);
extras.block_hashes.insert(1, block_0.clone());
extras.transaction_hashes.insert(1, vec![tx_0.clone()]);
// set tracing on
config.enabled = true;
@@ -669,8 +682,8 @@ mod tests {
{
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone()));
// import block 0
let request = create_simple_import_request(0, block_0.clone());
// import block 1
let request = create_simple_import_request(1, block_0.clone());
let mut batch = DBTransaction::new(&db);
tracedb.import(&mut batch, request);
db.write(batch).unwrap();
@@ -678,8 +691,28 @@ mod tests {
{
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras));
let traces = tracedb.transaction_traces(0, 0);
assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(0, block_0, tx_0)]);
let traces = tracedb.transaction_traces(1, 0);
assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(1, block_0, tx_0)]);
}
}
#[test]
fn query_genesis() {
let temp = RandomTempPath::new();
let db = new_db(temp.as_str());
let mut config = Config::default();
let mut extras = Extras::default();
let block_0 = H256::from(0xa1);
extras.block_hashes.insert(0, block_0.clone());
extras.transaction_hashes.insert(0, vec![]);
// set tracing on
config.enabled = true;
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone()));
let traces = tracedb.block_traces(0).unwrap();
assert_eq!(traces.len(), 0);
}
}

View File

@@ -119,7 +119,7 @@ impl Into<Vec<FlatTrace>> for FlatTransactionTraces {
}
/// Represents all traces produced by transactions in a single block.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Default)]
pub struct FlatBlockTraces(Vec<FlatTransactionTraces>);
impl HeapSizeOf for FlatBlockTraces {

View File

@@ -35,6 +35,9 @@ pub mod kind;
const MIN_MEM_LIMIT: usize = 16384;
const MIN_QUEUE_LIMIT: usize = 512;
// maximum possible number of verification threads.
const MAX_VERIFIERS: usize = 8;
/// Type alias for block queue convenience.
pub type BlockQueue = VerificationQueue<self::kind::Blocks>;
@@ -61,6 +64,37 @@ impl Default for Config {
}
}
struct VerifierHandle {
deleting: Arc<AtomicBool>,
sleep: Arc<AtomicBool>,
thread: JoinHandle<()>,
}
impl VerifierHandle {
// signal to the verifier thread that it should sleep.
fn sleep(&self) {
self.sleep.store(true, AtomicOrdering::SeqCst);
}
// signal to the verifier thread that it should wake up.
fn wake_up(&self) {
self.sleep.store(false, AtomicOrdering::SeqCst);
self.thread.thread().unpark();
}
// signal to the verifier thread that it should conclude its
// operations.
fn conclude(&self) {
self.wake_up();
self.deleting.store(true, AtomicOrdering::Release);
}
// join the verifier thread.
fn join(self) {
self.thread.join().expect("Verifier thread panicked");
}
}
/// An item which is in the process of being verified.
pub struct Verifying<K: Kind> {
hash: H256,
@@ -97,11 +131,12 @@ pub struct VerificationQueue<K: Kind> {
engine: Arc<Engine>,
more_to_verify: Arc<SCondvar>,
verification: Arc<Verification<K>>,
verifiers: Vec<JoinHandle<()>>,
verifiers: Mutex<(Vec<VerifierHandle>, usize)>,
deleting: Arc<AtomicBool>,
ready_signal: Arc<QueueSignal>,
empty: Arc<SCondvar>,
processing: RwLock<HashSet<H256>>,
ticks_since_adjustment: AtomicUsize,
max_queue_size: usize,
max_mem_use: usize,
}
@@ -157,6 +192,7 @@ struct Verification<K: Kind> {
more_to_verify: SMutex<()>,
empty: SMutex<()>,
sizes: Sizes,
check_seal: bool,
}
impl<K: Kind> VerificationQueue<K> {
@@ -173,7 +209,8 @@ impl<K: Kind> VerificationQueue<K> {
unverified: AtomicUsize::new(0),
verifying: AtomicUsize::new(0),
verified: AtomicUsize::new(0),
}
},
check_seal: check_seal,
});
let more_to_verify = Arc::new(SCondvar::new());
let deleting = Arc::new(AtomicBool::new(false));
@@ -185,44 +222,82 @@ impl<K: Kind> VerificationQueue<K> {
let empty = Arc::new(SCondvar::new());
let panic_handler = PanicHandler::new_in_arc();
let mut verifiers: Vec<JoinHandle<()>> = Vec::new();
let thread_count = max(::num_cpus::get(), 3) - 2;
for i in 0..thread_count {
let verification = verification.clone();
let engine = engine.clone();
let more_to_verify = more_to_verify.clone();
let ready_signal = ready_signal.clone();
let empty = empty.clone();
let max_verifiers = min(::num_cpus::get(), MAX_VERIFIERS);
let default_amount = max(::num_cpus::get(), 3) - 2;
let mut verifiers = Vec::with_capacity(max_verifiers);
debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, default_amount);
for i in 0..max_verifiers {
debug!(target: "verification", "Adding verification thread #{}", i);
let deleting = deleting.clone();
let panic_handler = panic_handler.clone();
verifiers.push(
thread::Builder::new()
.name(format!("Verifier #{}", i))
.spawn(move || {
panic_handler.catch_panic(move || {
VerificationQueue::verify(verification, engine, more_to_verify, ready_signal, deleting, empty, check_seal)
}).unwrap()
})
.expect("Error starting block verification thread")
);
let verification = verification.clone();
let engine = engine.clone();
let wait = more_to_verify.clone();
let ready = ready_signal.clone();
let empty = empty.clone();
// enable only the first few verifiers.
let sleep = if i < default_amount {
Arc::new(AtomicBool::new(false))
} else {
Arc::new(AtomicBool::new(true))
};
verifiers.push(VerifierHandle {
deleting: deleting.clone(),
sleep: sleep.clone(),
thread: thread::Builder::new()
.name(format!("Verifier #{}", i))
.spawn(move || {
panic_handler.catch_panic(move || {
VerificationQueue::verify(verification, engine, wait, ready, deleting, empty, sleep)
}).unwrap()
})
.expect("Failed to create verifier thread.")
});
}
VerificationQueue {
engine: engine,
panic_handler: panic_handler,
ready_signal: ready_signal.clone(),
more_to_verify: more_to_verify.clone(),
verification: verification.clone(),
verifiers: verifiers,
deleting: deleting.clone(),
ready_signal: ready_signal,
more_to_verify: more_to_verify,
verification: verification,
verifiers: Mutex::new((verifiers, default_amount)),
deleting: deleting,
processing: RwLock::new(HashSet::new()),
empty: empty.clone(),
empty: empty,
ticks_since_adjustment: AtomicUsize::new(0),
max_queue_size: max(config.max_queue_size, MIN_QUEUE_LIMIT),
max_mem_use: max(config.max_mem_use, MIN_MEM_LIMIT),
}
}
fn verify(verification: Arc<Verification<K>>, engine: Arc<Engine>, wait: Arc<SCondvar>, ready: Arc<QueueSignal>, deleting: Arc<AtomicBool>, empty: Arc<SCondvar>, check_seal: bool) {
fn verify(
verification: Arc<Verification<K>>,
engine: Arc<Engine>,
wait: Arc<SCondvar>,
ready: Arc<QueueSignal>,
deleting: Arc<AtomicBool>,
empty: Arc<SCondvar>,
sleep: Arc<AtomicBool>,
) {
while !deleting.load(AtomicOrdering::Acquire) {
{
while sleep.load(AtomicOrdering::SeqCst) {
trace!(target: "verification", "Verifier sleeping");
::std::thread::park();
trace!(target: "verification", "Verifier waking up");
if deleting.load(AtomicOrdering::Acquire) {
return;
}
}
}
{
let mut more_to_verify = verification.more_to_verify.lock().unwrap();
@@ -255,7 +330,7 @@ impl<K: Kind> VerificationQueue<K> {
};
let hash = item.hash();
let is_ready = match K::verify(item, &*engine, check_seal) {
let is_ready = match K::verify(item, &*engine, verification.check_seal) {
Ok(verified) => {
let mut verifying = verification.verifying.lock();
let mut idx = None;
@@ -302,9 +377,15 @@ impl<K: Kind> VerificationQueue<K> {
}
}
fn drain_verifying(verifying: &mut VecDeque<Verifying<K>>, verified: &mut VecDeque<K::Verified>, bad: &mut HashSet<H256>, sizes: &Sizes) {
fn drain_verifying(
verifying: &mut VecDeque<Verifying<K>>,
verified: &mut VecDeque<K::Verified>,
bad: &mut HashSet<H256>,
sizes: &Sizes,
) {
let mut removed_size = 0;
let mut inserted_size = 0;
while let Some(output) = verifying.front_mut().and_then(|x| x.output.take()) {
assert!(verifying.pop_front().is_some());
let size = output.heap_size_of_children();
@@ -487,14 +568,85 @@ impl<K: Kind> VerificationQueue<K> {
}
}
/// Optimise memory footprint of the heap fields.
/// Optimise memory footprint of the heap fields, and adjust the number of threads
/// to better suit the workload.
pub fn collect_garbage(&self) {
{
self.verification.unverified.lock().shrink_to_fit();
// number of ticks to average queue stats over
// when deciding whether to change the number of verifiers.
#[cfg(not(test))]
const READJUSTMENT_PERIOD: usize = 12;
#[cfg(test)]
const READJUSTMENT_PERIOD: usize = 1;
let (u_len, v_len) = {
let u_len = {
let mut q = self.verification.unverified.lock();
q.shrink_to_fit();
q.len()
};
self.verification.verifying.lock().shrink_to_fit();
self.verification.verified.lock().shrink_to_fit();
}
let v_len = {
let mut q = self.verification.verified.lock();
q.shrink_to_fit();
q.len()
};
(u_len as isize, v_len as isize)
};
self.processing.write().shrink_to_fit();
if self.ticks_since_adjustment.fetch_add(1, AtomicOrdering::SeqCst) + 1 >= READJUSTMENT_PERIOD {
self.ticks_since_adjustment.store(0, AtomicOrdering::SeqCst);
} else {
return;
}
let current = self.verifiers.lock().1;
let diff = (v_len - u_len).abs();
let total = v_len + u_len;
self.scale_verifiers(
if u_len < 20 {
1
} else if diff <= total / 10 {
current
} else if v_len > u_len {
current - 1
} else {
current + 1
}
);
}
// wake up or sleep verifiers to get as close to the target as
// possible, never going over the amount of initially allocated threads
// or below 1.
fn scale_verifiers(&self, target: usize) {
let mut verifiers = self.verifiers.lock();
let &mut (ref mut verifiers, ref mut verifier_count) = &mut *verifiers;
let target = min(verifiers.len(), target);
let target = max(1, target);
debug!(target: "verification", "Scaling from {} to {} verifiers", verifier_count, target);
// scaling up
for i in *verifier_count..target {
debug!(target: "verification", "Waking up verifier {}", i);
verifiers[i].wake_up();
}
// scaling down.
for i in target..*verifier_count {
debug!(target: "verification", "Putting verifier {} to sleep", i);
verifiers[i].sleep();
}
*verifier_count = target;
}
}
@@ -509,10 +661,23 @@ impl<K: Kind> Drop for VerificationQueue<K> {
trace!(target: "shutdown", "[VerificationQueue] Closing...");
self.clear();
self.deleting.store(true, AtomicOrdering::Release);
self.more_to_verify.notify_all();
for t in self.verifiers.drain(..) {
t.join().unwrap();
let mut verifiers = self.verifiers.get_mut();
let mut verifiers = &mut verifiers.0;
// first pass to signal conclusion. must be done before
// notify or deadlock possible.
for handle in verifiers.iter() {
handle.conclude();
}
self.more_to_verify.notify_all();
// second pass to join.
for handle in verifiers.drain(..) {
handle.join();
}
trace!(target: "shutdown", "[VerificationQueue] Closed.");
}
}
@@ -611,4 +776,56 @@ mod tests {
}
assert!(queue.queue_info().is_full());
}
#[test]
fn scaling_limits() {
use super::MAX_VERIFIERS;
let queue = get_test_queue();
queue.scale_verifiers(MAX_VERIFIERS + 1);
assert!(queue.verifiers.lock().1 < MAX_VERIFIERS + 1);
queue.scale_verifiers(0);
assert!(queue.verifiers.lock().1 == 1);
}
#[test]
fn readjust_verifiers() {
let queue = get_test_queue();
// put all the verifiers to sleep to ensure
// the test isn't timing sensitive.
let num_verifiers = {
let verifiers = queue.verifiers.lock();
for i in 0..verifiers.1 {
verifiers.0[i].sleep();
}
verifiers.1
};
for block in get_good_dummy_block_seq(5000) {
queue.import(Unverified::new(block)).expect("Block good by definition; qed");
}
// almost all unverified == bump verifier count.
queue.collect_garbage();
assert_eq!(queue.verifiers.lock().1, num_verifiers + 1);
// wake them up again and verify everything.
{
let verifiers = queue.verifiers.lock();
for i in 0..verifiers.1 {
verifiers.0[i].wake_up();
}
}
queue.flush();
// nothing to verify == use minimum number of verifiers.
queue.collect_garbage();
assert_eq!(queue.verifiers.lock().1, 1);
}
}