From 4c9c43f20e6d65ba8f3fccedfa5df7b758227a5f Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 11:57:57 +0900 Subject: [PATCH 01/26] contracts/stamina: stamina generate scrypt and bindata added --- contracts/stamina/contract/Stamina.sol | 153 +++++ contracts/stamina/contract/stamina.go | 914 +++++++++++++++++++++++++ contracts/stamina/stamina.go | 19 + 3 files changed, 1086 insertions(+) create mode 100644 contracts/stamina/contract/Stamina.sol create mode 100644 contracts/stamina/contract/stamina.go create mode 100644 contracts/stamina/stamina.go diff --git a/contracts/stamina/contract/Stamina.sol b/contracts/stamina/contract/Stamina.sol new file mode 100644 index 000000000..2c64142f9 --- /dev/null +++ b/contracts/stamina/contract/Stamina.sol @@ -0,0 +1,153 @@ +pragma solidity ^0.4.24; + +contract Stamina { + /** + * Internal States + */ + // delegatee of `from` account + // `from` => `delegatee` + mapping (address => address) _delegatee; + + // Stamina balance of delegatee + // `delegatee` => `balance` + mapping (address => uint) _stamina; + + // total deposit of delegatee + // `delegatee` => `total deposit` + mapping (address => uint) _total_deposit; + + // deposit of delegatee + // `depositor` => `delegatee` => `deposit` + mapping (address => mapping (address => uint)) _deposit; + + uint public t = 0xdead; + + bool public initialized; + + /** + * Public States + */ + uint public MIN_DEPOSIT; + + /** + * Modifiers + */ + modifier onlyChain() { + // TODO: uncomment below + // require(msg.sender == address(0)); + _; + } + + /** + * Events + */ + event Deposited(address indexed depositor, address indexed delegatee, uint amount); + event Withdrawn(address indexed depositor, address indexed delegatee, uint amount); + event DelegateeChanged(address delegater, address oldDelegatee, address newDelegatee); + + /** + * Init + */ + function init(uint minDeposit) external { + require(!initialized); + + MIN_DEPOSIT = minDeposit; + + initialized = true; + } + + /** + * Getters + */ + function getDelegatee(address delegater) public view returns (address) { + return _delegatee[delegater]; + } + + function getStamina(address addr) public view returns (uint) { + return _stamina[addr]; + } + + function getTotalDeposit(address delegatee) public view returns (uint) { + return _total_deposit[delegatee]; + } + + function getDeposit(address depositor, address delegatee) public view returns (uint) { + return _deposit[depositor][delegatee]; + } + + /** + * Setters and External functions + */ + /// @notice set `msg.sender` as delegatee of `delegater` + function setDelegatee(address delegater) external returns (bool) { + address oldDelegatee = _delegatee[delegater]; + + _delegatee[delegater] = msg.sender; + + emit DelegateeChanged(delegater, oldDelegatee, msg.sender); + return true; + } + + /// @notice deposit Ether to delegatee + function deposit(address delegatee) external payable returns (bool) { + require(msg.value >= MIN_DEPOSIT); + + uint dTotalDeposit = _total_deposit[delegatee]; + uint fDeposit = _deposit[msg.sender][delegatee]; + + require(dTotalDeposit + msg.value > dTotalDeposit); + require(fDeposit + msg.value > fDeposit); + + _total_deposit[delegatee] = dTotalDeposit + msg.value; + _deposit[msg.sender][delegatee] = fDeposit + msg.value; + + emit Deposited(msg.sender, delegatee, msg.value); + return true; + } + + /// @notice request to withdraw Ether from delegatee. it store Ether to Escrow contract. + /// later `withdrawPayments` transfers Ether from Escrow to the depositor + function withdraw(address delegatee, uint amount) external returns (bool) { + uint dTotalDeposit = _total_deposit[delegatee]; + uint fDeposit = _deposit[msg.sender][delegatee]; + + require(dTotalDeposit - amount < dTotalDeposit); + require(fDeposit - amount < fDeposit); + + _total_deposit[delegatee] = dTotalDeposit - amount; + _deposit[msg.sender][delegatee] = fDeposit - amount; + + msg.sender.transfer(amount); + + emit Withdrawn(msg.sender, delegatee, amount); + return true; + } + + /// @notice reset stamina up to total deposit of delegatee + function resetStamina(address delegatee) external onlyChain { + _stamina[delegatee] = _total_deposit[delegatee]; + } + + /// @notice add stamina of delegatee. The upper bound of stamina is total deposit of delegatee. + function addStamina(address delegatee, uint amount) external onlyChain returns (bool) { + uint dTotalDeposit = _total_deposit[delegatee]; + uint dBalance = _stamina[delegatee]; + + require(dBalance + amount > dBalance); + uint targetBalance = dBalance + amount; + + if (targetBalance > dTotalDeposit) _stamina[delegatee] = dTotalDeposit; + else _stamina[delegatee] = targetBalance; + + return true; + } + + /// @notice subtracte stamina of delegatee. + function subtractStamina(address delegatee, uint amount) external onlyChain returns (bool) { + uint dBalance = _stamina[delegatee]; + + require(dBalance - amount < dBalance); + _stamina[delegatee] = dBalance - amount; + return true; + } +} diff --git a/contracts/stamina/contract/stamina.go b/contracts/stamina/contract/stamina.go new file mode 100644 index 000000000..11dd08810 --- /dev/null +++ b/contracts/stamina/contract/stamina.go @@ -0,0 +1,914 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contract + +import ( + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// StaminaABI is the input ABI used to generate the binding from. +const StaminaABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"resetStamina\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getTotalDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"t\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegater\",\"type\":\"address\"}],\"name\":\"getDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"minDeposit\",\"type\":\"uint256\"}],\"name\":\"init\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"subtractStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MIN_DEPOSIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegater\",\"type\":\"address\"}],\"name\":\"setDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"delegater\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"oldDelegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"newDelegatee\",\"type\":\"address\"}],\"name\":\"DelegateeChanged\",\"type\":\"event\"}]" + +// StaminaBin is the compiled bytecode used for deploying new contracts. +const StaminaBin = `0x608060405261dead60045534801561001657600080fd5b506107c3806100266000396000f3006080604052600436106100cf5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663158ef93e81146100d45780633900e4ec146100fd57806362eb5d9814610142578063857184d11461017757806392d0d153146101aa5780639b4e735f146101bf578063b7b0422d1461020e578063bcac973614610238578063c35082a914610271578063d1c0c042146102ac578063e1e158a5146102e5578063e842a64b146102fa578063f340fa011461032d578063f3fef3a314610353575b600080fd5b3480156100e057600080fd5b506100e961038c565b604080519115158252519081900360200190f35b34801561010957600080fd5b506101306004803603602081101561012057600080fd5b5035600160a060020a0316610395565b60408051918252519081900360200190f35b34801561014e57600080fd5b506101756004803603602081101561016557600080fd5b5035600160a060020a03166103b0565b005b34801561018357600080fd5b506101306004803603602081101561019a57600080fd5b5035600160a060020a03166103d6565b3480156101b657600080fd5b506101306103f1565b3480156101cb57600080fd5b506101f2600480360360208110156101e257600080fd5b5035600160a060020a03166103f7565b60408051600160a060020a039092168252519081900360200190f35b34801561021a57600080fd5b506101756004803603602081101561023157600080fd5b5035610415565b34801561024457600080fd5b506100e96004803603604081101561025b57600080fd5b50600160a060020a038135169060200135610437565b34801561027d57600080fd5b506101306004803603604081101561029457600080fd5b50600160a060020a03813581169160200135166104bc565b3480156102b857600080fd5b506100e9600480360360408110156102cf57600080fd5b50600160a060020a0381351690602001356104e7565b3480156102f157600080fd5b50610130610536565b34801561030657600080fd5b506100e96004803603602081101561031d57600080fd5b5035600160a060020a031661053c565b6100e96004803603602081101561034357600080fd5b5035600160a060020a03166105c5565b34801561035f57600080fd5b506100e96004803603604081101561037657600080fd5b50600160a060020a03813516906020013561069a565b60055460ff1681565b600160a060020a031660009081526001602052604090205490565b600160a060020a0316600090815260026020908152604080832054600190925290912055565b600160a060020a031660009081526002602052604090205490565b60045481565b600160a060020a039081166000908152602081905260409020541690565b60055460ff161561042557600080fd5b6006556005805460ff19166001179055565b600160a060020a0382166000908152600260209081526040808320546001909252822054838101811061046957600080fd5b8084018281111561049457600160a060020a03861660009081526001602052604090208390556104b0565b600160a060020a03861660009081526001602052604090208190555b50600195945050505050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600160a060020a038216600090815260016020526040812054828103811161050e57600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b60065481565b600160a060020a03808216600081815260208181526040808320805473ffffffffffffffffffffffffffffffffffffffff1981163390811790925582519586529095169184018290528381019490945292519092917f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692919081900360600190a150600192915050565b6006546000903410156105d757600080fd5b600160a060020a0382166000818152600260209081526040808320543384526003835281842094845293909152902054348201821061061557600080fd5b348101811061062357600080fd5b600160a060020a03841660008181526002602090815260408083203487810190915533808552600384528285208686528452938290208682019055815190815290517f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7929181900390910190a35060019392505050565b600160a060020a038216600081815260026020908152604080832054338452600383528184209484529390915281205490919083820382116106db57600080fd5b83810381116106e957600080fd5b600160a060020a0385166000818152600260209081526040808320888703905533808452600383528184209484529390915280822087850390555186156108fc0291879190818181858888f1935050505015801561074b573d6000803e3d6000fd5b50604080518581529051600160a060020a0387169133917fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb9181900360200190a35060019493505050505600a165627a7a72305820a011f3b07b2d2070faaf83531209f631ad3e33cd6aa2a5012e67d91316a8ef4d0029` + +// DeployStamina deploys a new Ethereum contract, binding an instance of Stamina to it. +func DeployStamina(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Stamina, error) { + parsed, err := abi.JSON(strings.NewReader(StaminaABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(StaminaBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Stamina{StaminaCaller: StaminaCaller{contract: contract}, StaminaTransactor: StaminaTransactor{contract: contract}, StaminaFilterer: StaminaFilterer{contract: contract}}, nil +} + +// Stamina is an auto generated Go binding around an Ethereum contract. +type Stamina struct { + StaminaCaller // Read-only binding to the contract + StaminaTransactor // Write-only binding to the contract + StaminaFilterer // Log filterer for contract events +} + +// StaminaCaller is an auto generated read-only Go binding around an Ethereum contract. +type StaminaCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StaminaTransactor is an auto generated write-only Go binding around an Ethereum contract. +type StaminaTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StaminaFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type StaminaFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StaminaSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type StaminaSession struct { + Contract *Stamina // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StaminaCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type StaminaCallerSession struct { + Contract *StaminaCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// StaminaTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type StaminaTransactorSession struct { + Contract *StaminaTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StaminaRaw is an auto generated low-level Go binding around an Ethereum contract. +type StaminaRaw struct { + Contract *Stamina // Generic contract binding to access the raw methods on +} + +// StaminaCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type StaminaCallerRaw struct { + Contract *StaminaCaller // Generic read-only contract binding to access the raw methods on +} + +// StaminaTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type StaminaTransactorRaw struct { + Contract *StaminaTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewStamina creates a new instance of Stamina, bound to a specific deployed contract. +func NewStamina(address common.Address, backend bind.ContractBackend) (*Stamina, error) { + contract, err := bindStamina(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Stamina{StaminaCaller: StaminaCaller{contract: contract}, StaminaTransactor: StaminaTransactor{contract: contract}, StaminaFilterer: StaminaFilterer{contract: contract}}, nil +} + +// NewStaminaCaller creates a new read-only instance of Stamina, bound to a specific deployed contract. +func NewStaminaCaller(address common.Address, caller bind.ContractCaller) (*StaminaCaller, error) { + contract, err := bindStamina(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &StaminaCaller{contract: contract}, nil +} + +// NewStaminaTransactor creates a new write-only instance of Stamina, bound to a specific deployed contract. +func NewStaminaTransactor(address common.Address, transactor bind.ContractTransactor) (*StaminaTransactor, error) { + contract, err := bindStamina(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &StaminaTransactor{contract: contract}, nil +} + +// NewStaminaFilterer creates a new log filterer instance of Stamina, bound to a specific deployed contract. +func NewStaminaFilterer(address common.Address, filterer bind.ContractFilterer) (*StaminaFilterer, error) { + contract, err := bindStamina(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &StaminaFilterer{contract: contract}, nil +} + +// bindStamina binds a generic wrapper to an already deployed contract. +func bindStamina(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(StaminaABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Stamina *StaminaRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Stamina.Contract.StaminaCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Stamina *StaminaRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Stamina.Contract.StaminaTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Stamina *StaminaRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Stamina.Contract.StaminaTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Stamina *StaminaCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Stamina.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Stamina *StaminaTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Stamina.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Stamina *StaminaTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Stamina.Contract.contract.Transact(opts, method, params...) +} + +// MINDEPOSIT is a free data retrieval call binding the contract method 0xe1e158a5. +// +// Solidity: function MIN_DEPOSIT() constant returns(uint256) +func (_Stamina *StaminaCaller) MINDEPOSIT(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "MIN_DEPOSIT") + return *ret0, err +} + +// MINDEPOSIT is a free data retrieval call binding the contract method 0xe1e158a5. +// +// Solidity: function MIN_DEPOSIT() constant returns(uint256) +func (_Stamina *StaminaSession) MINDEPOSIT() (*big.Int, error) { + return _Stamina.Contract.MINDEPOSIT(&_Stamina.CallOpts) +} + +// MINDEPOSIT is a free data retrieval call binding the contract method 0xe1e158a5. +// +// Solidity: function MIN_DEPOSIT() constant returns(uint256) +func (_Stamina *StaminaCallerSession) MINDEPOSIT() (*big.Int, error) { + return _Stamina.Contract.MINDEPOSIT(&_Stamina.CallOpts) +} + +// GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. +// +// Solidity: function getDelegatee(delegater address) constant returns(address) +func (_Stamina *StaminaCaller) GetDelegatee(opts *bind.CallOpts, delegater common.Address) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getDelegatee", delegater) + return *ret0, err +} + +// GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. +// +// Solidity: function getDelegatee(delegater address) constant returns(address) +func (_Stamina *StaminaSession) GetDelegatee(delegater common.Address) (common.Address, error) { + return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegater) +} + +// GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. +// +// Solidity: function getDelegatee(delegater address) constant returns(address) +func (_Stamina *StaminaCallerSession) GetDelegatee(delegater common.Address) (common.Address, error) { + return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegater) +} + +// GetDeposit is a free data retrieval call binding the contract method 0xc35082a9. +// +// Solidity: function getDeposit(depositor address, delegatee address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetDeposit(opts *bind.CallOpts, depositor common.Address, delegatee common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getDeposit", depositor, delegatee) + return *ret0, err +} + +// GetDeposit is a free data retrieval call binding the contract method 0xc35082a9. +// +// Solidity: function getDeposit(depositor address, delegatee address) constant returns(uint256) +func (_Stamina *StaminaSession) GetDeposit(depositor common.Address, delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetDeposit(&_Stamina.CallOpts, depositor, delegatee) +} + +// GetDeposit is a free data retrieval call binding the contract method 0xc35082a9. +// +// Solidity: function getDeposit(depositor address, delegatee address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetDeposit(depositor common.Address, delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetDeposit(&_Stamina.CallOpts, depositor, delegatee) +} + +// GetStamina is a free data retrieval call binding the contract method 0x3900e4ec. +// +// Solidity: function getStamina(addr address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetStamina(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getStamina", addr) + return *ret0, err +} + +// GetStamina is a free data retrieval call binding the contract method 0x3900e4ec. +// +// Solidity: function getStamina(addr address) constant returns(uint256) +func (_Stamina *StaminaSession) GetStamina(addr common.Address) (*big.Int, error) { + return _Stamina.Contract.GetStamina(&_Stamina.CallOpts, addr) +} + +// GetStamina is a free data retrieval call binding the contract method 0x3900e4ec. +// +// Solidity: function getStamina(addr address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetStamina(addr common.Address) (*big.Int, error) { + return _Stamina.Contract.GetStamina(&_Stamina.CallOpts, addr) +} + +// GetTotalDeposit is a free data retrieval call binding the contract method 0x857184d1. +// +// Solidity: function getTotalDeposit(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetTotalDeposit(opts *bind.CallOpts, delegatee common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getTotalDeposit", delegatee) + return *ret0, err +} + +// GetTotalDeposit is a free data retrieval call binding the contract method 0x857184d1. +// +// Solidity: function getTotalDeposit(delegatee address) constant returns(uint256) +func (_Stamina *StaminaSession) GetTotalDeposit(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetTotalDeposit(&_Stamina.CallOpts, delegatee) +} + +// GetTotalDeposit is a free data retrieval call binding the contract method 0x857184d1. +// +// Solidity: function getTotalDeposit(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetTotalDeposit(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetTotalDeposit(&_Stamina.CallOpts, delegatee) +} + +// Initialized is a free data retrieval call binding the contract method 0x158ef93e. +// +// Solidity: function initialized() constant returns(bool) +func (_Stamina *StaminaCaller) Initialized(opts *bind.CallOpts) (bool, error) { + var ( + ret0 = new(bool) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "initialized") + return *ret0, err +} + +// Initialized is a free data retrieval call binding the contract method 0x158ef93e. +// +// Solidity: function initialized() constant returns(bool) +func (_Stamina *StaminaSession) Initialized() (bool, error) { + return _Stamina.Contract.Initialized(&_Stamina.CallOpts) +} + +// Initialized is a free data retrieval call binding the contract method 0x158ef93e. +// +// Solidity: function initialized() constant returns(bool) +func (_Stamina *StaminaCallerSession) Initialized() (bool, error) { + return _Stamina.Contract.Initialized(&_Stamina.CallOpts) +} + +// T is a free data retrieval call binding the contract method 0x92d0d153. +// +// Solidity: function t() constant returns(uint256) +func (_Stamina *StaminaCaller) T(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "t") + return *ret0, err +} + +// T is a free data retrieval call binding the contract method 0x92d0d153. +// +// Solidity: function t() constant returns(uint256) +func (_Stamina *StaminaSession) T() (*big.Int, error) { + return _Stamina.Contract.T(&_Stamina.CallOpts) +} + +// T is a free data retrieval call binding the contract method 0x92d0d153. +// +// Solidity: function t() constant returns(uint256) +func (_Stamina *StaminaCallerSession) T() (*big.Int, error) { + return _Stamina.Contract.T(&_Stamina.CallOpts) +} + +// AddStamina is a paid mutator transaction binding the contract method 0xbcac9736. +// +// Solidity: function addStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactor) AddStamina(opts *bind.TransactOpts, delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "addStamina", delegatee, amount) +} + +// AddStamina is a paid mutator transaction binding the contract method 0xbcac9736. +// +// Solidity: function addStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaSession) AddStamina(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.AddStamina(&_Stamina.TransactOpts, delegatee, amount) +} + +// AddStamina is a paid mutator transaction binding the contract method 0xbcac9736. +// +// Solidity: function addStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactorSession) AddStamina(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.AddStamina(&_Stamina.TransactOpts, delegatee, amount) +} + +// Deposit is a paid mutator transaction binding the contract method 0xf340fa01. +// +// Solidity: function deposit(delegatee address) returns(bool) +func (_Stamina *StaminaTransactor) Deposit(opts *bind.TransactOpts, delegatee common.Address) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "deposit", delegatee) +} + +// Deposit is a paid mutator transaction binding the contract method 0xf340fa01. +// +// Solidity: function deposit(delegatee address) returns(bool) +func (_Stamina *StaminaSession) Deposit(delegatee common.Address) (*types.Transaction, error) { + return _Stamina.Contract.Deposit(&_Stamina.TransactOpts, delegatee) +} + +// Deposit is a paid mutator transaction binding the contract method 0xf340fa01. +// +// Solidity: function deposit(delegatee address) returns(bool) +func (_Stamina *StaminaTransactorSession) Deposit(delegatee common.Address) (*types.Transaction, error) { + return _Stamina.Contract.Deposit(&_Stamina.TransactOpts, delegatee) +} + +// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// +// Solidity: function init(minDeposit uint256) returns() +func (_Stamina *StaminaTransactor) Init(opts *bind.TransactOpts, minDeposit *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "init", minDeposit) +} + +// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// +// Solidity: function init(minDeposit uint256) returns() +func (_Stamina *StaminaSession) Init(minDeposit *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit) +} + +// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// +// Solidity: function init(minDeposit uint256) returns() +func (_Stamina *StaminaTransactorSession) Init(minDeposit *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit) +} + +// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// +// Solidity: function resetStamina(delegatee address) returns() +func (_Stamina *StaminaTransactor) ResetStamina(opts *bind.TransactOpts, delegatee common.Address) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "resetStamina", delegatee) +} + +// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// +// Solidity: function resetStamina(delegatee address) returns() +func (_Stamina *StaminaSession) ResetStamina(delegatee common.Address) (*types.Transaction, error) { + return _Stamina.Contract.ResetStamina(&_Stamina.TransactOpts, delegatee) +} + +// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// +// Solidity: function resetStamina(delegatee address) returns() +func (_Stamina *StaminaTransactorSession) ResetStamina(delegatee common.Address) (*types.Transaction, error) { + return _Stamina.Contract.ResetStamina(&_Stamina.TransactOpts, delegatee) +} + +// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// +// Solidity: function setDelegatee(delegater address) returns(bool) +func (_Stamina *StaminaTransactor) SetDelegatee(opts *bind.TransactOpts, delegater common.Address) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "setDelegatee", delegater) +} + +// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// +// Solidity: function setDelegatee(delegater address) returns(bool) +func (_Stamina *StaminaSession) SetDelegatee(delegater common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegater) +} + +// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// +// Solidity: function setDelegatee(delegater address) returns(bool) +func (_Stamina *StaminaTransactorSession) SetDelegatee(delegater common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegater) +} + +// SubtractStamina is a paid mutator transaction binding the contract method 0xd1c0c042. +// +// Solidity: function subtractStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactor) SubtractStamina(opts *bind.TransactOpts, delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "subtractStamina", delegatee, amount) +} + +// SubtractStamina is a paid mutator transaction binding the contract method 0xd1c0c042. +// +// Solidity: function subtractStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaSession) SubtractStamina(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.SubtractStamina(&_Stamina.TransactOpts, delegatee, amount) +} + +// SubtractStamina is a paid mutator transaction binding the contract method 0xd1c0c042. +// +// Solidity: function subtractStamina(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactorSession) SubtractStamina(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.SubtractStamina(&_Stamina.TransactOpts, delegatee, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactor) Withdraw(opts *bind.TransactOpts, delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "withdraw", delegatee, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaSession) Withdraw(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts, delegatee, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactorSession) Withdraw(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts, delegatee, amount) +} + +// StaminaDelegateeChangedIterator is returned from FilterDelegateeChanged and is used to iterate over the raw logs and unpacked data for DelegateeChanged events raised by the Stamina contract. +type StaminaDelegateeChangedIterator struct { + Event *StaminaDelegateeChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaDelegateeChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaDelegateeChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaDelegateeChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaDelegateeChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaDelegateeChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaDelegateeChanged represents a DelegateeChanged event raised by the Stamina contract. +type StaminaDelegateeChanged struct { + Delegater common.Address + OldDelegatee common.Address + NewDelegatee common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDelegateeChanged is a free log retrieval operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. +// +// Solidity: e DelegateeChanged(delegater address, oldDelegatee address, newDelegatee address) +func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts) (*StaminaDelegateeChangedIterator, error) { + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "DelegateeChanged") + if err != nil { + return nil, err + } + return &StaminaDelegateeChangedIterator{contract: _Stamina.contract, event: "DelegateeChanged", logs: logs, sub: sub}, nil +} + +// WatchDelegateeChanged is a free log subscription operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. +// +// Solidity: e DelegateeChanged(delegater address, oldDelegatee address, newDelegatee address) +func (_Stamina *StaminaFilterer) WatchDelegateeChanged(opts *bind.WatchOpts, sink chan<- *StaminaDelegateeChanged) (event.Subscription, error) { + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "DelegateeChanged") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaDelegateeChanged) + if err := _Stamina.contract.UnpackLog(event, "DelegateeChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// StaminaDepositedIterator is returned from FilterDeposited and is used to iterate over the raw logs and unpacked data for Deposited events raised by the Stamina contract. +type StaminaDepositedIterator struct { + Event *StaminaDeposited // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaDepositedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaDeposited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaDeposited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaDepositedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaDepositedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaDeposited represents a Deposited event raised by the Stamina contract. +type StaminaDeposited struct { + Depositor common.Address + Delegatee common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeposited is a free log retrieval operation binding the contract event 0x8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7. +// +// Solidity: e Deposited(depositor indexed address, delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) FilterDeposited(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaDepositedIterator, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "Deposited", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return &StaminaDepositedIterator{contract: _Stamina.contract, event: "Deposited", logs: logs, sub: sub}, nil +} + +// WatchDeposited is a free log subscription operation binding the contract event 0x8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7. +// +// Solidity: e Deposited(depositor indexed address, delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) WatchDeposited(opts *bind.WatchOpts, sink chan<- *StaminaDeposited, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "Deposited", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaDeposited) + if err := _Stamina.contract.UnpackLog(event, "Deposited", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// StaminaWithdrawnIterator is returned from FilterWithdrawn and is used to iterate over the raw logs and unpacked data for Withdrawn events raised by the Stamina contract. +type StaminaWithdrawnIterator struct { + Event *StaminaWithdrawn // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaWithdrawnIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaWithdrawn) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaWithdrawn) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaWithdrawnIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaWithdrawnIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaWithdrawn represents a Withdrawn event raised by the Stamina contract. +type StaminaWithdrawn struct { + Depositor common.Address + Delegatee common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdrawn is a free log retrieval operation binding the contract event 0xd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb. +// +// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) FilterWithdrawn(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawnIterator, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "Withdrawn", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return &StaminaWithdrawnIterator{contract: _Stamina.contract, event: "Withdrawn", logs: logs, sub: sub}, nil +} + +// WatchWithdrawn is a free log subscription operation binding the contract event 0xd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb. +// +// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawn, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "Withdrawn", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaWithdrawn) + if err := _Stamina.contract.UnpackLog(event, "Withdrawn", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} diff --git a/contracts/stamina/stamina.go b/contracts/stamina/stamina.go new file mode 100644 index 000000000..780477ebf --- /dev/null +++ b/contracts/stamina/stamina.go @@ -0,0 +1,19 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package stamina + +//go:generate abigen --sol contract/Stamina.sol --pkg contract --out contract/stamina.go From fdb4fad26a7adaf69298bd73279bad14a5f93f51 Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 11:58:56 +0900 Subject: [PATCH 02/26] stamina/common: common / contract-related parameters --- stamina/common/config.go | 11 +++++++++++ stamina/common/constants.go | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 stamina/common/config.go create mode 100644 stamina/common/constants.go diff --git a/stamina/common/config.go b/stamina/common/config.go new file mode 100644 index 000000000..d71224759 --- /dev/null +++ b/stamina/common/config.go @@ -0,0 +1,11 @@ +package common + +import ( + "github.com/ethereum/go-ethereum/common" +) + +var StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" +var StaminaContractAddress = common.HexToAddress(StaminaContractAddressHex) + +// deployed bytecode +var StaminaContractBin = "0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063158ef93e146100d55780633900e4ec1461010457806362eb5d981461015b578063857184d11461019e57806392d0d153146101f55780639b4e735f14610220578063b7b0422d146102a3578063bcac9736146102d0578063c35082a914610335578063d1c0c042146103ac578063e1e158a514610411578063e842a64b1461043c578063f340fa0114610497578063f3fef3a3146104e5575b600080fd5b3480156100e157600080fd5b506100ea61054a565b604051808215151515815260200191505060405180910390f35b34801561011057600080fd5b50610145600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061055d565b6040518082815260200191505060405180910390f35b34801561016757600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105a6565b005b3480156101aa57600080fd5b506101df600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061062c565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b5061020a610675565b6040518082815260200191505060405180910390f35b34801561022c57600080fd5b50610261600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102af57600080fd5b506102ce600480360381019080803590602001909291905050506106e3565b005b3480156102dc57600080fd5b5061031b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610724565b604051808215151515815260200191505060405180910390f35b34801561034157600080fd5b50610396600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610866565b6040518082815260200191505060405180910390f35b3480156103b857600080fd5b506103f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ed565b604051808215151515815260200191505060405180910390f35b34801561041d57600080fd5b50610426610993565b6040518082815260200191505060405180910390f35b34801561044857600080fd5b5061047d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610999565b604051808215151515815260200191505060405180910390f35b6104cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b4f565b604051808215151515815260200191505060405180910390f35b3480156104f157600080fd5b50610530600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d7f565b604051808215151515815260200191505060405180910390f35b600560009054906101000a900460ff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60045481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600560009054906101000a900460ff161515156106ff57600080fd5b806006819055506001600560006101000a81548160ff02191690831515021790555050565b600080600080600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549250600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150818583011115156107be57600080fd5b8482019050828111156108145782600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610859565b80600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001935050505092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508083820310151561094257600080fd5b828103600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600191505092915050565b60065481565b6000806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050336000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692838233604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001935050505060405180910390a16001915050919050565b60008060006006543410151515610b6557600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081348301111515610c3657600080fd5b80348201111515610c4657600080fd5b348201600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550348101600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7346040518082815260200191505060405180910390a3600192505050919050565b6000806000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081848303101515610e5557600080fd5b80848203101515610e6557600080fd5b838203600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550838103600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f19350505050158015610f74573d6000803e3d6000fd5b508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb866040518082815260200191505060405180910390a3600192505050929150505600a165627a7a72305820e9bc8cfcd1e8821074892973d25b4cabffda4b6fd0e7b766fdbcb413ed432e040029" diff --git a/stamina/common/constants.go b/stamina/common/constants.go new file mode 100644 index 000000000..43ae6507c --- /dev/null +++ b/stamina/common/constants.go @@ -0,0 +1,21 @@ +package common + +import ( + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/contracts/stamina/contract" +) + +type accountWrapper struct { + address common.Address +} + +func (a accountWrapper) Address() common.Address { + return a.address +} + +var BlockchainAccount = accountWrapper{common.HexToAddress("0x00")} +var StaminaAccount = accountWrapper{StaminaContractAddress} +var StaminaABI, _ = abi.JSON(strings.NewReader(contract.StaminaABI)) From c1adb66aa570c2fc406ea662748b1ad6d3fac758 Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 11:59:15 +0900 Subject: [PATCH 03/26] stamina: implement stamina related functionality --- stamina/stamina.go | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 stamina/stamina.go diff --git a/stamina/stamina.go b/stamina/stamina.go new file mode 100644 index 000000000..41ef9b1f9 --- /dev/null +++ b/stamina/stamina.go @@ -0,0 +1,64 @@ +package stamina + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + staminaCommon "github.com/ethereum/go-ethereum/stamina/common" +) + +func GetDelegatee(evm *vm.EVM, from common.Address) (common.Address, error) { + data, err := staminaCommon.StaminaABI.Pack("getDelegatee", from) + if err != nil { + return common.Address{}, err + } + + ret, _, err := evm.StaticCall(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000) + + if err != nil { + return common.Address{}, err + } + + return common.BytesToAddress(ret), nil +} + +func GetStamina(evm *vm.EVM, delegatee common.Address) (*big.Int, error) { + data, err := staminaCommon.StaminaABI.Pack("getStamina", delegatee) + if err != nil { + return big.NewInt(0), err + } + + ret, _, err := evm.StaticCall(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000) + + if err != nil { + return big.NewInt(0), err + } + + stamina := new(big.Int) + stamina.SetBytes(ret) + + return stamina, nil +} + +func AddStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { + data, err := staminaCommon.StaminaABI.Pack("addStamina", delegatee, gas) + if err != nil { + return err + } + + _, _, err = evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + + return err +} + +func SubtractStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { + data, err := staminaCommon.StaminaABI.Pack("subtractStamina", delegatee, gas) + if err != nil { + return err + } + + _, _, err = evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + + return err +} From 51deb64f2e896d82809c9e1499d505c66a976cf8 Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 12:01:41 +0900 Subject: [PATCH 04/26] core: create static evm with fake message, chain, header --- core/tx_pool.go | 55 +++++++++++++++++++++++++++++++++++++------- core/tx_pool_test.go | 23 ++++++++++++------ 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 2614852d2..705dcdde6 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -25,14 +25,15 @@ import ( "sync" "time" - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/common/prque" - "github.com/Onther-Tech/plasma-evm/core/state" - "github.com/Onther-Tech/plasma-evm/core/types" - "github.com/Onther-Tech/plasma-evm/event" - "github.com/Onther-Tech/plasma-evm/log" - "github.com/Onther-Tech/plasma-evm/metrics" - "github.com/Onther-Tech/plasma-evm/params" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/prque" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" ) const ( @@ -119,6 +120,10 @@ type blockChain interface { StateAt(root common.Hash) (*state.StateDB, error) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription + + // moscow - added to create evm + Engine() consensus.Engine + GetHeader(common.Hash, uint64) *types.Header } // TxPoolConfig are the configuration parameters of the transaction pool. @@ -1114,6 +1119,40 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { } } +// moscow - arbitrary msg & header & author +func (pool *TxPool) newStaticEVM() *vm.EVM { + msg := types.NewMessage( + staminaCommon.BlockchainAccount.Address(), + &staminaCommon.StaminaContractAddress, + 0, + big.NewInt(0), + 1000000, + big.NewInt(1e9), + nil, + false, + ) + + vmConfig := vm.Config{} + + ctx := NewEVMContext( + msg, + &types.Header{ + Number: big.NewInt(0), + Time: big.NewInt(0), + Difficulty: big.NewInt(0), + }, + pool.chain, + &common.Address{}, + ) + + return vm.NewEVM( + ctx, + pool.currentState, + pool.chainconfig, + vmConfig, + ) +} + // demoteUnexecutables removes invalid and processed transactions from the pools // executable/pending queue and any subsequent transactions that become unexecutable // are moved back into the future queue. diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index b6deda2c5..32a51769b 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -26,13 +26,14 @@ import ( "testing" "time" - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/core/state" - "github.com/Onther-Tech/plasma-evm/core/types" - "github.com/Onther-Tech/plasma-evm/crypto" - "github.com/Onther-Tech/plasma-evm/ethdb" - "github.com/Onther-Tech/plasma-evm/event" - "github.com/Onther-Tech/plasma-evm/params" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/params" ) // testTxPoolConfig is a transaction pool configuration without stateful disk @@ -68,6 +69,14 @@ func (bc *testBlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) even return bc.chainHeadFeed.Subscribe(ch) } +// moscow - new interface +func (bc *testBlockChain) Engine() consensus.Engine { + return nil +} +func (bc *testBlockChain) GetHeader(common.Hash, uint64) *types.Header { + return nil +} + func transaction(nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) *types.Transaction { return pricedTransaction(nonce, gaslimit, big.NewInt(1), key) } From 8890bb81fe3ccc231b15e57f283dfeb4f7600e0a Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 12:07:06 +0900 Subject: [PATCH 05/26] core: insert stamina contract at development genesis --- core/genesis.go | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index fdf644d43..417a55101 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -25,16 +25,17 @@ import ( "math/big" "strings" - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/common/hexutil" - "github.com/Onther-Tech/plasma-evm/common/math" - "github.com/Onther-Tech/plasma-evm/core/rawdb" - "github.com/Onther-Tech/plasma-evm/core/state" - "github.com/Onther-Tech/plasma-evm/core/types" - "github.com/Onther-Tech/plasma-evm/ethdb" - "github.com/Onther-Tech/plasma-evm/log" - "github.com/Onther-Tech/plasma-evm/params" - "github.com/Onther-Tech/plasma-evm/rlp" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + staminaCommon "github.com/ethereum/go-ethereum/stamina/common" ) //go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go @@ -354,6 +355,12 @@ func DeveloperGenesisBlock(period uint64) *Genesis { config := *params.AllCliqueProtocolChanges config.Clique.Period = period + var err error + staminaBinBytes, err := hex.DecodeString(staminaCommon.StaminaContractBin[2:]) + if err != nil { + panic(err) + } + // Assemble and return the genesis with the precompiles and faucet pre-funded return &Genesis{ Config: &config, @@ -369,7 +376,11 @@ func DeveloperGenesisBlock(period uint64) *Genesis { common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing - params.Operator: {Balance: big.NewInt(0)}, + staminaCommon.StaminaContractAddress: { + Code: staminaBinBytes, + Balance: big.NewInt(0), + }, + faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, }, } } From 57ea27431d6ca0602c9aec333db0cba43e8d60b1 Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 23 Jul 2018 12:07:43 +0900 Subject: [PATCH 06/26] core: change tx execution / tx validation / tx pool promotion --- core/state_transition.go | 131 ++++++++++++++++++++++++++++++++++----- core/tx_pool.go | 83 ++++++++++++++++++------- 2 files changed, 177 insertions(+), 37 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index d16429794..9dd5889bd 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -21,10 +21,11 @@ import ( "math" "math/big" - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/core/vm" - "github.com/Onther-Tech/plasma-evm/log" - "github.com/Onther-Tech/plasma-evm/params" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/stamina" ) var ( @@ -170,6 +171,26 @@ func (st *StateTransition) buyGas() error { } } +func (st *StateTransition) buyDelegateeGas(delegatee common.Address) error { + mgval := new(big.Int).Mul(new(big.Int).SetUint64(st.msg.Gas()), st.gasPrice) + balance, err := stamina.GetStamina(st.evm, delegatee) + if err != nil { + return err + } + + if balance.Cmp(mgval) < 0 { + return errInsufficientBalanceForGas + } + if err := st.gp.SubGas(st.msg.Gas()); err != nil { + return err + } + st.gas += st.msg.Gas() + + st.initialGas = st.msg.Gas() + stamina.SubtractStamina(st.evm, delegatee, mgval) + return nil +} + func (st *StateTransition) preCheck() error { // Make sure this transaction's nonce is correct. if st.msg.CheckNonce() { @@ -183,18 +204,86 @@ func (st *StateTransition) preCheck() error { return st.buyGas() } +func (st *StateTransition) preDelegateeCheck(delegatee common.Address) error { + // Make sure this transaction's nonce is correct. + if st.msg.CheckNonce() { + nonce := st.state.GetNonce(st.msg.From()) + if nonce < st.msg.Nonce() { + return ErrNonceTooHigh + } else if nonce > st.msg.Nonce() { + return ErrNonceTooLow + } + } + + return st.buyDelegateeGas(delegatee) +} + // TransitionDb will transition the state by applying the current message and -// returning the result including the used gas. It returns an error if failed. -// An error indicates a consensus issue. +// returning the result including the the used gas. It returns an error if it +// failed. An error indicates a consensus issue. +// TODO: moscow - apply message 수정 부분. +// st.evm.Context에 추가 구현된 Stamina 함수들을 사용. func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bool, err error) { - if err = st.preCheck(); err != nil { - return - } + var ( + evm = st.evm + // vm errors do not effect consensus and are therefor + // not assigned to err, except for insufficient balance + // error. + vmerr error + ) + msg := st.msg sender := vm.AccountRef(msg.From()) homestead := st.evm.ChainConfig().IsHomestead(st.evm.BlockNumber) contractCreation := msg.To() == nil + // get delegatee + delegatee, _ := stamina.GetDelegatee(evm, msg.From()) + log.Info("GetDelegatee", "from", msg.From(), "delegatee", delegatee) + + // moscow - if has delegatee + if delegatee != common.HexToAddress("0x00") { + if err = st.preDelegateeCheck(delegatee); err != nil { + return + } + + // Pay intrinsic gas + gas, err := IntrinsicGas(st.data, contractCreation, homestead) + if err != nil { + return nil, 0, false, err + } + if err = st.useGas(gas); err != nil { + return nil, 0, false, err + } + + if contractCreation { + ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value) + } else { + // Increment the nonce for the next transaction + st.state.SetNonce(msg.From(), st.state.GetNonce(sender.Address())+1) + ret, st.gas, vmerr = evm.Call(sender, st.to(), st.data, st.gas, st.value) + } + if vmerr != nil { + log.Debug("VM returned with error", "err", vmerr) + // The only possible consensus-error would be if there wasn't + // sufficient balance to make the transfer happen. The first + // balance transfer may never fail. + if vmerr == vm.ErrInsufficientBalance { + return nil, 0, false, vmerr + } + } + st.refundDelegateeGas(delegatee) + // TODO: gas fee to miner + st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice)) + + return ret, st.gasUsed(), vmerr != nil, err + } + + // moscow - original version + if err = st.preCheck(); err != nil { + return + } + // Pay intrinsic gas gas, err := IntrinsicGas(st.data, contractCreation, homestead) if err != nil { @@ -204,13 +293,6 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo return nil, 0, false, err } - var ( - evm = st.evm - // vm errors do not effect consensus and are therefor - // not assigned to err, except for insufficient balance - // error. - vmerr error - ) if contractCreation { ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value) } else { @@ -253,6 +335,23 @@ func (st *StateTransition) refundGas() { st.gp.AddGas(st.gas) } +func (st *StateTransition) refundDelegateeGas(delegatee common.Address) { + // Apply refund counter, capped to half of the used gas. + refund := st.gasUsed() / 2 + if refund > st.state.GetRefund() { + refund = st.state.GetRefund() + } + st.gas += refund + + // Return ETH for remaining gas, exchanged at the original rate. + remaining := new(big.Int).Mul(new(big.Int).SetUint64(st.gas), st.gasPrice) + stamina.AddStamina(st.evm, delegatee, remaining) + + // Also return remaining gas to the block gas counter so it is + // available for the next transaction. + st.gp.AddGas(st.gas) +} + // gasUsed returns the amount of gas used up by the state transition. func (st *StateTransition) gasUsed() uint64 { return st.initialGas - st.gas diff --git a/core/tx_pool.go b/core/tx_pool.go index 705dcdde6..ac56201fa 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -30,10 +30,13 @@ import ( "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/stamina" + staminaCommon "github.com/ethereum/go-ethereum/stamina/common" ) const ( @@ -77,6 +80,13 @@ var ( // than some meaningful limit a user might use. This is not a consensus error // making the transaction invalid, rather a DOS protection. ErrOversizedData = errors.New("oversized data") + + // moscow - stamina related error + // TODO: change variable name and message + ErrStaminaTxSigner = errors.New("failed to get signer") + ErrStaminaGetDelegatee = errors.New("failed to get delegatee") + ErrInsufficientStamina = errors.New("insufficient funds for gas * price") + ErrInsufficientValue = errors.New("insufficient funds for value") ) var ( @@ -605,21 +615,41 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if pool.currentState.GetNonce(from) > tx.Nonce() { return ErrNonceTooLow } - // Transactor should have enough funds to cover the costs - // cost == V + GP * GL - if from == params.NullAddress { - return nil + + // moscow - delegatee 고려하기 + // 검증할 때의 스태미나와 마이닝 될 때의 스태미나가 다를 텐데.. + evm := pool.newStaticEVM() + delegatee, err := stamina.GetDelegatee(evm, from) + if err != nil { + return ErrStaminaGetDelegatee + } + + if delegatee != common.HexToAddress("0x00") { + mgval := new(big.Int).Mul(tx.GasPrice(), big.NewInt(int64(tx.Gas()))) + + // delegatee should have enough stemina + // cost == GP * GL + if stamina, _ := stamina.GetStamina(evm, delegatee); stamina.Cmp(mgval) < 0 { + return ErrInsufficientStamina + } + // sender should have enough value + if pool.currentState.GetBalance(from).Cmp(tx.Value()) < 0 { + return ErrInsufficientValue + } } else { + // Transactor should have enough funds to cover the costs + // cost == V + GP * GL if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 { return ErrInsufficientFunds } - intrGas, err := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead) - if err != nil { - return err - } - if tx.Gas() < intrGas { - return ErrIntrinsicGas - } + } + + intrGas, err := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead) + if err != nil { + return err + } + if tx.Gas() < intrGas { + return ErrIntrinsicGas } return nil } @@ -966,18 +996,29 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { pool.all.Remove(hash) pool.priced.Removed() } + // Drop all transactions that are too costly (low balance or out of gas) - if addr == params.NullAddress { - continue + // moscow - do not drop tx if delegatee has enough stamina + evm := pool.newStaticEVM() + delegatee, _ := stamina.GetDelegatee(evm, addr) + stamina, _ := stamina.GetStamina(evm, delegatee) + balance := pool.currentState.GetBalance(addr) + + var costlimit *big.Int + + if stamina.Cmp(balance) >= 0 { + costlimit = stamina } else { - drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas) - for _, tx := range drops { - hash := tx.Hash() - log.Trace("Removed unpayable queued transaction", "hash", hash) - pool.all.Remove(hash) - pool.priced.Removed() - queuedNofundsCounter.Inc(1) - } + costlimit = balance + } + + drops, _ := list.Filter(costlimit, pool.currentMaxGas) + for _, tx := range drops { + hash := tx.Hash() + log.Trace("Removed unpayable queued transaction", "hash", hash) + pool.all.Remove(hash) + pool.priced.Removed() + queuedNofundsCounter.Inc(1) } // Gather all executable transactions and promote them for _, tx := range list.Ready(pool.pendingState.GetNonce(addr)) { From ca435734156341499a0000ecd37790f59ce23b84 Mon Sep 17 00:00:00 2001 From: 4000D Date: Tue, 24 Jul 2018 15:51:00 +0900 Subject: [PATCH 07/26] stamina, contracts/stamina: update Stamina contract --- contracts/stamina/contract/Stamina.sol | 264 +++++++++--- contracts/stamina/contract/stamina.go | 539 ++++++++++++++++++++----- stamina/common/config.go | 2 +- 3 files changed, 643 insertions(+), 162 deletions(-) diff --git a/contracts/stamina/contract/Stamina.sol b/contracts/stamina/contract/Stamina.sol index 2c64142f9..50dca6e07 100644 --- a/contracts/stamina/contract/Stamina.sol +++ b/contracts/stamina/contract/Stamina.sol @@ -1,15 +1,24 @@ pragma solidity ^0.4.24; + contract Stamina { + // Withdrawal handles withdrawal request + struct Withdrawal { + uint128 amount; + uint128 requestBlockNumber; + address delegatee; + bool processed; + } + /** * Internal States */ - // delegatee of `from` account - // `from` => `delegatee` + // delegatee of `delegator` account + // `delegator` => `delegatee` mapping (address => address) _delegatee; - // Stamina balance of delegatee - // `delegatee` => `balance` + // stamina of delegatee + // `delegatee` => `stamina` mapping (address => uint) _stamina; // total deposit of delegatee @@ -20,21 +29,40 @@ contract Stamina { // `depositor` => `delegatee` => `deposit` mapping (address => mapping (address => uint)) _deposit; - uint public t = 0xdead; + // last recovery block of delegatee + mapping (address => uint256) _last_recovery_block; - bool public initialized; + // depositor => [index] => Withdrawal + mapping (address => Withdrawal[]) _withdrawal; + mapping (address => uint256) _last_processed_withdrawal; + mapping (address => uint) _num_recovery; /** * Public States */ + bool public initialized; + uint public MIN_DEPOSIT; + uint public RECOVER_EPOCH_LENGTH; // stamina is recovered when block number % RECOVER_DELAY == 0 + uint public WITHDRAWAL_DELAY; // Refund will be made WITHDRAWAL_DELAY blocks after depositor request Withdrawal. + // WITHDRAWAL_DELAY prevents immediate withdrawal. + // RECOVER_EPOCH_LENGTH * 2 < WITHDRAWAL_DELAY + + + bool public development = true; // if the contract is inserted directly into + // genesis block, it will be false + /** * Modifiers */ modifier onlyChain() { - // TODO: uncomment below - // require(msg.sender == address(0)); + require(development || msg.sender == address(0)); + _; + } + + modifier onlyInitialized() { + require(initialized); _; } @@ -42,16 +70,25 @@ contract Stamina { * Events */ event Deposited(address indexed depositor, address indexed delegatee, uint amount); - event Withdrawn(address indexed depositor, address indexed delegatee, uint amount); - event DelegateeChanged(address delegater, address oldDelegatee, address newDelegatee); + event DelegateeChanged(address delegator, address oldDelegatee, address newDelegatee); + event WithdrawalRequested(address indexed depositor, address indexed delegatee, uint amount, uint requestBlockNumber, uint withdrawalIndex); + event Withdrawan(address indexed depositor, address indexed delegatee, uint amount, uint withdrawalIndex); /** * Init */ - function init(uint minDeposit) external { + function init(uint minDeposit, uint recoveryEpochLength, uint withdrawalDelay) external { require(!initialized); + require(minDeposit > 0); + require(recoveryEpochLength > 0); + require(withdrawalDelay > 0); + + require(recoveryEpochLength * 2 < withdrawalDelay); + MIN_DEPOSIT = minDeposit; + RECOVER_EPOCH_LENGTH = recoveryEpochLength; + WITHDRAWAL_DELAY = withdrawalDelay; initialized = true; } @@ -59,8 +96,8 @@ contract Stamina { /** * Getters */ - function getDelegatee(address delegater) public view returns (address) { - return _delegatee[delegater]; + function getDelegatee(address delegator) public view returns (address) { + return _delegatee[delegator]; } function getStamina(address addr) public view returns (uint) { @@ -75,79 +112,204 @@ contract Stamina { return _deposit[depositor][delegatee]; } + function getNumWithdrawals(address depositor) public view returns (uint) { + return _withdrawal[depositor].length; + } + + function getLastRecoveryBlock(address delegatee) public view returns (uint) { + return _last_recovery_block[delegatee]; + } + + function getNumRecovery(address delegatee) public view returns (uint) { + return _num_recovery[delegatee]; + } + + function getWithdrawal(address depositor, uint withdrawalIndex) + public + view + returns (uint128 amount, uint128 requestBlockNumber, address delegatee, bool processed) + { + require(withdrawalIndex < getNumWithdrawals(depositor)); + + Withdrawal memory w = _withdrawal[depositor][withdrawalIndex]; + + amount = w.amount; + requestBlockNumber = w.requestBlockNumber; + delegatee = w.delegatee; + processed = w.processed; + } + /** - * Setters and External functions + * Setters */ - /// @notice set `msg.sender` as delegatee of `delegater` - function setDelegatee(address delegater) external returns (bool) { - address oldDelegatee = _delegatee[delegater]; + /// @notice Set `msg.sender` as delegatee of `delegator` + function setDelegatee(address delegator) + external + onlyInitialized + returns (bool) + { + address oldDelegatee = _delegatee[delegator]; - _delegatee[delegater] = msg.sender; + _delegatee[delegator] = msg.sender; - emit DelegateeChanged(delegater, oldDelegatee, msg.sender); + emit DelegateeChanged(delegator, oldDelegatee, msg.sender); return true; } - /// @notice deposit Ether to delegatee - function deposit(address delegatee) external payable returns (bool) { + /** + * Deposit / Withdraw + */ + /// @notice Deposit Ether to delegatee + function deposit(address delegatee) + external + payable + onlyInitialized + returns (bool) + { require(msg.value >= MIN_DEPOSIT); - uint dTotalDeposit = _total_deposit[delegatee]; - uint fDeposit = _deposit[msg.sender][delegatee]; + uint totalDeposit = _total_deposit[delegatee]; + uint deposit = _deposit[msg.sender][delegatee]; + uint stamina = _stamina[delegatee]; + + // check overflow + require(totalDeposit + msg.value > totalDeposit); + require(deposit + msg.value > deposit); + require(stamina + msg.value > stamina); - require(dTotalDeposit + msg.value > dTotalDeposit); - require(fDeposit + msg.value > fDeposit); + _total_deposit[delegatee] = totalDeposit + msg.value; + _deposit[msg.sender][delegatee] = deposit + msg.value; + _stamina[delegatee] = stamina + msg.value; - _total_deposit[delegatee] = dTotalDeposit + msg.value; - _deposit[msg.sender][delegatee] = fDeposit + msg.value; + if (_last_recovery_block[delegatee] == 0) { + _last_recovery_block[delegatee] = block.number; + } emit Deposited(msg.sender, delegatee, msg.value); return true; } - /// @notice request to withdraw Ether from delegatee. it store Ether to Escrow contract. - /// later `withdrawPayments` transfers Ether from Escrow to the depositor - function withdraw(address delegatee, uint amount) external returns (bool) { - uint dTotalDeposit = _total_deposit[delegatee]; - uint fDeposit = _deposit[msg.sender][delegatee]; + /// @notice Request to withdraw deposit of delegatee. Ether can be withdrawn + /// after WITHDRAWAL_DELAY blocks + function requestWithdrawal(address delegatee, uint amount) + external + onlyInitialized + returns (bool) + { + require(amount > 0); - require(dTotalDeposit - amount < dTotalDeposit); - require(fDeposit - amount < fDeposit); + uint totalDeposit = _total_deposit[delegatee]; + uint deposit = _deposit[msg.sender][delegatee]; + uint stamina = _stamina[delegatee]; - _total_deposit[delegatee] = dTotalDeposit - amount; - _deposit[msg.sender][delegatee] = fDeposit - amount; + require(deposit > 0); - msg.sender.transfer(amount); + // check underflow + require(totalDeposit - amount < totalDeposit); + require(deposit - amount < deposit); // this guarentees deposit >= amount + + _total_deposit[delegatee] = totalDeposit - amount; + _deposit[msg.sender][delegatee] = deposit - amount; + + // NOTE: Is accepting the request right when stamina < amount? + if (stamina > amount) { + _stamina[delegatee] = stamina - amount; + } else { + _stamina[delegatee] = 0; + } + + Withdrawal[] storage withdrawals = _withdrawal[msg.sender]; + + uint withdrawalIndex = withdrawals.length; + Withdrawal storage withdrawal = withdrawals[withdrawals.length++]; - emit Withdrawn(msg.sender, delegatee, amount); + withdrawal.amount = uint128(amount); + withdrawal.requestBlockNumber = uint128(block.number); + withdrawal.delegatee = delegatee; + + emit WithdrawalRequested(msg.sender, delegatee, amount, block.number, withdrawalIndex); return true; } - /// @notice reset stamina up to total deposit of delegatee - function resetStamina(address delegatee) external onlyChain { - _stamina[delegatee] = _total_deposit[delegatee]; + /// @notice Process last unprocessed withdrawal request. + function withdraw() external returns (bool) { + Withdrawal[] storage withdrawals = _withdrawal[msg.sender]; + require(withdrawals.length > 0); + + uint lastWithdrawalIndex = _last_processed_withdrawal[msg.sender]; + uint withdrawalIndex; + + if (lastWithdrawalIndex == 0 && !withdrawals[0].processed) { + withdrawalIndex = 0; + } else if (lastWithdrawalIndex == 0) { // lastWithdrawalIndex == 0 && withdrawals[0].processed + require(withdrawals.length >= 2); + + withdrawalIndex = 1; + } else { + withdrawalIndex = lastWithdrawalIndex + 1; + } + + // double check out of index + require(withdrawalIndex < withdrawals.length); + + Withdrawal storage withdrawal = _withdrawal[msg.sender][withdrawalIndex]; + + // check withdrawal condition + require(!withdrawal.processed); + require(withdrawal.requestBlockNumber + WITHDRAWAL_DELAY <= block.number); + + uint amount = uint(withdrawal.amount); + + // withdrawal is processed + withdrawal.processed = true; + + // mark processed withdrawal index + _last_processed_withdrawal[msg.sender] = withdrawalIndex; + + // tranfser ether to depositor + msg.sender.transfer(amount); + emit Withdrawan(msg.sender, withdrawal.delegatee, amount, withdrawalIndex); + + return true; } - /// @notice add stamina of delegatee. The upper bound of stamina is total deposit of delegatee. + /** + * Stamina modification (only blockchain) + * No event emitted during these functions. + */ + /// @notice Add stamina of delegatee. The upper bound of stamina is total deposit of delegatee. + /// addStamina is called when remaining gas is refunded. So we can recover stamina + /// if RECOVER_EPOCH_LENGTH blocks are passed. + /// + /// NOTE: can use block.number here? function addStamina(address delegatee, uint amount) external onlyChain returns (bool) { - uint dTotalDeposit = _total_deposit[delegatee]; - uint dBalance = _stamina[delegatee]; + // if enough blocks has passed since the last recovery, recover whole used stamina. + if (_last_recovery_block[delegatee] + RECOVER_EPOCH_LENGTH <= block.number) { + _stamina[delegatee] = _total_deposit[delegatee]; + _last_recovery_block[delegatee] = block.number; + _num_recovery[delegatee] += 1; + + return true; + } + + uint totalDeposit = _total_deposit[delegatee]; + uint stamina = _stamina[delegatee]; - require(dBalance + amount > dBalance); - uint targetBalance = dBalance + amount; + require(stamina + amount > stamina); + uint targetBalance = stamina + amount; - if (targetBalance > dTotalDeposit) _stamina[delegatee] = dTotalDeposit; + if (targetBalance > totalDeposit) _stamina[delegatee] = totalDeposit; else _stamina[delegatee] = targetBalance; return true; } - /// @notice subtracte stamina of delegatee. + /// @notice Subtract stamina of delegatee. function subtractStamina(address delegatee, uint amount) external onlyChain returns (bool) { - uint dBalance = _stamina[delegatee]; + uint stamina = _stamina[delegatee]; - require(dBalance - amount < dBalance); - _stamina[delegatee] = dBalance - amount; + require(stamina - amount < stamina); + _stamina[delegatee] = stamina - amount; return true; } } diff --git a/contracts/stamina/contract/stamina.go b/contracts/stamina/contract/stamina.go index 11dd08810..f48484a90 100644 --- a/contracts/stamina/contract/stamina.go +++ b/contracts/stamina/contract/stamina.go @@ -16,10 +16,10 @@ import ( ) // StaminaABI is the input ABI used to generate the binding from. -const StaminaABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"resetStamina\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getTotalDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"t\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegater\",\"type\":\"address\"}],\"name\":\"getDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"minDeposit\",\"type\":\"uint256\"}],\"name\":\"init\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"subtractStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MIN_DEPOSIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegater\",\"type\":\"address\"}],\"name\":\"setDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"delegater\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"oldDelegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"newDelegatee\",\"type\":\"address\"}],\"name\":\"DelegateeChanged\",\"type\":\"event\"}]" +const StaminaABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"WITHDRAWAL_DELAY\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"RECOVER_EPOCH_LENGTH\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"getWithdrawal\",\"outputs\":[{\"name\":\"amount\",\"type\":\"uint128\"},{\"name\":\"requestBlockNumber\",\"type\":\"uint128\"},{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"processed\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getTotalDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"minDeposit\",\"type\":\"uint256\"},{\"name\":\"recoveryEpochLength\",\"type\":\"uint256\"},{\"name\":\"withdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"init\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getLastRecoveryBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"getDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getNumRecovery\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"subtractStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"}],\"name\":\"getNumWithdrawals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"requestWithdrawal\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MIN_DEPOSIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"setDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"oldDelegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"newDelegatee\",\"type\":\"address\"}],\"name\":\"DelegateeChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"WithdrawalRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"Withdrawan\",\"type\":\"event\"}]" // StaminaBin is the compiled bytecode used for deploying new contracts. -const StaminaBin = `0x608060405261dead60045534801561001657600080fd5b506107c3806100266000396000f3006080604052600436106100cf5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663158ef93e81146100d45780633900e4ec146100fd57806362eb5d9814610142578063857184d11461017757806392d0d153146101aa5780639b4e735f146101bf578063b7b0422d1461020e578063bcac973614610238578063c35082a914610271578063d1c0c042146102ac578063e1e158a5146102e5578063e842a64b146102fa578063f340fa011461032d578063f3fef3a314610353575b600080fd5b3480156100e057600080fd5b506100e961038c565b604080519115158252519081900360200190f35b34801561010957600080fd5b506101306004803603602081101561012057600080fd5b5035600160a060020a0316610395565b60408051918252519081900360200190f35b34801561014e57600080fd5b506101756004803603602081101561016557600080fd5b5035600160a060020a03166103b0565b005b34801561018357600080fd5b506101306004803603602081101561019a57600080fd5b5035600160a060020a03166103d6565b3480156101b657600080fd5b506101306103f1565b3480156101cb57600080fd5b506101f2600480360360208110156101e257600080fd5b5035600160a060020a03166103f7565b60408051600160a060020a039092168252519081900360200190f35b34801561021a57600080fd5b506101756004803603602081101561023157600080fd5b5035610415565b34801561024457600080fd5b506100e96004803603604081101561025b57600080fd5b50600160a060020a038135169060200135610437565b34801561027d57600080fd5b506101306004803603604081101561029457600080fd5b50600160a060020a03813581169160200135166104bc565b3480156102b857600080fd5b506100e9600480360360408110156102cf57600080fd5b50600160a060020a0381351690602001356104e7565b3480156102f157600080fd5b50610130610536565b34801561030657600080fd5b506100e96004803603602081101561031d57600080fd5b5035600160a060020a031661053c565b6100e96004803603602081101561034357600080fd5b5035600160a060020a03166105c5565b34801561035f57600080fd5b506100e96004803603604081101561037657600080fd5b50600160a060020a03813516906020013561069a565b60055460ff1681565b600160a060020a031660009081526001602052604090205490565b600160a060020a0316600090815260026020908152604080832054600190925290912055565b600160a060020a031660009081526002602052604090205490565b60045481565b600160a060020a039081166000908152602081905260409020541690565b60055460ff161561042557600080fd5b6006556005805460ff19166001179055565b600160a060020a0382166000908152600260209081526040808320546001909252822054838101811061046957600080fd5b8084018281111561049457600160a060020a03861660009081526001602052604090208390556104b0565b600160a060020a03861660009081526001602052604090208190555b50600195945050505050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600160a060020a038216600090815260016020526040812054828103811161050e57600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b60065481565b600160a060020a03808216600081815260208181526040808320805473ffffffffffffffffffffffffffffffffffffffff1981163390811790925582519586529095169184018290528381019490945292519092917f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692919081900360600190a150600192915050565b6006546000903410156105d757600080fd5b600160a060020a0382166000818152600260209081526040808320543384526003835281842094845293909152902054348201821061061557600080fd5b348101811061062357600080fd5b600160a060020a03841660008181526002602090815260408083203487810190915533808552600384528285208686528452938290208682019055815190815290517f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7929181900390910190a35060019392505050565b600160a060020a038216600081815260026020908152604080832054338452600383528184209484529390915281205490919083820382116106db57600080fd5b83810381116106e957600080fd5b600160a060020a0385166000818152600260209081526040808320888703905533808452600383528184209484529390915280822087850390555186156108fc0291879190818181858888f1935050505015801561074b573d6000803e3d6000fd5b50604080518581529051600160a060020a0387169133917fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb9181900360200190a35060019493505050505600a165627a7a72305820a011f3b07b2d2070faaf83531209f631ad3e33cd6aa2a5012e67d91316a8ef4d0029` +const StaminaBin = `0x6080604052600c805460ff1916600117905534801561001d57600080fd5b50610f5b8061002d6000396000f3006080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b146101ae5780635be4f765146101c35780637b929c2714610241578063857184d1146102565780638cd8db8a14610289578063937aaef1146102c15780639b4e735f146102f4578063b69ad63b14610343578063bcac973614610376578063c35082a9146103af578063d1c0c042146103ea578063d898ae1c14610423578063da95ebf714610456578063e1e158a51461048f578063e842a64b146104a4578063f340fa01146104d7575b600080fd5b34801561012257600080fd5b5061012b6104fd565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b610503565b34801561015e57600080fd5b50610167610509565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b6004803603602081101561019e57600080fd5b5035600160a060020a0316610512565b3480156101ba57600080fd5b5061016761052d565b3480156101cf57600080fd5b506101fc600480360360408110156101e657600080fd5b50600160a060020a038135169060200135610737565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561024d57600080fd5b5061016761081a565b34801561026257600080fd5b5061012b6004803603602081101561027957600080fd5b5035600160a060020a0316610823565b34801561029557600080fd5b506102bf600480360360608110156102ac57600080fd5b508035906020810135906040013561083e565b005b3480156102cd57600080fd5b5061012b600480360360208110156102e457600080fd5b5035600160a060020a031661089f565b34801561030057600080fd5b506103276004803603602081101561031757600080fd5b5035600160a060020a03166108ba565b60408051600160a060020a039092168252519081900360200190f35b34801561034f57600080fd5b5061012b6004803603602081101561036657600080fd5b5035600160a060020a03166108d8565b34801561038257600080fd5b506101676004803603604081101561039957600080fd5b50600160a060020a0381351690602001356108f3565b3480156103bb57600080fd5b5061012b600480360360408110156103d257600080fd5b50600160a060020a0381358116916020013516610a02565b3480156103f657600080fd5b506101676004803603604081101561040d57600080fd5b50600160a060020a038135169060200135610a2d565b34801561042f57600080fd5b5061012b6004803603602081101561044657600080fd5b5035600160a060020a0316610a99565b34801561046257600080fd5b506101676004803603604081101561047957600080fd5b50600160a060020a038135169060200135610ab4565b34801561049b57600080fd5b5061012b610cba565b3480156104b057600080fd5b50610167600480360360208110156104c757600080fd5b5035600160a060020a0316610cc0565b610167600480360360208110156104ed57600080fd5b5035600160a060020a0316610d59565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b3360009081526005602052604081208054821061054957600080fd5b336000908152600660205260408120549081158015610593575082600081548110151561057257fe5b906000526020600020906002020160010160149054906101000a900460ff16155b156105a0575060006105c4565b8115156105be578254600211156105b657600080fd5b5060016105c4565b50600181015b825481106105d157600080fd5b3360009081526005602052604081208054839081106105ec57fe5b906000526020600020906002020190508060010160149054906101000a900460ff1615151561061a57600080fd5b600b548154437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561065557600080fd5b805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156106de573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927ff105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879928290030190a36001955050505050505b90565b60008060008061074686610a99565b851061075157600080fd5b610759610e99565b600160a060020a038716600090815260056020526040902080548790811061077d57fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600160a060020a031660009081526002602052604090205490565b60085460ff161561084e57600080fd5b6000831161085b57600080fd5b6000821161086857600080fd5b6000811161087557600080fd5b60028202811161088457600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009060ff1680610905575033155b151561091057600080fd5b600a54600160a060020a0384166000908152600460205260409020544391011161097a5750600160a060020a0382166000908152600260209081526040808320546001808452828520919091556004835281842043905560079092529091208054820190556109fc565b600160a060020a03831660009081526002602090815260408083205460019092529091205483810181106109ad57600080fd5b808401828111156109d857600160a060020a03861660009081526001602052604090208390556109f4565b600160a060020a03861660009081526001602052604090208190555b600193505050505b92915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c5460009060ff1680610a3f575033155b1515610a4a57600080fd5b600160a060020a0383166000908152600160205260409020548281038111610a7157600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b60085460009060ff161515610ac857600080fd5b60008211610ad557600080fd5b600160a060020a0383166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205490918211610b1a57600080fd5b8483038311610b2857600080fd5b8482038211610b3657600080fd5b600160a060020a038616600081815260026020908152604080832089880390553383526003825280832093835292905220858303905584811115610b9657600160a060020a03861660009081526001602052604090208582039055610bb0565b600160a060020a0386166000908152600160205260408120555b336000908152600560205260408120805490918282610bd28260018301610ec0565b81548110610bdc57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009060ff161515610cd457600080fd5b600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b60085460009060ff161515610d6d57600080fd5b600954341015610d7c57600080fd5b600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610dc357600080fd5b3482018210610dd157600080fd5b3481018110610ddf57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610e4e57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610eec57600202816002028360005260206000209182019101610eec9190610ef1565b505050565b61073491905b80821115610f2b576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ef7565b50905600a165627a7a72305820a02bfd230d4c61a1e1f620f19aa68a9f2b4e21138813f3eb509c3191aa204f1b0029` // DeployStamina deploys a new Ethereum contract, binding an instance of Stamina to it. func DeployStamina(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Stamina, error) { @@ -202,30 +202,108 @@ func (_Stamina *StaminaCallerSession) MINDEPOSIT() (*big.Int, error) { return _Stamina.Contract.MINDEPOSIT(&_Stamina.CallOpts) } +// RECOVEREPOCHLENGTH is a free data retrieval call binding the contract method 0x1556d8ac. +// +// Solidity: function RECOVER_EPOCH_LENGTH() constant returns(uint256) +func (_Stamina *StaminaCaller) RECOVEREPOCHLENGTH(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "RECOVER_EPOCH_LENGTH") + return *ret0, err +} + +// RECOVEREPOCHLENGTH is a free data retrieval call binding the contract method 0x1556d8ac. +// +// Solidity: function RECOVER_EPOCH_LENGTH() constant returns(uint256) +func (_Stamina *StaminaSession) RECOVEREPOCHLENGTH() (*big.Int, error) { + return _Stamina.Contract.RECOVEREPOCHLENGTH(&_Stamina.CallOpts) +} + +// RECOVEREPOCHLENGTH is a free data retrieval call binding the contract method 0x1556d8ac. +// +// Solidity: function RECOVER_EPOCH_LENGTH() constant returns(uint256) +func (_Stamina *StaminaCallerSession) RECOVEREPOCHLENGTH() (*big.Int, error) { + return _Stamina.Contract.RECOVEREPOCHLENGTH(&_Stamina.CallOpts) +} + +// WITHDRAWALDELAY is a free data retrieval call binding the contract method 0x0ebb172a. +// +// Solidity: function WITHDRAWAL_DELAY() constant returns(uint256) +func (_Stamina *StaminaCaller) WITHDRAWALDELAY(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "WITHDRAWAL_DELAY") + return *ret0, err +} + +// WITHDRAWALDELAY is a free data retrieval call binding the contract method 0x0ebb172a. +// +// Solidity: function WITHDRAWAL_DELAY() constant returns(uint256) +func (_Stamina *StaminaSession) WITHDRAWALDELAY() (*big.Int, error) { + return _Stamina.Contract.WITHDRAWALDELAY(&_Stamina.CallOpts) +} + +// WITHDRAWALDELAY is a free data retrieval call binding the contract method 0x0ebb172a. +// +// Solidity: function WITHDRAWAL_DELAY() constant returns(uint256) +func (_Stamina *StaminaCallerSession) WITHDRAWALDELAY() (*big.Int, error) { + return _Stamina.Contract.WITHDRAWALDELAY(&_Stamina.CallOpts) +} + +// Development is a free data retrieval call binding the contract method 0x7b929c27. +// +// Solidity: function development() constant returns(bool) +func (_Stamina *StaminaCaller) Development(opts *bind.CallOpts) (bool, error) { + var ( + ret0 = new(bool) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "development") + return *ret0, err +} + +// Development is a free data retrieval call binding the contract method 0x7b929c27. +// +// Solidity: function development() constant returns(bool) +func (_Stamina *StaminaSession) Development() (bool, error) { + return _Stamina.Contract.Development(&_Stamina.CallOpts) +} + +// Development is a free data retrieval call binding the contract method 0x7b929c27. +// +// Solidity: function development() constant returns(bool) +func (_Stamina *StaminaCallerSession) Development() (bool, error) { + return _Stamina.Contract.Development(&_Stamina.CallOpts) +} + // GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. // -// Solidity: function getDelegatee(delegater address) constant returns(address) -func (_Stamina *StaminaCaller) GetDelegatee(opts *bind.CallOpts, delegater common.Address) (common.Address, error) { +// Solidity: function getDelegatee(delegator address) constant returns(address) +func (_Stamina *StaminaCaller) GetDelegatee(opts *bind.CallOpts, delegator common.Address) (common.Address, error) { var ( ret0 = new(common.Address) ) out := ret0 - err := _Stamina.contract.Call(opts, out, "getDelegatee", delegater) + err := _Stamina.contract.Call(opts, out, "getDelegatee", delegator) return *ret0, err } // GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. // -// Solidity: function getDelegatee(delegater address) constant returns(address) -func (_Stamina *StaminaSession) GetDelegatee(delegater common.Address) (common.Address, error) { - return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegater) +// Solidity: function getDelegatee(delegator address) constant returns(address) +func (_Stamina *StaminaSession) GetDelegatee(delegator common.Address) (common.Address, error) { + return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegator) } // GetDelegatee is a free data retrieval call binding the contract method 0x9b4e735f. // -// Solidity: function getDelegatee(delegater address) constant returns(address) -func (_Stamina *StaminaCallerSession) GetDelegatee(delegater common.Address) (common.Address, error) { - return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegater) +// Solidity: function getDelegatee(delegator address) constant returns(address) +func (_Stamina *StaminaCallerSession) GetDelegatee(delegator common.Address) (common.Address, error) { + return _Stamina.Contract.GetDelegatee(&_Stamina.CallOpts, delegator) } // GetDeposit is a free data retrieval call binding the contract method 0xc35082a9. @@ -254,6 +332,84 @@ func (_Stamina *StaminaCallerSession) GetDeposit(depositor common.Address, deleg return _Stamina.Contract.GetDeposit(&_Stamina.CallOpts, depositor, delegatee) } +// GetLastRecoveryBlock is a free data retrieval call binding the contract method 0x937aaef1. +// +// Solidity: function getLastRecoveryBlock(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetLastRecoveryBlock(opts *bind.CallOpts, delegatee common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getLastRecoveryBlock", delegatee) + return *ret0, err +} + +// GetLastRecoveryBlock is a free data retrieval call binding the contract method 0x937aaef1. +// +// Solidity: function getLastRecoveryBlock(delegatee address) constant returns(uint256) +func (_Stamina *StaminaSession) GetLastRecoveryBlock(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetLastRecoveryBlock(&_Stamina.CallOpts, delegatee) +} + +// GetLastRecoveryBlock is a free data retrieval call binding the contract method 0x937aaef1. +// +// Solidity: function getLastRecoveryBlock(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetLastRecoveryBlock(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetLastRecoveryBlock(&_Stamina.CallOpts, delegatee) +} + +// GetNumRecovery is a free data retrieval call binding the contract method 0xb69ad63b. +// +// Solidity: function getNumRecovery(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetNumRecovery(opts *bind.CallOpts, delegatee common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getNumRecovery", delegatee) + return *ret0, err +} + +// GetNumRecovery is a free data retrieval call binding the contract method 0xb69ad63b. +// +// Solidity: function getNumRecovery(delegatee address) constant returns(uint256) +func (_Stamina *StaminaSession) GetNumRecovery(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetNumRecovery(&_Stamina.CallOpts, delegatee) +} + +// GetNumRecovery is a free data retrieval call binding the contract method 0xb69ad63b. +// +// Solidity: function getNumRecovery(delegatee address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetNumRecovery(delegatee common.Address) (*big.Int, error) { + return _Stamina.Contract.GetNumRecovery(&_Stamina.CallOpts, delegatee) +} + +// GetNumWithdrawals is a free data retrieval call binding the contract method 0xd898ae1c. +// +// Solidity: function getNumWithdrawals(depositor address) constant returns(uint256) +func (_Stamina *StaminaCaller) GetNumWithdrawals(opts *bind.CallOpts, depositor common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Stamina.contract.Call(opts, out, "getNumWithdrawals", depositor) + return *ret0, err +} + +// GetNumWithdrawals is a free data retrieval call binding the contract method 0xd898ae1c. +// +// Solidity: function getNumWithdrawals(depositor address) constant returns(uint256) +func (_Stamina *StaminaSession) GetNumWithdrawals(depositor common.Address) (*big.Int, error) { + return _Stamina.Contract.GetNumWithdrawals(&_Stamina.CallOpts, depositor) +} + +// GetNumWithdrawals is a free data retrieval call binding the contract method 0xd898ae1c. +// +// Solidity: function getNumWithdrawals(depositor address) constant returns(uint256) +func (_Stamina *StaminaCallerSession) GetNumWithdrawals(depositor common.Address) (*big.Int, error) { + return _Stamina.Contract.GetNumWithdrawals(&_Stamina.CallOpts, depositor) +} + // GetStamina is a free data retrieval call binding the contract method 0x3900e4ec. // // Solidity: function getStamina(addr address) constant returns(uint256) @@ -306,6 +462,50 @@ func (_Stamina *StaminaCallerSession) GetTotalDeposit(delegatee common.Address) return _Stamina.Contract.GetTotalDeposit(&_Stamina.CallOpts, delegatee) } +// GetWithdrawal is a free data retrieval call binding the contract method 0x5be4f765. +// +// Solidity: function getWithdrawal(depositor address, withdrawalIndex uint256) constant returns(amount uint128, requestBlockNumber uint128, delegatee address, processed bool) +func (_Stamina *StaminaCaller) GetWithdrawal(opts *bind.CallOpts, depositor common.Address, withdrawalIndex *big.Int) (struct { + Amount *big.Int + RequestBlockNumber *big.Int + Delegatee common.Address + Processed bool +}, error) { + ret := new(struct { + Amount *big.Int + RequestBlockNumber *big.Int + Delegatee common.Address + Processed bool + }) + out := ret + err := _Stamina.contract.Call(opts, out, "getWithdrawal", depositor, withdrawalIndex) + return *ret, err +} + +// GetWithdrawal is a free data retrieval call binding the contract method 0x5be4f765. +// +// Solidity: function getWithdrawal(depositor address, withdrawalIndex uint256) constant returns(amount uint128, requestBlockNumber uint128, delegatee address, processed bool) +func (_Stamina *StaminaSession) GetWithdrawal(depositor common.Address, withdrawalIndex *big.Int) (struct { + Amount *big.Int + RequestBlockNumber *big.Int + Delegatee common.Address + Processed bool +}, error) { + return _Stamina.Contract.GetWithdrawal(&_Stamina.CallOpts, depositor, withdrawalIndex) +} + +// GetWithdrawal is a free data retrieval call binding the contract method 0x5be4f765. +// +// Solidity: function getWithdrawal(depositor address, withdrawalIndex uint256) constant returns(amount uint128, requestBlockNumber uint128, delegatee address, processed bool) +func (_Stamina *StaminaCallerSession) GetWithdrawal(depositor common.Address, withdrawalIndex *big.Int) (struct { + Amount *big.Int + RequestBlockNumber *big.Int + Delegatee common.Address + Processed bool +}, error) { + return _Stamina.Contract.GetWithdrawal(&_Stamina.CallOpts, depositor, withdrawalIndex) +} + // Initialized is a free data retrieval call binding the contract method 0x158ef93e. // // Solidity: function initialized() constant returns(bool) @@ -332,32 +532,6 @@ func (_Stamina *StaminaCallerSession) Initialized() (bool, error) { return _Stamina.Contract.Initialized(&_Stamina.CallOpts) } -// T is a free data retrieval call binding the contract method 0x92d0d153. -// -// Solidity: function t() constant returns(uint256) -func (_Stamina *StaminaCaller) T(opts *bind.CallOpts) (*big.Int, error) { - var ( - ret0 = new(*big.Int) - ) - out := ret0 - err := _Stamina.contract.Call(opts, out, "t") - return *ret0, err -} - -// T is a free data retrieval call binding the contract method 0x92d0d153. -// -// Solidity: function t() constant returns(uint256) -func (_Stamina *StaminaSession) T() (*big.Int, error) { - return _Stamina.Contract.T(&_Stamina.CallOpts) -} - -// T is a free data retrieval call binding the contract method 0x92d0d153. -// -// Solidity: function t() constant returns(uint256) -func (_Stamina *StaminaCallerSession) T() (*big.Int, error) { - return _Stamina.Contract.T(&_Stamina.CallOpts) -} - // AddStamina is a paid mutator transaction binding the contract method 0xbcac9736. // // Solidity: function addStamina(delegatee address, amount uint256) returns(bool) @@ -400,67 +574,67 @@ func (_Stamina *StaminaTransactorSession) Deposit(delegatee common.Address) (*ty return _Stamina.Contract.Deposit(&_Stamina.TransactOpts, delegatee) } -// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// Init is a paid mutator transaction binding the contract method 0x8cd8db8a. // -// Solidity: function init(minDeposit uint256) returns() -func (_Stamina *StaminaTransactor) Init(opts *bind.TransactOpts, minDeposit *big.Int) (*types.Transaction, error) { - return _Stamina.contract.Transact(opts, "init", minDeposit) +// Solidity: function init(minDeposit uint256, recoveryEpochLength uint256, withdrawalDelay uint256) returns() +func (_Stamina *StaminaTransactor) Init(opts *bind.TransactOpts, minDeposit *big.Int, recoveryEpochLength *big.Int, withdrawalDelay *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "init", minDeposit, recoveryEpochLength, withdrawalDelay) } -// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// Init is a paid mutator transaction binding the contract method 0x8cd8db8a. // -// Solidity: function init(minDeposit uint256) returns() -func (_Stamina *StaminaSession) Init(minDeposit *big.Int) (*types.Transaction, error) { - return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit) +// Solidity: function init(minDeposit uint256, recoveryEpochLength uint256, withdrawalDelay uint256) returns() +func (_Stamina *StaminaSession) Init(minDeposit *big.Int, recoveryEpochLength *big.Int, withdrawalDelay *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit, recoveryEpochLength, withdrawalDelay) } -// Init is a paid mutator transaction binding the contract method 0xb7b0422d. +// Init is a paid mutator transaction binding the contract method 0x8cd8db8a. // -// Solidity: function init(minDeposit uint256) returns() -func (_Stamina *StaminaTransactorSession) Init(minDeposit *big.Int) (*types.Transaction, error) { - return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit) +// Solidity: function init(minDeposit uint256, recoveryEpochLength uint256, withdrawalDelay uint256) returns() +func (_Stamina *StaminaTransactorSession) Init(minDeposit *big.Int, recoveryEpochLength *big.Int, withdrawalDelay *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.Init(&_Stamina.TransactOpts, minDeposit, recoveryEpochLength, withdrawalDelay) } -// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// RequestWithdrawal is a paid mutator transaction binding the contract method 0xda95ebf7. // -// Solidity: function resetStamina(delegatee address) returns() -func (_Stamina *StaminaTransactor) ResetStamina(opts *bind.TransactOpts, delegatee common.Address) (*types.Transaction, error) { - return _Stamina.contract.Transact(opts, "resetStamina", delegatee) +// Solidity: function requestWithdrawal(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactor) RequestWithdrawal(opts *bind.TransactOpts, delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "requestWithdrawal", delegatee, amount) } -// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// RequestWithdrawal is a paid mutator transaction binding the contract method 0xda95ebf7. // -// Solidity: function resetStamina(delegatee address) returns() -func (_Stamina *StaminaSession) ResetStamina(delegatee common.Address) (*types.Transaction, error) { - return _Stamina.Contract.ResetStamina(&_Stamina.TransactOpts, delegatee) +// Solidity: function requestWithdrawal(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaSession) RequestWithdrawal(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.RequestWithdrawal(&_Stamina.TransactOpts, delegatee, amount) } -// ResetStamina is a paid mutator transaction binding the contract method 0x62eb5d98. +// RequestWithdrawal is a paid mutator transaction binding the contract method 0xda95ebf7. // -// Solidity: function resetStamina(delegatee address) returns() -func (_Stamina *StaminaTransactorSession) ResetStamina(delegatee common.Address) (*types.Transaction, error) { - return _Stamina.Contract.ResetStamina(&_Stamina.TransactOpts, delegatee) +// Solidity: function requestWithdrawal(delegatee address, amount uint256) returns(bool) +func (_Stamina *StaminaTransactorSession) RequestWithdrawal(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { + return _Stamina.Contract.RequestWithdrawal(&_Stamina.TransactOpts, delegatee, amount) } // SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. // -// Solidity: function setDelegatee(delegater address) returns(bool) -func (_Stamina *StaminaTransactor) SetDelegatee(opts *bind.TransactOpts, delegater common.Address) (*types.Transaction, error) { - return _Stamina.contract.Transact(opts, "setDelegatee", delegater) +// Solidity: function setDelegatee(delegator address) returns(bool) +func (_Stamina *StaminaTransactor) SetDelegatee(opts *bind.TransactOpts, delegator common.Address) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "setDelegatee", delegator) } // SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. // -// Solidity: function setDelegatee(delegater address) returns(bool) -func (_Stamina *StaminaSession) SetDelegatee(delegater common.Address) (*types.Transaction, error) { - return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegater) +// Solidity: function setDelegatee(delegator address) returns(bool) +func (_Stamina *StaminaSession) SetDelegatee(delegator common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegator) } // SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. // -// Solidity: function setDelegatee(delegater address) returns(bool) -func (_Stamina *StaminaTransactorSession) SetDelegatee(delegater common.Address) (*types.Transaction, error) { - return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegater) +// Solidity: function setDelegatee(delegator address) returns(bool) +func (_Stamina *StaminaTransactorSession) SetDelegatee(delegator common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegator) } // SubtractStamina is a paid mutator transaction binding the contract method 0xd1c0c042. @@ -484,25 +658,25 @@ func (_Stamina *StaminaTransactorSession) SubtractStamina(delegatee common.Addre return _Stamina.Contract.SubtractStamina(&_Stamina.TransactOpts, delegatee, amount) } -// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. // -// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) -func (_Stamina *StaminaTransactor) Withdraw(opts *bind.TransactOpts, delegatee common.Address, amount *big.Int) (*types.Transaction, error) { - return _Stamina.contract.Transact(opts, "withdraw", delegatee, amount) +// Solidity: function withdraw() returns(bool) +func (_Stamina *StaminaTransactor) Withdraw(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "withdraw") } -// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. // -// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) -func (_Stamina *StaminaSession) Withdraw(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { - return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts, delegatee, amount) +// Solidity: function withdraw() returns(bool) +func (_Stamina *StaminaSession) Withdraw() (*types.Transaction, error) { + return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts) } -// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. // -// Solidity: function withdraw(delegatee address, amount uint256) returns(bool) -func (_Stamina *StaminaTransactorSession) Withdraw(delegatee common.Address, amount *big.Int) (*types.Transaction, error) { - return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts, delegatee, amount) +// Solidity: function withdraw() returns(bool) +func (_Stamina *StaminaTransactorSession) Withdraw() (*types.Transaction, error) { + return _Stamina.Contract.Withdraw(&_Stamina.TransactOpts) } // StaminaDelegateeChangedIterator is returned from FilterDelegateeChanged and is used to iterate over the raw logs and unpacked data for DelegateeChanged events raised by the Stamina contract. @@ -574,7 +748,7 @@ func (it *StaminaDelegateeChangedIterator) Close() error { // StaminaDelegateeChanged represents a DelegateeChanged event raised by the Stamina contract. type StaminaDelegateeChanged struct { - Delegater common.Address + Delegator common.Address OldDelegatee common.Address NewDelegatee common.Address Raw types.Log // Blockchain specific contextual infos @@ -582,7 +756,7 @@ type StaminaDelegateeChanged struct { // FilterDelegateeChanged is a free log retrieval operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. // -// Solidity: e DelegateeChanged(delegater address, oldDelegatee address, newDelegatee address) +// Solidity: e DelegateeChanged(delegator address, oldDelegatee address, newDelegatee address) func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts) (*StaminaDelegateeChangedIterator, error) { logs, sub, err := _Stamina.contract.FilterLogs(opts, "DelegateeChanged") @@ -594,7 +768,7 @@ func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts) ( // WatchDelegateeChanged is a free log subscription operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. // -// Solidity: e DelegateeChanged(delegater address, oldDelegatee address, newDelegatee address) +// Solidity: e DelegateeChanged(delegator address, oldDelegatee address, newDelegatee address) func (_Stamina *StaminaFilterer) WatchDelegateeChanged(opts *bind.WatchOpts, sink chan<- *StaminaDelegateeChanged) (event.Subscription, error) { logs, sub, err := _Stamina.contract.WatchLogs(opts, "DelegateeChanged") @@ -771,9 +945,9 @@ func (_Stamina *StaminaFilterer) WatchDeposited(opts *bind.WatchOpts, sink chan< }), nil } -// StaminaWithdrawnIterator is returned from FilterWithdrawn and is used to iterate over the raw logs and unpacked data for Withdrawn events raised by the Stamina contract. -type StaminaWithdrawnIterator struct { - Event *StaminaWithdrawn // Event containing the contract specifics and raw log +// StaminaWithdrawalRequestedIterator is returned from FilterWithdrawalRequested and is used to iterate over the raw logs and unpacked data for WithdrawalRequested events raised by the Stamina contract. +type StaminaWithdrawalRequestedIterator struct { + Event *StaminaWithdrawalRequested // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -787,7 +961,7 @@ type StaminaWithdrawnIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *StaminaWithdrawnIterator) Next() bool { +func (it *StaminaWithdrawalRequestedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -796,7 +970,7 @@ func (it *StaminaWithdrawnIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(StaminaWithdrawn) + it.Event = new(StaminaWithdrawalRequested) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -811,7 +985,7 @@ func (it *StaminaWithdrawnIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(StaminaWithdrawn) + it.Event = new(StaminaWithdrawalRequested) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -827,29 +1001,174 @@ func (it *StaminaWithdrawnIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *StaminaWithdrawnIterator) Error() error { +func (it *StaminaWithdrawalRequestedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *StaminaWithdrawnIterator) Close() error { +func (it *StaminaWithdrawalRequestedIterator) Close() error { it.sub.Unsubscribe() return nil } -// StaminaWithdrawn represents a Withdrawn event raised by the Stamina contract. -type StaminaWithdrawn struct { - Depositor common.Address - Delegatee common.Address - Amount *big.Int - Raw types.Log // Blockchain specific contextual infos +// StaminaWithdrawalRequested represents a WithdrawalRequested event raised by the Stamina contract. +type StaminaWithdrawalRequested struct { + Depositor common.Address + Delegatee common.Address + Amount *big.Int + RequestBlockNumber *big.Int + WithdrawalIndex *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdrawalRequested is a free log retrieval operation binding the contract event 0x3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69. +// +// Solidity: e WithdrawalRequested(depositor indexed address, delegatee indexed address, amount uint256, requestBlockNumber uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) FilterWithdrawalRequested(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawalRequestedIterator, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "WithdrawalRequested", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return &StaminaWithdrawalRequestedIterator{contract: _Stamina.contract, event: "WithdrawalRequested", logs: logs, sub: sub}, nil +} + +// WatchWithdrawalRequested is a free log subscription operation binding the contract event 0x3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69. +// +// Solidity: e WithdrawalRequested(depositor indexed address, delegatee indexed address, amount uint256, requestBlockNumber uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) WatchWithdrawalRequested(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawalRequested, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "WithdrawalRequested", depositorRule, delegateeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaWithdrawalRequested) + if err := _Stamina.contract.UnpackLog(event, "WithdrawalRequested", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// StaminaWithdrawanIterator is returned from FilterWithdrawan and is used to iterate over the raw logs and unpacked data for Withdrawan events raised by the Stamina contract. +type StaminaWithdrawanIterator struct { + Event *StaminaWithdrawan // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaWithdrawanIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaWithdrawan) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaWithdrawan) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaWithdrawanIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaWithdrawanIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaWithdrawan represents a Withdrawan event raised by the Stamina contract. +type StaminaWithdrawan struct { + Depositor common.Address + Delegatee common.Address + Amount *big.Int + WithdrawalIndex *big.Int + Raw types.Log // Blockchain specific contextual infos } -// FilterWithdrawn is a free log retrieval operation binding the contract event 0xd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb. +// FilterWithdrawan is a free log retrieval operation binding the contract event 0xf105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879. // -// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256) -func (_Stamina *StaminaFilterer) FilterWithdrawn(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawnIterator, error) { +// Solidity: e Withdrawan(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) FilterWithdrawan(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawanIterator, error) { var depositorRule []interface{} for _, depositorItem := range depositor { @@ -860,17 +1179,17 @@ func (_Stamina *StaminaFilterer) FilterWithdrawn(opts *bind.FilterOpts, deposito delegateeRule = append(delegateeRule, delegateeItem) } - logs, sub, err := _Stamina.contract.FilterLogs(opts, "Withdrawn", depositorRule, delegateeRule) + logs, sub, err := _Stamina.contract.FilterLogs(opts, "Withdrawan", depositorRule, delegateeRule) if err != nil { return nil, err } - return &StaminaWithdrawnIterator{contract: _Stamina.contract, event: "Withdrawn", logs: logs, sub: sub}, nil + return &StaminaWithdrawanIterator{contract: _Stamina.contract, event: "Withdrawan", logs: logs, sub: sub}, nil } -// WatchWithdrawn is a free log subscription operation binding the contract event 0xd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb. +// WatchWithdrawan is a free log subscription operation binding the contract event 0xf105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879. // -// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256) -func (_Stamina *StaminaFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawn, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { +// Solidity: e Withdrawan(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) WatchWithdrawan(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawan, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { var depositorRule []interface{} for _, depositorItem := range depositor { @@ -881,7 +1200,7 @@ func (_Stamina *StaminaFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan< delegateeRule = append(delegateeRule, delegateeItem) } - logs, sub, err := _Stamina.contract.WatchLogs(opts, "Withdrawn", depositorRule, delegateeRule) + logs, sub, err := _Stamina.contract.WatchLogs(opts, "Withdrawan", depositorRule, delegateeRule) if err != nil { return nil, err } @@ -891,8 +1210,8 @@ func (_Stamina *StaminaFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan< select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(StaminaWithdrawn) - if err := _Stamina.contract.UnpackLog(event, "Withdrawn", log); err != nil { + event := new(StaminaWithdrawan) + if err := _Stamina.contract.UnpackLog(event, "Withdrawan", log); err != nil { return err } event.Raw = log diff --git a/stamina/common/config.go b/stamina/common/config.go index d71224759..7e0bbc645 100644 --- a/stamina/common/config.go +++ b/stamina/common/config.go @@ -8,4 +8,4 @@ var StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" var StaminaContractAddress = common.HexToAddress(StaminaContractAddressHex) // deployed bytecode -var StaminaContractBin = "0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063158ef93e146100d55780633900e4ec1461010457806362eb5d981461015b578063857184d11461019e57806392d0d153146101f55780639b4e735f14610220578063b7b0422d146102a3578063bcac9736146102d0578063c35082a914610335578063d1c0c042146103ac578063e1e158a514610411578063e842a64b1461043c578063f340fa0114610497578063f3fef3a3146104e5575b600080fd5b3480156100e157600080fd5b506100ea61054a565b604051808215151515815260200191505060405180910390f35b34801561011057600080fd5b50610145600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061055d565b6040518082815260200191505060405180910390f35b34801561016757600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105a6565b005b3480156101aa57600080fd5b506101df600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061062c565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b5061020a610675565b6040518082815260200191505060405180910390f35b34801561022c57600080fd5b50610261600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102af57600080fd5b506102ce600480360381019080803590602001909291905050506106e3565b005b3480156102dc57600080fd5b5061031b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610724565b604051808215151515815260200191505060405180910390f35b34801561034157600080fd5b50610396600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610866565b6040518082815260200191505060405180910390f35b3480156103b857600080fd5b506103f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ed565b604051808215151515815260200191505060405180910390f35b34801561041d57600080fd5b50610426610993565b6040518082815260200191505060405180910390f35b34801561044857600080fd5b5061047d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610999565b604051808215151515815260200191505060405180910390f35b6104cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b4f565b604051808215151515815260200191505060405180910390f35b3480156104f157600080fd5b50610530600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d7f565b604051808215151515815260200191505060405180910390f35b600560009054906101000a900460ff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60045481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600560009054906101000a900460ff161515156106ff57600080fd5b806006819055506001600560006101000a81548160ff02191690831515021790555050565b600080600080600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549250600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150818583011115156107be57600080fd5b8482019050828111156108145782600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610859565b80600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001935050505092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508083820310151561094257600080fd5b828103600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600191505092915050565b60065481565b6000806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050336000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692838233604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001935050505060405180910390a16001915050919050565b60008060006006543410151515610b6557600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081348301111515610c3657600080fd5b80348201111515610c4657600080fd5b348201600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550348101600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7346040518082815260200191505060405180910390a3600192505050919050565b6000806000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549150600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081848303101515610e5557600080fd5b80848203101515610e6557600080fd5b838203600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550838103600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f19350505050158015610f74573d6000803e3d6000fd5b508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb866040518082815260200191505060405180910390a3600192505050929150505600a165627a7a72305820e9bc8cfcd1e8821074892973d25b4cabffda4b6fd0e7b766fdbcb413ed432e040029" +var StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a578063857184d11461022f5780638cd8db8a14610250578063937aaef1146102705780639b4e735f14610291578063b69ad63b146102ce578063bcac9736146102ef578063c35082a914610313578063d1c0c0421461033a578063d898ae1c1461035e578063da95ebf71461037f578063e1e158a5146103a3578063e842a64b146103b8578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b5061012b600160a060020a036004351661071f565b34801561025c57600080fd5b5061026e60043560243560443561073a565b005b34801561027c57600080fd5b5061012b600160a060020a036004351661079b565b34801561029d57600080fd5b506102b2600160a060020a03600435166107b6565b60408051600160a060020a039092168252519081900360200190f35b3480156102da57600080fd5b5061012b600160a060020a03600435166107d4565b3480156102fb57600080fd5b50610167600160a060020a03600435166024356107ef565b34801561031f57600080fd5b5061012b600160a060020a036004358116906024351661090b565b34801561034657600080fd5b50610167600160a060020a0360043516602435610936565b34801561036a57600080fd5b5061012b600160a060020a03600435166109a5565b34801561038b57600080fd5b50610167600160a060020a03600435166024356109c0565b3480156103af57600080fd5b5061012b610be1565b3480156103c457600080fd5b50610167600160a060020a0360043516610be7565b610167600160a060020a0360043516610c83565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927ff105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879928290030190a360019550505050505090565b600080600080610641610dcc565b61064a876109a5565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600160a060020a031660009081526002602052604090205490565b60085460ff161561074a57600080fd5b6000831161075757600080fd5b6000821161076457600080fd5b6000811161077157600080fd5b60028202811161078057600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff1680610807575033155b151561081257600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161087d57600160a060020a0386166000908152600260209081526040808320546001808452828520919091556004835281842043905560079092529091208054820190559350610902565b600160a060020a038616600090815260026020908152604080832054600190925290912054909350915084820182106108b557600080fd5b50808401828111156108e157600160a060020a03861660009081526001602052604090208390556108fd565b600160a060020a03861660009081526001602052604090208190555b600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff168061094a575033155b151561095557600080fd5b50600160a060020a038316600090815260016020526040902054828103811161097d57600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff1615156109e657600080fd5b600088116109f357600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610a3e57600080fd5b8786038611610a4c57600080fd5b8785038511610a5a57600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610aba57600160a060020a03891660009081526001602052604090208885039055610ad4565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610af98260018301610df3565b81548110610b0357fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b600854600090819060ff161515610bfd57600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b60085460009081908190819060ff161515610c9d57600080fd5b600954341015610cac57600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610cf657600080fd5b3482018210610d0457600080fd5b3481018110610d1257600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610d8157600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e1f57600202816002028360005260206000209182019101610e1f9190610e24565b505050565b610e6291905b80821115610e5e576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610e2a565b5090565b905600a165627a7a72305820ddf055e26c2a327946e559e1745b43733da24238521adba440289ce35074746d0029" From aefb2dc0aba81dde3687e456f5176575cef4d293 Mon Sep 17 00:00:00 2001 From: 4000D Date: Tue, 24 Jul 2018 15:57:15 +0900 Subject: [PATCH 08/26] stamina: return error if the update fails --- stamina/stamina.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/stamina/stamina.go b/stamina/stamina.go index 41ef9b1f9..74802a3ca 100644 --- a/stamina/stamina.go +++ b/stamina/stamina.go @@ -1,6 +1,7 @@ package stamina import ( + "errors" "math/big" "github.com/ethereum/go-ethereum/common" @@ -8,6 +9,10 @@ import ( staminaCommon "github.com/ethereum/go-ethereum/stamina/common" ) +var ( + ErrUpdateStamina = errors.New("Failed to update stamina.") +) + func GetDelegatee(evm *vm.EVM, from common.Address) (common.Address, error) { data, err := staminaCommon.StaminaABI.Pack("getDelegatee", from) if err != nil { @@ -47,7 +52,11 @@ func AddStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { return err } - _, _, err = evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + res, _, err := evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + + if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { + return ErrUpdateStamina + } return err } @@ -58,7 +67,11 @@ func SubtractStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error return err } - _, _, err = evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + res, _, err := evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) + + if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { + return ErrUpdateStamina + } return err } From f1e0ac4f2dd3cfd794789b0458779585b91e061c Mon Sep 17 00:00:00 2001 From: 4000D Date: Thu, 26 Jul 2018 12:20:38 +0900 Subject: [PATCH 09/26] stamina, contracts/stamina: update Stamina contractr --- contracts/stamina/contract/Stamina.sol | 4 +++- stamina/common/config.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/stamina/contract/Stamina.sol b/contracts/stamina/contract/Stamina.sol index 50dca6e07..b1abc858e 100644 --- a/contracts/stamina/contract/Stamina.sol +++ b/contracts/stamina/contract/Stamina.sol @@ -143,7 +143,9 @@ contract Stamina { * Setters */ /// @notice Set `msg.sender` as delegatee of `delegator` - function setDelegatee(address delegator) + /* TODO: unset */ + /* TODO: prevent setting if _delegatee is not 0x00 */ + function setDelegator(address delegator) external onlyInitialized returns (bool) diff --git a/stamina/common/config.go b/stamina/common/config.go index 7e0bbc645..9e1f7d296 100644 --- a/stamina/common/config.go +++ b/stamina/common/config.go @@ -8,4 +8,4 @@ var StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" var StaminaContractAddress = common.HexToAddress(StaminaContractAddressHex) // deployed bytecode -var StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a578063857184d11461022f5780638cd8db8a14610250578063937aaef1146102705780639b4e735f14610291578063b69ad63b146102ce578063bcac9736146102ef578063c35082a914610313578063d1c0c0421461033a578063d898ae1c1461035e578063da95ebf71461037f578063e1e158a5146103a3578063e842a64b146103b8578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b5061012b600160a060020a036004351661071f565b34801561025c57600080fd5b5061026e60043560243560443561073a565b005b34801561027c57600080fd5b5061012b600160a060020a036004351661079b565b34801561029d57600080fd5b506102b2600160a060020a03600435166107b6565b60408051600160a060020a039092168252519081900360200190f35b3480156102da57600080fd5b5061012b600160a060020a03600435166107d4565b3480156102fb57600080fd5b50610167600160a060020a03600435166024356107ef565b34801561031f57600080fd5b5061012b600160a060020a036004358116906024351661090b565b34801561034657600080fd5b50610167600160a060020a0360043516602435610936565b34801561036a57600080fd5b5061012b600160a060020a03600435166109a5565b34801561038b57600080fd5b50610167600160a060020a03600435166024356109c0565b3480156103af57600080fd5b5061012b610be1565b3480156103c457600080fd5b50610167600160a060020a0360043516610be7565b610167600160a060020a0360043516610c83565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927ff105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879928290030190a360019550505050505090565b600080600080610641610dcc565b61064a876109a5565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600160a060020a031660009081526002602052604090205490565b60085460ff161561074a57600080fd5b6000831161075757600080fd5b6000821161076457600080fd5b6000811161077157600080fd5b60028202811161078057600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff1680610807575033155b151561081257600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161087d57600160a060020a0386166000908152600260209081526040808320546001808452828520919091556004835281842043905560079092529091208054820190559350610902565b600160a060020a038616600090815260026020908152604080832054600190925290912054909350915084820182106108b557600080fd5b50808401828111156108e157600160a060020a03861660009081526001602052604090208390556108fd565b600160a060020a03861660009081526001602052604090208190555b600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff168061094a575033155b151561095557600080fd5b50600160a060020a038316600090815260016020526040902054828103811161097d57600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff1615156109e657600080fd5b600088116109f357600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610a3e57600080fd5b8786038611610a4c57600080fd5b8785038511610a5a57600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610aba57600160a060020a03891660009081526001602052604090208885039055610ad4565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610af98260018301610df3565b81548110610b0357fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b600854600090819060ff161515610bfd57600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b60085460009081908190819060ff161515610c9d57600080fd5b600954341015610cac57600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610cf657600080fd5b3482018210610d0457600080fd5b3481018110610d1257600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610d8157600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e1f57600202816002028360005260206000209182019101610e1f9190610e24565b505050565b610e6291905b80821115610e5e576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610e2a565b5090565b905600a165627a7a72305820ddf055e26c2a327946e559e1745b43733da24238521adba440289ce35074746d0029" +var StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107bb565b34801561027d57600080fd5b5061028f6004356024356044356107d6565b005b34801561029d57600080fd5b5061012b600160a060020a0360043516610837565b3480156102be57600080fd5b506102d3600160a060020a0360043516610852565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610870565b34801561031c57600080fd5b50610167600160a060020a036004351660243561088b565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a23565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a4e565b34801561038b57600080fd5b5061012b600160a060020a0360043516610abd565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610ad8565b3480156103d057600080fd5b5061012b610cf9565b610167600160a060020a0360043516610cff565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e48565b61064a87610abd565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107e657600080fd5b600083116107f357600080fd5b6000821161080057600080fd5b6000811161080d57600080fd5b60028202811161081c57600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff16806108a3575033155b15156108ae57600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161095257600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a1a565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098a57600080fd5b50808401828111156109b657600160a060020a03861660009081526001602052604090208390556109d2565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a62575033155b1515610a6d57600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a9557600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610afe57600080fd5b60008811610b0b57600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b5657600080fd5b8786038611610b6457600080fd5b8785038511610b7257600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bd257600160a060020a03891660009081526001602052604090208885039055610bec565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c118260018301610e6f565b81548110610c1b57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d1957600080fd5b600954341015610d2857600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d7257600080fd5b3482018210610d8057600080fd5b3481018110610d8e57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610dfd57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e9b57600202816002028360005260206000209182019101610e9b9190610ea0565b505050565b610ede91905b80821115610eda576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ea6565b5090565b905600a165627a7a72305820bfd698107b970c134cc22e548ada179f36b69083c8842ba6a43ca34c5b9120280029" From bf0e972e84c848f9e932a8bbdc850f1e02fbedd2 Mon Sep 17 00:00:00 2001 From: 4000D Date: Mon, 6 Aug 2018 17:12:16 +0900 Subject: [PATCH 10/26] core: pay with ETH if delegatee has not enough stamina --- core/state_transition.go | 7 ++++--- core/tx_pool.go | 11 ++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 9dd5889bd..f34999bb6 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -239,10 +239,11 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo // get delegatee delegatee, _ := stamina.GetDelegatee(evm, msg.From()) - log.Info("GetDelegatee", "from", msg.From(), "delegatee", delegatee) + availableStamina, _ := stamina.GetStamina(evm, delegatee) + upfrontGasCost := new(big.Int).Mul(msg.GasPrice(), big.NewInt(int64(msg.Gas()))) - // moscow - if has delegatee - if delegatee != common.HexToAddress("0x00") { + // moscow - if delegatee can pay up-front gas cost + if availableStamina.Cmp(upfrontGasCost) >= 0 { if err = st.preDelegateeCheck(delegatee); err != nil { return } diff --git a/core/tx_pool.go b/core/tx_pool.go index ac56201fa..a0dab61f2 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -624,14 +624,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrStaminaGetDelegatee } - if delegatee != common.HexToAddress("0x00") { - mgval := new(big.Int).Mul(tx.GasPrice(), big.NewInt(int64(tx.Gas()))) + mgval := new(big.Int).Mul(tx.GasPrice(), big.NewInt(int64(tx.Gas()))) + availableStamina, _ := stamina.GetStamina(evm, delegatee) - // delegatee should have enough stemina - // cost == GP * GL - if stamina, _ := stamina.GetStamina(evm, delegatee); stamina.Cmp(mgval) < 0 { - return ErrInsufficientStamina - } + // moscow - only if can pay with stamina + if availableStamina.Cmp(mgval) >= 0 { // sender should have enough value if pool.currentState.GetBalance(from).Cmp(tx.Value()) < 0 { return ErrInsufficientValue From 95a250ff69887094309f228561790330e935f66d Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Tue, 8 Jan 2019 16:36:27 +0900 Subject: [PATCH 11/26] Fix import paths --- contracts/stamina/contract/stamina.go | 12 ++++++------ core/genesis.go | 22 +++++++++++----------- core/state_transition.go | 10 +++++----- core/tx_pool.go | 24 ++++++++++++------------ core/tx_pool_test.go | 16 ++++++++-------- stamina/common/config.go | 2 +- stamina/common/constants.go | 6 +++--- stamina/stamina.go | 6 +++--- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/contracts/stamina/contract/stamina.go b/contracts/stamina/contract/stamina.go index f48484a90..6ab1a8c48 100644 --- a/contracts/stamina/contract/stamina.go +++ b/contracts/stamina/contract/stamina.go @@ -7,12 +7,12 @@ import ( "math/big" "strings" - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" + ethereum "github.com/Onther-Tech/plasma-evm" + "github.com/Onther-Tech/plasma-evm/accounts/abi" + "github.com/Onther-Tech/plasma-evm/accounts/abi/bind" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/core/types" + "github.com/Onther-Tech/plasma-evm/event" ) // StaminaABI is the input ABI used to generate the binding from. diff --git a/core/genesis.go b/core/genesis.go index 417a55101..ef0329a6c 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -25,17 +25,17 @@ import ( "math/big" "strings" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" - staminaCommon "github.com/ethereum/go-ethereum/stamina/common" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/common/hexutil" + "github.com/Onther-Tech/plasma-evm/common/math" + "github.com/Onther-Tech/plasma-evm/core/rawdb" + "github.com/Onther-Tech/plasma-evm/core/state" + "github.com/Onther-Tech/plasma-evm/core/types" + "github.com/Onther-Tech/plasma-evm/ethdb" + "github.com/Onther-Tech/plasma-evm/log" + "github.com/Onther-Tech/plasma-evm/params" + "github.com/Onther-Tech/plasma-evm/rlp" + staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" ) //go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go diff --git a/core/state_transition.go b/core/state_transition.go index f34999bb6..4f8ffe16e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -21,11 +21,11 @@ import ( "math" "math/big" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/stamina" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/core/vm" + "github.com/Onther-Tech/plasma-evm/log" + "github.com/Onther-Tech/plasma-evm/params" + "github.com/Onther-Tech/plasma-evm/stamina" ) var ( diff --git a/core/tx_pool.go b/core/tx_pool.go index a0dab61f2..301468e7e 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -25,18 +25,18 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/prque" - "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/stamina" - staminaCommon "github.com/ethereum/go-ethereum/stamina/common" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/common/prque" + "github.com/Onther-Tech/plasma-evm/consensus" + "github.com/Onther-Tech/plasma-evm/core/state" + "github.com/Onther-Tech/plasma-evm/core/types" + "github.com/Onther-Tech/plasma-evm/core/vm" + "github.com/Onther-Tech/plasma-evm/event" + "github.com/Onther-Tech/plasma-evm/log" + "github.com/Onther-Tech/plasma-evm/metrics" + "github.com/Onther-Tech/plasma-evm/params" + "github.com/Onther-Tech/plasma-evm/stamina" + staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" ) const ( diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 32a51769b..8367a58ae 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -26,14 +26,14 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/params" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/consensus" + "github.com/Onther-Tech/plasma-evm/core/state" + "github.com/Onther-Tech/plasma-evm/core/types" + "github.com/Onther-Tech/plasma-evm/crypto" + "github.com/Onther-Tech/plasma-evm/ethdb" + "github.com/Onther-Tech/plasma-evm/event" + "github.com/Onther-Tech/plasma-evm/params" ) // testTxPoolConfig is a transaction pool configuration without stateful disk diff --git a/stamina/common/config.go b/stamina/common/config.go index 9e1f7d296..6764f5199 100644 --- a/stamina/common/config.go +++ b/stamina/common/config.go @@ -1,7 +1,7 @@ package common import ( - "github.com/ethereum/go-ethereum/common" + "github.com/Onther-Tech/plasma-evm/common" ) var StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" diff --git a/stamina/common/constants.go b/stamina/common/constants.go index 43ae6507c..9a53cc356 100644 --- a/stamina/common/constants.go +++ b/stamina/common/constants.go @@ -3,9 +3,9 @@ package common import ( "strings" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/contracts/stamina/contract" + "github.com/Onther-Tech/plasma-evm/accounts/abi" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/contracts/stamina/contract" ) type accountWrapper struct { diff --git a/stamina/stamina.go b/stamina/stamina.go index 74802a3ca..9bc3a164b 100644 --- a/stamina/stamina.go +++ b/stamina/stamina.go @@ -4,9 +4,9 @@ import ( "errors" "math/big" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/vm" - staminaCommon "github.com/ethereum/go-ethereum/stamina/common" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/core/vm" + staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" ) var ( From 23bc99df14b863e7f9c313bc2f3d6544400c941f Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Tue, 8 Jan 2019 16:40:54 +0900 Subject: [PATCH 12/26] core: fix not enough argument error --- core/genesis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index ef0329a6c..6f0206851 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -350,7 +350,7 @@ func DefaultRinkebyGenesisBlock() *Genesis { } // DeveloperGenesisBlock returns the Plasma genesis block -func DeveloperGenesisBlock(period uint64) *Genesis { +func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { // Override the default period to the user requested one config := *params.AllCliqueProtocolChanges config.Clique.Period = period From 78f6a61193e7cb745d13a8ae22416e2826bd6995 Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Tue, 8 Jan 2019 18:23:01 +0900 Subject: [PATCH 13/26] core: add stamina contract addr to genesis block --- core/genesis.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index 6f0206851..f95e79a4c 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -306,6 +306,10 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big // DefaultGenesisBlock returns the Plasma main net genesis block. func DefaultGenesisBlock() *Genesis { + staminaBinBytes, err := hex.DecodeString(staminaCommon.StaminaContractBin[2:]) + if err != nil { + panic(err) + } return &Genesis{ Config: params.PlasmaChainConfig, ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"), @@ -321,6 +325,10 @@ func DefaultGenesisBlock() *Genesis { common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing params.Operator: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, + staminaCommon.StaminaContractAddress: { + Code: staminaBinBytes, + Balance: big.NewInt(0), + }, }, } } @@ -355,7 +363,6 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { config := *params.AllCliqueProtocolChanges config.Clique.Period = period - var err error staminaBinBytes, err := hex.DecodeString(staminaCommon.StaminaContractBin[2:]) if err != nil { panic(err) From a2eae173e24ae4d4f2e317b840bdd0a33757a202 Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Fri, 11 Jan 2019 14:16:53 +0900 Subject: [PATCH 14/26] core, stamina: stamina code migration from stmina pkg to core pkg --- core/genesis.go | 9 ++-- core/stamina.go | 97 +++++++++++++++++++++++++++++++++++++ core/state_transition.go | 11 ++--- core/tx_pool.go | 16 +++--- stamina/common/config.go | 11 ----- stamina/common/constants.go | 21 -------- stamina/stamina.go | 77 ----------------------------- 7 files changed, 112 insertions(+), 130 deletions(-) create mode 100644 core/stamina.go delete mode 100644 stamina/common/config.go delete mode 100644 stamina/common/constants.go delete mode 100644 stamina/stamina.go diff --git a/core/genesis.go b/core/genesis.go index f95e79a4c..0afba85b8 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -35,7 +35,6 @@ import ( "github.com/Onther-Tech/plasma-evm/log" "github.com/Onther-Tech/plasma-evm/params" "github.com/Onther-Tech/plasma-evm/rlp" - staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" ) //go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go @@ -306,7 +305,7 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big // DefaultGenesisBlock returns the Plasma main net genesis block. func DefaultGenesisBlock() *Genesis { - staminaBinBytes, err := hex.DecodeString(staminaCommon.StaminaContractBin[2:]) + staminaBinBytes, err := hex.DecodeString(staminaContractBin[2:]) if err != nil { panic(err) } @@ -325,7 +324,7 @@ func DefaultGenesisBlock() *Genesis { common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing params.Operator: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, - staminaCommon.StaminaContractAddress: { + staminaContractAddress: { Code: staminaBinBytes, Balance: big.NewInt(0), }, @@ -363,7 +362,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { config := *params.AllCliqueProtocolChanges config.Clique.Period = period - staminaBinBytes, err := hex.DecodeString(staminaCommon.StaminaContractBin[2:]) + staminaBinBytes, err := hex.DecodeString(staminaContractBin[2:]) if err != nil { panic(err) } @@ -383,7 +382,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing - staminaCommon.StaminaContractAddress: { + staminaContractAddress: { Code: staminaBinBytes, Balance: big.NewInt(0), }, diff --git a/core/stamina.go b/core/stamina.go new file mode 100644 index 000000000..7a2f5e618 --- /dev/null +++ b/core/stamina.go @@ -0,0 +1,97 @@ +package core + +import ( + "errors" + "math/big" + "strings" + + "github.com/Onther-Tech/plasma-evm/accounts/abi" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/contracts/stamina/contract" + "github.com/Onther-Tech/plasma-evm/core/vm" +) + +var ( + errUpdateStamina = errors.New("failed to update stamina") +) + +var ( + staminaContractAddressHex = "0x000000000000000000000000000000000000dead" + staminaContractAddress = common.HexToAddress(staminaContractAddressHex) + staminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107bb565b34801561027d57600080fd5b5061028f6004356024356044356107d6565b005b34801561029d57600080fd5b5061012b600160a060020a0360043516610837565b3480156102be57600080fd5b506102d3600160a060020a0360043516610852565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610870565b34801561031c57600080fd5b50610167600160a060020a036004351660243561088b565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a23565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a4e565b34801561038b57600080fd5b5061012b600160a060020a0360043516610abd565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610ad8565b3480156103d057600080fd5b5061012b610cf9565b610167600160a060020a0360043516610cff565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e48565b61064a87610abd565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107e657600080fd5b600083116107f357600080fd5b6000821161080057600080fd5b6000811161080d57600080fd5b60028202811161081c57600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff16806108a3575033155b15156108ae57600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161095257600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a1a565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098a57600080fd5b50808401828111156109b657600160a060020a03861660009081526001602052604090208390556109d2565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a62575033155b1515610a6d57600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a9557600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610afe57600080fd5b60008811610b0b57600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b5657600080fd5b8786038611610b6457600080fd5b8785038511610b7257600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bd257600160a060020a03891660009081526001602052604090208885039055610bec565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c118260018301610e6f565b81548110610c1b57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d1957600080fd5b600954341015610d2857600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d7257600080fd5b3482018210610d8057600080fd5b3481018110610d8e57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610dfd57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e9b57600202816002028360005260206000209182019101610e9b9190610ea0565b505050565b610ede91905b80821115610eda576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ea6565b5090565b905600a165627a7a72305820bfd698107b970c134cc22e548ada179f36b69083c8842ba6a43ca34c5b9120280029" + + blockchainAccount = accountWrapper{common.HexToAddress("0x00")} + staminaAccount = accountWrapper{staminaContractAddress} + staminaABI, _ = abi.JSON(strings.NewReader(contract.StaminaABI)) +) + +type accountWrapper struct { + address common.Address +} + +func (a accountWrapper) Address() common.Address { + return a.address +} + +func GetDelegatee(evm *vm.EVM, from common.Address) (common.Address, error) { + data, err := staminaABI.Pack("getDelegatee", from) + if err != nil { + return common.Address{}, err + } + + ret, _, err := evm.StaticCall(blockchainAccount, staminaContractAddress, data, 1000000) + + if err != nil { + return common.Address{}, err + } + + return common.BytesToAddress(ret), nil +} + +func GetStamina(evm *vm.EVM, delegatee common.Address) (*big.Int, error) { + data, err := staminaABI.Pack("getStamina", delegatee) + if err != nil { + return big.NewInt(0), err + } + + ret, _, err := evm.StaticCall(blockchainAccount, staminaContractAddress, data, 1000000) + + if err != nil { + return big.NewInt(0), err + } + + stamina := new(big.Int) + stamina.SetBytes(ret) + + return stamina, nil +} + +func AddStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { + data, err := staminaABI.Pack("addStamina", delegatee, gas) + if err != nil { + return err + } + + res, _, err := evm.Call(blockchainAccount, staminaContractAddress, data, 1000000, big.NewInt(0)) + + if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { + return errUpdateStamina + } + + return err +} + +func SubtractStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { + data, err := staminaABI.Pack("subtractStamina", delegatee, gas) + if err != nil { + return err + } + + res, _, err := evm.Call(blockchainAccount, staminaContractAddress, data, 1000000, big.NewInt(0)) + + if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { + return errUpdateStamina + } + + return err +} diff --git a/core/state_transition.go b/core/state_transition.go index 4f8ffe16e..9bb5aaf31 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -25,7 +25,6 @@ import ( "github.com/Onther-Tech/plasma-evm/core/vm" "github.com/Onther-Tech/plasma-evm/log" "github.com/Onther-Tech/plasma-evm/params" - "github.com/Onther-Tech/plasma-evm/stamina" ) var ( @@ -173,7 +172,7 @@ func (st *StateTransition) buyGas() error { func (st *StateTransition) buyDelegateeGas(delegatee common.Address) error { mgval := new(big.Int).Mul(new(big.Int).SetUint64(st.msg.Gas()), st.gasPrice) - balance, err := stamina.GetStamina(st.evm, delegatee) + balance, err := GetStamina(st.evm, delegatee) if err != nil { return err } @@ -187,7 +186,7 @@ func (st *StateTransition) buyDelegateeGas(delegatee common.Address) error { st.gas += st.msg.Gas() st.initialGas = st.msg.Gas() - stamina.SubtractStamina(st.evm, delegatee, mgval) + SubtractStamina(st.evm, delegatee, mgval) return nil } @@ -238,8 +237,8 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo contractCreation := msg.To() == nil // get delegatee - delegatee, _ := stamina.GetDelegatee(evm, msg.From()) - availableStamina, _ := stamina.GetStamina(evm, delegatee) + delegatee, _ := GetDelegatee(evm, msg.From()) + availableStamina, _ := GetStamina(evm, delegatee) upfrontGasCost := new(big.Int).Mul(msg.GasPrice(), big.NewInt(int64(msg.Gas()))) // moscow - if delegatee can pay up-front gas cost @@ -346,7 +345,7 @@ func (st *StateTransition) refundDelegateeGas(delegatee common.Address) { // Return ETH for remaining gas, exchanged at the original rate. remaining := new(big.Int).Mul(new(big.Int).SetUint64(st.gas), st.gasPrice) - stamina.AddStamina(st.evm, delegatee, remaining) + AddStamina(st.evm, delegatee, remaining) // Also return remaining gas to the block gas counter so it is // available for the next transaction. diff --git a/core/tx_pool.go b/core/tx_pool.go index 301468e7e..23d1b5c66 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -35,8 +35,6 @@ import ( "github.com/Onther-Tech/plasma-evm/log" "github.com/Onther-Tech/plasma-evm/metrics" "github.com/Onther-Tech/plasma-evm/params" - "github.com/Onther-Tech/plasma-evm/stamina" - staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" ) const ( @@ -616,16 +614,14 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrNonceTooLow } - // moscow - delegatee 고려하기 - // 검증할 때의 스태미나와 마이닝 될 때의 스태미나가 다를 텐데.. evm := pool.newStaticEVM() - delegatee, err := stamina.GetDelegatee(evm, from) + delegatee, err := GetDelegatee(evm, from) if err != nil { return ErrStaminaGetDelegatee } mgval := new(big.Int).Mul(tx.GasPrice(), big.NewInt(int64(tx.Gas()))) - availableStamina, _ := stamina.GetStamina(evm, delegatee) + availableStamina, _ := GetStamina(evm, delegatee) // moscow - only if can pay with stamina if availableStamina.Cmp(mgval) >= 0 { @@ -997,8 +993,8 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { // Drop all transactions that are too costly (low balance or out of gas) // moscow - do not drop tx if delegatee has enough stamina evm := pool.newStaticEVM() - delegatee, _ := stamina.GetDelegatee(evm, addr) - stamina, _ := stamina.GetStamina(evm, delegatee) + delegatee, _ := GetDelegatee(evm, addr) + stamina, _ := GetStamina(evm, delegatee) balance := pool.currentState.GetBalance(addr) var costlimit *big.Int @@ -1160,8 +1156,8 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { // moscow - arbitrary msg & header & author func (pool *TxPool) newStaticEVM() *vm.EVM { msg := types.NewMessage( - staminaCommon.BlockchainAccount.Address(), - &staminaCommon.StaminaContractAddress, + blockchainAccount.Address(), + &staminaContractAddress, 0, big.NewInt(0), 1000000, diff --git a/stamina/common/config.go b/stamina/common/config.go deleted file mode 100644 index 6764f5199..000000000 --- a/stamina/common/config.go +++ /dev/null @@ -1,11 +0,0 @@ -package common - -import ( - "github.com/Onther-Tech/plasma-evm/common" -) - -var StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" -var StaminaContractAddress = common.HexToAddress(StaminaContractAddressHex) - -// deployed bytecode -var StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107bb565b34801561027d57600080fd5b5061028f6004356024356044356107d6565b005b34801561029d57600080fd5b5061012b600160a060020a0360043516610837565b3480156102be57600080fd5b506102d3600160a060020a0360043516610852565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610870565b34801561031c57600080fd5b50610167600160a060020a036004351660243561088b565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a23565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a4e565b34801561038b57600080fd5b5061012b600160a060020a0360043516610abd565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610ad8565b3480156103d057600080fd5b5061012b610cf9565b610167600160a060020a0360043516610cff565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e48565b61064a87610abd565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107e657600080fd5b600083116107f357600080fd5b6000821161080057600080fd5b6000811161080d57600080fd5b60028202811161081c57600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff16806108a3575033155b15156108ae57600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161095257600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a1a565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098a57600080fd5b50808401828111156109b657600160a060020a03861660009081526001602052604090208390556109d2565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a62575033155b1515610a6d57600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a9557600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610afe57600080fd5b60008811610b0b57600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b5657600080fd5b8786038611610b6457600080fd5b8785038511610b7257600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bd257600160a060020a03891660009081526001602052604090208885039055610bec565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c118260018301610e6f565b81548110610c1b57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d1957600080fd5b600954341015610d2857600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d7257600080fd5b3482018210610d8057600080fd5b3481018110610d8e57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610dfd57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e9b57600202816002028360005260206000209182019101610e9b9190610ea0565b505050565b610ede91905b80821115610eda576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ea6565b5090565b905600a165627a7a72305820bfd698107b970c134cc22e548ada179f36b69083c8842ba6a43ca34c5b9120280029" diff --git a/stamina/common/constants.go b/stamina/common/constants.go deleted file mode 100644 index 9a53cc356..000000000 --- a/stamina/common/constants.go +++ /dev/null @@ -1,21 +0,0 @@ -package common - -import ( - "strings" - - "github.com/Onther-Tech/plasma-evm/accounts/abi" - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/contracts/stamina/contract" -) - -type accountWrapper struct { - address common.Address -} - -func (a accountWrapper) Address() common.Address { - return a.address -} - -var BlockchainAccount = accountWrapper{common.HexToAddress("0x00")} -var StaminaAccount = accountWrapper{StaminaContractAddress} -var StaminaABI, _ = abi.JSON(strings.NewReader(contract.StaminaABI)) diff --git a/stamina/stamina.go b/stamina/stamina.go deleted file mode 100644 index 9bc3a164b..000000000 --- a/stamina/stamina.go +++ /dev/null @@ -1,77 +0,0 @@ -package stamina - -import ( - "errors" - "math/big" - - "github.com/Onther-Tech/plasma-evm/common" - "github.com/Onther-Tech/plasma-evm/core/vm" - staminaCommon "github.com/Onther-Tech/plasma-evm/stamina/common" -) - -var ( - ErrUpdateStamina = errors.New("Failed to update stamina.") -) - -func GetDelegatee(evm *vm.EVM, from common.Address) (common.Address, error) { - data, err := staminaCommon.StaminaABI.Pack("getDelegatee", from) - if err != nil { - return common.Address{}, err - } - - ret, _, err := evm.StaticCall(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000) - - if err != nil { - return common.Address{}, err - } - - return common.BytesToAddress(ret), nil -} - -func GetStamina(evm *vm.EVM, delegatee common.Address) (*big.Int, error) { - data, err := staminaCommon.StaminaABI.Pack("getStamina", delegatee) - if err != nil { - return big.NewInt(0), err - } - - ret, _, err := evm.StaticCall(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000) - - if err != nil { - return big.NewInt(0), err - } - - stamina := new(big.Int) - stamina.SetBytes(ret) - - return stamina, nil -} - -func AddStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { - data, err := staminaCommon.StaminaABI.Pack("addStamina", delegatee, gas) - if err != nil { - return err - } - - res, _, err := evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) - - if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { - return ErrUpdateStamina - } - - return err -} - -func SubtractStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { - data, err := staminaCommon.StaminaABI.Pack("subtractStamina", delegatee, gas) - if err != nil { - return err - } - - res, _, err := evm.Call(staminaCommon.BlockchainAccount, staminaCommon.StaminaContractAddress, data, 1000000, big.NewInt(0)) - - if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { - return ErrUpdateStamina - } - - return err -} From c42e6c4b56ff4004e8e1908f2c7daf213d36c01a Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Mon, 14 Jan 2019 13:37:13 +0900 Subject: [PATCH 15/26] contracts/stamina, core: update stamina contract --- contracts/stamina/contract/Stamina.sol | 31 +-- contracts/stamina/contract/stamina.go | 359 ++++++++++++++++++++++--- core/stamina.go | 2 +- 3 files changed, 333 insertions(+), 59 deletions(-) diff --git a/contracts/stamina/contract/Stamina.sol b/contracts/stamina/contract/Stamina.sol index b1abc858e..af6745759 100644 --- a/contracts/stamina/contract/Stamina.sol +++ b/contracts/stamina/contract/Stamina.sol @@ -2,7 +2,6 @@ pragma solidity ^0.4.24; contract Stamina { - // Withdrawal handles withdrawal request struct Withdrawal { uint128 amount; uint128 requestBlockNumber; @@ -50,8 +49,7 @@ contract Stamina { bool public development = true; // if the contract is inserted directly into - // genesis block, it will be false - + // genesis block without state, it will be false /** * Modifiers @@ -70,9 +68,11 @@ contract Stamina { * Events */ event Deposited(address indexed depositor, address indexed delegatee, uint amount); - event DelegateeChanged(address delegator, address oldDelegatee, address newDelegatee); + event DelegateeChanged(address indexed delegator, address oldDelegatee, address newDelegatee); event WithdrawalRequested(address indexed depositor, address indexed delegatee, uint amount, uint requestBlockNumber, uint withdrawalIndex); - event Withdrawan(address indexed depositor, address indexed delegatee, uint amount, uint withdrawalIndex); + event Withdrawn(address indexed depositor, address indexed delegatee, uint amount, uint withdrawalIndex); + event StaminaAdded(address indexed delegatee, uint amount, bool recovered); + event StaminaSubtracted(address indexed delegatee, uint amount); /** * Init @@ -143,8 +143,6 @@ contract Stamina { * Setters */ /// @notice Set `msg.sender` as delegatee of `delegator` - /* TODO: unset */ - /* TODO: prevent setting if _delegatee is not 0x00 */ function setDelegator(address delegator) external onlyInitialized @@ -213,7 +211,7 @@ contract Stamina { _total_deposit[delegatee] = totalDeposit - amount; _deposit[msg.sender][delegatee] = deposit - amount; - // NOTE: Is accepting the request right when stamina < amount? + // NOTE: Is it right to accept the request when stamina < amount? if (stamina > amount) { _stamina[delegatee] = stamina - amount; } else { @@ -251,7 +249,7 @@ contract Stamina { withdrawalIndex = lastWithdrawalIndex + 1; } - // double check out of index + // check out of index require(withdrawalIndex < withdrawals.length); Withdrawal storage withdrawal = _withdrawal[msg.sender][withdrawalIndex]; @@ -262,28 +260,23 @@ contract Stamina { uint amount = uint(withdrawal.amount); - // withdrawal is processed + // update state withdrawal.processed = true; - - // mark processed withdrawal index _last_processed_withdrawal[msg.sender] = withdrawalIndex; // tranfser ether to depositor msg.sender.transfer(amount); - emit Withdrawan(msg.sender, withdrawal.delegatee, amount, withdrawalIndex); + emit Withdrawn(msg.sender, withdrawal.delegatee, amount, withdrawalIndex); return true; } /** * Stamina modification (only blockchain) - * No event emitted during these functions. */ /// @notice Add stamina of delegatee. The upper bound of stamina is total deposit of delegatee. /// addStamina is called when remaining gas is refunded. So we can recover stamina /// if RECOVER_EPOCH_LENGTH blocks are passed. - /// - /// NOTE: can use block.number here? function addStamina(address delegatee, uint amount) external onlyChain returns (bool) { // if enough blocks has passed since the last recovery, recover whole used stamina. if (_last_recovery_block[delegatee] + RECOVER_EPOCH_LENGTH <= block.number) { @@ -291,6 +284,7 @@ contract Stamina { _last_recovery_block[delegatee] = block.number; _num_recovery[delegatee] += 1; + emit StaminaAdded(delegatee, 0, true); return true; } @@ -303,6 +297,7 @@ contract Stamina { if (targetBalance > totalDeposit) _stamina[delegatee] = totalDeposit; else _stamina[delegatee] = targetBalance; + emit StaminaAdded(delegatee, amount, false); return true; } @@ -312,6 +307,8 @@ contract Stamina { require(stamina - amount < stamina); _stamina[delegatee] = stamina - amount; + + emit StaminaSubtracted(delegatee, amount); return true; } -} +} \ No newline at end of file diff --git a/contracts/stamina/contract/stamina.go b/contracts/stamina/contract/stamina.go index 6ab1a8c48..9e10a79f5 100644 --- a/contracts/stamina/contract/stamina.go +++ b/contracts/stamina/contract/stamina.go @@ -16,10 +16,10 @@ import ( ) // StaminaABI is the input ABI used to generate the binding from. -const StaminaABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"WITHDRAWAL_DELAY\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"RECOVER_EPOCH_LENGTH\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"getWithdrawal\",\"outputs\":[{\"name\":\"amount\",\"type\":\"uint128\"},{\"name\":\"requestBlockNumber\",\"type\":\"uint128\"},{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"processed\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getTotalDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"minDeposit\",\"type\":\"uint256\"},{\"name\":\"recoveryEpochLength\",\"type\":\"uint256\"},{\"name\":\"withdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"init\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getLastRecoveryBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"getDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getNumRecovery\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"subtractStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"}],\"name\":\"getNumWithdrawals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"requestWithdrawal\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MIN_DEPOSIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"setDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"oldDelegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"newDelegatee\",\"type\":\"address\"}],\"name\":\"DelegateeChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"WithdrawalRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"Withdrawan\",\"type\":\"event\"}]" +const StaminaABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"WITHDRAWAL_DELAY\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"RECOVER_EPOCH_LENGTH\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"getWithdrawal\",\"outputs\":[{\"name\":\"amount\",\"type\":\"uint128\"},{\"name\":\"requestBlockNumber\",\"type\":\"uint128\"},{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"processed\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"setDelegator\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getTotalDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"minDeposit\",\"type\":\"uint256\"},{\"name\":\"recoveryEpochLength\",\"type\":\"uint256\"},{\"name\":\"withdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"init\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getLastRecoveryBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"getDelegatee\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getNumRecovery\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"},{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"getDeposit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"subtractStamina\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\"}],\"name\":\"getNumWithdrawals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"requestWithdrawal\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MIN_DEPOSIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"deposit\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"oldDelegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"newDelegatee\",\"type\":\"address\"}],\"name\":\"DelegateeChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"WithdrawalRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"withdrawalIndex\",\"type\":\"uint256\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"recovered\",\"type\":\"bool\"}],\"name\":\"StaminaAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"delegatee\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"StaminaSubtracted\",\"type\":\"event\"}]" // StaminaBin is the compiled bytecode used for deploying new contracts. -const StaminaBin = `0x6080604052600c805460ff1916600117905534801561001d57600080fd5b50610f5b8061002d6000396000f3006080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b146101ae5780635be4f765146101c35780637b929c2714610241578063857184d1146102565780638cd8db8a14610289578063937aaef1146102c15780639b4e735f146102f4578063b69ad63b14610343578063bcac973614610376578063c35082a9146103af578063d1c0c042146103ea578063d898ae1c14610423578063da95ebf714610456578063e1e158a51461048f578063e842a64b146104a4578063f340fa01146104d7575b600080fd5b34801561012257600080fd5b5061012b6104fd565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b610503565b34801561015e57600080fd5b50610167610509565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b6004803603602081101561019e57600080fd5b5035600160a060020a0316610512565b3480156101ba57600080fd5b5061016761052d565b3480156101cf57600080fd5b506101fc600480360360408110156101e657600080fd5b50600160a060020a038135169060200135610737565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561024d57600080fd5b5061016761081a565b34801561026257600080fd5b5061012b6004803603602081101561027957600080fd5b5035600160a060020a0316610823565b34801561029557600080fd5b506102bf600480360360608110156102ac57600080fd5b508035906020810135906040013561083e565b005b3480156102cd57600080fd5b5061012b600480360360208110156102e457600080fd5b5035600160a060020a031661089f565b34801561030057600080fd5b506103276004803603602081101561031757600080fd5b5035600160a060020a03166108ba565b60408051600160a060020a039092168252519081900360200190f35b34801561034f57600080fd5b5061012b6004803603602081101561036657600080fd5b5035600160a060020a03166108d8565b34801561038257600080fd5b506101676004803603604081101561039957600080fd5b50600160a060020a0381351690602001356108f3565b3480156103bb57600080fd5b5061012b600480360360408110156103d257600080fd5b50600160a060020a0381358116916020013516610a02565b3480156103f657600080fd5b506101676004803603604081101561040d57600080fd5b50600160a060020a038135169060200135610a2d565b34801561042f57600080fd5b5061012b6004803603602081101561044657600080fd5b5035600160a060020a0316610a99565b34801561046257600080fd5b506101676004803603604081101561047957600080fd5b50600160a060020a038135169060200135610ab4565b34801561049b57600080fd5b5061012b610cba565b3480156104b057600080fd5b50610167600480360360208110156104c757600080fd5b5035600160a060020a0316610cc0565b610167600480360360208110156104ed57600080fd5b5035600160a060020a0316610d59565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b3360009081526005602052604081208054821061054957600080fd5b336000908152600660205260408120549081158015610593575082600081548110151561057257fe5b906000526020600020906002020160010160149054906101000a900460ff16155b156105a0575060006105c4565b8115156105be578254600211156105b657600080fd5b5060016105c4565b50600181015b825481106105d157600080fd5b3360009081526005602052604081208054839081106105ec57fe5b906000526020600020906002020190508060010160149054906101000a900460ff1615151561061a57600080fd5b600b548154437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561065557600080fd5b805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156106de573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927ff105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879928290030190a36001955050505050505b90565b60008060008061074686610a99565b851061075157600080fd5b610759610e99565b600160a060020a038716600090815260056020526040902080548790811061077d57fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600160a060020a031660009081526002602052604090205490565b60085460ff161561084e57600080fd5b6000831161085b57600080fd5b6000821161086857600080fd5b6000811161087557600080fd5b60028202811161088457600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009060ff1680610905575033155b151561091057600080fd5b600a54600160a060020a0384166000908152600460205260409020544391011161097a5750600160a060020a0382166000908152600260209081526040808320546001808452828520919091556004835281842043905560079092529091208054820190556109fc565b600160a060020a03831660009081526002602090815260408083205460019092529091205483810181106109ad57600080fd5b808401828111156109d857600160a060020a03861660009081526001602052604090208390556109f4565b600160a060020a03861660009081526001602052604090208190555b600193505050505b92915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c5460009060ff1680610a3f575033155b1515610a4a57600080fd5b600160a060020a0383166000908152600160205260409020548281038111610a7157600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b60085460009060ff161515610ac857600080fd5b60008211610ad557600080fd5b600160a060020a0383166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205490918211610b1a57600080fd5b8483038311610b2857600080fd5b8482038211610b3657600080fd5b600160a060020a038616600081815260026020908152604080832089880390553383526003825280832093835292905220858303905584811115610b9657600160a060020a03861660009081526001602052604090208582039055610bb0565b600160a060020a0386166000908152600160205260408120555b336000908152600560205260408120805490918282610bd28260018301610ec0565b81548110610bdc57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009060ff161515610cd457600080fd5b600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b60085460009060ff161515610d6d57600080fd5b600954341015610d7c57600080fd5b600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610dc357600080fd5b3482018210610dd157600080fd5b3481018110610ddf57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610e4e57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610eec57600202816002028360005260206000209182019101610eec9190610ef1565b505050565b61073491905b80821115610f2b576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ef7565b50905600a165627a7a72305820a02bfd230d4c61a1e1f620f19aa68a9f2b4e21138813f3eb509c3191aa204f1b0029` +const StaminaBin = `0x6080604052600c805460ff1916600117905534801561001d57600080fd5b50610f388061002d6000396000f3006080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107b2565b34801561027d57600080fd5b5061028f6004356024356044356107cd565b005b34801561029d57600080fd5b5061012b600160a060020a036004351661082e565b3480156102be57600080fd5b506102d3600160a060020a0360043516610849565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610867565b34801561031c57600080fd5b50610167600160a060020a0360043516602435610882565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a1a565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a45565b34801561038b57600080fd5b5061012b600160a060020a0360043516610ae8565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610b03565b3480156103d057600080fd5b5061012b610d24565b610167600160a060020a0360043516610d2a565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e73565b61064a87610ae8565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a038281166000818152602081815260409182902080543373ffffffffffffffffffffffffffffffffffffffff19821681179092558351951680865291850152815190937f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c69292908290030190a250600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107dd57600080fd5b600083116107ea57600080fd5b600082116107f757600080fd5b6000811161080457600080fd5b60028202811161081357600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff168061089a575033155b15156108a557600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161094957600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a11565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098157600080fd5b50808401828111156109ad57600160a060020a03861660009081526001602052604090208390556109c9565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a59575033155b1515610a6457600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a8c57600080fd5b600160a060020a0384166000818152600160209081526040918290208685039055815186815291517f66649d0546ffaed7a9e91793ec2fba0941afa9ebed5b599a8031611ad911fd2f9281900390910190a25060019392505050565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610b2957600080fd5b60008811610b3657600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b8157600080fd5b8786038611610b8f57600080fd5b8785038511610b9d57600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bfd57600160a060020a03891660009081526001602052604090208885039055610c17565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c3c8260018301610e9a565b81548110610c4657fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d4457600080fd5b600954341015610d5357600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d9d57600080fd5b3482018210610dab57600080fd5b3481018110610db957600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610e2857600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610ec657600202816002028360005260206000209182019101610ec69190610ecb565b505050565b610f0991905b80821115610f05576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ed1565b5090565b905600a165627a7a723058207756db8d0b66ca08e1c2d55388ff88403e3a0156e622cdf21e7c37b165814dec0029` // DeployStamina deploys a new Ethereum contract, binding an instance of Stamina to it. func DeployStamina(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Stamina, error) { @@ -616,25 +616,25 @@ func (_Stamina *StaminaTransactorSession) RequestWithdrawal(delegatee common.Add return _Stamina.Contract.RequestWithdrawal(&_Stamina.TransactOpts, delegatee, amount) } -// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// SetDelegator is a paid mutator transaction binding the contract method 0x83cd9cc3. // -// Solidity: function setDelegatee(delegator address) returns(bool) -func (_Stamina *StaminaTransactor) SetDelegatee(opts *bind.TransactOpts, delegator common.Address) (*types.Transaction, error) { - return _Stamina.contract.Transact(opts, "setDelegatee", delegator) +// Solidity: function setDelegator(delegator address) returns(bool) +func (_Stamina *StaminaTransactor) SetDelegator(opts *bind.TransactOpts, delegator common.Address) (*types.Transaction, error) { + return _Stamina.contract.Transact(opts, "setDelegator", delegator) } -// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// SetDelegator is a paid mutator transaction binding the contract method 0x83cd9cc3. // -// Solidity: function setDelegatee(delegator address) returns(bool) -func (_Stamina *StaminaSession) SetDelegatee(delegator common.Address) (*types.Transaction, error) { - return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegator) +// Solidity: function setDelegator(delegator address) returns(bool) +func (_Stamina *StaminaSession) SetDelegator(delegator common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegator(&_Stamina.TransactOpts, delegator) } -// SetDelegatee is a paid mutator transaction binding the contract method 0xe842a64b. +// SetDelegator is a paid mutator transaction binding the contract method 0x83cd9cc3. // -// Solidity: function setDelegatee(delegator address) returns(bool) -func (_Stamina *StaminaTransactorSession) SetDelegatee(delegator common.Address) (*types.Transaction, error) { - return _Stamina.Contract.SetDelegatee(&_Stamina.TransactOpts, delegator) +// Solidity: function setDelegator(delegator address) returns(bool) +func (_Stamina *StaminaTransactorSession) SetDelegator(delegator common.Address) (*types.Transaction, error) { + return _Stamina.Contract.SetDelegator(&_Stamina.TransactOpts, delegator) } // SubtractStamina is a paid mutator transaction binding the contract method 0xd1c0c042. @@ -756,10 +756,15 @@ type StaminaDelegateeChanged struct { // FilterDelegateeChanged is a free log retrieval operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. // -// Solidity: e DelegateeChanged(delegator address, oldDelegatee address, newDelegatee address) -func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts) (*StaminaDelegateeChangedIterator, error) { +// Solidity: e DelegateeChanged(delegator indexed address, oldDelegatee address, newDelegatee address) +func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts, delegator []common.Address) (*StaminaDelegateeChangedIterator, error) { - logs, sub, err := _Stamina.contract.FilterLogs(opts, "DelegateeChanged") + var delegatorRule []interface{} + for _, delegatorItem := range delegator { + delegatorRule = append(delegatorRule, delegatorItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "DelegateeChanged", delegatorRule) if err != nil { return nil, err } @@ -768,10 +773,15 @@ func (_Stamina *StaminaFilterer) FilterDelegateeChanged(opts *bind.FilterOpts) ( // WatchDelegateeChanged is a free log subscription operation binding the contract event 0x5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c692. // -// Solidity: e DelegateeChanged(delegator address, oldDelegatee address, newDelegatee address) -func (_Stamina *StaminaFilterer) WatchDelegateeChanged(opts *bind.WatchOpts, sink chan<- *StaminaDelegateeChanged) (event.Subscription, error) { +// Solidity: e DelegateeChanged(delegator indexed address, oldDelegatee address, newDelegatee address) +func (_Stamina *StaminaFilterer) WatchDelegateeChanged(opts *bind.WatchOpts, sink chan<- *StaminaDelegateeChanged, delegator []common.Address) (event.Subscription, error) { + + var delegatorRule []interface{} + for _, delegatorItem := range delegator { + delegatorRule = append(delegatorRule, delegatorItem) + } - logs, sub, err := _Stamina.contract.WatchLogs(opts, "DelegateeChanged") + logs, sub, err := _Stamina.contract.WatchLogs(opts, "DelegateeChanged", delegatorRule) if err != nil { return nil, err } @@ -945,6 +955,273 @@ func (_Stamina *StaminaFilterer) WatchDeposited(opts *bind.WatchOpts, sink chan< }), nil } +// StaminaStaminaAddedIterator is returned from FilterStaminaAdded and is used to iterate over the raw logs and unpacked data for StaminaAdded events raised by the Stamina contract. +type StaminaStaminaAddedIterator struct { + Event *StaminaStaminaAdded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaStaminaAddedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaStaminaAdded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaStaminaAdded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaStaminaAddedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaStaminaAddedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaStaminaAdded represents a StaminaAdded event raised by the Stamina contract. +type StaminaStaminaAdded struct { + Delegatee common.Address + Amount *big.Int + Recovered bool + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaminaAdded is a free log retrieval operation binding the contract event 0x85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809. +// +// Solidity: e StaminaAdded(delegatee indexed address, amount uint256, recovered bool) +func (_Stamina *StaminaFilterer) FilterStaminaAdded(opts *bind.FilterOpts, delegatee []common.Address) (*StaminaStaminaAddedIterator, error) { + + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "StaminaAdded", delegateeRule) + if err != nil { + return nil, err + } + return &StaminaStaminaAddedIterator{contract: _Stamina.contract, event: "StaminaAdded", logs: logs, sub: sub}, nil +} + +// WatchStaminaAdded is a free log subscription operation binding the contract event 0x85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809. +// +// Solidity: e StaminaAdded(delegatee indexed address, amount uint256, recovered bool) +func (_Stamina *StaminaFilterer) WatchStaminaAdded(opts *bind.WatchOpts, sink chan<- *StaminaStaminaAdded, delegatee []common.Address) (event.Subscription, error) { + + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "StaminaAdded", delegateeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaStaminaAdded) + if err := _Stamina.contract.UnpackLog(event, "StaminaAdded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// StaminaStaminaSubtractedIterator is returned from FilterStaminaSubtracted and is used to iterate over the raw logs and unpacked data for StaminaSubtracted events raised by the Stamina contract. +type StaminaStaminaSubtractedIterator struct { + Event *StaminaStaminaSubtracted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StaminaStaminaSubtractedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StaminaStaminaSubtracted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StaminaStaminaSubtracted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StaminaStaminaSubtractedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StaminaStaminaSubtractedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StaminaStaminaSubtracted represents a StaminaSubtracted event raised by the Stamina contract. +type StaminaStaminaSubtracted struct { + Delegatee common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaminaSubtracted is a free log retrieval operation binding the contract event 0x66649d0546ffaed7a9e91793ec2fba0941afa9ebed5b599a8031611ad911fd2f. +// +// Solidity: e StaminaSubtracted(delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) FilterStaminaSubtracted(opts *bind.FilterOpts, delegatee []common.Address) (*StaminaStaminaSubtractedIterator, error) { + + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.FilterLogs(opts, "StaminaSubtracted", delegateeRule) + if err != nil { + return nil, err + } + return &StaminaStaminaSubtractedIterator{contract: _Stamina.contract, event: "StaminaSubtracted", logs: logs, sub: sub}, nil +} + +// WatchStaminaSubtracted is a free log subscription operation binding the contract event 0x66649d0546ffaed7a9e91793ec2fba0941afa9ebed5b599a8031611ad911fd2f. +// +// Solidity: e StaminaSubtracted(delegatee indexed address, amount uint256) +func (_Stamina *StaminaFilterer) WatchStaminaSubtracted(opts *bind.WatchOpts, sink chan<- *StaminaStaminaSubtracted, delegatee []common.Address) (event.Subscription, error) { + + var delegateeRule []interface{} + for _, delegateeItem := range delegatee { + delegateeRule = append(delegateeRule, delegateeItem) + } + + logs, sub, err := _Stamina.contract.WatchLogs(opts, "StaminaSubtracted", delegateeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StaminaStaminaSubtracted) + if err := _Stamina.contract.UnpackLog(event, "StaminaSubtracted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + // StaminaWithdrawalRequestedIterator is returned from FilterWithdrawalRequested and is used to iterate over the raw logs and unpacked data for WithdrawalRequested events raised by the Stamina contract. type StaminaWithdrawalRequestedIterator struct { Event *StaminaWithdrawalRequested // Event containing the contract specifics and raw log @@ -1089,9 +1366,9 @@ func (_Stamina *StaminaFilterer) WatchWithdrawalRequested(opts *bind.WatchOpts, }), nil } -// StaminaWithdrawanIterator is returned from FilterWithdrawan and is used to iterate over the raw logs and unpacked data for Withdrawan events raised by the Stamina contract. -type StaminaWithdrawanIterator struct { - Event *StaminaWithdrawan // Event containing the contract specifics and raw log +// StaminaWithdrawnIterator is returned from FilterWithdrawn and is used to iterate over the raw logs and unpacked data for Withdrawn events raised by the Stamina contract. +type StaminaWithdrawnIterator struct { + Event *StaminaWithdrawn // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1105,7 +1382,7 @@ type StaminaWithdrawanIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *StaminaWithdrawanIterator) Next() bool { +func (it *StaminaWithdrawnIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1114,7 +1391,7 @@ func (it *StaminaWithdrawanIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(StaminaWithdrawan) + it.Event = new(StaminaWithdrawn) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1129,7 +1406,7 @@ func (it *StaminaWithdrawanIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(StaminaWithdrawan) + it.Event = new(StaminaWithdrawn) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1145,19 +1422,19 @@ func (it *StaminaWithdrawanIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *StaminaWithdrawanIterator) Error() error { +func (it *StaminaWithdrawnIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *StaminaWithdrawanIterator) Close() error { +func (it *StaminaWithdrawnIterator) Close() error { it.sub.Unsubscribe() return nil } -// StaminaWithdrawan represents a Withdrawan event raised by the Stamina contract. -type StaminaWithdrawan struct { +// StaminaWithdrawn represents a Withdrawn event raised by the Stamina contract. +type StaminaWithdrawn struct { Depositor common.Address Delegatee common.Address Amount *big.Int @@ -1165,10 +1442,10 @@ type StaminaWithdrawan struct { Raw types.Log // Blockchain specific contextual infos } -// FilterWithdrawan is a free log retrieval operation binding the contract event 0xf105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879. +// FilterWithdrawn is a free log retrieval operation binding the contract event 0x91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2. // -// Solidity: e Withdrawan(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) -func (_Stamina *StaminaFilterer) FilterWithdrawan(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawanIterator, error) { +// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) FilterWithdrawn(opts *bind.FilterOpts, depositor []common.Address, delegatee []common.Address) (*StaminaWithdrawnIterator, error) { var depositorRule []interface{} for _, depositorItem := range depositor { @@ -1179,17 +1456,17 @@ func (_Stamina *StaminaFilterer) FilterWithdrawan(opts *bind.FilterOpts, deposit delegateeRule = append(delegateeRule, delegateeItem) } - logs, sub, err := _Stamina.contract.FilterLogs(opts, "Withdrawan", depositorRule, delegateeRule) + logs, sub, err := _Stamina.contract.FilterLogs(opts, "Withdrawn", depositorRule, delegateeRule) if err != nil { return nil, err } - return &StaminaWithdrawanIterator{contract: _Stamina.contract, event: "Withdrawan", logs: logs, sub: sub}, nil + return &StaminaWithdrawnIterator{contract: _Stamina.contract, event: "Withdrawn", logs: logs, sub: sub}, nil } -// WatchWithdrawan is a free log subscription operation binding the contract event 0xf105379f79c77d26f97e62cc481d8493005422dde6ad256be000ea973120e879. +// WatchWithdrawn is a free log subscription operation binding the contract event 0x91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2. // -// Solidity: e Withdrawan(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) -func (_Stamina *StaminaFilterer) WatchWithdrawan(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawan, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { +// Solidity: e Withdrawn(depositor indexed address, delegatee indexed address, amount uint256, withdrawalIndex uint256) +func (_Stamina *StaminaFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan<- *StaminaWithdrawn, depositor []common.Address, delegatee []common.Address) (event.Subscription, error) { var depositorRule []interface{} for _, depositorItem := range depositor { @@ -1200,7 +1477,7 @@ func (_Stamina *StaminaFilterer) WatchWithdrawan(opts *bind.WatchOpts, sink chan delegateeRule = append(delegateeRule, delegateeItem) } - logs, sub, err := _Stamina.contract.WatchLogs(opts, "Withdrawan", depositorRule, delegateeRule) + logs, sub, err := _Stamina.contract.WatchLogs(opts, "Withdrawn", depositorRule, delegateeRule) if err != nil { return nil, err } @@ -1210,8 +1487,8 @@ func (_Stamina *StaminaFilterer) WatchWithdrawan(opts *bind.WatchOpts, sink chan select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(StaminaWithdrawan) - if err := _Stamina.contract.UnpackLog(event, "Withdrawan", log); err != nil { + event := new(StaminaWithdrawn) + if err := _Stamina.contract.UnpackLog(event, "Withdrawn", log); err != nil { return err } event.Raw = log diff --git a/core/stamina.go b/core/stamina.go index 7a2f5e618..acc007036 100644 --- a/core/stamina.go +++ b/core/stamina.go @@ -18,7 +18,7 @@ var ( var ( staminaContractAddressHex = "0x000000000000000000000000000000000000dead" staminaContractAddress = common.HexToAddress(staminaContractAddressHex) - staminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107bb565b34801561027d57600080fd5b5061028f6004356024356044356107d6565b005b34801561029d57600080fd5b5061012b600160a060020a0360043516610837565b3480156102be57600080fd5b506102d3600160a060020a0360043516610852565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610870565b34801561031c57600080fd5b50610167600160a060020a036004351660243561088b565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a23565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a4e565b34801561038b57600080fd5b5061012b600160a060020a0360043516610abd565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610ad8565b3480156103d057600080fd5b5061012b610cf9565b610167600160a060020a0360043516610cff565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e48565b61064a87610abd565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a0380831660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19811633908117909255835194855290941690830181905282820193909352517f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c6929181900360600190a150600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107e657600080fd5b600083116107f357600080fd5b6000821161080057600080fd5b6000811161080d57600080fd5b60028202811161081c57600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff16806108a3575033155b15156108ae57600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161095257600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a1a565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098a57600080fd5b50808401828111156109b657600160a060020a03861660009081526001602052604090208390556109d2565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a62575033155b1515610a6d57600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a9557600080fd5b600160a060020a03939093166000908152600160208190526040909120929093039091555090565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610afe57600080fd5b60008811610b0b57600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b5657600080fd5b8786038611610b6457600080fd5b8785038511610b7257600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bd257600160a060020a03891660009081526001602052604090208885039055610bec565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c118260018301610e6f565b81548110610c1b57fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d1957600080fd5b600954341015610d2857600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d7257600080fd5b3482018210610d8057600080fd5b3481018110610d8e57600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610dfd57600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610e9b57600202816002028360005260206000209182019101610e9b9190610ea0565b505050565b610ede91905b80821115610eda576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ea6565b5090565b905600a165627a7a72305820bfd698107b970c134cc22e548ada179f36b69083c8842ba6a43ca34c5b9120280029" + StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107b2565b34801561027d57600080fd5b5061028f6004356024356044356107cd565b005b34801561029d57600080fd5b5061012b600160a060020a036004351661082e565b3480156102be57600080fd5b506102d3600160a060020a0360043516610849565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610867565b34801561031c57600080fd5b50610167600160a060020a0360043516602435610882565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a1a565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a45565b34801561038b57600080fd5b5061012b600160a060020a0360043516610ae8565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610b03565b3480156103d057600080fd5b5061012b610d24565b610167600160a060020a0360043516610d2a565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e73565b61064a87610ae8565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a038281166000818152602081815260409182902080543373ffffffffffffffffffffffffffffffffffffffff19821681179092558351951680865291850152815190937f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c69292908290030190a250600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107dd57600080fd5b600083116107ea57600080fd5b600082116107f757600080fd5b6000811161080457600080fd5b60028202811161081357600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff168061089a575033155b15156108a557600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161094957600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a11565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098157600080fd5b50808401828111156109ad57600160a060020a03861660009081526001602052604090208390556109c9565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a59575033155b1515610a6457600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a8c57600080fd5b600160a060020a0384166000818152600160209081526040918290208685039055815186815291517f66649d0546ffaed7a9e91793ec2fba0941afa9ebed5b599a8031611ad911fd2f9281900390910190a25060019392505050565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610b2957600080fd5b60008811610b3657600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b8157600080fd5b8786038611610b8f57600080fd5b8785038511610b9d57600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bfd57600160a060020a03891660009081526001602052604090208885039055610c17565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c3c8260018301610e9a565b81548110610c4657fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d4457600080fd5b600954341015610d5357600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d9d57600080fd5b3482018210610dab57600080fd5b3481018110610db957600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610e2857600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610ec657600202816002028360005260206000209182019101610ec69190610ecb565b505050565b610f0991905b80821115610f05576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ed1565b5090565b905600a165627a7a72305820b06bd3333e2e53776453551e59e68eaca02b9467d31ef476ff0cd67025335b4d0029" blockchainAccount = accountWrapper{common.HexToAddress("0x00")} staminaAccount = accountWrapper{staminaContractAddress} From 228316f2b0f4b4e6f2e1733b4887491b01311e4e Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Mon, 14 Jan 2019 13:38:52 +0900 Subject: [PATCH 16/26] core: export variables about stamina --- core/genesis.go | 8 ++++---- core/stamina.go | 16 +++++++++------- core/tx_pool.go | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index 0afba85b8..effd6c342 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -305,7 +305,7 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big // DefaultGenesisBlock returns the Plasma main net genesis block. func DefaultGenesisBlock() *Genesis { - staminaBinBytes, err := hex.DecodeString(staminaContractBin[2:]) + staminaBinBytes, err := hex.DecodeString(StaminaContractBin[2:]) if err != nil { panic(err) } @@ -324,7 +324,7 @@ func DefaultGenesisBlock() *Genesis { common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing params.Operator: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, - staminaContractAddress: { + StaminaContractAddress: { Code: staminaBinBytes, Balance: big.NewInt(0), }, @@ -362,7 +362,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { config := *params.AllCliqueProtocolChanges config.Clique.Period = period - staminaBinBytes, err := hex.DecodeString(staminaContractBin[2:]) + staminaBinBytes, err := hex.DecodeString(StaminaContractBin[2:]) if err != nil { panic(err) } @@ -382,7 +382,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing - staminaContractAddress: { + StaminaContractAddress: { Code: staminaBinBytes, Balance: big.NewInt(0), }, diff --git a/core/stamina.go b/core/stamina.go index acc007036..4f1b20398 100644 --- a/core/stamina.go +++ b/core/stamina.go @@ -16,12 +16,14 @@ var ( ) var ( - staminaContractAddressHex = "0x000000000000000000000000000000000000dead" - staminaContractAddress = common.HexToAddress(staminaContractAddressHex) + StaminaContractAddressHex = "0x000000000000000000000000000000000000dead" + StaminaContractAddress = common.HexToAddress(StaminaContractAddressHex) StaminaContractBin = "0x6080604052600436106101115763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630ebb172a81146101165780631556d8ac1461013d578063158ef93e146101525780633900e4ec1461017b5780633ccfd60b1461019c5780635be4f765146101b15780637b929c271461021a57806383cd9cc31461022f578063857184d1146102505780638cd8db8a14610271578063937aaef1146102915780639b4e735f146102b2578063b69ad63b146102ef578063bcac973614610310578063c35082a914610334578063d1c0c0421461035b578063d898ae1c1461037f578063da95ebf7146103a0578063e1e158a5146103c4578063f340fa01146103d9575b600080fd5b34801561012257600080fd5b5061012b6103ed565b60408051918252519081900360200190f35b34801561014957600080fd5b5061012b6103f3565b34801561015e57600080fd5b506101676103f9565b604080519115158252519081900360200190f35b34801561018757600080fd5b5061012b600160a060020a0360043516610402565b3480156101a857600080fd5b5061016761041d565b3480156101bd57600080fd5b506101d5600160a060020a0360043516602435610633565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152600160a060020a03909116828401521515606082015290519081900360800190f35b34801561022657600080fd5b50610167610716565b34801561023b57600080fd5b50610167600160a060020a036004351661071f565b34801561025c57600080fd5b5061012b600160a060020a03600435166107b2565b34801561027d57600080fd5b5061028f6004356024356044356107cd565b005b34801561029d57600080fd5b5061012b600160a060020a036004351661082e565b3480156102be57600080fd5b506102d3600160a060020a0360043516610849565b60408051600160a060020a039092168252519081900360200190f35b3480156102fb57600080fd5b5061012b600160a060020a0360043516610867565b34801561031c57600080fd5b50610167600160a060020a0360043516602435610882565b34801561034057600080fd5b5061012b600160a060020a0360043581169060243516610a1a565b34801561036757600080fd5b50610167600160a060020a0360043516602435610a45565b34801561038b57600080fd5b5061012b600160a060020a0360043516610ae8565b3480156103ac57600080fd5b50610167600160a060020a0360043516602435610b03565b3480156103d057600080fd5b5061012b610d24565b610167600160a060020a0360043516610d2a565b600b5481565b600a5481565b60085460ff1681565b600160a060020a031660009081526001602052604090205490565b33600090815260056020526040812080548290819081908190811061044157600080fd5b3360009081526006602052604090205493508315801561048c575084600081548110151561046b57fe5b906000526020600020906002020160010160149054906101000a900460ff16155b1561049a57600092506104c0565b8315156104b9578454600211156104b057600080fd5b600192506104c0565b8360010192505b845483106104cd57600080fd5b3360009081526005602052604090208054849081106104e857fe5b906000526020600020906002020191508160010160149054906101000a900460ff1615151561051657600080fd5b600b548254437001000000000000000000000000000000009091046fffffffffffffffffffffffffffffffff16909101111561055157600080fd5b50805460018201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905533600081815260066020526040808220869055516fffffffffffffffffffffffffffffffff9093169283156108fc0291849190818181858888f193505050501580156105db573d6000803e3d6000fd5b50600182015460408051838152602081018690528151600160a060020a039093169233927f91fb9d98b786c57d74c099ccd2beca1739e9f6a81fb49001ca465c4b7591bbe2928290030190a360019550505050505090565b600080600080610641610e73565b61064a87610ae8565b861061065557600080fd5b600160a060020a038716600090815260056020526040902080548790811061067957fe5b600091825260209182902060408051608081018252600290930290910180546fffffffffffffffffffffffffffffffff80821680865270010000000000000000000000000000000090920416948401859052600190910154600160a060020a03811692840183905260ff7401000000000000000000000000000000000000000090910416151560609093018390529a929950975095509350505050565b600c5460ff1681565b600854600090819060ff16151561073557600080fd5b50600160a060020a038281166000818152602081815260409182902080543373ffffffffffffffffffffffffffffffffffffffff19821681179092558351951680865291850152815190937f5884d7e3ec123de8e772bcf576c18dcdad75b056c4314f999ed966693419c69292908290030190a250600192915050565b600160a060020a031660009081526002602052604090205490565b60085460ff16156107dd57600080fd5b600083116107ea57600080fd5b600082116107f757600080fd5b6000811161080457600080fd5b60028202811161081357600080fd5b600992909255600a55600b556008805460ff19166001179055565b600160a060020a031660009081526004602052604090205490565b600160a060020a039081166000908152602081905260409020541690565b600160a060020a031660009081526007602052604090205490565b600c5460009081908190819060ff168061089a575033155b15156108a557600080fd5b600a54600160a060020a0387166000908152600460205260409020544391011161094957600160a060020a038616600081815260026020908152604080832054600180845282852091909155600483528184204390556007835281842080548201905581519384529183019190915280517f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f68099281900390910190a260019350610a11565b600160a060020a0386166000908152600260209081526040808320546001909252909120549093509150848201821061098157600080fd5b50808401828111156109ad57600160a060020a03861660009081526001602052604090208390556109c9565b600160a060020a03861660009081526001602052604090208190555b60408051868152600060208201528151600160a060020a038916927f85bf8701ef98ea32e97f08708da81c7daa93e87ea3e2fd661801cce6d36f6809928290030190a2600193505b50505092915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600c54600090819060ff1680610a59575033155b1515610a6457600080fd5b50600160a060020a0383166000908152600160205260409020548281038111610a8c57600080fd5b600160a060020a0384166000818152600160209081526040918290208685039055815186815291517f66649d0546ffaed7a9e91793ec2fba0941afa9ebed5b599a8031611ad911fd2f9281900390910190a25060019392505050565b600160a060020a031660009081526005602052604090205490565b6000806000806000806000600860009054906101000a900460ff161515610b2957600080fd5b60008811610b3657600080fd5b600160a060020a0389166000818152600260209081526040808320543384526003835281842094845293825280832054600190925282205492985096509094508511610b8157600080fd5b8786038611610b8f57600080fd5b8785038511610b9d57600080fd5b600160a060020a03891660008181526002602090815260408083208c8b0390553383526003825280832093835292905220888603905587841115610bfd57600160a060020a03891660009081526001602052604090208885039055610c17565b600160a060020a0389166000908152600160205260408120555b336000908152600560205260409020805490935091508282610c3c8260018301610e9a565b81548110610c4657fe5b60009182526020918290206002919091020180546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff8b8116919091178116700100000000000000000000000000000000439283160217825560018201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038e16908117909155604080518d81529485019290925283820186905290519193509133917f3aeb15af61588a39bcfafb19ed853140d195c2a924537afbf9a6d04348e76a69916060908290030190a350600198975050505050505050565b60095481565b60085460009081908190819060ff161515610d4457600080fd5b600954341015610d5357600080fd5b505050600160a060020a03821660008181526002602090815260408083205433845260038352818420948452938252808320546001909252909120543483018310610d9d57600080fd5b3482018210610dab57600080fd5b3481018110610db957600080fd5b600160a060020a038516600081815260026020908152604080832034888101909155338452600383528184209484529382528083208685019055600182528083209385019093556004905220541515610e2857600160a060020a03851660009081526004602052604090204390555b604080513481529051600160a060020a0387169133917f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a79181900360200190a3506001949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b815481835581811115610ec657600202816002028360005260206000209182019101610ec69190610ecb565b505050565b610f0991905b80821115610f05576000815560018101805474ffffffffffffffffffffffffffffffffffffffffff19169055600201610ed1565b5090565b905600a165627a7a72305820b06bd3333e2e53776453551e59e68eaca02b9467d31ef476ff0cd67025335b4d0029" +) +var ( blockchainAccount = accountWrapper{common.HexToAddress("0x00")} - staminaAccount = accountWrapper{staminaContractAddress} + staminaAccount = accountWrapper{StaminaContractAddress} staminaABI, _ = abi.JSON(strings.NewReader(contract.StaminaABI)) ) @@ -39,7 +41,7 @@ func GetDelegatee(evm *vm.EVM, from common.Address) (common.Address, error) { return common.Address{}, err } - ret, _, err := evm.StaticCall(blockchainAccount, staminaContractAddress, data, 1000000) + ret, _, err := evm.StaticCall(blockchainAccount, StaminaContractAddress, data, 1000000) if err != nil { return common.Address{}, err @@ -54,7 +56,7 @@ func GetStamina(evm *vm.EVM, delegatee common.Address) (*big.Int, error) { return big.NewInt(0), err } - ret, _, err := evm.StaticCall(blockchainAccount, staminaContractAddress, data, 1000000) + ret, _, err := evm.StaticCall(blockchainAccount, StaminaContractAddress, data, 1000000) if err != nil { return big.NewInt(0), err @@ -72,7 +74,7 @@ func AddStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error { return err } - res, _, err := evm.Call(blockchainAccount, staminaContractAddress, data, 1000000, big.NewInt(0)) + res, _, err := evm.Call(blockchainAccount, StaminaContractAddress, data, 1000000, big.NewInt(0)) if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { return errUpdateStamina @@ -87,7 +89,7 @@ func SubtractStamina(evm *vm.EVM, delegatee common.Address, gas *big.Int) error return err } - res, _, err := evm.Call(blockchainAccount, staminaContractAddress, data, 1000000, big.NewInt(0)) + res, _, err := evm.Call(blockchainAccount, StaminaContractAddress, data, 1000000, big.NewInt(0)) if new(big.Int).SetBytes(res).Cmp(common.Big1) != 0 { return errUpdateStamina diff --git a/core/tx_pool.go b/core/tx_pool.go index 23d1b5c66..6fcfcbecd 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1157,7 +1157,7 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { func (pool *TxPool) newStaticEVM() *vm.EVM { msg := types.NewMessage( blockchainAccount.Address(), - &staminaContractAddress, + &StaminaContractAddress, 0, big.NewInt(0), 1000000, From f63c74c7bc1b11512b0760746c652b6c1e736092 Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Mon, 14 Jan 2019 13:41:03 +0900 Subject: [PATCH 17/26] accounts/abi/bind: add CurrentBlock func --- accounts/abi/bind/backends/simulated.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index ded8a105b..cdb30a7cf 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -35,10 +35,10 @@ import ( "github.com/Onther-Tech/plasma-evm/core/state" "github.com/Onther-Tech/plasma-evm/core/types" "github.com/Onther-Tech/plasma-evm/core/vm" - "github.com/Onther-Tech/plasma-evm/pls/filters" "github.com/Onther-Tech/plasma-evm/ethdb" "github.com/Onther-Tech/plasma-evm/event" "github.com/Onther-Tech/plasma-evm/params" + "github.com/Onther-Tech/plasma-evm/pls/filters" "github.com/Onther-Tech/plasma-evm/rpc" ) @@ -158,6 +158,11 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres return val[:], nil } +// CurrentBlock returns current block number. +func (b *SimulatedBackend) CurrentBlock() *big.Int { + return b.blockchain.CurrentBlock().Number() +} + // TransactionReceipt returns the receipt of a transaction. func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash) From 73c8b7d807b385335a6e967aa629cf3c6ed216d9 Mon Sep 17 00:00:00 2001 From: "Geonwoo, Shin" Date: Mon, 14 Jan 2019 19:41:23 +0900 Subject: [PATCH 18/26] core: change receipt root calc func --- core/block_validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/block_validator.go b/core/block_validator.go index 215042dfa..3e045873e 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -89,7 +89,7 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat return fmt.Errorf("invalid bloom (remote: %x local: %x)", header.Bloom, rbloom) } // Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, R1]])) - receiptSha := types.DeriveSha(receipts) + receiptSha := types.DeriveShaFromBMT(receipts) if receiptSha != header.ReceiptHash { return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash, receiptSha) } From c2dff98168ae785c8a9479c1972bb9e74865893a Mon Sep 17 00:00:00 2001 From: "Geonwoo, Shin" Date: Mon, 14 Jan 2019 19:45:07 +0900 Subject: [PATCH 19/26] contracts/stamina: make core/stamina test code --- contracts/stamina/stamina.go | 42 +++--- contracts/stamina/stamina_test.go | 210 ++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+), 16 deletions(-) create mode 100644 contracts/stamina/stamina_test.go diff --git a/contracts/stamina/stamina.go b/contracts/stamina/stamina.go index 780477ebf..97066b04e 100644 --- a/contracts/stamina/stamina.go +++ b/contracts/stamina/stamina.go @@ -1,19 +1,29 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library 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 Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - package stamina //go:generate abigen --sol contract/Stamina.sol --pkg contract --out contract/stamina.go + +import ( + "github.com/Onther-Tech/plasma-evm/accounts/abi/bind" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/contracts/stamina/contract" +) + +type Stamina struct { + *contract.StaminaSession + contractBackend bind.ContractBackend +} + +func NewStamina(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*Stamina, error) { + stamina, err := contract.NewStamina(contractAddr, contractBackend) + if err != nil { + return nil, err + } + + return &Stamina{ + &contract.StaminaSession{ + Contract: stamina, + TransactOpts: *transactOpts, + }, + contractBackend, + }, nil +} diff --git a/contracts/stamina/stamina_test.go b/contracts/stamina/stamina_test.go new file mode 100644 index 000000000..3194d7783 --- /dev/null +++ b/contracts/stamina/stamina_test.go @@ -0,0 +1,210 @@ +package stamina + +import ( + "context" + "crypto/ecdsa" + "encoding/hex" + "math/big" + "testing" + + "github.com/Onther-Tech/plasma-evm/accounts/abi/bind" + "github.com/Onther-Tech/plasma-evm/accounts/abi/bind/backends" + "github.com/Onther-Tech/plasma-evm/common" + "github.com/Onther-Tech/plasma-evm/core" + "github.com/Onther-Tech/plasma-evm/core/types" + "github.com/Onther-Tech/plasma-evm/crypto" + "github.com/Onther-Tech/plasma-evm/params" +) + +var ( + delegateeKey, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") + delegateeAddr = crypto.PubkeyToAddress(delegateeKey.PublicKey) + delegateeOpt = bind.NewKeyedTransactor(delegateeKey) + + depositorAddr = delegateeAddr + + key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + key2, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") + addr1 = crypto.PubkeyToAddress(key1.PublicKey) + addr2 = crypto.PubkeyToAddress(key2.PublicKey) + opt1 = bind.NewKeyedTransactor(key1) + opt2 = bind.NewKeyedTransactor(key2) +) + +var ( + stamina = big.NewInt(5000000000) + minDeposit = big.NewInt(100) + recoveryEpochLength = big.NewInt(10) + withdrawalDelay = big.NewInt(50) +) + +func TestStamina(t *testing.T) { + staminaBinBytes, err := hex.DecodeString(core.StaminaContractBin[2:]) + if err != nil { + panic(err) + } + + contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{ + delegateeAddr: {Balance: big.NewInt(10000000000)}, + addr1: {Balance: big.NewInt(0)}, + addr2: {Balance: big.NewInt(10000000000)}, + core.StaminaContractAddress: { + Code: staminaBinBytes, + Balance: big.NewInt(0), + }, + }, 10000000000) + + staminaContract, err := NewStamina(delegateeOpt, core.StaminaContractAddress, contractBackend) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + + // init + if _, err := staminaContract.Init(minDeposit, recoveryEpochLength, withdrawalDelay); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + initialized, err := staminaContract.Initialized() + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if !initialized { + t.Errorf("expected: %v, got %v", false, initialized) + } + + staminaContract.TransactOpts.Value = stamina + // deposit + if _, err := staminaContract.Deposit(delegateeAddr); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + deposit, err := staminaContract.GetDeposit(depositorAddr, delegateeAddr) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if deposit.Cmp(stamina) != 0 { + t.Errorf("expected: %v, got %v", stamina, deposit) + } + + // Eth : short + // Stamina: short + if err := sendSignedTransferTransaction(contractBackend, addr1, key1); err == nil { + t.Fatal("expected insufficient balance to pay for gas") + } + + // Eth : short + // Stamina: enough + staminaContract.TransactOpts = *delegateeOpt + if _, err = staminaContract.SetDelegator(addr1); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + delegatee, err := staminaContract.GetDelegatee(addr1) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if delegatee != delegateeAddr { + t.Errorf("expected: %v, got %v", delegateeAddr, delegatee) + } + + staminaContract.TransactOpts = *opt1 + beforeStaminaRemaining, _ := staminaContract.GetStamina(delegateeAddr) + beforeBalance, _ := contractBackend.BalanceAt(context.Background(), addr1, contractBackend.CurrentBlock()) + + if err := sendSignedTransferTransaction(contractBackend, addr1, key1); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + afterStaminaRemaining, _ := staminaContract.GetStamina(delegateeAddr) + afterBalance, _ := contractBackend.BalanceAt(context.Background(), addr1, contractBackend.CurrentBlock()) + + if beforeBalance.Cmp(afterBalance) != 0 { + t.Errorf("balance before: %v, after %v", beforeBalance, afterBalance) + } + if beforeStaminaRemaining.Cmp(new(big.Int).Add(afterStaminaRemaining, big.NewInt(21000))) != 0 { + t.Error("failed precise stamina subtract") + } + + // Eth : enough + // Stamina: short + staminaContract.TransactOpts = *opt2 + beforeStaminaRemaining, _ = staminaContract.GetStamina(delegateeAddr) + beforeBalance, _ = contractBackend.BalanceAt(context.Background(), addr2, contractBackend.CurrentBlock()) + + if err := sendSignedTransferTransaction(contractBackend, addr2, key2); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + afterStaminaRemaining, _ = staminaContract.GetStamina(delegateeAddr) + afterBalance, _ = contractBackend.BalanceAt(context.Background(), addr2, contractBackend.CurrentBlock()) + + if beforeBalance.Cmp(new(big.Int).Add(afterBalance, big.NewInt(21000))) != 0 { + t.Error("failed precise balance subtract") + } + if beforeStaminaRemaining.Cmp(afterStaminaRemaining) != 0 { + t.Errorf("stamina before: %v, after %v", beforeStaminaRemaining, afterStaminaRemaining) + } + + // Eth : enough + // Stamina: enough + staminaContract.TransactOpts = *delegateeOpt + if _, err := staminaContract.SetDelegator(addr2); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + delegatee, err = staminaContract.GetDelegatee(addr2) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if delegatee != delegateeAddr { + t.Errorf("expected: %v, got %v", delegateeAddr, delegatee) + } + + staminaContract.TransactOpts = *opt2 + beforeStaminaRemaining, _ = staminaContract.GetStamina(delegateeAddr) + beforeBalance, _ = contractBackend.BalanceAt(context.Background(), addr2, contractBackend.CurrentBlock()) + + if err := sendSignedTransferTransaction(contractBackend, addr2, key2); err != nil { + t.Fatalf("expected no error, got %v", err) + } + contractBackend.Commit() + + afterStaminaRemaining, _ = staminaContract.GetStamina(delegateeAddr) + afterBalance, _ = contractBackend.BalanceAt(context.Background(), addr2, contractBackend.CurrentBlock()) + + if beforeBalance.Cmp(afterBalance) != 0 { + t.Errorf("balance before: %v, after %v", beforeBalance, afterBalance) + } + if beforeStaminaRemaining.Cmp(new(big.Int).Add(afterStaminaRemaining, big.NewInt(21000))) != 0 { + t.Error("failed precise stamina subtract") + } +} + +func sendSignedTransferTransaction(contractBackend *backends.SimulatedBackend, addr common.Address, key *ecdsa.PrivateKey) (err error) { + defer func() { + if r := recover(); r != nil { + err = r.(error) + } + }() + + nonce, err := contractBackend.NonceAt(context.Background(), addr, contractBackend.CurrentBlock()) + if err != nil { + return err + } + signedTx, err := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(1), nil), types.HomesteadSigner{}, key) + if err != nil { + return err + } + err = contractBackend.SendTransaction(context.Background(), signedTx) + if err != nil { + return err + } + + return nil +} From 3dd52951ebfc436e02548589de15e51f4f0b9165 Mon Sep 17 00:00:00 2001 From: cd4761 Date: Wed, 23 Jan 2019 17:36:25 +0900 Subject: [PATCH 20/26] cmd/puppeth: add query for rootchain contract address --- Makefile | 5 +++++ cmd/puppeth/wizard_genesis.go | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 966bf9cbb..ce40a3fb1 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,11 @@ swarm: all: build/env.sh go run build/ci.go install +puppeth: + build/env.sh go run build/ci.go install ./cmd/puppeth + @echo "Done building." + @echo "Run \"$(GOBIN)/puppeth\" to launch puppeth." + android: build/env.sh go run build/ci.go aar --local @echo "Done building." diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 898cac4d9..cef03e40e 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -63,7 +63,17 @@ func (w *wizard) makeGenesis() { case choice == "1": // In case of ethash, we're pretty much done genesis.Config.Ethash = new(params.EthashConfig) - genesis.ExtraData = make([]byte, 32) + genesis.ExtraData = make([]byte, 20) + genesis.Difficulty = big.NewInt(1) + + // Query for the rootchain contract + fmt.Println() + fmt.Println("What is the rootchain contract address?") + var rootchain []common.Address + if address := w.readAddress(); address != nil { + rootchain = append(rootchain, *address) + } + copy(genesis.ExtraData[:common.AddressLength], rootchain[0][:]) case choice == "" || choice == "2": // In the case of clique, configure the consensus parameters @@ -127,6 +137,9 @@ func (w *wizard) makeGenesis() { genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(1)} } } + + //copy(genesis.ExtraData[:common.AddressLength], rootchain[0][:]) + // Query the user for some custom extras fmt.Println() fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)") From 394a85079c9134020e7f0df47fc6716ed3539d33 Mon Sep 17 00:00:00 2001 From: cd4761 Date: Wed, 23 Jan 2019 17:38:37 +0900 Subject: [PATCH 21/26] cmd/puppeth: add query for rootchain contract address --- cmd/puppeth/wizard_genesis.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index cef03e40e..385daba27 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -138,8 +138,6 @@ func (w *wizard) makeGenesis() { } } - //copy(genesis.ExtraData[:common.AddressLength], rootchain[0][:]) - // Query the user for some custom extras fmt.Println() fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)") From 7683677d339af97266f955cf27060bf12409a512 Mon Sep 17 00:00:00 2001 From: Geonwoo Shin Date: Thu, 24 Jan 2019 16:31:22 +0900 Subject: [PATCH 22/26] pls: set ethash default mode to fake mode --- pls/backend.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pls/backend.go b/pls/backend.go index 0ae6f2165..aea60fa73 100644 --- a/pls/backend.go +++ b/pls/backend.go @@ -271,16 +271,8 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo log.Warn("Ethash used in shared mode") return ethash.NewShared() default: - engine := ethash.New(ethash.Config{ - CacheDir: ctx.ResolvePath(config.CacheDir), - CachesInMem: config.CachesInMem, - CachesOnDisk: config.CachesOnDisk, - DatasetDir: config.DatasetDir, - DatasetsInMem: config.DatasetsInMem, - DatasetsOnDisk: config.DatasetsOnDisk, - }, notify, noverify) - engine.SetThreads(-1) // Disable CPU mining - return engine + log.Warn("Ethash used in fake mode") + return ethash.NewFaker() } } From 0f2f467576d83f4b87da20da2bf7dc93911264fd Mon Sep 17 00:00:00 2001 From: Dapploper Date: Thu, 24 Jan 2019 16:46:06 +0900 Subject: [PATCH 23/26] consensus/ethash: verify forknumber by difficulty --- consensus/ethash/consensus.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index e71dcf891..939319727 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -24,7 +24,6 @@ import ( "runtime" "time" - mapset "github.com/deckarep/golang-set" "github.com/Onther-Tech/plasma-evm/common" "github.com/Onther-Tech/plasma-evm/common/math" "github.com/Onther-Tech/plasma-evm/consensus" @@ -34,6 +33,7 @@ import ( "github.com/Onther-Tech/plasma-evm/crypto/sha3" "github.com/Onther-Tech/plasma-evm/params" "github.com/Onther-Tech/plasma-evm/rlp" + mapset "github.com/deckarep/golang-set" ) // Ethash proof-of-work protocol constants. @@ -254,12 +254,13 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * if header.Time.Cmp(parent.Time) <= 0 { return errZeroBlockTime } - // Verify the block's difficulty based in it's timestamp and parent's difficulty + // Verify the block's fork number by difficulty expected := ethash.CalcDifficulty(chain, header.Time.Uint64(), parent) - if expected.Cmp(header.Difficulty) != 0 { + if expected.Cmp(header.Difficulty) != 0 && new(big.Int).Sub(header.Difficulty, expected).Cmp(big.NewInt(1)) != 0 { return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, expected) } + // Verify that the gas limit is <= 2^63-1 cap := uint64(0x7fffffffffffffff) if header.GasLimit > cap { @@ -304,6 +305,9 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * // the difficulty that a new block should have when created at time // given the parent block's time and difficulty. func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int { + if ethash.config.PowMode == ModeFake || ethash.config.PowMode == ModeFullFake { + return new(big.Int).Set(parent.Difficulty) + } return CalcDifficulty(chain.Config(), time, parent) } From 6e548f73dd5716f663e1616836601fde0f0ae279 Mon Sep 17 00:00:00 2001 From: 4000D Date: Wed, 23 Jan 2019 17:44:23 +0900 Subject: [PATCH 24/26] contracts,plasma: update RootChain contract --- contracts/plasma/plasma-evm-cotracts | 2 +- contracts/plasma/rootchain/rootchain.go | 90 +++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/contracts/plasma/plasma-evm-cotracts b/contracts/plasma/plasma-evm-cotracts index bd99cd481..c8ce19476 160000 --- a/contracts/plasma/plasma-evm-cotracts +++ b/contracts/plasma/plasma-evm-cotracts @@ -1 +1 @@ -Subproject commit bd99cd481f7918ab6a7c9a4844e8533709ea11be +Subproject commit c8ce194768afbdecbf53c1d8d6fe13dec18710ae diff --git a/contracts/plasma/rootchain/rootchain.go b/contracts/plasma/rootchain/rootchain.go index d0f3a6b36..8a826b524 100644 --- a/contracts/plasma/rootchain/rootchain.go +++ b/contracts/plasma/rootchain/rootchain.go @@ -341,7 +341,7 @@ func (_BMT *BMTTransactorRaw) Transact(opts *bind.TransactOpts, method string, p const DataABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"NA_TX_GAS_PRICE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NA_TX_GAS_LIMIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"APPLY_IN_ROOTCHAIN_SIGNATURE\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"APPLY_IN_CHILDCHAIN_SIGNATURE\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NA\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" // DataBin is the compiled bytecode used for deploying new contracts. -const DataBin = `0x610208610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600436106100835763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631927ac58811461008857806390e84f56146100a6578063a7b6ae28146100ae578063a89ca766146100c3578063ab73ff05146100cb575b600080fd5b6100906100e0565b60405161009d919061017f565b60405180910390f35b6100906100e8565b6100b66100ef565b60405161009d9190610171565b6100b6610113565b6100d3610137565b60405161009d919061015d565b633b9aca0081565b620186a081565b7fd9afd3a90000000000000000000000000000000000000000000000000000000081565b7fe904e3d90000000000000000000000000000000000000000000000000000000081565b600081565b6101458161018d565b82525050565b610145816101a6565b610145816101cb565b6020810161016b828461013c565b92915050565b6020810161016b828461014b565b6020810161016b8284610154565b73ffffffffffffffffffffffffffffffffffffffff1690565b7fffffffff000000000000000000000000000000000000000000000000000000001690565b905600a265627a7a72305820460487125101bc5bab9c30a7bc7fd2458c964362244ccebf4d517e89b4d949f36c6578706572696d656e74616cf50037` +const DataBin = `0x610208610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600436106100835763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631927ac58811461008857806390e84f56146100a6578063a7b6ae28146100ae578063a89ca766146100c3578063ab73ff05146100cb575b600080fd5b6100906100e0565b60405161009d919061017f565b60405180910390f35b6100906100e8565b6100b66100ef565b60405161009d9190610171565b6100b6610113565b6100d3610137565b60405161009d919061015d565b633b9aca0081565b620186a081565b7fd9afd3a90000000000000000000000000000000000000000000000000000000081565b7fe904e3d90000000000000000000000000000000000000000000000000000000081565b600081565b6101458161018d565b82525050565b610145816101a6565b610145816101cb565b6020810161016b828461013c565b92915050565b6020810161016b828461014b565b6020810161016b8284610154565b73ffffffffffffffffffffffffffffffffffffffff1690565b7fffffffff000000000000000000000000000000000000000000000000000000001690565b905600a265627a7a72305820855d1c8d387d249f4cb04a3b5052a4c42db6dc4f573e1c0467312b07c4da54f96c6578706572696d656e74616cf50037` // DeployData deploys a new Ethereum contract, binding an instance of Data to it. func DeployData(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Data, error) { @@ -1315,10 +1315,10 @@ func (_RequestableContractI *RequestableContractITransactorSession) ApplyRequest } // RootChainABI is the input ABI used to generate the binding from. -const RootChainABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB_PREPARE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_COMPUTATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"lastEpoch\",\"outputs\":[{\"name\":\"lastBlock\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedForkNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"lastBlock\",\"outputs\":[{\"name\":\"lastBlock\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numEnterForORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"startExit\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpoch\",\"outputs\":[{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"startBlockNumber\",\"type\":\"uint64\"},{\"name\":\"endBlockNumber\",\"type\":\"uint64\"},{\"name\":\"firstRequestBlockId\",\"type\":\"uint64\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"isEmpty\",\"type\":\"bool\"},{\"name\":\"initialized\",\"type\":\"bool\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"rebase\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getLastEpoch\",\"outputs\":[{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"startBlockNumber\",\"type\":\"uint64\"},{\"name\":\"endBlockNumber\",\"type\":\"uint64\"},{\"name\":\"firstRequestBlockId\",\"type\":\"uint64\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"isEmpty\",\"type\":\"bool\"},{\"name\":\"initialized\",\"type\":\"bool\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"rebase\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_isTransfer\",\"type\":\"bool\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"startEnter\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_index\",\"type\":\"uint256\"},{\"name\":\"_receiptData\",\"type\":\"bytes\"},{\"name\":\"_proof\",\"type\":\"bytes\"}],\"name\":\"challengeExit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlock\",\"outputs\":[{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestBlockId\",\"type\":\"uint64\"},{\"name\":\"referenceBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"statesRoot\",\"type\":\"bytes32\"},{\"name\":\"transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"receiptsRoot\",\"type\":\"bytes32\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"challenging\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"forks\",\"outputs\":[{\"name\":\"forkedBlock\",\"type\":\"uint64\"},{\"name\":\"firstEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEpoch\",\"type\":\"uint64\"},{\"name\":\"firstBlock\",\"type\":\"uint64\"},{\"name\":\"lastBlock\",\"type\":\"uint64\"},{\"name\":\"lastFinalizedBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"firstEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"nextBlockToRebase\",\"type\":\"uint64\"},{\"name\":\"rebased\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"operator\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"applyRequest\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_key\",\"type\":\"bytes\"},{\"name\":\"_txByte\",\"type\":\"bytes\"},{\"name\":\"_branchMask\",\"type\":\"uint256\"},{\"name\":\"_siblings\",\"type\":\"bytes32[]\"}],\"name\":\"challengeNullAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitNRB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitURB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"firstFilledORENumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"finalizeBlock\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"REQUEST_GAS\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_REQUESTS\",\"outputs\":[{\"name\":\"maxRequests\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_NRB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitORB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NRELength\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_WITHHOLDING\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"makeERU\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"EROs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumEROs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"URBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PREPARE_TIMEOUT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_rootchain\",\"type\":\"address\"},{\"name\":\"_childchain\",\"type\":\"address\"}],\"name\":\"mapRequestableContractByOperator\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"}],\"name\":\"forked\",\"outputs\":[{\"name\":\"result\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_requestId\",\"type\":\"uint256\"}],\"name\":\"getEROBytes\",\"outputs\":[{\"name\":\"out\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"getLastFinalizedBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"requestableContracts\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NULL_ADDRESS\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"prepareToSubmitURB\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"epochHandler\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumORBs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ORBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_requestId\",\"type\":\"uint256\"},{\"name\":\"_userActivated\",\"type\":\"bool\"}],\"name\":\"getRequestFinalized\",\"outputs\":[{\"name\":\"finalized\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ERUs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedBlockNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_epochHandler\",\"type\":\"address\"},{\"name\":\"_development\",\"type\":\"bool\"},{\"name\":\"_NRELength\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"SessionTimeout\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newFork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"forkedBlockNumber\",\"type\":\"uint256\"}],\"name\":\"Forked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"rebase\",\"type\":\"bool\"}],\"name\":\"EpochPrepared\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilling\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"EpochRebased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"fork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"BlockSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"weiAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"isTransfer\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isExit\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"}],\"name\":\"ERUCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"BlockFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestChallenged\",\"type\":\"event\"}]" +const RootChainABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB_PREPARE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_COMPUTATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"lastEpoch\",\"outputs\":[{\"name\":\"lastBlock\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedForkNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"lastBlock\",\"outputs\":[{\"name\":\"lastBlock\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numEnterForORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"startExit\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpoch\",\"outputs\":[{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"startBlockNumber\",\"type\":\"uint64\"},{\"name\":\"endBlockNumber\",\"type\":\"uint64\"},{\"name\":\"firstRequestBlockId\",\"type\":\"uint64\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"isEmpty\",\"type\":\"bool\"},{\"name\":\"initialized\",\"type\":\"bool\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"rebase\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getLastEpoch\",\"outputs\":[{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"startBlockNumber\",\"type\":\"uint64\"},{\"name\":\"endBlockNumber\",\"type\":\"uint64\"},{\"name\":\"firstRequestBlockId\",\"type\":\"uint64\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"isEmpty\",\"type\":\"bool\"},{\"name\":\"initialized\",\"type\":\"bool\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"rebase\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_isTransfer\",\"type\":\"bool\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"startEnter\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_index\",\"type\":\"uint256\"},{\"name\":\"_receiptData\",\"type\":\"bytes\"},{\"name\":\"_proof\",\"type\":\"bytes\"}],\"name\":\"challengeExit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlock\",\"outputs\":[{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestBlockId\",\"type\":\"uint64\"},{\"name\":\"referenceBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"statesRoot\",\"type\":\"bytes32\"},{\"name\":\"transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"receiptsRoot\",\"type\":\"bytes32\"},{\"name\":\"isRequest\",\"type\":\"bool\"},{\"name\":\"userActivated\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"challenging\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"forks\",\"outputs\":[{\"name\":\"forkedBlock\",\"type\":\"uint64\"},{\"name\":\"firstEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEpoch\",\"type\":\"uint64\"},{\"name\":\"firstBlock\",\"type\":\"uint64\"},{\"name\":\"lastBlock\",\"type\":\"uint64\"},{\"name\":\"lastFinalizedBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"firstEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"nextBlockToRebase\",\"type\":\"uint64\"},{\"name\":\"rebased\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"operator\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockFinalizedAt\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"applyRequest\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_key\",\"type\":\"bytes\"},{\"name\":\"_txByte\",\"type\":\"bytes\"},{\"name\":\"_branchMask\",\"type\":\"uint256\"},{\"name\":\"_siblings\",\"type\":\"bytes32[]\"}],\"name\":\"challengeNullAddress\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitNRB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitURB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"firstFilledORENumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"finalizeBlock\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_EXIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"REQUEST_GAS\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_REQUESTS\",\"outputs\":[{\"name\":\"maxRequests\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_NRB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"name\":\"submitORB\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NRELength\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_WITHHOLDING\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_trieKey\",\"type\":\"bytes32\"},{\"name\":\"_trieValue\",\"type\":\"bytes32\"}],\"name\":\"makeERU\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"EROs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumEROs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"URBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PREPARE_TIMEOUT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_rootchain\",\"type\":\"address\"},{\"name\":\"_childchain\",\"type\":\"address\"}],\"name\":\"mapRequestableContractByOperator\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_forkNumber\",\"type\":\"uint256\"}],\"name\":\"forked\",\"outputs\":[{\"name\":\"result\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_requestId\",\"type\":\"uint256\"}],\"name\":\"getEROBytes\",\"outputs\":[{\"name\":\"out\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"forkNumber\",\"type\":\"uint256\"}],\"name\":\"getLastFinalizedBlock\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"requestableContracts\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NULL_ADDRESS\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"prepareToSubmitURB\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"epochHandler\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumORBs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ORBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_requestId\",\"type\":\"uint256\"},{\"name\":\"_userActivated\",\"type\":\"bool\"}],\"name\":\"getRequestFinalized\",\"outputs\":[{\"name\":\"finalized\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ERUs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedBlockNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_epochHandler\",\"type\":\"address\"},{\"name\":\"_development\",\"type\":\"bool\"},{\"name\":\"_NRELength\",\"type\":\"uint256\"},{\"name\":\"_statesRoot\",\"type\":\"bytes32\"},{\"name\":\"_transactionsRoot\",\"type\":\"bytes32\"},{\"name\":\"_receiptsRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"SessionTimeout\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newFork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"forkedBlockNumber\",\"type\":\"uint256\"}],\"name\":\"Forked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"rebase\",\"type\":\"bool\"}],\"name\":\"EpochPrepared\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilling\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"EpochRebased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"fork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"BlockSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"weiAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"isTransfer\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isExit\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"}],\"name\":\"ERUCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"BlockFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestChallenged\",\"type\":\"event\"}]" // RootChainBin is the compiled bytecode used for deploying new contracts. -const RootChainBin = `0x60806040523480156200001157600080fd5b5060405160c080620053c083398101604090815281516020830151918301516060840151608085015160a09095015192949192909190600080600160a060020a03881615156200006057600080fd5b62000082600160a060020a03891664010000000062003c1b6200018c82021704565b15156200008e57600080fd5b505060018054600160a060020a031916600160a060020a0388161781556000805460ff19168715151761010060a860020a03191661010033810291909117825560028781556003805484526005602090815260408086208680526004810183528187208089018c90558086018b90558085018a905593810190925285209586018054600160c060020a03167801000000000000000000000000000000000000000000000000426001604060020a03160217905594909101805461ff001916909217909155906200016b908390839064010000000062000194810204565b6200017e6401000000006200021a810204565b5050505050505050620002db565b6000903b1190565b60048201805464ff0000000019166401000000001790556001830180546001604060020a0383166801000000000000000002604060020a608060020a0319909116179055600354604080519182526020820183905280517ffb96205e4b3633fd57aa805b26b51ecf528714a10241a4af015929dce86768d99281900390910190a1505050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744e524228290000000000000000000000815250601501905060405180910390207c010000000000000000000000000000000000000000000000000000000090046040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381865af4925050501515620002d957600080fd5b565b6150d580620002eb6000396000f3006080604052600436106102585763ffffffff60e060020a600035041663033cfbed811461025d57806308c4fff01461028457806311e4c91414610299578063164bc2ae146102b1578063183d2d1c146102c6578063192adc5b146102db5780631ec2042b146102f05780631f261d5914610308578063236915661461031d57806324839704146103325780632b25a38b14610360578063398bac63146103eb5780633cfb871e14610400578063404f7d661461041f5780634a44bdb8146104595780634ba3a126146104eb578063570ca7351461057157806361d29e83146105a25780636299fb24146105b757806365d724bc146105f75780636b13ab6f1461060c5780636f3e4b901461062057806372ecb9a81461063457806375395a581461064c5780637b929c27146106615780638b5172d0146106765780638eb288ca1461068b57806393521222146106a057806394be3aa51461025d578063a820c067146106b5578063ab96da2d146106c9578063b17fa6e9146106de578063b2ae9ba81461025d578063b41e69dd146106f3578063b443f3cc1461070d578063b540adba14610799578063c0e86064146107ae578063c2bc88fa14610811578063cb5d742f14610826578063ce8a2bc21461084d578063d1723a9614610865578063d636857e146108f2578063d691acd81461025d578063da0185f81461090a578063de0ce17d1461092b578063e6925d0814610940578063e7b88b8014610948578063ea0c73f61461095d578063ea7f22a814610972578063f28a7afa1461098a578063f4f31de4146109a7578063fb788a27146109bf575b600080fd5b34801561026957600080fd5b506102726109d4565b60408051918252519081900360200190f35b34801561029057600080fd5b506102726109e0565b3480156102a557600080fd5b506102726004356109e5565b3480156102bd57600080fd5b50610272610a0a565b3480156102d257600080fd5b50610272610a10565b3480156102e757600080fd5b50610272610a16565b3480156102fc57600080fd5b50610272600435610a22565b34801561031457600080fd5b50610272610a40565b34801561032957600080fd5b50610272610a46565b61034c600160a060020a0360043516602435604435610a4c565b604080519115158252519081900360200190f35b34801561036c57600080fd5b5061037b600435602435610b0b565b604080516001604060020a039c8d1681529a8c1660208c0152988b168a8a0152968a1660608a015294891660808901529290971660a0870152151560c086015294151560e08501529315156101008401529215156101208301529115156101408201529051908190036101600190f35b3480156103f757600080fd5b5061037b610b99565b61034c6004351515600160a060020a0360243516604435606435610c32565b34801561042b57600080fd5b506104576004803590602480359160443591606435808201929081013591608435908101910135610d28565b005b34801561046557600080fd5b50610474600435602435610f86565b604080516001604060020a039d8e1681529b8d1660208d0152998c168b8b015297909a1660608a0152608089019590955260a088019390935260c0870191909152151560e0860152151561010085015215156101208401529215156101408301529115156101608201529051908190036101800190f35b3480156104f757600080fd5b50610503600435611017565b604080516001604060020a039c8d1681529a8c1660208c0152988b168a8a0152968a1660608a0152948916608089015292881660a088015290871660c0870152861660e086015285166101008501529093166101208301529115156101408201529051908190036101600190f35b34801561057d57600080fd5b50610586611089565b60408051600160a060020a039092168252519081900360200190f35b3480156105ae57600080fd5b5061034c61109d565b3480156105c357600080fd5b5061045760048035906024803580820192908101359160443580820192908101359160643591608435918201910135611734565b34801561060357600080fd5b50610272611796565b61034c60043560243560443560643561179c565b61034c600435602435604435606435611b27565b34801561064057600080fd5b50610272600435611eb8565b34801561065857600080fd5b5061034c611eca565b34801561066d57600080fd5b5061034c611ee6565b34801561068257600080fd5b50610272611eef565b34801561069757600080fd5b50610272611efb565b3480156106ac57600080fd5b50610272611f02565b61034c600435602435604435606435611f11565b3480156106d557600080fd5b5061027261242c565b3480156106ea57600080fd5b50610272612432565b61034c600160a060020a0360043516602435604435612437565b34801561071957600080fd5b506107256004356124e9565b604080516001604060020a03909c168c5299151560208c01529715158a8a015295151560608a015293151560808901526001608060020a0390921660a0880152600160a060020a0390811660c08801521660e086015261010085015261012084015261014083015251908190036101600190f35b3480156107a557600080fd5b50610272612593565b3480156107ba57600080fd5b506107c6600435612599565b6040805196151587526001604060020a0395861660208801529385168685015291841660608601529092166080840152600160a060020a0390911660a0830152519081900360c00190f35b34801561081d57600080fd5b50610272612615565b34801561083257600080fd5b5061034c600160a060020a036004358116906024351661261b565b34801561085957600080fd5b5061034c6004356126bf565b34801561087157600080fd5b5061087d6004356126c7565b6040805160208082528351818301528351919283929083019185019080838360005b838110156108b757818101518382015260200161089f565b50505050905090810190601f1680156108e45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156108fe57600080fd5b506102726004356127f7565b34801561091657600080fd5b50610586600160a060020a036004351661281c565b34801561093757600080fd5b50610586612837565b61045761283c565b34801561095457600080fd5b506105866128e1565b34801561096957600080fd5b506102726128f0565b34801561097e57600080fd5b506107c66004356128f6565b34801561099657600080fd5b5061034c6004356024351515612904565b3480156109b357600080fd5b5061072560043561294f565b3480156109cb57600080fd5b5061027261295d565b67016345785d8a000081565b600181565b600081815260056020526040902054608060020a90046001604060020a03165b919050565b600b5481565b60035481565b670c7d713b49da000081565b6000908152600560205260409020600101546001604060020a031690565b600e5481565b600a5481565b60008067016345785d8a000034811115610a6557600080fd5b831515610a7157600080fd5b610a886006600860008960008a8a60016000612963565b60408051828152336020820152600160a060020a038916818301526000606082018190526080820189905260a0820188905260c08201819052600160e083015261010082015290519193507f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e391908190036101200190a150600195945050505050565b6000918252600560209081526040808420928452600390920190529020805460018201546002909201546001604060020a0380831694604060020a808504831695608060020a860484169560c060020a900484169484821694929091049091169160ff8083169261010081048216926201000082048316926301000000830481169264010000000090041690565b60038054600090815260056020908152604080832080546001604060020a03608060020a9182900481168652919095019092529091208054600182015460029092015481841695604060020a808404861696840486169560c060020a90940484169480851694919004169160ff808216926101008304821692620100008104831692630100000082048116926401000000009092041690565b6000803481610c4a600660088a8a868b8b8880612963565b600a80546001019055600354600090815260056020908152604080832081518581529283019390935280519396509193507f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929081900390910190a160408051848152336020820152600160a060020a03891681830152606081018490526080810188905260a0810187905289151560c0820152600060e0820181905261010082015290517f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e3918190036101200190a1506001979650505050505050565b6000878152600560209081526040808320898452600480820190935290832091820154909290819060ff161515610d5e57600080fd5b6004830154640100000000900460ff161515610d7957600080fd5b506004820154610100900460ff168015610e6757825460098054610e2e92869291604060020a9091046001604060020a0316908110610db457fe5b906000526020600020906002020160078c8c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050508b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843750612f12945050505050565b60405190925033906000906702c68af0bb1400009082818181858883f19350505050158015610e61573d6000803e3d6000fd5b50610f3d565b825460088054610f0892869291604060020a9091046001604060020a0316908110610e8e57fe5b906000526020600020906002020160068c8c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050508b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843750612f12945050505050565b604051909250339060009067016345785d8a00009082818181858883f19350505050158015610f3b573d6000803e3d6000fd5b505b60408051838152821515602082015281517fc8135db115644ed4ae193313c4c801235ef740d2a57a8d5e6fe26ab66635698a929181900390910190a15050505050505050505050565b60009182526005602090815260408084209284526004928301909152909120805460018201546002830154600384015493909401546001604060020a0380841696604060020a850482169660c060020a8604831696608060020a90960490921694919260ff808216926101008304821692620100008104831692630100000082048116926401000000009092041690565b6005602052600090815260409020805460018201546002909201546001604060020a0380831693604060020a808504831694608060020a80820485169560c060020a9283900486169585811695858104821695848204831695909104821693838316939182049092169160ff9104168b565b6000546101009004600160a060020a031681565b600b5460009081526005602052604081206001810154600c548392839290918391829182918291829182916001604060020a0390911610156110de57600080fd5b600c54600090815260048089016020908152604080842080546001604060020a031680865260038d01909352932091830154909b50919750955060ff1615156111b1575b600089815260038801602052604090206002015462010000900460ff161515611177576000898152600388016020526040902060020154610100900460ff16151561116c57600080fd5b886001019850611122565b9354608060020a90046001604060020a0316600c8190556000898152600388016020908152604080832093835260048a0190915290209550935b6004860154640100000000900460ff1615156111cc57600080fd5b6004860154610100900460ff161561148557600e5460075490985088106111f257600080fd5b600780548990811061120057fe5b9060005260206000209060060201935060098660000160089054906101000a90046001604060020a03166001604060020a031681548110151561123f57fe5b6000918252602090912060029091020160018101549093506001604060020a03168814156112b057865460006001604060020a0390911611801561129757508654600c546000196001604060020a0392831601909116145b156112a657600b805460010190555b600c805460010190555b60018801600e558354604060020a900460ff1680156112d857508354605860020a900460ff16155b1561142957604080516101608101825285546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001850154600160a060020a0390811660c083015260028601541660e08201526003850154610100820152600485015461012082015260058501546101408201526113ac9089613059565b506001840154604051600160a060020a03909116906000906702c68af0bb1400009082818181858883f193505050501580156113ec573d6000803e3d6000fd5b50604080518981526001602082015281517f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929181900390910190a15b83546aff000000000000000000001916605060020a178455604080518981526001602082015281517f134017cf3262b18f892ee95dde3b0aec9a80cc70a7c96f09c64bd237aceb0473929181900390910190a160019950611728565b600d54600654909850881061149957600080fd5b60068054899081106114a757fe5b9060005260206000209060060201915060088660000160089054906101000a90046001604060020a03166001604060020a03168154811015156114e657fe5b6000918252602090912060029091020160018101549091506001604060020a031688141561155757865460006001604060020a0390911611801561153e57508654600c546000196001604060020a0392831601909116145b1561154d57600b805460010190555b600c805460010190555b60018801600d558154604060020a900460ff16801561157f57508154605860020a900460ff16155b156116d057604080516101608101825283546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001830154600160a060020a0390811660c083015260028401541660e08201526003830154610100820152600483015461012082015260058301546101408201526116539089613059565b506001820154604051600160a060020a039091169060009067016345785d8a00009082818181858883f19350505050158015611693573d6000803e3d6000fd5b50604080518981526000602082015281517f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929181900390910190a15b81546aff000000000000000000001916605060020a178255604080518981526000602082015281517f134017cf3262b18f892ee95dde3b0aec9a80cc70a7c96f09c64bd237aceb0473929181900390910190a1600199505b50505050505050505090565b60035460009081526005602090815260408083208b8452600480820190935292209081015460ff161561176657600080fd5b8054426001604060020a03608060020a909204919091166001011161178a57600080fd5b50505050505050505050565b600d5481565b6000805481908190819081906101009004600160a060020a031633146117c157600080fd5b67016345785d8a0000348111156117d757600080fd5b6117df613184565b506003548a146117ee57600080fd5b60008a8152600560205260409020945089158061183c57506000198a016000908152600560205260409020546001604060020a03161580159061183c57506002850154608060020a900460ff165b156118cf57611857858a8a8a6000808063ffffffff61330e16565b604080518d8152602081018490528082018390526000606082018190526080820152905192965090945060008051602061508a833981519152919081900360a00190a1600084815260038601602052604090205460c060020a90046001604060020a03168314156118ca576118ca6134f0565b611b1a565b6118e6858a8a8a600080600163ffffffff61330e16565b80945081955050508460020160089054906101000a90046001604060020a031685600401600085815260200190815260200160002060000160186101000a8154816001604060020a0302191690836001604060020a031602179055506005600060018c03815260200190815260200160002091508160040160008660020160089054906101000a90046001604060020a03166001604060020a03168152602001908152602001600020600201546000191688600019161415156119a857600080fd5b604080518b8152602081018690528082018590526000606082018190526080820152905160008051602061508a8339815191529181900360a00190a16119f4858363ffffffff61357e16565b15611b15578285600301600086815260200190815260200160002060000160186101000a8154816001604060020a0302191690836001604060020a0316021790555060018560020160106101000a81548160ff0219169083151502179055507f030c1c69405c93021f28f57557240dee939a320b826a1fd0d39bf6e629ecab478a8587600301600088815260200190815260200160002060000160109054906101000a90046001604060020a0316866000806000806000604051808a8152602001898152602001886001604060020a03168152602001878152602001868152602001858152602001841515151581526020018315151515815260200182151515158152602001995050505050505050505060405180910390a1611b156136c6565b600195505b5050505050949350505050565b60008080808080670c7d713b49da000034811115611b4457600080fd5b8a6003546001011495508580611b5b57508a600354145b1515611b6657600080fd5b60008b815260056020526040902094508515611c185760038054600101905560008b8152600560205260409020945042611b9e613752565b6001870154608060020a90046001604060020a03160111611bbe57600080fd5b8454604080518d81526001604060020a03608060020a84048116602083015260c060020a90930490921682820152517f0647d42ab02f6e0ae76959757dcb6aa6feac1d4ba6f077f1223fb4b1b429f06c9181900360600190a15b8454608060020a90046001604060020a031660009081526003860160205260409020600281015490945062010000900460ff161515611c5657600080fd5b60028401546301000000900460ff161515611c7057600080fd5b85611c9b57600185810154611c96916001604060020a039091169063ffffffff61375816565b611cae565b845460c060020a90046001604060020a03165b6001604060020a0316925084600401600084815260200190815260200160002091508460000160109054906101000a90046001604060020a03168260000160006101000a8154816001604060020a0302191690836001604060020a03160217905550898260010181600019169055508882600201816000191690555087826003018160001916905550428260000160106101000a8154816001604060020a0302191690836001604060020a0316021790555060018260040160006101000a81548160ff02191690831515021790555060018260040160016101000a81548160ff021916908315150217905550828560010160006101000a8154816001604060020a0302191690836001604060020a031602179055506000809054906101000a900460ff161515611e365760018501546001604060020a03908116600090815260048701602052604090205460098054611e36939192604060020a9004909116908110611e1657fe5b6000918252602082208c926002909202019060079063ffffffff61377d16565b600354855460408051928352608060020a9091046001604060020a0316602083015281810185905260016060830181905260808301525160008051602061508a8339815191529160a0908290030190a1835460c060020a90046001604060020a0316831415611ea757611ea76138ac565b5060019a9950505050505050505050565b60046020526000908152604090205481565b6000611ed4613184565b1515611edf57600080fd5b5060015b90565b60005460ff1681565b6702c68af0bb14000081565b620186a081565b6000611f0c613938565b905090565b60008060008060008060008060019054906101000a9004600160a060020a0316600160a060020a031633600160a060020a0316141515611f5057600080fd5b67016345785d8a000034811115611f6657600080fd5b611f6e613184565b506003548c14611f7d57600080fd5b60008c815260056020526040902096508b1580611fcb57506000198c016000908152600560205260409020546001604060020a031615801590611fcb57506002870154608060020a900460ff165b1561218657611fe7878c8c8c600160008063ffffffff61330e16565b600054919750955060ff1615156120565760018701546001604060020a03908116600090815260048901602052604090205460088054612056939192604060020a900490911690811061203657fe5b6000918252602082208d926002909202019060069063ffffffff61377d16565b600085815260048801602052604090205460088054604060020a9092046001604060020a03169550908590811061208957fe5b906000526020600020906002020160000160019054906101000a90046001604060020a031687600301600088815260200190815260200160002060010160088282829054906101000a90046001604060020a03160192506101000a8154816001604060020a0302191690836001604060020a0316021790555060008051602061508a8339815191528c8787600160006040518086815260200185815260200184815260200183151515158152602001821515151581526020019550505050505060405180910390a1600086815260038801602052604090205460c060020a90046001604060020a0316851415612181576121816136c6565b61241d565b61219d878c8c8c600160008163ffffffff61330e16565b6000198e01600090815260056020908152604080832084845260048d8101845282852060028f018054825477ffffffffffffffffffffffffffffffffffffffffffffffff16604060020a918290046001604060020a0390811660c060020a0291909117808555925482900481168952938501909652938620546fffffffffffffffff0000000000000000199094169385900490911690930291909117825591549399509197509450925060ff1615156122925781546008805461229292604060020a90046001604060020a031690811061227357fe5b600091825260209091208c91600202016006600163ffffffff61377d16565b604080518d8152602081018890528082018790526001606082015260006080820152905160008051602061508a8339815191529181900360a00190a16122e08784600863ffffffff61393e16565b15612418578487600301600088815260200190815260200160002060000160186101000a8154816001604060020a0302191690836001604060020a031602179055507f030c1c69405c93021f28f57557240dee939a320b826a1fd0d39bf6e629ecab478c878960030160008a815260200190815260200160002060000160109054906101000a90046001604060020a0316888b60030160008c815260200190815260200160002060000160009054906101000a90046001604060020a031660008060016000604051808a8152602001898152602001886001604060020a03168152602001878152602001866001604060020a03168152602001858152602001841515151581526020018315151515815260200182151515158152602001995050505050505050505060405180910390a1612418613b8f565b600197505b50505050505050949350505050565b60025481565b600381565b6000806702c68af0bb1400003481111561245057600080fd5b6124666007600960008960008a8a600180612963565b60408051828152336020820152600160a060020a038916818301526000606082018190526080820189905260a0820188905260c0820152600160e0820181905261010082015290519193507f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e391908190036101200190a150600195945050505050565b60068054829081106124f757fe5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001604060020a0385169650604060020a850460ff9081169669010000000000000000008704821696605060020a8104831696605860020a8204909316956c010000000000000000000000009091046001608060020a031694600160a060020a039384169493909116929091908b565b60065490565b60098054829081106125a757fe5b60009182526020909120600290910201805460019091015460ff821692506001604060020a0361010083048116926901000000000000000000810482169271010000000000000000000000000000000000909104821691811690600160a060020a03604060020a9091041686565b610e1081565b600080546101009004600160a060020a0316331461263857600080fd5b61264a83600160a060020a0316613c1b565b151561265557600080fd5b600160a060020a038381166000908152600f6020526040902054161561267a57600080fd5b50600160a060020a038281166000908152600f60205260409020805473ffffffffffffffffffffffffffffffffffffffff191691831691909117905560015b92915050565b600354141590565b606060006006838154811015156126da57fe5b600091825260208083206006929092029091016002810154600160a060020a03908116808552600f845260408086205481516101608101835285546001604060020a0381168252604060020a810460ff908116151598830198909852690100000000000000000081048816151593820193909352605060020a8304871615156060820152605860020a8304909616151560808701526c010000000000000000000000009091046001608060020a031660a08601526001840154831660c086015260e08501919091526003830154610100850152600483015461012085015260058301546101408501529194506127ee936127e993889391926127dc9216613c23565b919063ffffffff613cb416565b613d0c565b91505b50919050565b600090815260056020526040902060010154604060020a90046001604060020a031690565b600f60205260009081526040902054600160a060020a031681565b600081565b67016345785d8a00003481111561285257600080fd5b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f70726570617265546f5375626d697455524228290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af49250505015156128de57600080fd5b50565b600154600160a060020a031681565b60085490565b60088054829081106125a757fe5b6000811561291f57600780548490811061291a57fe5b506000525b600680548490811061292d57fe5b6000918252602090912060069091020154605060020a900460ff169392505050565b60078054829081106124f757fe5b600c5481565b6000806000808a8061298e5750600160a060020a038a81166000908152600f60205260409020541615155b151561299957600080fd5b8a156129c15788158015906129ac575087155b80156129b6575086155b15156129c157600080fd5b8c546129d08e60018301614e54565b93508c848154811015156129e057fe5b90600052602060002090600602019250338360010160006101000a815481600160a060020a030219169083600160a060020a031602179055508883600001600c6101000a8154816001608060020a0302191690836001608060020a03160217905550898360020160006101000a815481600160a060020a030219169083600160a060020a031602179055508783600301816000191690555086836004018160001916905550428360000160006101000a8154816001604060020a0302191690836001604060020a03160217905550858360000160086101000a81548160ff0219169083151502179055508a8360000160096101000a81548160ff02191690831515021790555085158015612af257508a155b15612bd157604080516101608101825284546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001840154600160a060020a0390811660c083015260028501541660e0820152600384015461010082015260048401546101208201526005840154610140820152612bc69085613059565b1515612bd157600080fd5b8b541515612bf2578b54612be88d60018301614e85565b5060009150612bfb565b8b546000190191505b8b82815481101515612c0957fe5b90600052602060002090600202019050851515612c4b5780546001604060020a0361010080830482166001019091160268ffffffffffffffff00199091161781555b805460ff1680612c8e5750612c5e613938565b81546001808401546001604060020a03710100000000000000000000000000000000009093048316908316030116145b15612d00578b548c90612ca48260018301614e85565b81548110612cae57fe5b60009182526020909120600290910201805478ffffffffffffffff00000000000000000000000000000000001916710100000000000000000000000000000000006001604060020a0387160217815590505b612d09816128de565b60018101805467ffffffffffffffff19166001604060020a0386161790558a15612e1657604080516101608101825284546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001840154600160a060020a0390811660c083015260028501541660e0820152600384015461010082015260048401546101208201526005840154610140820152612e11908490612e02908d613c23565b8391908763ffffffff613ec216565b612f02565b600160a060020a038a81166000908152600f60209081526040918290205482516101608101845287546001604060020a0381168252604060020a810460ff908116151594830194909452690100000000000000000081048416151594820194909452605060020a8404831615156060820152605860020a8404909216151560808301526c010000000000000000000000009092046001608060020a031660a08201526001860154831660c08201526002860154831660e0820152600386015461010082015260048601546101208201526005860154610140820152612f02928692612e02929116613c23565b5050509998505050505050505050565b845460018601546001604060020a03710100000000000000000000000000000000009092048216850191600091829116831115612f4e57600080fd5b8683815481101515612f5c57fe5b600091825260209091206006909102018054909250605860020a900460ff1615612f8557600080fd5b8154605060020a900460ff1615612f9b57600080fd5b846040518082805190602001908083835b60208310612fcb5780518252601f199092019160209182019101612fac565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020905061300385613ee4565b1561300d57600080fd5b60005460ff1615156130345761302981878b6003015487613f25565b151561303457600080fd5b81546bff00000000000000000000001916605860020a17825550509695505050505050565b60008260400151156130b9578260e00151600160a060020a03166108fc8460a001516001608060020a03169081150290604051600060405180830381858888f193505050501580156130af573d6000803e3d6000fd5b50600190506126b9565b60e083015160208085015160c0860151610100870151610120880151604080517fd9afd3a9000000000000000000000000000000000000000000000000000000008152941515600486015260248501899052600160a060020a039384166044860152606485019290925260848401525193169263d9afd3a99260a4808401939192918290030181600087803b15801561315157600080fd5b505af1158015613165573d6000803e3d6000fd5b505050506040513d602081101561317b57600080fd5b50519392505050565b60035460009081526005602052604081205481908190819081906001604060020a0316156131b55760009450613307565b600354600090815260056020526040902080546001808301549296506131fb926001604060020a0360c060020a909304831692604060020a90910481169091011661409e565b60018501549093506001604060020a031683111561321c5760009450613307565b600083815260048581016020526040909120908101549092506301000000900460ff161561324d5760009450613307565b600482015460ff1615613297578154426001604060020a03608060020a9092049190911660010111156132835760009450613307565b61328e8483856140b5565b60019450613307565b5080546001604060020a03908116600101166132b3848261413c565b156132ce57815461328e9085906001604060020a031661427d565b8154426001604060020a03608060020a9092049190911660030111156132f75760009450613307565b6133028483856140b5565b600194505b5050505090565b86546001808901546001604060020a03608060020a909304831692600092839283926133429291169063ffffffff6143ea16565b600085815260038d01602052604090208054919450925060016001604060020a0360c060020a909204821601168314156133c2578a546001604060020a03600195909501948516608060020a0277ffffffffffffffff0000000000000000000000000000000019909116178b55600084815260038c016020526040902091505b8154608060020a90046001604060020a03168310156133e057600080fd5b84806133fd5750815460c060020a90046001604060020a03168311155b151561340857600080fd5b600282015460ff620100009091041615158715151461342657600080fd5b600282015460ff63010000009091041615158615151461344557600080fd5b5050600081815260048a81016020526040909120805460018083019b909b556002820199909955600381019790975567ffffffffffffffff199788166001604060020a038481169190911777ffffffffffffffff000000000000000000000000000000001916608060020a428316021788559601805460ff19169515159590951761ff0019166101009415159490940293909317909355509390940180549092169083161790559091565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744f5242282900000000000000000000008152506015019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561357c57600080fd5b565b60028201546001604060020a03604060020a909104811660008181526004840160209081526040808320548516808452600387019092528220549193909160c060020a90041682106135f5576002016000818152600385016020526040902054608060020a90046001604060020a031691506135fc565b6001820191505b6000818152600385016020526040902060020154610100900460ff161515613642576002850180546fffffffffffffffff000000000000000019169055600192506136be565b6000828152600485016020526040902054608060020a90046001604060020a0316151561368d576002850180546fffffffffffffffff000000000000000019169055600192506136be565b6002850180546fffffffffffffffff00000000000000001916604060020a6001604060020a03851602179055600092505b505092915050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744e5242282900000000000000000000008152506015019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561357c57600080fd5b610e1090565b60008282016001604060020a03808516908216101561377657600080fd5b9392505050565b825460018401546001604060020a037101000000000000000000000000000000000090920482169116600060608180866137bc578585036001016137cd565b885461010090046001604060020a03165b9350600084116137dc57600080fd5b83604051908082528060200260200182016040528015613806578160200160208202803883390190505b5092508591508590505b8481116138985786158061384a5750878181548110151561382d57fe5b6000918252602090912060069091020154604060020a900460ff16155b1561389057878181548110151561385d57fe5b9060005260206000209060060201600501548387840381518110151561387f57fe5b602090810290910101526001909101905b600101613810565b896138a2846143fc565b1461178a57600080fd5b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f707265706172654f5245416674657255524528290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561357c57600080fd5b6103e890565b60028301546001604060020a03604060020a90910481166000818152600485016020526040812054909216825b6000828152600387016020526040902060020154610100900460ff1615613b8057600082815260038701602052604090205460c060020a90046001604060020a031683106139de576002919091016000818152600387016020526040902054608060020a90046001604060020a03169250905b5b6000828152600387016020526040902060010154604060020a90046001604060020a0316158015613a2857506000828152600387016020526040902060020154610100900460ff165b15613a5c576002919091016000818152600387016020526040902054608060020a90046001604060020a03169250906139df565b6000828152600387016020526040902060020154610100900460ff161515613a875760019350613b85565b50600081815260038601602052604090205460c060020a90046001604060020a03165b808311613b1457600083815260048701602052604081205486548791604060020a90046001604060020a0316908110613adf57fe5b600091825260209091206002909102015461010090046001604060020a03161115613b0957613b14565b600183019250613aaa565b80831115613b4b576002919091016000818152600387016020526040902054608060020a90046001604060020a031692509061396b565b6002870180546fffffffffffffffff00000000000000001916604060020a6001604060020a0386160217905560009350613b85565b600193505b5050509392505050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f707265706172654e5245416674657255524528290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561357c57600080fd5b6000903b1190565b613c2b614eb1565b6020808401511515908201526040808401511580159183019190915260c080850151600160a060020a03169083015260a0808501516001608060020a03169083015261010080850151908301526101208085015190830152613c9f5760e080840151600160a060020a0316908201526126b9565b600160a060020a03821660e082015292915050565b613cbc614f0d565b633b9aca006020820152620186a0604082015260e0840151600160a060020a0316606082015260a08401516001608060020a03166080820152613d00848484614649565b60a08201529392505050565b6040805160098082526101408201909252606091829190816020015b6060815260200190600190039081613d285750508351909150613d53906001604060020a0316614746565b816000815181101515613d6257fe5b90602001906020020181905250613d7c8360200151614746565b816001815181101515613d8b57fe5b602090810290910101526040830151613dac906001604060020a0316614746565b816002815181101515613dbb57fe5b602090810290910101526060830151613ddc90600160a060020a0316614759565b816003815181101515613deb57fe5b602090810290910101526080830151613e0390614746565b816004815181101515613e1257fe5b6020908102909101015260a0830151613e2a90614789565b816005815181101515613e3957fe5b6020908102909101015260c0830151613e5190614746565b816006815181101515613e6057fe5b6020908102909101015260e0830151613e7890614746565b816007815181101515613e8757fe5b60209081029091010152610100830151613ea090614746565b816008815181101515613eaf57fe5b602090810290910101526127ee8161480c565b613ed6613ed183836000613cb4565b614866565b600590930192909255505050565b60006060613f026004613ef6856148d8565b9063ffffffff6148fb16565b90506127ee816000815181101515613f1657fe5b90602001906020020151614981565b600080600080600060208651811515613f3a57fe5b0615613f4557600080fd5b855160209004935060108410613f5a57600080fd5b5087905060205b60208402811161408f5785810151925060028806151561400057604080516020808201859052818301869052825180830384018152606090920192839052815191929182918401908083835b60208310613fcc5780518252601f199092019160209182019101613fad565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209150614081565b604080516020808201869052818301859052825180830384018152606090920192839052815191929182918401908083835b602083106140515780518252601f199092019160209182019101614032565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902091505b600288049750602001613f61565b50949094149695505050505050565b6000818310156140ae5781613776565b5090919050565b60048201805464ff0000000019166401000000001790556001830180546001604060020a038316604060020a026fffffffffffffffff000000000000000019909116179055600354604080519182526020820183905280517ffb96205e4b3633fd57aa805b26b51ecf528714a10241a4af015929dce86768d99281900390910190a1505050565b815460009081908190608060020a90046001604060020a031684111561416557600092506136be565b60008481526003860160205260409020600281015490925062010000900460ff16151561419557600092506136be565b600282015460ff16156141cf574260018360010160189054906101000a90046001604060020a03166001604060020a0316011192506136be565b600185015482546001604060020a03918216608060020a90910490911611156141fb57600092506136be565b508054608060020a90046001604060020a031660009081526004858101602052604090912090810154640100000000900460ff161561423d57600192506136be565b60048101546301000000900460ff161561425a57600092506136be565b54426001608060020a9092046001604060020a0316919091011115949350505050565b600081815260038301602052604081206002810154909190819062010000900460ff16156142aa57600080fd5b8254608060020a90046001604060020a031691505b825460c060020a90046001604060020a0316821161433a5750600081815260048581016020526040909120908101546301000000900460ff168061430d5750600481015462010000900460ff165b156143175761433a565b60048101805464ff000000001916640100000000179055600191909101906142bf565b8254600019909201916001604060020a03608060020a9091041682106143e3576001850180546001604060020a03808516604060020a026fffffffffffffffff0000000000000000199092169190911790915560035484546040805192835260208301889052608060020a909104909216818301526060810184905290517f70801d4d63b3da6c19ba7349911f45bed5a99ccdfb51b8138c105872529bebd59181900360800190a15b5050505050565b60008282018381101561377657600080fd5b60006060600083516001141561442c5783600081518110151561441b57fe5b906020019060200201519250614642565b83516002906001010460405190808252806020026020018201604052801561445e578160200160208202803883390190505b5091505b835181600101101561454c57838181518110151561447c57fe5b90602001906020020151848260010181518110151561449757fe5b6020908102909101810151604080518084019490945283810191909152805180840382018152606090930190819052825190918291908401908083835b602083106144f35780518252601f1990920191602091820191016144d4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208260028381151561452d57fe5b0481518110151561453a57fe5b60209081029091010152600201614462565b835160029006600114156146365783518490600019810190811061456c57fe5b9060200190602002015184600186510381518110151561458857fe5b6020908102909101810151604080518084019490945283810191909152805180840382018152606090930190819052825190918291908401908083835b602083106145e45780518252601f1990920191602091820191016145c5565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208260028381151561461e57fe5b0481518110151561462b57fe5b602090810290910101525b61463f826143fc565b92505b5050919050565b6060600084604001511561465c5761473e565b82614687577fe904e3d9000000000000000000000000000000000000000000000000000000006146a9565b7fd9afd3a9000000000000000000000000000000000000000000000000000000005b90508085602001516146bc5760006146bf565b60015b60c0870151610100880151610120890151604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19909616602087015260ff94909416602486015260448501899052600160a060020a039092166064850152608484015260a4808401919091528151808403909101815260c4909201905291505b509392505050565b60606126b9614754836149a5565b614789565b604080517414000000000000000000000000000000000000000083186014820152603481019091526060906127ee815b6060815160011480156147e8575081517f7f0000000000000000000000000000000000000000000000000000000000000090839060009081106147c857fe5b90602001015160f860020a900460f860020a02600160f860020a03191611155b156147f4575080610a05565b6126b96148068351608060ff16614ad6565b83614bfe565b604080516000808252602082019092526060915b83518110156148545761484a82858381518110151561483b57fe5b90602001906020020151614bfe565b9150600101614820565b61463f614806835160c060ff16614ad6565b6000606061487383613d0c565b9050806040518082805190602001908083835b602083106148a55780518252601f199092019160209182019101614886565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209695505050505050565b6148e0614f75565b50805160408051808201909152602092830181529182015290565b6060614905614f8c565b60008360405190808252806020026020018201604052801561494157816020015b61492e614f75565b8152602001906001900390816149265790505b50925061494d85614d08565b91505b838110156136be5761496182614d2d565b838281518110151561496f57fe5b60209081029091010152600101614950565b600080600061498f84614d5f565b90516020919091036101000a9004949350505050565b60408051602080825281830190925260609160009183918291849180820161040080388339019050509250856020840152600093505b6020841015614a395782848151811015156149f257fe5b60209101015160f860020a90819004027fff000000000000000000000000000000000000000000000000000000000000001615614a2e57614a39565b6001909301926149db565b836020036040519080825280601f01601f191660200182016040528015614a6a578160200160208202803883390190505b509150600090505b8151811015614acd578251600185019484918110614a8c57fe5b90602001015160f860020a900460f860020a028282815181101515614aad57fe5b906020010190600160f860020a031916908160001a905350600101614a72565b50949350505050565b60608080604060020a8510614b4c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f696e70757420746f6f206c6f6e67000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001808252818301909252906020808301908038833901905050915060378511614bac5783850160f860020a02826000815181101515614b8c57fe5b906020010190600160f860020a031916908160001a9053508192506136be565b614bb5856149a5565b90508381510160370160f860020a02826000815181101515614bd357fe5b906020010190600160f860020a031916908160001a905350614bf58282614bfe565b95945050505050565b60608060008084518651016040519080825280601f01601f191660200182016040528015614c36578160200160208202803883390190505b50925060009150600090505b8551811015614c9e578581815181101515614c5957fe5b90602001015160f860020a900460f860020a028383815181101515614c7a57fe5b906020010190600160f860020a031916908160001a90535060019182019101614c42565b5060005b8451811015614cfe578481815181101515614cb957fe5b90602001015160f860020a900460f860020a028383815181101515614cda57fe5b906020010190600160f860020a031916908160001a90535060019182019101614ca2565b5090949350505050565b614d10614f8c565b6000614d1b83614dc2565b83519383529092016020820152919050565b614d35614f75565b60208201516000614d4582614e28565b828452602080850182905292019390910192909252919050565b805180516000918291821a90826080831015614d815781945060019350614dba565b60b8831015614d9f5760018660200151039350816001019450614dba565b60b78303905080600187602001510303935080820160010194505b505050915091565b8051805160009190821a906080821015614ddf5760009250614642565b60b8821080614dfa575060c08210158015614dfa575060f882105b15614e085760019250614642565b60c0821015614e1d5760b51982019250614642565b5060f5190192915050565b8051600090811a6080811015614e4157600191506127f1565b60b88110156127f157607e190192915050565b815481835581811115614e8057600602816006028360005260206000209182019101614e809190614fad565b505050565b815481835581811115614e8057600202816002028360005260206000209182019101614e80919061502c565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915290565b6101206040519081016040528060006001604060020a031681526020016000815260200160006001604060020a031681526020016000600160a060020a0316815260200160008152602001606081526020016000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b606060405190810160405280614fa0614f75565b8152602001600081525090565b611ee391905b808211156150285780547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815560018101805473ffffffffffffffffffffffffffffffffffffffff199081169091556002820180549091169055600060038201819055600482018190556005820155600601614fb3565b5090565b611ee391905b8082111561502857805478ffffffffffffffffffffffffffffffffffffffffffffffffff191681556001810180547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916905560020161503256003d4a04291c66b06f39a4ecb817875b12b5485a05ec563133a56a905305c48e55a165627a7a72305820c10bced43a152f65371a42ce0787f4c472a5e1f2ec771b97dfcdc773c1a5ebb30029` +const RootChainBin = `0x60806040523480156200001157600080fd5b5060405160c0806200562c83398101604090815281516020830151918301516060840151608085015160a09095015192949192909190600080600160a060020a03881615156200006057600080fd5b62000082600160a060020a03891664010000000062003df96200018d82021704565b15156200008e57600080fd5b505060018054600160a060020a031916600160a060020a0388161781556000805460ff19168715151761010060a860020a0319166101003381029190911782556002878155600380548452600560209081526040808620868052600480820184528288208087018d90558086018c90559081018a905593810190925285209586018054600160c060020a03167801000000000000000000000000000000000000000000000000426001604060020a03160217905594909101805461ff001916909217909155906200016c908390839064010000000062000195810204565b6200017f64010000000062000250810204565b505050505050505062000311565b6000903b1190565b60058201805464ff00000000191664010000000017905581546001604060020a03428116780100000000000000000000000000000000000000000000000002600160c060020a039092169190911783556001840180549183166801000000000000000002604060020a608060020a0319909216919091179055600354604080519182526020820183905280517ffb96205e4b3633fd57aa805b26b51ecf528714a10241a4af015929dce86768d99281900390910190a1505050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744e524228290000000000000000000000815250601501905060405180910390207c010000000000000000000000000000000000000000000000000000000090046040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381865af49250505015156200030f57600080fd5b565b61530b80620003216000396000f30060806040526004361061026e5763ffffffff60e060020a600035041663033cfbed811461027357806308c4fff01461029a57806311e4c914146102af578063164bc2ae146102c7578063183d2d1c146102dc578063192adc5b146102f15780631ec2042b146103065780631f261d591461031e578063236915661461033357806324839704146103485780632b25a38b14610376578063398bac63146104015780633cfb871e14610416578063404f7d66146104355780634a44bdb81461046f5780634ba3a12614610501578063570ca735146105875780635b884682146105b857806361d29e83146105d35780636299fb24146105e857806365d724bc146106285780636b13ab6f1461063d5780636f3e4b901461065157806372ecb9a81461066557806375395a581461067d5780637b929c27146106925780638155717d146106a75780638b5172d0146106bc5780638eb288ca146106d157806393521222146106e657806394be3aa514610273578063a820c067146106fb578063ab96da2d1461070f578063b17fa6e914610724578063b2ae9ba814610273578063b41e69dd14610739578063b443f3cc14610753578063b540adba146107df578063c0e86064146107f4578063c2bc88fa14610857578063cb5d742f1461086c578063ce8a2bc214610893578063d1723a96146108ab578063d636857e14610938578063d691acd814610273578063da0185f814610950578063de0ce17d14610971578063e6925d0814610986578063e7b88b801461098e578063ea0c73f6146109a3578063ea7f22a8146109b8578063f28a7afa146109d0578063f4f31de4146109ed578063fb788a2714610a05575b600080fd5b34801561027f57600080fd5b50610288610a1a565b60408051918252519081900360200190f35b3480156102a657600080fd5b50610288610a26565b3480156102bb57600080fd5b50610288600435610a2b565b3480156102d357600080fd5b50610288610a50565b3480156102e857600080fd5b50610288610a56565b3480156102fd57600080fd5b50610288610a5c565b34801561031257600080fd5b50610288600435610a68565b34801561032a57600080fd5b50610288610a86565b34801561033f57600080fd5b50610288610a8c565b610362600160a060020a0360043516602435604435610a92565b604080519115158252519081900360200190f35b34801561038257600080fd5b50610391600435602435610b51565b604080516001604060020a039c8d1681529a8c1660208c0152988b168a8a0152968a1660608a015294891660808901529290971660a0870152151560c086015294151560e08501529315156101008401529215156101208301529115156101408201529051908190036101600190f35b34801561040d57600080fd5b50610391610bdf565b6103626004351515600160a060020a0360243516604435606435610c78565b34801561044157600080fd5b5061046d6004803590602480359160443591606435808201929081013591608435908101910135610d6e565b005b34801561047b57600080fd5b5061048a600435602435610fca565b604080516001604060020a039d8e1681529b8d1660208d0152998c168b8b015297909a1660608a0152608089019590955260a088019390935260c0870191909152151560e0860152151561010085015215156101208401529215156101408301529115156101608201529051908190036101800190f35b34801561050d57600080fd5b5061051960043561105b565b604080516001604060020a039c8d1681529a8c1660208c0152988b168a8a0152968a1660608a0152948916608089015292881660a088015290871660c0870152861660e086015285166101008501529093166101208301529115156101408201529051908190036101600190f35b34801561059357600080fd5b5061059c6110cd565b60408051600160a060020a039092168252519081900360200190f35b3480156105c457600080fd5b506102886004356024356110e1565b3480156105df57600080fd5b50610362611115565b3480156105f457600080fd5b5061046d60048035906024803580820192908101359160443580820192908101359160643591608435918201910135611910565b34801561063457600080fd5b50610288611972565b610362600435602435604435606435611978565b610362600435602435604435606435611d10565b34801561067157600080fd5b506102886004356120a1565b34801561068957600080fd5b506103626120b3565b34801561069e57600080fd5b506103626120cf565b3480156106b357600080fd5b506102886120d8565b3480156106c857600080fd5b506102886120dd565b3480156106dd57600080fd5b506102886120e9565b3480156106f257600080fd5b506102886120f0565b6103626004356024356044356064356120ff565b34801561071b57600080fd5b50610288612616565b34801561073057600080fd5b5061028861261c565b610362600160a060020a0360043516602435604435612621565b34801561075f57600080fd5b5061076b6004356126d3565b604080516001604060020a03909c168c5299151560208c01529715158a8a015295151560608a015293151560808901526001608060020a0390921660a0880152600160a060020a0390811660c08801521660e086015261010085015261012084015261014083015251908190036101600190f35b3480156107eb57600080fd5b5061028861277d565b34801561080057600080fd5b5061080c600435612783565b6040805196151587526001604060020a0395861660208801529385168685015291841660608601529092166080840152600160a060020a0390911660a0830152519081900360c00190f35b34801561086357600080fd5b506102886127f1565b34801561087857600080fd5b50610362600160a060020a03600435811690602435166127f7565b34801561089f57600080fd5b50610362600435612895565b3480156108b757600080fd5b506108c360043561289d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156108fd5781810151838201526020016108e5565b50505050905090810190601f16801561092a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561094457600080fd5b506102886004356129cd565b34801561095c57600080fd5b5061059c600160a060020a03600435166129f2565b34801561097d57600080fd5b5061059c612a0d565b61046d612a12565b34801561099a57600080fd5b5061059c612ab7565b3480156109af57600080fd5b50610288612ac6565b3480156109c457600080fd5b5061080c600435612acc565b3480156109dc57600080fd5b506103626004356024351515612ada565b3480156109f957600080fd5b5061076b600435612b25565b348015610a1157600080fd5b50610288612b33565b67016345785d8a000081565b600f81565b600081815260056020526040902054608060020a90046001604060020a03165b919050565b600b5481565b60035481565b670c7d713b49da000081565b6000908152600560205260409020600101546001604060020a031690565b600e5481565b600a5481565b60008067016345785d8a000034811115610aab57600080fd5b831515610ab757600080fd5b610ace6006600860008960008a8a60016000612b39565b60408051828152336020820152600160a060020a038916818301526000606082018190526080820189905260a0820188905260c08201819052600160e083015261010082015290519193507f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e391908190036101200190a150600195945050505050565b6000918252600560209081526040808420928452600390920190529020805460018201546002909201546001604060020a0380831694604060020a808504831695608060020a860484169560c060020a900484169484821694929091049091169160ff8083169261010081048216926201000082048316926301000000830481169264010000000090041690565b60038054600090815260056020908152604080832080546001604060020a03608060020a9182900481168652919095019092529091208054600182015460029092015481841695604060020a808404861696840486169560c060020a90940484169480851694919004169160ff808216926101008304821692620100008104831692630100000082048116926401000000009092041690565b6000803481610c90600660088a8a868b8b8880612b39565b600a80546001019055600354600090815260056020908152604080832081518581529283019390935280519396509193507f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929081900390910190a160408051848152336020820152600160a060020a03891681830152606081018490526080810188905260a0810187905289151560c0820152600060e0820181905261010082015290517f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e3918190036101200190a1506001979650505050505050565b60008781526005602081815260408084208a855260048101909252832091820154909290819060ff161515610da257600080fd5b6005830154640100000000900460ff161515610dbd57600080fd5b506005820154610100900460ff168015610eab57825460098054610e7292869291604060020a9091046001604060020a0316908110610df857fe5b906000526020600020906002020160078c8c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437506130cc945050505050565b60405190925033906000906702c68af0bb1400009082818181858883f19350505050158015610ea5573d6000803e3d6000fd5b50610f81565b825460088054610f4c92869291604060020a9091046001604060020a0316908110610ed257fe5b906000526020600020906002020160068c8c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437506130cc945050505050565b604051909250339060009067016345785d8a00009082818181858883f19350505050158015610f7f573d6000803e3d6000fd5b505b60408051838152821515602082015281517fc8135db115644ed4ae193313c4c801235ef740d2a57a8d5e6fe26ab66635698a929181900390910190a15050505050505050505050565b6000918252600560208181526040808520938552600493840190915290922080546001820154600283015460038401549484015493909501546001604060020a0380841697604060020a850482169793821696608060020a909504909116949293929160ff808216926101008304821692620100008104831692630100000082048116926401000000009092041690565b6005602052600090815260409020805460018201546002909201546001604060020a0380831693604060020a808504831694608060020a80820485169560c060020a9283900486169585811695858104821695848204831695909104821693838316939182049092169160ff9104168b565b6000546101009004600160a060020a031681565b600082815260056020908152604080832084845260040190915290205460c060020a90046001604060020a03165b92915050565b600b5460009081526005602052604081206001810154600c548392839290918391829182918291829182916001604060020a03909116101561115657600080fd5b600c546000908152600488016020908152604080832080546001604060020a0390811680865260038d01909452919093208a54929c5092985091965016158015906111af57508654600c546001604060020a0390911611155b1561121757600b805460010190819055600090815260056020908152604080832080546001604060020a03604060020a8204811680875260038401865284872060c060020a909304909116600c81905586526004830190945291909320919b50919850965094505b600586015460ff1615156112b9575b600285015462010000900460ff1615806112445750600285015460ff165b1561128f576000898152600388016020526040902060020154610100900460ff16151561127057600080fd5b6001909801600081815260038801602052604090209098909450611226565b8454608060020a90046001604060020a0316600c8190556000908152600488016020526040902095505b600285015460ff16156112cb57600080fd5b600285015462010000900460ff1615156112e457600080fd5b600586015460ff1615156112f757600080fd5b6005860154640100000000900460ff16151561131257600080fd5b8554426001604060020a0360c060020a90920491909116600a011061133657600080fd5b6005860154610100900460ff161561162857600e54600754909850881061135c57600080fd5b600780548990811061136a57fe5b9060005260206000209060060201935060098660000160089054906101000a90046001604060020a03166001604060020a03168154811015156113a957fe5b600091825260209091206002909102018054909350608860020a90046001604060020a031688108015906113ea575060018301546001604060020a03168811155b15156113f557600080fd5b60018301546001604060020a031688141561145357865460006001604060020a0390911611801561143a57508654600c546000196001604060020a0392831601909116145b1561144957600b805460010190555b600c805460010190555b60018801600e558354604060020a900460ff16801561147b57508354605860020a900460ff16155b156115cc57604080516101608101825285546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001850154600160a060020a0390811660c083015260028601541660e082015260038501546101008201526004850154610120820152600585015461014082015261154f9089613243565b506001840154604051600160a060020a03909116906000906702c68af0bb1400009082818181858883f1935050505015801561158f573d6000803e3d6000fd5b50604080518981526001602082015281517f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929181900390910190a15b83546aff000000000000000000001916605060020a178455604080518981526001602082015281517f134017cf3262b18f892ee95dde3b0aec9a80cc70a7c96f09c64bd237aceb0473929181900390910190a160019950611904565b600d54600654909850881061163c57600080fd5b600680548990811061164a57fe5b9060005260206000209060060201915060088660000160089054906101000a90046001604060020a03166001604060020a031681548110151561168957fe5b600091825260209091206002909102018054909150608860020a90046001604060020a031688108015906116ca575060018101546001604060020a03168811155b15156116d557600080fd5b60018101546001604060020a031688141561173357865460006001604060020a0390911611801561171a57508654600c546000196001604060020a0392831601909116145b1561172957600b805460010190555b600c805460010190555b60018801600d558154604060020a900460ff16801561175b57508154605860020a900460ff16155b156118ac57604080516101608101825283546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001830154600160a060020a0390811660c083015260028401541660e082015260038301546101008201526004830154610120820152600583015461014082015261182f9089613243565b506001820154604051600160a060020a039091169060009067016345785d8a00009082818181858883f1935050505015801561186f573d6000803e3d6000fd5b50604080518981526000602082015281517f6940a01870e576ceb735867e13863646d517ce10e66c0133186a4ebdfe9388c2929181900390910190a15b81546aff000000000000000000001916605060020a178255604080518981526000602082015281517f134017cf3262b18f892ee95dde3b0aec9a80cc70a7c96f09c64bd237aceb0473929181900390910190a1600199505b50505050505050505090565b60035460009081526005602081815260408084208c8552600481019092529092209081015460ff161561194257600080fd5b8054426001604060020a03608060020a90920491909116600f011161196657600080fd5b50505050505050505050565b600d5481565b6000805481908190819081906101009004600160a060020a0316331461199d57600080fd5b67016345785d8a0000348111156119b357600080fd5b60005460ff1615156119c9576119c761336e565b505b6003548a146119d757600080fd5b60008a81526005602052604090209450891580611a2557506000198a016000908152600560205260409020546001604060020a031615801590611a2557506002850154608060020a900460ff165b15611ab857611a40858a8a8a6000808063ffffffff6134f716565b604080518d815260208101849052808201839052600060608201819052608082015290519296509094506000805160206152c0833981519152919081900360a00190a1600084815260038601602052604090205460c060020a90046001604060020a0316831415611ab357611ab36136dc565b611d03565b611acf858a8a8a600080600163ffffffff6134f716565b80945081955050508460020160089054906101000a90046001604060020a031685600401600085815260200190815260200160002060010160006101000a8154816001604060020a0302191690836001604060020a031602179055506005600060018c03815260200190815260200160002091508160040160008660020160089054906101000a90046001604060020a03166001604060020a0316815260200190815260200160002060030154600019168860001916141515611b9157600080fd5b604080518b815260208101869052808201859052600060608201819052608082015290516000805160206152c08339815191529181900360a00190a1611bdd858363ffffffff61376a16565b15611cfe578285600301600086815260200190815260200160002060000160186101000a8154816001604060020a0302191690836001604060020a0316021790555060018560020160106101000a81548160ff0219169083151502179055507f030c1c69405c93021f28f57557240dee939a320b826a1fd0d39bf6e629ecab478a8587600301600088815260200190815260200160002060000160109054906101000a90046001604060020a0316866000806000806000604051808a8152602001898152602001886001604060020a03168152602001878152602001868152602001858152602001841515151581526020018315151515815260200182151515158152602001995050505050505050505060405180910390a1611cfe6138b2565b600195505b5050505050949350505050565b60008080808080670c7d713b49da000034811115611d2d57600080fd5b8a6003546001011495508580611d4457508a600354145b1515611d4f57600080fd5b60008b815260056020526040902094508515611e015760038054600101905560008b8152600560205260409020945042611d8761393e565b6001870154608060020a90046001604060020a03160111611da757600080fd5b8454604080518d81526001604060020a03608060020a84048116602083015260c060020a90930490921682820152517f0647d42ab02f6e0ae76959757dcb6aa6feac1d4ba6f077f1223fb4b1b429f06c9181900360600190a15b8454608060020a90046001604060020a031660009081526003860160205260409020600281015490945062010000900460ff161515611e3f57600080fd5b60028401546301000000900460ff161515611e5957600080fd5b85611e8457600185810154611e7f916001604060020a039091169063ffffffff61394416565b611e97565b845460c060020a90046001604060020a03165b6001604060020a0316925084600401600084815260200190815260200160002091508460000160109054906101000a90046001604060020a03168260000160006101000a8154816001604060020a0302191690836001604060020a03160217905550898260020181600019169055508882600301816000191690555087826004018160001916905550428260000160106101000a8154816001604060020a0302191690836001604060020a0316021790555060018260050160006101000a81548160ff02191690831515021790555060018260050160016101000a81548160ff021916908315150217905550828560010160006101000a8154816001604060020a0302191690836001604060020a031602179055506000809054906101000a900460ff16151561201f5760018501546001604060020a0390811660009081526004870160205260409020546009805461201f939192604060020a9004909116908110611fff57fe5b6000918252602082208c926002909202019060079063ffffffff61396916565b600354855460408051928352608060020a9091046001604060020a031660208301528181018590526001606083018190526080830152516000805160206152c08339815191529160a0908290030190a1835460c060020a90046001604060020a031683141561209057612090613a8a565b5060019a9950505050505050505050565b60046020526000908152604090205481565b60006120bd61336e565b15156120c857600080fd5b5060015b90565b60005460ff1681565b600a81565b6702c68af0bb14000081565b620186a081565b60006120fa613b16565b905090565b60008060008060008060008060019054906101000a9004600160a060020a0316600160a060020a031633600160a060020a031614151561213e57600080fd5b67016345785d8a00003481111561215457600080fd5b60005460ff16151561216a5761216861336e565b505b6003548c1461217857600080fd5b60008c815260056020526040902096508b15806121c657506000198c016000908152600560205260409020546001604060020a0316158015906121c657506002870154608060020a900460ff165b15612381576121e2878c8c8c600160008063ffffffff6134f716565b600054919750955060ff1615156122515760018701546001604060020a03908116600090815260048901602052604090205460088054612251939192604060020a900490911690811061223157fe5b6000918252602082208d926002909202019060069063ffffffff61396916565b600085815260048801602052604090205460088054604060020a9092046001604060020a03169550908590811061228457fe5b906000526020600020906002020160000160019054906101000a90046001604060020a031687600301600088815260200190815260200160002060010160088282829054906101000a90046001604060020a03160192506101000a8154816001604060020a0302191690836001604060020a031602179055506000805160206152c08339815191528c8787600160006040518086815260200185815260200184815260200183151515158152602001821515151581526020019550505050505060405180910390a1600086815260038801602052604090205460c060020a90046001604060020a031685141561237c5761237c6138b2565b612607565b612398878c8c8c600160008163ffffffff6134f716565b6000198e0160009081526005602090815260408083208484526004808e01845282852060028f01805460018301805467ffffffffffffffff19166001604060020a03604060020a9384900481169190911790915591548190048216885292840190955292852054835490829004909416026fffffffffffffffff0000000000000000199093169290921781559154939950919750909450925060ff16151561247c5781546008805461247c92604060020a90046001604060020a031690811061245d57fe5b600091825260209091208c91600202016006600163ffffffff61396916565b604080518d815260208101889052808201879052600160608201526000608082015290516000805160206152c08339815191529181900360a00190a16124ca8784600863ffffffff613b1c16565b15612602578487600301600088815260200190815260200160002060000160186101000a8154816001604060020a0302191690836001604060020a031602179055507f030c1c69405c93021f28f57557240dee939a320b826a1fd0d39bf6e629ecab478c878960030160008a815260200190815260200160002060000160109054906101000a90046001604060020a0316888b60030160008c815260200190815260200160002060000160009054906101000a90046001604060020a031660008060016000604051808a8152602001898152602001886001604060020a03168152602001878152602001866001604060020a03168152602001858152602001841515151581526020018315151515815260200182151515158152602001995050505050505050505060405180910390a1612602613d6d565b600197505b50505050505050949350505050565b60025481565b601481565b6000806702c68af0bb1400003481111561263a57600080fd5b6126506007600960008960008a8a600180612b39565b60408051828152336020820152600160a060020a038916818301526000606082018190526080820189905260a0820188905260c0820152600160e0820181905261010082015290519193507f9d57b50c5371c1c3fc64a8947cec60dbae09432e1e5d9ef048317ad7240353e391908190036101200190a150600195945050505050565b60068054829081106126e157fe5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001604060020a0385169650604060020a850460ff9081169669010000000000000000008704821696605060020a8104831696605860020a8204909316956c010000000000000000000000009091046001608060020a031694600160a060020a039384169493909116929091908b565b60065490565b600980548290811061279157fe5b60009182526020909120600290910201805460019091015460ff821692506001604060020a03610100830481169269010000000000000000008104821692608860020a909104821691811690600160a060020a03604060020a9091041686565b610e1081565b600080546101009004600160a060020a0316331461281457600080fd5b61282683600160a060020a0316613df9565b151561283157600080fd5b600160a060020a038381166000908152600f6020526040902054161561285657600080fd5b50600160a060020a039182166000908152600f60205260409020805473ffffffffffffffffffffffffffffffffffffffff191691909216179055600190565b600354141590565b606060006006838154811015156128b057fe5b600091825260208083206006929092029091016002810154600160a060020a03908116808552600f845260408086205481516101608101835285546001604060020a0381168252604060020a810460ff908116151598830198909852690100000000000000000081048816151593820193909352605060020a8304871615156060820152605860020a8304909616151560808701526c010000000000000000000000009091046001608060020a031660a08601526001840154831660c086015260e08501919091526003830154610100850152600483015461012085015260058301546101408501529194506129c4936129bf93889391926129b29216613e01565b919063ffffffff613e9216565b613eea565b91505b50919050565b600090815260056020526040902060010154604060020a90046001604060020a031690565b600f60205260009081526040902054600160a060020a031681565b600081565b67016345785d8a000034811115612a2857600080fd5b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f70726570617265546f5375626d697455524228290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af4925050501515612ab457600080fd5b50565b600154600160a060020a031681565b60085490565b600880548290811061279157fe5b60008115612af5576007805484908110612af057fe5b506000525b6006805484908110612b0357fe5b6000918252602090912060069091020154605060020a900460ff169392505050565b60078054829081106126e157fe5b600c5481565b6000806000808a80612b645750600160a060020a038a81166000908152600f60205260409020541615155b1515612b6f57600080fd5b8a15612b97578815801590612b82575087155b8015612b8c575086155b1515612b9757600080fd5b8c54612ba68e6001830161508a565b93508c84815481101515612bb657fe5b90600052602060002090600602019250338360010160006101000a815481600160a060020a030219169083600160a060020a031602179055508883600001600c6101000a8154816001608060020a0302191690836001608060020a03160217905550898360020160006101000a815481600160a060020a030219169083600160a060020a031602179055508783600301816000191690555086836004018160001916905550428360000160006101000a8154816001604060020a0302191690836001604060020a03160217905550858360000160086101000a81548160ff0219169083151502179055508a8360000160096101000a81548160ff02191690831515021790555085158015612cc857508a155b15612da757604080516101608101825284546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001840154600160a060020a0390811660c083015260028501541660e0820152600384015461010082015260048401546101208201526005840154610140820152612d9c9085613243565b1515612da757600080fd5b8b541515612dc8578b54612dbe8d600183016150bb565b5060009150612dd1565b8b546000190191505b8b82815481101515612ddf57fe5b90600052602060002090600202019050851515612e215780546001604060020a0361010080830482166001019091160268ffffffffffffffff00199091161781555b805460ff1680612e565750612e34613b16565b81546001808401546001604060020a03608860020a9093048316908316030116145b15612eba578b548c90612e6c82600183016150bb565b81548110612e7657fe5b60009182526020909120600290910201805478ffffffffffffffff00000000000000000000000000000000001916608860020a6001604060020a0387160217815590505b612ec381612ab4565b60018101805467ffffffffffffffff19166001604060020a0386161790558a15612fd057604080516101608101825284546001604060020a0381168252604060020a810460ff90811615156020840152690100000000000000000082048116151593830193909352605060020a8104831615156060830152605860020a8104909216151560808201526c010000000000000000000000009091046001608060020a031660a08201526001840154600160a060020a0390811660c083015260028501541660e0820152600384015461010082015260048401546101208201526005840154610140820152612fcb908490612fbc908d613e01565b8391908763ffffffff6140a016565b6130bc565b600160a060020a038a81166000908152600f60209081526040918290205482516101608101845287546001604060020a0381168252604060020a810460ff908116151594830194909452690100000000000000000081048416151594820194909452605060020a8404831615156060820152605860020a8404909216151560808301526c010000000000000000000000009092046001608060020a031660a08201526001860154831660c08201526002860154831660e08201526003860154610100820152600486015461012082015260058601546101408201526130bc928692612fbc929116613e01565b5050509998505050505050505050565b845460018601546001604060020a03608860020a90920482168501916000918291168311156130fa57600080fd5b868381548110151561310857fe5b600091825260209091208a546006909202019250426001604060020a0360c060020a90920491909116600a011161313e57600080fd5b6005890154640100000000900460ff16151561315957600080fd5b8154605860020a900460ff161561316f57600080fd5b8154605060020a900460ff161561318557600080fd5b846040518082805190602001908083835b602083106131b55780518252601f199092019160209182019101613196565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902090506131ed856140c2565b156131f757600080fd5b60005460ff16151561321e5761321381878b6004015487614103565b151561321e57600080fd5b81546bff00000000000000000000001916605860020a17825550509695505050505050565b60008260400151156132a3578260e00151600160a060020a03166108fc8460a001516001608060020a03169081150290604051600060405180830381858888f19350505050158015613299573d6000803e3d6000fd5b506001905061110f565b60e083015160208085015160c0860151610100870151610120880151604080517fd9afd3a9000000000000000000000000000000000000000000000000000000008152941515600486015260248501899052600160a060020a039384166044860152606485019290925260848401525193169263d9afd3a99260a4808401939192918290030181600087803b15801561333b57600080fd5b505af115801561334f573d6000803e3d6000fd5b505050506040513d602081101561336557600080fd5b50519392505050565b60035460009081526005602052604081205481908190819081906001604060020a03161561339f57600094506134f0565b600354600090815260056020526040902080546001808301549296506133e5926001604060020a0360c060020a909304831692604060020a90910481169091011661427c565b60018501549093506001604060020a031683111561340657600094506134f0565b6000838152600485016020526040902060058101549092506301000000900460ff161561343657600094506134f0565b600582015460ff1615613480578154426001604060020a03608060020a90920491909116600f01111561346c57600094506134f0565b613477848385614293565b600194506134f0565b5080546001604060020a039081166001011661349c848261434b565b156134b75781546134779085906001604060020a0316614483565b8154426001604060020a03608060020a9092049190911660140111156134e057600094506134f0565b6134eb848385614293565b600194505b5050505090565b86546001808901546001604060020a03608060020a9093048316926000928392839261352b9291169063ffffffff61462016565b600085815260038d01602052604090208054919450925060016001604060020a0360c060020a909204821601168314156135ab578a546001604060020a03600195909501948516608060020a0277ffffffffffffffff0000000000000000000000000000000019909116178b55600084815260038c016020526040902091505b8154608060020a90046001604060020a03168310156135c957600080fd5b84806135e65750815460c060020a90046001604060020a03168311155b15156135f157600080fd5b600282015460ff620100009091041615158715151461360f57600080fd5b600282015460ff63010000009091041615158615151461362e57600080fd5b5060008281526004808c0160205260409091208054600282018c9055600382018b9055918101899055426001604060020a03908116608060020a0277ffffffffffffffff000000000000000000000000000000001982881667ffffffffffffffff1995861617161782556005820180548915156101000261ff00198c151560ff19909316929092179190911617905560018d0180549186169190931617909155505097509795505050505050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744f5242282900000000000000000000008152506015019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561376857600080fd5b565b60028201546001604060020a03604060020a909104811660008181526004840160209081526040808320548516808452600387019092528220549193909160c060020a90041682106137e1576002016000818152600385016020526040902054608060020a90046001604060020a031691506137e8565b6001820191505b6000818152600385016020526040902060020154610100900460ff16151561382e576002850180546fffffffffffffffff000000000000000019169055600192506138aa565b6000828152600485016020526040902054608060020a90046001604060020a03161515613879576002850180546fffffffffffffffff000000000000000019169055600192506138aa565b6002850180546fffffffffffffffff00000000000000001916604060020a6001604060020a03851602179055600092505b505092915050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f5f70726570617265546f5375626d69744e5242282900000000000000000000008152506015019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561376857600080fd5b610e1090565b60008282016001604060020a03808516908216101561396257600080fd5b9392505050565b825460018401546001604060020a03608860020a909204821691166000606081808661399a578585036001016139ab565b885461010090046001604060020a03165b9350600084116139ba57600080fd5b836040519080825280602002602001820160405280156139e4578160200160208202803883390190505b5092508591508590505b848111613a7657861580613a2857508781815481101515613a0b57fe5b6000918252602090912060069091020154604060020a900460ff16155b15613a6e578781815481101515613a3b57fe5b90600052602060002090600602016005015483878403815181101515613a5d57fe5b602090810290910101526001909101905b6001016139ee565b89613a8084614632565b1461196657600080fd5b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f707265706172654f5245416674657255524528290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561376857600080fd5b6103e890565b60028301546001604060020a03604060020a90910481166000818152600485016020526040812054909216825b6000828152600387016020526040902060020154610100900460ff1615613d5e57600082815260038701602052604090205460c060020a90046001604060020a03168310613bbc576002919091016000818152600387016020526040902054608060020a90046001604060020a03169250905b5b6000828152600387016020526040902060010154604060020a90046001604060020a0316158015613c0657506000828152600387016020526040902060020154610100900460ff165b15613c3a576002919091016000818152600387016020526040902054608060020a90046001604060020a0316925090613bbd565b6000828152600387016020526040902060020154610100900460ff161515613c655760019350613d63565b50600081815260038601602052604090205460c060020a90046001604060020a03165b808311613cf257600083815260048701602052604081205486548791604060020a90046001604060020a0316908110613cbd57fe5b600091825260209091206002909102015461010090046001604060020a03161115613ce757613cf2565b600183019250613c88565b80831115613d29576002919091016000818152600387016020526040902054608060020a90046001604060020a0316925090613b49565b6002870180546fffffffffffffffff00000000000000001916604060020a6001604060020a0386160217905560009350613d63565b600193505b5050509392505050565b600160009054906101000a9004600160a060020a0316600160a060020a031660405180807f707265706172654e5245416674657255524528290000000000000000000000008152506014019050604051809103902060e060020a90046040518163ffffffff1660e060020a028152600401600060405180830381865af492505050151561376857600080fd5b6000903b1190565b613e096150e7565b6020808401511515908201526040808401511580159183019190915260c080850151600160a060020a03169083015260a0808501516001608060020a03169083015261010080850151908301526101208085015190830152613e7d5760e080840151600160a060020a03169082015261110f565b600160a060020a03821660e082015292915050565b613e9a615143565b633b9aca006020820152620186a0604082015260e0840151600160a060020a0316606082015260a08401516001608060020a03166080820152613ede84848461487f565b60a08201529392505050565b6040805160098082526101408201909252606091829190816020015b6060815260200190600190039081613f065750508351909150613f31906001604060020a031661497c565b816000815181101515613f4057fe5b90602001906020020181905250613f5a836020015161497c565b816001815181101515613f6957fe5b602090810290910101526040830151613f8a906001604060020a031661497c565b816002815181101515613f9957fe5b602090810290910101526060830151613fba90600160a060020a031661498f565b816003815181101515613fc957fe5b602090810290910101526080830151613fe19061497c565b816004815181101515613ff057fe5b6020908102909101015260a0830151614008906149bf565b81600581518110151561401757fe5b6020908102909101015260c083015161402f9061497c565b81600681518110151561403e57fe5b6020908102909101015260e08301516140569061497c565b81600781518110151561406557fe5b6020908102909101015261010083015161407e9061497c565b81600881518110151561408d57fe5b602090810290910101526129c481614a42565b6140b46140af83836000613e92565b614a9c565b600590930192909255505050565b600060606140e060046140d485614b0e565b9063ffffffff614b3116565b90506129c48160008151811015156140f457fe5b90602001906020020151614bb7565b60008060008060006020865181151561411857fe5b061561412357600080fd5b85516020900493506010841061413857600080fd5b5087905060205b60208402811161426d578581015192506002880615156141de57604080516020808201859052818301869052825180830384018152606090920192839052815191929182918401908083835b602083106141aa5780518252601f19909201916020918201910161418b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020915061425f565b604080516020808201869052818301859052825180830384018152606090920192839052815191929182918401908083835b6020831061422f5780518252601f199092019160209182019101614210565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902091505b60028804975060200161413f565b50949094149695505050505050565b60008183101561428c5781613962565b5090919050565b60058201805464ff00000000191664010000000017905581546001604060020a0342811660c060020a0277ffffffffffffffffffffffffffffffffffffffffffffffff909216919091178355600184018054918316604060020a026fffffffffffffffff000000000000000019909216919091179055600354604080519182526020820183905280517ffb96205e4b3633fd57aa805b26b51ecf528714a10241a4af015929dce86768d99281900390910190a1505050565b815460009081908190608060020a90046001604060020a031684111561437457600092506138aa565b60008481526003860160205260409020600281015490925062010000900460ff1615156143a457600092506138aa565b600282015460ff16156143d6576001820154426001604060020a0360c060020a90920491909116600f011192506138aa565b600185015482546001604060020a03918216608060020a909104909116111561440257600092506138aa565b508054608060020a90046001604060020a0316600090815260048501602052604090206005810154640100000000900460ff161561444357600192506138aa565b60058101546301000000900460ff161561446057600092506138aa565b5442600f608060020a9092046001604060020a0316919091011115949350505050565b600081815260038301602052604081206002810154909190819062010000900460ff16156144b057600080fd5b8254608060020a90046001604060020a031691505b825460c060020a90046001604060020a0316821161457057506000818152600485016020526040902060058101546301000000900460ff16806145125750600581015462010000900460ff165b1561451c57614570565b60058101805464ff00000000191664010000000017905580546001604060020a03421660c060020a0277ffffffffffffffffffffffffffffffffffffffffffffffff909116178155600191909101906144c5565b8254600019909201916001604060020a03608060020a909104168210614619576001850180546001604060020a03808516604060020a026fffffffffffffffff0000000000000000199092169190911790915560035484546040805192835260208301889052608060020a909104909216818301526060810184905290517f70801d4d63b3da6c19ba7349911f45bed5a99ccdfb51b8138c105872529bebd59181900360800190a15b5050505050565b60008282018381101561396257600080fd5b6000606060008351600114156146625783600081518110151561465157fe5b906020019060200201519250614878565b835160029060010104604051908082528060200260200182016040528015614694578160200160208202803883390190505b5091505b83518160010110156147825783818151811015156146b257fe5b9060200190602002015184826001018151811015156146cd57fe5b6020908102909101810151604080518084019490945283810191909152805180840382018152606090930190819052825190918291908401908083835b602083106147295780518252601f19909201916020918201910161470a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208260028381151561476357fe5b0481518110151561477057fe5b60209081029091010152600201614698565b8351600290066001141561486c578351849060001981019081106147a257fe5b906020019060200201518460018651038151811015156147be57fe5b6020908102909101810151604080518084019490945283810191909152805180840382018152606090930190819052825190918291908401908083835b6020831061481a5780518252601f1990920191602091820191016147fb565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208260028381151561485457fe5b0481518110151561486157fe5b602090810290910101525b61487582614632565b92505b5050919050565b6060600084604001511561489257614974565b826148bd577fe904e3d9000000000000000000000000000000000000000000000000000000006148df565b7fd9afd3a9000000000000000000000000000000000000000000000000000000005b90508085602001516148f25760006148f5565b60015b60c0870151610100880151610120890151604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19909616602087015260ff94909416602486015260448501899052600160a060020a039092166064850152608484015260a4808401919091528151808403909101815260c4909201905291505b509392505050565b606061110f61498a83614bdb565b6149bf565b604080517414000000000000000000000000000000000000000083186014820152603481019091526060906129c4815b606081516001148015614a1e575081517f7f0000000000000000000000000000000000000000000000000000000000000090839060009081106149fe57fe5b90602001015160f860020a900460f860020a02600160f860020a03191611155b15614a2a575080610a4b565b61110f614a3c8351608060ff16614d0c565b83614e34565b604080516000808252602082019092526060915b8351811015614a8a57614a80828583815181101515614a7157fe5b90602001906020020151614e34565b9150600101614a56565b614875614a3c835160c060ff16614d0c565b60006060614aa983613eea565b9050806040518082805190602001908083835b60208310614adb5780518252601f199092019160209182019101614abc565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209695505050505050565b614b166151ab565b50805160408051808201909152602092830181529182015290565b6060614b3b6151c2565b600083604051908082528060200260200182016040528015614b7757816020015b614b646151ab565b815260200190600190039081614b5c5790505b509250614b8385614f3e565b91505b838110156138aa57614b9782614f63565b8382815181101515614ba557fe5b60209081029091010152600101614b86565b6000806000614bc584614f95565b90516020919091036101000a9004949350505050565b60408051602080825281830190925260609160009183918291849180820161040080388339019050509250856020840152600093505b6020841015614c6f578284815181101515614c2857fe5b60209101015160f860020a90819004027fff000000000000000000000000000000000000000000000000000000000000001615614c6457614c6f565b600190930192614c11565b836020036040519080825280601f01601f191660200182016040528015614ca0578160200160208202803883390190505b509150600090505b8151811015614d03578251600185019484918110614cc257fe5b90602001015160f860020a900460f860020a028282815181101515614ce357fe5b906020010190600160f860020a031916908160001a905350600101614ca8565b50949350505050565b60608080604060020a8510614d8257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f696e70757420746f6f206c6f6e67000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001808252818301909252906020808301908038833901905050915060378511614de25783850160f860020a02826000815181101515614dc257fe5b906020010190600160f860020a031916908160001a9053508192506138aa565b614deb85614bdb565b90508381510160370160f860020a02826000815181101515614e0957fe5b906020010190600160f860020a031916908160001a905350614e2b8282614e34565b95945050505050565b60608060008084518651016040519080825280601f01601f191660200182016040528015614e6c578160200160208202803883390190505b50925060009150600090505b8551811015614ed4578581815181101515614e8f57fe5b90602001015160f860020a900460f860020a028383815181101515614eb057fe5b906020010190600160f860020a031916908160001a90535060019182019101614e78565b5060005b8451811015614f34578481815181101515614eef57fe5b90602001015160f860020a900460f860020a028383815181101515614f1057fe5b906020010190600160f860020a031916908160001a90535060019182019101614ed8565b5090949350505050565b614f466151c2565b6000614f5183614ff8565b83519383529092016020820152919050565b614f6b6151ab565b60208201516000614f7b8261505e565b828452602080850182905292019390910192909252919050565b805180516000918291821a90826080831015614fb75781945060019350614ff0565b60b8831015614fd55760018660200151039350816001019450614ff0565b60b78303905080600187602001510303935080820160010194505b505050915091565b8051805160009190821a9060808210156150155760009250614878565b60b8821080615030575060c08210158015615030575060f882105b1561503e5760019250614878565b60c08210156150535760b51982019250614878565b5060f5190192915050565b8051600090811a608081101561507757600191506129c7565b60b88110156129c757607e190192915050565b8154818355818111156150b6576006028160060283600052602060002091820191016150b691906151e3565b505050565b8154818355818111156150b6576002028160020283600052602060002091820191016150b69190615262565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915290565b6101206040519081016040528060006001604060020a031681526020016000815260200160006001604060020a031681526020016000600160a060020a0316815260200160008152602001606081526020016000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b6060604051908101604052806151d66151ab565b8152602001600081525090565b6120cc91905b8082111561525e5780547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815560018101805473ffffffffffffffffffffffffffffffffffffffff1990811690915560028201805490911690556000600382018190556004820181905560058201556006016151e9565b5090565b6120cc91905b8082111561525e57805478ffffffffffffffffffffffffffffffffffffffffffffffffff191681556001810180547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916905560020161526856003d4a04291c66b06f39a4ecb817875b12b5485a05ec563133a56a905305c48e55a165627a7a72305820d840859e4ed5df6173c31607a7d88d0b3eefb1290151118110ff4f8bff5dfa990029` // DeployRootChain deploys a new Ethereum contract, binding an instance of RootChain to it. func DeployRootChain(auth *bind.TransactOpts, backend bind.ContractBackend, _epochHandler common.Address, _development bool, _NRELength *big.Int, _statesRoot [32]byte, _transactionsRoot [32]byte, _receiptsRoot [32]byte) (common.Address, *types.Transaction, *RootChain, error) { @@ -1657,6 +1657,32 @@ func (_RootChain *RootChainCallerSession) CPCOMPUTATION() (*big.Int, error) { return _RootChain.Contract.CPCOMPUTATION(&_RootChain.CallOpts) } +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChain *RootChainCaller) CPEXIT(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _RootChain.contract.Call(opts, out, "CP_EXIT") + return *ret0, err +} + +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChain *RootChainSession) CPEXIT() (*big.Int, error) { + return _RootChain.Contract.CPEXIT(&_RootChain.CallOpts) +} + +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChain *RootChainCallerSession) CPEXIT() (*big.Int, error) { + return _RootChain.Contract.CPEXIT(&_RootChain.CallOpts) +} + // CPWITHHOLDING is a free data retrieval call binding the contract method 0xb17fa6e9. // // Solidity: function CP_WITHHOLDING() constant returns(uint256) @@ -2339,6 +2365,32 @@ func (_RootChain *RootChainCallerSession) GetBlock(forkNumber *big.Int, blockNum return _RootChain.Contract.GetBlock(&_RootChain.CallOpts, forkNumber, blockNumber) } +// GetBlockFinalizedAt is a free data retrieval call binding the contract method 0x5b884682. +// +// Solidity: function getBlockFinalizedAt(forkNumber uint256, blockNumber uint256) constant returns(uint256) +func (_RootChain *RootChainCaller) GetBlockFinalizedAt(opts *bind.CallOpts, forkNumber *big.Int, blockNumber *big.Int) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _RootChain.contract.Call(opts, out, "getBlockFinalizedAt", forkNumber, blockNumber) + return *ret0, err +} + +// GetBlockFinalizedAt is a free data retrieval call binding the contract method 0x5b884682. +// +// Solidity: function getBlockFinalizedAt(forkNumber uint256, blockNumber uint256) constant returns(uint256) +func (_RootChain *RootChainSession) GetBlockFinalizedAt(forkNumber *big.Int, blockNumber *big.Int) (*big.Int, error) { + return _RootChain.Contract.GetBlockFinalizedAt(&_RootChain.CallOpts, forkNumber, blockNumber) +} + +// GetBlockFinalizedAt is a free data retrieval call binding the contract method 0x5b884682. +// +// Solidity: function getBlockFinalizedAt(forkNumber uint256, blockNumber uint256) constant returns(uint256) +func (_RootChain *RootChainCallerSession) GetBlockFinalizedAt(forkNumber *big.Int, blockNumber *big.Int) (*big.Int, error) { + return _RootChain.Contract.GetBlockFinalizedAt(&_RootChain.CallOpts, forkNumber, blockNumber) +} + // GetEROBytes is a free data retrieval call binding the contract method 0xd1723a96. // // Solidity: function getEROBytes(_requestId uint256) constant returns(out bytes) @@ -4855,7 +4907,7 @@ func (_RootChain *RootChainFilterer) WatchSessionTimeout(opts *bind.WatchOpts, s const RootChainEventABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"SessionTimeout\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"newFork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"forkedBlockNumber\",\"type\":\"uint256\"}],\"name\":\"Forked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"rebase\",\"type\":\"bool\"}],\"name\":\"EpochPrepared\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilling\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFilled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestStart\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestEnd\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochIsEmpty\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"EpochRebased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"fork\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"isRequest\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"BlockSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"weiAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"isTransfer\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"isExit\",\"type\":\"bool\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"requestor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"trieValue\",\"type\":\"bytes32\"}],\"name\":\"ERUCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"BlockFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"forkNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"startBlockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"endBlockNumber\",\"type\":\"uint256\"}],\"name\":\"EpochFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"requestId\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"userActivated\",\"type\":\"bool\"}],\"name\":\"RequestChallenged\",\"type\":\"event\"}]" // RootChainEventBin is the compiled bytecode used for deploying new contracts. -const RootChainEventBin = `0x6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a72305820c785dc71652ad777820a42fb69b7a903356787b890d3a0076c6ea9e190b685530029` +const RootChainEventBin = `0x6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a7230582060103dd4d10c342964c8bcac3acbda0faeaa04d0a9fb8d56b5aa5290322531fa0029` // DeployRootChainEvent deploys a new Ethereum contract, binding an instance of RootChainEvent to it. func DeployRootChainEvent(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *RootChainEvent, error) { @@ -6765,10 +6817,10 @@ func (_RootChainEvent *RootChainEventFilterer) WatchSessionTimeout(opts *bind.Wa } // RootChainStorageABI is the input ABI used to generate the binding from. -const RootChainStorageABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB_PREPARE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_COMPUTATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedForkNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numEnterForORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"forks\",\"outputs\":[{\"name\":\"forkedBlock\",\"type\":\"uint64\"},{\"name\":\"firstEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEpoch\",\"type\":\"uint64\"},{\"name\":\"firstBlock\",\"type\":\"uint64\"},{\"name\":\"lastBlock\",\"type\":\"uint64\"},{\"name\":\"lastFinalizedBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"firstEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"nextBlockToRebase\",\"type\":\"uint64\"},{\"name\":\"rebased\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"operator\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"firstFilledORENumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"REQUEST_GAS\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_NRB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NRELength\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_WITHHOLDING\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"EROs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"URBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PREPARE_TIMEOUT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"requestableContracts\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NULL_ADDRESS\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"epochHandler\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ORBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ERUs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedBlockNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" +const RootChainStorageABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB_PREPARE\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_COMPUTATION\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedForkNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_URB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numEnterForORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"forks\",\"outputs\":[{\"name\":\"forkedBlock\",\"type\":\"uint64\"},{\"name\":\"firstEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEpoch\",\"type\":\"uint64\"},{\"name\":\"firstBlock\",\"type\":\"uint64\"},{\"name\":\"lastBlock\",\"type\":\"uint64\"},{\"name\":\"lastFinalizedBlock\",\"type\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"firstEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"lastEnterEpoch\",\"type\":\"uint64\"},{\"name\":\"nextBlockToRebase\",\"type\":\"uint64\"},{\"name\":\"rebased\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"operator\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"firstFilledORENumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"development\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_EXIT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERU\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"REQUEST_GAS\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_NRB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NRELength\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"CP_WITHHOLDING\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ORB\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"EROs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"URBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"PREPARE_TIMEOUT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"COST_ERO\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"requestableContracts\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NULL_ADDRESS\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"epochHandler\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ORBs\",\"outputs\":[{\"name\":\"submitted\",\"type\":\"bool\"},{\"name\":\"numEnter\",\"type\":\"uint64\"},{\"name\":\"epochNumber\",\"type\":\"uint64\"},{\"name\":\"requestStart\",\"type\":\"uint64\"},{\"name\":\"requestEnd\",\"type\":\"uint64\"},{\"name\":\"trie\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ERUs\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\"},{\"name\":\"isExit\",\"type\":\"bool\"},{\"name\":\"isTransfer\",\"type\":\"bool\"},{\"name\":\"finalized\",\"type\":\"bool\"},{\"name\":\"challenged\",\"type\":\"bool\"},{\"name\":\"value\",\"type\":\"uint128\"},{\"name\":\"requestor\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"trieKey\",\"type\":\"bytes32\"},{\"name\":\"trieValue\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastAppliedBlockNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" // RootChainStorageBin is the compiled bytecode used for deploying new contracts. -const RootChainStorageBin = `0x608060405234801561001057600080fd5b50610803806100206000396000f3006080604052600436106101695763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663033cfbed811461016e57806308c4fff014610195578063164bc2ae146101aa578063183d2d1c146101bf578063192adc5b146101d45780631f261d59146101e957806323691566146101fe5780634ba3a12614610213578063570ca7351461029a57806365d724bc146102cb57806372ecb9a8146102e05780637b929c27146102f85780638b5172d0146103215780638eb288ca1461033657806394be3aa51461016e578063ab96da2d1461034b578063b17fa6e914610360578063b2ae9ba81461016e578063b443f3cc14610375578063c0e860641461040b578063c2bc88fa1461046f578063d691acd81461016e578063da0185f814610484578063de0ce17d146104a5578063e7b88b80146104ba578063ea7f22a8146104cf578063f4f31de4146104e7578063fb788a27146104ff575b600080fd5b34801561017a57600080fd5b50610183610514565b60408051918252519081900360200190f35b3480156101a157600080fd5b50610183610520565b3480156101b657600080fd5b50610183610525565b3480156101cb57600080fd5b5061018361052b565b3480156101e057600080fd5b50610183610531565b3480156101f557600080fd5b5061018361053d565b34801561020a57600080fd5b50610183610543565b34801561021f57600080fd5b5061022b600435610549565b6040805167ffffffffffffffff9c8d1681529a8c1660208c0152988b168a8a0152968a1660608a0152948916608089015292881660a088015290871660c0870152861660e086015285166101008501529093166101208301529115156101408201529051908190036101600190f35b3480156102a657600080fd5b506102af6105e3565b60408051600160a060020a039092168252519081900360200190f35b3480156102d757600080fd5b506101836105f7565b3480156102ec57600080fd5b506101836004356105fd565b34801561030457600080fd5b5061030d61060f565b604080519115158252519081900360200190f35b34801561032d57600080fd5b50610183610618565b34801561034257600080fd5b50610183610624565b34801561035757600080fd5b5061018361062b565b34801561036c57600080fd5b50610183610631565b34801561038157600080fd5b5061038d600435610636565b6040805167ffffffffffffffff909c168c5299151560208c01529715158a8a015295151560608a015293151560808901526fffffffffffffffffffffffffffffffff90921660a0880152600160a060020a0390811660c08801521660e086015261010085015261012084015261014083015251908190036101600190f35b34801561041757600080fd5b506104236004356106fe565b60408051961515875267ffffffffffffffff95861660208801529385168685015291841660608601529092166080840152600160a060020a0390911660a0830152519081900360c00190f35b34801561047b57600080fd5b50610183610780565b34801561049057600080fd5b506102af600160a060020a0360043516610786565b3480156104b157600080fd5b506102af6107a1565b3480156104c657600080fd5b506102af6107a6565b3480156104db57600080fd5b506104236004356107b5565b3480156104f357600080fd5b5061038d6004356107c3565b34801561050b57600080fd5b506101836107d1565b67016345785d8a000081565b600181565b600b5481565b60035481565b670c7d713b49da000081565b600e5481565b600a5481565b60056020526000908152604090208054600182015460029092015467ffffffffffffffff808316936801000000000000000080850483169470010000000000000000000000000000000080820485169578010000000000000000000000000000000000000000000000009283900486169585811695858104821695848204831695909104821693838316939182049092169160ff9104168b565b6000546101009004600160a060020a031681565b600d5481565b60046020526000908152604090205481565b60005460ff1681565b6702c68af0bb14000081565b620186a081565b60025481565b600381565b600680548290811061064457fe5b600091825260209091206006909102018054600182015460028301546003840154600485015460059095015467ffffffffffffffff8516965068010000000000000000850460ff90811696690100000000000000000087048216966a010000000000000000000081048316966b0100000000000000000000008204909316956c010000000000000000000000009091046fffffffffffffffffffffffffffffffff1694600160a060020a039384169493909116929091908b565b600980548290811061070c57fe5b60009182526020909120600290910201805460019091015460ff8216925067ffffffffffffffff61010083048116926901000000000000000000810482169271010000000000000000000000000000000000909104821691811690600160a060020a03680100000000000000009091041686565b610e1081565b600f60205260009081526040902054600160a060020a031681565b600081565b600154600160a060020a031681565b600880548290811061070c57fe5b600780548290811061064457fe5b600c54815600a165627a7a7230582087f2547f36fc8a1fe4dbfa5c937dfb1cda519142940ca31ceb93fadd9fef11540029` +const RootChainStorageBin = `0x608060405234801561001057600080fd5b50610828806100206000396000f3006080604052600436106101745763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663033cfbed811461017957806308c4fff0146101a0578063164bc2ae146101b5578063183d2d1c146101ca578063192adc5b146101df5780631f261d59146101f457806323691566146102095780634ba3a1261461021e578063570ca735146102a557806365d724bc146102d657806372ecb9a8146102eb5780637b929c27146103035780638155717d1461032c5780638b5172d0146103415780638eb288ca1461035657806394be3aa514610179578063ab96da2d1461036b578063b17fa6e914610380578063b2ae9ba814610179578063b443f3cc14610395578063c0e860641461042b578063c2bc88fa1461048f578063d691acd814610179578063da0185f8146104a4578063de0ce17d146104c5578063e7b88b80146104da578063ea7f22a8146104ef578063f4f31de414610507578063fb788a271461051f575b600080fd5b34801561018557600080fd5b5061018e610534565b60408051918252519081900360200190f35b3480156101ac57600080fd5b5061018e610540565b3480156101c157600080fd5b5061018e610545565b3480156101d657600080fd5b5061018e61054b565b3480156101eb57600080fd5b5061018e610551565b34801561020057600080fd5b5061018e61055d565b34801561021557600080fd5b5061018e610563565b34801561022a57600080fd5b50610236600435610569565b6040805167ffffffffffffffff9c8d1681529a8c1660208c0152988b168a8a0152968a1660608a0152948916608089015292881660a088015290871660c0870152861660e086015285166101008501529093166101208301529115156101408201529051908190036101600190f35b3480156102b157600080fd5b506102ba610603565b60408051600160a060020a039092168252519081900360200190f35b3480156102e257600080fd5b5061018e610617565b3480156102f757600080fd5b5061018e60043561061d565b34801561030f57600080fd5b5061031861062f565b604080519115158252519081900360200190f35b34801561033857600080fd5b5061018e610638565b34801561034d57600080fd5b5061018e61063d565b34801561036257600080fd5b5061018e610649565b34801561037757600080fd5b5061018e610650565b34801561038c57600080fd5b5061018e610656565b3480156103a157600080fd5b506103ad60043561065b565b6040805167ffffffffffffffff909c168c5299151560208c01529715158a8a015295151560608a015293151560808901526fffffffffffffffffffffffffffffffff90921660a0880152600160a060020a0390811660c08801521660e086015261010085015261012084015261014083015251908190036101600190f35b34801561043757600080fd5b50610443600435610723565b60408051961515875267ffffffffffffffff95861660208801529385168685015291841660608601529092166080840152600160a060020a0390911660a0830152519081900360c00190f35b34801561049b57600080fd5b5061018e6107a5565b3480156104b057600080fd5b506102ba600160a060020a03600435166107ab565b3480156104d157600080fd5b506102ba6107c6565b3480156104e657600080fd5b506102ba6107cb565b3480156104fb57600080fd5b506104436004356107da565b34801561051357600080fd5b506103ad6004356107e8565b34801561052b57600080fd5b5061018e6107f6565b67016345785d8a000081565b600f81565b600b5481565b60035481565b670c7d713b49da000081565b600e5481565b600a5481565b60056020526000908152604090208054600182015460029092015467ffffffffffffffff808316936801000000000000000080850483169470010000000000000000000000000000000080820485169578010000000000000000000000000000000000000000000000009283900486169585811695858104821695848204831695909104821693838316939182049092169160ff9104168b565b6000546101009004600160a060020a031681565b600d5481565b60046020526000908152604090205481565b60005460ff1681565b600a81565b6702c68af0bb14000081565b620186a081565b60025481565b601481565b600680548290811061066957fe5b600091825260209091206006909102018054600182015460028301546003840154600485015460059095015467ffffffffffffffff8516965068010000000000000000850460ff90811696690100000000000000000087048216966a010000000000000000000081048316966b0100000000000000000000008204909316956c010000000000000000000000009091046fffffffffffffffffffffffffffffffff1694600160a060020a039384169493909116929091908b565b600980548290811061073157fe5b60009182526020909120600290910201805460019091015460ff8216925067ffffffffffffffff61010083048116926901000000000000000000810482169271010000000000000000000000000000000000909104821691811690600160a060020a03680100000000000000009091041686565b610e1081565b600f60205260009081526040902054600160a060020a031681565b600081565b600154600160a060020a031681565b600880548290811061073157fe5b600780548290811061066957fe5b600c54815600a165627a7a723058209a79890ea93f099cf56cd812c3b9dd674cff2667d5139cec725f3c7edf193f9b0029` // DeployRootChainStorage deploys a new Ethereum contract, binding an instance of RootChainStorage to it. func DeployRootChainStorage(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *RootChainStorage, error) { @@ -7107,6 +7159,32 @@ func (_RootChainStorage *RootChainStorageCallerSession) CPCOMPUTATION() (*big.In return _RootChainStorage.Contract.CPCOMPUTATION(&_RootChainStorage.CallOpts) } +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChainStorage *RootChainStorageCaller) CPEXIT(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _RootChainStorage.contract.Call(opts, out, "CP_EXIT") + return *ret0, err +} + +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChainStorage *RootChainStorageSession) CPEXIT() (*big.Int, error) { + return _RootChainStorage.Contract.CPEXIT(&_RootChainStorage.CallOpts) +} + +// CPEXIT is a free data retrieval call binding the contract method 0x8155717d. +// +// Solidity: function CP_EXIT() constant returns(uint256) +func (_RootChainStorage *RootChainStorageCallerSession) CPEXIT() (*big.Int, error) { + return _RootChainStorage.Contract.CPEXIT(&_RootChainStorage.CallOpts) +} + // CPWITHHOLDING is a free data retrieval call binding the contract method 0xb17fa6e9. // // Solidity: function CP_WITHHOLDING() constant returns(uint256) From e2a26ee762338fe551a7b974ee324e97856bc23d Mon Sep 17 00:00:00 2001 From: 4000D Date: Thu, 24 Jan 2019 18:24:26 +0900 Subject: [PATCH 25/26] pls: log elapsed time to process ORB --- pls/rootchain_manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pls/rootchain_manager.go b/pls/rootchain_manager.go index 2f98b9f72..e85a5e10e 100644 --- a/pls/rootchain_manager.go +++ b/pls/rootchain_manager.go @@ -381,6 +381,7 @@ func (rcm *RootChainManager) handleEpochPrepared(ev *rootchain.RootChainEpochPre log.Debug("Num Orbs", "epochNumber", e.EpochNumber, "numORBs", numORBs, "requestBlockId", requestBlockId, "e.EndBlockNumber", e.EndBlockNumber, "e.StartBlockNumber", e.StartBlockNumber) for blockNumber := e.StartBlockNumber; blockNumber.Cmp(e.EndBlockNumber) <= 0; { + begin := time.Now() orb, err := rcm.rootchainContract.ORBs(baseCallOpt, requestBlockId) if err != nil { @@ -436,11 +437,10 @@ func (rcm *RootChainManager) handleEpochPrepared(ev *rootchain.RootChainEpochPre } body = append(body, requestTx) - requestId += 1 } - log.Info("Request txs fetched", "blockNumber", blockNumber, "requestBlockId", requestBlockId, "body", body) + log.Info("Request txs fetched", "blockNumber", blockNumber, "requestBlockId", requestBlockId, "numRequests", len(body), "elapsed", time.Since(begin)) bodies = append(bodies, body) From 225477d801f22dc75cb9e379f9cbad1cc6f3ea80 Mon Sep 17 00:00:00 2001 From: 4000D Date: Thu, 24 Jan 2019 18:28:53 +0900 Subject: [PATCH 26/26] pls: update test - check blcok by each block number --- pls/rootchain_manager_test.go | 244 +++++++++++++++++++--------------- 1 file changed, 140 insertions(+), 104 deletions(-) diff --git a/pls/rootchain_manager_test.go b/pls/rootchain_manager_test.go index 3cb838799..7e48a31db 100644 --- a/pls/rootchain_manager_test.go +++ b/pls/rootchain_manager_test.go @@ -12,9 +12,6 @@ import ( "testing" "time" - "io/ioutil" - "os" - "github.com/Onther-Tech/plasma-evm/accounts" "github.com/Onther-Tech/plasma-evm/accounts/abi/bind" "github.com/Onther-Tech/plasma-evm/accounts/keystore" @@ -41,6 +38,8 @@ import ( "github.com/Onther-Tech/plasma-evm/plsclient" "github.com/Onther-Tech/plasma-evm/rpc" "github.com/mattn/go-colorable" + "io/ioutil" + "os" ) var ( @@ -102,7 +101,7 @@ var ( // rootchain contract NRELength = big.NewInt(2) - development = true + development = false // transaction defaultGasPrice = big.NewInt(1) // 1 Gwei @@ -185,14 +184,14 @@ func TestScenario1(t *testing.T) { blockInfo := ev.Data.(core.NewMinedBlockEvent) if rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should not be request block, but it is not. blockNumber:", blockInfo.Block.NumberU64()) + t.Fatal("Block should not be request block, but it is not. blockNumber:", blockInfo.Block.NumberU64()) } } ev := <-events.Chan() blockInfo := ev.Data.(core.NewMinedBlockEvent) if !rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should be request block", "blockNumber", blockInfo.Block.NumberU64()) } for i = 0; i < NRELength.Uint64()*2; { @@ -203,7 +202,7 @@ func TestScenario1(t *testing.T) { makeSampleTx(rcm) if rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should not be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should not be request block", "blockNumber", blockInfo.Block.NumberU64()) } } @@ -283,7 +282,7 @@ func TestScenario2(t *testing.T) { blockInfo := ev.Data.(core.NewMinedBlockEvent) if rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should not be request block, but it is not. blockNumber:", blockInfo.Block.NumberU64()) + t.Fatal("Block should not be request block, but it is not. blockNumber:", blockInfo.Block.NumberU64()) } } @@ -293,7 +292,7 @@ func TestScenario2(t *testing.T) { ev := <-events.Chan() blockInfo := ev.Data.(core.NewMinedBlockEvent) if !rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should be request block", "blockNumber", blockInfo.Block.NumberU64()) } // balance check in plasma chain after enter db, _ := rcm.blockchain.State() @@ -323,7 +322,7 @@ func TestScenario2(t *testing.T) { makeSampleTx(rcm) if rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should not be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should not be request block", "blockNumber", blockInfo.Block.NumberU64()) } } @@ -340,7 +339,7 @@ func TestScenario2(t *testing.T) { ev := <-events.Chan() blockInfo := ev.Data.(core.NewMinedBlockEvent) if !rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should be request block", "blockNumber", blockInfo.Block.NumberU64()) } db, _ := rcm.blockchain.State() @@ -359,7 +358,7 @@ func TestScenario2(t *testing.T) { makeSampleTx(rcm) if rcm.minerEnv.IsRequest { - t.Fatal("PlasmaBlock should not be request block", "blockNumber", blockInfo.Block.NumberU64()) + t.Fatal("Block should not be request block", "blockNumber", blockInfo.Block.NumberU64()) } } @@ -380,8 +379,7 @@ func TestScenario2(t *testing.T) { return } -// TestScenario3 tests RootChainManager with Plasma service providing RPC endpoint to -// plasma network +// TestScenario3 tests enter & exit with token transfer in child chain. func TestScenario3(t *testing.T) { pls, rpcServer, dir, err := makePls() defer os.RemoveAll(dir) @@ -392,14 +390,10 @@ func TestScenario3(t *testing.T) { defer pls.Stop() defer rpcServer.Stop() - // pls.Start() - pls.protocolManager.Start(1) - if err := pls.rootchainManager.Start(); err != nil { t.Fatalf("Failed to start RootChainManager: %v", err) } - - pls.StartMining(runtime.NumCPU()) + pls.protocolManager.Start(1) rpcClient := rpc.DialInProc(rpcServer) @@ -421,11 +415,11 @@ func TestScenario3(t *testing.T) { log.Info("All backends are set up") - // NRBEpoch#1 / PlasmaBlock#1 (1/2) + // NRE#1 / Block#1 (1/2) tokenInRootChain, tokenInChildChain, tokenAddrInRootChain, tokenAddrInChildChain := deployTokenContracts(t) wait(4) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 1); err != nil { t.Fatal(err) } @@ -455,7 +449,7 @@ func TestScenario3(t *testing.T) { if err != nil { t.Fatalf("Failed to map token addresses to RootChain contract: %v", err) } - wait(2) + wait(e) tokenAddr, err := pls.rootchainManager.rootchainContract.RequestableContracts(baseCallOpt, tokenAddrInRootChain) wait(2) @@ -476,15 +470,15 @@ func TestScenario3(t *testing.T) { startETHDeposit(t, pls.rootchainManager, key, depositAmount) } - // NRBEpoch#1 / PlasmaBlock#2 (2/2) + // NRE#1 / Block#2 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 2); err != nil { t.Fatal(err) } - // ORBEpoch#2 / PlasmaBlock#3 (1/1): 4 ETH deposits - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#2 / Block#3 (1/1): 4 ETH deposits + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 3); err != nil { t.Fatal(err) } @@ -515,22 +509,22 @@ func TestScenario3(t *testing.T) { startTokenDeposit(t, pls.rootchainManager, tokenInRootChain, tokenAddrInRootChain, key1, tokenAmount) //wait(2) - // NRBEpoch#3 / PlasmaBlock#4 (1/2) + // NRE#3 / Block#4 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 4); err != nil { t.Fatal(err) } - // NRBEpoch#3 / PlasmaBlock#5 (2/2) + // NRE#3 / Block#5 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 5); err != nil { t.Fatal(err) } - // ORBEpoch#4 / PlasmaBlock#6 (1/1): 1 Token deposit - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#4 / Block#6 (1/1): 1 Token deposit + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 6); err != nil { t.Fatal(err) } @@ -553,9 +547,9 @@ func TestScenario3(t *testing.T) { tokenAmountToTransfer := new(big.Int).Div(ether(1), big.NewInt(2)) tokenAmountToTransferNeg := new(big.Int).Neg(tokenAmountToTransfer) - // NRBEpoch#5 / PlasmaBlock#7 (1/2) + // NRE#5 / Block#7 (1/2) transferToken(t, tokenInChildChain, key1, addr2, tokenAmountToTransfer) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 7); err != nil { t.Fatal(err) } @@ -567,10 +561,10 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#5 / PlasmaBlock#8 (2/2) + // NRE#5 / Block#8 (2/2) transferToken(t, tokenInChildChain, key1, addr2, tokenAmountToTransfer) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 8); err != nil { t.Fatal(err) } @@ -582,10 +576,12 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#6 / PlasmaBlock#9 (1/2) + // ORE#6 is empty + + // NRE#7 / Block#9 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 9); err != nil { t.Fatal(err) } @@ -597,15 +593,15 @@ func TestScenario3(t *testing.T) { // (1/4) withdraw addr2's token to root chain startTokenWithdraw(t, pls.rootchainManager.rootchainContract, tokenInRootChain, tokenAddrInRootChain, key2, tokenAmountToWithdraw, big.NewInt(int64(pls.rootchainManager.state.costERO))) - // NRBEpoch#6 / PlasmaBlock#10 (2/2) + // NRE#7 / Block#10 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 10); err != nil { t.Fatal(err) } - // ORBEpoch#7 / PlasmaBlock#11 (1/1) + // ORE#8 / Block#11 (1/1) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 11); err != nil { t.Fatal(err) } @@ -614,23 +610,23 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#8 / PlasmaBlock#12 (1/2) + // NRE#9 / Block#12 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 12); err != nil { t.Fatal(err) } // (2/4) withdraw addr2's token to root chain startTokenWithdraw(t, pls.rootchainManager.rootchainContract, tokenInRootChain, tokenAddrInRootChain, key2, tokenAmountToWithdraw, big.NewInt(int64(pls.rootchainManager.state.costERO))) - // NRBEpoch#8 / PlasmaBlock#13 (2/2) + // NRE#9 / Block#13 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 13); err != nil { t.Fatal(err) } - // ORBEpoch#9 / PlasmaBlock#14 (1/1) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#10 / Block#14 (1/1) + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 14); err != nil { t.Fatal(err) } @@ -639,23 +635,23 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#10 / PlasmaBlock#15 (1/2) + // NRE#11 / Block#15 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 15); err != nil { t.Fatal(err) } // (3/4) withdraw addr2's token to root chain startTokenWithdraw(t, pls.rootchainManager.rootchainContract, tokenInRootChain, tokenAddrInRootChain, key2, tokenAmountToWithdraw, big.NewInt(int64(pls.rootchainManager.state.costERO))) - // NRBEpoch#10 / PlasmaBlock#16 (2/2) + // NRE#11 / Block#16 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 16); err != nil { t.Fatal(err) } - // ORBEpoch#11 / PlasmaBlock#17 (1/1) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#12 / Block#17 (1/1) + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 17); err != nil { t.Fatal(err) } @@ -664,23 +660,23 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#12 / PlasmaBlock#18 (1/2) + // NRE#13 / Block#18 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 18); err != nil { t.Fatal(err) } // (4/4) withdraw addr2's token to root chain startTokenWithdraw(t, pls.rootchainManager.rootchainContract, tokenInRootChain, tokenAddrInRootChain, key2, tokenAmountToWithdraw, big.NewInt(int64(pls.rootchainManager.state.costERO))) - // NRBEpoch#12 / PlasmaBlock#19 (2/2) + // NRE#13 / Block#19 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 19); err != nil { t.Fatal(err) } - // ORBEpoch#13 / PlasmaBlock#20 (1/1) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#14 / Block#20 (1/1) + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 20); err != nil { t.Fatal(err) } @@ -689,15 +685,15 @@ func TestScenario3(t *testing.T) { t.Fatal(err) } - // NRBEpoch#14 / PlasmaBlock#21 (1/2) + // NRE#15 / Block#21 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 21); err != nil { t.Fatal(err) } - // NRBEpoch#14 / PlasmaBlock#22 (2/2) + // NRE#15 / Block#22 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 22); err != nil { t.Fatal(err) } @@ -758,11 +754,11 @@ func TestScenario4(t *testing.T) { log.Info("All backends are set up") - // NRBEpoch#1 / PlasmaBlock#1 (1/2) + // NRE#1 / Block#1 (1/2) tokenInRootChain, tokenInChildChain, tokenAddrInRootChain, tokenAddrInChildChain := deployTokenContracts(t) wait(4) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 1); err != nil { t.Fatal(err) } @@ -813,15 +809,15 @@ func TestScenario4(t *testing.T) { startETHDeposit(t, pls.rootchainManager, key, depositAmount) } - // NRBEpoch#1 / PlasmaBlock#2 (2/2) + // NRE#1 / Block#2 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 2); err != nil { t.Fatal(err) } - // ORBEpoch#2 / PlasmaBlock#3 (1/1): 4 ETH deposits - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#2 / Block#3 (1/1): 4 ETH deposits + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 3); err != nil { t.Fatal(err) } @@ -852,22 +848,22 @@ func TestScenario4(t *testing.T) { startTokenDeposit(t, pls.rootchainManager, tokenInRootChain, tokenAddrInRootChain, key1, tokenAmount) wait(2) - // NRBEpoch#3 / PlasmaBlock#4 (1/2) + // NRE#3 / Block#4 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 4); err != nil { t.Fatal(err) } - // NRBEpoch#3 / PlasmaBlock#5 (2/2) + // NRE#3 / Block#5 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 5); err != nil { t.Fatal(err) } - // ORBEpoch#4 / PlasmaBlock#6 (1/1): 1 Token deposit - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + // ORE#4 / Block#6 (1/1): 1 Token deposit + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 6); err != nil { t.Fatal(err) } @@ -889,51 +885,51 @@ func TestScenario4(t *testing.T) { wait(2) - // NRBEpoch#5 / PlasmaBlock#7 (1/2) + // NRE#5 / Block#7 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 7); err != nil { t.Fatal(err) } - // NRBEpoch#5 / PlasmaBlock#8 (2/2) + // NRE#5 / Block#8 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 8); err != nil { t.Fatal(err) } - // ORBEpoch#6 / PlasmaBlock#9 (1/1): invalid withdrawal + // ORE#6 / Block#9 (1/1): invalid withdrawal - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, true, 0, 9); err != nil { t.Fatal(err) } - // NRBEpoch#7 / PlasmaBlock#10 (1/2) + // NRE#7 / Block#10 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 10); err != nil { t.Fatal(err) } - // NRBEpoch#7 / PlasmaBlock#11 (2/2) + // NRE#7 / Block#11 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 11); err != nil { t.Fatal(err) } - // NRBEpoch#8 / PlasmaBlock#12 (1/2) + // NRE#8 / Block#12 (1/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 12); err != nil { t.Fatal(err) } - // NRBEpoch#8 / PlasmaBlock#12 (2/2) + // NRE#8 / Block#13 (2/2) makeSampleTx(pls.rootchainManager) - if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false); err != nil { + if err := checkBlock(pls, plasmaBlockMinedEvents, blockSubmitEvents, false, 0, 13); err != nil { t.Fatal(err) } @@ -1066,6 +1062,22 @@ func startTokenWithdraw(t *testing.T, rootchainContract *rootchain.RootChain, to wait(3) + receipt, err := ethClient.TransactionReceipt(context.Background(), tx.Hash()) + if err != nil { + t.Fatalf("Failed to get receipt: %v", err) + } + if receipt == nil { + t.Fatalf("Failed to send transaction: %v", tx.Hash().Hex()) + } + if receipt.Status == 0 { + t.Fatalf("Transaction reverted: %v", tx.Hash().Hex()) + } + if err != nil { + t.Fatalf("Failed to make an token withdrawal request: %v", err) + } + + wait(3) + receipt, err := ethClient.TransactionReceipt(context.Background(), tx.Hash()) if err != nil { t.Fatalf("Failed to get receipt: %v", err) @@ -1408,8 +1420,8 @@ func makeManager() (*RootChainManager, func(), error) { if err != nil { return nil, func() {}, err } - - go miner.Start(operator) + // TODO (aiden): there's no need to start miner in here, it starts when rcm connect to root chain contract by reading 1st NRE. + //go Miner.Start(operator, &miner.NRE) return rcm, stopFn, nil } @@ -1473,13 +1485,16 @@ func makeSampleTx(rcm *RootChainManager) error { return nil } -func checkBlock(pls *Plasma, pbMinedEvents *event.TypeMuxSubscription, pbSubmitedEvents chan *rootchain.RootChainBlockSubmitted, expectedIsRequest bool) error { +func checkBlock(pls *Plasma, pbMinedEvents *event.TypeMuxSubscription, pbSubmitedEvents chan *rootchain.RootChainBlockSubmitted, expectedIsRequest bool, expectedFork, expectedBlockNumber int64) error { + // TODO: delete below line after genesis.Difficulty is set 0 + expectedFork += 1 + outC := make(chan struct{}) errC := make(chan error) defer close(outC) defer close(errC) - timer := time.NewTimer(2 * time.Second) + timer := time.NewTimer(4 * time.Second) defer timer.Stop() go func() { @@ -1490,16 +1505,37 @@ func checkBlock(pls *Plasma, pbMinedEvents *event.TypeMuxSubscription, pbSubmite }() go func() { - ev := <-pbMinedEvents.Chan() - <-pbSubmitedEvents - blockInfo := ev.Data.(core.NewMinedBlockEvent) + outC2 := make(chan struct{}) + defer close(outC2) + // use goroutine to read both events + var blockInfo core.NewMinedBlockEvent + go func() { + e := <-pbMinedEvents.Chan() + blockInfo = e.Data.(core.NewMinedBlockEvent) + outC2 <- struct{}{} + }() + + go func() { + <-pbSubmitedEvents + outC2 <- struct{}{} + }() + + <-outC2 + <-outC2 + block := blockInfo.Block - log.Info("Check PlasmaBlock Number", "localBlockNumber", pls.blockchain.CurrentBlock().NumberU64(), "minedBlockNumber", block.NumberU64()) + log.Warn("Check Block Number", "expectedBlockNumber", expectedBlockNumber, "minedBlockNumber", block.NumberU64(), "forkNumber", block.Difficulty().Uint64()) // check block number. - if pls.blockchain.CurrentBlock().NumberU64() != block.NumberU64() { - errC <- errors.New(fmt.Sprintf("Expected block number: %d, actual block %d", block.NumberU64(), pls.blockchain.CurrentBlock().NumberU64())) + if expectedBlockNumber != block.Number().Int64() { + errC <- errors.New(fmt.Sprintf("Expected block number: %d, actual block %d", expectedBlockNumber, block.Number().Int64())) + return + } + + // check fork number + if expectedFork != block.Difficulty().Int64() { + errC <- errors.New(fmt.Sprintf("Block Expected ForkNumber: %d, Actual ForkNumber %d", expectedFork, block.Difficulty().Int64())) return } @@ -1523,28 +1559,28 @@ func checkBlock(pls *Plasma, pbMinedEvents *event.TypeMuxSubscription, pbSubmite } if pb.IsRequest != block.IsRequest() { - errC <- errors.New(fmt.Sprintf("PlasmaBlock Expected isRequest: %t, Actual isRequest %t", pb.IsRequest, block.IsRequest())) + errC <- errors.New(fmt.Sprintf("Block Expected isRequest: %t, Actual isRequest %t", pb.IsRequest, block.IsRequest())) return } pbStateRoot := pb.StatesRoot[:] bStateRoot := block.Header().Root.Bytes() if bytes.Compare(pbStateRoot, bStateRoot) != 0 { - errC <- errors.New(fmt.Sprintf("PlasmaBlock Expected stateRoot: %s, Actual stateRoot: %s", pbStateRoot, bStateRoot)) + errC <- errors.New(fmt.Sprintf("Block Expected stateRoot: %s, Actual stateRoot: %s", pbStateRoot, bStateRoot)) return } pbTxRoot := pb.TransactionsRoot[:] bTxRoot := block.Header().TxHash.Bytes() if bytes.Compare(pbTxRoot, bTxRoot) != 0 { - errC <- errors.New(fmt.Sprintf("PlasmaBlock Expected txRoot: %s, Actual txRoot: %s", pbTxRoot, bTxRoot)) + errC <- errors.New(fmt.Sprintf("Block Expected txRoot: %s, Actual txRoot: %s", pbTxRoot, bTxRoot)) return } pbReceiptsRoot := pb.ReceiptsRoot[:] bReceiptsRoot := block.Header().ReceiptHash.Bytes() if bytes.Compare(pbReceiptsRoot, bReceiptsRoot) != 0 { - errC <- errors.New(fmt.Sprintf("PlasmaBlock Expected receiptsRoot: %s, Actual receiptsRoot: %s", pbReceiptsRoot, bReceiptsRoot)) + errC <- errors.New(fmt.Sprintf("Block Expected receiptsRoot: %s, Actual receiptsRoot: %s", pbReceiptsRoot, bReceiptsRoot)) return } log.Debug("Check block finished")