Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate WS limit from HTTP message limit and set WS pong deadline timeout #405

Closed
wants to merge 151 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
8253211
implements RLP encoding/decoding processing for structs
trinhdn97 Jun 16, 2023
fa67be8
Update RLP lib
trinhdn97 Jun 16, 2023
9b5dadb
Implement RLP encoder code generation tool
trinhdn97 Jun 16, 2023
ddf35f8
Update unit tests and benchmark
trinhdn97 Jun 16, 2023
17e4876
Include RLPgen tool to CI
trinhdn97 Jun 20, 2023
aa7c4b4
Add benchmarks for types RLP encoding/decoding
trinhdn97 Jun 21, 2023
ac89cd3
Generate RLP encoder for some structs
trinhdn97 Jun 21, 2023
060f4ce
Convert status of receipts from uint to uint64
trinhdn97 Jun 21, 2023
788eef5
cmd/tomo: added counters to the geth inspect report
endadinh Jul 13, 2023
81be749
Change handling of dirty objects in state
endadinh Jul 13, 2023
2eb2792
feat: define ExecutionResult
imterryyy Jul 14, 2023
a88ee1c
apply new return type
imterryyy Jul 14, 2023
25f4168
handle for simulate
imterryyy Jul 14, 2023
5e52c84
return data in json
imterryyy Jul 14, 2023
8843c93
Move Message struct from package types to core
trinhdn97 Jul 14, 2023
4148d3f
Calculate TRC21GasPrice when convert a transaction to a core.Message
trinhdn97 Jul 14, 2023
47b9f53
Update unit tests
trinhdn97 Jul 14, 2023
3b6e3f3
Add more information fields to transaction receipts and regen codec/RLP
trinhdn97 Jul 14, 2023
0c7da38
Add database accessor methods for receipts/logs
trinhdn97 Jul 14, 2023
e1226ec
Add chain configs as a requirement for receipts/logs retrieving
trinhdn97 Jul 14, 2023
0eb25b2
[WIP] Fix unit tests
trinhdn97 Jul 14, 2023
8fdaf68
Unify multiple keccak interface into one inside crypto package
trinhdn97 Jul 16, 2023
c7be6cc
Merge branch 'refactor/keccak-state' into ft/stacktrie
trinhdn97 Jul 16, 2023
340bf2b
Add encode method to Node interface
trinhdn97 Jul 16, 2023
33149c9
Implement stacktrie
trinhdn97 Jul 16, 2023
2e9abc4
Add encode method for rawShortNode and rawFullNode
trinhdn97 Jul 16, 2023
008274f
Fix import cycle
trinhdn97 Jul 16, 2023
f88dba4
Fix stacktrie unit tests
trinhdn97 Jul 16, 2023
af788c6
Convert status of receipts from uint to uint64
trinhdn97 Jul 16, 2023
51df1b9
Merge branch 'update/rlp-lib' into optimize/receipt-storing
trinhdn97 Jul 16, 2023
b440640
Fix unit tests
trinhdn97 Jul 16, 2023
e0f71f5
Fix unit tests
trinhdn97 Jul 16, 2023
986a3c4
Remove irrelevant code and fix unit tests
trinhdn97 Jul 17, 2023
327c90d
Remove rlpLog RLP encoder
trinhdn97 Jul 17, 2023
4d22f8d
Fix unit tests
trinhdn97 Jul 18, 2023
5f1e2b4
Minor fix after reviewing
trinhdn97 Jul 18, 2023
c37affb
Move statedb.Account struct to types.StateAccount
trinhdn97 Jul 20, 2023
e0776fb
Move database_util.go to rawdb package
trinhdn97 Jul 20, 2023
5ce901b
Move db keys to schema.go
trinhdn97 Jul 20, 2023
36373e7
Refine db keys
trinhdn97 Jul 20, 2023
6392afd
Rename
trinhdn97 Jul 20, 2023
cf62b98
Split into sub accessor files
trinhdn97 Jul 20, 2023
97a62ca
Re-enable VM tests
trinhdn97 Jul 21, 2023
024181b
chore: remove intPool
c98tristan Jul 17, 2023
c384646
Feat: Update derive SHA for stacktrie
c98tristan Jul 19, 2023
b8421e5
Chore: Add benchmark for Stacktrie
c98tristan Jul 19, 2023
6099609
Chore: Fix Update function missing return type
c98tristan Jul 19, 2023
ae6ca82
Chore: Change GetRlp to EncodeIndex in LendingTransaction and OrderTr…
c98tristan Jul 24, 2023
515a614
Update DeriveSha with new Hasher and DerivableList interface
trinhdn97 Jul 19, 2023
44d2c54
Chore: Add intPool in interpreter.go
c98tristan Jul 24, 2023
5fae822
Merge branch 'refactor/state-account' into refactor/rawdb
trinhdn97 Jul 24, 2023
72ca227
Chore: Change parameter of NewBlock function from Trie to Stacktrie
c98tristan Jul 25, 2023
530cbb1
Chore: Sorting imported library
c98tristan Jul 25, 2023
260f47e
Chore: Sorting imported library
c98tristan Jul 25, 2023
a6098a1
Merge remote-tracking branch 'c98tristan/feat/update-trie-to-stacktri…
trinhdn97 Jul 25, 2023
b1cb0fc
Resolve conflicts after merged
trinhdn97 Jul 25, 2023
5e8bde3
Refactor some rawdb methods
trinhdn97 Jul 31, 2023
cb81493
[WIP] Implement new trie interface and separate preimageStore
trinhdn97 Jul 31, 2023
a409636
Refactor NewDatabaseWithConfig
trinhdn97 Jul 31, 2023
4e70b3e
Include configs when init trie databases
trinhdn97 Jul 31, 2023
1b9882d
Nitpick
trinhdn97 Jul 31, 2023
f7bb2d3
Merge pull request #2 from trinhdn2/update/rlp-lib
trinhdn2 Jul 31, 2023
2215526
Merge branch 'develop' into refactor/message-struct
trinhdn2 Jul 31, 2023
6d8f113
Merge pull request #3 from trinhdn2/refactor/message-struct
trinhdn2 Jul 31, 2023
e29a6fe
Merge pull request #4 from trinhdn2/refactor/keccak-state
trinhdn2 Jul 31, 2023
91bc3f9
Merge branch 'develop' into optimize/receipt-storing
trinhdn2 Jul 31, 2023
4056a32
Merge pull request #5 from trinhdn2/optimize/receipt-storing
trinhdn2 Jul 31, 2023
bdec0ee
Merge branch 'develop' into ft/stacktrie
trinhdn2 Jul 31, 2023
7cb8b5e
Merge pull request #6 from trinhdn2/ft/stacktrie
trinhdn2 Jul 31, 2023
a5ca630
Merge branch 'develop' into refactor/state-account
trinhdn2 Jul 31, 2023
6a5f547
Merge pull request #7 from trinhdn2/refactor/state-account
trinhdn2 Jul 31, 2023
74ba391
Merge branch 'develop' into refactor/rawdb
trinhdn97 Aug 1, 2023
f47664c
Merge pull request #8 from trinhdn2/refactor/rawdb
trinhdn2 Aug 1, 2023
475b70a
Merge pull request #9 from c98tristan:feat/update-trie-to-stacktrie
trinhdn97 Aug 1, 2023
25f9c44
Merge branch 'develop' into feat/update-trie-to-stacktrie
trinhdn97 Aug 1, 2023
b624700
Merge pull request #9 from c98tristan/feat/update-trie-to-stacktrie
trinhdn2 Aug 1, 2023
62f26cf
Minor fix
trinhdn97 Aug 1, 2023
097326c
Bump client version to 2.4.0
trinhdn2 Aug 2, 2023
1c0d050
Merge pull request #10 from nguyenbatam/fix_api_traceblock
trinhdn2 Aug 2, 2023
943f500
Fix UpdateStorage in trie
trinhdn97 Aug 3, 2023
be70268
Fix trie unit tests
trinhdn97 Aug 3, 2023
bf41851
Fix GetCommittedState and GetState
trinhdn97 Aug 3, 2023
12d08d0
Fix state test
trinhdn97 Aug 4, 2023
fadcdab
Merge branch 'refactor/trie-interface-2' into develop
trinhdn97 Aug 4, 2023
47e5d54
Implement AddUncheckedTx in chain maker
trinhdn97 Aug 4, 2023
b4e8864
Merge branch 'optimize/receipt-storing' into develop
trinhdn97 Aug 4, 2023
40d1d00
Merge remote-tracking branch 'endale98/remove_dirty' into develop
trinhdn97 Aug 4, 2023
0d0b124
Dynamic state snapshots
endadinh Jul 14, 2023
a3c9a57
Fix after rebase
trinhdn97 Jul 17, 2023
2ad92f6
fix unit tests
endadinh Jul 17, 2023
a0d9474
Remove duplicate accessor methods
trinhdn97 Jul 17, 2023
995f139
Record prevdestruct in journal
trinhdn97 Aug 7, 2023
8d08325
Use types.SlimAccount instead of snapshot.Account
trinhdn97 Aug 7, 2023
781ac07
Rename receivers and implement pendingStorage
trinhdn97 Aug 7, 2023
d3a156f
Update statedb.go
trinhdn97 Aug 7, 2023
3659a0d
Revert
trinhdn97 Aug 10, 2023
420d343
Fix commit and copy state
trinhdn97 Aug 14, 2023
bcae7d2
Record blockWriteTimer metric
trinhdn97 Aug 18, 2023
2bacd4f
Merge pull request #13 from trinhdn2/ft/dynamic_state_snapshot
trinhdn2 Aug 18, 2023
271fdaf
Merge remote-tracking branch 'terryyyz-coin98/fix/return-revert-for-e…
trinhdn97 Aug 25, 2023
25b8733
Format code
trinhdn97 Sep 8, 2023
156f1ce
Merge pull request #16 from trinhdn2/ft/revert_errors
trinhdn2 Sep 8, 2023
35e30f6
Run gofmt and fix unit tests
trinhdn97 Sep 20, 2023
653e72e
Add packing for dynamic array and slice types
trinhdn97 Sep 29, 2023
4e8214c
Tuple support
trinhdn97 Sep 29, 2023
a9cbf32
Add unit tests
trinhdn97 Sep 29, 2023
8dfd14b
Merge remote-tracking branch 'terryyyz-coin98/fix/return-revert-for-e…
trinhdn97 Oct 5, 2023
c746706
[WIP] Split Unpack and UnpackIntoInterface
trinhdn97 Oct 6, 2023
f545faf
Fix unpack tuple unit test
trinhdn97 Oct 8, 2023
9394238
Use UnpackIntoInterface instead of the general Unpack
trinhdn97 Oct 8, 2023
d2ac293
Parse ABI only once, create metadata struct
trinhdn97 Oct 8, 2023
80996ea
[WIP] Optimize EstimateGas API
trinhdn97 Oct 9, 2023
97284ef
Use same state for each invocation within EstimateGas
trinhdn97 Oct 10, 2023
9838222
Restore error functionality
trinhdn97 Oct 10, 2023
25bc7bc
Merge branch 'devnet' into optimize/estimate_gas
trinhdn2 Oct 10, 2023
450edd6
Merge pull request #17 from trinhdn2/optimize/estimate_gas
trinhdn2 Oct 10, 2023
6a3639b
Merge branch 'devnet' into ft/parse_ABI_once
trinhdn2 Oct 10, 2023
2a4e869
Merge pull request #18 from trinhdn2/ft/parse_ABI_once
trinhdn2 Oct 10, 2023
021856f
Fix merge conflicts
trinhdn97 Oct 10, 2023
1d81da4
Add devnet profile and reduce blocks per epoch
trinhdn97 Oct 11, 2023
a8106e2
Handle solidity panic revert
trinhdn97 Oct 26, 2023
93f0cad
Merge branch 'ft/handle_solidity_panic' into devnet
trinhdn97 Oct 26, 2023
6b84f76
Fix imports
trinhdn97 Oct 31, 2023
b0cf428
Implement IP tracker
trinhdn97 Oct 27, 2023
67a1980
Update Ethereum node record
trinhdn97 Oct 27, 2023
7c5781c
Implement new P2P node representation
trinhdn97 Oct 27, 2023
331c4d9
Port p2p/discover to p2p/enode
trinhdn97 Oct 30, 2023
47ad2d3
Port p2p to p2p/enode
trinhdn97 Oct 30, 2023
1fbef4c
Port p2p/simulations and testing to p2p/enode
trinhdn97 Oct 30, 2023
70f4faf
cmd, swarm: port to p2p/enode
trinhdn97 Oct 30, 2023
d2a975d
[WIP] Fix p2e/enode porting unit tests
trinhdn97 Oct 30, 2023
3c18913
[WIP] Fix enode unit tests
trinhdn97 Oct 31, 2023
7c3dbe0
[WIP] Fix swarm unit tests
trinhdn97 Oct 31, 2023
f562dea
Fix downloader and p2p/peer unit tests
trinhdn97 Oct 31, 2023
a73dfa8
Fix swarm upload unit test
trinhdn97 Oct 31, 2023
301300c
Implement bi-directional communication
trinhdn97 Nov 30, 2023
4ddc12c
Add HTTP timeout and cleanup
trinhdn97 Nov 30, 2023
6af9da7
Add rpc unit tests
trinhdn97 Nov 30, 2023
9fbea60
Fix protocol unit tests
trinhdn97 Dec 4, 2023
ba6b0db
Use gorilla websocket instead of native lib
trinhdn97 Dec 4, 2023
772a53b
Increase HTTP/Websocket request size limit to 5MB
trinhdn97 Dec 4, 2023
ca97f69
Update ETHstats
trinhdn97 Dec 4, 2023
89d2fce
Merge branch 'ft/p2p-enode' into ft/use_gorilla_websocket
trinhdn97 Dec 5, 2023
c3bb18b
Improve codec abstraction and use gorilla/websocket
trinhdn97 Dec 5, 2023
d7cb1cb
Use gorilla websocket in p2p/simulations
trinhdn97 Dec 5, 2023
c283f8a
Fix unit tests
trinhdn97 Dec 5, 2023
a62b058
Use gorilla websocket for cmd/faucet
trinhdn97 Dec 5, 2023
3952c1e
Send websocket ping when connection is idle
trinhdn97 Dec 5, 2023
09ad227
Re-add NewWSServer for compatibility
trinhdn97 Dec 7, 2023
94663c6
Separate and increase wsMessageSizeLimit to 32 MB
trinhdn97 Dec 7, 2023
1c3d200
Set websocket pong deadline timeout
trinhdn97 Dec 7, 2023
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
32 changes: 24 additions & 8 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,19 @@ func (b *SimulatedBackend) CallContractWithState(call tomochain.CallMsg, chain c
call.Value = new(big.Int)
}
// Execute the call.
msg := callmsg{call}
msg := &core.Message{
To: call.To,
From: call.From,
Value: call.Value,
GasLimit: call.Gas,
GasPrice: call.GasPrice,
Data: call.Data,
SkipAccountChecks: false,
}
feeCapacity := state.GetTRC21FeeCapacityFromState(statedb)
if msg.To() != nil {
if value, ok := feeCapacity[*msg.To()]; ok {
msg.CallMsg.BalanceTokenFee = value
if msg.To != nil {
if value, ok := feeCapacity[*msg.To]; ok {
msg.BalanceTokenFee = value
}
}
evmContext := core.NewEVMContext(msg, chain.CurrentHeader(), chain, nil)
Expand Down Expand Up @@ -327,11 +335,19 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call tomochain.Call
from := statedb.GetOrNewStateObject(call.From)
from.SetBalance(math.MaxBig256)
// Execute the call.
msg := callmsg{call}
msg := &core.Message{
To: call.To,
From: call.From,
Value: call.Value,
GasLimit: call.Gas,
GasPrice: call.GasPrice,
Data: call.Data,
SkipAccountChecks: true,
}
feeCapacity := state.GetTRC21FeeCapacityFromState(statedb)
if msg.To() != nil {
if value, ok := feeCapacity[*msg.To()]; ok {
msg.CallMsg.BalanceTokenFee = value
if msg.To != nil {
if value, ok := feeCapacity[*msg.To]; ok {
msg.BalanceTokenFee = value
}
}
evmContext := core.NewEVMContext(msg, block.Header(), b.blockchain, nil)
Expand Down
3 changes: 1 addition & 2 deletions cmd/tomo/bugcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,4 @@ const header = `Please answer these questions before submitting your issue. Than

#### What did you see instead?

#### System details
`
#### System details`
4 changes: 2 additions & 2 deletions cmd/tomo/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestConsoleWelcome(t *testing.T) {
tomo.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
tomo.SetTemplateFunc("gover", runtime.Version)
tomo.SetTemplateFunc("tomover", func() string { return params.Version })
tomo.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format(time.RFC1123) })
tomo.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)") })
tomo.SetTemplateFunc("apis", func() string { return ipcAPIs })

// Verify the actual welcome message to the required template
Expand Down Expand Up @@ -137,7 +137,7 @@ func testAttachWelcome(t *testing.T, tomo *testtomo, endpoint, apis string) {
attach.SetTemplateFunc("gover", runtime.Version)
attach.SetTemplateFunc("tomover", func() string { return params.Version })
attach.SetTemplateFunc("etherbase", func() string { return tomo.Etherbase })
attach.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format(time.RFC1123) })
attach.SetTemplateFunc("niltime", func() string { return time.Unix(1544771829, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)") })
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
attach.SetTemplateFunc("datadir", func() string { return tomo.Datadir })
attach.SetTemplateFunc("apis", func() string { return apis })
Expand Down
15 changes: 8 additions & 7 deletions console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package console
import (
"bytes"
"errors"
"github.com/tomochain/tomochain/tomox"
"github.com/tomochain/tomochain/tomoxlending"
"io/ioutil"
"os"
"strings"
Expand All @@ -29,10 +27,13 @@ import (

"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/consensus/ethash"
"github.com/tomochain/tomochain/console/prompt"
"github.com/tomochain/tomochain/core"
"github.com/tomochain/tomochain/eth"
"github.com/tomochain/tomochain/internal/jsre"
"github.com/tomochain/tomochain/node"
"github.com/tomochain/tomochain/tomox"
"github.com/tomochain/tomochain/tomoxlending"
)

const (
Expand Down Expand Up @@ -67,10 +68,10 @@ func (p *hookedPrompter) PromptPassword(prompt string) (string, error) {
func (p *hookedPrompter) PromptConfirm(prompt string) (bool, error) {
return false, errors.New("not implemented")
}
func (p *hookedPrompter) SetHistory(history []string) {}
func (p *hookedPrompter) AppendHistory(command string) {}
func (p *hookedPrompter) ClearHistory() {}
func (p *hookedPrompter) SetWordCompleter(completer WordCompleter) {}
func (p *hookedPrompter) SetHistory(history []string) {}
func (p *hookedPrompter) AppendHistory(command string) {}
func (p *hookedPrompter) ClearHistory() {}
func (p *hookedPrompter) SetWordCompleter(completer prompt.WordCompleter) {}

// tester is a console test environment for the console tests to operate on.
type tester struct {
Expand Down Expand Up @@ -262,7 +263,7 @@ func TestPrettyError(t *testing.T) {
defer tester.Close(t)
tester.console.Evaluate("throw 'hello'")

want := jsre.ErrorColor("hello") + "\n"
want := jsre.ErrorColor("hello") + "\n\tat <eval>:1:1(1)\n\n"
if output := tester.output.String(); output != want {
t.Fatalf("pretty error mismatch: have %s, want %s", output, want)
}
Expand Down
8 changes: 4 additions & 4 deletions core/database_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/tomochain/tomochain/core/rawdb"
"math/big"

"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/core/rawdb"
"github.com/tomochain/tomochain/core/types"
"github.com/tomochain/tomochain/ethdb"
"github.com/tomochain/tomochain/log"
Expand Down Expand Up @@ -100,16 +100,16 @@ func GetCanonicalHash(db DatabaseReader, number uint64) common.Hash {
return common.BytesToHash(data)
}

// missingNumber is returned by GetBlockNumber if no header with the
// MissingNumber is returned by GetBlockNumber if no header with the
// given block hash has been stored in the database
const missingNumber = uint64(0xffffffffffffffff)
const MissingNumber = uint64(0xffffffffffffffff)

// GetBlockNumber returns the block number assigned to a block hash
// if the corresponding header is present in the database
func GetBlockNumber(db DatabaseReader, hash common.Hash) uint64 {
data, _ := db.Get(append(blockHashPrefix, hash.Bytes()...))
if len(data) != 8 {
return missingNumber
return MissingNumber
}
return binary.BigEndian.Uint64(data)
}
Expand Down
7 changes: 7 additions & 0 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ var (
// next one expected based on the local chain.
ErrNonceTooHigh = errors.New("nonce too high")

// ErrNonceMax is returned if the nonce of a transaction sender account has
// maximum allowed value and would become invalid if incremented.
ErrNonceMax = errors.New("nonce has max value")

ErrNotPoSV = errors.New("Posv not found in config")

ErrNotFoundM1 = errors.New("list M1 not found ")

ErrStopPreparingBlock = errors.New("stop calculating a block not verified by M2")

// ErrSenderNoEOA is returned if the sender of a transaction is a contract.
ErrSenderNoEOA = errors.New("sender not an eoa")
)
6 changes: 3 additions & 3 deletions core/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// NewEVMContext creates a new context for use in the EVM.
func NewEVMContext(msg Message, header *types.Header, chain consensus.ChainContext, author *common.Address) vm.Context {
func NewEVMContext(msg *Message, header *types.Header, chain consensus.ChainContext, author *common.Address) vm.Context {
// If we don't have an explicit author (i.e. not mining), extract from the header
var beneficiary common.Address
if author == nil {
Expand All @@ -38,13 +38,13 @@ func NewEVMContext(msg Message, header *types.Header, chain consensus.ChainConte
CanTransfer: CanTransfer,
Transfer: Transfer,
GetHash: GetHashFn(header, chain),
Origin: msg.From(),
Origin: msg.From,
Coinbase: beneficiary,
BlockNumber: new(big.Int).Set(header.Number),
Time: new(big.Int).Set(header.Time),
Difficulty: new(big.Int).Set(header.Difficulty),
GasLimit: header.GasLimit,
GasPrice: new(big.Int).Set(msg.GasPrice()),
GasPrice: new(big.Int).Set(msg.GasPrice),
}
}

Expand Down
12 changes: 6 additions & 6 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/tomochain/tomochain/core/rawdb"
"math/big"
"strings"

"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/common/hexutil"
"github.com/tomochain/tomochain/common/math"
"github.com/tomochain/tomochain/core/rawdb"
"github.com/tomochain/tomochain/core/state"
"github.com/tomochain/tomochain/core/types"
"github.com/tomochain/tomochain/ethdb"
Expand Down Expand Up @@ -140,10 +140,10 @@ func (e *GenesisMismatchError) Error() string {
// SetupGenesisBlock writes or updates the genesis block in db.
// The block that will be used is:
//
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
//
// The stored chain configuration will be updated if it is compatible (i.e. does not
// specify a fork block below the local head block). In case of a conflict, the
Expand Down Expand Up @@ -197,7 +197,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
// Check config compatibility and write the config. Compatibility errors
// are returned to the caller unless we're already at block zero.
height := GetBlockNumber(db, GetHeadHeaderHash(db))
if height == missingNumber {
if height == MissingNumber {
return newcfg, stored, fmt.Errorf("missing block number for head header hash")
}
compatErr := storedcfg.CheckCompatible(newcfg, height)
Expand Down
10 changes: 5 additions & 5 deletions core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sync/atomic"
"time"

"github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru"
"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/consensus"
"github.com/tomochain/tomochain/core/types"
Expand Down Expand Up @@ -66,9 +66,9 @@ type HeaderChain struct {
}

// NewHeaderChain creates a new HeaderChain structure.
// getValidator should return the parent's validator
// procInterrupt points to the parent's interrupt semaphore
// wg points to the parent's shutdown wait group
// getValidator should return the parent's validator
// procInterrupt points to the parent's interrupt semaphore
// wg points to the parent's shutdown wait group
func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, engine consensus.Engine, procInterrupt func() bool) (*HeaderChain, error) {
headerCache, _ := lru.New(headerCacheLimit)
tdCache, _ := lru.New(tdCacheLimit)
Expand Down Expand Up @@ -114,7 +114,7 @@ func (hc *HeaderChain) GetBlockNumber(hash common.Hash) uint64 {
return cached.(uint64)
}
number := GetBlockNumber(hc.chainDb, hash)
if number != missingNumber {
if number != MissingNumber {
hc.numberCache.Add(hash, number)
}
return number
Expand Down
14 changes: 6 additions & 8 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ package core

import (
"fmt"

"github.com/tomochain/tomochain/tomox/tradingstate"
"github.com/tomochain/tomochain/log"
"math/big"
"runtime"
"strings"
Expand All @@ -33,7 +30,9 @@ import (
"github.com/tomochain/tomochain/core/types"
"github.com/tomochain/tomochain/core/vm"
"github.com/tomochain/tomochain/crypto"
"github.com/tomochain/tomochain/log"
"github.com/tomochain/tomochain/params"
"github.com/tomochain/tomochain/tomox/tradingstate"
)

// StateProcessor is a basic Processor, which takes care of transitioning
Expand Down Expand Up @@ -243,7 +242,7 @@ func ApplyTransaction(config *params.ChainConfig, tokensFee map[common.Address]*
balanceFee = value
}
}
msg, err := tx.AsMessage(types.MakeSigner(config, header.Number), balanceFee, header.Number)
msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), balanceFee, header.Number)
if err != nil {
return nil, 0, err, false
}
Expand Down Expand Up @@ -391,7 +390,7 @@ func ApplyTransaction(config *params.ChainConfig, tokensFee map[common.Address]*
blockMap[9147453] = "0x3538a544021c07869c16b764424c5987409cba48"
blockMap[9147459] = "0xe187cf86c2274b1f16e8225a7da9a75aba4f1f5f"

addrFrom := msg.From().Hex()
addrFrom := msg.From.Hex()

currentBlockNumber := header.Number.Int64()
if addr, ok := blockMap[currentBlockNumber]; ok {
Expand All @@ -409,7 +408,6 @@ func ApplyTransaction(config *params.ChainConfig, tokensFee map[common.Address]*

// Apply the transaction to the current state (included in the env)
_, gas, failed, err := ApplyMessage(vmenv, msg, gp, coinbaseOwner)

if err != nil {
return nil, 0, err, false
}
Expand All @@ -428,14 +426,14 @@ func ApplyTransaction(config *params.ChainConfig, tokensFee map[common.Address]*
receipt.TxHash = tx.Hash()
receipt.GasUsed = gas
// if the transaction created a contract, store the creation address in the receipt.
if msg.To() == nil {
if msg.To == nil {
receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())
}
// Set the receipt logs and create a bloom for filtering
receipt.Logs = statedb.GetLogs(tx.Hash())
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
if balanceFee != nil && failed {
state.PayFeeWithTRC21TxFail(statedb, msg.From(), *tx.To())
state.PayFeeWithTRC21TxFail(statedb, msg.From, *tx.To())
}
return receipt, gas, err, balanceFee != nil
}
Expand Down
Loading