Skip to content

Commit

Permalink
all: update generated code (ethereum#15808)
Browse files Browse the repository at this point in the history
* core/types, core/vm, eth, tests: regenerate gencodec files

* Makefile: update devtools target

Install protoc-gen-go and print reminders about npm, solc and protoc.
Also switch to github.com/kevinburke/go-bindata because it's more
maintained.

* contracts/ens: update contracts and regenerate with solidity v0.4.19

The newer upstream version of the FIFSRegistrar contract doesn't set the
resolver anymore. The resolver is now deployed separately.

* contracts/release: regenerate with solidity v0.4.19

* contracts/chequebook: fix fallback and regenerate with solidity v0.4.19

The contract didn't have a fallback function, payments would be rejected
when compiled with newer solidity. References to 'mortal' and 'owned'
use the local file system so we can compile without network access.

* p2p/discv5: regenerate with recent stringer

* cmd/faucet: regenerate

* dashboard: regenerate

* eth/tracers: regenerate

* internal/jsre/deps: regenerate

* dashboard: avoid sed -i because it's not portable

* accounts/usbwallet/internal/trezor: fix go generate warnings
  • Loading branch information
fjl authored and mariameda committed Aug 19, 2018
1 parent 9ae4ed7 commit 5cb7c6d
Show file tree
Hide file tree
Showing 20 changed files with 898 additions and 89 deletions.
Empty file modified contracts/chequebook/contract/mortal.sol
100755 → 100644
Empty file.
Empty file modified contracts/chequebook/contract/owned.sol
100755 → 100644
Empty file.
Empty file modified contracts/ens/contract/AbstractENS.sol
100755 → 100644
Empty file.
Empty file modified contracts/ens/contract/ENS.sol
100755 → 100644
Empty file.
Empty file modified contracts/ens/contract/FIFSRegistrar.sol
100755 → 100644
Empty file.
Empty file modified contracts/ens/contract/PublicResolver.sol
100755 → 100644
Empty file.
8 changes: 4 additions & 4 deletions contracts/ens/contract/fifsregistrar.go
100755 → 100644

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

8 changes: 4 additions & 4 deletions contracts/ens/contract/publicresolver.go
100755 → 100644

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

34 changes: 15 additions & 19 deletions contracts/ens/ens.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package ens

//go:generate abigen --sol contract/ens.sol --pkg contract --out contract/ens.go
//go:generate abigen --sol contract/ENS.sol --exc contract/AbstractENS.sol:AbstractENS --pkg contract --out contract/ens.go
//go:generate abigen --sol contract/FIFSRegistrar.sol --exc contract/AbstractENS.sol:AbstractENS --pkg contract --out contract/fifsregistrar.go
//go:generate abigen --sol contract/PublicResolver.sol --exc contract/AbstractENS.sol:AbstractENS --pkg contract --out contract/publicresolver.go

import (
"strings"
Expand Down Expand Up @@ -57,31 +59,29 @@ func NewENS(transactOpts *bind.TransactOpts, contractAddr common.Address, contra
}

// DeployENS deploys an instance of the ENS nameservice, with a 'first-in, first-served' root registrar.
func DeployENS(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (*ENS, error) {
// Deploy the ENS registry
ensAddr, _, _, err := contract.DeployENS(transactOpts, contractBackend, transactOpts.From)
func DeployENS(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *ENS, error) {
// Deploy the ENS registry.
ensAddr, _, _, err := contract.DeployENS(transactOpts, contractBackend)
if err != nil {
return nil, err
return ensAddr, nil, err
}

ens, err := NewENS(transactOpts, ensAddr, contractBackend)
if err != nil {
return nil, err
return ensAddr, nil, err
}

// Deploy the registrar
// Deploy the registrar.
regAddr, _, _, err := contract.DeployFIFSRegistrar(transactOpts, contractBackend, ensAddr, [32]byte{})
if err != nil {
return nil, err
return ensAddr, nil, err
}

// Set the registrar as owner of the ENS root
_, err = ens.SetOwner([32]byte{}, regAddr)
if err != nil {
return nil, err
// Set the registrar as owner of the ENS root.
if _, err = ens.SetOwner([32]byte{}, regAddr); err != nil {
return ensAddr, nil, err
}

return ens, nil
return ensAddr, ens, nil
}

func ensParentNode(name string) (common.Hash, common.Hash) {
Expand Down Expand Up @@ -155,15 +155,11 @@ func (self *ENS) Resolve(name string) (common.Hash, error) {
// Only works if the registrar for the parent domain implements the FIFS registrar protocol.
func (self *ENS) Register(name string) (*types.Transaction, error) {
parentNode, label := ensParentNode(name)

registrar, err := self.getRegistrar(parentNode)
if err != nil {
return nil, err
}

opts := self.TransactOpts
opts.GasLimit = 200000
return registrar.Contract.Register(&opts, label, self.TransactOpts.From)
return registrar.Contract.Register(&self.TransactOpts, label, self.TransactOpts.From)
}

// SetContentHash sets the content hash associated with a name. Only works if the caller
Expand Down
28 changes: 19 additions & 9 deletions contracts/ens/ens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/contracts/ens/contract"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
)
Expand All @@ -36,27 +37,36 @@ var (
func TestENS(t *testing.T) {
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}})
transactOpts := bind.NewKeyedTransactor(key)
// Workaround for bug estimating gas in the call to Register
transactOpts.GasLimit = 1000000

ens, err := DeployENS(transactOpts, contractBackend)
ensAddr, ens, err := DeployENS(transactOpts, contractBackend)
if err != nil {
t.Fatalf("expected no error, got %v", err)
t.Fatalf("can't deploy root registry: %v", err)
}
contractBackend.Commit()

_, err = ens.Register(name)
if err != nil {
t.Fatalf("expected no error, got %v", err)
// Set ourself as the owner of the name.
if _, err := ens.Register(name); err != nil {
t.Fatalf("can't register: %v", err)
}
contractBackend.Commit()

_, err = ens.SetContentHash(name, hash)
// Deploy a resolver and make it responsible for the name.
resolverAddr, _, _, err := contract.DeployPublicResolver(transactOpts, contractBackend, ensAddr)
if err != nil {
t.Fatalf("expected no error, got %v", err)
t.Fatalf("can't deploy resolver: %v", err)
}
if _, err := ens.SetResolver(ensNode(name), resolverAddr); err != nil {
t.Fatalf("can't set resolver: %v", err)
}
contractBackend.Commit()

// Set the content hash for the name.
if _, err = ens.SetContentHash(name, hash); err != nil {
t.Fatalf("can't set content hash: %v", err)
}
contractBackend.Commit()

// Try to resolve the name.
vhost, err := ens.Resolve(name)
if err != nil {
t.Fatalf("expected no error, got %v", err)
Expand Down
4 changes: 2 additions & 2 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ type Header struct {
type headerMarshaling struct {
Difficulty *hexutil.Big
Number *hexutil.Big
GasLimit *hexutil.Uint64
GasUsed *hexutil.Uint64
GasLimit hexutil.Uint64
GasUsed hexutil.Uint64
Time *hexutil.Big
Extra hexutil.Bytes
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
Expand Down
6 changes: 4 additions & 2 deletions core/types/gen_header_json.go

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

20 changes: 14 additions & 6 deletions core/vm/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,30 @@ type StructLog struct {
Stack []*big.Int `json:"stack"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"`
Err error `json:"error"`
Err error `json:"-"`
}

// overrides for gencodec
type structLogMarshaling struct {
Stack []*math.HexOrDecimal256
Gas math.HexOrDecimal64
GasCost math.HexOrDecimal64
Memory hexutil.Bytes
OpName string `json:"opName"`
Stack []*math.HexOrDecimal256
Gas math.HexOrDecimal64
GasCost math.HexOrDecimal64
Memory hexutil.Bytes
OpName string `json:"opName"` // adds call to OpName() in MarshalJSON
ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON
}

func (s *StructLog) OpName() string {
return s.Op.String()
}

func (s *StructLog) ErrorString() string {
if s.Err != nil {
return s.Err.Error()
}
return ""
}

// Tracer is used to collect execution traces from an EVM transaction
// execution. CaptureState is called for each step of the VM with the
// current VM state.
Expand Down
28 changes: 12 additions & 16 deletions dashboard/assets.go

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

Loading

0 comments on commit 5cb7c6d

Please sign in to comment.