Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions consensus/XDPoS/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type V2BlockInfo struct {
ParentHash common.Hash
Committed bool
Miner common.Hash
Timestamp *big.Int
Timestamp uint64
EncodedRLP string
Error string
}
Expand Down Expand Up @@ -297,7 +297,7 @@ func (api *API) GetV2BlockByHeader(header *types.Header, uncle bool) *V2BlockInf
Round: round,
Committed: committed,
Miner: header.Coinbase.Hash(),
Timestamp: new(big.Int).SetUint64(header.Time),
Timestamp: header.Time,
EncodedRLP: base64.StdEncoding.EncodeToString(encodeBytes),
}
return block
Expand Down
2 changes: 1 addition & 1 deletion core/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
GetHash: GetHashFn(header, chain),
Coinbase: beneficiary,
BlockNumber: new(big.Int).Set(header.Number),
Time: new(big.Int).SetUint64(header.Time),
Time: header.Time,
Difficulty: new(big.Int).Set(header.Difficulty),
BaseFee: baseFee,
GasLimit: header.GasLimit,
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type BlockContext struct {
Coinbase common.Address // Provides information for COINBASE
GasLimit uint64 // Provides information for GASLIMIT
BlockNumber *big.Int // Provides information for NUMBER
Time *big.Int // Provides information for TIME
Time uint64 // Provides information for TIME
Difficulty *big.Int // Provides information for DIFFICULTY
BaseFee *big.Int // Provides information for BASEFEE (0 if vm runs with NoBaseFee flag and 0 gas price)
Random *common.Hash // Provides information for PREVRANDAO
Expand Down
3 changes: 1 addition & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ func opCoinbase(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
}

func opTimestamp(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
v, _ := uint256.FromBig(interpreter.evm.Context.Time)
scope.Stack.push(v)
scope.Stack.push(new(uint256.Int).SetUint64(interpreter.evm.Context.Time))
return nil, nil
}

Expand Down
6 changes: 1 addition & 5 deletions core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package runtime
import (
"math"
"math/big"
"time"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
Expand All @@ -38,7 +37,7 @@ type Config struct {
Origin common.Address
Coinbase common.Address
BlockNumber *big.Int
Time *big.Int
Time uint64
GasLimit uint64
GasPrice *big.Int
Value *big.Int
Expand Down Expand Up @@ -77,9 +76,6 @@ func setDefaults(cfg *Config) {
if cfg.Difficulty == nil {
cfg.Difficulty = new(big.Int)
}
if cfg.Time == nil {
cfg.Time = big.NewInt(time.Now().Unix())
}
if cfg.GasLimit == 0 {
cfg.GasLimit = math.MaxUint64
}
Expand Down
5 changes: 1 addition & 4 deletions core/vm/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func TestDefaults(t *testing.T) {
t.Error("expected difficulty to be non nil")
}

if cfg.Time == nil {
t.Error("expected time to be non nil")
}
if cfg.GasLimit == 0 {
t.Error("didn't expect gaslimit to be zero")
}
Expand Down Expand Up @@ -171,7 +168,7 @@ func benchmarkEVM_Create(bench *testing.B, code string) {
State: statedb,
GasLimit: 10000000,
Difficulty: big.NewInt(0x200000),
Time: new(big.Int).SetUint64(0),
Time: 0,
Coinbase: common.Address{},
BlockNumber: new(big.Int).SetUint64(1),
ChainConfig: &params.ChainConfig{
Expand Down
6 changes: 3 additions & 3 deletions eth/tracers/testing/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
Transfer: core.Transfer,
Coinbase: test.Context.Miner,
BlockNumber: new(big.Int).SetUint64(uint64(test.Context.Number)),
Time: new(big.Int).SetUint64(uint64(test.Context.Time)),
Time: uint64(test.Context.Time),
Difficulty: (*big.Int)(test.Context.Difficulty),
GasLimit: uint64(test.Context.GasLimit),
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) {
Transfer: core.Transfer,
Coinbase: test.Context.Miner,
BlockNumber: new(big.Int).SetUint64(uint64(test.Context.Number)),
Time: new(big.Int).SetUint64(uint64(test.Context.Time)),
Time: uint64(test.Context.Time),
Difficulty: (*big.Int)(test.Context.Difficulty),
GasLimit: uint64(test.Context.GasLimit),
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func testContractTracer(tracerName string, dirPath string, t *testing.T) {
Transfer: core.Transfer,
Coinbase: test.Context.Miner,
BlockNumber: new(big.Int).SetUint64(uint64(test.Context.Number)),
Time: new(big.Int).SetUint64(uint64(test.Context.Time)),
Time: uint64(test.Context.Time),
Difficulty: (*big.Int)(test.Context.Difficulty),
GasLimit: uint64(test.Context.GasLimit),
}
Expand Down
6 changes: 3 additions & 3 deletions eth/tracers/tracers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestZeroValueToNotExitCall(t *testing.T) {
Transfer: core.Transfer,
Coinbase: common.Address{},
BlockNumber: new(big.Int).SetUint64(8000000),
Time: new(big.Int).SetUint64(5),
Time: 5,
Difficulty: big.NewInt(0x30000),
GasLimit: uint64(6000000),
}
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
Transfer: core.Transfer,
Coinbase: common.Address{},
BlockNumber: new(big.Int).SetUint64(8000000),
Time: new(big.Int).SetUint64(5),
Time: 5,
Difficulty: big.NewInt(0x30000),
GasLimit: uint64(6000000),
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
Transfer: core.Transfer,
Coinbase: common.Address{},
BlockNumber: new(big.Int).SetUint64(uint64(5)),
Time: new(big.Int).SetUint64(uint64(5)),
Time: 5,
Difficulty: big.NewInt(0xffffffff),
GasLimit: gas,
BaseFee: big.NewInt(8),
Expand Down
2 changes: 1 addition & 1 deletion tests/vm_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig vm.Config) *vm.EVM {
GetHash: vmTestBlockHash,
Coinbase: t.json.Env.Coinbase,
BlockNumber: new(big.Int).SetUint64(t.json.Env.Number),
Time: new(big.Int).SetUint64(t.json.Env.Timestamp),
Time: t.json.Env.Timestamp,
GasLimit: t.json.Env.GasLimit,
Difficulty: t.json.Env.Difficulty,
}
Expand Down