Skip to content

Commit

Permalink
further cleanup, unit tests for RPC daemon and tracing improvements (e…
Browse files Browse the repository at this point in the history
…rigontech#1392)

* Cleanup and rpcdaemon unit tests

* Fix

* Fix

* Fix lint

* Test for debug_traceTransaction

* Add NoRefunds option

* Compile fix, test for no refunds

* Fix compile

* Add poly contract, fix compile errors

* No refunds now work

* Fix NPE in rpcdaemon

Co-authored-by: Alexey Sharp <[email protected]>
  • Loading branch information
AlexeyAkhunov and Alexey Sharp authored Dec 9, 2020
1 parent 84304b2 commit 2cc36da
Show file tree
Hide file tree
Showing 35 changed files with 1,075 additions and 62 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
vmEnv := vm.NewEVM(evmContext, statedb, b.config, vm.Config{})
gasPool := new(core.GasPool).AddGas(math.MaxUint64)

return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb()
return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb(true /* refunds */)
}

// SendTransaction updates the pending block to include the given transaction.
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
}
snapshot := ibs.Snapshot()
// (ret []byte, usedGas uint64, failed bool, err error)
msgResult, err := core.ApplyMessage(evm, msg, gaspool)
msgResult, err := core.ApplyMessage(evm, msg, gaspool, true /* refunds */)
if err != nil {
ibs.RevertToSnapshot(snapshot)
log.Info("rejected tx", "index", i, "hash", tx.Hash(), "from", msg.From(), "error", err)
Expand Down
1 change: 0 additions & 1 deletion cmd/integration/commands/reset_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func resetState(db ethdb.Database, _ context.Context) error {
return err
}

core.UsePlainStateExecution = true
// don't reset senders here
if err := resetExec(db); err != nil {
return err
Expand Down
8 changes: 0 additions & 8 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ func silkwormExecutionFunc() unsafe.Pointer {
}

func stageExec(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true

sm, err := ethdb.GetStorageModeFromDB(db)
if err != nil {
panic(err)
Expand Down Expand Up @@ -390,7 +388,6 @@ func stageExec(db ethdb.Database, ctx context.Context) error {
}

func stageIHash(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

if err := migrations.NewMigrator().Apply(db, tmpdir); err != nil {
Expand Down Expand Up @@ -426,7 +423,6 @@ func stageIHash(db ethdb.Database, ctx context.Context) error {
}

func stageHashState(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

err := SetSnapshotKV(db, snapshotDir, snapshotMode)
Expand Down Expand Up @@ -458,7 +454,6 @@ func stageHashState(db ethdb.Database, ctx context.Context) error {
}

func stageLogIndex(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

_, bc, _, progress := newSync(ctx.Done(), db, db, nil)
Expand Down Expand Up @@ -488,7 +483,6 @@ func stageLogIndex(db ethdb.Database, ctx context.Context) error {
}

func stageCallTraces(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

_, bc, _, progress := newSync(ctx.Done(), db, db, nil)
Expand Down Expand Up @@ -536,7 +530,6 @@ func stageCallTraces(db ethdb.Database, ctx context.Context) error {
}

func stageHistory(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

err := SetSnapshotKV(db, snapshotDir, snapshotMode)
Expand Down Expand Up @@ -584,7 +577,6 @@ func stageHistory(db ethdb.Database, ctx context.Context) error {
}

func stageTxLookup(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true
tmpdir := path.Join(datadir, etl.TmpDirName)

err := SetSnapshotKV(db, snapshotDir, snapshotMode)
Expand Down
3 changes: 0 additions & 3 deletions cmd/integration/commands/state_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/common/changeset"
"github.com/ledgerwatch/turbo-geth/common/dbutils"
"github.com/ledgerwatch/turbo-geth/core"
"github.com/ledgerwatch/turbo-geth/core/state"
"github.com/ledgerwatch/turbo-geth/eth/stagedsync"
"github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages"
Expand Down Expand Up @@ -64,8 +63,6 @@ func init() {
}

func syncBySmallSteps(db ethdb.Database, ctx context.Context) error {
core.UsePlainStateExecution = true

sm, err := ethdb.GetStorageModeFromDB(db)
if err != nil {
panic(err)
Expand Down
1 change: 0 additions & 1 deletion cmd/pics/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ func initialState1() error {
}
db.Close()
// We reset the DB and use the generated blocks
core.UsePlainStateExecution = true
db = ethdb.NewMemDatabase()
kv = db.KV()
snapshotDB := db.MemCopy()
Expand Down
1 change: 1 addition & 0 deletions cmd/rpcdaemon/commands/contracts/build/Poly.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"d","type":"address"}],"name":"DeployEvent","type":"event"},{"inputs":[{"internalType":"uint256","name":"salt","type":"uint256"}],"name":"deploy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"salt","type":"uint256"}],"name":"deployAndDestruct","outputs":[],"stateMutability":"nonpayable","type":"function"}]
1 change: 1 addition & 0 deletions cmd/rpcdaemon/commands/contracts/build/Poly.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
608060405234801561001057600080fd5b506101d1806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80639debe9811461003b578063a5e387511461005a575b600080fd5b6100586004803603602081101561005157600080fd5b5035610077565b005b6100586004803603602081101561007057600080fd5b50356100fd565b6040805180820190915260138082527260606000534360015360ff60025360036000f360681b60208301908152600091849183f59050600080600080600085620186a0f150604080516001600160a01b038316815290517f68f6a0f063c25c6678c443b9a484086f15ba8f91f60218695d32a5251f2050eb9181900360200190a1505050565b6040805180820190915260138082527260606000534360015360ff60025360036000f360681b60208301908152600091849183f5604080516001600160a01b038316815290519192507f68f6a0f063c25c6678c443b9a484086f15ba8f91f60218695d32a5251f2050eb919081900360200190a150505056fea2646970667358221220c4436dde70fbebb14cf02477e4d8f270620c7f9f54b9b1a2e09b1edcc8c6db6764736f6c637827302e372e352d646576656c6f702e323032302e31322e392b636f6d6d69742e65623737656430380058
1 change: 1 addition & 0 deletions cmd/rpcdaemon/commands/contracts/build/Token.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
1 change: 1 addition & 0 deletions cmd/rpcdaemon/commands/contracts/build/Token.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
608060405234801561001057600080fd5b506040516102cd3803806102cd8339818101604052602081101561003357600080fd5b5051600280546001600160a01b0319166001600160a01b0390921691909117905561026a806100636000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063075461721461005c57806318160ddd1461008057806340c10f191461009a57806370a08231146100da578063a9059cbb14610100575b600080fd5b61006461012c565b604080516001600160a01b039092168252519081900360200190f35b61008861013b565b60408051918252519081900360200190f35b6100c6600480360360408110156100b057600080fd5b506001600160a01b038135169060200135610141565b604080519115158252519081900360200190f35b610088600480360360208110156100f057600080fd5b50356001600160a01b03166101b1565b6100c66004803603604081101561011657600080fd5b506001600160a01b0381351690602001356101c3565b6002546001600160a01b031681565b60005481565b6002546000906001600160a01b0316331461015b57600080fd5b6001600160a01b03831660009081526001602052604090205482810181111561018357600080fd5b6001600160a01b03841660009081526001602081905260408220928501909255805484019055905092915050565b60016020526000908152604090205481565b33600090815260016020526040808220546001600160a01b038516835290822054838210156101f157600080fd5b80848201101561020057600080fd5b336000908152600160208190526040808320948790039094556001600160a01b03969096168152919091209201909155509056fea2646970667358221220db4c7b3ba8d073604af68ade92006926639bb4003f2a18929524d580777155fb64736f6c63430007020033
4 changes: 4 additions & 0 deletions cmd/rpcdaemon/commands/contracts/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package contracts

//go:generate solc --allow-paths ., --abi --bin --overwrite --optimize -o build token.sol
//go:generate abigen -abi build/Token.abi -bin build/Token.bin -pkg contracts -type token -out ./gen_token.go
Loading

0 comments on commit 2cc36da

Please sign in to comment.