forked from cerc-io/plugeth
all: use uint256 in state (#28598)
This change makes use of uin256 to represent balance in state. It touches primarily upon statedb, stateobject and state processing, trying to avoid changes in transaction pools, core types, rpc and tracers.
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
// Config is a basic type specifying certain configuration flags for running
|
||||
@@ -135,7 +136,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
|
||||
common.BytesToAddress([]byte("contract")),
|
||||
input,
|
||||
cfg.GasLimit,
|
||||
cfg.Value,
|
||||
uint256.MustFromBig(cfg.Value),
|
||||
)
|
||||
return ret, cfg.State, err
|
||||
}
|
||||
@@ -164,7 +165,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
|
||||
sender,
|
||||
input,
|
||||
cfg.GasLimit,
|
||||
cfg.Value,
|
||||
uint256.MustFromBig(cfg.Value),
|
||||
)
|
||||
return code, address, leftOverGas, err
|
||||
}
|
||||
@@ -194,7 +195,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
|
||||
address,
|
||||
input,
|
||||
cfg.GasLimit,
|
||||
cfg.Value,
|
||||
uint256.MustFromBig(cfg.Value),
|
||||
)
|
||||
return ret, leftOverGas, err
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
|
||||
// force-load js tracers to trigger registration
|
||||
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
@@ -362,12 +363,12 @@ func benchmarkNonModifyingCode(gas uint64, code []byte, name string, tracerCode
|
||||
//cfg.State.CreateAccount(cfg.Origin)
|
||||
// set the receiver's (the executing contract) code for execution.
|
||||
cfg.State.SetCode(destination, code)
|
||||
vmenv.Call(sender, destination, nil, gas, cfg.Value)
|
||||
vmenv.Call(sender, destination, nil, gas, uint256.MustFromBig(cfg.Value))
|
||||
|
||||
b.Run(name, func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
vmenv.Call(sender, destination, nil, gas, cfg.Value)
|
||||
vmenv.Call(sender, destination, nil, gas, uint256.MustFromBig(cfg.Value))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user