From c69d115965bc57d238d021414c69f0604df7a360 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 6 Jun 2021 09:34:18 +0200 Subject: [PATCH] Introduce sim example --- .../data/DemurrageTokenMultiCap.bin | 2 +- python/erc20_demurrage_token/sim/sim.py | 76 ++++++++++++----- python/erc20_demurrage_token/token.py | 50 +++++++++++ python/examples/sim.py | 76 +++++++++++++++++ python/tests/base.py | 48 +++++++++++ python/tests/sim/tests_sim.py | 2 +- python/tests/test_redistribution.py | 3 +- python/tests/test_redistribution_real.py | 84 +++++++++++++++++++ solidity/DemurrageTokenMultiCap.sol | 6 +- 9 files changed, 323 insertions(+), 24 deletions(-) create mode 100644 python/examples/sim.py create mode 100644 python/tests/test_redistribution_real.py diff --git a/python/erc20_demurrage_token/data/DemurrageTokenMultiCap.bin b/python/erc20_demurrage_token/data/DemurrageTokenMultiCap.bin index 2214fe0..a5696a8 100644 --- a/python/erc20_demurrage_token/data/DemurrageTokenMultiCap.bin +++ b/python/erc20_demurrage_token/data/DemurrageTokenMultiCap.bin @@ -1 +1 @@ -60e06040523480156200001157600080fd5b5060405162003d6c38038062003d6c833981810160405281019062000037919062000496565b33600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555086600590805190602001906200010a9291906200032f565b508560069080519060200190620001239291906200032f565b508460ff166007819055504260808181525050603c836200014591906200076c565b60a08181525050620f42406d04ee2d6d415b85acef81000000006200016b91906200076c565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600260106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360c0818152505060006200020a6000620f424060006001620002a3640100000000026401000000009004565b905060008190806001815401808255809150506001900390600052602060002001600090919091909150558160098190555082600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508560ff16600a6200028f91906200062f565b600a819055505050505050505050620009b3565b60008073fffff00000000000000000000000000000000000608c60ff16869060020a021660010281179050710fffffffff00000000000000000000000000606860ff16879060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b8280546200033d906200084e565b90600052602060002090601f016020900481019282620003615760008555620003ad565b82601f106200037c57805160ff1916838001178555620003ad565b82800160010185558215620003ad579182015b82811115620003ac5782518255916020019190600101906200038f565b5b509050620003bc9190620003c0565b5090565b5b80821115620003db576000816000905550600101620003c1565b5090565b6000620003f6620003f0846200059e565b62000575565b9050828152602081018484840111156200040f57600080fd5b6200041c84828562000818565b509392505050565b600081519050620004358162000965565b92915050565b600082601f8301126200044d57600080fd5b81516200045f848260208601620003df565b91505092915050565b60008151905062000479816200097f565b92915050565b600081519050620004908162000999565b92915050565b600080600080600080600060e0888a031215620004b257600080fd5b600088015167ffffffffffffffff811115620004cd57600080fd5b620004db8a828b016200043b565b975050602088015167ffffffffffffffff811115620004f957600080fd5b620005078a828b016200043b565b96505060406200051a8a828b016200047f565b95505060606200052d8a828b0162000468565b9450506080620005408a828b0162000468565b93505060a0620005538a828b0162000424565b92505060c0620005668a828b0162000468565b91505092959891949750929550565b60006200058162000594565b90506200058f828262000884565b919050565b6000604051905090565b600067ffffffffffffffff821115620005bc57620005bb62000918565b5b620005c78262000947565b9050602081019050919050565b6000808291508390505b60018511156200062657808604811115620005fe57620005fd620008ba565b5b60018516156200060e5780820291505b80810290506200061e8562000958565b9450620005de565b94509492505050565b60006200063c8262000801565b9150620006498362000801565b9250620006787fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000680565b905092915050565b60008262000692576001905062000765565b81620006a2576000905062000765565b8160018114620006bb5760028114620006c657620006fc565b600191505062000765565b60ff841115620006db57620006da620008ba565b5b8360020a915084821115620006f557620006f4620008ba565b5b5062000765565b5060208310610133831016604e8410600b8410161715620007365782820a90508381111562000730576200072f620008ba565b5b62000765565b620007458484846001620005d4565b925090508184048111156200075f576200075e620008ba565b5b81810290505b9392505050565b6000620007798262000801565b9150620007868362000801565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620007c257620007c1620008ba565b5b828202905092915050565b6000620007da82620007e1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015620008385780820151818401526020810190506200081b565b8381111562000848576000848401525b50505050565b600060028204905060018216806200086757607f821691505b602082108114156200087e576200087d620008e9565b5b50919050565b6200088f8262000947565b810181811067ffffffffffffffff82111715620008b157620008b062000918565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6000600282049050919050565b6200097081620007cd565b81146200097c57600080fd5b50565b6200098a8162000801565b81146200099657600080fd5b50565b620009a4816200080b565b8114620009b057600080fd5b50565b60805160a05160c05161334a62000a2260003960008181610cd101528181610f2c015281816110bd01528181611def0152818161247101526124a90152600081816113bc01528181611d9d0152611e8a0152600081816113e801528181611eab0152611ef0015261334a6000f3fe608060405234801561001057600080fd5b5060043610610265576000357c0100000000000000000000000000000000000000000000000000000000900480636a2d094e11610158578063983b2d56116100d5578063e3ab207a11610099578063e3ab207a146107ec578063e54d63f71461081c578063e80952951461084c578063eda4e6d61461086a578063f2fde38b1461088857610265565b8063983b2d56146107205780639da7d8ba14610750578063a2119e2f14610780578063a9059cbb1461079e578063b470aade146107ce57610265565b806379ba50971161011c57806379ba50971461068a5780638da5cb5b146106a85780638f1df6bc146106c65780638f770ad0146106e457806395d89b411461070257610265565b80636a2d094e146105ac5780636d5055a6146105dc5780636ffa8a051461060c57806370a082311461063c578063731f237c1461066c57610265565b806331333487116101e6578063449a52f8116101aa578063449a52f8146104ce57806347a50517146104fe5780634abfbba21461052e578063573cc5071461055e5780636787a9be1461057c57610265565b806331333487146103f0578063313ce5671461042057806335b16eb81461043e57806340452d911461046e57806340fc89f51461049e57610265565b80631989c6a81161022d5780631989c6a814610324578063216ea5ec14610342578063229ba1971461037257806323b872dd146103905780633092afd5146103c057610265565b806301ffc9a71461026a57806306fdde031461029a578063095ea7b3146102b857806309f28f3c146102e857806318160ddd14610306575b600080fd5b610284600480360381019061027f9190612bf2565b6108b8565b6040516102919190612dc0565b60405180910390f35b6102a2610a63565b6040516102af9190612df6565b60405180910390f35b6102d260048036038101906102cd9190612b8d565b610af1565b6040516102df9190612dc0565b60405180910390f35b6102f0610c15565b6040516102fd9190612e78565b60405180910390f35b61030e610c37565b60405161031b9190612eae565b60405180910390f35b61032c610c3d565b6040516103399190612eae565b60405180910390f35b61035c60048036038101906103579190612c6d565b610c49565b6040516103699190612eae565b60405180910390f35b61037a610ccf565b6040516103879190612eae565b60405180910390f35b6103aa60048036038101906103a59190612b3e565b610cf3565b6040516103b79190612dc0565b60405180910390f35b6103da60048036038101906103d59190612b15565b610e1d565b6040516103e79190612dc0565b60405180910390f35b61040a60048036038101906104059190612c6d565b610f10565b6040516104179190612eae565b60405180910390f35b610428610fc1565b6040516104359190612eae565b60405180910390f35b61045860048036038101906104539190612b15565b610fc7565b6040516104659190612dc0565b60405180910390f35b61048860048036038101906104839190612c44565b6111ed565b6040516104959190612ddb565b60405180910390f35b6104b860048036038101906104b39190612bc9565b611211565b6040516104c59190612eae565b60405180910390f35b6104e860048036038101906104e39190612b8d565b611242565b6040516104f59190612dc0565b60405180910390f35b61051860048036038101906105139190612b15565b611360565b6040516105259190612eae565b60405180910390f35b61054860048036038101906105439190612c44565b6113b8565b6040516105559190612eae565b60405180910390f35b610566611418565b6040516105739190612eae565b60405180910390f35b61059660048036038101906105919190612c44565b61141e565b6040516105a39190612eae565b60405180910390f35b6105c660048036038101906105c19190612c44565b61148a565b6040516105d39190612eae565b60405180910390f35b6105f660048036038101906105f19190612b15565b6114ab565b6040516106039190612eae565b60405180910390f35b61062660048036038101906106219190612bc9565b611516565b6040516106339190612eae565b60405180910390f35b61065660048036038101906106519190612b15565b611549565b6040516106639190612eae565b60405180910390f35b61067461162a565b6040516106819190612dc0565b60405180910390f35b6106926117d8565b60405161069f9190612dc0565b60405180910390f35b6106b061197f565b6040516106bd9190612da5565b60405180910390f35b6106ce6119a5565b6040516106db9190612dc0565b60405180910390f35b6106ec611b5c565b6040516106f99190612eae565b60405180910390f35b61070a611b62565b6040516107179190612df6565b60405180910390f35b61073a60048036038101906107359190612b15565b611bf0565b6040516107479190612dc0565b60405180910390f35b61076a60048036038101906107659190612bc9565b611cad565b6040516107779190612eae565b60405180910390f35b610788611cd9565b6040516107959190612e78565b60405180910390f35b6107b860048036038101906107b39190612b8d565b611cfb565b6040516107c59190612dc0565b60405180910390f35b6107d6611d9b565b6040516107e39190612eae565b60405180910390f35b61080660048036038101906108019190612bc9565b611dbf565b6040516108139190612eae565b60405180910390f35b61083660048036038101906108319190612c6d565b611dd3565b6040516108439190612eae565b60405180910390f35b610854611e84565b6040516108619190612e78565b60405180910390f35b610872611eee565b60405161087f9190612eae565b60405180910390f35b6108a2600480360381019061089d9190612b15565b611f12565b6040516108af9190612dc0565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561090d5760019050610a5e565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109605760019050610a5e565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109b35760019050610a5e565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a065760019050610a5e565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a595760019050610a5e565b600090505b919050565b60058054610a709061310d565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9c9061310d565b8015610ae95780601f10610abe57610100808354040283529160200191610ae9565b820191906000526020600020905b815481529060010190602001808311610acc57829003601f168201915b505050505081565b600080610afc6119a5565b50610b0633610fc7565b50610b108361141e565b905080600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b9e9190612ee5565b925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051610c029190612eae565b60405180910390a3600191505092915050565b600260009054906101000a90046fffffffffffffffffffffffffffffffff1681565b60085481565b60008080549050905090565b600080600080851415610c91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8890612e18565b60405180910390fd5b838510610c9d57600080fd5b8484610ca99190612f3b565b91508482610cb79190612f6c565b90508084610cc59190612ffa565b9250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000610d006119a5565b50610d0a33610fc7565b50610d148461141e565b915081600c60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610d9f57600080fd5b610daa868684611fb4565b90508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610e099190612eae565b60405180910390a380925050509392505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610ea657503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b610eaf57600080fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000610f559190612f3b565b905060005b84811015610f9c57620f42408284610f729190612f6c565b610f7c9190612f3b565b83610f879190612ffa565b92508080610f949061313f565b915050610f5a565b50620f42408583610fad9190612f6c565b610fb79190612f3b565b9250505092915050565b60075481565b600080600080600080600080610fdc896114ab565b915060008214806110065750610ff0611e84565b6fffffffffffffffffffffffffffffffff168210155b1561101b5760009750505050505050506111e8565b600060018361102a9190612ffa565b81548110611061577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154965061107787611211565b945060008514156110925760009750505050505050506111e8565b61109b87611cad565b95506110a687611516565b90506d04ee2d6d415b85acef8100000000620f42407f00000000000000000000000000000000000000000000000000000000000000006110e69190612f3b565b86886110f29190612f3b565b6110fc9190612f6c565b6111069190612f3b565b9350620f424081856111189190612f6c565b6111229190612f3b565b92506cffffffff00000000000000000019600102600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254169250508190555061118c8984612058565b50818973ffffffffffffffffffffffffffffffffffffffff167f9a2a887706623ad3ff7fc85652deeceabe9fe1e00466c597972079ee91ea40d3856040516111d49190612eae565b60405180910390a360019750505050505050505b919050565b600081815481106111fd57600080fd5b906000526020600020016000915090505481565b6000606860ff16710fffffffff00000000000000000000000000836001900416908060020a82049150509050919050565b600080600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661129b57600080fd5b600954600854846112ac9190612ee5565b11156112b757600080fd5b6112bf6119a5565b5082905082600860008282546112d59190612ee5565b925050819055506112e68482612058565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8856040516113449190612eae565b60405180910390a36113546121b4565b50600191505092915050565b600068ffffffffffffffffff600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004169050919050565b60007f0000000000000000000000000000000000000000000000000000000000000000826113e69190612f6c565b7f00000000000000000000000000000000000000000000000000000000000000006114119190612ee5565b9050919050565b600a5481565b6000600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16620f42406d04ee2d6d415b85acef81000000008461146f9190612f6c565b6114799190612f6c565b6114839190612f3b565b9050919050565b6000603c824261149a9190612ffa565b6114a49190612f3b565b9050919050565b6000604860ff166cffffffff000000000000000000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546001900416908060020a82049150509050919050565b6000608c60ff1673fffff00000000000000000000000000000000000836001900416908060020a82049150509050919050565b60008060008061155885611360565b9250600260109054906101000a90046fffffffffffffffffffffffffffffffff16611581611e84565b61158b9190612fc6565b6fffffffffffffffffffffffffffffffff1690506115d9600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1682610f10565b6fffffffffffffffffffffffffffffffff169150620f42406d04ee2d6d415b85acef810000000061160a9190612f6c565b82846116169190612f6c565b6116209190612f3b565b9350505050919050565b600080600080600061163a611e84565b9350600260109054906101000a90046fffffffffffffffffffffffffffffffff16846116669190612fc6565b92506000836fffffffffffffffffffffffffffffffff1614156116905760009450505050506117d5565b600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1691506116df82846fffffffffffffffffffffffffffffffff16610f10565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555083600260106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555081836fffffffffffffffffffffffffffffffff16856fffffffffffffffffffffffffffffffff167fa0717e54e02bd9829db5e6e998aec0ae9de796b8d150a3cc46a92ab869697755600260009054906101000a90046fffffffffffffffffffffffffffffffff166040516117c49190612e93565b60405180910390a460019450505050505b90565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461183557600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060008060008060008060006119be61229c565b995060006001028a14156119df5760009a5050505050505050505050611b59565b6119e88a611dbf565b97506001886119f79190612ee5565b9050611a02886113b8565b9150611a0c61162a565b50600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169450611a498261148a565b92506000831115611a7e576d04ee2d6d415b85acef8100000000611a6d8685611dd3565b611a779190612f3b565b9350611a9b565b6d04ee2d6d415b85acef810000000085611a989190612f3b565b93505b611aaa600085600854846123cc565b98506000899080600181540180825580915050600190039060005260206000200160009091909190915055611ade8a611211565b96506000871415611af957611af28a612458565b9550611b13565b611b0587600854610c49565b9550611b11868961264b565b505b7f55d243082e019fce4009ccea5368b92e436c17586a1e793c7deda16df4e5d67581604051611b429190612eae565b60405180910390a160019a50505050505050505050505b90565b60095481565b60068054611b6f9061310d565b80601f0160208091040260200160405190810160405280929190818152602001828054611b9b9061310d565b8015611be85780601f10611bbd57610100808354040283529160200191611be8565b820191906000526020600020905b815481529060010190602001808311611bcb57829003601f168201915b505050505081565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c4c57600080fd5b6001600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000602060ff166cffffffffffffffffff00000000836001900416908060020a82049150509050919050565b600260109054906101000a90046fffffffffffffffffffffffffffffffff1681565b6000806000611d086119a5565b50611d1233610fc7565b50611d1c8461141e565b9150611d29338684611fb4565b90508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051611d889190612eae565b60405180910390a3809250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600063ffffffff8260019004169050919050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000611e189190612f3b565b905060005b84811015611e5f57620f42408284611e359190612f6c565b611e3f9190612f3b565b83611e4a9190612ee5565b92508080611e579061313f565b915050611e1d565b50620f42408583611e709190612f6c565b611e7a9190612f3b565b9250505092915050565b600060017f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000042611ed59190612ffa565b611edf9190612f3b565b611ee99190612ee5565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f6e57600080fd5b81600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080611fc18584612781565b50611fcc8484612058565b50611fd5611e84565b6fffffffffffffffffffffffffffffffff169050600a548310158015612003575080612000866114ab565b14155b801561203b57508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561204c5761204a85826128b2565b505b60019150509392505050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004905060008514156120b957600093505050506121ae565b6120c286611360565b925084836120d09190612ee5565b91508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1611612140576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213790612e58565b60405180910390fd5b68ffffffffffffffffff198116905068ffffffffffffffffff82168117905080600102600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b600080600060016000805490506121cb9190612ffa565b81548110612202577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546001900490506cffffffffffffffffff000000001981169050602060ff166008549060020a0281179050806001026000600160008054905061224f9190612ffa565b81548110612286577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550600191505090565b60008060008060016000805490506122b49190612ffa565b815481106122eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015491503073ffffffffffffffffffffffffffffffffffffffff1663e80952956040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801561235a57600080fd5b505afa15801561236e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123929190612c1b565b6fffffffffffffffffffffffffffffffff1690506123af82611dbf565b81116123c3576000600102925050506123c9565b81925050505b90565b60008073fffff00000000000000000000000000000000000608c60ff16869060020a021660010281179050710fffffffff00000000000000000000000000606860ff16879060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b600080600080600061246986611cad565b9350620f42407f00000000000000000000000000000000000000000000000000000000000000008561249b9190612f6c565b6124a59190612f3b565b91507f0000000000000000000000000000000000000000000000000000000000000000620f4240836124d79190612f6c565b6124e19190612f3b565b9050838110156125f9576124f486611dbf565b9250710fffffffff0000000000000000000000000019600102600060018561251c9190612ffa565b81548110612553577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160008282541692505081905550606860ff1660019060020a027f80000000000000000000000000000000000000000000000000000000000000001760010260006001856125aa9190612ffa565b815481106125e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001600082825417925050819055505b61263e600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166d04ee2d6d415b85acef8100000000846126399190612f3b565b612058565b5081945050505050919050565b600080600084141561266157600091505061277b565b7f800000000000000000000000000000000000000000000000000000000000000060010260006001856126949190612ffa565b815481106126cb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020016000828254179250508190555061273b60006001856126f49190612ffa565b8154811061272b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154611cad565b9050612774600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16858361276f9190612ffa565b612058565b5060019150505b92915050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004905060008514156127e257600093505050506128ac565b6127eb86611360565b925084831015612830576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282790612e38565b60405180910390fd5b848361283c9190612ffa565b915068ffffffffffffffffff198116905068ffffffffffffffffff82168117905080600102600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b60006cffffffff00000000000000000019600102600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825416925050819055506cffffffff000000000000000000604860ff16839060020a0216600102600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254179250508190555061298361298e565b506001905092915050565b600080600080600060016000805490506129a89190612ffa565b815481106129df577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154925060016129f784611211565b612a019190612ee5565b905082600190049150710fffffffff000000000000000000000000001982169150710fffffffff00000000000000000000000000606860ff16829060020a0216821791508160010260006001600080549050612a5d9190612ffa565b81548110612a94577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506001935050505090565b600081359050612abb816132a1565b92915050565b600081359050612ad0816132b8565b92915050565b600081359050612ae5816132cf565b92915050565b600081519050612afa816132e6565b92915050565b600081359050612b0f816132fd565b92915050565b600060208284031215612b2757600080fd5b6000612b3584828501612aac565b91505092915050565b600080600060608486031215612b5357600080fd5b6000612b6186828701612aac565b9350506020612b7286828701612aac565b9250506040612b8386828701612b00565b9150509250925092565b60008060408385031215612ba057600080fd5b6000612bae85828601612aac565b9250506020612bbf85828601612b00565b9150509250929050565b600060208284031215612bdb57600080fd5b6000612be984828501612ac1565b91505092915050565b600060208284031215612c0457600080fd5b6000612c1284828501612ad6565b91505092915050565b600060208284031215612c2d57600080fd5b6000612c3b84828501612aeb565b91505092915050565b600060208284031215612c5657600080fd5b6000612c6484828501612b00565b91505092915050565b60008060408385031215612c8057600080fd5b6000612c8e85828601612b00565b9250506020612c9f85828601612b00565b9150509250929050565b612cb28161302e565b82525050565b612cc181613040565b82525050565b612cd08161304c565b82525050565b6000612ce182612ec9565b612ceb8185612ed4565b9350612cfb8185602086016130da565b612d0481613215565b840191505092915050565b6000612d1c601183612ed4565b9150612d2782613226565b602082019050919050565b6000612d3f600d83612ed4565b9150612d4a8261324f565b602082019050919050565b6000612d62600d83612ed4565b9150612d6d82613278565b602082019050919050565b612d8181613082565b82525050565b612d90816130c8565b82525050565b612d9f816130be565b82525050565b6000602082019050612dba6000830184612ca9565b92915050565b6000602082019050612dd56000830184612cb8565b92915050565b6000602082019050612df06000830184612cc7565b92915050565b60006020820190508181036000830152612e108184612cd6565b905092915050565b60006020820190508181036000830152612e3181612d0f565b9050919050565b60006020820190508181036000830152612e5181612d32565b9050919050565b60006020820190508181036000830152612e7181612d55565b9050919050565b6000602082019050612e8d6000830184612d78565b92915050565b6000602082019050612ea86000830184612d87565b92915050565b6000602082019050612ec36000830184612d96565b92915050565b600081519050919050565b600082825260208201905092915050565b6000612ef0826130be565b9150612efb836130be565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f3057612f2f613188565b5b828201905092915050565b6000612f46826130be565b9150612f51836130be565b925082612f6157612f606131b7565b5b828204905092915050565b6000612f77826130be565b9150612f82836130be565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612fbb57612fba613188565b5b828202905092915050565b6000612fd182613082565b9150612fdc83613082565b925082821015612fef57612fee613188565b5b828203905092915050565b6000613005826130be565b9150613010836130be565b92508282101561302357613022613188565b5b828203905092915050565b60006130398261309e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006130d382613082565b9050919050565b60005b838110156130f85780820151818401526020810190506130dd565b83811115613107576000848401525b50505050565b6000600282049050600182168061312557607f821691505b60208210811415613139576131386131e6565b5b50919050565b600061314a826130be565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561317d5761317c613188565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f4552525f4e554d50415254535f5a45524f000000000000000000000000000000600082015250565b7f4552525f4f5645525350454e4400000000000000000000000000000000000000600082015250565b7f4552525f574f554c445752415000000000000000000000000000000000000000600082015250565b6132aa8161302e565b81146132b557600080fd5b50565b6132c18161304c565b81146132cc57600080fd5b50565b6132d881613056565b81146132e357600080fd5b50565b6132ef81613082565b81146132fa57600080fd5b50565b613306816130be565b811461331157600080fd5b5056fea2646970667358221220c5feb6b1114a2cab184be4920704db0d3d14a87b8c092f786f96263d39c1457b64736f6c63430008040033 \ No newline at end of file +60e06040523480156200001157600080fd5b5060405162003d6c38038062003d6c833981810160405281019062000037919062000496565b33600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555086600590805190602001906200010a9291906200032f565b508560069080519060200190620001239291906200032f565b508460ff166007819055504260808181525050603c836200014591906200076c565b60a08181525050620f42406d04ee2d6d415b85acef81000000006200016b91906200076c565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600260106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360c0818152505060006200020a6000620f424060006001620002a3640100000000026401000000009004565b905060008190806001815401808255809150506001900390600052602060002001600090919091909150558160098190555082600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508560ff16600a6200028f91906200062f565b600a819055505050505050505050620009b3565b60008073fffff00000000000000000000000000000000000608c60ff16869060020a021660010281179050710fffffffff00000000000000000000000000606860ff16879060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b8280546200033d906200084e565b90600052602060002090601f016020900481019282620003615760008555620003ad565b82601f106200037c57805160ff1916838001178555620003ad565b82800160010185558215620003ad579182015b82811115620003ac5782518255916020019190600101906200038f565b5b509050620003bc9190620003c0565b5090565b5b80821115620003db576000816000905550600101620003c1565b5090565b6000620003f6620003f0846200059e565b62000575565b9050828152602081018484840111156200040f57600080fd5b6200041c84828562000818565b509392505050565b600081519050620004358162000965565b92915050565b600082601f8301126200044d57600080fd5b81516200045f848260208601620003df565b91505092915050565b60008151905062000479816200097f565b92915050565b600081519050620004908162000999565b92915050565b600080600080600080600060e0888a031215620004b257600080fd5b600088015167ffffffffffffffff811115620004cd57600080fd5b620004db8a828b016200043b565b975050602088015167ffffffffffffffff811115620004f957600080fd5b620005078a828b016200043b565b96505060406200051a8a828b016200047f565b95505060606200052d8a828b0162000468565b9450506080620005408a828b0162000468565b93505060a0620005538a828b0162000424565b92505060c0620005668a828b0162000468565b91505092959891949750929550565b60006200058162000594565b90506200058f828262000884565b919050565b6000604051905090565b600067ffffffffffffffff821115620005bc57620005bb62000918565b5b620005c78262000947565b9050602081019050919050565b6000808291508390505b60018511156200062657808604811115620005fe57620005fd620008ba565b5b60018516156200060e5780820291505b80810290506200061e8562000958565b9450620005de565b94509492505050565b60006200063c8262000801565b9150620006498362000801565b9250620006787fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000680565b905092915050565b60008262000692576001905062000765565b81620006a2576000905062000765565b8160018114620006bb5760028114620006c657620006fc565b600191505062000765565b60ff841115620006db57620006da620008ba565b5b8360020a915084821115620006f557620006f4620008ba565b5b5062000765565b5060208310610133831016604e8410600b8410161715620007365782820a90508381111562000730576200072f620008ba565b5b62000765565b620007458484846001620005d4565b925090508184048111156200075f576200075e620008ba565b5b81810290505b9392505050565b6000620007798262000801565b9150620007868362000801565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620007c257620007c1620008ba565b5b828202905092915050565b6000620007da82620007e1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015620008385780820151818401526020810190506200081b565b8381111562000848576000848401525b50505050565b600060028204905060018216806200086757607f821691505b602082108114156200087e576200087d620008e9565b5b50919050565b6200088f8262000947565b810181811067ffffffffffffffff82111715620008b157620008b062000918565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6000600282049050919050565b6200097081620007cd565b81146200097c57600080fd5b50565b6200098a8162000801565b81146200099657600080fd5b50565b620009a4816200080b565b8114620009b057600080fd5b50565b60805160a05160c05161334a62000a2260003960008181610cd101528181610f2c015281816110bd01528181611def0152818161247101526124a90152600081816113bc01528181611d9d0152611e8a0152600081816113e801528181611eab0152611ef0015261334a6000f3fe608060405234801561001057600080fd5b5060043610610265576000357c0100000000000000000000000000000000000000000000000000000000900480636a2d094e11610158578063983b2d56116100d5578063e3ab207a11610099578063e3ab207a146107ec578063e54d63f71461081c578063e80952951461084c578063eda4e6d61461086a578063f2fde38b1461088857610265565b8063983b2d56146107205780639da7d8ba14610750578063a2119e2f14610780578063a9059cbb1461079e578063b470aade146107ce57610265565b806379ba50971161011c57806379ba50971461068a5780638da5cb5b146106a85780638f1df6bc146106c65780638f770ad0146106e457806395d89b411461070257610265565b80636a2d094e146105ac5780636d5055a6146105dc5780636ffa8a051461060c57806370a082311461063c578063731f237c1461066c57610265565b806331333487116101e6578063449a52f8116101aa578063449a52f8146104ce57806347a50517146104fe5780634abfbba21461052e578063573cc5071461055e5780636787a9be1461057c57610265565b806331333487146103f0578063313ce5671461042057806335b16eb81461043e57806340452d911461046e57806340fc89f51461049e57610265565b80631989c6a81161022d5780631989c6a814610324578063216ea5ec14610342578063229ba1971461037257806323b872dd146103905780633092afd5146103c057610265565b806301ffc9a71461026a57806306fdde031461029a578063095ea7b3146102b857806309f28f3c146102e857806318160ddd14610306575b600080fd5b610284600480360381019061027f9190612bf2565b6108b8565b6040516102919190612dc0565b60405180910390f35b6102a2610a63565b6040516102af9190612df6565b60405180910390f35b6102d260048036038101906102cd9190612b8d565b610af1565b6040516102df9190612dc0565b60405180910390f35b6102f0610c15565b6040516102fd9190612e78565b60405180910390f35b61030e610c37565b60405161031b9190612eae565b60405180910390f35b61032c610c3d565b6040516103399190612eae565b60405180910390f35b61035c60048036038101906103579190612c6d565b610c49565b6040516103699190612eae565b60405180910390f35b61037a610ccf565b6040516103879190612eae565b60405180910390f35b6103aa60048036038101906103a59190612b3e565b610cf3565b6040516103b79190612dc0565b60405180910390f35b6103da60048036038101906103d59190612b15565b610e1d565b6040516103e79190612dc0565b60405180910390f35b61040a60048036038101906104059190612c6d565b610f10565b6040516104179190612eae565b60405180910390f35b610428610fc1565b6040516104359190612eae565b60405180910390f35b61045860048036038101906104539190612b15565b610fc7565b6040516104659190612dc0565b60405180910390f35b61048860048036038101906104839190612c44565b6111ed565b6040516104959190612ddb565b60405180910390f35b6104b860048036038101906104b39190612bc9565b611211565b6040516104c59190612eae565b60405180910390f35b6104e860048036038101906104e39190612b8d565b611242565b6040516104f59190612dc0565b60405180910390f35b61051860048036038101906105139190612b15565b611360565b6040516105259190612eae565b60405180910390f35b61054860048036038101906105439190612c44565b6113b8565b6040516105559190612eae565b60405180910390f35b610566611418565b6040516105739190612eae565b60405180910390f35b61059660048036038101906105919190612c44565b61141e565b6040516105a39190612eae565b60405180910390f35b6105c660048036038101906105c19190612c44565b61148a565b6040516105d39190612eae565b60405180910390f35b6105f660048036038101906105f19190612b15565b6114ab565b6040516106039190612eae565b60405180910390f35b61062660048036038101906106219190612bc9565b611516565b6040516106339190612eae565b60405180910390f35b61065660048036038101906106519190612b15565b611549565b6040516106639190612eae565b60405180910390f35b61067461162a565b6040516106819190612dc0565b60405180910390f35b6106926117d8565b60405161069f9190612dc0565b60405180910390f35b6106b061197f565b6040516106bd9190612da5565b60405180910390f35b6106ce6119a5565b6040516106db9190612dc0565b60405180910390f35b6106ec611b5c565b6040516106f99190612eae565b60405180910390f35b61070a611b62565b6040516107179190612df6565b60405180910390f35b61073a60048036038101906107359190612b15565b611bf0565b6040516107479190612dc0565b60405180910390f35b61076a60048036038101906107659190612bc9565b611cad565b6040516107779190612eae565b60405180910390f35b610788611cd9565b6040516107959190612e78565b60405180910390f35b6107b860048036038101906107b39190612b8d565b611cfb565b6040516107c59190612dc0565b60405180910390f35b6107d6611d9b565b6040516107e39190612eae565b60405180910390f35b61080660048036038101906108019190612bc9565b611dbf565b6040516108139190612eae565b60405180910390f35b61083660048036038101906108319190612c6d565b611dd3565b6040516108439190612eae565b60405180910390f35b610854611e84565b6040516108619190612e78565b60405180910390f35b610872611eee565b60405161087f9190612eae565b60405180910390f35b6108a2600480360381019061089d9190612b15565b611f12565b6040516108af9190612dc0565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561090d5760019050610a5e565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109605760019050610a5e565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109b35760019050610a5e565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a065760019050610a5e565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a595760019050610a5e565b600090505b919050565b60058054610a709061310d565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9c9061310d565b8015610ae95780601f10610abe57610100808354040283529160200191610ae9565b820191906000526020600020905b815481529060010190602001808311610acc57829003601f168201915b505050505081565b600080610afc6119a5565b50610b0633610fc7565b50610b108361141e565b905080600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b9e9190612ee5565b925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051610c029190612eae565b60405180910390a3600191505092915050565b600260009054906101000a90046fffffffffffffffffffffffffffffffff1681565b60085481565b60008080549050905090565b600080600080851415610c91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8890612e18565b60405180910390fd5b838510610c9d57600080fd5b8484610ca99190612f3b565b91508482610cb79190612f6c565b90508084610cc59190612ffa565b9250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000610d006119a5565b50610d0a33610fc7565b50610d148461141e565b915081600c60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610d9f57600080fd5b610daa868684611fb4565b90508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610e099190612eae565b60405180910390a380925050509392505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610ea657503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b610eaf57600080fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000610f559190612f3b565b905060005b84811015610f9c57620f42408284610f729190612f6c565b610f7c9190612f3b565b83610f879190612ffa565b92508080610f949061313f565b915050610f5a565b50620f42408583610fad9190612f6c565b610fb79190612f3b565b9250505092915050565b60075481565b600080600080600080600080610fdc896114ab565b915060008214806110065750610ff0611e84565b6fffffffffffffffffffffffffffffffff168210155b1561101b5760009750505050505050506111e8565b600060018361102a9190612ffa565b81548110611061577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154965061107787611211565b945060008514156110925760009750505050505050506111e8565b61109b87611cad565b95506110a687611516565b90506d04ee2d6d415b85acef8100000000620f42407f00000000000000000000000000000000000000000000000000000000000000006110e69190612f3b565b86886110f29190612f3b565b6110fc9190612f6c565b6111069190612f3b565b9350620f424081856111189190612f6c565b6111229190612f3b565b92506cffffffff00000000000000000019600102600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254169250508190555061118c8984612058565b50818973ffffffffffffffffffffffffffffffffffffffff167f9a2a887706623ad3ff7fc85652deeceabe9fe1e00466c597972079ee91ea40d3856040516111d49190612eae565b60405180910390a360019750505050505050505b919050565b600081815481106111fd57600080fd5b906000526020600020016000915090505481565b6000606860ff16710fffffffff00000000000000000000000000836001900416908060020a82049150509050919050565b600080600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661129b57600080fd5b600954600854846112ac9190612ee5565b11156112b757600080fd5b6112bf6119a5565b5082905082600860008282546112d59190612ee5565b925050819055506112e68482612058565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8856040516113449190612eae565b60405180910390a36113546121b4565b50600191505092915050565b600068ffffffffffffffffff600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004169050919050565b60007f0000000000000000000000000000000000000000000000000000000000000000826113e69190612f6c565b7f00000000000000000000000000000000000000000000000000000000000000006114119190612ee5565b9050919050565b600a5481565b6000600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16620f42406d04ee2d6d415b85acef81000000008461146f9190612f6c565b6114799190612f6c565b6114839190612f3b565b9050919050565b6000603c824261149a9190612ffa565b6114a49190612f3b565b9050919050565b6000604860ff166cffffffff000000000000000000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546001900416908060020a82049150509050919050565b6000608c60ff1673fffff00000000000000000000000000000000000836001900416908060020a82049150509050919050565b60008060008061155885611360565b9250600260109054906101000a90046fffffffffffffffffffffffffffffffff16611581611e84565b61158b9190612fc6565b6fffffffffffffffffffffffffffffffff1690506115d9600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1682610f10565b6fffffffffffffffffffffffffffffffff169150620f42406d04ee2d6d415b85acef810000000061160a9190612f6c565b82846116169190612f6c565b6116209190612f3b565b9350505050919050565b600080600080600061163a611e84565b9350600260109054906101000a90046fffffffffffffffffffffffffffffffff16846116669190612fc6565b92506000836fffffffffffffffffffffffffffffffff1614156116905760009450505050506117d5565b600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1691506116df82846fffffffffffffffffffffffffffffffff16610f10565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555083600260106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555081836fffffffffffffffffffffffffffffffff16856fffffffffffffffffffffffffffffffff167fa0717e54e02bd9829db5e6e998aec0ae9de796b8d150a3cc46a92ab869697755600260009054906101000a90046fffffffffffffffffffffffffffffffff166040516117c49190612e93565b60405180910390a460019450505050505b90565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461183557600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060008060008060008060006119be61162a565b506119c761229c565b995060006001028a14156119e85760009a5050505050505050505050611b59565b6119f18a611dbf565b9750600188611a009190612ee5565b9050611a0b886113b8565b9150600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169450611a498261148a565b92506000831115611a7e576d04ee2d6d415b85acef8100000000611a6d8685611dd3565b611a779190612f3b565b9350611a9b565b6d04ee2d6d415b85acef810000000085611a989190612f3b565b93505b611aaa600085600854846123cc565b98506000899080600181540180825580915050600190039060005260206000200160009091909190915055611ade8a611211565b96506000871415611af957611af28a612458565b9550611b13565b611b0587600854610c49565b9550611b11868961264b565b505b7f55d243082e019fce4009ccea5368b92e436c17586a1e793c7deda16df4e5d67581604051611b429190612eae565b60405180910390a160019a50505050505050505050505b90565b60095481565b60068054611b6f9061310d565b80601f0160208091040260200160405190810160405280929190818152602001828054611b9b9061310d565b8015611be85780601f10611bbd57610100808354040283529160200191611be8565b820191906000526020600020905b815481529060010190602001808311611bcb57829003601f168201915b505050505081565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c4c57600080fd5b6001600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000602060ff166cffffffffffffffffff00000000836001900416908060020a82049150509050919050565b600260109054906101000a90046fffffffffffffffffffffffffffffffff1681565b6000806000611d086119a5565b50611d1233610fc7565b50611d1c8461141e565b9150611d29338684611fb4565b90508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051611d889190612eae565b60405180910390a3809250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600063ffffffff8260019004169050919050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000611e189190612f3b565b905060005b84811015611e5f57620f42408284611e359190612f6c565b611e3f9190612f3b565b83611e4a9190612ee5565b92508080611e579061313f565b915050611e1d565b50620f42408583611e709190612f6c565b611e7a9190612f3b565b9250505092915050565b600060017f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000042611ed59190612ffa565b611edf9190612f3b565b611ee99190612ee5565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f6e57600080fd5b81600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080611fc18584612781565b50611fcc8484612058565b50611fd5611e84565b6fffffffffffffffffffffffffffffffff169050600a548310158015612003575080612000866114ab565b14155b801561203b57508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561204c5761204a85826128b2565b505b60019150509392505050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004905060008514156120b957600093505050506121ae565b6120c286611360565b925084836120d09190612ee5565b91508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1611612140576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213790612e58565b60405180910390fd5b68ffffffffffffffffff198116905068ffffffffffffffffff82168117905080600102600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b600080600060016000805490506121cb9190612ffa565b81548110612202577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546001900490506cffffffffffffffffff000000001981169050602060ff166008549060020a0281179050806001026000600160008054905061224f9190612ffa565b81548110612286577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550600191505090565b60008060008060016000805490506122b49190612ffa565b815481106122eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015491503073ffffffffffffffffffffffffffffffffffffffff1663e80952956040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801561235a57600080fd5b505afa15801561236e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123929190612c1b565b6fffffffffffffffffffffffffffffffff1690506123af82611dbf565b81116123c3576000600102925050506123c9565b81925050505b90565b60008073fffff00000000000000000000000000000000000608c60ff16869060020a021660010281179050710fffffffff00000000000000000000000000606860ff16879060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b600080600080600061246986611cad565b9350620f42407f00000000000000000000000000000000000000000000000000000000000000008561249b9190612f6c565b6124a59190612f3b565b91507f0000000000000000000000000000000000000000000000000000000000000000620f4240836124d79190612f6c565b6124e19190612f3b565b9050838110156125f9576124f486611dbf565b9250710fffffffff0000000000000000000000000019600102600060018561251c9190612ffa565b81548110612553577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160008282541692505081905550606860ff1660019060020a027f80000000000000000000000000000000000000000000000000000000000000001760010260006001856125aa9190612ffa565b815481106125e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001600082825417925050819055505b61263e600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166d04ee2d6d415b85acef8100000000846126399190612f3b565b612058565b5081945050505050919050565b600080600084141561266157600091505061277b565b7f800000000000000000000000000000000000000000000000000000000000000060010260006001856126949190612ffa565b815481106126cb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020016000828254179250508190555061273b60006001856126f49190612ffa565b8154811061272b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154611cad565b9050612774600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16858361276f9190612ffa565b612058565b5060019150505b92915050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004905060008514156127e257600093505050506128ac565b6127eb86611360565b925084831015612830576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282790612e38565b60405180910390fd5b848361283c9190612ffa565b915068ffffffffffffffffff198116905068ffffffffffffffffff82168117905080600102600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b60006cffffffff00000000000000000019600102600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825416925050819055506cffffffff000000000000000000604860ff16839060020a0216600102600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254179250508190555061298361298e565b506001905092915050565b600080600080600060016000805490506129a89190612ffa565b815481106129df577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154925060016129f784611211565b612a019190612ee5565b905082600190049150710fffffffff000000000000000000000000001982169150710fffffffff00000000000000000000000000606860ff16829060020a0216821791508160010260006001600080549050612a5d9190612ffa565b81548110612a94577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506001935050505090565b600081359050612abb816132a1565b92915050565b600081359050612ad0816132b8565b92915050565b600081359050612ae5816132cf565b92915050565b600081519050612afa816132e6565b92915050565b600081359050612b0f816132fd565b92915050565b600060208284031215612b2757600080fd5b6000612b3584828501612aac565b91505092915050565b600080600060608486031215612b5357600080fd5b6000612b6186828701612aac565b9350506020612b7286828701612aac565b9250506040612b8386828701612b00565b9150509250925092565b60008060408385031215612ba057600080fd5b6000612bae85828601612aac565b9250506020612bbf85828601612b00565b9150509250929050565b600060208284031215612bdb57600080fd5b6000612be984828501612ac1565b91505092915050565b600060208284031215612c0457600080fd5b6000612c1284828501612ad6565b91505092915050565b600060208284031215612c2d57600080fd5b6000612c3b84828501612aeb565b91505092915050565b600060208284031215612c5657600080fd5b6000612c6484828501612b00565b91505092915050565b60008060408385031215612c8057600080fd5b6000612c8e85828601612b00565b9250506020612c9f85828601612b00565b9150509250929050565b612cb28161302e565b82525050565b612cc181613040565b82525050565b612cd08161304c565b82525050565b6000612ce182612ec9565b612ceb8185612ed4565b9350612cfb8185602086016130da565b612d0481613215565b840191505092915050565b6000612d1c601183612ed4565b9150612d2782613226565b602082019050919050565b6000612d3f600d83612ed4565b9150612d4a8261324f565b602082019050919050565b6000612d62600d83612ed4565b9150612d6d82613278565b602082019050919050565b612d8181613082565b82525050565b612d90816130c8565b82525050565b612d9f816130be565b82525050565b6000602082019050612dba6000830184612ca9565b92915050565b6000602082019050612dd56000830184612cb8565b92915050565b6000602082019050612df06000830184612cc7565b92915050565b60006020820190508181036000830152612e108184612cd6565b905092915050565b60006020820190508181036000830152612e3181612d0f565b9050919050565b60006020820190508181036000830152612e5181612d32565b9050919050565b60006020820190508181036000830152612e7181612d55565b9050919050565b6000602082019050612e8d6000830184612d78565b92915050565b6000602082019050612ea86000830184612d87565b92915050565b6000602082019050612ec36000830184612d96565b92915050565b600081519050919050565b600082825260208201905092915050565b6000612ef0826130be565b9150612efb836130be565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f3057612f2f613188565b5b828201905092915050565b6000612f46826130be565b9150612f51836130be565b925082612f6157612f606131b7565b5b828204905092915050565b6000612f77826130be565b9150612f82836130be565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612fbb57612fba613188565b5b828202905092915050565b6000612fd182613082565b9150612fdc83613082565b925082821015612fef57612fee613188565b5b828203905092915050565b6000613005826130be565b9150613010836130be565b92508282101561302357613022613188565b5b828203905092915050565b60006130398261309e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006130d382613082565b9050919050565b60005b838110156130f85780820151818401526020810190506130dd565b83811115613107576000848401525b50505050565b6000600282049050600182168061312557607f821691505b60208210811415613139576131386131e6565b5b50919050565b600061314a826130be565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561317d5761317c613188565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f4552525f4e554d50415254535f5a45524f000000000000000000000000000000600082015250565b7f4552525f4f5645525350454e4400000000000000000000000000000000000000600082015250565b7f4552525f574f554c445752415000000000000000000000000000000000000000600082015250565b6132aa8161302e565b81146132b557600080fd5b50565b6132c18161304c565b81146132cc57600080fd5b50565b6132d881613056565b81146132e357600080fd5b50565b6132ef81613082565b81146132fa57600080fd5b50565b613306816130be565b811461331157600080fd5b5056fea26469706673582212205fe3344c82204d4212d82a7bddaa1be626af5a3994d0f1bb597b3119fc542ef264736f6c63430008040033 \ No newline at end of file diff --git a/python/erc20_demurrage_token/sim/sim.py b/python/erc20_demurrage_token/sim/sim.py index d689e95..3011885 100644 --- a/python/erc20_demurrage_token/sim/sim.py +++ b/python/erc20_demurrage_token/sim/sim.py @@ -97,6 +97,7 @@ class DemurrageTokenSimulation: self.period = 1 self.period_txs = [] self.period_tx_limit = self.period_seconds - 1 + self.sink_address = settings.sink_address logg.info('intialized at block {} timestamp {} period {} demurrage level {} sink address {} (first address in keystore)'.format( self.last_block, @@ -126,6 +127,32 @@ class DemurrageTokenSimulation: logg.debug('tx {} block {} index {} verified'.format(tx_hash, self.last_block, rcpt['transaction_index'])) + def get_now(self): + o = block_latest() + r = self.rpc.do(o) + o = block_by_number(r, include_tx=False) + r = self.rpc.do(o) + return r['timestamp'] + + + def get_minutes(self): + t = self.get_now() + return int((t - self.start_timestamp) / 60) + + + def get_start(self): + return self.start_timestamp + + + def get_period(self): + return self.period + + def get_demurrage_modifier(self): + o = self.caller_contract.demurrage_amount(self.address, sender_address=self.caller_address) + r = self.rpc.do(o) + return float(self.caller_contract.parse_demurrage_amount(r) / (10 ** 38)) + + def from_units(self, v): return v * (10 ** self.decimals) @@ -136,9 +163,10 @@ class DemurrageTokenSimulation: c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.gas_oracle) (tx_hash, o) = c.mint_to(self.address, self.accounts[0], recipient, value) self.rpc.do(o) - self.next_block() + self.__next_block() self.__check_tx(tx_hash) self.period_txs.append(tx_hash) + logg.info('mint {} tokens to {} - {}'.format(value, recipient, tx_hash)) return tx_hash @@ -147,9 +175,10 @@ class DemurrageTokenSimulation: c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.gas_oracle) (tx_hash, o) = c.transfer(self.address, sender, recipient, value) self.rpc.do(o) - self.next_block() + self.__next_block() self.__check_tx(tx_hash) self.period_txs.append(tx_hash) + logg.info('transfer {} tokens from {} to {} - {}'.format(value, sender, recipient, tx_hash)) return tx_hash @@ -163,42 +192,51 @@ class DemurrageTokenSimulation: return self.caller_contract.parse_balance_of(r) - def next_block(self): + def __next_block(self): hsh = self.eth_helper.mine_block() o = block_by_hash(hsh) r = self.rpc.do(o) - logg.info('now at block {} timestamp {}'.format(r['number'], r['timestamp'])) + + for tx_hash in r['transactions']: + o = receipt(tx_hash) + rcpt = self.rpc.do(o) + if rcpt['status'] == 0: + raise RuntimeError('tx {} (block {} index {}) failed'.format(tx_hash, self.last_block, rcpt['transaction_index'])) + logg.debug('tx {} (block {} index {}) verified'.format(tx_hash, self.last_block, rcpt['transaction_index'])) + + logg.debug('now at block {} timestamp {}'.format(r['number'], r['timestamp'])) def next(self): - target_timestamp = self.start_timestamp + (self.period * self.period_seconds) - 1 + target_timestamp = self.start_timestamp + (self.period * self.period_seconds) logg.debug('warping to {}, {} from start'.format(target_timestamp, target_timestamp - self.start_timestamp)) self.last_timestamp = target_timestamp self.eth_helper.time_travel(self.last_timestamp) - self.next_block() + self.__next_block() o = block_by_number(self.last_block) r = self.rpc.do(o) self.last_block = r['number'] block_base = self.last_block + -# for tx_hash in r['transactions']: -# o = receipt(tx_hash) -# rcpt = self.rpc.do(o) -# if rcpt['status'] == 0: -# raise RuntimeError('tx {} (block {} index {}) failed'.format(tx_hash, self.last_block, rcpt['transaction_index'])) -# logg.info('tx {} (block {} index {}) verified'.format(tx_hash, self.last_block, rcpt['transaction_index'])) - - nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.rpc) + nonce_oracle = RPCNonceOracle(self.accounts[2], conn=self.rpc) c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.gas_oracle) - (tx_hash, o) = c.apply_demurrage(self.address, self.accounts[0]) + (tx_hash, o) = c.change_period(self.address, self.accounts[2]) self.rpc.do(o) - self.next_block() - (tx_hash, o) = c.change_period(self.address, self.accounts[0]) + for actor in self.actors: + nonce_oracle = RPCNonceOracle(actor, conn=self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.gas_oracle) + (tx_hash, o) = c.apply_redistribution_on_account(self.address, actor, actor) + self.rpc.do(o) + + nonce_oracle = RPCNonceOracle(self.sink_address, conn=self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=self.gas_oracle) + (tx_hash, o) = c.apply_redistribution_on_account(self.address, self.sink_address, self.sink_address) self.rpc.do(o) - self.next_block() + self.__next_block() o = block_latest() self.last_block = self.rpc.do(o) @@ -212,7 +250,7 @@ class DemurrageTokenSimulation: raise RuntimeError('demurrage step failed on block {}'.format(self.last_block)) self.last_timestamp = r['timestamp'] - logg.info('next concludes at block {} timestamp {}, {} after start'.format(self.last_block, self.last_timestamp, self.last_timestamp - self.start_timestamp)) + logg.debug('next concludes at block {} timestamp {}, {} after start'.format(self.last_block, self.last_timestamp, self.last_timestamp - self.start_timestamp)) self.period += 1 self.period_txs = [] diff --git a/python/erc20_demurrage_token/token.py b/python/erc20_demurrage_token/token.py index 3862ecd..767872f 100644 --- a/python/erc20_demurrage_token/token.py +++ b/python/erc20_demurrage_token/token.py @@ -223,6 +223,51 @@ class DemurrageToken(ERC20): return o + def to_redistribution_participants(self, contract_address, redistribution, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('toRedistributionParticipants') + enc.typ(ABIContractType.BYTES32) + enc.bytes32(redistribution) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + + def to_redistribution_supply(self, contract_address, redistribution, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('toRedistributionSupply') + enc.typ(ABIContractType.BYTES32) + enc.bytes32(redistribution) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + + def to_redistribution_demurrage_modifier(self, contract_address, redistribution, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('toRedistributionDemurrageModifier') + enc.typ(ABIContractType.BYTES32) + enc.bytes32(redistribution) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + def base_balance_of(self, contract_address, address, sender_address=ZERO_ADDRESS): o = jsonrpc_template() o['method'] = 'eth_call' @@ -323,6 +368,11 @@ class DemurrageToken(ERC20): return abi_decode_single(ABIContractType.UINT256, v) + @classmethod + def parse_to_redistribution_item(self, v): + return abi_decode_single(ABIContractType.UINT256, v) + + @classmethod def parse_supply_cap(self, v): return abi_decode_single(ABIContractType.UINT256, v) diff --git a/python/examples/sim.py b/python/examples/sim.py new file mode 100644 index 0000000..7d86ae4 --- /dev/null +++ b/python/examples/sim.py @@ -0,0 +1,76 @@ +# standard imports +import logging + +# local imports +from erc20_demurrage_token import DemurrageTokenSettings +from erc20_demurrage_token.sim import DemurrageTokenSimulation + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +decay_per_minute = 0.000050105908373373 # equals approx 2% per month + +# parameters for simulation object +settings = DemurrageTokenSettings() +settings.name = 'Simulated Demurrage Token' +settings.symbol = 'SIM' +settings.decimals = 6 +settings.demurrage_level = int(decay_per_minute*(10**40)) +settings.period_minutes = 10800 # 1 week in minutes +chain = 'evm:foochain:42' +cap = sim.from_units(10 ** 12) # 1 tn token units, with 6 decimal places + +# instantiate simulation +sim = DemurrageTokenSimulation(chain, settings, redistribute=True, cap=cap, actors=10) + +# name the usual suspects +alice = sim.actors[0] +bob = sim.actors[1] +carol = sim.actors[2] + +# mint and transfer (every single action advances one block, and one second in time) +sim.mint(alice, sim.from_units(100)) # 10000000 tokens +sim.mint(bob, sim.from_units(100)) +sim.transfer(alice, carol, sim.from_units(50)) + +# check that balances have been updated +assert sim.balance(alice) == sim.from_units(50) +assert sim.balance(bob) == sim.from_units(100) +assert sim.balance(carol) == sim.from_units(50) + +# advance to next redistribution period +sim.next() + +# inspect balances +print('alice balance: demurraged {:>9d} base {:>9d}'.format(sim.balance(alice), sim.balance(alice, base=True))) +print('bob balance: demurraged {:>9d} base {:>9d}'.format(sim.balance(bob), sim.balance(bob, base=True))) +print('carol balance: demurraged {:>9d} base {:>9d}'.format(sim.balance(carol), sim.balance(carol, base=True))) + + +# get times +minutes = sim.get_minutes() +start = sim.get_now() +timestamp = sim.get_start() +period = sim.get_period() +print('start {} now {} period {} minutes passed {}'.format(start, timestamp, period, minutes)) + + +contract_demurrage = 1 - sim.get_demurrage_modifier() # demurrage in percent (float) +frontend_demurrage = ((1 - decay_per_minute) ** minutes / 100) # corresponding demurrage modifier (float) +demurrage_delta = contract_demurrage - frontend_demurrage # difference between demurrage in contract and demurrage calculated in frontend + +alice_checksum = 50000000 - (50000000 * frontend_demurrage) + (200000000 * frontend_demurrage) # alice's balance calculated with frontend demurrage +print("""alice frontend balance {} +alice contract balance {} +frontend demurrage {} +contract demurrage {} +demurrage delta {}""".format( + alice_checksum, + sim.balance(alice), + frontend_demurrage, + contract_demurrage, + demurrage_delta), +) + +balance_sum = sim.balance(alice) + sim.balance(bob) + sim.balance(carol) +print('sum of contract demurraged balances {}'.format(balance_sum)) diff --git a/python/tests/base.py b/python/tests/base.py index cf9d951..197cf66 100644 --- a/python/tests/base.py +++ b/python/tests/base.py @@ -163,3 +163,51 @@ class TestDemurrageCap(TestDemurrage): self.deploy(c, self.mode) logg.info('deployed with mode {}'.format(self.mode)) + + + +class TestDemurrageReal(TestDemurrage): + + def setUp(self): + super(TestDemurrage, self).setUp() + + self.tax_level = int(0.000050105908373373*(10**40)) + self.period = 10800 + self.period_seconds = self.period * 60 + + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + self.settings = DemurrageTokenSettings() + self.settings.name = 'Foo Token' + self.settings.symbol = 'FOO' + self.settings.decimals = 6 + self.settings.demurrage_level = self.tax_level + self.settings.period_minutes = 10800 + self.settings.sink_address = self.accounts[9] + self.sink_address = self.settings.sink_address + + o = block_latest() + self.start_block = self.rpc.do(o) + + o = block_by_number(self.start_block, include_tx=False) + r = self.rpc.do(o) + + try: + self.start_time = int(r['timestamp'], 16) + except TypeError: + self.start_time = int(r['timestamp']) + + self.default_supply = 1000000000000 + self.default_supply_cap = int(self.default_supply * 10) + + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + self.mode = os.environ.get('ERC20_DEMURRAGE_TOKEN_TEST_MODE') + if self.mode == None: + self.mode = 'MultiNocap' + logg.debug('executing test setup default mode {}'.format(self.mode)) + + self.deploy(c, self.mode) + + logg.info('deployed with mode {}'.format(self.mode)) + diff --git a/python/tests/sim/tests_sim.py b/python/tests/sim/tests_sim.py index 1f354d2..ecca403 100644 --- a/python/tests/sim/tests_sim.py +++ b/python/tests/sim/tests_sim.py @@ -60,7 +60,7 @@ class TestSim(unittest.TestCase): self.sim.next() balance = self.sim.balance(self.sim.actors[0]) - self.assertEqual(balance, 89995500) + self.assertEqual(balance, 90005520) balance = self.sim.balance(self.sim.actors[1]) self.assertEqual(balance, 99995000) diff --git a/python/tests/test_redistribution.py b/python/tests/test_redistribution.py index 4aa01c4..eed04a9 100644 --- a/python/tests/test_redistribution.py +++ b/python/tests/test_redistribution.py @@ -26,7 +26,6 @@ logg = logging.getLogger() testdir = os.path.dirname(__file__) - class TestRedistribution(TestDemurrageDefault): def test_debug_periods(self): @@ -261,3 +260,5 @@ class TestRedistribution(TestDemurrageDefault): self.assertEqual(spender_actual_balance, spender_new_decayed_balance) +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/test_redistribution_real.py b/python/tests/test_redistribution_real.py new file mode 100644 index 0000000..992c93b --- /dev/null +++ b/python/tests/test_redistribution_real.py @@ -0,0 +1,84 @@ +# standard imports +import os +import unittest +import json +import logging + +# external imports +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.tx import receipt + +# local imports +from erc20_demurrage_token import DemurrageToken + +# test imports +from tests.base import TestDemurrageReal + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + +testdir = os.path.dirname(__file__) + + +class TestRedistribution(TestDemurrageReal): + + def test_simple_example(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 100000000) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], 100000000) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[3], 50000000) + r = self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + self.backend.time_travel(self.start_time + self.period_seconds + 1) + + (tx_hash, o) = c.change_period(self.address, self.accounts[1]) + r = self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + o = c.redistributions(self.address, 1, sender_address=self.accounts[0]) + redistribution = self.rpc.do(o) + logg.debug('redistribution {}'.format(redistribution)) + + o = c.to_redistribution_period(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + period = c.parse_to_redistribution_item(r) + logg.debug('period {}'.format(period)) + + o = c.to_redistribution_participants(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + participants = c.parse_to_redistribution_item(r) + logg.debug('participants {}'.format(participants)) + + o = c.to_redistribution_supply(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + supply = c.parse_to_redistribution_item(r) + logg.debug('supply {}'.format(supply)) + + o = c.to_redistribution_demurrage_modifier(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + modifier = c.parse_to_redistribution_item(r) + logg.debug('modifier {}'.format(modifier)) + + + +if __name__ == '__main__': + unittest.main() diff --git a/solidity/DemurrageTokenMultiCap.sol b/solidity/DemurrageTokenMultiCap.sol index 723dc1a..922adb1 100644 --- a/solidity/DemurrageTokenMultiCap.sol +++ b/solidity/DemurrageTokenMultiCap.sol @@ -246,7 +246,7 @@ contract DemurrageTokenMultiCap { return (uint256(redistribution) & maskRedistributionParticipants) >> shiftRedistributionParticipants; } - // Serializes the number of participants part of the redistribution word + // Serializes the demurrage modifier part of the redistribution word function toRedistributionDemurrageModifier(bytes32 redistribution) public pure returns (uint256) { return (uint256(redistribution) & maskRedistributionDemurrage) >> shiftRedistributionDemurrage; } @@ -417,6 +417,8 @@ contract DemurrageTokenMultiCap { uint256 periodTimestamp; uint256 nextPeriod; + applyDemurrage(); + currentRedistribution = checkPeriod(); if (currentRedistribution == bytes32(0x00)) { return false; @@ -426,7 +428,7 @@ contract DemurrageTokenMultiCap { nextPeriod = currentPeriod + 1; periodTimestamp = getPeriodTimeDelta(currentPeriod); - applyDemurrage(); + //applyDemurrage(); currentDemurrageAmount = demurrageAmount; demurrageCounts = demurrageCycles(periodTimestamp);