In this commit, the RPC API is adapted to run on top of the new Go API.
This required lots of changes to many packages, but has a few side
benefits:
- Ethereum and LightEthereum can now be used as a contract backend.
- Some duplicated code could be removed (there is added duplication in
other places though)
- It is now much easier to see which operations are unsupported with the
light client. Package les previously relied on the full node RPC API
backend, which masked several issues because the RPC API performed
direct access to the chain database.
Changes to packages in detail:
accounts/abi/bind:
- Contract call boilerplate has moved to package core.
cmd/utils:
- les now inherits the event.TypeMux from the Node instance
contracts/release:
- The ReleaseService now uses Ethereum and LightEthereum as backend.
core:
- MissingNumber is exposed so it can be used in package eth.
- GetTransaction now returns the index as an int, for convenience
reasons.
- ApplyCallMessage has been added as the new one and only
implementation of read-only contract calls.
- TxPool exposes NonceAt instead of the more general accessor for the
ManagedState.
core/types:
- Signer.SignECDSA is gone (it was basically unused).
- WithSignature doesn't return an error anymore (all implementations panic for
invalid length). I made this change to avoid code duplication in the API.
eth:
- EthApiBackend is gone. In its place, Ethereum gains many new methods
which implement a large portion of the new Go API. It does not
yet support event subscriptions and log filtering.
- Some accessors for internal objects are gone.
- ethapi.PrivateDebugAPI and ethapi.TxPoolDebugAPI are now created in
package eth for dependency reasons.
eth/downloader:
- Progress returns a pointer to simplify callers.
eth/filters:
- The Backend interface is simpler and uses the stable Go API where
possible. The new BlockReceipts method saves one DB read because
BlockReceipts also takes a block number argument.
- ChainDB is no longer passed via the Backend interface.
- EventSystem now relies on HeaderByHash for reorgs in light client mode
instead of reading from the chain database.
eth/gasprice:
- The LightPriceOracle now uses ethereum.ChainReader instead of
ethapi.Backend.
ethclient:
- TransactionByHash is adapted for the last-minute API change which
adds the isPending return value.
internal/ethapi:
- PublicTxPoolAPI is now called TxPoolDebugAPI, moved to its own file
and talks to the transaction pool instead of using the main Backend.
- The API no longer accesses the chain database directly. All access
is mediated through Backend methods.
- The backend is now split into three interfaces.
Implementing Backend is mandatory but does not require the pending
state. The other two (PendingState, TransactionInclusionBlock) are
optional and discovered at runtime.
les:
- LesApiBackend is gone, LightEthereum gets all the methods.
- Weird accessors copied from package eth are now gone as well.
light:
- TxPool.Stats now returns a queued count of zero. It implements the
ethapi.TxPool interface and can be used with TxPoolDebugAPI.
This commit implements EIP158 part 1, 2, 3 & 4
1. If an account is empty it's no longer written to the trie. An empty
account is defined as (balance=0, nonce=0, storage=0, code=0).
2. Delete an empty account if it's touched
3. An empty account is redefined as either non-existent or empty.
4. Zero value calls and zero value suicides no longer consume the 25k
reation costs.
params: moved core/config to params
Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>
This commit includes several API changes:
- The behavior of eth_sign is changed. It now accepts an arbitrary
message, prepends the well-known string
\x19Ethereum Signed Message:\n<length of message>
hashes the result using keccak256 and calculates the signature of
the hash. This breaks backwards compatability!
- personal_sign(hash, address [, password]) is added. It has the same
semantics as eth_sign but also accepts a password. The private key
used to sign the hash is temporarily unlocked in the scope of the
request.
- personal_recover(message, signature) is added and returns the
address for the account that created a signature.
This implements 1b & 1c of EIP150 by adding a new GasTable which must be
returned from the RuleSet config method. This table is used to determine
the gas prices for the current epoch.
Please note that when the CreateBySuicide gas price is set it is assumed
that we're in the new epoch phase.
In addition this PR will serve as temporary basis while refactorisation
in being done in the EVM64 PR, which will substentially overhaul the gas
price code.
This commit replaces the deep-copy based state revert mechanism with a
linear complexity journal. This commit also hides several internal
StateDB methods to limit the number of ways in which calling code can
use the journal incorrectly.
As usual consultation and bug fixes to the initial implementation were
provided by @karalabe, @obscuren and @Arachnid. Thank you!
that specifies the maximum number of elements in the `structLogs`
output. This option is useful for debugging a transaction that
involves a large number of repetition.
For example,
```
debug.traceTransaction(tx, {disableStorage: true, limit: 2})
```
shows at most the first two steps in the `structLogs`.
- returned headers didn't include mixHash
- returned transactions didn't include signature fields
- empty transaction input was returned as "", but should be "0x"
- returned receipts didn't include the bloom filter
- "root" in receipts was missing 0x prefix
This CL makes several refactors:
- Define a Tracer interface, implementing the `CaptureState` method
- Add the VM environment as the first argument of
`Tracer.CaptureState`
- Rename existing functionality `StructLogger` an make it an
implementation of `Tracer`
- Delete `StructLogCollector` and make `StructLogger` collect the logs
directly
- Change all callers to use the new `StructLogger` where necessary and
extract logs from that.
- Deletes the apparently obsolete and likely nonfunctional 'TraceCall'
from the eth API.
Callers that only wish accumulated logs can use the `StructLogger`
implementation straightforwardly. Callers that wish to efficiently
capture VM traces and operate on them without excessive copying can now
implement the `Tracer` interface to receive VM state at each step and
do with it as they wish.
This CL also removes the accumulation of logs from the vm.Environment;
this was necessary as part of the refactor, but also simplifies it by
removing a responsibility that doesn't directly belong to the
Environment.
Support for legacy version 0.9.x is gone. The compiler version is no
longer cached. Compilation results (and the version) are read directly
from stdout using the --combined-json flag. As a workaround for
ethereum/solidity#651, source code is written to a temporary file before
compilation.
Integration of solc in package ethapi and cmd/abigen is now much simpler
because the compiler wrapper is no longer passed around as a pointer.
Fixes#2806, accidentally