diff --git a/Cargo.lock b/Cargo.lock index 60565f17585..b2a112acbae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,6 +451,20 @@ dependencies = [ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ethabi" +version = "5.1.1" +source = "git+https://github.com/paritytech/ethabi?branch=casper#6ec7a3eb5e0c12dd24bbba037e1c885e47d7fd33" +dependencies = [ + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ethabi" version = "5.1.1" @@ -465,11 +479,27 @@ dependencies = [ "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ethabi-contract" +version = "5.1.0" +source = "git+https://github.com/paritytech/ethabi?branch=casper#6ec7a3eb5e0c12dd24bbba037e1c885e47d7fd33" + [[package]] name = "ethabi-contract" version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ethabi-derive" +version = "5.1.2" +source = "git+https://github.com/paritytech/ethabi?branch=casper#6ec7a3eb5e0c12dd24bbba037e1c885e47d7fd33" +dependencies = [ + "ethabi 5.1.1 (git+https://github.com/paritytech/ethabi?branch=casper)", + "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ethabi-derive" version = "5.1.2" @@ -518,9 +548,9 @@ dependencies = [ "common-types 0.1.0", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 5.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi-contract 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi-derive 5.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 5.1.1 (git+https://github.com/paritytech/ethabi?branch=casper)", + "ethabi-contract 5.1.0 (git+https://github.com/paritytech/ethabi?branch=casper)", + "ethabi-derive 5.1.2 (git+https://github.com/paritytech/ethabi?branch=casper)", "ethash 1.12.0", "ethcore-bloom-journal 0.1.0", "ethcore-bytes 0.1.0", @@ -2666,7 +2696,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3824,8 +3854,11 @@ dependencies = [ "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" +"checksum ethabi 5.1.1 (git+https://github.com/paritytech/ethabi?branch=casper)" = "" "checksum ethabi 5.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05e33a914b94b763f0a92333e4e5c95c095563f06ef7d6b295b3d3c2cf31e21f" +"checksum ethabi-contract 5.1.0 (git+https://github.com/paritytech/ethabi?branch=casper)" = "" "checksum ethabi-contract 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "210c9e21d164c15b6ef64fe601e0e12a3c84a031d5ef558e38463e53edbd22ed" +"checksum ethabi-derive 5.1.2 (git+https://github.com/paritytech/ethabi?branch=casper)" = "" "checksum ethabi-derive 5.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2bc7099baa147187aedaecd9fe04a6c0541c82bc43ff317cb6900fe2b983d74" "checksum ethbloom 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a93a43ce2e9f09071449da36bfa7a1b20b950ee344b6904ff23de493b03b386" "checksum ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c48729b8aea8aedb12cf4cb2e5cef439fdfe2dda4a89e47eeebd15778ef53b6" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 2b6ab9ebc3a..031f3dc0ec7 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -29,9 +29,9 @@ ethcore-stratum = { path = "./stratum" } ethcore-transaction = { path = "./transaction" } ethereum-types = "0.3" memory-cache = { path = "../util/memory_cache" } -ethabi = "5.1" -ethabi-derive = "5.0" -ethabi-contract = "5.0" +ethabi = { git = "https://github.com/paritytech/ethabi", branch = "casper" } +ethabi-derive = { git = "https://github.com/paritytech/ethabi", branch = "casper" } +ethabi-contract = { git = "https://github.com/paritytech/ethabi", branch = "casper" } ethjson = { path = "../json" } ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } diff --git a/ethcore/res/code/blockhash.hex b/ethcore/res/code/blockhash.hex new file mode 100644 index 00000000000..a6e35ce460c --- /dev/null +++ b/ethcore/res/code/blockhash.hex @@ -0,0 +1 @@ +"73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b" diff --git a/ethcore/res/code/msg_hasher.hex b/ethcore/res/code/msg_hasher.hex new file mode 100644 index 00000000000..c4f62229c51 --- /dev/null +++ b/ethcore/res/code/msg_hasher.hex @@ -0,0 +1 @@ +"60007f01000000000000000000000000000000000000000000000000000000000000006000350460f8811215610038576001915061003f565b60f6810391505b508060005b368312156100c8577f01000000000000000000000000000000000000000000000000000000000000008335048391506080811215610087576001840193506100c2565b60b881121561009d57607f8103840193506100c1565b60c08112156100c05760b68103600185013560b783036020035260005101840193505b5b5b50610044565b81810360388112156100f4578060c00160005380836001378060010160002060e052602060e0f3610143565b61010081121561010557600161011b565b6201000081121561011757600261011a565b60035b5b8160005280601f038160f701815382856020378282600101018120610140526020610140f350505b50505050" diff --git a/ethcore/res/code/purity_checker.hex b/ethcore/res/code/purity_checker.hex new file mode 100644 index 00000000000..a7cae7dbe37 --- /dev/null +++ b/ethcore/res/code/purity_checker.hex @@ -0,0 +1 @@ +"600061033f537c0100000000000000000000000000000000000000000000000000000000600035047f80010000000000000000000000000000000000000030ffff1c0e00000000000060205263a1903eab8114156103f7573659905901600090523660048237600435608052506080513b806020015990590160009052818152602081019050905060a0526080513b600060a0516080513c6080513b8060200260200159905901600090528181526020810190509050610100526080513b806020026020015990590160009052818152602081019050905061016052600060005b602060a05103518212156103c957610100601f8360a051010351066020518160020a161561010a57fe5b80606013151561011e57607f811315610121565b60005b1561014f5780607f036101000a60018460a0510101510482602002610160510152605e8103830192506103b2565b60f18114801561015f5780610164565b60f282145b905080156101725780610177565b60f482145b9050156103aa5760028212151561019e5760606001830360200261010051015112156101a1565b60005b156101bc57607f6001830360200261010051015113156101bf565b60005b156101d157600282036102605261031e565b6004821215156101f057600360018303602002610100510151146101f3565b60005b1561020d57605a6002830360200261010051015114610210565b60005b1561022b57606060038303602002610100510151121561022e565b60005b1561024957607f60038303602002610100510151131561024c565b60005b1561025e57600482036102605261031d565b60028212151561027d57605a6001830360200261010051015114610280565b60005b1561029257600282036102605261031c565b6002821215156102b157609060018303602002610100510151146102b4565b60005b156102c657600282036102605261031b565b6002821215156102e65760806001830360200261010051015112156102e9565b60005b156103035760906001830360200261010051015112610306565b60005b1561031857600282036102605261031a565bfe5b5b5b5b5b604060405990590160009052600081526102605160200261016051015181602001528090502054156103555760016102a052610393565b60306102605160200261010051015114156103755760016102a052610392565b60606102605160200261010051015114156103915760016102a0525b5b5b6102a051151561039f57fe5b6001830192506103b1565b6001830192505b5b8082602002610100510152600182019150506100e0565b50506001604060405990590160009052600081526080518160200152809050205560016102e05260206102e0f35b63c23697a8811415610440573659905901600090523660048237600435608052506040604059905901600090526000815260805181602001528090502054610300526020610300f35b50" diff --git a/ethcore/res/code/rlp_decoder.hex b/ethcore/res/code/rlp_decoder.hex new file mode 100644 index 00000000000..969404f3af2 --- /dev/null +++ b/ethcore/res/code/rlp_decoder.hex @@ -0,0 +1 @@ +"60006109ac5260006109cc527f0100000000000000000000000000000000000000000000000000000000000000600035046109ec526000610a0c5260006109005260c06109ec51101515585760f86109ec51101561006e5760bf6109ec510336141558576001610a0c52610098565b60013560f76109ec51036020035260005160f66109ec510301361415585760f66109ec5103610a0c525b61022060016064818352015b36610a0c511015156100b557610291565b7f0100000000000000000000000000000000000000000000000000000000000000610a0c5135046109ec526109cc5160206109ac51026040015260016109ac51016109ac5260806109ec51101561013b5760016109cc5161044001526001610a0c516109cc5161046001376001610a0c5101610a0c5260216109cc51016109cc52610281565b60b86109ec5110156101d15760806109ec51036109cc51610440015260806109ec51036001610a0c51016109cc51610460013760816109ec5114156101ac5760807f01000000000000000000000000000000000000000000000000000000000000006001610a0c5101350410151558575b607f6109ec5103610a0c5101610a0c5260606109ec51036109cc51016109cc52610280565b60c06109ec51101561027d576001610a0c51013560b76109ec510360200352600051610a2c526038610a2c5110157f01000000000000000000000000000000000000000000000000000000000000006001610a0c5101350402155857610a2c516109cc516104400152610a2c5160b66109ec5103610a0c51016109cc516104600137610a2c5160b66109ec5103610a0c510101610a0c526020610a2c51016109cc51016109cc5261027f565bfe5b5b5b81516001018083528114156100a4575b5050601f6109ac511115155857602060206109ac5102016109005260206109005103610a0c5261022060016064818352015b6000610a0c5112156102d45761030a565b61090051610a0c516040015101610a0c51610900516104400301526020610a0c5103610a0c5281516001018083528114156102c3575b50506109cc516109005101610420526109cc5161090051016109005161044003f3" diff --git a/ethcore/res/code/simple_casper.hex b/ethcore/res/code/simple_casper.hex new file mode 100644 index 00000000000..438a76a3a3b --- /dev/null +++ b/ethcore/res/code/simple_casper.hex @@ -0,0 +1 @@ +"600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526358c4540b60005114156103fa5761012060046101403734156100b557600080fd5b606051600435806040519013156100cb57600080fd5b80919012156100d957600080fd5b50606051602435806040519013156100f057600080fd5b80919012156100fe57600080fd5b506060516044358060405190131561011557600080fd5b809190121561012357600080fd5b506060516064358060405190131561013a57600080fd5b809190121561014857600080fd5b50608435602051811061015a57600080fd5b5060a435602051811061016c57600080fd5b50606051610104358060405190131561018457600080fd5b809190121561019257600080fd5b50601554156101a057600080fd5b610100610140511260006101405113166101b957600080fd5b60006101605112156101ca57600080fd5b60006101805112156101db57600080fd5b60026101a05112156101ec57600080fd5b60006102005112156101fd57600080fd5b600061022051121561020e57600080fd5b6000610240511361021e57600080fd5b60016015556101405160165561016051601755610180516018556101a05160195561020051601c5561022051601d5561024051601e55600060a0516016548061026657600080fd5b6402540be4006060516101605143018060405190131561028557600080fd5b809190121561029357600080fd5b0205806080519013156102a557600080fd5b80919012156102b357600080fd5b1215610329576402540be4006402540be3ff60a051601654806102d557600080fd5b6402540be400606051610160514301806040519013156102f457600080fd5b809190121561030257600080fd5b02058060805190131561031457600080fd5b809190121561032257600080fd5b030561038e565b6402540be40060a0516016548061033f57600080fd5b6402540be4006060516101605143018060405190131561035e57600080fd5b809190121561036c57600080fd5b02058060805190131561037e57600080fd5b809190121561038c57600080fd5b055b601f556101c051601a556101e051601b5560016002556000600455601f54600f5568056bc75e2d63100000600c60c052600f5460e052604060c02055600060065560006007556c0c9f2c9cd04674edea4000000060205562030d4060215562030d406022556003602355005b639a8eec77600051141561045157341561041357600080fd5b30331461041f57600080fd5b606051601054600f54038060405190131561043957600080fd5b809190121561044757600080fd5b60005260206000f3005b63db23eee060005114156107f757341561046a57600080fd5b30331461047657600080fd5b600f54610140526060516001600060a051670de0b6b3a764000060a051600c60c05260605160016101405103806040519013156104b257600080fd5b80919012156104c057600080fd5b60e052604060c02054600754600654808212156104dd57806104df565b815b9050905081810281158383830514176104f757600080fd5b6402540be40081059050905090508060805190131561051557600080fd5b809190121561052357600080fd5b058060805190131561053457600080fd5b809190121561054257600080fd5b1215610619576402540be4006402540be3ff60a051670de0b6b3a764000060a051600c60c052606051600161014051038060405190131561058257600080fd5b809190121561059057600080fd5b60e052604060c02054600754600654808212156105ad57806105af565b815b9050905081810281158383830514176105c757600080fd5b6402540be4008105905090509050806080519013156105e557600080fd5b80919012156105f357600080fd5b058060805190131561060457600080fd5b809190121561061257600080fd5b03056106df565b6402540be40060a051670de0b6b3a764000060a051600c60c052606051600161014051038060405190131561064d57600080fd5b809190121561065b57600080fd5b60e052604060c0205460075460065480821215610678578061067a565b815b90509050818102811583838305141761069257600080fd5b6402540be4008105905090509050806080519013156106b057600080fd5b80919012156106be57600080fd5b05806080519013156106cf57600080fd5b80919012156106dd57600080fd5b055b01806040519013156106f057600080fd5b80919012156106fe57600080fd5b6101605260a0516404a817c80068056bc75e2d631000006101605102058060805190131561072b57600080fd5b809190121561073957600080fd5b610180526101a060006014818352015b60a051600260a05160a051610180518061076257600080fd5b68056bc75e2d631000006101605102058060805190131561078257600080fd5b809190121561079057600080fd5b6101805101806080519013156107a557600080fd5b80919012156107b357600080fd5b05806080519013156107c457600080fd5b80919012156107d257600080fd5b610180525b8151600101808352811415610749575b50506101805160005260206000f3005b63de7f9975600051141561083357341561081057600080fd5b30331461081c57600080fd5b6000600754136000600654131660005260206000f3005b63d286bb82600051141561097657341561084c57600080fd5b30331461085857600080fd5b600f54610140526002600a60c052606051600261014051038060405190131561088057600080fd5b809190121561088e57600080fd5b60e052604060c02060c052602060c0200154156109265760046060516001825401806040519013156108bf57600080fd5b80919012156108cd57600080fd5b815550600654600755600660a051600560c05260045460e052604060c02054825401806080519013156108ff57600080fd5b809190121561090d57600080fd5b81555061014051600860c05260045460e052604060c020555b600454600960c0526101405160e052604060c02055600b541561096f57606051600161014051038060405190131561095d57600080fd5b809190121561096b57600080fd5b6013555b6000600b55005b636526ed726000511415610b1657341561098f57600080fd5b30331461099b57600080fd5b600f54610140526001600b5560016003600a60c05260605160016101405103806040519013156109ca57600080fd5b80919012156109d857600080fd5b60e052604060c02060c052602060c020015560016002600a60c0526060516001610140510380604051901315610a0d57600080fd5b8091901215610a1b57600080fd5b60e052604060c02060c052602060c02001556060516001610140510380604051901315610a4757600080fd5b8091901215610a5557600080fd5b6011556060516001610140510380604051901315610a7257600080fd5b8091901215610a8057600080fd5b601055600161016052600161018052600160c0526060516001610140510380604051901315610aae57600080fd5b8091901215610abc57600080fd5b60e052604060c020546060516001610140510380604051901315610adf57600080fd5b8091901215610aed57600080fd5b7f6940a3069a76fdb79d757f4dca548d7930f85e4bce3a3e2d06f5562bda0b10b96040610160a3005b63acc619c36000511415610d61573415610b2f57600080fd5b303314610b3b57600080fd5b600f5461014052600260206101e06004639a8eec776101805261019c6000305af1610b6557600080fd5b6101e05113156101605261016051156020610260600463de7f99756102005261021c6000305af1610b9557600080fd5b61026051151715610bab57600060005260206000f35b60a0516001600a60c0526060516001610140510380604051901315610bcf57600080fd5b8091901215610bdd57600080fd5b60e052604060c02060c052602060c0200160c05260135460e052604060c0205460065480610c0a57600080fd5b806402540be4008302059050905080608051901315610c2857600080fd5b8091901215610c3657600080fd5b6102805260a0516005600a60c0526060516001610140510380604051901315610c5e57600080fd5b8091901215610c6c57600080fd5b60e052604060c02060c052602060c0200160c05260135460e052604060c0205460075480610c9957600080fd5b806402540be4008302059050905080608051901315610cb757600080fd5b8091901215610cc557600080fd5b6102a052610280516102a05180821315610cdf5780610ce1565b815b905090506102c05260a051600260a0516012546102c0518181028115838383051417610d0c57600080fd5b6402540be400810590509050905080608051901315610d2a57600080fd5b8091901215610d3857600080fd5b0580608051901315610d4957600080fd5b8091901215610d5757600080fd5b60005260206000f3005b63579f38b260005114156111215760406004610140373415610d8257600080fd5b303314610d8e57600080fd5b60605160043580604051901315610da457600080fd5b8091901215610db257600080fd5b5060605160243580604051901315610dc957600080fd5b8091901215610dd757600080fd5b506001600060c0526101405160e052604060c02060c052602060c0200160a0516402540be400610160510282540180608051901315610e1557600080fd5b8091901215610e2357600080fd5b8155506004600060c0526101405160e052604060c02060c052602060c0200154610180526002600060c0526101405160e052604060c02060c052602060c02001546101a0526004546101c05260605160016101c0510380604051901315610e8957600080fd5b8091901215610e9757600080fd5b6101e0526101a0516101c051126101c0516101805113151615610ee957600660a0516402540be400610160510282540180608051901315610ed757600080fd5b8091901215610ee557600080fd5b8155505b6101a0516101e051126101e0516101805113151615610f3757600760a0516402540be400610160510282540180608051901315610f2557600080fd5b8091901215610f3357600080fd5b8155505b6020546101a0511215610f8857600560c0526101a05160e052604060c02060a0516402540be400610160510282540380608051901315610f7657600080fd5b8091901215610f8457600080fd5b8155505b6000600060006000600060a051600860a051600c60c052600f5460e052604060c02054610160518181028115838383051417610fc357600080fd5b8090509050905080608051901315610fda57600080fd5b8091901215610fe857600080fd5b0580608051901315610ff957600080fd5b809190121561100757600080fd5b1215611095576402540be4006402540be3ff60a051600860a051600c60c052600f5460e052604060c0205461016051818102811583838305141761104a57600080fd5b809050905090508060805190131561106157600080fd5b809190121561106f57600080fd5b058060805190131561108057600080fd5b809190121561108e57600080fd5b0305611112565b6402540be40060a051600860a051600c60c052600f5460e052604060c020546101605181810281158383830514176110cc57600080fd5b80905090509050806080519013156110e357600080fd5b80919012156110f157600080fd5b058060805190131561110257600080fd5b809190121561111057600080fd5b055b416000f161111f57600080fd5b005b6301b7af1860005114156111ea576020600461014037341561114257600080fd5b30331461114e57600080fd5b6060516004358060405190131561116457600080fd5b809190121561117257600080fd5b506000600360c0526006600060c0526101405160e052604060c02060c052602060c020015460e052604060c02055600060c0526101405160e052604060c02060c052602060c0206000815560006001820155600060028201556000600382015560006004820155600060058201556000600682015550005b63a2767400600051141561132f576060600461014037341561120b57600080fd5b30331461121757600080fd5b6104206024356004016101a03761040060243560040135111561123957600080fd5b6060516044358060405190131561124f57600080fd5b809190121561125d57600080fd5b5060016000610140516020826105e00101526020810190506101a0610400806020846105e001018260208501600060046078f1505080518201915050806105e0526105e09050805160200180610a40828460006004600a8704601201f16112c357600080fd5b50506020610ec0610a4051610a606000600060c0526101805160e052604060c02060c052602060c02054602254f16112fa57600080fd5b6020610ea052610ea060206000602083510381131561131857600080fd5b0460200260200181015190501460005260206000f3005b6337df0ba8600051141561143257341561134857600080fd5b60a0516001600a60c052600f5460e052604060c02060c052602060c0200160c05260135460e052604060c020546006548061138257600080fd5b806402540be40083020590509050806080519013156113a057600080fd5b80919012156113ae57600080fd5b60a0516005600a60c052600f5460e052604060c02060c052602060c0200160c05260135460e052604060c02054600754806113e857600080fd5b806402540be400830205905090508060805190131561140657600080fd5b809190121561141457600080fd5b808213156114225780611424565b815b9050905060005260206000f3005b6399fb5eec60005114156115f8576020600461014037341561145357600080fd5b6060516004358060405190131561146957600080fd5b809190121561147757600080fd5b50600060a051600c60c052600f5460e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176114bf57600080fd5b6402540be4008105905090509050806080519013156114dd57600080fd5b80919012156114eb57600080fd5b1215611575576402540be4006402540be3ff60a051600c60c052600f5460e052604060c020546001600060c0526101405160e052604060c02060c052602060c0200154818102811583838305141761154257600080fd5b6402540be40081059050905090508060805190131561156057600080fd5b809190121561156e57600080fd5b03056115ee565b6402540be40060a051600c60c052600f5460e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176115c057600080fd5b6402540be4008105905090509050806080519013156115de57600080fd5b80919012156115ec57600080fd5b055b60005260206000f3005b634a8fd698600051141561174357341561161157600080fd5b600060a051600c60c052600f5460e052604060c02054600654818102811583838305141761163e57600080fd5b6402540be40081059050905090508060805190131561165c57600080fd5b809190121561166a57600080fd5b12156116da576402540be4006402540be3ff60a051600c60c052600f5460e052604060c0205460065481810281158383830514176116a757600080fd5b6402540be4008105905090509050806080519013156116c557600080fd5b80919012156116d357600080fd5b0305611739565b6402540be40060a051600c60c052600f5460e052604060c02054600654818102811583838305141761170b57600080fd5b6402540be40081059050905090508060805190131561172957600080fd5b809190121561173757600080fd5b055b60005260206000f3005b637db2eedc600051141561188e57341561175c57600080fd5b600060a051600c60c052600f5460e052604060c02054600754818102811583838305141761178957600080fd5b6402540be4008105905090509050806080519013156117a757600080fd5b80919012156117b557600080fd5b1215611825576402540be4006402540be3ff60a051600c60c052600f5460e052604060c0205460075481810281158383830514176117f257600080fd5b6402540be40081059050905090508060805190131561181057600080fd5b809190121561181e57600080fd5b0305611884565b6402540be40060a051600c60c052600f5460e052604060c02054600754818102811583838305141761185657600080fd5b6402540be40081059050905090508060805190131561187457600080fd5b809190121561188257600080fd5b055b60005260206000f3005b6313d21fa36000511415611f6c57604060046101403734156118af57600080fd5b610420600435600401610180376104006004356004013511156118d157600080fd5b6104206024356004016105c0376104006024356004013511156118f357600080fd5b610180805160200180610a20828460006004600a8704601201f161191657600080fd5b50506020610e80610a2051610a406000601a54602154f161193657600080fd5b6020610e6052610e6060206000602083510381131561195457600080fd5b046020026020018101519050610a0052611520610180610620610ec0825160208401600073610dc0f1505060c0610ec051146119a357600080fd5b610ec051610ec0018060200151600082518060209013156119c357600080fd5b80919012156119d157600080fd5b606051816020036101000a8304806040519013156119ee57600080fd5b80919012156119fc57600080fd5b90509050905081526020610ee051610ec0015114611a1957600080fd5b610ee051610ee001518160200152610f0051610ec001806020015160008251806020901315611a4757600080fd5b8091901215611a5557600080fd5b606051816020036101000a830480604051901315611a7257600080fd5b8091901215611a8057600080fd5b9050905090508160400152610f2051610ec001806020015160008251806020901315611aab57600080fd5b8091901215611ab957600080fd5b606051816020036101000a830480604051901315611ad657600080fd5b8091901215611ae457600080fd5b9050905090508160600152610f4051610ec00180516020018083608001828460006004600a8704601201f1611b1857600080fd5b505050611520516119e05261156051611a005261158051611a20526115a0805160200180611a40828460006004600a8704601201f1611b5657600080fd5b50506105c0805160200180611ea0828460006004600a8704601201f1611b7b57600080fd5b50506020612300611ea051611ec06000601a54602154f1611b9b57600080fd5b60206122e0526122e0602060006020835103811315611bb957600080fd5b046020026020018101519050611e80526129a06105c0610620612340825160208401600073610dc0f1505060c06123405114611c0857600080fd5b6123405161234001806020015160008251806020901315611c2857600080fd5b8091901215611c3657600080fd5b606051816020036101000a830480604051901315611c5357600080fd5b8091901215611c6157600080fd5b9050905090508152602061236051612340015114611c7e57600080fd5b61236051612360015181602001526123805161234001806020015160008251806020901315611cac57600080fd5b8091901215611cba57600080fd5b606051816020036101000a830480604051901315611cd757600080fd5b8091901215611ce557600080fd5b90509050905081604001526123a05161234001806020015160008251806020901315611d1057600080fd5b8091901215611d1e57600080fd5b606051816020036101000a830480604051901315611d3b57600080fd5b8091901215611d4957600080fd5b90509050905081606001526123c0516123400180516020018083608001828460006004600a8704601201f1611d7d57600080fd5b5050506129a051612e60526129e051612e8052612a0051612ea052612a20805160200180612ec0828460006004600a8704601201f1611dbb57600080fd5b505060206137e0610484606063a276740061330052610a0051613320528061334052611a40808051602001808461332001828460006004600a8704601201f1611e0357600080fd5b5050805182016020019150506119e0516133605261331c90506000305af1611e2a57600080fd5b6137e0511515611e3f57600060005260206000f35b6020613ce0610484606063a276740061380052611e8051613820528061384052612ec0808051602001808461382001828460006004600a8704601201f1611e8557600080fd5b505080518201602001915050612e60516138605261381c90506000305af1611eac57600080fd5b613ce0511515611ec157600060005260206000f35b612e60516119e051141515611edb57600060005260206000f35b611e8051610a00511415611ef457600060005260206000f35b6003600060c0526119e05160e052604060c02060c052602060c020015415611f2157600060005260206000f35b612e8051611a005114613d0052611a2051612ea05112611a0051612e80511316612ea051611a205112612e8051611a0051131617613d2052613d2051613d00511760005260206000f3005b6310f246356000511415611f92573415611f8557600080fd5b60135460005260206000f3005b63855f372c600051141561201f573415611fab57600080fd5b6060516001606051601654600f540280604051901315611fca57600080fd5b8091901215611fd857600080fd5b0380604051901315611fe957600080fd5b8091901215611ff757600080fd5b610100430381121561200857600080fd5b43811061201457600080fd5b4060005260206000f3005b635c0a75de6000511415612167576020600461014037341561204057600080fd5b6060516004358060405190131561205657600080fd5b809190121561206457600080fd5b5061018060006c0c9f2c9cd04674edea40000000818352015b60605161018051600f54038060405190131561209857600080fd5b80919012156120a657600080fd5b610160526003600a60c0526101605160e052604060c02060c052602060c02001546101a05261014051600a60c0526101605160e052604060c02060c052602060c0205412156101c052610140516004600a60c0526101605160e052604060c02060c052602060c020015412156101e0526101e0516101c051166101a0511615612136576101605160005260206000f35b601f5461016051141561214857612159565b5b815160010180835281141561207d575b5050600060005260206000f3005b631f994c4060005114156122ce576020600461014037341561218857600080fd5b6060516004358060405190131561219e57600080fd5b80919012156121ac57600080fd5b5061018060006c0c9f2c9cd04674edea40000000818352015b60605161018051600f5403806040519013156121e057600080fd5b80919012156121ee57600080fd5b610160526002600a60c0526101605160e052604060c02060c052602060c02001546101a05261014051600a60c0526101605160e052604060c02060c052602060c0205412156101c052610140516004600a60c0526101605160e052604060c02060c052602060c020015412156101e0526101e0516101c051166101a051161561227e576101605160005260206000f35b601f54610160511415612290576122a1565b5b81516001018083528114156121c5575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000f3005b635dcffc17600051141561285457602060046101403734156122ef57600080fd5b6060516004358060405190131561230557600080fd5b809190121561231357600080fd5b50600060a0516016548061232657600080fd5b6402540be4004302058060805190131561233f57600080fd5b809190121561234d57600080fd5b121561239d576402540be4006402540be3ff60a0516016548061236f57600080fd5b6402540be4004302058060805190131561238857600080fd5b809190121561239657600080fd5b03056123dc565b6402540be40060a051601654806123b357600080fd5b6402540be400430205806080519013156123cc57600080fd5b80919012156123da57600080fd5b055b610160526060516001600f5401806040519013156123f957600080fd5b809190121561240757600080fd5b6101405114610160516101405113151661242057600080fd5b60206101e06004634a8fd6986101805261019c6000305af161244157600080fd5b6101e051600a60c0526101405160e052604060c02060c052602060c0205560206102606004637db2eedc6102005261021c6000305af161248057600080fd5b610260516004600a60c0526101405160e052604060c02060c052602060c020015561014051600f5560a05160206102e0600463acc619c36102805261029c6000305af16124cc57600080fd5b6102e0516402540be40001806080519013156124e757600080fd5b80919012156124f557600080fd5b600e5560a051600e5460a0516012546402540be400018060805190131561251b57600080fd5b809190121561252957600080fd5b8061253357600080fd5b806402540be400830205905090508060805190131561255157600080fd5b809190121561255f57600080fd5b600d5560a051600d54600c60c052606051600161014051038060405190131561258757600080fd5b809190121561259557600080fd5b60e052604060c0205481810281158383830514176125b257600080fd5b6402540be4008105905090509050806080519013156125d057600080fd5b80919012156125de57600080fd5b600c60c0526101405160e052604060c02055601460c052606051600161014051038060405190131561260f57600080fd5b809190121561261d57600080fd5b60e052604060c02054601460c0526101405160e052604060c0205560206103c0600463de7f99756103605261037c6000305af161265957600080fd5b6103c0511561278c5760a051601c546020610460600463db23eee06104005261041c6000305af161268957600080fd5b610460518061269757600080fd5b806402540be40083020590509050806080519013156126b557600080fd5b80919012156126c357600080fd5b6103e05260a05160a051606051600260206104e06004639a8eec776104805261049c6000305af16126f357600080fd5b6104e051038060405190131561270857600080fd5b809190121561271657600080fd5b601d54818102811583838305141761272d57600080fd5b809050905090508060805190131561274457600080fd5b809190121561275257600080fd5b6103e051018060805190131561276757600080fd5b809190121561277557600080fd5b60125560006012541361278757600080fd5b6127b2565b600060006004636526ed726103005261031c6000305af16127ac57600080fd5b60006012555b6020610560600463855f372c6105005261051c6000305af16127d357600080fd5b61056051600160c0526101405160e052604060c0205560006000600463d286bb826105805261059c6000305af161280957600080fd5b60006105e052600061060052600160c0526101405160e052604060c02054610140517f6940a3069a76fdb79d757f4dca548d7930f85e4bce3a3e2d06f5562bda0b10b960406105e0a3005b63f9609f086000511415612b5d576040600461014037600435602051811061287b57600080fd5b50602435602051811061288d57600080fd5b50600060006004610180527fa1903eab000000000000000000000000000000000000000000000000000000006101a0526101806004806020846101e001018260208501600060046012f1505080518201915050610140516020826101e0010152602081019050806101e0526101e09050805160200180610260828460006004600a8704601201f161291d57600080fd5b50506020610300610260516102806000601b546207a120f161293e57600080fd5b60206102e0526102e060206000602083510381131561295c57600080fd5b046020026020018101519050141561297357600080fd5b600360c0526101605160e052604060c020541561298f57600080fd5b601e5434121561299e57600080fd5b606051600260045401806040519013156129b757600080fd5b80919012156129c557600080fd5b6103405260a051600c60c052600f5460e052604060c02054806129e757600080fd5b68056bc75e2d6310000034020580608051901315612a0457600080fd5b8091901215612a1257600080fd5b61036052600060c05260025460e052604060c02060c052602060c0206101405181556103605160018201556020546002820155600060038201556103405160048201556000600582015561016051600682015550600254600360c0526101605160e052604060c020556002606051600182540180604051901315612a9557600080fd5b8091901215612aa357600080fd5b815550600560c0526103405160e052604060c02060a0516103605182540180608051901315612ad157600080fd5b8091901215612adf57600080fd5b81555061014051610380526004600060c052600360c0526101605160e052604060c0205460e052604060c02060c052602060c02001546103a052346103c052600360c0526101605160e052604060c02054610160517fc913dcae46368ac8a73eb63d4f2077a2de58e994bf2cddf074ab3a0fcaa3a0e16060610380a3005b6342310c3260005114156130795760206004610140373415612b7e57600080fd5b61042060043560040161016037610400600435600401351115612ba057600080fd5b600060a05160165480612bb257600080fd5b6402540be40043020580608051901315612bcb57600080fd5b8091901215612bd957600080fd5b1215612c29576402540be4006402540be3ff60a05160165480612bfb57600080fd5b6402540be40043020580608051901315612c1457600080fd5b8091901215612c2257600080fd5b0305612c68565b6402540be40060a05160165480612c3f57600080fd5b6402540be40043020580608051901315612c5857600080fd5b8091901215612c6657600080fd5b055b600f5414612c7557600080fd5b6101608051602001806105c0828460006004600a8704601201f1612c9857600080fd5b50506020610a206105c0516105e06000601a54602154f1612cb857600080fd5b6020610a0052610a00602060006020835103811315612cd657600080fd5b0460200260200181015190506105a052611000610160610560610a60825160208401600073610aa0f150506080610a605114612d2557600080fd5b610a6051610a6001806020015160008251806020901315612d4557600080fd5b8091901215612d5357600080fd5b606051816020036101000a830480604051901315612d7057600080fd5b8091901215612d7e57600080fd5b9050905090508152610a8051610a6001806020015160008251806020901315612da657600080fd5b8091901215612db457600080fd5b606051816020036101000a830480604051901315612dd157600080fd5b8091901215612ddf57600080fd5b9050905090508160200152610aa051610a600180516020018083604001828460006004600a8704601201f1612e1357600080fd5b5050506110005161148052611020516114a0526110408051602001806114c0828460006004600a8704601201f1612e4957600080fd5b50506114a051600f541215612e5d57600080fd5b6006600060c0526114805160e052604060c02060c052602060c02001543314611900526020611e00610484606063a2767400611920526105a0516119405280611960526114c0808051602001808461194001828460006004600a8704601201f1612ec657600080fd5b505080518201602001915050611480516119805261193c90506000305af1612eed57600080fd5b611e00516119005117612eff57600080fd5b6060516019546004540180604051901315612f1957600080fd5b8091901215612f2757600080fd5b611e2052611e20516002600060c0526114805160e052604060c02060c052602060c020015413612f5657600080fd5b611e20516002600060c0526114805160e052604060c02060c052602060c02001556020611ea06004634a8fd698611e4052611e5c6000305af1612f9857600080fd5b611ea0516005600060c0526114805160e052604060c02060c052602060c0200155600560c052611e205160e052604060c02060a0516001600060c0526114805160e052604060c02060c052602060c020015482540380608051901315612ffd57600080fd5b809190121561300b57600080fd5b8155506002600060c0526114805160e052604060c02060c052602060c0200154611ec052611480516006600060c0526114805160e052604060c02060c052602060c02001547fb0da0cd4d3f901fa403fa301bd3cad4934e079e9f1a5b61bdb33a03da2c9aaaf6020611ec0a3005b63edea148060005114156137a4576020600461014037341561309a57600080fd5b606051600435806040519013156130b057600080fd5b80919012156130be57600080fd5b506002600060c0526101405160e052604060c02060c052602060c0200154600454136130e957600080fd5b600860c05260605160016002600060c0526101405160e052604060c02060c052602060c0200154018060405190131561312157600080fd5b809190121561312f57600080fd5b60e052604060c020546101605260605160185461016051018060405190131561315757600080fd5b809190121561316557600080fd5b6101805261018051600f54121561317b57600080fd5b6003600060c0526101405160e052604060c02060c052602060c0200154151561332057600060a051600c60c0526101605160e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176131e657600080fd5b6402540be40081059050905090508060805190131561320457600080fd5b809190121561321257600080fd5b121561329d576402540be4006402540be3ff60a051600c60c0526101605160e052604060c020546001600060c0526101405160e052604060c02060c052602060c0200154818102811583838305141761326a57600080fd5b6402540be40081059050905090508060805190131561328857600080fd5b809190121561329657600080fd5b0305613317565b6402540be40060a051600c60c0526101605160e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176132e957600080fd5b6402540be40081059050905090508060805190131561330757600080fd5b809190121561331557600080fd5b055b6101a0526136f5565b606051601460c0526060516060516018546002028060405190131561334457600080fd5b809190121561335257600080fd5b61018051038060405190131561336757600080fd5b809190121561337557600080fd5b60e052604060c02054601460c0526101805160e052604060c0205403806040519013156133a157600080fd5b80919012156133af57600080fd5b6101c05260a0516005600060c0526101405160e052604060c02060c052602060c0200154806133dd57600080fd5b6402540be4006060516023546101c05102806040519013156133fe57600080fd5b809190121561340c57600080fd5b02058060805190131561341e57600080fd5b809190121561342c57600080fd5b6101e05260a0516101e0516402540be400038060805190131561344e57600080fd5b809190121561345c57600080fd5b60006402540be400810282121561347a576402540be400810261347c565b815b9050905061020052600060a051600c60c0526101805160e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176134cc57600080fd5b6402540be4008105905090509050806080519013156134ea57600080fd5b80919012156134f857600080fd5b1215613583576402540be4006402540be3ff60a051600c60c0526101805160e052604060c020546001600060c0526101405160e052604060c02060c052602060c0200154818102811583838305141761355057600080fd5b6402540be40081059050905090508060805190131561356e57600080fd5b809190121561357c57600080fd5b03056135fd565b6402540be40060a051600c60c0526101805160e052604060c020546001600060c0526101405160e052604060c02060c052602060c020015481810281158383830514176135cf57600080fd5b6402540be4008105905090509050806080519013156135ed57600080fd5b80919012156135fb57600080fd5b055b61022052600060a0516102005161022051818102811583838305141761362257600080fd5b809050905090508060805190131561363957600080fd5b809190121561364757600080fd5b12156136a4576402540be4006402540be3ff60a0516102005161022051818102811583838305141761367857600080fd5b809050905090508060805190131561368f57600080fd5b809190121561369d57600080fd5b03056136f0565b6402540be40060a051610200516102205181810281158383830514176136c957600080fd5b80905090509050806080519013156136e057600080fd5b80919012156136ee57600080fd5b055b6101a0525b60006000600060006101a0516006600060c0526101405160e052604060c02060c052602060c02001546000f161372a57600080fd5b6101a05161024052610140516006600060c0526101405160e052604060c02060c052602060c02001547f499b9fc824d01426cfde5b95eebcfc53494a24d6316bb139b2333377f7c00e476020610240a36000600060246301b7af1861026052610140516102805261027c6000305af16137a257600080fd5b005b63e9dc0614600051141561448657602060046101403734156137c557600080fd5b610420600435600401610160376104006004356004013511156137e757600080fd5b6101608051602001806105c0828460006004600a8704601201f161380a57600080fd5b50506020610a206105c0516105e06000601a54602154f161382a57600080fd5b6020610a0052610a0060206000602083510381131561384857600080fd5b0460200260200181015190506105a0526110c0610160610620610a60825160208401600073610dc0f1505060c0610a60511461389757600080fd5b610a6051610a60018060200151600082518060209013156138b757600080fd5b80919012156138c557600080fd5b606051816020036101000a8304806040519013156138e257600080fd5b80919012156138f057600080fd5b90509050905081526020610a8051610a6001511461390d57600080fd5b610a8051610a8001518160200152610aa051610a600180602001516000825180602090131561393b57600080fd5b809190121561394957600080fd5b606051816020036101000a83048060405190131561396657600080fd5b809190121561397457600080fd5b9050905090508160400152610ac051610a600180602001516000825180602090131561399f57600080fd5b80919012156139ad57600080fd5b606051816020036101000a8304806040519013156139ca57600080fd5b80919012156139d857600080fd5b9050905090508160600152610ae051610a600180516020018083608001828460006004600a8704601201f1613a0c57600080fd5b5050506110c051611580526110e0516115a052611100516115c052611120516115e052611140805160200180611600828460006004600a8704601201f1613a5257600080fd5b50506020611f20610484606063a2767400611a40526105a051611a605280611a80526116008080516020018084611a6001828460006004600a8704601201f1613a9a57600080fd5b50508051820160200191505061158051611aa052611a5c90506000305af1613ac157600080fd5b611f2051613ace57600080fd5b6001606051610100611580510780604051901315613aeb57600080fd5b8091901215613af957600080fd5b6000811215613b10578060000360020a8204613b17565b8060020a82025b905090506006600a60c0526115c05160e052604060c02060c052602060c0200160c052600060a0516101006402540be40061158051020580608051901315613b5e57600080fd5b8091901215613b6c57600080fd5b1215613bb5576402540be4006402540be3ff60a0516101006402540be40061158051020580608051901315613ba057600080fd5b8091901215613bae57600080fd5b0305613bed565b6402540be40060a0516101006402540be40061158051020580608051901315613bdd57600080fd5b8091901215613beb57600080fd5b055b60e052604060c020541615613c0157600080fd5b6020611fa0600463855f372c611f4052611f5c6000305af1613c2257600080fd5b611fa0516115a05114613c3457600080fd5b600f546115c05114613c4557600080fd5b6003600a60c0526115e05160e052604060c02060c052602060c0200154613c6b57600080fd5b6004600060c0526115805160e052604060c02060c052602060c0200154611fc0526002600060c0526115805160e052604060c02060c052602060c0200154611fe052600454612000526060516001612000510380604051901315613cce57600080fd5b8091901215613cdc57600080fd5b61202052611fe051612000511261200051611fc05113151661204052611fe051612020511261202051611fc05113151661206052612060516120405117613d2257600080fd5b6001606051610100611580510780604051901315613d3f57600080fd5b8091901215613d4d57600080fd5b6000811215613d64578060000360020a8204613d6b565b8060020a82025b905090506006600a60c0526115c05160e052604060c02060c052602060c0200160c052600060a0516101006402540be40061158051020580608051901315613db257600080fd5b8091901215613dc057600080fd5b1215613e09576402540be4006402540be3ff60a0516101006402540be40061158051020580608051901315613df457600080fd5b8091901215613e0257600080fd5b0305613e41565b6402540be40060a0516101006402540be40061158051020580608051901315613e3157600080fd5b8091901215613e3f57600080fd5b055b60e052604060c02054176006600a60c0526115c05160e052604060c02060c052602060c0200160c052600060a0516101006402540be40061158051020580608051901315613e8e57600080fd5b8091901215613e9c57600080fd5b1215613ee5576402540be4006402540be3ff60a0516101006402540be40061158051020580608051901315613ed057600080fd5b8091901215613ede57600080fd5b0305613f1d565b6402540be40060a0516101006402540be40061158051020580608051901315613f0d57600080fd5b8091901215613f1b57600080fd5b055b60e052604060c020556001600a60c0526115c05160e052604060c02060c052602060c0200160c0526115e05160e052604060c02054612080526005600a60c0526115c05160e052604060c02060c052602060c0200160c0526115e05160e052604060c020546120a05261204051156140075761208060a0516001600060c0526115805160e052604060c02060c052602060c020015482510180608051901315613fc557600080fd5b8091901215613fd357600080fd5b815250612080516001600a60c0526115c05160e052604060c02060c052602060c0200160c0526115e05160e052604060c020555b6120605115614088576120a060a0516001600060c0526115805160e052604060c02060c052602060c02001548251018060805190131561404657600080fd5b809190121561405457600080fd5b8152506120a0516005600a60c0526115c05160e052604060c02060c052602060c0200160c0526115e05160e052604060c020555b6115e051601354141561421657600060a0516012546001600060c0526115805160e052604060c02060c052602060c020015481810281158383830514176140ce57600080fd5b6402540be4008105905090509050806080519013156140ec57600080fd5b80919012156140fa57600080fd5b1215614176576402540be4006402540be3ff60a0516012546001600060c0526115805160e052604060c02060c052602060c0200154818102811583838305141761414357600080fd5b6402540be40081059050905090508060805190131561416157600080fd5b809190121561416f57600080fd5b03056141e1565b6402540be40060a0516012546001600060c0526115805160e052604060c02060c052602060c020015481810281158383830514176141b357600080fd5b6402540be4008105905090509050806080519013156141d157600080fd5b80919012156141df57600080fd5b055b6120c05260006000604463579f38b26120e05261158051612100526120c051612120526120fc6000305af161421557600080fd5b5b6003600a60c0526115c05160e052604060c02060c052602060c02001541560a051600360a0516002600754818102811583838305141761425557600080fd5b809050905090508060805190131561426c57600080fd5b809190121561427a57600080fd5b058060805190131561428b57600080fd5b809190121561429957600080fd5b6120a051121560a051600360a051600260065481810281158383830514176142c057600080fd5b80905090509050806080519013156142d757600080fd5b80919012156142e557600080fd5b05806080519013156142f657600080fd5b809190121561430457600080fd5b6120805112151616156144285760016003600a60c0526115c05160e052604060c02060c052602060c02001556115c0516011556001600b5560016121805260006121a052600160c0526115c05160e052604060c020546115c0517f6940a3069a76fdb79d757f4dca548d7930f85e4bce3a3e2d06f5562bda0b10b96040612180a360605160016115e051018060405190131561439f57600080fd5b80919012156143ad57600080fd5b6115c05114156144275760016002600a60c0526115e05160e052604060c02060c052602060c02001556115e05160105560016121c05260016121e052600160c0526115e05160e052604060c020546115e0517f6940a3069a76fdb79d757f4dca548d7930f85e4bce3a3e2d06f5562bda0b10b960406121c0a35b5b6115c051612200526115e051612220526115a051611580516006600060c0526115805160e052604060c02060c052602060c02001547f0fa814a7606272ed601db3d9974a12a26536f050d147ad209b7e7b0a95746f176040612200a4005b63cc20f16b6000511415614ab057604060046101403734156144a757600080fd5b610420600435600401610180376104006004356004013511156144c957600080fd5b6104206024356004016105c0376104006024356004013511156144eb57600080fd5b60206112e061088460406313d21fa3610a005280610a20526101808080516020018084610a2001828460006004600a8704601201f161452957600080fd5b50508051820160200191505080610a40526105c08080516020018084610a2001828460006004600a8704601201f161456057600080fd5b505080518201602001915050610a1c90506000305af161457f57600080fd5b6112e05161458c57600080fd5b611960610180610620611300825160208401600073610dc0f1505060c061130051146145cb57600080fd5b61130051611300018060200151600082518060209013156145eb57600080fd5b80919012156145f957600080fd5b606051816020036101000a83048060405190131561461657600080fd5b809190121561462457600080fd5b905090509050815260206113205161130001511461464157600080fd5b6113205161132001518160200152611340516113000180602001516000825180602090131561466f57600080fd5b809190121561467d57600080fd5b606051816020036101000a83048060405190131561469a57600080fd5b80919012156146a857600080fd5b905090509050816040015261136051611300018060200151600082518060209013156146d357600080fd5b80919012156146e157600080fd5b606051816020036101000a8304806040519013156146fe57600080fd5b809190121561470c57600080fd5b9050905090508160600152611380516113000180516020018083608001828460006004600a8704601201f161474057600080fd5b50505061196051611e20526020611ee060246399fb5eec611e6052611e2051611e8052611e7c6000305af161477457600080fd5b611ee051611e4052600060a05160196402540be400611e405102058060805190131561479f57600080fd5b80919012156147ad57600080fd5b12156147f5576402540be4006402540be3ff60a05160196402540be400611e40510205806080519013156147e057600080fd5b80919012156147ee57600080fd5b030561482c565b6402540be40060a05160196402540be400611e405102058060805190131561481c57600080fd5b809190121561482a57600080fd5b055b611f0052606051611f0051611e4051038060405190131561484c57600080fd5b809190121561485a57600080fd5b611f2052601460c052600f5460e052604060c020606051611e40518254018060405190131561488857600080fd5b809190121561489657600080fd5b81555060016003600060c052611e205160e052604060c02060c052602060c0200155611f0051611f4052611f2051611f6052611e20516006600060c052611e205160e052604060c02060c052602060c0200154337fb63bb46c05149b79f409b978407acff3bb3bfb5fb728ed2909fdb52677c220da6040611f40a46002600060c052611e205160e052604060c02060c052602060c0200154611f8052611f80516004541215614a95576001600060c052611e205160e052604060c02060c052602060c0200154611fa052600560c0526060516001600454018060405190131561497e57600080fd5b809190121561498c57600080fd5b60e052604060c02060a051611fa051825403806080519013156149ae57600080fd5b80919012156149bc57600080fd5b815550606051600160045401806040519013156149d857600080fd5b80919012156149e657600080fd5b6002600060c052611e205160e052604060c02060c052602060c0200155602054611f80511215614a5157600560c052611f805160e052604060c02060a051611fa05182540180608051901315614a3b57600080fd5b8091901215614a4957600080fd5b815550614a94565b60206120206004634a8fd698611fc052611fdc6000305af1614a7257600080fd5b612020516005600060c052611e205160e052604060c02060c052602060c02001555b5b6000600060006000611f0051336000f1614aae57600080fd5b005b63bcc44d996000511415614b1d5760206004610140373415614ad157600080fd5b60605160043580604051901315614ae757600080fd5b8091901215614af557600080fd5b506001600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b63faf944fa6000511415614b8a5760206004610140373415614b3e57600080fd5b60605160043580604051901315614b5457600080fd5b8091901215614b6257600080fd5b506004600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b63c253bf416000511415614bf75760206004610140373415614bab57600080fd5b60605160043580604051901315614bc157600080fd5b8091901215614bcf57600080fd5b506002600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b633b4f3ae36000511415614c645760206004610140373415614c1857600080fd5b60605160043580604051901315614c2e57600080fd5b8091901215614c3c57600080fd5b506003600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b6306fcf2ff6000511415614cd15760206004610140373415614c8557600080fd5b60605160043580604051901315614c9b57600080fd5b8091901215614ca957600080fd5b506005600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b63bb0115f06000511415614d3b5760206004610140373415614cf257600080fd5b60605160043580604051901315614d0857600080fd5b8091901215614d1657600080fd5b50600060c0526101405160e052604060c02060c052602060c0205460005260206000f3005b635dbfd1ce6000511415614da85760206004610140373415614d5c57600080fd5b60605160043580604051901315614d7257600080fd5b8091901215614d8057600080fd5b506006600060c0526101405160e052604060c02060c052602060c020015460005260206000f3005b638208b8756000511415614e0a5760206004610140373415614dc957600080fd5b60605160043580604051901315614ddf57600080fd5b8091901215614ded57600080fd5b50600160c0526101405160e052604060c0205460005260206000f3005b637d69c5d96000511415614e30573415614e2357600080fd5b60025460005260206000f3005b63dc2059b36000511415614e7f5760206004610140373415614e5157600080fd5b6004356020518110614e6257600080fd5b50600360c0526101405160e052604060c0205460005260206000f3005b637060054d6000511415614ea5573415614e9857600080fd5b60045460005260206000f3005b63c44dc6596000511415614f075760206004610140373415614ec657600080fd5b60605160043580604051901315614edc57600080fd5b8091901215614eea57600080fd5b50600560c0526101405160e052604060c0205460005260206000f3005b63a2630bae6000511415614f695760206004610140373415614f2857600080fd5b60605160043580604051901315614f3e57600080fd5b8091901215614f4c57600080fd5b50600860c0526101405160e052604060c0205460005260206000f3005b6365ca80e66000511415614fcb5760206004610140373415614f8a57600080fd5b60605160043580604051901315614fa057600080fd5b8091901215614fae57600080fd5b50600960c0526101405160e052604060c0205460005260206000f3005b634af8e81a60005114156150355760206004610140373415614fec57600080fd5b6060516004358060405190131561500257600080fd5b809190121561501057600080fd5b50600a60c0526101405160e052604060c02060c052602060c0205460005260206000f3005b6326becf5860005114156150a2576020600461014037341561505657600080fd5b6060516004358060405190131561506c57600080fd5b809190121561507a57600080fd5b506004600a60c0526101405160e052604060c02060c052602060c020015460005260206000f3005b63be26608e600051141561514357604060046101403734156150c357600080fd5b606051600435806040519013156150d957600080fd5b80919012156150e757600080fd5b50606051602435806040519013156150fe57600080fd5b809190121561510c57600080fd5b506001600a60c0526101405160e052604060c02060c052602060c0200160c0526101605160e052604060c0205460005260206000f3005b633673fd9860005114156151e4576040600461014037341561516457600080fd5b6060516004358060405190131561517a57600080fd5b809190121561518857600080fd5b506060516024358060405190131561519f57600080fd5b80919012156151ad57600080fd5b506005600a60c0526101405160e052604060c02060c052602060c0200160c0526101605160e052604060c0205460005260206000f3005b63e270eb666000511415615285576040600461014037341561520557600080fd5b6060516004358060405190131561521b57600080fd5b809190121561522957600080fd5b506060516024358060405190131561524057600080fd5b809190121561524e57600080fd5b506006600a60c0526101405160e052604060c02060c052602060c0200160c0526101605160e052604060c0205460005260206000f3005b6330d3c41a60005114156152f257602060046101403734156152a657600080fd5b606051600435806040519013156152bc57600080fd5b80919012156152ca57600080fd5b506003600a60c0526101405160e052604060c02060c052602060c020015460005260206000f3005b63cfff38c0600051141561535f576020600461014037341561531357600080fd5b6060516004358060405190131561532957600080fd5b809190121561533757600080fd5b506002600a60c0526101405160e052604060c02060c052602060c020015460005260206000f3005b6399787ac6600051141561538557341561537857600080fd5b600b5460005260206000f3005b63e430757f60005114156153e757602060046101403734156153a657600080fd5b606051600435806040519013156153bc57600080fd5b80919012156153ca57600080fd5b50600c60c0526101405160e052604060c0205460005260206000f3005b638a484407600051141561540d57341561540057600080fd5b600d5460005260206000f3005b63e6b57366600051141561543357341561542657600080fd5b600e5460005260206000f3005b639372b4e4600051141561545957341561544c57600080fd5b600f5460005260206000f3005b632eff8759600051141561547f57341561547257600080fd5b60105460005260206000f3005b635f61165060005114156154a557341561549857600080fd5b60115460005260206000f3005b6307dcf45b60005114156154cb5734156154be57600080fd5b60125460005260206000f3005b635b03544a60005114156154f15734156154e457600080fd5b60135460005260206000f3005b634c7756756000511415615553576020600461014037341561551257600080fd5b6060516004358060405190131561552857600080fd5b809190121561553657600080fd5b50601460c0526101405160e052604060c0205460005260206000f3005b63ac4746ab600051141561557957341561556c57600080fd5b60165460005260206000f3005b6397fbdf08600051141561559f57341561559257600080fd5b60175460005260206000f3005b630ebb172a60005114156155c55734156155b857600080fd5b60185460005260206000f3005b634f4ddb5e60005114156155eb5734156155de57600080fd5b60195460005260206000f3005b633f8a500e600051141561561157341561560457600080fd5b601c5460005260206000f3005b6361073e88600051141561563757341561562a57600080fd5b601d5460005260206000f3005b6326c0817e600051141561565d57341561565057600080fd5b601e5460005260206000f3005b63d4b31281600051141561568357341561567657600080fd5b601f5460005260206000f3005b" diff --git a/ethcore/res/contracts/simple_casper.json b/ethcore/res/contracts/simple_casper.json new file mode 100644 index 00000000000..e7d917d5ee1 --- /dev/null +++ b/ethcore/res/contracts/simple_casper.json @@ -0,0 +1 @@ +[{"name": "Deposit", "inputs": [{"type": "address", "name": "_from", "indexed": true}, {"type": "int128", "name": "_validator_index", "indexed": true}, {"type": "address", "name": "_validation_address", "indexed": false}, {"type": "int128", "name": "_start_dyn", "indexed": false}, {"type": "int128", "name": "_amount", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Vote", "inputs": [{"type": "address", "name": "_from", "indexed": true}, {"type": "int128", "name": "_validator_index", "indexed": true}, {"type": "bytes32", "name": "_target_hash", "indexed": true}, {"type": "int128", "name": "_target_epoch", "indexed": false}, {"type": "int128", "name": "_source_epoch", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Logout", "inputs": [{"type": "address", "name": "_from", "indexed": true}, {"type": "int128", "name": "_validator_index", "indexed": true}, {"type": "int128", "name": "_end_dyn", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Withdraw", "inputs": [{"type": "address", "name": "_to", "indexed": true}, {"type": "int128", "name": "_validator_index", "indexed": true}, {"type": "int128", "name": "_amount", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Slash", "inputs": [{"type": "address", "name": "_from", "indexed": true}, {"type": "address", "name": "_offender", "indexed": true}, {"type": "int128", "name": "_offender_index", "indexed": true}, {"type": "int128", "name": "_bounty", "indexed": false}, {"type": "int128", "name": "_destroyed", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Epoch", "inputs": [{"type": "int128", "name": "_number", "indexed": true}, {"type": "bytes32", "name": "_checkpoint_hash", "indexed": true}, {"type": "bool", "name": "_is_justified", "indexed": false}, {"type": "bool", "name": "_is_finalized", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "init", "outputs": [], "inputs": [{"type": "int128", "name": "epoch_length"}, {"type": "int128", "name": "warm_up_period"}, {"type": "int128", "name": "withdrawal_delay"}, {"type": "int128", "name": "dynasty_logout_delay"}, {"type": "address", "name": "msg_hasher"}, {"type": "address", "name": "purity_checker"}, {"type": "fixed168x10", "name": "base_interest_factor"}, {"type": "fixed168x10", "name": "base_penalty_factor"}, {"type": "int128", "name": "min_deposit_size"}], "constant": false, "payable": false, "type": "function", "gas": 693389}, {"name": "main_hash_voted_frac", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 3125}, {"name": "deposit_size", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "validator_index"}], "constant": true, "payable": false, "type": "function", "gas": 3127}, {"name": "total_curdyn_deposits_in_wei", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2663}, {"name": "total_prevdyn_deposits_in_wei", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2693}, {"name": "slashable", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "bytes", "name": "vote_msg_1"}, {"type": "bytes", "name": "vote_msg_2"}], "constant": false, "payable": false, "type": "function", "gas": 37420}, {"name": "recommended_source_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 933}, {"name": "recommended_target_hash", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 810}, {"name": "highest_justified_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "min_total_deposits"}], "constant": true, "payable": false, "type": "function", "gas": 1984000000000000000000000000000946}, {"name": "highest_finalized_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "min_total_deposits"}], "constant": true, "payable": false, "type": "function", "gas": 1984000000000000000000000000000976}, {"name": "initialize_epoch", "outputs": [], "inputs": [{"type": "int128", "name": "epoch"}], "constant": false, "payable": false, "type": "function", "gas": 743858}, {"name": "deposit", "outputs": [], "inputs": [{"type": "address", "name": "validation_addr"}, {"type": "address", "name": "withdrawal_addr"}], "constant": false, "payable": true, "type": "function", "gas": 831732}, {"name": "logout", "outputs": [], "inputs": [{"type": "bytes", "name": "logout_msg"}], "constant": false, "payable": false, "type": "function", "gas": 132888}, {"name": "withdraw", "outputs": [], "inputs": [{"type": "int128", "name": "validator_index"}], "constant": false, "payable": false, "type": "function", "gas": 223404}, {"name": "vote", "outputs": [], "inputs": [{"type": "bytes", "name": "vote_msg"}], "constant": false, "payable": false, "type": "function", "gas": 503266}, {"name": "slash", "outputs": [], "inputs": [{"type": "bytes", "name": "vote_msg_1"}, {"type": "bytes", "name": "vote_msg_2"}], "constant": false, "payable": false, "type": "function", "gas": 284884}, {"name": "validators__deposit", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1534}, {"name": "validators__start_dynasty", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1564}, {"name": "validators__end_dynasty", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1594}, {"name": "validators__is_slashed", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1624}, {"name": "validators__total_deposits_at_logout", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1654}, {"name": "validators__addr", "outputs": [{"type": "address", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1678}, {"name": "validators__withdrawal_addr", "outputs": [{"type": "address", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1714}, {"name": "checkpoint_hashes", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1666}, {"name": "next_validator_index", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1473}, {"name": "validator_indexes", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "address", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1675}, {"name": "dynasty", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1533}, {"name": "dynasty_wei_delta", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1786}, {"name": "dynasty_start_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1816}, {"name": "dynasty_in_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1846}, {"name": "checkpoints__cur_dyn_deposits", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1948}, {"name": "checkpoints__prev_dyn_deposits", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 1984}, {"name": "checkpoints__cur_dyn_votes", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}, {"type": "int128", "name": "arg1"}], "constant": true, "payable": false, "type": "function", "gas": 2225}, {"name": "checkpoints__prev_dyn_votes", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}, {"type": "int128", "name": "arg1"}], "constant": true, "payable": false, "type": "function", "gas": 2255}, {"name": "checkpoints__vote_bitmap", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}, {"type": "int128", "name": "arg1"}], "constant": true, "payable": false, "type": "function", "gas": 2285}, {"name": "checkpoints__is_justified", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 2104}, {"name": "checkpoints__is_finalized", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 2134}, {"name": "main_hash_justified", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1863}, {"name": "deposit_scale_factor", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 2116}, {"name": "last_nonvoter_rescale", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1923}, {"name": "last_voter_rescale", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1953}, {"name": "current_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1983}, {"name": "last_finalized_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2013}, {"name": "last_justified_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2043}, {"name": "reward_factor", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2073}, {"name": "expected_source_epoch", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2103}, {"name": "total_slashed", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "int128", "name": "arg0"}], "constant": true, "payable": false, "type": "function", "gas": 2356}, {"name": "EPOCH_LENGTH", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2163}, {"name": "WARM_UP_PERIOD", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2193}, {"name": "WITHDRAWAL_DELAY", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2223}, {"name": "DYNASTY_LOGOUT_DELAY", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2253}, {"name": "BASE_INTEREST_FACTOR", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2283}, {"name": "BASE_PENALTY_FACTOR", "outputs": [{"type": "fixed168x10", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2313}, {"name": "MIN_DEPOSIT_SIZE", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2343}, {"name": "START_EPOCH", "outputs": [{"type": "int128", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 2373}] diff --git a/ethcore/res/ethereum/casper_test.json b/ethcore/res/ethereum/casper_test.json new file mode 100644 index 00000000000..38eca8835a3 --- /dev/null +++ b/ethcore/res/ethereum/casper_test.json @@ -0,0 +1,72 @@ +{ + "name": "Casper Testnet", + "dataDir": "caspertest", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x1ee73", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "homesteadTransition": "0x0", + "eip649Reward": "0x29A2241AF62C0000", + "eip100bTransition": "0x0", + "eip649Transition": "0x0", + "hybridCasperTransition": "0x32", + "hybridCasperParams": { + "epochLength": 50, + "warmUpPeriod": 50 + } + } + } + }, + "params": { + "gasLimitBoundDivisor": "0x0400", + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x1ee7", + "eip155Transition": "0x0", + "eip98Transition": "0x7fffffffffffff", + "eip86Transition": "0x7fffffffffffff", + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x0", + "eip140Transition": "0x0", + "eip211Transition": "0x0", + "eip214Transition": "0x0", + "eip658Transition": "0x0", + "eip150Transition": "0x0", + "eip160Transition": "0x0", + "eip161abcTransition": "0x0", + "eip161dTransition": "0x0" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x0000000000000056", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x20000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x5f5e100" + }, + "nodes": [ + "enode://c32ec5909c84ca346dda05435809889fed101dadadcae5e255e09658bcb1e4d1ed304c90929e34a3b51d9cf5869ff486c887f600dbd8f0305f52637280a7a55a@139.162.71.88:30303", + "enode://b541cb9808a932ac2b7e3ea9fb584dc0cac391527788773fccceaae7a2d86bd250f725bf5899a452ef25b2ff69084d830c2f905fce619eaf372ccd63f3056d98@139.162.71.88:31303" + ], + "accounts": { + "0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, + "0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, + "0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, + "0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, + "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "pricing": { "modexp": { "divisor": 20 } } } }, + "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "pricing": { "linear": { "base": 500, "word": 0 } } } }, + "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, + "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "bfb20f94b5640d144592ab9a64c3b515add1b90e": { "balance": "0x52B7D2DCC80CD2E4000000" } + } +} diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 682171170e1..1241477909e 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -351,8 +351,17 @@ impl<'x> OpenBlock<'x> { return Err(TransactionError::AlreadyImported.into()); } - let env_info = self.env_info(); - let outcome = self.block.state.apply(&env_info, self.engine.machine(), &t, self.block.traces.is_enabled())?; + let mut env_info = self.env_info(); + self.engine.prepare_env_info(&t, &self.block, &mut env_info); + self.block.state.checkpoint(); + let mut outcome = self.block.state.apply(&env_info, self.engine.machine(), &t, self.block.traces.is_enabled())?; + + if let Err(e) = self.engine.verify_transaction_outcome(&t, &mut self.block, &mut outcome.receipt) { + self.block.state.revert_to_checkpoint(); + return Err(e).into(); + } + + self.block.state.discard_checkpoint(); self.block.transactions_set.insert(h.unwrap_or_else(||t.hash())); self.block.transactions.push(t.into()); diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index e2e88c8178d..bcb55973ecb 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -1366,6 +1366,8 @@ impl Engine for AuthorityRound { } } +impl ::engines::EthEngine for AuthorityRound { } + #[cfg(test)] mod tests { use std::sync::Arc; diff --git a/ethcore/src/engines/basic_authority.rs b/ethcore/src/engines/basic_authority.rs index dde0af2d960..97f687a7d13 100644 --- a/ethcore/src/engines/basic_authority.rs +++ b/ethcore/src/engines/basic_authority.rs @@ -197,6 +197,8 @@ impl Engine for BasicAuthority { } } +impl ::engines::EthEngine for BasicAuthority { } + #[cfg(test)] mod tests { use std::sync::Arc; diff --git a/ethcore/src/engines/hybrid_casper.rs b/ethcore/src/engines/hybrid_casper.rs new file mode 100644 index 00000000000..a47506370c4 --- /dev/null +++ b/ethcore/src/engines/hybrid_casper.rs @@ -0,0 +1,371 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Hybrid Casper related functionalities. + +use bytes::Bytes; +use block::{IsBlock, ExecutedBlock}; +use ethereum_types::{Address, U256, H256}; +use engines::{DEFAULT_CASPER_CONTRACT, DEFAULT_PURITY_CHECKER_CONTRACT, DEFAULT_MSG_HASHER_CONTRACT, DEFAULT_RLP_DECODER_CONTRACT, ForkChoice}; +use header::ExtendedHeader; +use rustc_hex::FromHex; +use rlp; +use transaction::{SignedTransaction, Action}; +use vm::{EnvInfo, Schedule}; +use parity_machine::{WithMetadata, WithMetadataHeader, TotalScoredHeader}; +use state::{State, Backend}; +use types::BlockNumber; +use types::ancestry_action::AncestryAction; +use types::receipt::{Receipt, TransactionOutcome}; +use ethabi::{self, ParamType}; +use super::SystemCall; + +use_contract!(simple_casper, "SimpleCasper", "res/contracts/simple_casper.json"); + +/// Hybrid Casper parameters. +#[derive(Debug, Clone, PartialEq)] +pub struct HybridCasperParams { + /// Main contract code. + pub contract_code: Bytes, + /// Address to deploy the main contract. + pub contract_address: Address, + /// Balance to force set in the beginning. + pub contract_balance: U256, + /// Purity checker contract code. + pub purity_checker_contract_code: Bytes, + /// Address to deploy the purity checker. + pub purity_checker_contract_address: Address, + /// Msg hasher contract code. + pub msg_hasher_contract_code: Bytes, + /// Address to deploy the msg hasher. + pub msg_hasher_contract_address: Address, + /// RLP decoder contract code. + pub rlp_decoder_contract_code: Bytes, + /// Address to deploy the RLP decoder. + pub rlp_decoder_contract_address: Address, + /// Whether force-deploying the RLP decoder or not. + pub deploy_rlp_decoder: bool, + + /// Casper epoch length. + pub epoch_length: u64, + /// Casper withdrawal delay. + pub withdrawal_delay: u64, + /// Casper dynasty logout delay. + pub dynasty_logout_delay: u64, + /// Base interest factor passed to the Casper init function. + pub base_interest_factor: U256, + /// Base penalty factor passed to the Casper init function. + pub base_penalty_factor: U256, + /// Min deposit size accepted by Casper. + pub min_deposit_size: U256, + /// Warm up period before vote begins. + pub warm_up_period: u64, + /// Min deposit to consider a block to be justified. + pub non_revert_min_deposits: U256, +} + +impl From<::ethjson::spec::HybridCasperParams> for HybridCasperParams { + fn from(p: ::ethjson::spec::HybridCasperParams) -> Self { + let rlp_decoder_contract_address = p.rlp_decoder_contract_address.map_or(Address::from(0x43u64), Into::into); + + HybridCasperParams { + contract_code: p.contract_code + .map_or(DEFAULT_CASPER_CONTRACT + .replace("", &format!("{:x}", rlp_decoder_contract_address)) + .from_hex() + .expect("DEFAULT_CASPER_CONTRACT is valid bytearray; qed"), Into::into), + contract_address: p.contract_address.map_or(Address::from(0x40u64), Into::into), + contract_balance: p.contract_balance.map_or(U256::from(1250000) * ::ethereum::ether(), Into::into), + + purity_checker_contract_code: p.purity_checker_contract_code + .map_or(DEFAULT_PURITY_CHECKER_CONTRACT + .from_hex() + .expect("DEFAULT_PURITY_CHECKER_CONTRACT is valid bytearray; qed"), Into::into), + purity_checker_contract_address: p.purity_checker_contract_address.map_or(Address::from(0x41u64), Into::into), + + msg_hasher_contract_code: p.msg_hasher_contract_code + .map_or(DEFAULT_MSG_HASHER_CONTRACT + .from_hex() + .expect("DEFAULT_MSG_HASHER_CONTRACT is valid bytearray; qed"), Into::into), + msg_hasher_contract_address: p.msg_hasher_contract_address.map_or(Address::from(0x42u64), Into::into), + + rlp_decoder_contract_code: p.rlp_decoder_contract_code + .map_or(DEFAULT_RLP_DECODER_CONTRACT + .from_hex() + .expect("DEFAULT_RLP_DECODER_CONTRACT is valid bytearray; qed"), Into::into), + rlp_decoder_contract_address: rlp_decoder_contract_address, + deploy_rlp_decoder: p.deploy_rlp_decoder.unwrap_or(true), + + epoch_length: p.epoch_length.map_or(50, Into::into), + withdrawal_delay: p.withdrawal_delay.map_or(15000, Into::into), + dynasty_logout_delay: p.dynasty_logout_delay.map_or(700, Into::into), + base_interest_factor: p.base_interest_factor.map_or(U256::from(70000000), Into::into), + base_penalty_factor: p.base_penalty_factor.map_or(U256::from(2000), Into::into), + min_deposit_size: p.min_deposit_size.map_or(U256::from(1500) * ::ethereum::ether(), Into::into), + warm_up_period: p.warm_up_period.map_or(180000, Into::into), + non_revert_min_deposits: p.non_revert_min_deposits.map_or(U256::from(1) * ::ethereum::ether(), Into::into), + } + } +} + +impl Default for HybridCasperParams { + fn default() -> Self { + Self::from(::ethjson::spec::HybridCasperParams::default()) + } +} + +/// Casper related metadata. +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +pub struct HybridCasperMetadata { + /// Gas used in vote transactions. + pub vote_gas_used: U256, + /// Highest justified epoch returned by Casper contract. + pub highest_justified_epoch: U256, + /// Highest finalized epoch returned by Casper contract. + pub highest_finalized_epoch: U256, + /// Highest finalized block hash returned by Casper contract. + pub highest_finalized_hash: H256, +} + +impl Default for HybridCasperMetadata { + fn default() -> Self { + Self { + vote_gas_used: U256::zero(), + highest_justified_epoch: U256::zero(), + highest_finalized_epoch: U256::zero(), + highest_finalized_hash: Default::default(), + } + } +} + +/// Hybrid Casper functionalities as defined by EIP1011. +pub struct HybridCasper { + params: HybridCasperParams, + provider: simple_casper::SimpleCasper, +} + +impl HybridCasper { + /// Create a new Hybrid Casper instance based on parameters. + pub fn new(params: HybridCasperParams) -> Self { + Self { + params, + provider: simple_casper::SimpleCasper::default(), + } + } + + /// Check whether a signed transaction is vote transaction. The vote transaction must be an unsigned transaction, + /// whose to address is the casper contract address, and data starts with bytes 0xe9dc0614. + pub fn is_vote_transaction(&self, transaction: &SignedTransaction) -> bool { + if !transaction.is_unsigned() { + return false; + } + + let unsigned = transaction.as_unsigned(); + + match unsigned.action { + Action::Create => { + return false; + }, + Action::Call(address) => { + if address != self.params.contract_address { + return false; + } + }, + } + + if unsigned.data.len() < 4 { + return false; + } + + if &unsigned.data[0..4] != &[0xe9, 0xdc, 0x06, 0x14] { + return false; + } + + return true; + } + + /// Modify the schedule to enable Casper-related functionalities. + pub fn enable_casper_schedule(&self, schedule: &mut Schedule) { + schedule.eip86 = true; + } + + /// Initialize Casper contract, purity checker contract, msg hasher contract and RLP decoder. + pub fn init_state(&self, state: &mut State) -> Result<(), ::error::Error> { + state.new_contract(&self.params.contract_address, + self.params.contract_balance, + U256::zero()); + state.init_code(&self.params.contract_address, + self.params.contract_code.clone())?; + state.init_code(&self.params.purity_checker_contract_address, + self.params.purity_checker_contract_code.clone())?; + state.init_code(&self.params.msg_hasher_contract_address, + self.params.msg_hasher_contract_code.clone())?; + if self.params.deploy_rlp_decoder { + state.init_code(&self.params.rlp_decoder_contract_address, + self.params.rlp_decoder_contract_code.clone())?; + } + + Ok(()) + } + + /// Called `init` function in Casper contract. + pub fn init_casper_contract(&self, caller: &mut SystemCall) -> Result<(), ::error::Error> { + let data = self.provider.functions().init().input( + self.params.epoch_length, + self.params.warm_up_period, + self.params.withdrawal_delay, + self.params.dynasty_logout_delay, + self.params.msg_hasher_contract_address, + self.params.purity_checker_contract_address, + self.params.base_interest_factor, + self.params.base_penalty_factor, + self.params.min_deposit_size, + ); + caller(self.params.contract_address, data) + .map(|_| ()) + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } + + /// Called at every block after Casper's warm up period. Initialize a new epoch if we are at the epoch starting + /// block. + pub fn on_new_epoch(&self, block_number: BlockNumber, caller: &mut SystemCall) -> Result<(), ::error::Error> { + if block_number % self.params.epoch_length == 0 { + let data = self.provider.functions().initialize_epoch().input( + block_number / self.params.epoch_length + ); + caller(self.params.contract_address, data) + .map(|_| ()) + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } else { + Ok(()) + } + } + + /// Get the highest justified epoch. + pub fn highest_justified_epoch(&self, caller: &mut SystemCall) -> Result { + let data = self.provider.functions().highest_justified_epoch().input( + self.params.non_revert_min_deposits, + ); + caller(self.params.contract_address, data) + .and_then(|output| { + Ok(ethabi::decode(&[ParamType::Int(128)], &output) + .map_err(|e| format!("{}", e))?[0].clone() + .to_int() + .expect("type checked by ethabi::decode; qed")) + }) + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } + + /// Get the highest finalized epoch. + pub fn highest_finalized_epoch(&self, caller: &mut SystemCall) -> Result { + let data = self.provider.functions().highest_finalized_epoch().input( + self.params.non_revert_min_deposits, + ); + caller(self.params.contract_address, data) + .and_then(|output| { + Ok(ethabi::decode(&[ParamType::Int(128)], &output) + .map_err(|e| format!("{}", e))?[0].clone() + .to_int() + .expect("type checked by ethabi::decode; qed")) + }) + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } + + /// Get checkpoint hashes given an epoch. + pub fn checkpoint_hashes(&self, epoch: U256, caller: &mut SystemCall) -> Result { + let data = self.provider.functions().checkpoint_hashes().input( + epoch, + ); + caller(self.params.contract_address, data) + .and_then(|output| { + Ok(H256::from_slice(ðabi::decode(&[ParamType::FixedBytes(32)], &output) + .map_err(|e| format!("{}", e))?[0].clone() + .to_fixed_bytes() + .expect("type checked by ethabi::decode; qed"))) + }) + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } + + /// Update block metadata based on the current block state. + pub fn update_metadata(&self, metadata: &mut HybridCasperMetadata, caller: &mut SystemCall) -> Result<(), ::error::Error> { + metadata.highest_justified_epoch = self.highest_justified_epoch(caller)?; + metadata.highest_finalized_epoch = self.highest_finalized_epoch(caller)?; + metadata.highest_finalized_hash = self.checkpoint_hashes(metadata.highest_finalized_epoch, caller)?; + + Ok(()) + } + + /// Casper-specific fork choice. + pub fn fork_choice(&self, new: &ExtendedHeader, current: &ExtendedHeader) -> ForkChoice { + let new_metadata: HybridCasperMetadata = new.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + let current_metadata: HybridCasperMetadata = current.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + + // Casper fails back to total difficulty fork choice if highest_justified_epoch is zero. So we don't need to + // check transition block here. + let new_score = new_metadata.highest_justified_epoch * U256::from(10).pow(U256::from(40)) + new.total_score(); + let current_score = current_metadata.highest_justified_epoch * U256::from(10).pow(U256::from(40)) + current.total_score(); + + if new_score > current_score { + ForkChoice::New + } else { + ForkChoice::Old + } + } + + /// Casper-specific ancestry actions. + pub fn ancestry_actions(&self, block: &ExecutedBlock) -> Vec { + let metadata: HybridCasperMetadata = block.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + + if metadata.highest_finalized_hash != Default::default() { + // Call finalize on an already finalized block won't do anything. So we just do that for now to avoid a + // conditional. + vec![AncestryAction::MarkFinalized(metadata.highest_finalized_hash)] + } else { + // Default metadata would match this. So we don't need to check Casper transition block here. + vec![] + } + } + + /// Prepare the env info required for vote transactions. + pub fn prepare_vote_transaction_env_info(&self, _t: &SignedTransaction, block: &ExecutedBlock, env_info: &mut EnvInfo) { + let metadata: HybridCasperMetadata = block.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + env_info.gas_used = metadata.vote_gas_used; + } + + /// Verify the outcome of a vote transaction is valid. + pub fn verify_vote_transaction_outcome(&self, _t: &SignedTransaction, block: &mut ExecutedBlock, receipt: &mut Receipt) -> Result<(), ::error::Error> { + match receipt.outcome { + TransactionOutcome::StatusCode(c) => { + if c == 0 { + return Err("Vote transaction failed.".into()); + } + }, + _ => panic!("Casper requires EIP658 to be enabled."), + } + + let mut metadata: HybridCasperMetadata = block.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + metadata.vote_gas_used = receipt.gas_used; + receipt.gas_used = block.receipts().last().map(|r| r.gas_used).unwrap_or_else(U256::zero); + block.set_metadata(Some(rlp::encode(&metadata).to_vec())); + + Ok(()) + } +} diff --git a/ethcore/src/engines/instant_seal.rs b/ethcore/src/engines/instant_seal.rs index a35dea5219a..6a0f1dbed57 100644 --- a/ethcore/src/engines/instant_seal.rs +++ b/ethcore/src/engines/instant_seal.rs @@ -69,6 +69,8 @@ impl Engine for InstantSeal } } +impl ::engines::EthEngine for InstantSeal<::machine::EthereumMachine> { } + #[cfg(test)] mod tests { use std::sync::Arc; diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 54a9dde2e64..183fe2a6003 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -26,6 +26,7 @@ mod transition; mod validator_set; mod vote_collector; +pub mod hybrid_casper; pub mod block_reward; pub mod epoch; @@ -55,12 +56,26 @@ use ethkey::Signature; use parity_machine::{Machine, LocalizedMachine as Localized, TotalScoredHeader}; use ethereum_types::{H256, U256, Address}; use unexpected::{Mismatch, OutOfBounds}; +use block::ExecutedBlock; use bytes::Bytes; use types::ancestry_action::AncestryAction; +use types::receipt::Receipt; /// Default EIP-210 contract code. /// As defined in https://github.com/ethereum/EIPs/pull/210 -pub const DEFAULT_BLOCKHASH_CONTRACT: &'static str = "73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b"; +pub const DEFAULT_BLOCKHASH_CONTRACT: &'static str = include!("../../res/code/blockhash.hex"); + +/// Hybrid Casper CASPER_CODE +pub const DEFAULT_CASPER_CONTRACT: &'static str = include!("../../res/code/simple_casper.hex"); + +/// Hybrid Casper PURITY_CHECKER_CODE +pub const DEFAULT_PURITY_CHECKER_CONTRACT: &'static str = include!("../../res/code/purity_checker.hex"); + +/// Hybrid Casper MSG_HASHER_CODE +pub const DEFAULT_MSG_HASHER_CONTRACT: &'static str = include!("../../res/code/msg_hasher.hex"); + +/// Hybrid Casper RLP_DECODER_CODE +pub const DEFAULT_RLP_DECODER_CONTRACT: &'static str = include!("../../res/code/rlp_decoder.hex"); /// Fork choice. #[derive(Debug, PartialEq, Eq)] @@ -448,7 +463,15 @@ pub trait EthEngine: Engine<::machine::EthereumMachine> { /// TODO: Add flags for which bits of the transaction to check. /// TODO: consider including State in the params. fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> { - self.machine().verify_transaction_basic(t, header) + self.machine().verify_transaction_basic(t, header, false) + } + + /// Prepare the environment information passed for transaction execution. + fn prepare_env_info(&self, _t: &SignedTransaction, _block: &ExecutedBlock, _env_info: &mut EnvInfo) { } + + /// Verify the transaction outcome is acceptable. + fn verify_transaction_outcome(&self, _t: &SignedTransaction, _block: &mut ExecutedBlock, _receipt: &mut Receipt) -> Result<(), Error> { + Ok(()) } /// Additional information. @@ -456,11 +479,13 @@ pub trait EthEngine: Engine<::machine::EthereumMachine> { self.machine().additional_params() } - /// Performs pre-validation of RLP decoded transaction before other processing + /// Performs pre-validation of RLP decoded transaction before other processing. fn decode_transaction(&self, transaction: &[u8]) -> Result { self.machine().decode_transaction(transaction) } -} -// convenience wrappers for existing functions. -impl EthEngine for T where T: Engine<::machine::EthereumMachine> { } + /// Whether the given transaction is considered a builtin service transaction. + fn is_builtin_service_transaction(&self, _t: &SignedTransaction, _header: &Header) -> bool { + false + } +} diff --git a/ethcore/src/engines/null_engine.rs b/ethcore/src/engines/null_engine.rs index f9e698307d5..02047cbdbd9 100644 --- a/ethcore/src/engines/null_engine.rs +++ b/ethcore/src/engines/null_engine.rs @@ -109,3 +109,5 @@ impl Engine for NullEngine super::total_difficulty_fork_choice(new, current) } } + +impl ::engines::EthEngine for NullEngine<::machine::EthereumMachine> { } diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index 967ef482a69..2627bfb2f2a 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -770,6 +770,8 @@ impl Engine for Tendermint { } } +impl ::engines::EthEngine for Tendermint { } + #[cfg(test)] mod tests { use std::str::FromStr; diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index b51da58fec6..663f3354cc7 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -20,16 +20,22 @@ use std::collections::BTreeMap; use std::sync::Arc; use hash::{KECCAK_EMPTY_LIST_RLP}; use engines::block_reward::{self, RewardKind}; +use engines::hybrid_casper::{HybridCasper, HybridCasperParams, HybridCasperMetadata}; use ethash::{quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor}; use ethereum_types::{H256, H64, U256, Address}; use unexpected::{OutOfBounds, Mismatch}; use block::*; use error::{BlockError, Error}; use header::{Header, BlockNumber, ExtendedHeader}; -use engines::{self, Engine}; +use engines::{self, Engine, EthEngine, ForkChoice}; use ethjson; -use rlp::Rlp; +use rlp::{self, Rlp}; +use transaction::{self, UnverifiedTransaction, SignedTransaction}; +use types::receipt::Receipt; use machine::EthereumMachine; +use parity_machine::WithMetadata; +use types::ancestry_action::AncestryAction; +use vm::EnvInfo; /// Number of blocks in an ethash snapshot. // make dependent on difficulty incrment divisor? @@ -124,6 +130,10 @@ pub struct EthashParams { pub expip2_transition: u64, /// EXPIP-2 duration limit pub expip2_duration_limit: u64, + /// Number of first block wehre Casper rules begin. + pub hybrid_casper_transition: u64, + /// Hybrid casper parameters. + pub hybrid_casper_params: HybridCasperParams, } impl From for EthashParams { @@ -154,6 +164,8 @@ impl From for EthashParams { eip649_reward: p.eip649_reward.map(Into::into), expip2_transition: p.expip2_transition.map_or(u64::max_value(), Into::into), expip2_duration_limit: p.expip2_duration_limit.map_or(30, Into::into), + hybrid_casper_transition: p.hybrid_casper_transition.map_or(u64::max_value(), Into::into), + hybrid_casper_params: p.hybrid_casper_params.map_or_else(Default::default, Into::into), } } } @@ -164,6 +176,7 @@ pub struct Ethash { ethash_params: EthashParams, pow: EthashManager, machine: EthereumMachine, + casper: Arc, } impl Ethash { @@ -171,10 +184,21 @@ impl Ethash { pub fn new>>( cache_dir: &Path, ethash_params: EthashParams, - machine: EthereumMachine, + mut machine: EthereumMachine, optimize_for: T, ) -> Arc { + let casper = Arc::new(HybridCasper::new(ethash_params.hybrid_casper_params.clone())); + let casper_c = casper.clone(); + let hybrid_casper_transition = ethash_params.hybrid_casper_transition; + + machine.set_schedule_creation_rules(Box::new(move |schedule, block_number| { + if block_number >= hybrid_casper_transition { + casper_c.enable_casper_schedule(schedule); + } + })); + Arc::new(Ethash { + casper, ethash_params, machine, pow: EthashManager::new(cache_dir.as_ref(), optimize_for.into()), @@ -222,6 +246,33 @@ impl Engine for Arc { header.set_difficulty(difficulty); } + fn on_new_block(&self, block: &mut ExecutedBlock, _epoch_begin: bool, _ancestry: &mut Iterator) -> Result<(), Error> { + if block.header().number() == self.ethash_params.hybrid_casper_transition { + self.casper.init_state(block.state_mut())?; + self.casper.init_casper_contract(&mut |address, data| { + self.machine().execute_as_system( + block, + address, + U256::max_value(), + Some(data) + ).map_err(|e| format!("{}", e)) + })?; + } + + if block.header().number() >= self.ethash_params.hybrid_casper_transition.saturating_add(self.ethash_params.hybrid_casper_params.warm_up_period) { + self.casper.on_new_epoch(block.header().number(), &mut |address, data| { + self.machine().execute_as_system( + block, + address, + U256::max_value(), + Some(data) + ).map_err(|e| format!("{}", e)) + })?; + } + + Ok(()) + } + /// Apply the block reward on finalisation of the block. /// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current). fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> { @@ -277,6 +328,20 @@ impl Engine for Arc { rewards.push((*uncle_author, RewardKind::Uncle, result_uncle_reward)); } + // Write closing metadata for Casper. + if number >= self.ethash_params.hybrid_casper_transition { + let mut metadata: HybridCasperMetadata = block.metadata().map(|d| rlp::decode(d).expect("Metadata is only set by serializing CasperMetadata struct; deserializing CasperMetadata RLP always succeeds; qed")).unwrap_or_else(Default::default); + self.casper.update_metadata(&mut metadata, &mut |address, data| { + self.machine().execute_as_system( + block, + address, + U256::max_value(), + Some(data) + ).map_err(|e| format!("{}", e)) + })?; + block.set_metadata(Some(rlp::encode(&metadata).to_vec())); + } + block_reward::apply_block_rewards(&rewards, block, &self.machine) } @@ -357,8 +422,55 @@ impl Engine for Arc { Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS))) } - fn fork_choice(&self, new: &ExtendedHeader, current: &ExtendedHeader) -> engines::ForkChoice { - engines::total_difficulty_fork_choice(new, current) + fn fork_choice(&self, new: &ExtendedHeader, current: &ExtendedHeader) -> ForkChoice { + self.casper.fork_choice(new, current) + } + + fn ancestry_actions(&self, block: &ExecutedBlock, _ancestry: &mut Iterator) -> Vec { + self.casper.ancestry_actions(block) + } +} + +impl EthEngine for Arc { + fn verify_transaction_unordered(&self, t: UnverifiedTransaction, header: &Header) -> Result { + let signed = self.machine().verify_transaction_unordered(t, header)?; + + if header.number() >= self.ethash_params.hybrid_casper_transition { + if signed.is_unsigned() && !self.casper.is_vote_transaction(&signed) { + return Err(transaction::Error::NotAllowed); + } + } + + Ok(signed) + } + + fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> { + self.machine().verify_transaction_basic(t, header, header.number() >= self.ethash_params.hybrid_casper_transition) + } + + fn prepare_env_info(&self, t: &SignedTransaction, block: &ExecutedBlock, env_info: &mut EnvInfo) { + if block.header().number() >= self.ethash_params.hybrid_casper_transition { + if t.is_unsigned() { + self.casper.prepare_vote_transaction_env_info(t, block, env_info); + } + } + } + + fn verify_transaction_outcome(&self, t: &SignedTransaction, block: &mut ExecutedBlock, receipt: &mut Receipt) -> Result<(), Error> { + if block.header().number() >= self.ethash_params.hybrid_casper_transition { + if t.is_unsigned() { + self.casper.verify_vote_transaction_outcome(t, block, receipt)?; + } + } + Ok(()) + } + + fn is_builtin_service_transaction(&self, t: &SignedTransaction, header: &Header) -> bool { + if header.number() >= self.ethash_params.hybrid_casper_transition { + self.casper.is_vote_transaction(t) + } else { + false + } } } @@ -524,6 +636,8 @@ mod tests { eip649_reward: None, expip2_transition: u64::max_value(), expip2_duration_limit: 30, + hybrid_casper_transition: u64::max_value(), + hybrid_casper_params: Default::default(), } } diff --git a/ethcore/src/machine.rs b/ethcore/src/machine.rs index dbf66aa1217..400a7e7177d 100644 --- a/ethcore/src/machine.rs +++ b/ethcore/src/machine.rs @@ -323,7 +323,7 @@ impl EthereumMachine { } /// Does basic verification of the transaction. - pub fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> { + pub fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header, allow_null_signer: bool) -> Result<(), transaction::Error> { let check_low_s = match self.ethash_extensions { Some(ref ext) => header.number() >= ext.homestead_transition, None => true, @@ -336,7 +336,7 @@ impl EthereumMachine { } else { None }; - t.verify_basic(check_low_s, chain_id, false)?; + t.verify_basic(check_low_s, chain_id, allow_null_signer)?; Ok(()) } @@ -500,7 +500,7 @@ mod tests { let mut header = ::header::Header::new(); header.set_number(15); - let res = machine.verify_transaction_basic(&transaction, &header); + let res = machine.verify_transaction_basic(&transaction, &header, false); assert_eq!(res, Err(transaction::Error::InvalidSignature("Crypto error (Invalid EC signature)".into()))); } diff --git a/ethcore/src/miner/pool_client.rs b/ethcore/src/miner/pool_client.rs index 226fe21e293..c729820a978 100644 --- a/ethcore/src/miner/pool_client.rs +++ b/ethcore/src/miner/pool_client.rs @@ -135,13 +135,17 @@ impl<'a, C: 'a> pool::client::Client for PoolClient<'a, C> where fn transaction_type(&self, tx: &SignedTransaction) -> pool::client::TransactionType { match self.service_transaction_checker { None => pool::client::TransactionType::Regular, - Some(ref checker) => match checker.check(self.chain, &tx) { - Ok(true) => pool::client::TransactionType::Service, - Ok(false) => pool::client::TransactionType::Regular, - Err(e) => { - debug!(target: "txqueue", "Unable to verify service transaction: {:?}", e); - pool::client::TransactionType::Regular - }, + Some(ref checker) => if self.engine.is_builtin_service_transaction(tx, &self.best_block_header) { + pool::client::TransactionType::Service + } else { + match checker.check(self.chain, &tx) { + Ok(true) => pool::client::TransactionType::Service, + Ok(false) => pool::client::TransactionType::Regular, + Err(e) => { + debug!(target: "txqueue", "Unable to verify service transaction: {:?}", e); + pool::client::TransactionType::Regular + }, + } } } } diff --git a/json/src/spec/ethash.rs b/json/src/spec/ethash.rs index 19fd0966273..bddb647122b 100644 --- a/json/src/spec/ethash.rs +++ b/json/src/spec/ethash.rs @@ -18,6 +18,7 @@ use uint::{self, Uint}; use hash::Address; +use super::HybridCasperParams; /// Deserializable doppelganger of EthashParams. #[derive(Clone, Debug, PartialEq, Deserialize)] @@ -122,6 +123,13 @@ pub struct EthashParams { /// EXPIP-2 duration limit #[serde(rename="expip2DurationLimit")] pub expip2_duration_limit: Option, + + /// EIP1011 transition block + #[serde(rename="hybridCasperTransition")] + pub hybrid_casper_transition: Option, + /// EIP1011 parameters + #[serde(rename="hybridCasperParams")] + pub hybrid_casper_params: Option, } /// Ethash engine deserialization. @@ -232,6 +240,8 @@ mod tests { eip649_reward: None, expip2_transition: None, expip2_duration_limit: None, + hybrid_casper_transition: None, + hybrid_casper_params: None, } }); } @@ -276,6 +286,8 @@ mod tests { eip649_reward: None, expip2_transition: None, expip2_duration_limit: None, + hybrid_casper_transition: None, + hybrid_casper_params: None, } }); } diff --git a/json/src/spec/hybrid_casper.rs b/json/src/spec/hybrid_casper.rs new file mode 100644 index 00000000000..f47366a85c8 --- /dev/null +++ b/json/src/spec/hybrid_casper.rs @@ -0,0 +1,64 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Hybrid Casper spec deserialization. + +use uint::Uint; +use hash::Address; +use bytes::Bytes; + +/// Hybrid Casper params deserialization. +#[derive(Clone, Debug, Default, PartialEq, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct HybridCasperParams { + /// Main contract code. + pub contract_code: Option, + /// Address to deploy the main contract. + pub contract_address: Option
, + /// Balance to force set in the beginning. + pub contract_balance: Option, + /// Purity checker contract code. + pub purity_checker_contract_code: Option, + /// Address to deploy the purity checker. + pub purity_checker_contract_address: Option
, + /// Msg hasher contract code. + pub msg_hasher_contract_code: Option, + /// Address to deploy the msg hasher. + pub msg_hasher_contract_address: Option
, + /// RLP decoder contract code. + pub rlp_decoder_contract_code: Option, + /// Address to deploy the RLP decoder. + pub rlp_decoder_contract_address: Option
, + /// Whether force-deploying the RLP decoder or not. + pub deploy_rlp_decoder: Option, + + /// Casper epoch length. + pub epoch_length: Option, + /// Casper withdrawal delay. + pub withdrawal_delay: Option, + /// Casper dynasty logout delay. + pub dynasty_logout_delay: Option, + /// Base interest factor passed to the Casper init function. + pub base_interest_factor: Option, + /// Base penalty factor passed to the Casper init function. + pub base_penalty_factor: Option, + /// Min deposit size accepted by Casper. + pub min_deposit_size: Option, + /// Warm up period before vote begins. + pub warm_up_period: Option, + /// Min deposit to consider a block to be justified. + pub non_revert_min_deposits: Option, +} diff --git a/json/src/spec/mod.rs b/json/src/spec/mod.rs index 26965c887d0..54a45e8cac6 100644 --- a/json/src/spec/mod.rs +++ b/json/src/spec/mod.rs @@ -31,6 +31,7 @@ pub mod authority_round; pub mod tendermint; pub mod null_engine; pub mod hardcoded_sync; +pub mod hybrid_casper; pub use self::account::Account; pub use self::builtin::{Builtin, Pricing, Linear}; @@ -47,3 +48,4 @@ pub use self::authority_round::{AuthorityRound, AuthorityRoundParams}; pub use self::tendermint::{Tendermint, TendermintParams}; pub use self::null_engine::{NullEngine, NullEngineParams}; pub use self::hardcoded_sync::HardcodedSync; +pub use self::hybrid_casper::HybridCasperParams; diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index 6e93132b922..235287ed3e8 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -347,6 +347,10 @@ impl Parity for ParityClient { Err(errors::light_unimplemented(None)) } + fn send_unsigned_transaction(&self, _: H160, _: Bytes) -> Result { + Err(errors::light_unimplemented(None)) + } + fn chain_id(&self) -> Result> { Ok(self.client.signing_chain_id().map(U64::from)) } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index d7c26014edd..29f9c0095be 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -32,6 +32,7 @@ use ethcore::ids::BlockId; use ethcore::miner::{self, MinerService}; use ethcore::state::StateInfo; use ethcore_logger::RotatingLogger; +use transaction::{Transaction as CoreTransaction, Action as TransactionAction}; use node_health::{NodeHealth, Health}; use updater::{Service as UpdateService}; @@ -39,6 +40,7 @@ use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings}; +use v1::helpers::dispatch::FullDispatcher; use v1::metadata::Metadata; use v1::traits::Parity; use v1::types::{ @@ -199,6 +201,27 @@ impl Parity for ParityClient where Ok(self.client.spec_name()) } + fn send_unsigned_transaction(&self, to: H160, data: Bytes) -> Result { + use ethereum_types::{U256 as CoreU256}; + + let transaction = CoreTransaction { + nonce: CoreU256::zero(), + value: CoreU256::zero(), + gas_price: CoreU256::zero(), + gas: CoreU256::from(940000), + action: TransactionAction::Call(to.into()), + data: data.into() + }; + + let signed = transaction.null_sign(self.client.signing_chain_id().unwrap_or(0)); + + FullDispatcher::dispatch_transaction( + &*self.client, + &*self.miner, + signed.into(), + ).map(Into::into) + } + fn net_peers(&self) -> Result { let sync_status = self.sync.status(); let num_peers_range = self.net.num_peers_range(); diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 1b9a7d09f5b..916c3af1105 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -56,6 +56,10 @@ build_rpc_trait! { #[rpc(name = "parity_transactionsLimit")] fn transactions_limit(&self) -> Result; + /// Submit a raw unsigned EIP86 transaction locally. + #[rpc(name = "parity_sendUnsignedTransaction")] + fn send_unsigned_transaction(&self, H160, Bytes) -> Result; + /// Returns mining extra data. #[rpc(name = "parity_extraData")] fn extra_data(&self) -> Result;