diff --git a/contracts/registrar/contract/registrar.go b/contracts/registrar/contract/registrar.go index d79736abf0..5b4c774b49 100644 --- a/contracts/registrar/contract/registrar.go +++ b/contracts/registrar/contract/registrar.go @@ -16,10 +16,10 @@ import ( ) // ContractABI is the input ABI used to generate the binding from. -const ContractABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_description\",\"type\":\"string\"}],\"name\":\"AddAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GetAllAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GetLatestCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sectionIndex\",\"type\":\"uint256\"},{\"name\":\"_sectionHead\",\"type\":\"bytes32\"},{\"name\":\"_chtRoot\",\"type\":\"bytes32\"},{\"name\":\"_bloomTrieRoot\",\"type\":\"bytes32\"}],\"name\":\"SetCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_sectionIndex\",\"type\":\"uint256\"}],\"name\":\"GetCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_reason\",\"type\":\"string\"}],\"name\":\"RemoveAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_adminlist\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"checkpointHash\",\"type\":\"bytes32\"}],\"name\":\"NewCheckpointEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"description\",\"type\":\"string\"}],\"name\":\"AddAdminEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"RemoveAdminEvent\",\"type\":\"event\"}]" +const ContractABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_description\",\"type\":\"string\"}],\"name\":\"AddAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GetAllAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"GetLatestCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_sectionIndex\",\"type\":\"uint256\"}],\"name\":\"GetCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_addr\",\"type\":\"address\"},{\"name\":\"_reason\",\"type\":\"string\"}],\"name\":\"RemoveAdmin\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_sectionIndex\",\"type\":\"uint256\"},{\"name\":\"_hash\",\"type\":\"bytes32\"}],\"name\":\"SetCheckpoint\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_adminlist\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"checkpointHash\",\"type\":\"bytes32\"}],\"name\":\"NewCheckpointEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"description\",\"type\":\"string\"}],\"name\":\"AddAdminEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"grantor\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"RemoveAdminEvent\",\"type\":\"event\"}]" // ContractBin is the compiled bytecode used for deploying new contracts. -const ContractBin = `608060405234801561001057600080fd5b50604051610e83380380610e8383398101806040528101908080518201929190505050600060016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060013390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050600090505b81518110156101d2576001600080848481518110151561010057fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001828281518110151561015857fe5b9060200190602002015190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505080806001019150506100e4565b5050610ca0806101e36000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633561247d1461007d57806345848dfc1461011e5780634d6a304c1461018a578063651c7f49146101c4578063710aeac814610233578063a5ba0be21461027c575b600080fd5b34801561008957600080fd5b50610104600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061031d565b604051808215151515815260200191505060405180910390f35b34801561012a57600080fd5b50610133610574565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561017657808201518184015260208101905061015b565b505050509050019250505060405180910390f35b34801561019657600080fd5b5061019f61065b565b6040518083815260200182600019166000191681526020019250505060405180910390f35b3480156101d057600080fd5b506102196004803603810190808035906020019092919080356000191690602001909291908035600019169060200190929190803560001916906020019092919050505061067a565b604051808215151515815260200191505060405180910390f35b34801561023f57600080fd5b5061025e60048036038101908080359060200190929190505050610874565b60405180826000191660001916815260200191505060405180910390f35b34801561028857600080fd5b50610303600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610891565b604051808215151515815260200191505060405180910390f35b6000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411151561036b57600080fd5b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156103bb576000905061056e565b60016000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060018390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550507fecd88a3d10808aac9f879bbae95f9e4f9687f6c9f0615b88af2085f226d3cf93833384604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561052d578082015181840152602081019050610512565b50505050905090810190601f16801561055a5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1600190505b92915050565b60608060006001805490506040519080825280602002602001820160405280156105ad5781602001602082028038833980820191505090505b509150600090505b600180549050811015610653576001818154811015156105d157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828281518110151561060a57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506105b5565b819250505090565b600080600061066b600354610874565b90506003548192509250509091565b6000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156106c857600080fd5b60035485141580156106df57506001600354018514155b80156106ee5750600060035414155b156106fc576000905061086c565b610100618000600187010201431015610718576000905061086c565b8383836040516020018084600019166000191681526020018360001916600019168152602001826000191660001916815260200193505050506040516020818303038152906040526040518082805190602001908083835b6020831015156107955780518252602082019150602081019050602083039250610770565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060026000878152602001908152602001600020816000191690555084600381905550847f5b3eab050ccf1a983a26b4f6acb13c199093c7d2e7523a0ff036519f7ddaf560336002600089815260200190815260200160002054604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600019166000191681526020019250505060405180910390a25b949350505050565b600060026000838152602001908152602001600020549050919050565b6000806000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156108e257600080fd5b60008060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156109325760009250610c1b565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600091505b600180549050821015610b12578473ffffffffffffffffffffffffffffffffffffffff166001838154811015156109ac57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610b05578190505b6001808054905003811015610aa6576001808201815481101515610a1757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600182815481101515610a5157fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080806001019150506109f7565b600180808054905003815481101515610abb57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560018081818054905003915081610aff9190610c23565b50610b12565b8180600101925050610979565b7fe7d6ab069cde0507dc9c5971bf93e9fd183db04690725946e8cae907367e7c1f853386604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610bda578082015181840152602081019050610bbf565b50505050905090810190601f168015610c075780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1600192505b505092915050565b815481835581811115610c4a57818360005260206000209182019101610c499190610c4f565b5b505050565b610c7191905b80821115610c6d576000816000905550600101610c55565b5090565b905600a165627a7a723058208a04962a64cdbd8ff23fe8ac9263f150ac5ef09bc46fe9c174e53bdd9f58e11d0029` +const ContractBin = `608060405234801561001057600080fd5b50604051610da9380380610da983398101806040528101908080518201929190505050600060016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060013390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050600090505b81518110156101d2576001600080848481518110151561010057fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001828281518110151561015857fe5b9060200190602002015190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505080806001019150506100e4565b5050610bc6806101e36000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633561247d1461007d57806345848dfc1461011e5780634d6a304c1461018a578063710aeac8146101c4578063a5ba0be21461020d578063c4885d57146102ae575b600080fd5b34801561008957600080fd5b50610104600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610301565b604051808215151515815260200191505060405180910390f35b34801561012a57600080fd5b50610133610558565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561017657808201518184015260208101905061015b565b505050509050019250505060405180910390f35b34801561019657600080fd5b5061019f61063f565b6040518083815260200182600019166000191681526020019250505060405180910390f35b3480156101d057600080fd5b506101ef6004803603810190808035906020019092919050505061065e565b60405180826000191660001916815260200191505060405180910390f35b34801561021957600080fd5b50610294600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061067b565b604051808215151515815260200191505060405180910390f35b3480156102ba57600080fd5b506102e7600480360381019080803590602001909291908035600019169060200190929190505050610a0d565b604051808215151515815260200191505060405180910390f35b6000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411151561034f57600080fd5b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561039f5760009050610552565b60016000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060018390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550507fecd88a3d10808aac9f879bbae95f9e4f9687f6c9f0615b88af2085f226d3cf93833384604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156105115780820151818401526020810190506104f6565b50505050905090810190601f16801561053e5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1600190505b92915050565b60608060006001805490506040519080825280602002602001820160405280156105915781602001602082028038833980820191505090505b509150600090505b600180549050811015610637576001818154811015156105b557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682828151811015156105ee57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508080600101915050610599565b819250505090565b600080600061064f60035461065e565b90506003548192509250509091565b600060026000838152602001908152602001600020549050919050565b6000806000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156106cc57600080fd5b60008060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141561071c5760009250610a05565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600091505b6001805490508210156108fc578473ffffffffffffffffffffffffffffffffffffffff1660018381548110151561079657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156108ef578190505b600180805490500381101561089057600180820181548110151561080157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660018281548110151561083b57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080806001019150506107e1565b6001808080549050038154811015156108a557fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600180818180549050039150816108e99190610b49565b506108fc565b8180600101925050610763565b7fe7d6ab069cde0507dc9c5971bf93e9fd183db04690725946e8cae907367e7c1f853386604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156109c45780820151818401526020810190506109a9565b50505050905090810190601f1680156109f15780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1600192505b505092915050565b6000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515610a5b57600080fd5b6003548314158015610a7257506001600354018314155b8015610a815750600060035414155b15610a8f5760009050610b43565b610100618000600185010201431015610aab5760009050610b43565b8160026000858152602001908152602001600020816000191690555082600381905550827f5b3eab050ccf1a983a26b4f6acb13c199093c7d2e7523a0ff036519f7ddaf5603384604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600019166000191681526020019250505060405180910390a25b92915050565b815481835581811115610b7057818360005260206000209182019101610b6f9190610b75565b5b505050565b610b9791905b80821115610b93576000816000905550600101610b7b565b5090565b905600a165627a7a72305820eb37f4d3298a6e621a53fa9a92f70e4ae3fa9a8908075f947a120f69cf68fef40029` // DeployContract deploys a new Ethereum contract, binding an instance of Contract to it. func DeployContract(auth *bind.TransactOpts, backend bind.ContractBackend, _adminlist []common.Address) (common.Address, *types.Transaction, *Contract, error) { @@ -300,25 +300,25 @@ func (_Contract *ContractTransactorSession) RemoveAdmin(_addr common.Address, _r return _Contract.Contract.RemoveAdmin(&_Contract.TransactOpts, _addr, _reason) } -// SetCheckpoint is a paid mutator transaction binding the contract method 0x651c7f49. +// SetCheckpoint is a paid mutator transaction binding the contract method 0xc4885d57. // -// Solidity: function SetCheckpoint(_sectionIndex uint256, _sectionHead bytes32, _chtRoot bytes32, _bloomTrieRoot bytes32) returns(bool) -func (_Contract *ContractTransactor) SetCheckpoint(opts *bind.TransactOpts, _sectionIndex *big.Int, _sectionHead [32]byte, _chtRoot [32]byte, _bloomTrieRoot [32]byte) (*types.Transaction, error) { - return _Contract.contract.Transact(opts, "SetCheckpoint", _sectionIndex, _sectionHead, _chtRoot, _bloomTrieRoot) +// Solidity: function SetCheckpoint(_sectionIndex uint256, _hash bytes32) returns(bool) +func (_Contract *ContractTransactor) SetCheckpoint(opts *bind.TransactOpts, _sectionIndex *big.Int, _hash [32]byte) (*types.Transaction, error) { + return _Contract.contract.Transact(opts, "SetCheckpoint", _sectionIndex, _hash) } -// SetCheckpoint is a paid mutator transaction binding the contract method 0x651c7f49. +// SetCheckpoint is a paid mutator transaction binding the contract method 0xc4885d57. // -// Solidity: function SetCheckpoint(_sectionIndex uint256, _sectionHead bytes32, _chtRoot bytes32, _bloomTrieRoot bytes32) returns(bool) -func (_Contract *ContractSession) SetCheckpoint(_sectionIndex *big.Int, _sectionHead [32]byte, _chtRoot [32]byte, _bloomTrieRoot [32]byte) (*types.Transaction, error) { - return _Contract.Contract.SetCheckpoint(&_Contract.TransactOpts, _sectionIndex, _sectionHead, _chtRoot, _bloomTrieRoot) +// Solidity: function SetCheckpoint(_sectionIndex uint256, _hash bytes32) returns(bool) +func (_Contract *ContractSession) SetCheckpoint(_sectionIndex *big.Int, _hash [32]byte) (*types.Transaction, error) { + return _Contract.Contract.SetCheckpoint(&_Contract.TransactOpts, _sectionIndex, _hash) } -// SetCheckpoint is a paid mutator transaction binding the contract method 0x651c7f49. +// SetCheckpoint is a paid mutator transaction binding the contract method 0xc4885d57. // -// Solidity: function SetCheckpoint(_sectionIndex uint256, _sectionHead bytes32, _chtRoot bytes32, _bloomTrieRoot bytes32) returns(bool) -func (_Contract *ContractTransactorSession) SetCheckpoint(_sectionIndex *big.Int, _sectionHead [32]byte, _chtRoot [32]byte, _bloomTrieRoot [32]byte) (*types.Transaction, error) { - return _Contract.Contract.SetCheckpoint(&_Contract.TransactOpts, _sectionIndex, _sectionHead, _chtRoot, _bloomTrieRoot) +// Solidity: function SetCheckpoint(_sectionIndex uint256, _hash bytes32) returns(bool) +func (_Contract *ContractTransactorSession) SetCheckpoint(_sectionIndex *big.Int, _hash [32]byte) (*types.Transaction, error) { + return _Contract.Contract.SetCheckpoint(&_Contract.TransactOpts, _sectionIndex, _hash) } // ContractAddAdminEventIterator is returned from FilterAddAdminEvent and is used to iterate over the raw logs and unpacked data for AddAdminEvent events raised by the Contract contract. diff --git a/contracts/registrar/contract/registrar.sol b/contracts/registrar/contract/registrar.sol index a5e1f8d0c8..122f5611de 100644 --- a/contracts/registrar/contract/registrar.sol +++ b/contracts/registrar/contract/registrar.sol @@ -86,16 +86,12 @@ contract Registrar { * Note we trust the given information here provided by foundation, * need a trust less version for future. * @param _sectionIndex section index - * @param _sectionHead section header - * @param _chtRoot cht root hash - * @param _bloomTrieRoot bloom trie root hash + * @param _hash checkpoint hash calculated in the client side * @return indicator whether set checkpoint successfully */ function SetCheckpoint( uint _sectionIndex, - bytes32 _sectionHead, - bytes32 _chtRoot, - bytes32 _bloomTrieRoot + bytes32 _hash ) OnlyAuthorized public @@ -111,10 +107,10 @@ contract Registrar { return false; } - checkpoints[_sectionIndex] = keccak256(abi.encodePacked(_sectionHead, _chtRoot, _bloomTrieRoot)); + checkpoints[_sectionIndex] = _hash; latest = _sectionIndex; - emit NewCheckpointEvent(_sectionIndex, msg.sender, checkpoints[_sectionIndex]); + emit NewCheckpointEvent(_sectionIndex, msg.sender, _hash); } /** diff --git a/contracts/registrar/registrar.go b/contracts/registrar/registrar.go index dfa47570b1..1c1a176b79 100644 --- a/contracts/registrar/registrar.go +++ b/contracts/registrar/registrar.go @@ -23,9 +23,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/contracts/registrar/contract" - "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/params" ) @@ -34,7 +32,7 @@ var ( RegistrarAddr = map[common.Hash]common.Address{ // params.MainnetGenesisHash: common.HexToAddress(""), // params.TestnetGenesisHash: common.HexToAddress(""), - params.RinkebyGenesisHash: common.HexToAddress("0xe3f2686a5d0c56a2d853c19c46b173a755263be8"), + params.RinkebyGenesisHash: common.HexToAddress("0xaefc742121f79ce9d0953fea7c9cd10f6586179b"), } ) @@ -45,8 +43,8 @@ type Registrar struct { } // NewRegistrar binds checkpoint contract and returns a registrar instance. -func NewRegistrar(contractAddr common.Address, backend ethapi.Backend, lightMode bool) (*Registrar, error) { - contract, err := contract.NewContract(contractAddr, eth.NewContractBackend(backend, lightMode)) +func NewRegistrar(contractAddr common.Address, backend bind.ContractBackend) (*Registrar, error) { + contract, err := contract.NewContract(contractAddr, backend) if err != nil { return nil, err } diff --git a/contracts/registrar/registrar_test.go b/contracts/registrar/registrar_test.go index 9add4c638d..54c37f7ff6 100644 --- a/contracts/registrar/registrar_test.go +++ b/contracts/registrar/registrar_test.go @@ -43,6 +43,7 @@ var ( ChtRoot: common.HexToHash("cf92fd2a79464354e8dae4d589ae92acdf90a3a4f8f7d8a3ec5fb9c114ae81cd"), BloomTrieRoot: common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), } + checkpointHash = crypto.Keccak256Hash(trustedCheckpoint.SectionHead.Bytes(), trustedCheckpoint.ChtRoot.Bytes(), trustedCheckpoint.BloomTrieRoot.Bytes()) ) // validateOperation executes the operation, watches and delivers all events fired by the backend and ensures the @@ -200,8 +201,7 @@ func TestCheckpointRegister(t *testing.T) { // Register unstable checkpoint validateOperation(t, c, contractBackend, func() { - c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), trustedCheckpoint.SectionHead, - trustedCheckpoint.ChtRoot, trustedCheckpoint.BloomTrieRoot) + c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), checkpointHash) }, func(events <-chan *contract.ContractNewCheckpointEvent, events2 <-chan *contract.ContractAddAdminEvent, events3 <-chan *contract.ContractRemoveAdminEvent) error { hash, err := c.GetCheckpoint(nil, big.NewInt(int64(trustedCheckpoint.SectionIdx))) if err != nil { @@ -219,29 +219,27 @@ func TestCheckpointRegister(t *testing.T) { validateOperation(t, c, contractBackend, func() { user2, _ := crypto.GenerateKey() unauthorized := bind.NewKeyedTransactor(user2) - c.SetCheckpoint(unauthorized, big.NewInt(int64(trustedCheckpoint.SectionIdx)), trustedCheckpoint.SectionHead, - trustedCheckpoint.ChtRoot, trustedCheckpoint.BloomTrieRoot) + c.SetCheckpoint(unauthorized, big.NewInt(int64(trustedCheckpoint.SectionIdx)), checkpointHash) }, func(events <-chan *contract.ContractNewCheckpointEvent, events2 <-chan *contract.ContractAddAdminEvent, events3 <-chan *contract.ContractRemoveAdminEvent) error { hash, err := c.GetCheckpoint(nil, big.NewInt(int64(trustedCheckpoint.SectionIdx))) if err != nil { return errors.New("get checkpoint failed") } if hash != emptyHash { - return errors.New("unstable checkpoint should be banned") + return errors.New("checkpoint from unauthorized user should be banned") } return nil }, "register by unauthorized user") // Register a stable checkpoint validateOperation(t, c, contractBackend, func() { - c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), trustedCheckpoint.SectionHead, - trustedCheckpoint.ChtRoot, trustedCheckpoint.BloomTrieRoot) + c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), checkpointHash) }, func(events <-chan *contract.ContractNewCheckpointEvent, events2 <-chan *contract.ContractAddAdminEvent, events3 <-chan *contract.ContractRemoveAdminEvent) error { hash, err := c.GetCheckpoint(nil, big.NewInt(int64(trustedCheckpoint.SectionIdx))) if err != nil { return errors.New("get checkpoint failed") } - if !trustedCheckpoint.HashEqual(common.Hash(hash)) { + if hash != checkpointHash { return errors.New("register stable checkpoint failed") } if !validateEvents(1, events) { @@ -250,17 +248,16 @@ func TestCheckpointRegister(t *testing.T) { return nil }, "register stable checkpoint") + fakeHash := crypto.Keccak256Hash([]byte("dead"), []byte("beef"), []byte("deadbeef")) // Modify the latest checkpoint validateOperation(t, c, contractBackend, func() { - trustedCheckpoint.SectionHead = common.HexToHash("dead") - c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), trustedCheckpoint.SectionHead, - trustedCheckpoint.ChtRoot, trustedCheckpoint.BloomTrieRoot) + c.SetCheckpoint(transactOpts, big.NewInt(int64(trustedCheckpoint.SectionIdx)), fakeHash) }, func(events <-chan *contract.ContractNewCheckpointEvent, events2 <-chan *contract.ContractAddAdminEvent, events3 <-chan *contract.ContractRemoveAdminEvent) error { hash, err := c.GetCheckpoint(nil, big.NewInt(int64(trustedCheckpoint.SectionIdx))) if err != nil { return errors.New("get checkpoint failed") } - if !trustedCheckpoint.HashEqual(common.Hash(hash)) { + if hash != fakeHash { return errors.New("register stable checkpoint failed") } if !validateEvents(1, events) { diff --git a/eth/bind.go b/eth/bind.go index 7119114519..ca339b696a 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -39,20 +39,22 @@ import ( // object. These should be rewritten to internal Go method calls when the Go API // is refactored to support a clean library use. type ContractBackend struct { - eapi *ethapi.PublicEthereumAPI // Wrapper around the Ethereum object to access metadata - bcapi *ethapi.PublicBlockChainAPI // Wrapper around the blockchain to access chain data - txapi *ethapi.PublicTransactionPoolAPI // Wrapper around the transaction pool to access transaction data - filterapi *filters.PublicFilterAPI // Wrapper around the filter to watch and retrieve contract logs + filterBackend filters.Backend // Backend used for filter vm logs. + events *filters.EventSystem // Event system used to watch new fired vm logs. + eapi *ethapi.PublicEthereumAPI // Wrapper around the Ethereum object to access metadata + bcapi *ethapi.PublicBlockChainAPI // Wrapper around the blockchain to access chain data + txapi *ethapi.PublicTransactionPoolAPI // Wrapper around the transaction pool to access transaction data } // NewContractBackend creates a new native contract backend using an existing // Ethereum object. -func NewContractBackend(apiBackend ethapi.Backend, lightMode bool) *ContractBackend { +func NewContractBackend(apiBackend ethapi.Backend, filterBackend filters.Backend, lightMode bool) *ContractBackend { return &ContractBackend{ - eapi: ethapi.NewPublicEthereumAPI(apiBackend), - bcapi: ethapi.NewPublicBlockChainAPI(apiBackend), - txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend, new(ethapi.AddrLocker)), - filterapi: filters.NewPublicFilterAPI(apiBackend.(filters.Backend), lightMode), + filterBackend: filterBackend, + events: filters.NewEventSystem(apiBackend.EventMux(), filterBackend, lightMode), + eapi: ethapi.NewPublicEthereumAPI(apiBackend), + bcapi: ethapi.NewPublicBlockChainAPI(apiBackend), + txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend, new(ethapi.AddrLocker)), } } @@ -93,7 +95,7 @@ func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) if err != nil { return nil, err } - return (*big.Int)(price), nil + return price.ToInt(), nil } // EstimateGasLimit implements bind.ContractTransactor trying to estimate the gas @@ -117,23 +119,34 @@ func (b *ContractBackend) SendTransaction(ctx context.Context, tx *types.Transac // FilterLogs implements bind.ContractFilterer returning logs matching the given argument // that are stored within the state. func (b *ContractBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) { - ret, err := b.filterapi.GetLogs(ctx, filters.FilterCriteria(query)) + // Initialize unset filter boundaried to run from genesis to chain head + from := int64(0) + if query.FromBlock != nil { + from = query.FromBlock.Int64() + } + to := int64(-1) + if query.ToBlock != nil { + to = query.ToBlock.Int64() + } + // Construct and execute the filter + filter := filters.New(b.filterBackend, from, to, query.Addresses, query.Topics) + + logs, err := filter.Logs(ctx) if err != nil { return nil, err } - logs := make([]types.Log, len(ret)) - for idx, log := range ret { - logs[idx] = *log + res := make([]types.Log, len(logs)) + for i, log := range logs { + res[i] = *log } - return logs, nil + return res, nil } // SubscribeFilterLogs implements bind.ContractFilterer watching new fired logs matching the given argument. func (b *ContractBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) { // Subscribe to contract events sink := make(chan []*types.Log) - - sub, err := b.filterapi.EventSystem().SubscribeLogs(query, sink) + sub, err := b.events.SubscribeLogs(query, sink) if err != nil { return nil, err } diff --git a/eth/filters/api.go b/eth/filters/api.go index 9c2cb093c9..5ed80a8875 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -75,11 +75,6 @@ func NewPublicFilterAPI(backend Backend, lightMode bool) *PublicFilterAPI { return api } -// EventSystem returns -func (filter *PublicFilterAPI) EventSystem() *EventSystem { - return filter.events -} - // timeoutLoop runs every 5 minutes and deletes filters that have not been recently used. // Tt is started when the api is created. func (api *PublicFilterAPI) timeoutLoop() { diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 444f051652..c9ffe230c6 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/bloombits" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -45,8 +44,6 @@ type Backend interface { ChainDb() ethdb.Database EventMux() *event.TypeMux AccountManager() *accounts.Manager - BloomStatus() (uint64, uint64) - ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) // BlockChain API SetHead(number uint64) diff --git a/les/server.go b/les/server.go index 5ad0fcb065..aeabbc0ff1 100644 --- a/les/server.go +++ b/les/server.go @@ -62,27 +62,27 @@ type LesServer struct { bloomTrieIndexer *core.ChainIndexer // Indexers for creating bloom trie root for each block section } -func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) { +func NewLesServer(e *eth.Ethereum, config *eth.Config) (*LesServer, error) { quitSync := make(chan struct{}) - pm, err := NewProtocolManager(eth.BlockChain().Config(), false, ServerProtocolVersions, config.NetworkId, eth.EventMux(), eth.Engine(), newPeerSet(), eth.BlockChain(), eth.TxPool(), eth.ChainDb(), nil, nil, nil, quitSync, new(sync.WaitGroup)) + pm, err := NewProtocolManager(e.BlockChain().Config(), false, ServerProtocolVersions, config.NetworkId, e.EventMux(), e.Engine(), newPeerSet(), e.BlockChain(), e.TxPool(), e.ChainDb(), nil, nil, nil, quitSync, new(sync.WaitGroup)) if err != nil { return nil, err } lesTopics := make([]discv5.Topic, len(AdvertiseProtocolVersions)) for i, pv := range AdvertiseProtocolVersions { - lesTopics[i] = lesTopic(eth.BlockChain().Genesis().Hash(), pv) + lesTopics[i] = lesTopic(e.BlockChain().Genesis().Hash(), pv) } srv := &LesServer{ config: config, - backend: eth.APIBackend, - chaindb: eth.ChainDb(), + backend: e.APIBackend, + chaindb: e.ChainDb(), protocolManager: pm, quitSync: quitSync, lesTopics: lesTopics, - chtIndexer: light.NewChtIndexer(eth.ChainDb(), false), - bloomTrieIndexer: light.NewBloomTrieIndexer(eth.ChainDb(), false), + chtIndexer: light.NewChtIndexer(e.ChainDb(), false), + bloomTrieIndexer: light.NewBloomTrieIndexer(e.ChainDb(), false), } logger := log.New() @@ -105,7 +105,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) { logger.Info("Loaded bloom trie", "section", bloomTrieLastSection, "head", bloomTrieSectionHead, "root", bloomTrieRoot) } - srv.chtIndexer.Start(eth.BlockChain()) + srv.chtIndexer.Start(e.BlockChain()) pm.server = srv srv.defParams = &flowcontrol.ServerParams{ @@ -113,9 +113,9 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) { MinRecharge: 50000, } srv.fcManager = flowcontrol.NewClientManager(uint64(config.LightServ), 10, 1000000000) - srv.fcCostStats = newCostStats(eth.ChainDb()) - if addr, ok := registrar.RegistrarAddr[eth.BlockChain().Genesis().Hash()]; ok { - registrar, err := registrar.NewRegistrar(addr, eth.APIBackend, false) + srv.fcCostStats = newCostStats(e.ChainDb()) + if addr, ok := registrar.RegistrarAddr[e.BlockChain().Genesis().Hash()]; ok { + registrar, err := registrar.NewRegistrar(addr, eth.NewContractBackend(e.APIBackend, e.APIBackend, false)) if err != nil { return nil, err }