Skip to content

Commit

Permalink
Merge pull request ethereum#5 from ethereum/master
Browse files Browse the repository at this point in the history
Bring latest changes from original geth
  • Loading branch information
AlexeyAkhunov authored Jan 8, 2018
2 parents 50ad80e + 9d06026 commit 4c2fb58
Show file tree
Hide file tree
Showing 52 changed files with 2,279 additions and 1,571 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ clean:

devtools:
env GOBIN= go get -u golang.org/x/tools/cmd/stringer
env GOBIN= go get -u github.com/jteeuwen/go-bindata/go-bindata
env GOBIN= go get -u github.com/kevinburke/go-bindata/go-bindata
env GOBIN= go get -u github.com/fjl/gencodec
env GOBIN= go get -u github.com/golang/protobuf/protoc-gen-go
env GOBIN= go install ./cmd/abigen
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'

# Cross Compilation Targets (xgo)

Expand Down
2 changes: 2 additions & 0 deletions accounts/usbwallet/internal/trezor/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// https://github.com/trezor/trezor-common/blob/master/protob/messages.proto
// dated 28.07.2017, commit dd8ec3231fb5f7992360aff9bdfe30bb58130f4b.

syntax = "proto2";

/**
* Messages for TREZOR communication
*/
Expand Down
2 changes: 1 addition & 1 deletion accounts/usbwallet/internal/trezor/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// wallets. The wire protocol spec can be found on the SatoshiLabs website:
// https://doc.satoshilabs.com/trezor-tech/api-protobuf.html

//go:generate protoc --go_out=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor,import_path=trezor:. types.proto messages.proto
//go:generate protoc --go_out=import_path=trezor:. types.proto messages.proto

// Package trezor contains the wire protocol wrapper in Go.
package trezor
Expand Down
2 changes: 2 additions & 0 deletions accounts/usbwallet/internal/trezor/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// https://github.com/trezor/trezor-common/blob/master/protob/types.proto
// dated 28.07.2017, commit dd8ec3231fb5f7992360aff9bdfe30bb58130f4b.

syntax = "proto2";

