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

v2 #35

Closed
wants to merge 8 commits into from
Closed

v2 #35

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/**/*tx_database*
*/**/*dapps*
build/_vendor/pkg
data

#*
.#*
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ geth:
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."

start:; ./start.sh

all:
$(GORUN) build/ci.go install

Expand All @@ -35,4 +37,4 @@ devtools:
env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest
env GOBIN= go install ./cmd/abigen
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'
3 changes: 3 additions & 0 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ func (pool *LegacyPool) Init(gasTip *big.Int, head *types.Header, reserve txpool
statedb, err := pool.chain.StateAt(head.Root)
if err != nil {
statedb, err = pool.chain.StateAt(types.EmptyRootHash)
if err != nil {
statedb, err = pool.chain.StateAtBlockNumber(head.Number.Uint64())
}
}
if err != nil {
return err
Expand Down
54 changes: 54 additions & 0 deletions eth/api_miner_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package eth

import (
"errors"
"time"

"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/miner"
)

// BuildBlock is a convenience function to build a block.
func (s *MinerAPI) BuildBlock(attrs *miner.BuildPayloadArgs) (*engine.ExecutionPayloadEnvelope, error) {
// Send a request to generate a full block in the background.
// The result can be obtained via the returned channel.
args := &miner.BuildPayloadArgs{
Parent: attrs.Parent,
Timestamp: uint64(attrs.Timestamp),
FeeRecipient: attrs.FeeRecipient,
Random: attrs.Random,
Withdrawals: attrs.Withdrawals,
BeaconRoot: attrs.BeaconRoot,
}

payload, err := s.e.Miner().BuildPayload(args)
if err != nil {
log.Error("Failed to build payload", "err", err)
return nil, err
}

resCh := make(chan *engine.ExecutionPayloadEnvelope, 1)
go func() {
resCh <- payload.ResolveFull()
}()

timer := time.NewTimer(4 * time.Second)
defer timer.Stop()

select {
case payload := <-resCh:
if payload == nil {
return nil, errors.New("received nil payload from sealing work")
}
return payload, nil
case <-timer.C:
log.Error("timeout waiting for block", "parent hash", attrs.Parent)
return nil, errors.New("timeout waiting for block result")
}
}

func (s *MinerAPI) Etherbase() common.Address {
return s.e.etherbase
}
61 changes: 61 additions & 0 deletions genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"config": {
"chainId": 7,
"homesteadBlock": 0,
"daoForkBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"mergeNetsplitBlock": 0,
"shanghaiTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x20000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000658bdf435d810c91414ec09147daa6db624063790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x2fefd8",
"nonce": "0x0000000000000000",
"timestamp": "0x65307BE5",
"alloc": {
"20f33ce90a13a4b5e7697e3544c3083b8f8a51d4": {
"balance": "0x123450000000000000000"
},
"0161e041aad467a890839d5b08b138c1e6373072": {
"balance": "0x123450000000000000000"
},
"87da6a8c6e9eff15d703fc2773e32f6af8dbe301": {
"balance": "0x123450000000000000000"
},
"b97de4b8c857e4f6bc354f226dc3249aaee49209": {
"balance": "0x123450000000000000000"
},
"c5065c9eeebe6df2c2284d046bfc906501846c51": {
"balance": "0x123450000000000000000"
},
"0000000000000000000000000000000000000314": {
"balance": "0x0",
"code": "0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063abd1a0cf1461008d578063abfced1d146100d4578063e05c914a14610110578063e6768b451461014c575b610000565b346100005761007761019d565b6040518082815260200191505060405180910390f35b34610000576100be600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506101a3565b6040518082815260200191505060405180910390f35b346100005761010e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506101ed565b005b346100005761014a600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610236565b005b346100005761017960048080359060200190919080359060200190919080359060200190919050506103c4565b60405180848152602001838152602001828152602001935050505060405180910390f35b60005481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b919050565b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5050565b7f6031a8d62d7c95988fa262657cd92107d90ed96e08d8f867d32f26edfe85502260405180905060405180910390a17f47e2689743f14e97f7dcfa5eec10ba1dff02f83b3d1d4b9c07b206cbbda66450826040518082815260200191505060405180910390a1817fa48a6b249a5084126c3da369fbc9b16827ead8cb5cdc094b717d3f1dcd995e2960405180905060405180910390a27f7890603b316f3509577afd111710f9ebeefa15e12f72347d9dffd0d65ae3bade81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a18073ffffffffffffffffffffffffffffffffffffffff167f7efef9ea3f60ddc038e50cccec621f86a0195894dc0520482abf8b5c6b659e4160405180905060405180910390a28181604051808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a05b5050565b6000600060008585859250925092505b935093509390505600a165627a7a72305820aaf842d0d0c35c45622c5263cbb54813d2974d3999c8c38551d7c613ea2bc1170029",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x1234",
"0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9": "0x01"
},
"nonce": "0x1"
},
"0000000000000000000000000000000000000315": {
"balance": "0x9999999999999999999999999999999",
"code": "0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ef2769ca1461003e575b610000565b3461000057610078600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061007a565b005b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051809050600060405180830381858888f1935050505015610106578173ffffffffffffffffffffffffffffffffffffffff167f30a3c50752f2552dcc2b93f5b96866280816a986c0c0408cb6778b9fa198288f826040518082815260200191505060405180910390a25b5b50505600a165627a7a72305820637991fabcc8abad4294bf2bb615db78fbec4edff1635a2647d3894e2daf6a610029",
"nonce": "0x1"
}
}
}
1 change: 1 addition & 0 deletions jwt.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ba6d51b12d7854243e2f91fc66ea419fc587f7f78cc63e6f2925df1469962a60
1 change: 1 addition & 0 deletions jwt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abdf6f2f080ea59ce6874d72f1e801d25578dacde4e624a1f034bedd1be76a92
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
case head := <-w.chainHeadCh:
clearPending(head.Block.NumberU64())
timestamp = time.Now().Unix()
commit(commitInterruptNewHead)
// commit(commitInterruptNewHead)

case <-timer.C:
// If sealing is running resubmit a new work cycle periodically to pull in
Expand All @@ -467,7 +467,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timer.Reset(recommit)
continue
}
commit(commitInterruptResubmit)
// commit(commitInterruptResubmit)
}

case interval := <-w.resubmitIntervalCh:
Expand Down
1 change: 1 addition & 0 deletions password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password
6 changes: 6 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
make
rm -rf data
mkdir data
mkdir data/node1
./build/bin/geth --datadir data/node1/ init genesis.json
./build/bin/geth --datadir data/node1 --ipcdisable --port 30301 --networkid 7 --http --http.addr 'localhost' --http.port 8545 --http.api 'admin,engine,debug,eth,miner,net,personal,txpool,web3' --allow-insecure-unlock --syncmode full