/**
* Types for TREZOR communication
*
Expand Down
1 change: 1 addition & 0 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package main

//go:generate go-bindata -nometadata -o website.go faucet.html
//go:generate gofmt -w -s website.go

import (
"bytes"
Expand Down
25 changes: 10 additions & 15 deletions cmd/faucet/website.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/chequebook/cheque.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// as well as (auto)depositing ether to the chequebook contract.
package chequebook

//go:generate abigen --sol contract/chequebook.sol --pkg contract --out contract/chequebook.go
//go:generate abigen --sol contract/chequebook.sol --exc contract/mortal.sol:mortal,contract/owned.sol:owned --pkg contract --out contract/chequebook.go
//go:generate go run ./gencode.go

import (
Expand Down
321 changes: 4 additions & 317 deletions contracts/chequebook/contract/chequebook.go

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions contracts/chequebook/contract/chequebook.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.18;

import "https://github.com/ethereum/solidity/std/mortal.sol";
import "./mortal.sol";

/// @title Chequebook for Ethereum micropayments
/// @author Daniel A. Nagy <daniel@ethereum.org>
Expand All @@ -11,6 +11,9 @@ contract chequebook is mortal {
/// @notice Overdraft event
event Overdraft(address deadbeat);

// Allow sending ether to the chequebook.
function() public payable { }

/// @notice Cash cheque
///
/// @param beneficiary beneficiary address
Expand All @@ -19,8 +22,7 @@ contract chequebook is mortal {
/// @param sig_r signature parameter r
/// @param sig_s signature parameter s
/// The digital signature is calculated on the concatenated triplet of contract address, beneficiary address and cumulative amount
function cash(address beneficiary, uint256 amount,
uint8 sig_v, bytes32 sig_r, bytes32 sig_s) {
function cash(address beneficiary, uint256 amount, uint8 sig_v, bytes32 sig_r, bytes32 sig_s) public {
// Check if the cheque is old.
// Only cheques that are more recent than the last cashed one are considered.
require(amount > sent[beneficiary]);
Expand All @@ -31,7 +33,7 @@ contract chequebook is mortal {
// and the cumulative amount on the last cashed cheque to beneficiary.
uint256 diff = amount - sent[beneficiary];
if (diff <= this.balance) {
// update the cumulative amount before sending
// update the cumulative amount before sending
sent[beneficiary] = amount;
beneficiary.transfer(diff);
} else {
Expand Down
2 changes: 1 addition & 1 deletion contracts/chequebook/contract/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package contract

// ContractDeployedCode is used to detect suicides. This constant needs to be
// updated when the contract code is changed.
const ContractDeployedCode = "0x606060405260e060020a600035046341c0e1b581146100315780637bf786f814610059578063fbf788d614610071575b005b61002f60005433600160a060020a03908116911614156100bd57600054600160a060020a0316ff5b6100ab60043560016020526000908152604090205481565b61002f600435602435604435606435608435600160a060020a03851660009081526001602052604081205485116100bf575b505050505050565b60408051918252519081900360200190f35b565b50604080516c0100000000000000000000000030600160a060020a0390811682028352881602601482015260288101869052815190819003604801812080825260ff861660208381019190915282840186905260608301859052925190926001926080818101939182900301816000866161da5a03f11561000257505060405151600054600160a060020a0390811691161461015a576100a3565b600160a060020a038681166000908152600160205260409020543090911631908603106101b357604060008181208790559051600160a060020a0388169190819081818181818881f1935050505015156100a357610002565b60005460408051600160a060020a03929092168252517f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f9789181900360200190a185600160a060020a0316ff"
const ContractDeployedCode = "0x6060604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b581146100585780637bf786f81461006b578063fbf788d61461009c575b005b341561006357600080fd5b6100566100ca565b341561007657600080fd5b61008a600160a060020a03600435166100f1565b60405190815260200160405180910390f35b34156100a757600080fd5b610056600160a060020a036004351660243560ff60443516606435608435610103565b60005433600160a060020a03908116911614156100ef57600054600160a060020a0316ff5b565b60016020526000908152604090205481565b600160a060020a0385166000908152600160205260408120548190861161012957600080fd5b3087876040516c01000000000000000000000000600160a060020a03948516810282529290931690910260148301526028820152604801604051809103902091506001828686866040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f115156101cf57600080fd5b505060206040510351600054600160a060020a039081169116146101f257600080fd5b50600160a060020a03808716600090815260016020526040902054860390301631811161026257600160a060020a0387166000818152600160205260409081902088905582156108fc0290839051600060405180830381858888f19350505050151561025d57600080fd5b6102b7565b6000547f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f97890600160a060020a0316604051600160a060020a03909116815260200160405180910390a186600160a060020a0316ff5b505050505050505600a165627a7a7230582014e927522ca5cd8f68529ac4d3b9cdf36d40e09d8a33b70008248d1abebf79680029"
10 changes: 10 additions & 0 deletions contracts/chequebook/contract/mortal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity ^0.4.0;

import "./owned.sol";

contract mortal is owned {
function kill() public {
if (msg.sender == owner)
selfdestruct(owner);
}
}
15 changes: 15 additions & 0 deletions contracts/chequebook/contract/owned.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.4.0;

contract owned {
address owner;

modifier onlyowner() {
if (msg.sender == owner) {
_;
}
}

function owned() public {
owner = msg.sender;
}
}
9 changes: 4 additions & 5 deletions contracts/chequebook/gencode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ import (
)

var (
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAccount = core.GenesisAccount{
Address: crypto.PubkeyToAddress(testKey.PublicKey),
Balance: big.NewInt(500000000000),
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAlloc = core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(500000000000)},
}
)

func main() {
backend := backends.NewSimulatedBackend(testAccount)
backend := backends.NewSimulatedBackend(testAlloc)
auth := bind.NewKeyedTransactor(testKey)

// Deploy the contract, get the code.
Expand Down
23 changes: 23 additions & 0 deletions contracts/ens/contract/AbstractENS.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pragma solidity ^0.4.0;

contract AbstractENS {
function owner(bytes32 node) constant returns(address);
function resolver(bytes32 node) constant returns(address);
function ttl(bytes32 node) constant returns(uint64);
function setOwner(bytes32 node, address owner);
function setSubnodeOwner(bytes32 node, bytes32 label, address owner);
function setResolver(bytes32 node, address resolver);
function setTTL(bytes32 node, uint64 ttl);

// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);

// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address owner);

// Logged when the resolver for a node changes.
event NewResolver(bytes32 indexed node, address resolver);

// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl);
}
94 changes: 94 additions & 0 deletions contracts/ens/contract/ENS.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
pragma solidity ^0.4.0;

import './AbstractENS.sol';

/**
* The ENS registry contract.
*/
contract ENS is AbstractENS {
struct Record {
address owner;
address resolver;
uint64 ttl;
}

mapping(bytes32=>Record) records;

// Permits modifications only by the owner of the specified node.
modifier only_owner(bytes32 node) {
if (records[node].owner != msg.sender) throw;
_;
}

/**
* Constructs a new ENS registrar.
*/
function ENS() {
records[0].owner = msg.sender;
}

/**
* Returns the address that owns the specified node.
*/
function owner(bytes32 node) constant returns (address) {
return records[node].owner;
}

/**
* Returns the address of the resolver for the specified node.
*/
function resolver(bytes32 node) constant returns (address) {
return records[node].resolver;
}

/**
* Returns the TTL of a node, and any records associated with it.
*/
function ttl(bytes32 node) constant returns (uint64) {
return records[node].ttl;
}

/**
* Transfers ownership of a node to a new address. May only be called by the current
* owner of the node.
* @param node The node to transfer ownership of.
* @param owner The address of the new owner.
*/
function setOwner(bytes32 node, address owner) only_owner(node) {
Transfer(node, owner);
records[node].owner = owner;
}

/**
* Transfers ownership of a subnode sha3(node, label) to a new address. May only be
* called by the owner of the parent node.
* @param node The parent node.
* @param label The hash of the label specifying the subnode.
* @param owner The address of the new owner.
*/
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) only_owner(node) {
var subnode = sha3(node, label);
NewOwner(node, label, owner);
records[subnode].owner = owner;
}

/**
* Sets the resolver address for the specified node.
* @param node The node to update.
* @param resolver The address of the resolver.
*/
function setResolver(bytes32 node, address resolver) only_owner(node) {
NewResolver(node, resolver);
records[node].resolver = resolver;
}

/**
* Sets the TTL for the specified node.
* @param node The node to update.
* @param ttl The TTL in seconds.
*/
function setTTL(bytes32 node, uint64 ttl) only_owner(node) {
NewTTL(node, ttl);
records[node].ttl = ttl;
}
}
39 changes: 39 additions & 0 deletions contracts/ens/contract/FIFSRegistrar.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pragma solidity ^0.4.0;

import './AbstractENS.sol';

/**
* A registrar that allocates subdomains to the first person to claim them.
*/
contract FIFSRegistrar {
AbstractENS ens;
bytes32 rootNode;

modifier only_owner(bytes32 subnode) {
var node = sha3(rootNode, subnode);
var currentOwner = ens.owner(node);

if (currentOwner != 0 && currentOwner != msg.sender) throw;

_;
}

/**
* Constructor.
* @param ensAddr The address of the ENS registry.
* @param node The node that this registrar administers.
*/
function FIFSRegistrar(AbstractENS ensAddr, bytes32 node) {
ens = ensAddr;
rootNode = node;
}

/**
* Register a name, or change the owner of an existing registration.
* @param subnode The hash of the label to register.
* @param owner The address of the new owner.
*/
function register(bytes32 subnode, address owner) only_owner(subnode) {
ens.setSubnodeOwner(rootNode, subnode, owner);
}
}
Loading

0 comments on commit 4c2fb58

Please sign in to comment.