From 8d5f66b7ad9da6083c8aadafb2f3d00f97e0f553 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 28 Sep 2022 21:25:19 +0530 Subject: [PATCH 01/36] new: init pos-845 testcase --- tests/bor/bor_reorg_test.go | 161 +++++++++++++++++++++++++++++++ tests/bor/testdata/genesis3.json | 68 +++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 tests/bor/testdata/genesis3.json diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index a93ac6bf95..bafc1f4383 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -114,6 +114,26 @@ func initGenesis(t *testing.T, faucets []*ecdsa.PrivateKey) *core.Genesis { return genesis } +func initGenesis2(t *testing.T, faucets []*ecdsa.PrivateKey) *core.Genesis { + + // sprint size = 128 in genesis + genesisData, err := ioutil.ReadFile("./testdata/genesis3.json") + if err != nil { + t.Fatalf("%s", err) + } + + genesis := &core.Genesis{} + + if err := json.Unmarshal(genesisData, genesis); err != nil { + t.Fatalf("%s", err) + } + + genesis.Config.ChainID = big.NewInt(15001) + genesis.Config.EIP150Hash = common.Hash{} + + return genesis +} + func TestValidatorWentOffline(t *testing.T) { log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) @@ -276,3 +296,144 @@ func TestValidatorWentOffline(t *testing.T) { assert.Equal(t, authorVal1, nodes[0].AccountManager().Accounts()[0]) } + +// TODO: Need to find a better name +func TestForkWithTwoNodeNet(t *testing.T) { + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + fdlimit.Raise(2048) + + // Generate a batch of accounts to seal and fund with + faucets := make([]*ecdsa.PrivateKey, 128) + for i := 0; i < len(faucets); i++ { + faucets[i], _ = crypto.GenerateKey() + } + + // Create an Ethash network based off of the Ropsten config + genesis := initGenesis2(t, faucets) + + var ( + stacks []*node.Node + nodes []*eth.Ethereum + enodes []*enode.Node + ) + + for i := 0; i < 2; i++ { + // Start the node and wait until it's up + stack, ethBackend, err := initMiner(genesis, keys[i]) + if err != nil { + panic(err) + } + defer stack.Close() + + for stack.Server().NodeInfo().Ports.Listener == 0 { + time.Sleep(250 * time.Millisecond) + } + // Connect the node to all the previous ones + for _, n := range enodes { + stack.Server().AddPeer(n) + } + // Start tracking the node and its enode + stacks = append(stacks, stack) + nodes = append(nodes, ethBackend) + enodes = append(enodes, stack.Server().Self()) + } + + // Iterate over all the nodes and start mining + time.Sleep(3 * time.Second) + for _, node := range nodes { + if err := node.StartMining(1); err != nil { + panic(err) + } + } + + time.Sleep(700 * time.Second) + // check block 10 miner ; expected author is node1 signer + //blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(128) + //blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(128) + //authorVal0, err := nodes[0].Engine().Author(blockHeaderVal0) + /*if err != nil { + log.Error("Error in getting author", "err", err) + } + authorVal1, err := nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error in getting author", "err", err) + }*/ + + // check both nodes have the same block 10 + //assert.Equal(t, authorVal0, authorVal1) + + blockHeaderVal2 := nodes[0].BlockChain().GetHeaderByNumber(130) + blockHeaderVal3 := nodes[1].BlockChain().GetHeaderByNumber(130) + + assert.Equal(t, blockHeaderVal2.Hash(), blockHeaderVal3.Hash()) + assert.Equal(t, blockHeaderVal2.Time, blockHeaderVal3.Time) + // check node0 has block mined by node1 + /*assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) + + // check node1 has block mined by node1 + assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) + + // check block 11 miner ; expected author is node1 signer + blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(11) + blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(11) + authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) + if err != nil { + log.Error("Error in getting author", "err", err) + } + authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error in getting author", "err", err) + } + + // check both nodes have the same block 11 + assert.Equal(t, authorVal0, authorVal1) + + // check node0 has block mined by node1 + assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) + + // check node1 has block mined by node1 + assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) + + // check block 12 miner ; expected author is node1 signer + blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(12) + blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(12) + authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) + if err != nil { + log.Error("Error in getting author", "err", err) + } + authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error in getting author", "err", err) + } + + // check both nodes have the same block 12 + assert.Equal(t, authorVal0, authorVal1) + + // check node0 has block mined by node1 + assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) + + // check node1 has block mined by node1 + assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) + + // check block 17 miner ; expected author is node0 signer + blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(17) + blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(17) + authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) + if err != nil { + log.Error("Error in getting author", "err", err) + } + authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error in getting author", "err", err) + } + + // check both nodes have the same block 17 + assert.Equal(t, authorVal0, authorVal1) + + // check node0 has block mined by node1 + assert.Equal(t, authorVal0, nodes[0].AccountManager().Accounts()[0]) + + // check node1 has block mined by node1 + assert.Equal(t, authorVal1, nodes[0].AccountManager().Accounts()[0]) + */ +} diff --git a/tests/bor/testdata/genesis3.json b/tests/bor/testdata/genesis3.json new file mode 100644 index 0000000000..aad92477af --- /dev/null +++ b/tests/bor/testdata/genesis3.json @@ -0,0 +1,68 @@ +{ + "config": { + "chainId": 15001, + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "berlinBlock": 0, + "londonBlock": 1, + "bor": { + "jaipurBlock": 2, + "period": { + "0": 5, + "128": 2, + "256": 8 + }, + "producerDelay": 4, + "sprint": 128, + "backupMultiplier": { + "0": 5, + "128": 2, + "256": 8 + }, + "validatorContract": "0x0000000000000000000000000000000000001000", + "stateReceiverContract": "0x0000000000000000000000000000000000001001", + "burntContract": { + "0": "0x000000000000000000000000000000000000dead" + } + } + }, + "nonce": "0x0", + "timestamp": "0x5ce28211", + "extraData": "", + "gasLimit": "0x989680", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "0000000000000000000000000000000000001000": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a91908101906129ba565b610706565b60405161021e939291906132f9565b60405180910390f35b610241600480360361023c91908101906129ba565b61075d565b60405161024f92919061311a565b60405180910390f35b610272600480360361026d91908101906129e3565b610939565b60405161027f9190613151565b60405180910390f35b6102a2600480360361029d9190810190612ac2565b610a91565b005b6102be60048036036102b991908101906129e3565b61112a565b6040516102cb9190613151565b60405180910390f35b6102dc611281565b6040516102e991906132a7565b60405180910390f35b61030c60048036036103079190810190612917565b611286565b604051610319919061316c565b60405180910390f35b61033c600480360361033791908101906129ba565b611307565b60405161034991906132a7565b60405180910390f35b61035a611437565b60405161036791906130ff565b60405180910390f35b61038a60048036036103859190810190612953565b61144f565b6040516103979190613151565b60405180910390f35b6103a861151a565b6040516103b5919061316c565b60405180910390f35b6103d860048036036103d39190810190612a1f565b611531565b6040516103e591906132a7565b60405180910390f35b610408600480360361040391908101906129e3565b611619565b604051610415919061328c565b60405180910390f35b610426611781565b60405161043391906132a7565b60405180910390f35b6104566004803603610451919081019061289c565b611791565b6040516104639190613151565b60405180910390f35b610486600480360361048191908101906128c5565b6117ab565b604051610493919061316c565b60405180910390f35b6104a4611829565b6040516104b3939291906132f9565b60405180910390f35b6104c461189d565b6040516104d292919061311a565b60405180910390f35b6104e3611a04565b6040516104f091906132a7565b60405180910390f35b610513600480360361050e9190810190612a86565b611a09565b604051610522939291906132c2565b60405180910390f35b6105456004803603610540919081019061289c565b611a6d565b6040516105529190613151565b60405180910390f35b610563611a87565b604051610570919061316c565b60405180910390f35b610593600480360361058e91908101906129ba565b611a9e565b6040516105a091906132a7565b60405180910390f35b6105b1611bcf565b6040516105be919061316c565b60405180910390f35b6105cf611be6565b6040516105de939291906132f9565b60405180910390f35b61060160048036036105fc91908101906129ba565b611c47565b60405161060e91906132a7565b60405180910390f35b61061f611d47565b60405161062d92919061311a565b60405180910390f35b610650600480360361064b91908101906129ba565b611d5b565b60405161065d91906132a7565b60405180910390f35b61066e611d7c565b60405161067b9190613330565b60405180910390f35b61069e60048036036106999190810190612a86565b611d81565b6040516106ad939291906132c2565b60405180910390f35b6106be611de5565b6040516106cb91906132a7565b60405180910390f35b6106ee60048036036106e991908101906129ba565b611df7565b6040516106fd939291906132f9565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611c47565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a9061326c565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b30611e21565b5b610b4560018261214290919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d906131ec565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf9061324c565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c119061322c565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a906131cc565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc39061320c565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d669190612696565b506000600160008a815260200190815260200160002081610d879190612696565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612161565b61218f565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b602002602001015161218f565b90506000808c81526020019081526020016000208054809190600101610e349190612696565b506040518060600160405280610e5d83600081518110610e5057fe5b602002602001015161226c565b8152602001610e7f83600181518110610e7257fe5b602002602001015161226c565b8152602001610ea183600281518110610e9457fe5b60200260200101516122dd565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612161565b61218f565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b602002602001015161218f565b9050600160008d81526020019081526020016000208054809190600101610fff9190612696565b5060405180606001604052806110288360008151811061101b57fe5b602002602001015161226c565b815260200161104a8360018151811061103d57fe5b602002602001015161226c565b815260200161106c8360028151811061105f57fe5b60200260200101516122dd565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a39392919061306c565b6040516020818303038152906040526040516112bf91906130a9565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff91908101906128ee565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b6020026020010151602001518361214290919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b604051611526906130d5565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff166041612300565b90506000611585828961238c90919063ffffffff16565b905061158f6126c8565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb81602001518761214290919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b6116216126c8565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611c47565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c6929190613040565b6040516020818303038152906040526040516117e291906130a9565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061182291908101906128ee565b9050919050565b60008060008061184a600161183c611781565b61214290919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060026040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b5090507371562b71999873db5b286df957af199ec94617f7816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050739fb29aac15b9a4b7f17c3385939b007540f4d7918160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050606060026040519080825280602002602001820160405280156119bf5781602001602082028038833980820191505090505b5090506028816000815181106119d157fe5b602002602001018181525050601e816001815181106119ec57fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611a2257fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611a80611a7a611781565b83610939565b9050919050565b604051611a93906130c0565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611b71578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611ad5565b505050509050600080905060008090505b8251811015611bc457611bb5838281518110611b9a57fe5b6020026020010151602001518361214290919063ffffffff16565b91508080600101915050611b82565b508092505050919050565b604051611bdb906130ea565b604051809103902081565b600080600080611bf4611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611d0757611c646126ff565b6002600060036001850381548110611c7857fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611cd557506000816040015114155b8015611ce5575080604001518411155b15611cf857806000015192505050611d42565b50808060019003915050611c53565b5060006003805490501115611d3d57600360016003805490500381548110611d2b57fe5b90600052602060002001549050611d42565b600090505b919050565b606080611d534361075d565b915091509091565b60038181548110611d6857fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611d9a57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060404381611df157fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b606080611e2c61189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff815250600260008381526020019081526020016000206000820151816000015560208201518160010155604082015181600201559050506003819080600181540180825580915050906001820390600052602060002001600090919290919091505550600080600083815260200190815260200160002081611ed59190612696565b5060006001600083815260200190815260200160002081611ef69190612696565b5060008090505b8351811015612018576000808381526020019081526020016000208054809190600101611f2a9190612696565b506040518060600160405280828152602001848381518110611f4857fe5b60200260200101518152602001858381518110611f6157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168152506000808481526020019081526020016000208281548110611f9f57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050611efd565b5060008090505b835181101561213c5760016000838152602001908152602001600020805480919060010161204d9190612696565b50604051806060016040528082815260200184838151811061206b57fe5b6020026020010151815260200185838151811061208457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168152506001600084815260200190815260200160002082815481106120c357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050808060010191505061201f565b50505050565b60008082840190508381101561215757600080fd5b8091505092915050565b612169612720565b600060208301905060405180604001604052808451815260200182815250915050919050565b606061219a82612496565b6121a357600080fd5b60006121ae836124e4565b90506060816040519080825280602002602001820160405280156121ec57816020015b6121d961273a565b8152602001906001900390816121d15790505b50905060006121fe8560200151612555565b8560200151019050600080600090505b8481101561225f5761221f836125de565b915060405180604001604052808381526020018481525084828151811061224257fe5b60200260200101819052508183019250808060010191505061220e565b5082945050505050919050565b600080826000015111801561228657506021826000015111155b61228f57600080fd5b600061229e8360200151612555565b905060008184600001510390506000808386602001510190508051915060208310156122d157826020036101000a820491505b81945050505050919050565b600060158260000151146122f057600080fd5b6122f98261226c565b9050919050565b60608183018451101561231257600080fd5b606082156000811461232f57604051915060208201604052612380565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561236d5780518352602083019250602081019050612350565b50868552601f19601f8301166040525050505b50809150509392505050565b60008060008060418551146123a75760009350505050612490565b602085015192506040850151915060ff6041860151169050601b8160ff1610156123d257601b810190505b601b8160ff16141580156123ea5750601c8160ff1614155b156123fb5760009350505050612490565b6000600187838686604051600081526020016040526040516124209493929190613187565b6020604051602081039080840390855afa158015612442573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561248857600080fd5b809450505050505b92915050565b600080826000015114156124ad57600090506124df565b60008083602001519050805160001a915060c060ff168260ff1610156124d8576000925050506124df565b6001925050505b919050565b600080826000015114156124fb5760009050612550565b6000809050600061250f8460200151612555565b84602001510190506000846000015185602001510190505b8082101561254957612538826125de565b820191508280600101935050612527565b8293505050505b919050565b600080825160001a9050608060ff168110156125755760009150506125d9565b60b860ff1681108061259a575060c060ff168110158015612599575060f860ff1681105b5b156125a95760019150506125d9565b60c060ff168110156125c95760018060b80360ff168203019150506125d9565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff168110156125ff576001915061268c565b60b860ff1681101561261c576001608060ff16820301915061268b565b60c060ff1681101561264c5760b78103600185019450806020036101000a8551046001820181019350505061268a565b60f860ff1681101561266957600160c060ff168203019150612689565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b8154818355818111156126c3576003028160030283600052602060002091820191016126c29190612754565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b6127a791905b808211156127a35760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060030161275a565b5090565b90565b6000813590506127b981613529565b92915050565b6000813590506127ce81613540565b92915050565b6000815190506127e381613540565b92915050565b60008083601f8401126127fb57600080fd5b8235905067ffffffffffffffff81111561281457600080fd5b60208301915083600182028301111561282c57600080fd5b9250929050565b600082601f83011261284457600080fd5b813561285761285282613378565b61334b565b9150808252602083016020830185838301111561287357600080fd5b61287e8382846134d3565b50505092915050565b60008135905061289681613557565b92915050565b6000602082840312156128ae57600080fd5b60006128bc848285016127aa565b91505092915050565b6000602082840312156128d757600080fd5b60006128e5848285016127bf565b91505092915050565b60006020828403121561290057600080fd5b600061290e848285016127d4565b91505092915050565b6000806040838503121561292a57600080fd5b6000612938858286016127bf565b9250506020612949858286016127bf565b9150509250929050565b60008060006060848603121561296857600080fd5b6000612976868287016127bf565b9350506020612987868287016127bf565b925050604084013567ffffffffffffffff8111156129a457600080fd5b6129b086828701612833565b9150509250925092565b6000602082840312156129cc57600080fd5b60006129da84828501612887565b91505092915050565b600080604083850312156129f657600080fd5b6000612a0485828601612887565b9250506020612a15858286016127aa565b9150509250929050565b600080600060608486031215612a3457600080fd5b6000612a4286828701612887565b9350506020612a53868287016127bf565b925050604084013567ffffffffffffffff811115612a7057600080fd5b612a7c86828701612833565b9150509250925092565b60008060408385031215612a9957600080fd5b6000612aa785828601612887565b9250506020612ab885828601612887565b9150509250929050565b600080600080600080600060a0888a031215612add57600080fd5b6000612aeb8a828b01612887565b9750506020612afc8a828b01612887565b9650506040612b0d8a828b01612887565b955050606088013567ffffffffffffffff811115612b2a57600080fd5b612b368a828b016127e9565b9450945050608088013567ffffffffffffffff811115612b5557600080fd5b612b618a828b016127e9565b925092505092959891949750929550565b6000612b7e8383612ba2565b60208301905092915050565b6000612b968383613013565b60208301905092915050565b612bab81613448565b82525050565b612bba81613448565b82525050565b6000612bcb826133c4565b612bd581856133ff565b9350612be0836133a4565b8060005b83811015612c11578151612bf88882612b72565b9750612c03836133e5565b925050600181019050612be4565b5085935050505092915050565b6000612c29826133cf565b612c338185613410565b9350612c3e836133b4565b8060005b83811015612c6f578151612c568882612b8a565b9750612c61836133f2565b925050600181019050612c42565b5085935050505092915050565b612c858161345a565b82525050565b612c9c612c9782613466565b613515565b82525050565b612cab81613492565b82525050565b612cc2612cbd82613492565b61351f565b82525050565b6000612cd3826133da565b612cdd8185613421565b9350612ced8185602086016134e2565b80840191505092915050565b6000612d0660048361343d565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612d46602d8361342c565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000612dac600f8361343d565b91507f6865696d64616c6c2d50357258776700000000000000000000000000000000006000830152600f82019050919050565b6000612dec600f8361342c565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000612e2c60138361342c565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b6000612e6c60458361342c565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000612ef8602a8361342c565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b6000612f5e60058361343d565b91507f31353030310000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000612f9e60128361342c565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b606082016000820151612fe76000850182613013565b506020820151612ffa6020850182613013565b50604082015161300d6040850182612ba2565b50505050565b61301c816134bc565b82525050565b61302b816134bc565b82525050565b61303a816134c6565b82525050565b600061304c8285612c8b565b60018201915061305c8284612cb1565b6020820191508190509392505050565b60006130788286612c8b565b6001820191506130888285612cb1565b6020820191506130988284612cb1565b602082019150819050949350505050565b60006130b58284612cc8565b915081905092915050565b60006130cb82612cf9565b9150819050919050565b60006130e082612d9f565b9150819050919050565b60006130f582612f51565b9150819050919050565b60006020820190506131146000830184612bb1565b92915050565b600060408201905081810360008301526131348185612bc0565b905081810360208301526131488184612c1e565b90509392505050565b60006020820190506131666000830184612c7c565b92915050565b60006020820190506131816000830184612ca2565b92915050565b600060808201905061319c6000830187612ca2565b6131a96020830186613031565b6131b66040830185612ca2565b6131c36060830184612ca2565b95945050505050565b600060208201905081810360008301526131e581612d39565b9050919050565b6000602082019050818103600083015261320581612ddf565b9050919050565b6000602082019050818103600083015261322581612e1f565b9050919050565b6000602082019050818103600083015261324581612e5f565b9050919050565b6000602082019050818103600083015261326581612eeb565b9050919050565b6000602082019050818103600083015261328581612f91565b9050919050565b60006060820190506132a16000830184612fd1565b92915050565b60006020820190506132bc6000830184613022565b92915050565b60006060820190506132d76000830186613022565b6132e46020830185613022565b6132f16040830184612bb1565b949350505050565b600060608201905061330e6000830186613022565b61331b6020830185613022565b6133286040830184613022565b949350505050565b60006020820190506133456000830184613031565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561336e57600080fd5b8060405250919050565b600067ffffffffffffffff82111561338f57600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006134538261349c565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b838110156135005780820151818401526020810190506134e5565b8381111561350f576000848401525b50505050565b6000819050919050565b6000819050919050565b61353281613448565b811461353d57600080fd5b50565b61354981613492565b811461355457600080fd5b50565b613560816134bc565b811461356b57600080fd5b5056fea365627a7a7231582051bf0a46b5958c4ecdf9f1f9a9d8b62deacac5d79cdf5595e9853f3c0132fe236c6578706572696d656e74616cf564736f6c63430005110040" + }, + "0000000000000000000000000000000000001001": { + "balance": "0x0", + "code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a72315820af228b81e19dac46d14c24d264bde25d8a461d559c4e3cc82a5f1660755df35e64736f6c63430005110032" + }, + "0000000000000000000000000000000000001010": { + "balance": "0x204fcdf1d291a6d552c00000", + "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a3565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116a9565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611736565b005b348015610b2e57600080fd5b50610b37611753565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa828488611779565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3690919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f046023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5690919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ee16023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b75565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600281526020017f3a9900000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c7338484611779565b90505b92915050565b6040518060800160405280605b8152602001611f79605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6d565b611d43565b9050949350505050565b613a9981565b60015481565b604051806080016040528060528152602001611f27605291396040516020018082805190602001908083835b602083106116f857805182526020820191506020810190506020830392506116d5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173e6114dd565b61174757600080fd5b61175081611b75565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117f957600080fd5b505afa15801561180d573d6000803e3d6000fd5b505050506040513d602081101561182357600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b557600080fd5b505afa1580156118c9573d6000803e3d6000fd5b505050506040513d60208110156118df57600080fd5b810190808051906020019092919050505090506118fd868686611d8d565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0557600080fd5b505afa158015611a19573d6000803e3d6000fd5b505050506040513d6020811015611a2f57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abd57600080fd5b505afa158015611ad1573d6000803e3d6000fd5b505050506040513d6020811015611ae757600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4557600080fd5b600082840390508091505092915050565b600080828401905083811015611b6b57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611baf57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611f79605b91396040516020018082805190602001908083835b60208310611cbf5780518252602082019150602081019050602083039250611c9c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e2f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611e75573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a723158205723157ad1c8ebb37fecace5dc0ce2dfa893ec59d46a1305ad694cd0170076ab64736f6c63430005110032" + }, + "71562b71999873DB5b286dF957af199Ec94617F7": { + "balance": "0x3635c9adc5dea00000" + }, + "9fB29AAc15b9A4B7F17c3385939b007540f4d791": { + "balance": "0x3635c9adc5dea00000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + \ No newline at end of file From 5b324f4b8445050f7f0fae99a6950724dbaa353d Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 29 Sep 2022 11:15:56 +0530 Subject: [PATCH 02/36] new: add some more checks --- tests/bor/bor_reorg_test.go | 103 +++++++----------------------------- 1 file changed, 19 insertions(+), 84 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index bafc1f4383..c2f6e2cb57 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -347,93 +347,28 @@ func TestForkWithTwoNodeNet(t *testing.T) { } time.Sleep(700 * time.Second) - // check block 10 miner ; expected author is node1 signer - //blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(128) - //blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(128) - //authorVal0, err := nodes[0].Engine().Author(blockHeaderVal0) - /*if err != nil { - log.Error("Error in getting author", "err", err) - } - authorVal1, err := nodes[1].Engine().Author(blockHeaderVal1) + + // Before the end of sprint + blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(120) + blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(120) + assert.Equal(t, blockHeaderVal0.Hash(), blockHeaderVal1.Hash()) + assert.Equal(t, blockHeaderVal0.Time, blockHeaderVal1.Time) + + author0, err := nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error in getting author", "err", err) - }*/ - - // check both nodes have the same block 10 - //assert.Equal(t, authorVal0, authorVal1) + log.Error("Error occured while fetching author", "err", err) + } + author1, err := nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error occured while fetching author", "err", err) + } + assert.Equal(t, author0, author1) + // After the end of sprint + // FIXME: POS-845 blockHeaderVal2 := nodes[0].BlockChain().GetHeaderByNumber(130) blockHeaderVal3 := nodes[1].BlockChain().GetHeaderByNumber(130) + assert.NotEqual(t, blockHeaderVal2.Hash(), blockHeaderVal3.Hash()) + assert.NotEqual(t, blockHeaderVal2.Time, blockHeaderVal3.Time) - assert.Equal(t, blockHeaderVal2.Hash(), blockHeaderVal3.Hash()) - assert.Equal(t, blockHeaderVal2.Time, blockHeaderVal3.Time) - // check node0 has block mined by node1 - /*assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) - - // check node1 has block mined by node1 - assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) - - // check block 11 miner ; expected author is node1 signer - blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(11) - blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(11) - authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) - if err != nil { - log.Error("Error in getting author", "err", err) - } - authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) - if err != nil { - log.Error("Error in getting author", "err", err) - } - - // check both nodes have the same block 11 - assert.Equal(t, authorVal0, authorVal1) - - // check node0 has block mined by node1 - assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) - - // check node1 has block mined by node1 - assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) - - // check block 12 miner ; expected author is node1 signer - blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(12) - blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(12) - authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) - if err != nil { - log.Error("Error in getting author", "err", err) - } - authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) - if err != nil { - log.Error("Error in getting author", "err", err) - } - - // check both nodes have the same block 12 - assert.Equal(t, authorVal0, authorVal1) - - // check node0 has block mined by node1 - assert.Equal(t, authorVal0, nodes[1].AccountManager().Accounts()[0]) - - // check node1 has block mined by node1 - assert.Equal(t, authorVal1, nodes[1].AccountManager().Accounts()[0]) - - // check block 17 miner ; expected author is node0 signer - blockHeaderVal0 = nodes[0].BlockChain().GetHeaderByNumber(17) - blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(17) - authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) - if err != nil { - log.Error("Error in getting author", "err", err) - } - authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) - if err != nil { - log.Error("Error in getting author", "err", err) - } - - // check both nodes have the same block 17 - assert.Equal(t, authorVal0, authorVal1) - - // check node0 has block mined by node1 - assert.Equal(t, authorVal0, nodes[0].AccountManager().Accounts()[0]) - - // check node1 has block mined by node1 - assert.Equal(t, authorVal1, nodes[0].AccountManager().Accounts()[0]) - */ } From 09e62ca35c303e45ecad89df6dccbe7ebf8ac7a0 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 29 Sep 2022 12:15:29 +0530 Subject: [PATCH 03/36] new: assert block authors --- tests/bor/bor_reorg_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index c2f6e2cb57..da5bde8ffd 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -371,4 +371,14 @@ func TestForkWithTwoNodeNet(t *testing.T) { assert.NotEqual(t, blockHeaderVal2.Hash(), blockHeaderVal3.Hash()) assert.NotEqual(t, blockHeaderVal2.Time, blockHeaderVal3.Time) + author2, err := nodes[0].Engine().Author(blockHeaderVal2) + if err != nil { + log.Error("Error occured while fetching author", "err", err) + } + author3, err := nodes[1].Engine().Author(blockHeaderVal3) + if err != nil { + log.Error("Error occured while fetching author", "err", err) + } + assert.NotEqual(t, author2, author3) + } From 1022d309b70c46e038197d17c88d8cbd774805c1 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Tue, 4 Oct 2022 21:54:47 +0530 Subject: [PATCH 04/36] make script OS independent (#538) --- scripts/getconfig.sh | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/scripts/getconfig.sh b/scripts/getconfig.sh index 26d5d0138c..943d540a88 100755 --- a/scripts/getconfig.sh +++ b/scripts/getconfig.sh @@ -1,10 +1,19 @@ #!/usr/bin/env sh +set -e # Instructions: # Execute `./getconfig.sh`, and follow the instructions displayed on the terminal # The `*-config.toml` file will be created in the same directory as start.sh # It is recommended to check the flags generated in config.toml +# Some checks to make commands OS independent +OS="$(uname -s)" +MKTEMPOPTION= +SEDOPTION= ## Not used as of now (TODO) +shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + SEDOPTION="''" + MKTEMPOPTION="-t" +fi read -p "* Path to start.sh: " startPath # check if start.sh is present @@ -15,7 +24,7 @@ then fi read -p "* Your validator address (e.g. 0xca67a8D767e45056DC92384b488E9Af654d78DE2), or press Enter to skip if running a sentry node: " ADD -echo "\nThank you, your inputs are:" +printf "\nThank you, your inputs are:\n" echo "Path to start.sh: "$startPath echo "Address: "$ADD @@ -26,8 +35,9 @@ if [[ -f $confPath ]] then echo "WARN: config.toml exists, data will be overwritten." fi +printf "\n" -tmpDir="$(mktemp -d -t ./temp-dir-XXXXXXXXXXX || oops "Can't create temporary directory")" +tmpDir="$(mktemp -d $MKTEMPOPTION ./temp-dir-XXXXXXXXXXX || oops "Can't create temporary directory")" cleanup() { rm -rf "$tmpDir" } @@ -39,8 +49,11 @@ chmod +x $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh $ADD rm $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh - -sed -i '' "s%*%'*'%g" ./temp +shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%*%'*'%g" ./temp +else + sed -i "s%*%'*'%g" ./temp +fi # read the flags from `./temp` dumpconfigflags=$(head -1 ./temp) @@ -51,17 +64,27 @@ bash -c "$command" rm ./temp +printf "\n" + if [[ -f ./tempStaticNodes.json ]] then echo "JSON StaticNodes found" staticnodesjson=$(head -1 ./tempStaticNodes.json) - sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodesjson}\"\]%" $confPath + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodesjson}\"\]%" $confPath + else + sed -i "s%static-nodes = \[\]%static-nodes = \[\"${staticnodesjson}\"\]%" $confPath + fi rm ./tempStaticNodes.json elif [[ -f ./tempStaticNodes.toml ]] then echo "TOML StaticNodes found" staticnodestoml=$(head -1 ./tempStaticNodes.toml) - sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodestoml}\"\]%" $confPath + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%static-nodes = \[\]%static-nodes = \[\"${staticnodestoml}\"\]%" $confPath + else + sed -i "s%static-nodes = \[\]%static-nodes = \[\"${staticnodestoml}\"\]%" $confPath + fi rm ./tempStaticNodes.toml else echo "neither JSON nor TOML StaticNodes found" @@ -71,12 +94,18 @@ if [[ -f ./tempTrustedNodes.toml ]] then echo "TOML TrustedNodes found" trustednodestoml=$(head -1 ./tempTrustedNodes.toml) - sed -i '' "s%trusted-nodes = \[\]%trusted-nodes = \[\"${trustednodestoml}\"\]%" $confPath + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%trusted-nodes = \[\]%trusted-nodes = \[\"${trustednodestoml}\"\]%" $confPath + else + sed -i "s%trusted-nodes = \[\]%trusted-nodes = \[\"${trustednodestoml}\"\]%" $confPath + fi rm ./tempTrustedNodes.toml else echo "neither JSON nor TOML TrustedNodes found" fi +printf "\n" + # comment flags in $configPath that were not passed through $startPath # SHA1 hash of `tempStart` -> `3305fe263dd4a999d58f96deb064e21bb70123d9` sed "s%bor --%go run getconfig.go ${confPath} --%" $startPath > $tmpDir/3305fe263dd4a999d58f96deb064e21bb70123d9.sh From 54f97b8598074bd5bb956add1afdef59c99e92c1 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Wed, 5 Oct 2022 23:38:19 +0530 Subject: [PATCH 05/36] internal/cli: add support for bor.logs flag in new-cli (#541) * add support for bor.logs flag in new-cli * handle bor.withoutheimdall flag commenting in conversion script --- builder/files/config.toml | 3 ++- docs/cli/removedb.md | 4 +++- docs/cli/server.md | 10 +++++++--- internal/cli/server/config.go | 8 +++++++- internal/cli/server/flags.go | 10 ++++++++-- scripts/getconfig.go | 4 +++- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/builder/files/config.toml b/builder/files/config.toml index ce9fd782d0..0d01f85d71 100644 --- a/builder/files/config.toml +++ b/builder/files/config.toml @@ -10,6 +10,7 @@ datadir = "/var/lib/bor/data" syncmode = "full" # gcmode = "full" # snapshot = true +# "bor.logs" = false # ethstats = "" # ["eth.requiredblocks"] @@ -134,4 +135,4 @@ syncmode = "full" # [developer] # dev = false - # period = 0 \ No newline at end of file + # period = 0 diff --git a/docs/cli/removedb.md b/docs/cli/removedb.md index 3c6e84f1d6..473d47ecef 100644 --- a/docs/cli/removedb.md +++ b/docs/cli/removedb.md @@ -4,4 +4,6 @@ The ```bor removedb``` command will remove the blockchain and state databases at ## Options -- ```datadir```: Path of the data directory to store information +- ```address```: Address of the grpc endpoint + +- ```datadir```: Path of the data directory to store information \ No newline at end of file diff --git a/docs/cli/server.md b/docs/cli/server.md index ac43555275..5fe440b5fd 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -16,18 +16,22 @@ The ```bor server``` command runs the Bor client. - ```config```: File for the config file -- ```syncmode```: Blockchain sync mode ("fast", "full", or "snap") +- ```syncmode```: Blockchain sync mode (only "full" sync supported) - ```gcmode```: Blockchain garbage collection mode ("full", "archive") -- ```requiredblocks```: Comma separated block number-to-hash mappings to enforce (=) +- ```eth.requiredblocks```: Comma separated block number-to-hash mappings to require for peering (=) -- ```snapshot```: Disables/Enables the snapshot-database mode (default = true) +- ```snapshot```: Enables the snapshot-database mode (default = true) + +- ```bor.logs```: Enables bor log retrieval (default = false) - ```bor.heimdall```: URL of Heimdall service - ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) +- ```bor.heimdallgRPC```: Address of Heimdall gRPC service + - ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port) - ```gpo.blocks```: Number of recent blocks to check for gas prices diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index b25b620dd8..e5e3a8b03e 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -62,9 +62,12 @@ type Config struct { // GcMode selects the garbage collection mode for the trie GcMode string `hcl:"gcmode,optional" toml:"gcmode,optional"` - // Snapshot disables/enables the snapshot database mode + // Snapshot enables the snapshot database mode Snapshot bool `hcl:"snapshot,optional" toml:"snapshot,optional"` + // BorLogs enables bor log retrieval + BorLogs bool `hcl:"bor.logs,optional" toml:"bor.logs,optional"` + // Ethstats is the address of the ethstats server to send telemetry Ethstats string `hcl:"ethstats,optional" toml:"ethstats,optional"` @@ -420,6 +423,7 @@ func DefaultConfig() *Config { SyncMode: "full", GcMode: "full", Snapshot: true, + BorLogs: false, TxPool: &TxPoolConfig{ Locals: []string{}, NoLocals: false, @@ -649,6 +653,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* n.NetworkId = c.chain.NetworkId n.Genesis = c.chain.Genesis } + n.HeimdallURL = c.Heimdall.URL n.WithoutHeimdall = c.Heimdall.Without n.HeimdallgRPCAddress = c.Heimdall.GRPCAddress @@ -881,6 +886,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* } } + n.BorLogs = c.BorLogs n.DatabaseHandles = dbHandles return &n, nil diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 82af795af6..6e93a94de0 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -45,7 +45,7 @@ func (c *Command) Flags() *flagset.Flagset { }) f.StringFlag(&flagset.StringFlag{ Name: "syncmode", - Usage: `Blockchain sync mode ("fast", "full", or "snap")`, + Usage: `Blockchain sync mode (only "full" sync supported)`, Value: &c.cliConfig.SyncMode, Default: c.cliConfig.SyncMode, }) @@ -62,10 +62,16 @@ func (c *Command) Flags() *flagset.Flagset { }) f.BoolFlag(&flagset.BoolFlag{ Name: "snapshot", - Usage: `Disables/Enables the snapshot-database mode (default = true)`, + Usage: `Enables the snapshot-database mode (default = true)`, Value: &c.cliConfig.Snapshot, Default: c.cliConfig.Snapshot, }) + f.BoolFlag(&flagset.BoolFlag{ + Name: "bor.logs", + Usage: `Enables bor log retrieval (default = false)`, + Value: &c.cliConfig.BorLogs, + Default: c.cliConfig.BorLogs, + }) // heimdall f.StringFlag(&flagset.StringFlag{ diff --git a/scripts/getconfig.go b/scripts/getconfig.go index 689ed68fbf..136b69ecab 100644 --- a/scripts/getconfig.go +++ b/scripts/getconfig.go @@ -109,8 +109,9 @@ var nameTagMap = map[string]string{ "gcmode": "gcmode", "eth.requiredblocks": "eth.requiredblocks", "0-snapshot": "snapshot", + "\"bor.logs\"": "bor.logs", "url": "bor.heimdall", - "bor.without": "bor.withoutheimdall", + "\"bor.without\"": "bor.withoutheimdall", "grpc-address": "bor.heimdallgRPC", "locals": "txpool.locals", "nolocals": "txpool.nolocals", @@ -231,6 +232,7 @@ var replacedFlagsMapFlag = map[string]string{ var currentBoolFlags = []string{ "snapshot", + "bor.logs", "bor.withoutheimdall", "txpool.nolocals", "mine", From 4e7cf125ae40c8d53cd233652a003cb59ed97631 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 6 Oct 2022 13:12:39 +0530 Subject: [PATCH 06/36] new: add cases --- tests/bor/bor_reorg_test.go | 168 +++++++++++++++++++++++------------- 1 file changed, 106 insertions(+), 62 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index da5bde8ffd..38f0914ca6 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "math/big" "os" + "sync" "testing" "time" @@ -15,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/downloader" @@ -299,6 +301,27 @@ func TestValidatorWentOffline(t *testing.T) { // TODO: Need to find a better name func TestForkWithTwoNodeNet(t *testing.T) { + + cases := []struct { + sprint uint64 + blockTime map[string]uint64 + }{ + { + sprint: 128, + blockTime: map[string]uint64{ + "0": 5, + "128": 2, + "256": 8, + }, + }, + { + sprint: 64, + blockTime: map[string]uint64{ + "0": 5, + "64": 2, + }, + }, + } log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) fdlimit.Raise(2048) @@ -309,76 +332,97 @@ func TestForkWithTwoNodeNet(t *testing.T) { } // Create an Ethash network based off of the Ropsten config - genesis := initGenesis2(t, faucets) + genesis := initGenesis(t, faucets) - var ( - stacks []*node.Node - nodes []*eth.Ethereum - enodes []*enode.Node - ) + for _, test := range cases { + genesis.Config.Bor.Sprint = test.sprint + genesis.Config.Bor.Period = test.blockTime - for i := 0; i < 2; i++ { - // Start the node and wait until it's up - stack, ethBackend, err := initMiner(genesis, keys[i]) + var ( + stacks []*node.Node + nodes []*eth.Ethereum + enodes []*enode.Node + ) + + for i := 0; i < 2; i++ { + // Start the node and wait until it's up + stack, ethBackend, err := initMiner(genesis, keys[i]) + if err != nil { + panic(err) + } + defer stack.Close() + + for stack.Server().NodeInfo().Ports.Listener == 0 { + time.Sleep(250 * time.Millisecond) + } + // Connect the node to all the previous ones + for _, n := range enodes { + stack.Server().AddPeer(n) + } + // Start tracking the node and its enode + stacks = append(stacks, stack) + nodes = append(nodes, ethBackend) + enodes = append(enodes, stack.Server().Self()) + } + + // Iterate over all the nodes and start mining + time.Sleep(3 * time.Second) + for _, node := range nodes { + if err := node.StartMining(1); err != nil { + panic(err) + } + } + + var wg sync.WaitGroup + blockHeaders := make([]*types.Header, 2) + + for i := 0; i < 2; i++ { + wg.Add(1) + + go func(i int) { + defer wg.Done() + for { + blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint + 1) + if blockHeaders[i] != nil { + break + } + } + }(i) + } + + wg.Wait() + + // Before the end of sprint + blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(test.sprint - 1) + blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(test.sprint - 1) + assert.Equal(t, blockHeaderVal0.Hash(), blockHeaderVal1.Hash()) + assert.Equal(t, blockHeaderVal0.Time, blockHeaderVal1.Time) + + author0, err := nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - panic(err) + log.Error("Error occured while fetching author", "err", err) } - defer stack.Close() - - for stack.Server().NodeInfo().Ports.Listener == 0 { - time.Sleep(250 * time.Millisecond) + author1, err := nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + log.Error("Error occured while fetching author", "err", err) } - // Connect the node to all the previous ones - for _, n := range enodes { - stack.Server().AddPeer(n) + assert.Equal(t, author0, author1) + + // After the end of sprint + // FIXME: POS-845 + assert.NotEqual(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) + assert.NotEqual(t, blockHeaders[0].Time, blockHeaders[1].Time) + + author2, err := nodes[0].Engine().Author(blockHeaders[0]) + if err != nil { + log.Error("Error occured while fetching author", "err", err) } - // Start tracking the node and its enode - stacks = append(stacks, stack) - nodes = append(nodes, ethBackend) - enodes = append(enodes, stack.Server().Self()) - } - - // Iterate over all the nodes and start mining - time.Sleep(3 * time.Second) - for _, node := range nodes { - if err := node.StartMining(1); err != nil { - panic(err) + author3, err := nodes[1].Engine().Author(blockHeaders[1]) + if err != nil { + log.Error("Error occured while fetching author", "err", err) } - } + assert.NotEqual(t, author2, author3) - time.Sleep(700 * time.Second) - - // Before the end of sprint - blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(120) - blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(120) - assert.Equal(t, blockHeaderVal0.Hash(), blockHeaderVal1.Hash()) - assert.Equal(t, blockHeaderVal0.Time, blockHeaderVal1.Time) - - author0, err := nodes[0].Engine().Author(blockHeaderVal0) - if err != nil { - log.Error("Error occured while fetching author", "err", err) } - author1, err := nodes[1].Engine().Author(blockHeaderVal1) - if err != nil { - log.Error("Error occured while fetching author", "err", err) - } - assert.Equal(t, author0, author1) - - // After the end of sprint - // FIXME: POS-845 - blockHeaderVal2 := nodes[0].BlockChain().GetHeaderByNumber(130) - blockHeaderVal3 := nodes[1].BlockChain().GetHeaderByNumber(130) - assert.NotEqual(t, blockHeaderVal2.Hash(), blockHeaderVal3.Hash()) - assert.NotEqual(t, blockHeaderVal2.Time, blockHeaderVal3.Time) - - author2, err := nodes[0].Engine().Author(blockHeaderVal2) - if err != nil { - log.Error("Error occured while fetching author", "err", err) - } - author3, err := nodes[1].Engine().Author(blockHeaderVal3) - if err != nil { - log.Error("Error occured while fetching author", "err", err) - } - assert.NotEqual(t, author2, author3) } From 0218f17bc013de345c85a2e24ad7430c3747efcd Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 7 Oct 2022 16:00:34 +0530 Subject: [PATCH 07/36] new: add more cases --- Makefile | 2 +- tests/bor/bor_reorg_test.go | 64 ++++++++++++++++-------------- tests/bor/testdata/genesis3.json | 68 -------------------------------- 3 files changed, 35 insertions(+), 99 deletions(-) delete mode 100644 tests/bor/testdata/genesis3.json diff --git a/Makefile b/Makefile index 6e1e472a03..e51d2d99eb 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ test-race: $(GOTEST) --timeout 15m -race -shuffle=on $(TESTALL) test-integration: - $(GOTEST) --timeout 30m -tags integration $(TESTE2E) + $(GOTEST) --timeout 60m -tags integration $(TESTE2E) escape: cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 38f0914ca6..7b7c25fab9 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -116,26 +116,6 @@ func initGenesis(t *testing.T, faucets []*ecdsa.PrivateKey) *core.Genesis { return genesis } -func initGenesis2(t *testing.T, faucets []*ecdsa.PrivateKey) *core.Genesis { - - // sprint size = 128 in genesis - genesisData, err := ioutil.ReadFile("./testdata/genesis3.json") - if err != nil { - t.Fatalf("%s", err) - } - - genesis := &core.Genesis{} - - if err := json.Unmarshal(genesisData, genesis); err != nil { - t.Fatalf("%s", err) - } - - genesis.Config.ChainID = big.NewInt(15001) - genesis.Config.EIP150Hash = common.Hash{} - - return genesis -} - func TestValidatorWentOffline(t *testing.T) { log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) @@ -299,12 +279,14 @@ func TestValidatorWentOffline(t *testing.T) { } -// TODO: Need to find a better name -func TestForkWithTwoNodeNet(t *testing.T) { +func TestForkWithBlockTime(t *testing.T) { cases := []struct { - sprint uint64 - blockTime map[string]uint64 + sprint uint64 + blockTime map[string]uint64 + change uint64 + producerDelay uint64 + forkExpected bool }{ { sprint: 128, @@ -313,6 +295,9 @@ func TestForkWithTwoNodeNet(t *testing.T) { "128": 2, "256": 8, }, + change: 2, + producerDelay: 8, + forkExpected: false, }, { sprint: 64, @@ -320,6 +305,19 @@ func TestForkWithTwoNodeNet(t *testing.T) { "0": 5, "64": 2, }, + change: 1, + producerDelay: 5, + forkExpected: false, + }, + { + sprint: 16, + blockTime: map[string]uint64{ + "0": 2, + "64": 5, + }, + change: 4, + producerDelay: 4, + forkExpected: true, }, } log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) @@ -337,6 +335,8 @@ func TestForkWithTwoNodeNet(t *testing.T) { for _, test := range cases { genesis.Config.Bor.Sprint = test.sprint genesis.Config.Bor.Period = test.blockTime + genesis.Config.Bor.BackupMultiplier = test.blockTime + genesis.Config.Bor.ProducerDelay = test.producerDelay var ( stacks []*node.Node @@ -382,7 +382,7 @@ func TestForkWithTwoNodeNet(t *testing.T) { go func(i int) { defer wg.Done() for { - blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint + 1) + blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) if blockHeaders[i] != nil { break } @@ -409,10 +409,6 @@ func TestForkWithTwoNodeNet(t *testing.T) { assert.Equal(t, author0, author1) // After the end of sprint - // FIXME: POS-845 - assert.NotEqual(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) - assert.NotEqual(t, blockHeaders[0].Time, blockHeaders[1].Time) - author2, err := nodes[0].Engine().Author(blockHeaders[0]) if err != nil { log.Error("Error occured while fetching author", "err", err) @@ -421,8 +417,16 @@ func TestForkWithTwoNodeNet(t *testing.T) { if err != nil { log.Error("Error occured while fetching author", "err", err) } - assert.NotEqual(t, author2, author3) + if test.forkExpected { + assert.NotEqual(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) + assert.NotEqual(t, blockHeaders[0].Time, blockHeaders[1].Time) + assert.NotEqual(t, author2, author3) + } else { + assert.Equal(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) + assert.Equal(t, blockHeaders[0].Time, blockHeaders[1].Time) + assert.Equal(t, author2, author3) + } } } diff --git a/tests/bor/testdata/genesis3.json b/tests/bor/testdata/genesis3.json deleted file mode 100644 index aad92477af..0000000000 --- a/tests/bor/testdata/genesis3.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "config": { - "chainId": 15001, - "homesteadBlock": 0, - "eip150Block": 0, - "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "berlinBlock": 0, - "londonBlock": 1, - "bor": { - "jaipurBlock": 2, - "period": { - "0": 5, - "128": 2, - "256": 8 - }, - "producerDelay": 4, - "sprint": 128, - "backupMultiplier": { - "0": 5, - "128": 2, - "256": 8 - }, - "validatorContract": "0x0000000000000000000000000000000000001000", - "stateReceiverContract": "0x0000000000000000000000000000000000001001", - "burntContract": { - "0": "0x000000000000000000000000000000000000dead" - } - } - }, - "nonce": "0x0", - "timestamp": "0x5ce28211", - "extraData": "", - "gasLimit": "0x989680", - "difficulty": "0x1", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "alloc": { - "0000000000000000000000000000000000001000": { - "balance": "0x0", - "code": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806360c8614d1161010f578063af26aa96116100a2578063d5b844eb11610071578063d5b844eb14610666578063dcf2793a14610684578063e3b7c924146106b6578063f59cf565146106d4576101f0565b8063af26aa96146105c7578063b71d7a69146105e7578063b7ab4db514610617578063c1b3c91914610636576101f0565b806370ba5707116100de57806370ba57071461052b57806398ab2b621461055b5780639d11b80714610579578063ae756451146105a9576101f0565b806360c8614d1461049c57806365b3a1e2146104bc57806366332354146104db578063687a9bd6146104f9576101f0565b80633434735f1161018757806344d6528f1161015657806344d6528f146103ee5780634dbc959f1461041e57806355614fcc1461043c578063582a8d081461046c576101f0565b80633434735f1461035257806335ddfeea1461037057806343ee8213146103a057806344c15cb1146103be576101f0565b806323f2a73f116101c357806323f2a73f146102a45780632bc06564146102d45780632de3a180146102f25780632eddf35214610322576101f0565b8063047a6c5b146101f55780630c35b1cb146102275780631270b5741461025857806323c2a2b414610288575b600080fd5b61020f600480360361020a91908101906129ba565b610706565b60405161021e939291906132f9565b60405180910390f35b610241600480360361023c91908101906129ba565b61075d565b60405161024f92919061311a565b60405180910390f35b610272600480360361026d91908101906129e3565b610939565b60405161027f9190613151565b60405180910390f35b6102a2600480360361029d9190810190612ac2565b610a91565b005b6102be60048036036102b991908101906129e3565b61112a565b6040516102cb9190613151565b60405180910390f35b6102dc611281565b6040516102e991906132a7565b60405180910390f35b61030c60048036036103079190810190612917565b611286565b604051610319919061316c565b60405180910390f35b61033c600480360361033791908101906129ba565b611307565b60405161034991906132a7565b60405180910390f35b61035a611437565b60405161036791906130ff565b60405180910390f35b61038a60048036036103859190810190612953565b61144f565b6040516103979190613151565b60405180910390f35b6103a861151a565b6040516103b5919061316c565b60405180910390f35b6103d860048036036103d39190810190612a1f565b611531565b6040516103e591906132a7565b60405180910390f35b610408600480360361040391908101906129e3565b611619565b604051610415919061328c565b60405180910390f35b610426611781565b60405161043391906132a7565b60405180910390f35b6104566004803603610451919081019061289c565b611791565b6040516104639190613151565b60405180910390f35b610486600480360361048191908101906128c5565b6117ab565b604051610493919061316c565b60405180910390f35b6104a4611829565b6040516104b3939291906132f9565b60405180910390f35b6104c461189d565b6040516104d292919061311a565b60405180910390f35b6104e3611a04565b6040516104f091906132a7565b60405180910390f35b610513600480360361050e9190810190612a86565b611a09565b604051610522939291906132c2565b60405180910390f35b6105456004803603610540919081019061289c565b611a6d565b6040516105529190613151565b60405180910390f35b610563611a87565b604051610570919061316c565b60405180910390f35b610593600480360361058e91908101906129ba565b611a9e565b6040516105a091906132a7565b60405180910390f35b6105b1611bcf565b6040516105be919061316c565b60405180910390f35b6105cf611be6565b6040516105de939291906132f9565b60405180910390f35b61060160048036036105fc91908101906129ba565b611c47565b60405161060e91906132a7565b60405180910390f35b61061f611d47565b60405161062d92919061311a565b60405180910390f35b610650600480360361064b91908101906129ba565b611d5b565b60405161065d91906132a7565b60405180910390f35b61066e611d7c565b60405161067b9190613330565b60405180910390f35b61069e60048036036106999190810190612a86565b611d81565b6040516106ad939291906132c2565b60405180910390f35b6106be611de5565b6040516106cb91906132a7565b60405180910390f35b6106ee60048036036106e991908101906129ba565b611df7565b6040516106fd939291906132f9565b60405180910390f35b60008060006002600085815260200190815260200160002060000154600260008681526020019081526020016000206001015460026000878152602001908152602001600020600201549250925092509193909250565b60608060ff83116107795761077061189d565b91509150610934565b600061078484611c47565b9050606060016000838152602001908152602001600020805490506040519080825280602002602001820160405280156107cd5781602001602082028038833980820191505090505b509050606060016000848152602001908152602001600020805490506040519080825280602002602001820160405280156108175781602001602082028038833980820191505090505b50905060008090505b60016000858152602001908152602001600020805490508110156109295760016000858152602001908152602001600020818154811061085c57fe5b906000526020600020906003020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683828151811061089a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001600085815260200190815260200160002081815481106108f257fe5b90600052602060002090600302016001015482828151811061091057fe5b6020026020010181815250508080600101915050610820565b508181945094505050505b915091565b6000606060016000858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610a0c578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610970565b50505050905060008090505b8151811015610a84578373ffffffffffffffffffffffffffffffffffffffff16828281518110610a4457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff161415610a7757600192505050610a8b565b8080600101915050610a18565b5060009150505b92915050565b73fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0a9061326c565b60405180910390fd5b6000610b1d611781565b90506000811415610b3157610b30611e21565b5b610b4560018261214290919063ffffffff16565b8814610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d906131ec565b60405180910390fd5b868611610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf9061324c565b60405180910390fd5b6000604060018989030181610bd957fe5b0614610c1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c119061322c565b60405180910390fd5b8660026000838152602001908152602001600020600101541115610c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6a906131cc565b60405180910390fd5b6000600260008a81526020019081526020016000206000015414610ccc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc39061320c565b60405180910390fd5b604051806060016040528089815260200188815260200187815250600260008a8152602001908152602001600020600082015181600001556020820151816001015560408201518160020155905050600388908060018154018082558091505090600182039060005260206000200160009091929091909150555060008060008a815260200190815260200160002081610d669190612696565b506000600160008a815260200190815260200160002081610d879190612696565b506060610ddf610dda87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612161565b61218f565b905060008090505b8151811015610f51576060610e0e838381518110610e0157fe5b602002602001015161218f565b90506000808c81526020019081526020016000208054809190600101610e349190612696565b506040518060600160405280610e5d83600081518110610e5057fe5b602002602001015161226c565b8152602001610e7f83600181518110610e7257fe5b602002602001015161226c565b8152602001610ea183600281518110610e9457fe5b60200260200101516122dd565b73ffffffffffffffffffffffffffffffffffffffff168152506000808d81526020019081526020016000208381548110610ed757fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610de7565b506060610fa9610fa486868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612161565b61218f565b905060008090505b815181101561111d576060610fd8838381518110610fcb57fe5b602002602001015161218f565b9050600160008d81526020019081526020016000208054809190600101610fff9190612696565b5060405180606001604052806110288360008151811061101b57fe5b602002602001015161226c565b815260200161104a8360018151811061103d57fe5b602002602001015161226c565b815260200161106c8360028151811061105f57fe5b60200260200101516122dd565b73ffffffffffffffffffffffffffffffffffffffff16815250600160008e815260200190815260200160002083815481106110a357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050508080600101915050610fb1565b5050505050505050505050565b60006060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fc578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611160565b50505050905060008090505b8151811015611274578373ffffffffffffffffffffffffffffffffffffffff1682828151811061123457fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff1614156112675760019250505061127b565b8080600101915050611208565b5060009150505b92915050565b604081565b60006002600160f81b84846040516020016112a39392919061306c565b6040516020818303038152906040526040516112bf91906130a9565b602060405180830381855afa1580156112dc573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506112ff91908101906128ee565b905092915050565b60006060600080848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156113d9578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250508152602001906001019061133d565b505050509050600080905060008090505b825181101561142c5761141d83828151811061140257fe5b6020026020010151602001518361214290919063ffffffff16565b915080806001019150506113ea565b508092505050919050565b73fffffffffffffffffffffffffffffffffffffffe81565b600080600080859050600060218087518161146657fe5b04029050600081111561147f5761147c876117ab565b91505b6000602190505b818111611509576000600182038801519050818801519550806000602081106114ab57fe5b1a60f81b9450600060f81b857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114f0576114e98685611286565b93506114fd565b6114fa8487611286565b93505b50602181019050611486565b508782149450505050509392505050565b604051611526906130d5565b604051809103902081565b60008060009050600080905060008090505b84518167ffffffffffffffff16101561160c57606061156e868367ffffffffffffffff166041612300565b90506000611585828961238c90919063ffffffff16565b905061158f6126c8565b6115998a83611619565b90506115a58a8361112a565b80156115dc57508473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16115b156115fe578194506115fb81602001518761214290919063ffffffff16565b95505b505050604181019050611543565b5081925050509392505050565b6116216126c8565b6060600080858152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156116f1578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611655565b50505050905060008090505b8151811015611779578373ffffffffffffffffffffffffffffffffffffffff1682828151811061172957fe5b60200260200101516040015173ffffffffffffffffffffffffffffffffffffffff16141561176c5781818151811061175d57fe5b60200260200101519250611779565b80806001019150506116fd565b505092915050565b600061178c43611c47565b905090565b60006117a461179e611781565b8361112a565b9050919050565b60006002600060f81b836040516020016117c6929190613040565b6040516020818303038152906040526040516117e291906130a9565b602060405180830381855afa1580156117ff573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525061182291908101906128ee565b9050919050565b60008060008061184a600161183c611781565b61214290919063ffffffff16565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b606080606060026040519080825280602002602001820160405280156118d25781602001602082028038833980820191505090505b5090507371562b71999873db5b286df957af199ec94617f7816000815181106118f757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050739fb29aac15b9a4b7f17c3385939b007540f4d7918160018151811061195357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050606060026040519080825280602002602001820160405280156119bf5781602001602082028038833980820191505090505b5090506028816000815181106119d157fe5b602002602001018181525050601e816001815181106119ec57fe5b60200260200101818152505081819350935050509091565b60ff81565b60016020528160005260406000208181548110611a2257fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b6000611a80611a7a611781565b83610939565b9050919050565b604051611a93906130c0565b604051809103902081565b6000606060016000848152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611b71578382906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190611ad5565b505050509050600080905060008090505b8251811015611bc457611bb5838281518110611b9a57fe5b6020026020010151602001518361214290919063ffffffff16565b91508080600101915050611b82565b508092505050919050565b604051611bdb906130ea565b604051809103902081565b600080600080611bf4611781565b905060026000828152602001908152602001600020600001546002600083815260200190815260200160002060010154600260008481526020019081526020016000206002015493509350935050909192565b60008060038054905090505b6000811115611d0757611c646126ff565b6002600060036001850381548110611c7857fe5b906000526020600020015481526020019081526020016000206040518060600160405290816000820154815260200160018201548152602001600282015481525050905083816020015111158015611cd557506000816040015114155b8015611ce5575080604001518411155b15611cf857806000015192505050611d42565b50808060019003915050611c53565b5060006003805490501115611d3d57600360016003805490500381548110611d2b57fe5b90600052602060002001549050611d42565b600090505b919050565b606080611d534361075d565b915091509091565b60038181548110611d6857fe5b906000526020600020016000915090505481565b600281565b60006020528160005260406000208181548110611d9a57fe5b9060005260206000209060030201600091509150508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060404381611df157fe5b04905090565b60026020528060005260406000206000915090508060000154908060010154908060020154905083565b606080611e2c61189d565b8092508193505050600080905060405180606001604052808281526020016000815260200160ff815250600260008381526020019081526020016000206000820151816000015560208201518160010155604082015181600201559050506003819080600181540180825580915050906001820390600052602060002001600090919290919091505550600080600083815260200190815260200160002081611ed59190612696565b5060006001600083815260200190815260200160002081611ef69190612696565b5060008090505b8351811015612018576000808381526020019081526020016000208054809190600101611f2a9190612696565b506040518060600160405280828152602001848381518110611f4857fe5b60200260200101518152602001858381518110611f6157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168152506000808481526020019081526020016000208281548110611f9f57fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050508080600101915050611efd565b5060008090505b835181101561213c5760016000838152602001908152602001600020805480919060010161204d9190612696565b50604051806060016040528082815260200184838151811061206b57fe5b6020026020010151815260200185838151811061208457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168152506001600084815260200190815260200160002082815481106120c357fe5b9060005260206000209060030201600082015181600001556020820151816001015560408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050808060010191505061201f565b50505050565b60008082840190508381101561215757600080fd5b8091505092915050565b612169612720565b600060208301905060405180604001604052808451815260200182815250915050919050565b606061219a82612496565b6121a357600080fd5b60006121ae836124e4565b90506060816040519080825280602002602001820160405280156121ec57816020015b6121d961273a565b8152602001906001900390816121d15790505b50905060006121fe8560200151612555565b8560200151019050600080600090505b8481101561225f5761221f836125de565b915060405180604001604052808381526020018481525084828151811061224257fe5b60200260200101819052508183019250808060010191505061220e565b5082945050505050919050565b600080826000015111801561228657506021826000015111155b61228f57600080fd5b600061229e8360200151612555565b905060008184600001510390506000808386602001510190508051915060208310156122d157826020036101000a820491505b81945050505050919050565b600060158260000151146122f057600080fd5b6122f98261226c565b9050919050565b60608183018451101561231257600080fd5b606082156000811461232f57604051915060208201604052612380565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561236d5780518352602083019250602081019050612350565b50868552601f19601f8301166040525050505b50809150509392505050565b60008060008060418551146123a75760009350505050612490565b602085015192506040850151915060ff6041860151169050601b8160ff1610156123d257601b810190505b601b8160ff16141580156123ea5750601c8160ff1614155b156123fb5760009350505050612490565b6000600187838686604051600081526020016040526040516124209493929190613187565b6020604051602081039080840390855afa158015612442573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561248857600080fd5b809450505050505b92915050565b600080826000015114156124ad57600090506124df565b60008083602001519050805160001a915060c060ff168260ff1610156124d8576000925050506124df565b6001925050505b919050565b600080826000015114156124fb5760009050612550565b6000809050600061250f8460200151612555565b84602001510190506000846000015185602001510190505b8082101561254957612538826125de565b820191508280600101935050612527565b8293505050505b919050565b600080825160001a9050608060ff168110156125755760009150506125d9565b60b860ff1681108061259a575060c060ff168110158015612599575060f860ff1681105b5b156125a95760019150506125d9565b60c060ff168110156125c95760018060b80360ff168203019150506125d9565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff168110156125ff576001915061268c565b60b860ff1681101561261c576001608060ff16820301915061268b565b60c060ff1681101561264c5760b78103600185019450806020036101000a8551046001820181019350505061268a565b60f860ff1681101561266957600160c060ff168203019150612689565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b8154818355818111156126c3576003028160030283600052602060002091820191016126c29190612754565b5b505050565b60405180606001604052806000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60405180606001604052806000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b6127a791905b808211156127a35760008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060030161275a565b5090565b90565b6000813590506127b981613529565b92915050565b6000813590506127ce81613540565b92915050565b6000815190506127e381613540565b92915050565b60008083601f8401126127fb57600080fd5b8235905067ffffffffffffffff81111561281457600080fd5b60208301915083600182028301111561282c57600080fd5b9250929050565b600082601f83011261284457600080fd5b813561285761285282613378565b61334b565b9150808252602083016020830185838301111561287357600080fd5b61287e8382846134d3565b50505092915050565b60008135905061289681613557565b92915050565b6000602082840312156128ae57600080fd5b60006128bc848285016127aa565b91505092915050565b6000602082840312156128d757600080fd5b60006128e5848285016127bf565b91505092915050565b60006020828403121561290057600080fd5b600061290e848285016127d4565b91505092915050565b6000806040838503121561292a57600080fd5b6000612938858286016127bf565b9250506020612949858286016127bf565b9150509250929050565b60008060006060848603121561296857600080fd5b6000612976868287016127bf565b9350506020612987868287016127bf565b925050604084013567ffffffffffffffff8111156129a457600080fd5b6129b086828701612833565b9150509250925092565b6000602082840312156129cc57600080fd5b60006129da84828501612887565b91505092915050565b600080604083850312156129f657600080fd5b6000612a0485828601612887565b9250506020612a15858286016127aa565b9150509250929050565b600080600060608486031215612a3457600080fd5b6000612a4286828701612887565b9350506020612a53868287016127bf565b925050604084013567ffffffffffffffff811115612a7057600080fd5b612a7c86828701612833565b9150509250925092565b60008060408385031215612a9957600080fd5b6000612aa785828601612887565b9250506020612ab885828601612887565b9150509250929050565b600080600080600080600060a0888a031215612add57600080fd5b6000612aeb8a828b01612887565b9750506020612afc8a828b01612887565b9650506040612b0d8a828b01612887565b955050606088013567ffffffffffffffff811115612b2a57600080fd5b612b368a828b016127e9565b9450945050608088013567ffffffffffffffff811115612b5557600080fd5b612b618a828b016127e9565b925092505092959891949750929550565b6000612b7e8383612ba2565b60208301905092915050565b6000612b968383613013565b60208301905092915050565b612bab81613448565b82525050565b612bba81613448565b82525050565b6000612bcb826133c4565b612bd581856133ff565b9350612be0836133a4565b8060005b83811015612c11578151612bf88882612b72565b9750612c03836133e5565b925050600181019050612be4565b5085935050505092915050565b6000612c29826133cf565b612c338185613410565b9350612c3e836133b4565b8060005b83811015612c6f578151612c568882612b8a565b9750612c61836133f2565b925050600181019050612c42565b5085935050505092915050565b612c858161345a565b82525050565b612c9c612c9782613466565b613515565b82525050565b612cab81613492565b82525050565b612cc2612cbd82613492565b61351f565b82525050565b6000612cd3826133da565b612cdd8185613421565b9350612ced8185602086016134e2565b80840191505092915050565b6000612d0660048361343d565b91507f766f7465000000000000000000000000000000000000000000000000000000006000830152600482019050919050565b6000612d46602d8361342c565b91507f537461727420626c6f636b206d7573742062652067726561746572207468616e60008301527f2063757272656e74207370616e000000000000000000000000000000000000006020830152604082019050919050565b6000612dac600f8361343d565b91507f6865696d64616c6c2d50357258776700000000000000000000000000000000006000830152600f82019050919050565b6000612dec600f8361342c565b91507f496e76616c6964207370616e20696400000000000000000000000000000000006000830152602082019050919050565b6000612e2c60138361342c565b91507f5370616e20616c726561647920657869737473000000000000000000000000006000830152602082019050919050565b6000612e6c60458361342c565b91507f446966666572656e6365206265747765656e20737461727420616e6420656e6460008301527f20626c6f636b206d75737420626520696e206d756c7469706c6573206f66207360208301527f7072696e740000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000612ef8602a8361342c565b91507f456e6420626c6f636b206d7573742062652067726561746572207468616e207360008301527f7461727420626c6f636b000000000000000000000000000000000000000000006020830152604082019050919050565b6000612f5e60058361343d565b91507f31353030310000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000612f9e60128361342c565b91507f4e6f742053797374656d204164646573732100000000000000000000000000006000830152602082019050919050565b606082016000820151612fe76000850182613013565b506020820151612ffa6020850182613013565b50604082015161300d6040850182612ba2565b50505050565b61301c816134bc565b82525050565b61302b816134bc565b82525050565b61303a816134c6565b82525050565b600061304c8285612c8b565b60018201915061305c8284612cb1565b6020820191508190509392505050565b60006130788286612c8b565b6001820191506130888285612cb1565b6020820191506130988284612cb1565b602082019150819050949350505050565b60006130b58284612cc8565b915081905092915050565b60006130cb82612cf9565b9150819050919050565b60006130e082612d9f565b9150819050919050565b60006130f582612f51565b9150819050919050565b60006020820190506131146000830184612bb1565b92915050565b600060408201905081810360008301526131348185612bc0565b905081810360208301526131488184612c1e565b90509392505050565b60006020820190506131666000830184612c7c565b92915050565b60006020820190506131816000830184612ca2565b92915050565b600060808201905061319c6000830187612ca2565b6131a96020830186613031565b6131b66040830185612ca2565b6131c36060830184612ca2565b95945050505050565b600060208201905081810360008301526131e581612d39565b9050919050565b6000602082019050818103600083015261320581612ddf565b9050919050565b6000602082019050818103600083015261322581612e1f565b9050919050565b6000602082019050818103600083015261324581612e5f565b9050919050565b6000602082019050818103600083015261326581612eeb565b9050919050565b6000602082019050818103600083015261328581612f91565b9050919050565b60006060820190506132a16000830184612fd1565b92915050565b60006020820190506132bc6000830184613022565b92915050565b60006060820190506132d76000830186613022565b6132e46020830185613022565b6132f16040830184612bb1565b949350505050565b600060608201905061330e6000830186613022565b61331b6020830185613022565b6133286040830184613022565b949350505050565b60006020820190506133456000830184613031565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561336e57600080fd5b8060405250919050565b600067ffffffffffffffff82111561338f57600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006134538261349c565b9050919050565b60008115159050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b838110156135005780820151818401526020810190506134e5565b8381111561350f576000848401525b50505050565b6000819050919050565b6000819050919050565b61353281613448565b811461353d57600080fd5b50565b61354981613492565b811461355457600080fd5b50565b613560816134bc565b811461356b57600080fd5b5056fea365627a7a7231582051bf0a46b5958c4ecdf9f1f9a9d8b62deacac5d79cdf5595e9853f3c0132fe236c6578706572696d656e74616cf564736f6c63430005110040" - }, - "0000000000000000000000000000000000001001": { - "balance": "0x0", - "code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806319494a17146100465780633434735f146100e15780635407ca671461012b575b600080fd5b6100c76004803603604081101561005c57600080fd5b81019080803590602001909291908035906020019064010000000081111561008357600080fd5b82018360208201111561009557600080fd5b803590602001918460018302840111640100000000831117156100b757600080fd5b9091929391929390505050610149565b604051808215151515815260200191505060405180910390f35b6100e961047a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610133610492565b6040518082815260200191505060405180910390f35b600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610200576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4e6f742053797374656d2041646465737321000000000000000000000000000081525060200191505060405180910390fd5b606061025761025285858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610498565b6104c6565b905060006102788260008151811061026b57fe5b60200260200101516105a3565b905080600160005401146102f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f537461746549647320617265206e6f742073657175656e7469616c000000000081525060200191505060405180910390fd5b600080815480929190600101919050555060006103248360018151811061031757fe5b6020026020010151610614565b905060606103458460028151811061033857fe5b6020026020010151610637565b9050610350826106c3565b1561046f576000624c4b409050606084836040516024018083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156103aa57808201518184015260208101905061038f565b50505050905090810190601f1680156103d75780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f26c53bea000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008082516020840160008887f1965050505b505050509392505050565b73fffffffffffffffffffffffffffffffffffffffe81565b60005481565b6104a0610943565b600060208301905060405180604001604052808451815260200182815250915050919050565b60606104d1826106dc565b6104da57600080fd5b60006104e58361072a565b905060608160405190808252806020026020018201604052801561052357816020015b61051061095d565b8152602001906001900390816105085790505b5090506000610535856020015161079b565b8560200151019050600080600090505b848110156105965761055683610824565b915060405180604001604052808381526020018481525084828151811061057957fe5b602002602001018190525081830192508080600101915050610545565b5082945050505050919050565b60008082600001511180156105bd57506021826000015111155b6105c657600080fd5b60006105d5836020015161079b565b9050600081846000015103905060008083866020015101905080519150602083101561060857826020036101000a820491505b81945050505050919050565b6000601582600001511461062757600080fd5b610630826105a3565b9050919050565b6060600082600001511161064a57600080fd5b6000610659836020015161079b565b905060008184600001510390506060816040519080825280601f01601f19166020018201604052801561069b5781602001600182028038833980820191505090505b50905060008160200190506106b78487602001510182856108dc565b81945050505050919050565b600080823b905060008163ffffffff1611915050919050565b600080826000015114156106f35760009050610725565b60008083602001519050805160001a915060c060ff168260ff16101561071e57600092505050610725565b6001925050505b919050565b600080826000015114156107415760009050610796565b60008090506000610755846020015161079b565b84602001510190506000846000015185602001510190505b8082101561078f5761077e82610824565b82019150828060010193505061076d565b8293505050505b919050565b600080825160001a9050608060ff168110156107bb57600091505061081f565b60b860ff168110806107e0575060c060ff1681101580156107df575060f860ff1681105b5b156107ef57600191505061081f565b60c060ff1681101561080f5760018060b80360ff1682030191505061081f565b60018060f80360ff168203019150505b919050565b6000806000835160001a9050608060ff1681101561084557600191506108d2565b60b860ff16811015610862576001608060ff1682030191506108d1565b60c060ff168110156108925760b78103600185019450806020036101000a855104600182018101935050506108d0565b60f860ff168110156108af57600160c060ff1682030191506108cf565b60f78103600185019450806020036101000a855104600182018101935050505b5b5b5b8192505050919050565b60008114156108ea5761093e565b5b602060ff16811061091a5782518252602060ff1683019250602060ff1682019150602060ff16810390506108eb565b6000600182602060ff16036101000a03905080198451168184511681811785525050505b505050565b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200160008152509056fea265627a7a72315820af228b81e19dac46d14c24d264bde25d8a461d559c4e3cc82a5f1660755df35e64736f6c63430005110032" - }, - "0000000000000000000000000000000000001010": { - "balance": "0x204fcdf1d291a6d552c00000", - "code": "0x60806040526004361061019c5760003560e01c806377d32e94116100ec578063acd06cb31161008a578063e306f77911610064578063e306f77914610a7b578063e614d0d614610aa6578063f2fde38b14610ad1578063fc0c546a14610b225761019c565b8063acd06cb31461097a578063b789543c146109cd578063cc79f97b14610a505761019c565b80639025e64c116100c65780639025e64c146107c957806395d89b4114610859578063a9059cbb146108e9578063abceeba21461094f5761019c565b806377d32e94146106315780638da5cb5b146107435780638f32d59b1461079a5761019c565b806347e7ef24116101595780637019d41a116101335780637019d41a1461053357806370a082311461058a578063715018a6146105ef578063771282f6146106065761019c565b806347e7ef2414610410578063485cc9551461046b57806360f96a8f146104dc5761019c565b806306fdde03146101a15780631499c5921461023157806318160ddd1461028257806319d27d9c146102ad5780632e1a7d4d146103b1578063313ce567146103df575b600080fd5b3480156101ad57600080fd5b506101b6610b79565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101f65780820151818401526020810190506101db565b50505050905090810190601f1680156102235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023d57600080fd5b506102806004803603602081101561025457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb6565b005b34801561028e57600080fd5b50610297610c24565b6040518082815260200191505060405180910390f35b3480156102b957600080fd5b5061036f600480360360a08110156102d057600080fd5b81019080803590602001906401000000008111156102ed57600080fd5b8201836020820111156102ff57600080fd5b8035906020019184600183028401116401000000008311171561032157600080fd5b9091929391929390803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dd600480360360208110156103c757600080fd5b8101908080359060200190929190505050610e06565b005b3480156103eb57600080fd5b506103f4610f58565b604051808260ff1660ff16815260200191505060405180910390f35b34801561041c57600080fd5b506104696004803603604081101561043357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f61565b005b34801561047757600080fd5b506104da6004803603604081101561048e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b005b3480156104e857600080fd5b506104f16111ec565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053f57600080fd5b50610548611212565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561059657600080fd5b506105d9600480360360208110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611238565b6040518082815260200191505060405180910390f35b3480156105fb57600080fd5b50610604611259565b005b34801561061257600080fd5b5061061b611329565b6040518082815260200191505060405180910390f35b34801561063d57600080fd5b506107016004803603604081101561065457600080fd5b81019080803590602001909291908035906020019064010000000081111561067b57600080fd5b82018360208201111561068d57600080fd5b803590602001918460018302840111640100000000831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061132f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561074f57600080fd5b506107586114b4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107a657600080fd5b506107af6114dd565b604051808215151515815260200191505060405180910390f35b3480156107d557600080fd5b506107de611534565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561081e578082015181840152602081019050610803565b50505050905090810190601f16801561084b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086557600080fd5b5061086e61156d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108ae578082015181840152602081019050610893565b50505050905090810190601f1680156108db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610935600480360360408110156108ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115aa565b604051808215151515815260200191505060405180910390f35b34801561095b57600080fd5b506109646115d0565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b506109b36004803603602081101561099d57600080fd5b810190808035906020019092919050505061165d565b604051808215151515815260200191505060405180910390f35b3480156109d957600080fd5b50610a3a600480360360808110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919050505061167d565b6040518082815260200191505060405180910390f35b348015610a5c57600080fd5b50610a6561169d565b6040518082815260200191505060405180910390f35b348015610a8757600080fd5b50610a906116a3565b6040518082815260200191505060405180910390f35b348015610ab257600080fd5b50610abb6116a9565b6040518082815260200191505060405180910390f35b348015610add57600080fd5b50610b2060048036036020811015610af457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611736565b005b348015610b2e57600080fd5b50610b37611753565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280600b81526020017f4d6174696320546f6b656e000000000000000000000000000000000000000000815250905090565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f44697361626c656420666561747572650000000000000000000000000000000081525060200191505060405180910390fd5b6000601260ff16600a0a6402540be40002905090565b6000808511610c4857600080fd5b6000831480610c575750824311155b610cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5369676e6174757265206973206578706972656400000000000000000000000081525060200191505060405180910390fd5b6000610cd73387878761167d565b9050600015156005600083815260200190815260200160002060009054906101000a900460ff16151514610d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f536967206465616374697661746564000000000000000000000000000000000081525060200191505060405180910390fd5b60016005600083815260200190815260200160002060006101000a81548160ff021916908315150217905550610ded8189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505061132f565b9150610dfa828488611779565b50509695505050505050565b60003390506000610e1682611238565b9050610e2d83600654611b3690919063ffffffff16565b600681905550600083118015610e4257508234145b610eb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e73756666696369656e7420616d6f756e740000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f8584610f3087611238565b60405180848152602001838152602001828152602001935050505060405180910390a3505050565b60006012905090565b610f696114dd565b610f7257600080fd5b600081118015610faf5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b611004576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f046023913960400191505060405180910390fd5b600061100f83611238565b905060008390508073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561105c573d6000803e3d6000fd5b5061107283600654611b5690919063ffffffff16565b6006819055508373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f685856110f489611238565b60405180848152602001838152602001828152602001935050505060405180910390a350505050565b600760009054906101000a900460ff1615611183576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ee16023913960400191505060405180910390fd5b6001600760006101000a81548160ff02191690831515021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506111e882611b75565b5050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6112616114dd565b61126a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60065481565b600080600080604185511461134a57600093505050506114ae565b602085015192506040850151915060ff6041860151169050601b8160ff16101561137557601b810190505b601b8160ff161415801561138d5750601c8160ff1614155b1561139e57600093505050506114ae565b60018682858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b505050602060405103519350600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4572726f7220696e2065637265636f766572000000000000000000000000000081525060200191505060405180910390fd5b5050505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6040518060400160405280600281526020017f3a9900000000000000000000000000000000000000000000000000000000000081525081565b60606040518060400160405280600581526020017f4d41544943000000000000000000000000000000000000000000000000000000815250905090565b60008134146115bc57600090506115ca565b6115c7338484611779565b90505b92915050565b6040518060800160405280605b8152602001611f79605b91396040516020018082805190602001908083835b6020831061161f57805182526020820191506020810190506020830392506115fc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b60056020528060005260406000206000915054906101000a900460ff1681565b600061169361168e86868686611c6d565b611d43565b9050949350505050565b613a9981565b60015481565b604051806080016040528060528152602001611f27605291396040516020018082805190602001908083835b602083106116f857805182526020820191506020810190506020830392506116d5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012081565b61173e6114dd565b61174757600080fd5b61175081611b75565b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000803073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156117f957600080fd5b505afa15801561180d573d6000803e3d6000fd5b505050506040513d602081101561182357600080fd5b8101908080519060200190929190505050905060003073ffffffffffffffffffffffffffffffffffffffff166370a08231866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156118b557600080fd5b505afa1580156118c9573d6000803e3d6000fd5b505050506040513d60208110156118df57600080fd5b810190808051906020019092919050505090506118fd868686611d8d565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c48786863073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611a0557600080fd5b505afa158015611a19573d6000803e3d6000fd5b505050506040513d6020811015611a2f57600080fd5b81019080805190602001909291905050503073ffffffffffffffffffffffffffffffffffffffff166370a082318e6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611abd57600080fd5b505afa158015611ad1573d6000803e3d6000fd5b505050506040513d6020811015611ae757600080fd5b8101908080519060200190929190505050604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a46001925050509392505050565b600082821115611b4557600080fd5b600082840390508091505092915050565b600080828401905083811015611b6b57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611baf57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806040518060800160405280605b8152602001611f79605b91396040516020018082805190602001908083835b60208310611cbf5780518252602082019150602081019050602083039250611c9c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405181815273ffffffffffffffffffffffffffffffffffffffff8716602082015285604082015284606082015283608082015260a0812092505081915050949350505050565b60008060015490506040517f190100000000000000000000000000000000000000000000000000000000000081528160028201528360228201526042812092505081915050919050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e2f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616e27742073656e6420746f204d524332300000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611e75573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe54686520636f6e747261637420697320616c726561647920696e697469616c697a6564496e73756666696369656e7420616d6f756e74206f7220696e76616c69642075736572454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429546f6b656e5472616e736665724f726465722861646472657373207370656e6465722c75696e7432353620746f6b656e49644f72416d6f756e742c6279746573333220646174612c75696e743235362065787069726174696f6e29a265627a7a723158205723157ad1c8ebb37fecace5dc0ce2dfa893ec59d46a1305ad694cd0170076ab64736f6c63430005110032" - }, - "71562b71999873DB5b286dF957af199Ec94617F7": { - "balance": "0x3635c9adc5dea00000" - }, - "9fB29AAc15b9A4B7F17c3385939b007540f4d791": { - "balance": "0x3635c9adc5dea00000" - } - }, - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" - } - \ No newline at end of file From fdd7988e94f46081db733ada1c2cc3682662bd10 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 12 Oct 2022 09:29:40 +0530 Subject: [PATCH 08/36] fix: PR comments --- tests/bor/bor_reorg_test.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 7b7c25fab9..f68566ee5f 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -139,7 +139,7 @@ func TestValidatorWentOffline(t *testing.T) { // Start the node and wait until it's up stack, ethBackend, err := initMiner(genesis, keys[i]) if err != nil { - panic(err) + t.Fatal("Error occured while initialising miner", "error", err) } defer stack.Close() @@ -160,7 +160,7 @@ func TestValidatorWentOffline(t *testing.T) { time.Sleep(3 * time.Second) for _, node := range nodes { if err := node.StartMining(1); err != nil { - panic(err) + t.Fatal("Error occured while starting miner", "node", node, "error", err) } } @@ -198,11 +198,11 @@ func TestValidatorWentOffline(t *testing.T) { blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(10) authorVal0, err := nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } authorVal1, err := nodes[1].Engine().Author(blockHeaderVal1) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } // check both nodes have the same block 10 @@ -219,11 +219,11 @@ func TestValidatorWentOffline(t *testing.T) { blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(11) authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } // check both nodes have the same block 11 @@ -240,11 +240,11 @@ func TestValidatorWentOffline(t *testing.T) { blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(12) authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } // check both nodes have the same block 12 @@ -261,11 +261,11 @@ func TestValidatorWentOffline(t *testing.T) { blockHeaderVal1 = nodes[1].BlockChain().GetHeaderByNumber(17) authorVal0, err = nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } authorVal1, err = nodes[1].Engine().Author(blockHeaderVal1) if err != nil { - log.Error("Error in getting author", "err", err) + t.Error("Error in getting author", "err", err) } // check both nodes have the same block 17 @@ -348,7 +348,7 @@ func TestForkWithBlockTime(t *testing.T) { // Start the node and wait until it's up stack, ethBackend, err := initMiner(genesis, keys[i]) if err != nil { - panic(err) + t.Fatal("Error occured while initialising miner", "error", err) } defer stack.Close() @@ -369,7 +369,7 @@ func TestForkWithBlockTime(t *testing.T) { time.Sleep(3 * time.Second) for _, node := range nodes { if err := node.StartMining(1); err != nil { - panic(err) + t.Fatal("Error occured while starting miner", "node", node, "error", err) } } @@ -400,22 +400,22 @@ func TestForkWithBlockTime(t *testing.T) { author0, err := nodes[0].Engine().Author(blockHeaderVal0) if err != nil { - log.Error("Error occured while fetching author", "err", err) + t.Error("Error occured while fetching author", "err", err) } author1, err := nodes[1].Engine().Author(blockHeaderVal1) if err != nil { - log.Error("Error occured while fetching author", "err", err) + t.Error("Error occured while fetching author", "err", err) } assert.Equal(t, author0, author1) // After the end of sprint author2, err := nodes[0].Engine().Author(blockHeaders[0]) if err != nil { - log.Error("Error occured while fetching author", "err", err) + t.Error("Error occured while fetching author", "err", err) } author3, err := nodes[1].Engine().Author(blockHeaders[1]) if err != nil { - log.Error("Error occured while fetching author", "err", err) + t.Error("Error occured while fetching author", "err", err) } if test.forkExpected { From bf39845222f314abbee525ef218c7942c3fc718f Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 12 Oct 2022 15:11:38 +0200 Subject: [PATCH 09/36] Testing Toolkit v1 PR Template (#536) * dev: add: pull request template --- .github/CODEOWNERS | 23 ----------------- .github/pull_request_template.md | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 23 deletions(-) delete mode 100644 .github/CODEOWNERS create mode 100644 .github/pull_request_template.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 2015604e64..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,23 +0,0 @@ -# Lines starting with '#' are comments. -# Each line is a file pattern followed by one or more owners. - -accounts/usbwallet @karalabe -accounts/scwallet @gballet -accounts/abi @gballet @MariusVanDerWijden -cmd/clef @holiman -cmd/puppeth @karalabe -consensus @karalabe -core/ @karalabe @holiman @rjl493456442 -eth/ @karalabe @holiman @rjl493456442 -eth/catalyst/ @gballet -graphql/ @gballet -les/ @zsfelfoldi @rjl493456442 -light/ @zsfelfoldi @rjl493456442 -mobile/ @karalabe @ligi -node/ @fjl @renaynay -p2p/ @fjl @zsfelfoldi -rpc/ @fjl @holiman -p2p/simulations @fjl -p2p/protocols @fjl -p2p/testing @fjl -signer/ @holiman diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..a369a528e3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,44 @@ +# Description + +Please provide a detailed description of what was done in this PR + +# Changes + +- [ ] Bugfix (non-breaking change that solves an issue) +- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention) +- [ ] New feature (non-breaking change that adds functionality) +- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality) + +# Breaking changes + +Please complete this section if any breaking changes have been made, otherwise delete it + +# Checklist + +- [ ] I have added at least 2 reviewer or the whole pos-v1 team +- [ ] I have added sufficient documentation in code +- [ ] I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply + +# Cross repository changes + +- [ ] This PR requires changes to heimdall + - In case link the PR here: +- [ ] This PR requires changes to matic-cli + - In case link the PR here: + +## Testing + +- [ ] I have added unit tests +- [ ] I have added tests to CI +- [ ] I have tested this code manually on local environment +- [ ] I have tested this code manually on remote devnet using express-cli +- [ ] I have tested this code manually on mumbai +- [ ] I have created new e2e tests into express-cli + +### Manual tests + +Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it + +# Additional comments + +Please post additional comments in this section if you have them, otherwise delete it \ No newline at end of file From 6baa56bc257811b833f8b85e60f94925668b89af Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Wed, 12 Oct 2022 20:06:00 +0530 Subject: [PATCH 10/36] add : Add state sync transaction to debug_traceBlock --- consensus/bor/statefull/processor.go | 52 +++++++-- core/vm/interface.go | 2 + eth/tracers/api.go | 159 +++++++++++++++++++++------ eth/tracers/api_test.go | 11 +- 4 files changed, 178 insertions(+), 46 deletions(-) diff --git a/consensus/bor/statefull/processor.go b/consensus/bor/statefull/processor.go index c87d4f4ff4..8ac633bb3d 100644 --- a/consensus/bor/statefull/processor.go +++ b/consensus/bor/statefull/processor.go @@ -31,22 +31,22 @@ func (c ChainContext) GetHeader(hash common.Hash, number uint64) *types.Header { } // callmsg implements core.Message to allow passing it as a transaction simulator. -type callmsg struct { +type Callmsg struct { ethereum.CallMsg } -func (m callmsg) From() common.Address { return m.CallMsg.From } -func (m callmsg) Nonce() uint64 { return 0 } -func (m callmsg) CheckNonce() bool { return false } -func (m callmsg) To() *common.Address { return m.CallMsg.To } -func (m callmsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } -func (m callmsg) Gas() uint64 { return m.CallMsg.Gas } -func (m callmsg) Value() *big.Int { return m.CallMsg.Value } -func (m callmsg) Data() []byte { return m.CallMsg.Data } +func (m Callmsg) From() common.Address { return m.CallMsg.From } +func (m Callmsg) Nonce() uint64 { return 0 } +func (m Callmsg) CheckNonce() bool { return false } +func (m Callmsg) To() *common.Address { return m.CallMsg.To } +func (m Callmsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } +func (m Callmsg) Gas() uint64 { return m.CallMsg.Gas } +func (m Callmsg) Value() *big.Int { return m.CallMsg.Value } +func (m Callmsg) Data() []byte { return m.CallMsg.Data } // get system message -func GetSystemMessage(toAddress common.Address, data []byte) callmsg { - return callmsg{ +func GetSystemMessage(toAddress common.Address, data []byte) Callmsg { + return Callmsg{ ethereum.CallMsg{ From: systemAddress, Gas: math.MaxUint64 / 2, @@ -61,7 +61,7 @@ func GetSystemMessage(toAddress common.Address, data []byte) callmsg { // apply message func ApplyMessage( _ context.Context, - msg callmsg, + msg Callmsg, state *state.StateDB, header *types.Header, chainConfig *params.ChainConfig, @@ -92,4 +92,32 @@ func ApplyMessage( gasUsed := initialGas - gasLeft return gasUsed, nil + +} + +func ApplyBorMessage(vmenv vm.EVM, msg Callmsg) (*core.ExecutionResult, error) { + + initialGas := msg.Gas() + + // Apply the transaction to the current state (included in the env) + ret, gasLeft, err := vmenv.Call( + vm.AccountRef(msg.From()), + *msg.To(), + msg.Data(), + msg.Gas(), + msg.Value(), + ) + // Update the state with pending changes + if err != nil { + vmenv.StateDB.Finalise(true) + } + + gasUsed := initialGas - gasLeft + + return &core.ExecutionResult{ + UsedGas: gasUsed, + Err: err, + ReturnData: ret, + }, nil + } diff --git a/core/vm/interface.go b/core/vm/interface.go index ad9b05d666..1064adf590 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -74,6 +74,8 @@ type StateDB interface { AddPreimage(common.Hash, []byte) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error + + Finalise(bool) } // CallContext provides a basic interface for the EVM calling conventions. The EVM diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 08c17601e4..12b1411ae7 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -28,9 +28,11 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" @@ -80,6 +82,9 @@ type Backend interface { // so this method should be called with the parent. StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, checkLive, preferDisk bool) (*state.StateDB, error) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (core.Message, vm.BlockContext, *state.StateDB, error) + + // Bor related APIs + GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) } // API is the collection of tracing APIs exposed over the private debugging endpoint. @@ -164,6 +169,25 @@ func (api *API) blockByNumberAndHash(ctx context.Context, number rpc.BlockNumber return api.blockByHash(ctx, hash) } +// returns block transactions along with state-sync transaction if present +func (api *API) getAllBlockTransactions(ctx context.Context, block *types.Block) (types.Transactions, bool) { + txs := block.Transactions() + + stateSyncPresent := false + + borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64()) + if borReceipt != nil { + txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) + if txHash != (common.Hash{}) { + borTx, _, _, _, _ := api.backend.GetBorBlockTransactionWithBlockHash(ctx, txHash, block.Hash()) + txs = append(txs, borTx) + stateSyncPresent = true + } + } + + return txs, stateSyncPresent +} + // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { *logger.Config @@ -274,19 +298,30 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config signer := types.MakeSigner(api.backend.ChainConfig(), task.block.Number()) blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), nil) // Trace all the transactions contained within - for i, tx := range task.block.Transactions() { + txs, stateSyncPresent := api.getAllBlockTransactions(ctx, task.block) + for i, tx := range txs { msg, _ := tx.AsMessage(signer, task.block.BaseFee()) txctx := &Context{ BlockHash: task.block.Hash(), TxIndex: i, TxHash: tx.Hash(), } - res, err := api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config) + + var res interface{} + var err error + + if stateSyncPresent && i == len(txs)-1 { + res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config, true) + } else { + res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config, false) + } + if err != nil { task.results[i] = &txTraceResult{Error: err.Error()} log.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err) break } + // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect task.statedb.Finalise(api.backend.ChainConfig().IsEIP158(task.block.Number())) task.results[i] = &txTraceResult{Result: res} @@ -492,6 +527,23 @@ func (api *API) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, return api.standardTraceBlockToFile(ctx, block, config) } +func prepareCallMessage(msg core.Message) statefull.Callmsg { + + return statefull.Callmsg{ + ethereum.CallMsg{ + From: msg.From(), + To: msg.To(), + Gas: msg.Gas(), + GasPrice: msg.GasPrice(), + GasFeeCap: msg.GasFeeCap(), + GasTipCap: msg.GasTipCap(), + Value: msg.Value(), + Data: msg.Data(), + AccessList: msg.AccessList(), + }} + +} + // IntermediateRoots executes a block (bad- or canon- or side-), and returns a list // of intermediate roots: the stateroot after each transaction. func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config *TraceConfig) ([]common.Hash, error) { @@ -525,23 +577,42 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) deleteEmptyObjects = chainConfig.IsEIP158(block.Number()) ) - for i, tx := range block.Transactions() { + txs, stateSyncPresent := api.getAllBlockTransactions(ctx, block) + for i, tx := range txs { var ( msg, _ = tx.AsMessage(signer, block.BaseFee()) txContext = core.NewEVMTxContext(msg) vmenv = vm.NewEVM(vmctx, txContext, statedb, chainConfig, vm.Config{}) ) statedb.Prepare(tx.Hash(), i) - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { - log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) - // We intentionally don't return the error here: if we do, then the RPC server will not - // return the roots. Most likely, the caller already knows that a certain transaction fails to - // be included, but still want the intermediate roots that led to that point. - // It may happen the tx_N causes an erroneous state, which in turn causes tx_N+M to not be - // executable. - // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. - return roots, nil + if stateSyncPresent && i == len(txs)-1 { + callmsg := prepareCallMessage(msg) + + if _, err := statefull.ApplyMessage(ctx, callmsg, statedb, block.Header(), api.backend.ChainConfig(), api.chainContext(ctx)); err != nil { + log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) + // We intentionally don't return the error here: if we do, then the RPC server will not + // return the roots. Most likely, the caller already knows that a certain transaction fails to + // be included, but still want the intermediate roots that led to that point. + // It may happen the tx_N causes an erroneous state, which in turn causes tx_N+M to not be + // executable. + // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. + return roots, nil + } + + } else { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { + log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) + // We intentionally don't return the error here: if we do, then the RPC server will not + // return the roots. Most likely, the caller already knows that a certain transaction fails to + // be included, but still want the intermediate roots that led to that point. + // It may happen the tx_N causes an erroneous state, which in turn causes tx_N+M to not be + // executable. + // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. + return roots, nil + } + } + // calling IntermediateRoot will internally call Finalize on the state // so any modifications are written to the trie roots = append(roots, statedb.IntermediateRoot(deleteEmptyObjects)) @@ -581,9 +652,9 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac } // Execute all the transaction contained within the block concurrently var ( - signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) - txs = block.Transactions() - results = make([]*txTraceResult, len(txs)) + signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) + txs, stateSyncPresent = api.getAllBlockTransactions(ctx, block) + results = make([]*txTraceResult, len(txs)) pend = new(sync.WaitGroup) jobs = make(chan *txTraceTask, len(txs)) @@ -606,7 +677,13 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac TxIndex: task.index, TxHash: txs[task.index].Hash(), } - res, err := api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config) + var res interface{} + var err error + if stateSyncPresent && task.index == len(txs)-1 { + res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config, true) + } else { + res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config, false) + } if err != nil { results[task.index] = &txTraceResult{Error: err.Error()} continue @@ -650,7 +727,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block, config *StdTraceConfig) ([]string, error) { // If we're tracing a single transaction, make sure it's present if config != nil && config.TxHash != (common.Hash{}) { - if !containsTx(block, config.TxHash) { + if !api.containsTx(ctx, block, config.TxHash) { return nil, fmt.Errorf("transaction %#x not found in block", config.TxHash) } } @@ -705,7 +782,8 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block canon = false } } - for i, tx := range block.Transactions() { + txs, stateSyncPresent := api.getAllBlockTransactions(ctx, block) + for i, tx := range txs { // Prepare the trasaction for un-traced execution var ( msg, _ = tx.AsMessage(signer, block.BaseFee()) @@ -739,10 +817,19 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block // Execute the transaction and flush any traces to disk vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf) statedb.Prepare(tx.Hash(), i) - _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())) - if writer != nil { - writer.Flush() + if stateSyncPresent && i == len(txs)-1 { + callmsg := prepareCallMessage(msg) + _, err = statefull.ApplyBorMessage(*vmenv, callmsg) + if writer != nil { + writer.Flush() + } + } else { + _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())) + if writer != nil { + writer.Flush() + } } + if dump != nil { dump.Close() log.Info("Wrote standard trace", "file", dump.Name()) @@ -764,8 +851,9 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block // containsTx reports whether the transaction with a certain hash // is contained within the specified block. -func containsTx(block *types.Block, hash common.Hash) bool { - for _, tx := range block.Transactions() { +func (api *API) containsTx(ctx context.Context, block *types.Block, hash common.Hash) bool { + txs, _ := api.getAllBlockTransactions(ctx, block) + for _, tx := range txs { if tx.Hash() == hash { return true } @@ -775,7 +863,7 @@ func containsTx(block *types.Block, hash common.Hash) bool { // TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object. -func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { +func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig, borTx bool) (interface{}, error) { tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) if tx == nil { // For BorTransaction, there will be no trace available @@ -811,14 +899,14 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config * TxIndex: int(index), TxHash: hash, } - return api.traceTx(ctx, msg, txctx, vmctx, statedb, config) + return api.traceTx(ctx, msg, txctx, vmctx, statedb, config, borTx) } // TraceCall lets you trace a given eth_call. It collects the structured logs // created during the execution of EVM if the given transaction was added on // top of the provided block and returns them as a JSON object. // You can provide -2 as a block number to trace on top of the pending block. -func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) { +func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig, borTx bool) (interface{}, error) { // Try to retrieve the specified block var ( err error @@ -865,13 +953,13 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc Reexec: config.Reexec, } } - return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig) + return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig, borTx) } // traceTx configures a new tracer according to the provided configuration, and // executes the given message in the provided environment. The return value will // be tracer dependent. -func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { +func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, borTx bool) (interface{}, error) { // Assemble the structured logger or the JavaScript tracer var ( tracer vm.EVMLogger @@ -911,9 +999,18 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex // Call Prepare to clear out the statedb access list statedb.Prepare(txctx.TxHash, txctx.TxIndex) - result, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) - if err != nil { - return nil, fmt.Errorf("tracing failed: %w", err) + var result *core.ExecutionResult + if borTx { + callmsg := prepareCallMessage(message) + if result, err = statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { + return nil, fmt.Errorf("tracing failed: %w", err) + } + + } else { + result, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) + if err != nil { + return nil, fmt.Errorf("tracing failed: %w", err) + } } // Depending on the tracer type, format and return the output. diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index d2ed9c2179..68335239e8 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -176,6 +176,11 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block return nil, vm.BlockContext{}, nil, fmt.Errorf("transaction index %d out of range for block %#x", txIndex, block.Hash()) } +func (b *testBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { + tx, blockHash, blockNumber, index := rawdb.ReadBorTransactionWithBlockHash(b.ChainDb(), txHash, blockHash) + return tx, blockHash, blockNumber, index, nil +} + func TestTraceCall(t *testing.T) { t.Parallel() @@ -285,7 +290,7 @@ func TestTraceCall(t *testing.T) { }, } for _, testspec := range testSuite { - result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config) + result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config, false) if testspec.expectErr != nil { if err == nil { t.Errorf("Expect error %v, get nothing", testspec.expectErr) @@ -325,7 +330,7 @@ func TestTraceTransaction(t *testing.T) { b.AddTx(tx) target = tx.Hash() })) - result, err := api.TraceTransaction(context.Background(), target, nil) + result, err := api.TraceTransaction(context.Background(), target, nil, false) if err != nil { t.Errorf("Failed to trace transaction %v", err) } @@ -508,7 +513,7 @@ func TestTracingWithOverrides(t *testing.T) { }, } for i, tc := range testSuite { - result, err := api.TraceCall(context.Background(), tc.call, rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, tc.config) + result, err := api.TraceCall(context.Background(), tc.call, rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, tc.config, false) if tc.expectErr != nil { if err == nil { t.Errorf("test %d: want error %v, have nothing", i, tc.expectErr) From 002717ad236018e8b5c3ac9a4c217e987f225e32 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Thu, 13 Oct 2022 15:36:21 +0530 Subject: [PATCH 11/36] chg : major fix --- eth/tracers/api.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 12b1411ae7..c6398d1a8a 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -702,11 +702,22 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac // Generate the next state snapshot fast without tracing msg, _ := tx.AsMessage(signer, block.BaseFee()) statedb.Prepare(tx.Hash(), i) + vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{}) - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { - failed = err - break + + if stateSyncPresent && i == len(txs)-1 { + callmsg := prepareCallMessage(msg) + if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { + failed = err + break + } + } else { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { + failed = err + break + } } + // Finalize the state so any modifications are written to the trie // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect statedb.Finalise(vmenv.ChainConfig().IsEIP158(block.Number())) From 0918cf73437d6bea349bd56ec1a50d773f8643b0 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Thu, 13 Oct 2022 15:55:45 +0530 Subject: [PATCH 12/36] chg : support state-sync in newcli server debugBorBlock --- eth/tracers/api_bor.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/eth/tracers/api_bor.go b/eth/tracers/api_bor.go index f42c7a27f7..b93baae432 100644 --- a/eth/tracers/api_bor.go +++ b/eth/tracers/api_bor.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/bor/statefull" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -68,14 +69,14 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T // Execute all the transaction contained within the block concurrently var ( - signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) - txs = block.Transactions() - deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number()) + signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) + txs, stateSyncPresent = api.getAllBlockTransactions(ctx, block) + deleteEmptyObjects = api.backend.ChainConfig().IsEIP158(block.Number()) ) blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) - traceTxn := func(indx int, tx *types.Transaction) *TxTraceResult { + traceTxn := func(indx int, tx *types.Transaction, borTx bool) *TxTraceResult { message, _ := tx.AsMessage(signer, block.BaseFee()) txContext := core.NewEVMTxContext(message) @@ -88,7 +89,15 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T // Not sure if we need to do this statedb.Prepare(tx.Hash(), indx) - execRes, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) + var execRes *core.ExecutionResult + + if borTx { + callmsg := prepareCallMessage(message) + execRes, err = statefull.ApplyBorMessage(*vmenv, callmsg) + } else { + execRes, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) + } + if err != nil { return &TxTraceResult{ Error: err.Error(), @@ -115,7 +124,11 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T } for indx, tx := range txs { - res.Transactions = append(res.Transactions, traceTxn(indx, tx)) + if stateSyncPresent && indx == len(txs)-1 { + res.Transactions = append(res.Transactions, traceTxn(indx, tx, true)) + } else { + res.Transactions = append(res.Transactions, traceTxn(indx, tx, false)) + } } return res, nil From d0508e7dc0a3a348b2cf838a74212e77f3623558 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 14 Oct 2022 12:53:46 +0530 Subject: [PATCH 13/36] chg : lint files --- consensus/bor/statefull/processor.go | 3 --- eth/tracers/api.go | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/consensus/bor/statefull/processor.go b/consensus/bor/statefull/processor.go index 8ac633bb3d..0fe9baeeba 100644 --- a/consensus/bor/statefull/processor.go +++ b/consensus/bor/statefull/processor.go @@ -92,11 +92,9 @@ func ApplyMessage( gasUsed := initialGas - gasLeft return gasUsed, nil - } func ApplyBorMessage(vmenv vm.EVM, msg Callmsg) (*core.ExecutionResult, error) { - initialGas := msg.Gas() // Apply the transaction to the current state (included in the env) @@ -119,5 +117,4 @@ func ApplyBorMessage(vmenv vm.EVM, msg Callmsg) (*core.ExecutionResult, error) { Err: err, ReturnData: ret, }, nil - } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index c6398d1a8a..baf9417b82 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -308,6 +308,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config } var res interface{} + var err error if stateSyncPresent && i == len(txs)-1 { @@ -528,9 +529,8 @@ func (api *API) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, } func prepareCallMessage(msg core.Message) statefull.Callmsg { - return statefull.Callmsg{ - ethereum.CallMsg{ + CallMsg: ethereum.CallMsg{ From: msg.From(), To: msg.To(), Gas: msg.Gas(), @@ -541,7 +541,6 @@ func prepareCallMessage(msg core.Message) statefull.Callmsg { Data: msg.Data(), AccessList: msg.AccessList(), }} - } // IntermediateRoots executes a block (bad- or canon- or side-), and returns a list @@ -577,6 +576,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) deleteEmptyObjects = chainConfig.IsEIP158(block.Number()) ) + txs, stateSyncPresent := api.getAllBlockTransactions(ctx, block) for i, tx := range txs { var ( @@ -585,6 +585,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config vmenv = vm.NewEVM(vmctx, txContext, statedb, chainConfig, vm.Config{}) ) statedb.Prepare(tx.Hash(), i) + if stateSyncPresent && i == len(txs)-1 { callmsg := prepareCallMessage(msg) @@ -598,7 +599,6 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. return roots, nil } - } else { if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) @@ -677,7 +677,9 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac TxIndex: task.index, TxHash: txs[task.index].Hash(), } + var res interface{} + var err error if stateSyncPresent && task.index == len(txs)-1 { res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config, true) @@ -793,6 +795,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block canon = false } } + txs, stateSyncPresent := api.getAllBlockTransactions(ctx, block) for i, tx := range txs { // Prepare the trasaction for un-traced execution @@ -828,9 +831,11 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block // Execute the transaction and flush any traces to disk vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf) statedb.Prepare(tx.Hash(), i) + if stateSyncPresent && i == len(txs)-1 { callmsg := prepareCallMessage(msg) _, err = statefull.ApplyBorMessage(*vmenv, callmsg) + if writer != nil { writer.Flush() } @@ -910,6 +915,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config * TxIndex: int(index), TxHash: hash, } + return api.traceTx(ctx, msg, txctx, vmctx, statedb, config, borTx) } @@ -964,6 +970,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc Reexec: config.Reexec, } } + return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig, borTx) } @@ -1011,12 +1018,12 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex statedb.Prepare(txctx.TxHash, txctx.TxIndex) var result *core.ExecutionResult + if borTx { callmsg := prepareCallMessage(message) if result, err = statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { return nil, fmt.Errorf("tracing failed: %w", err) } - } else { result, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) if err != nil { From 7c9cd4c21d40ac45e698f99d9ebfc1a476f4e5e6 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Fri, 14 Oct 2022 15:51:19 +0530 Subject: [PATCH 14/36] fix: benchmark test --- core/bench_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bench_test.go b/core/bench_test.go index 3d4cf31a4e..7a02b11eb7 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -162,7 +162,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) { // genUncles generates blocks with two uncle headers. func genUncles(i int, gen *BlockGen) { - if i >= 6 { + if i >= 7 { b2 := gen.PrevBlock(i - 6).Header() b2.Extra = []byte("foo") gen.AddUncle(b2) From 554712e95447b4d78d0adab8f4c5d9cc110a278f Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Mon, 17 Oct 2022 15:44:11 +0530 Subject: [PATCH 15/36] chg : use https://github.com/maticnetwork/crand instead of JekaMas/crand --- consensus/bor/snapshot_test.go | 2 +- core/forkchoice.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/consensus/bor/snapshot_test.go b/consensus/bor/snapshot_test.go index 503bd18b24..68a9ba042f 100644 --- a/consensus/bor/snapshot_test.go +++ b/consensus/bor/snapshot_test.go @@ -5,7 +5,7 @@ import ( "sort" "testing" - "github.com/JekaMas/crand" + "github.com/maticnetwork/crand" "github.com/stretchr/testify/require" "pgregory.net/rapid" diff --git a/core/forkchoice.go b/core/forkchoice.go index 9b7b60243d..018afdfac9 100644 --- a/core/forkchoice.go +++ b/core/forkchoice.go @@ -20,7 +20,7 @@ import ( "errors" "math/big" - "github.com/JekaMas/crand" + "github.com/maticnetwork/crand" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" diff --git a/go.mod b/go.mod index 18a2ca0ae7..36595ca307 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.19 require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 github.com/BurntSushi/toml v1.1.0 - github.com/JekaMas/crand v1.0.1 github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d github.com/VictoriaMetrics/fastcache v1.6.0 github.com/aws/aws-sdk-go-v2 v1.2.0 @@ -47,6 +46,7 @@ require ( github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e github.com/julienschmidt/httprouter v1.3.0 github.com/karalabe/usb v0.0.2 + github.com/maticnetwork/crand v1.0.2 github.com/maticnetwork/polyproto v0.0.2 github.com/mattn/go-colorable v0.1.8 github.com/mattn/go-isatty v0.0.12 diff --git a/go.sum b/go.sum index dc419821c6..96fa9d3f04 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,6 @@ github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/JekaMas/crand v1.0.1 h1:FMPxkUQqH/hExl0aUXsr0UCGYZ4lJH9IJ5H/KbM6Y9A= -github.com/JekaMas/crand v1.0.1/go.mod h1:GGzGpMCht/tbaNQ5A4kSiKSqEoNAhhyTfSDQyIENBQU= github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d h1:RO27lgfZF8s9lZ3pWyzc0gCE0RZC+6/PXbRjAa0CNp8= github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d/go.mod h1:romz7UPgSYhfJkKOalzEEyV6sWtt/eAEm0nX2aOrod0= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= @@ -345,6 +343,8 @@ github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2 github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/maticnetwork/crand v1.0.2 h1:Af0tAivC8zrxXDpGWNWVT/0s1fOz8w0eRbahZgURS8I= +github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxpj5ZKxfHjyg= github.com/maticnetwork/polyproto v0.0.2 h1:cPxuxbIDItdwGnucc3lZB58U8Zfe1mH73PWTGd15554= github.com/maticnetwork/polyproto v0.0.2/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= From 225a826e0e8e3067fa5839e9f30e1306aa018327 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Mon, 17 Oct 2022 18:00:30 +0530 Subject: [PATCH 16/36] add : TriesInMemory flag --- builder/files/config.toml | 1 + core/blockchain.go | 13 ++++--- core/blockchain_test.go | 72 +++++++++++++++++------------------ internal/cli/server/config.go | 4 ++ internal/cli/server/flags.go | 7 ++++ les/handler_test.go | 4 +- les/peer.go | 2 +- les/server_requests.go | 4 +- les/test_helper.go | 2 +- 9 files changed, 61 insertions(+), 48 deletions(-) diff --git a/builder/files/config.toml b/builder/files/config.toml index 0d01f85d71..13bf82bf93 100644 --- a/builder/files/config.toml +++ b/builder/files/config.toml @@ -122,6 +122,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # triesinmemory = 128 [accounts] # allow-insecure-unlock = true diff --git a/core/blockchain.go b/core/blockchain.go index 48d5e966db..d49bd5f937 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -92,7 +92,6 @@ const ( txLookupCacheLimit = 1024 maxFutureBlocks = 256 maxTimeFutureBlocks = 30 - TriesInMemory = 128 // BlockChainVersion ensures that an incompatible database forces a resync from scratch. // @@ -132,6 +131,7 @@ type CacheConfig struct { TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory Preimages bool // Whether to store preimage of trie key to the disk + TriesInMemory uint64 // Number of recent tries to keep in memory SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it } @@ -144,6 +144,7 @@ var DefaultCacheConfig = &CacheConfig{ TrieTimeLimit: 5 * time.Minute, SnapshotLimit: 256, SnapshotWait: true, + TriesInMemory: 128, } // BlockChain represents the canonical chain given a database with a genesis @@ -829,7 +830,7 @@ func (bc *BlockChain) Stop() { if !bc.cacheConfig.TrieDirtyDisabled { triedb := bc.stateCache.TrieDB() - for _, offset := range []uint64{0, 1, TriesInMemory - 1} { + for _, offset := range []uint64{0, 1, DefaultCacheConfig.TriesInMemory - 1} { if number := bc.CurrentBlock().NumberU64(); number > offset { recent := bc.GetBlockByNumber(number - offset) @@ -1297,7 +1298,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. triedb.Reference(root, common.Hash{}) // metadata reference to keep trie alive bc.triegc.Push(root, -int64(block.NumberU64())) - if current := block.NumberU64(); current > TriesInMemory { + if current := block.NumberU64(); current > DefaultCacheConfig.TriesInMemory { // If we exceeded our memory allowance, flush matured singleton nodes to disk var ( nodes, imgs = triedb.Size() @@ -1307,7 +1308,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. triedb.Cap(limit - ethdb.IdealBatchSize) } // Find the next state trie we need to commit - chosen := current - TriesInMemory + chosen := current - DefaultCacheConfig.TriesInMemory // If we exceeded out time allowance, flush an entire trie to disk if bc.gcproc > bc.cacheConfig.TrieTimeLimit { @@ -1319,8 +1320,8 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. } else { // If we're exceeding limits but haven't reached a large enough memory gap, // warn the user that the system is becoming unstable. - if chosen < lastWrite+TriesInMemory && bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit { - log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", bc.cacheConfig.TrieTimeLimit, "optimum", float64(chosen-lastWrite)/TriesInMemory) + if chosen < lastWrite+DefaultCacheConfig.TriesInMemory && bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit { + log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", DefaultCacheConfig.TriesInMemory, "optimum", float64(chosen-lastWrite)/float64((DefaultCacheConfig.TriesInMemory))) } // Flush an entire trie and restart the counters triedb.Commit(header.Root, true, nil) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index b2c14f81ba..4d05d11198 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1652,7 +1652,7 @@ func TestTrieForkGC(t *testing.T) { db := rawdb.NewMemoryDatabase() genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) - blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) + blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*int(DefaultCacheConfig.TriesInMemory), func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) // Generate a bunch of fork blocks, each side forking from the canonical chain forks := make([]*types.Block, len(blocks)) @@ -1681,7 +1681,7 @@ func TestTrieForkGC(t *testing.T) { } } // Dereference all the recent tries and ensure no past trie is left in - for i := 0; i < TriesInMemory; i++ { + for i := 0; i < int(DefaultCacheConfig.TriesInMemory); i++ { chain.stateCache.TrieDB().Dereference(blocks[len(blocks)-1-i].Root()) chain.stateCache.TrieDB().Dereference(forks[len(blocks)-1-i].Root()) } @@ -1700,8 +1700,8 @@ func TestLargeReorgTrieGC(t *testing.T) { genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) shared, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 64, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) - original, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) - competitor, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*TriesInMemory+1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{3}) }) + original, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*int(DefaultCacheConfig.TriesInMemory), func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) + competitor, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*int(DefaultCacheConfig.TriesInMemory)+1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{3}) }) // Import the shared chain and the original canonical one diskdb := rawdb.NewMemoryDatabase() @@ -1736,7 +1736,7 @@ func TestLargeReorgTrieGC(t *testing.T) { if _, err := chain.InsertChain(competitor[len(competitor)-2:]); err != nil { t.Fatalf("failed to finalize competitor chain: %v", err) } - for i, block := range competitor[:len(competitor)-TriesInMemory] { + for i, block := range competitor[:len(competitor)-int(DefaultCacheConfig.TriesInMemory)] { if node, _ := chain.stateCache.TrieDB().Node(block.Root()); node != nil { t.Fatalf("competitor %d: competing chain state missing", i) } @@ -1882,8 +1882,8 @@ func TestInsertReceiptChainRollback(t *testing.T) { // overtake the 'canon' chain until after it's passed canon by about 200 blocks. // // Details at: -// - https://github.com/ethereum/go-ethereum/issues/18977 -// - https://github.com/ethereum/go-ethereum/pull/18988 +// - https://github.com/ethereum/go-ethereum/issues/18977 +// - https://github.com/ethereum/go-ethereum/pull/18988 func TestLowDiffLongChain(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() @@ -1892,7 +1892,7 @@ func TestLowDiffLongChain(t *testing.T) { // We must use a pretty long chain to ensure that the fork doesn't overtake us // until after at least 128 blocks post tip - blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 6*TriesInMemory, func(i int, b *BlockGen) { + blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 6*int(DefaultCacheConfig.TriesInMemory), func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) b.OffsetTime(-9) }) @@ -1910,7 +1910,7 @@ func TestLowDiffLongChain(t *testing.T) { } // Generate fork chain, starting from an early block parent := blocks[10] - fork, _ := GenerateChain(params.TestChainConfig, parent, engine, db, 8*TriesInMemory, func(i int, b *BlockGen) { + fork, _ := GenerateChain(params.TestChainConfig, parent, engine, db, 8*int(DefaultCacheConfig.TriesInMemory), func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) @@ -1979,7 +1979,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // Set the terminal total difficulty in the config gspec.Config.TerminalTotalDifficulty = big.NewInt(0) } - blocks, _ := GenerateChain(&chainConfig, genesis, genEngine, db, 2*TriesInMemory, func(i int, gen *BlockGen) { + blocks, _ := GenerateChain(&chainConfig, genesis, genEngine, db, 2*int(DefaultCacheConfig.TriesInMemory), func(i int, gen *BlockGen) { tx, err := types.SignTx(types.NewTransaction(nonce, common.HexToAddress("deadbeef"), big.NewInt(100), 21000, big.NewInt(int64(i+1)*params.GWei), nil), signer, key) if err != nil { t.Fatalf("failed to create tx: %v", err) @@ -1991,9 +1991,9 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon t.Fatalf("block %d: failed to insert into chain: %v", n, err) } - lastPrunedIndex := len(blocks) - TriesInMemory - 1 + lastPrunedIndex := len(blocks) - int(DefaultCacheConfig.TriesInMemory) - 1 lastPrunedBlock := blocks[lastPrunedIndex] - firstNonPrunedBlock := blocks[len(blocks)-TriesInMemory] + firstNonPrunedBlock := blocks[len(blocks)-int(DefaultCacheConfig.TriesInMemory)] // Verify pruning of lastPrunedBlock if chain.HasBlockAndState(lastPrunedBlock.Hash(), lastPrunedBlock.NumberU64()) { @@ -2019,7 +2019,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // Generate fork chain, make it longer than canon parentIndex := lastPrunedIndex + blocksBetweenCommonAncestorAndPruneblock parent := blocks[parentIndex] - fork, _ := GenerateChain(&chainConfig, parent, genEngine, db, 2*TriesInMemory, func(i int, b *BlockGen) { + fork, _ := GenerateChain(&chainConfig, parent, genEngine, db, 2*int(DefaultCacheConfig.TriesInMemory), func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) // Prepend the parent(s) @@ -2046,7 +2046,8 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // That is: the sidechain for import contains some blocks already present in canon chain. // So the blocks are // [ Cn, Cn+1, Cc, Sn+3 ... Sm] -// ^ ^ ^ pruned +// +// ^ ^ ^ pruned func TestPrunedImportSide(t *testing.T) { //glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false))) //glogger.Verbosity(3) @@ -2841,9 +2842,9 @@ func BenchmarkBlockChain_1x1000Executions(b *testing.B) { // This internally leads to a sidechain import, since the blocks trigger an // ErrPrunedAncestor error. // This may e.g. happen if -// 1. Downloader rollbacks a batch of inserted blocks and exits -// 2. Downloader starts to sync again -// 3. The blocks fetched are all known and canonical blocks +// 1. Downloader rollbacks a batch of inserted blocks and exits +// 2. Downloader starts to sync again +// 3. The blocks fetched are all known and canonical blocks func TestSideImportPrunedBlocks(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() @@ -2851,7 +2852,7 @@ func TestSideImportPrunedBlocks(t *testing.T) { genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) // Generate and import the canonical chain - blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) + blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*int(DefaultCacheConfig.TriesInMemory), nil) diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) @@ -2863,14 +2864,14 @@ func TestSideImportPrunedBlocks(t *testing.T) { t.Fatalf("block %d: failed to insert into chain: %v", n, err) } - lastPrunedIndex := len(blocks) - TriesInMemory - 1 + lastPrunedIndex := len(blocks) - int(DefaultCacheConfig.TriesInMemory) - 1 lastPrunedBlock := blocks[lastPrunedIndex] // Verify pruning of lastPrunedBlock if chain.HasBlockAndState(lastPrunedBlock.Hash(), lastPrunedBlock.NumberU64()) { t.Errorf("Block %d not pruned", lastPrunedBlock.NumberU64()) } - firstNonPrunedBlock := blocks[len(blocks)-TriesInMemory] + firstNonPrunedBlock := blocks[len(blocks)-int(DefaultCacheConfig.TriesInMemory)] // Verify firstNonPrunedBlock is not pruned if !chain.HasBlockAndState(firstNonPrunedBlock.Hash(), firstNonPrunedBlock.NumberU64()) { t.Errorf("Block %d pruned", firstNonPrunedBlock.NumberU64()) @@ -3356,20 +3357,19 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) { // TestInitThenFailCreateContract tests a pretty notorious case that happened // on mainnet over blocks 7338108, 7338110 and 7338115. -// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated -// with 0.001 ether (thus created but no code) -// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on -// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the -// deployment fails due to OOG during initcode execution -// - Block 7338115: another tx checks the balance of -// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as -// zero. +// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated +// with 0.001 ether (thus created but no code) +// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on +// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the +// deployment fails due to OOG during initcode execution +// - Block 7338115: another tx checks the balance of +// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as +// zero. // // The problem being that the snapshotter maintains a destructset, and adds items // to the destructset in case something is created "onto" an existing item. // We need to either roll back the snapDestructs, or not place it into snapDestructs // in the first place. -// func TestInitThenFailCreateContract(t *testing.T) { var ( // Generate a canonical chain to act as the main dataset @@ -3558,13 +3558,13 @@ func TestEIP2718Transition(t *testing.T) { // TestEIP1559Transition tests the following: // -// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. -// 2. Gas accounting for access lists on EIP-1559 transactions is correct. -// 3. Only the transaction's tip will be received by the coinbase. -// 4. The transaction sender pays for both the tip and baseFee. -// 5. The coinbase receives only the partially realized tip when -// gasFeeCap - gasTipCap < baseFee. -// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). +// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. +// 2. Gas accounting for access lists on EIP-1559 transactions is correct. +// 3. Only the transaction's tip will be received by the coinbase. +// 4. The transaction sender pays for both the tip and baseFee. +// 5. The coinbase receives only the partially realized tip when +// gasFeeCap - gasTipCap < baseFee. +// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). func TestEIP1559Transition(t *testing.T) { var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index e5e3a8b03e..8bc4c3e753 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -364,6 +364,9 @@ type CacheConfig struct { // TxLookupLimit sets the maximum number of blocks from head whose tx indices are reserved. TxLookupLimit uint64 `hcl:"txlookuplimit,optional" toml:"txlookuplimit,optional"` + + // Number of block states to keep in memory (default = 128) + TriesInMemory uint64 `hcl:"triesinmemory,optional" toml:"triesinmemory,optional"` } type AccountsConfig struct { @@ -509,6 +512,7 @@ func DefaultConfig() *Config { NoPrefetch: false, Preimages: false, TxLookupLimit: 2350000, + TriesInMemory: 128, }, Accounts: &AccountsConfig{ Unlock: []string{}, diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 6e93a94de0..025ce8c80c 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -304,6 +304,13 @@ func (c *Command) Flags() *flagset.Flagset { Default: c.cliConfig.Cache.Preimages, Group: "Cache", }) + f.Uint64Flag(&flagset.Uint64Flag{ + Name: "cache.triesinmemory", + Usage: "Number of block states (tries) to keep in memory (default = 128)", + Value: &c.cliConfig.Cache.TriesInMemory, + Default: c.cliConfig.Cache.TriesInMemory, + Group: "Cache", + }) f.Uint64Flag(&flagset.Uint64Flag{ Name: "txlookuplimit", Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)", diff --git a/les/handler_test.go b/les/handler_test.go index aba45764b3..3ceabdf8ec 100644 --- a/les/handler_test.go +++ b/les/handler_test.go @@ -316,7 +316,7 @@ func TestGetStaleCodeLes4(t *testing.T) { testGetStaleCode(t, 4) } func testGetStaleCode(t *testing.T, protocol int) { netconfig := testnetConfig{ - blocks: core.TriesInMemory + 4, + blocks: int(core.DefaultCacheConfig.TriesInMemory) + 4, protocol: protocol, nopruning: true, } @@ -430,7 +430,7 @@ func TestGetStaleProofLes4(t *testing.T) { testGetStaleProof(t, 4) } func testGetStaleProof(t *testing.T, protocol int) { netconfig := testnetConfig{ - blocks: core.TriesInMemory + 4, + blocks: int(core.DefaultCacheConfig.TriesInMemory) + 4, protocol: protocol, nopruning: true, } diff --git a/les/peer.go b/les/peer.go index 499429739d..a525336f0a 100644 --- a/les/peer.go +++ b/les/peer.go @@ -1058,7 +1058,7 @@ func (p *clientPeer) Handshake(td *big.Int, head common.Hash, headNum uint64, ge // If local ethereum node is running in archive mode, advertise ourselves we have // all version state data. Otherwise only recent state is available. - stateRecent := uint64(core.TriesInMemory - blockSafetyMargin) + stateRecent := uint64(core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin) if server.archiveMode { stateRecent = 0 } diff --git a/les/server_requests.go b/les/server_requests.go index bab5f733d5..3595a6ab38 100644 --- a/les/server_requests.go +++ b/les/server_requests.go @@ -297,7 +297,7 @@ func handleGetCode(msg Decoder) (serveRequestFn, uint64, uint64, error) { // Refuse to search stale state data in the database since looking for // a non-exist key is kind of expensive. local := bc.CurrentHeader().Number.Uint64() - if !backend.ArchiveMode() && header.Number.Uint64()+core.TriesInMemory <= local { + if !backend.ArchiveMode() && header.Number.Uint64()+core.DefaultCacheConfig.TriesInMemory <= local { p.Log().Debug("Reject stale code request", "number", header.Number.Uint64(), "head", local) p.bumpInvalid() continue @@ -396,7 +396,7 @@ func handleGetProofs(msg Decoder) (serveRequestFn, uint64, uint64, error) { // Refuse to search stale state data in the database since looking for // a non-exist key is kind of expensive. local := bc.CurrentHeader().Number.Uint64() - if !backend.ArchiveMode() && header.Number.Uint64()+core.TriesInMemory <= local { + if !backend.ArchiveMode() && header.Number.Uint64()+core.DefaultCacheConfig.TriesInMemory <= local { p.Log().Debug("Reject stale trie request", "number", header.Number.Uint64(), "head", local) p.bumpInvalid() continue diff --git a/les/test_helper.go b/les/test_helper.go index a099458353..d68370d508 100644 --- a/les/test_helper.go +++ b/les/test_helper.go @@ -377,7 +377,7 @@ func (p *testPeer) handshakeWithClient(t *testing.T, td *big.Int, head common.Ha sendList = sendList.add("serveHeaders", nil) sendList = sendList.add("serveChainSince", uint64(0)) sendList = sendList.add("serveStateSince", uint64(0)) - sendList = sendList.add("serveRecentState", uint64(core.TriesInMemory-4)) + sendList = sendList.add("serveRecentState", uint64(core.DefaultCacheConfig.TriesInMemory-4)) sendList = sendList.add("txRelay", nil) sendList = sendList.add("flowControl/BL", testBufLimit) sendList = sendList.add("flowControl/MRR", testBufRecharge) From 3db339b6fe728fa47adfeef89fb6dc64ff52d495 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Mon, 17 Oct 2022 18:07:32 +0530 Subject: [PATCH 17/36] add : lint --- core/blockchain_test.go | 3 +++ les/peer.go | 2 +- les/test_helper.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 4d05d11198..d44d563b20 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1736,6 +1736,7 @@ func TestLargeReorgTrieGC(t *testing.T) { if _, err := chain.InsertChain(competitor[len(competitor)-2:]); err != nil { t.Fatalf("failed to finalize competitor chain: %v", err) } + for i, block := range competitor[:len(competitor)-int(DefaultCacheConfig.TriesInMemory)] { if node, _ := chain.stateCache.TrieDB().Node(block.Root()); node != nil { t.Fatalf("competitor %d: competing chain state missing", i) @@ -1979,6 +1980,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // Set the terminal total difficulty in the config gspec.Config.TerminalTotalDifficulty = big.NewInt(0) } + blocks, _ := GenerateChain(&chainConfig, genesis, genEngine, db, 2*int(DefaultCacheConfig.TriesInMemory), func(i int, gen *BlockGen) { tx, err := types.SignTx(types.NewTransaction(nonce, common.HexToAddress("deadbeef"), big.NewInt(100), 21000, big.NewInt(int64(i+1)*params.GWei), nil), signer, key) if err != nil { @@ -2871,6 +2873,7 @@ func TestSideImportPrunedBlocks(t *testing.T) { if chain.HasBlockAndState(lastPrunedBlock.Hash(), lastPrunedBlock.NumberU64()) { t.Errorf("Block %d not pruned", lastPrunedBlock.NumberU64()) } + firstNonPrunedBlock := blocks[len(blocks)-int(DefaultCacheConfig.TriesInMemory)] // Verify firstNonPrunedBlock is not pruned if !chain.HasBlockAndState(firstNonPrunedBlock.Hash(), firstNonPrunedBlock.NumberU64()) { diff --git a/les/peer.go b/les/peer.go index a525336f0a..46a88cfff7 100644 --- a/les/peer.go +++ b/les/peer.go @@ -1058,7 +1058,7 @@ func (p *clientPeer) Handshake(td *big.Int, head common.Hash, headNum uint64, ge // If local ethereum node is running in archive mode, advertise ourselves we have // all version state data. Otherwise only recent state is available. - stateRecent := uint64(core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin) + stateRecent := core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin if server.archiveMode { stateRecent = 0 } diff --git a/les/test_helper.go b/les/test_helper.go index d68370d508..1e6fb6653f 100644 --- a/les/test_helper.go +++ b/les/test_helper.go @@ -377,7 +377,7 @@ func (p *testPeer) handshakeWithClient(t *testing.T, td *big.Int, head common.Ha sendList = sendList.add("serveHeaders", nil) sendList = sendList.add("serveChainSince", uint64(0)) sendList = sendList.add("serveStateSince", uint64(0)) - sendList = sendList.add("serveRecentState", uint64(core.DefaultCacheConfig.TriesInMemory-4)) + sendList = sendList.add("serveRecentState", core.DefaultCacheConfig.TriesInMemory-4) sendList = sendList.add("txRelay", nil) sendList = sendList.add("flowControl/BL", testBufLimit) sendList = sendList.add("flowControl/MRR", testBufRecharge) From ec57aabf9e64d6c3f6754aa9b3ed3d483e165aac Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Tue, 18 Oct 2022 03:56:55 +0530 Subject: [PATCH 18/36] chg : minor fix --- core/blockchain.go | 13 ++++++++----- core/blockchain_test.go | 12 ++++++------ core/tests/blockchain_sethead_test.go | 2 ++ eth/backend.go | 1 + eth/ethconfig/config.go | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index d49bd5f937..5349ea8866 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -230,6 +230,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par if cacheConfig == nil { cacheConfig = DefaultCacheConfig } + if cacheConfig.TriesInMemory <= 0 { + cacheConfig.TriesInMemory = 128 + } bodyCache, _ := lru.New(bodyCacheLimit) bodyRLPCache, _ := lru.New(bodyCacheLimit) receiptsCache, _ := lru.New(receiptsCacheLimit) @@ -830,7 +833,7 @@ func (bc *BlockChain) Stop() { if !bc.cacheConfig.TrieDirtyDisabled { triedb := bc.stateCache.TrieDB() - for _, offset := range []uint64{0, 1, DefaultCacheConfig.TriesInMemory - 1} { + for _, offset := range []uint64{0, 1, bc.cacheConfig.TriesInMemory - 1} { if number := bc.CurrentBlock().NumberU64(); number > offset { recent := bc.GetBlockByNumber(number - offset) @@ -1298,7 +1301,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. triedb.Reference(root, common.Hash{}) // metadata reference to keep trie alive bc.triegc.Push(root, -int64(block.NumberU64())) - if current := block.NumberU64(); current > DefaultCacheConfig.TriesInMemory { + if current := block.NumberU64(); current > bc.cacheConfig.TriesInMemory { // If we exceeded our memory allowance, flush matured singleton nodes to disk var ( nodes, imgs = triedb.Size() @@ -1308,7 +1311,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. triedb.Cap(limit - ethdb.IdealBatchSize) } // Find the next state trie we need to commit - chosen := current - DefaultCacheConfig.TriesInMemory + chosen := current - bc.cacheConfig.TriesInMemory // If we exceeded out time allowance, flush an entire trie to disk if bc.gcproc > bc.cacheConfig.TrieTimeLimit { @@ -1320,8 +1323,8 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. } else { // If we're exceeding limits but haven't reached a large enough memory gap, // warn the user that the system is becoming unstable. - if chosen < lastWrite+DefaultCacheConfig.TriesInMemory && bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit { - log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", DefaultCacheConfig.TriesInMemory, "optimum", float64(chosen-lastWrite)/float64((DefaultCacheConfig.TriesInMemory))) + if chosen < lastWrite+bc.cacheConfig.TriesInMemory && bc.gcproc >= 2*bc.cacheConfig.TrieTimeLimit { + log.Info("State in memory for too long, committing", "time", bc.gcproc, "allowance", bc.cacheConfig.TriesInMemory, "optimum", float64(chosen-lastWrite)/float64((bc.cacheConfig.TriesInMemory))) } // Flush an entire trie and restart the counters triedb.Commit(header.Root, true, nil) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index d44d563b20..fa6b61225e 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1681,7 +1681,7 @@ func TestTrieForkGC(t *testing.T) { } } // Dereference all the recent tries and ensure no past trie is left in - for i := 0; i < int(DefaultCacheConfig.TriesInMemory); i++ { + for i := 0; i < int(chain.cacheConfig.TriesInMemory); i++ { chain.stateCache.TrieDB().Dereference(blocks[len(blocks)-1-i].Root()) chain.stateCache.TrieDB().Dereference(forks[len(blocks)-1-i].Root()) } @@ -1737,7 +1737,7 @@ func TestLargeReorgTrieGC(t *testing.T) { t.Fatalf("failed to finalize competitor chain: %v", err) } - for i, block := range competitor[:len(competitor)-int(DefaultCacheConfig.TriesInMemory)] { + for i, block := range competitor[:len(competitor)-int(chain.cacheConfig.TriesInMemory)] { if node, _ := chain.stateCache.TrieDB().Node(block.Root()); node != nil { t.Fatalf("competitor %d: competing chain state missing", i) } @@ -1993,9 +1993,9 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon t.Fatalf("block %d: failed to insert into chain: %v", n, err) } - lastPrunedIndex := len(blocks) - int(DefaultCacheConfig.TriesInMemory) - 1 + lastPrunedIndex := len(blocks) - int(chain.cacheConfig.TriesInMemory) - 1 lastPrunedBlock := blocks[lastPrunedIndex] - firstNonPrunedBlock := blocks[len(blocks)-int(DefaultCacheConfig.TriesInMemory)] + firstNonPrunedBlock := blocks[len(blocks)-int(chain.cacheConfig.TriesInMemory)] // Verify pruning of lastPrunedBlock if chain.HasBlockAndState(lastPrunedBlock.Hash(), lastPrunedBlock.NumberU64()) { @@ -2866,7 +2866,7 @@ func TestSideImportPrunedBlocks(t *testing.T) { t.Fatalf("block %d: failed to insert into chain: %v", n, err) } - lastPrunedIndex := len(blocks) - int(DefaultCacheConfig.TriesInMemory) - 1 + lastPrunedIndex := len(blocks) - int(chain.cacheConfig.TriesInMemory) - 1 lastPrunedBlock := blocks[lastPrunedIndex] // Verify pruning of lastPrunedBlock @@ -2874,7 +2874,7 @@ func TestSideImportPrunedBlocks(t *testing.T) { t.Errorf("Block %d not pruned", lastPrunedBlock.NumberU64()) } - firstNonPrunedBlock := blocks[len(blocks)-int(DefaultCacheConfig.TriesInMemory)] + firstNonPrunedBlock := blocks[len(blocks)-int(chain.cacheConfig.TriesInMemory)] // Verify firstNonPrunedBlock is not pruned if !chain.HasBlockAndState(firstNonPrunedBlock.Hash(), firstNonPrunedBlock.NumberU64()) { t.Errorf("Block %d pruned", firstNonPrunedBlock.NumberU64()) diff --git a/core/tests/blockchain_sethead_test.go b/core/tests/blockchain_sethead_test.go index ad6e78697d..6160dfb48f 100644 --- a/core/tests/blockchain_sethead_test.go +++ b/core/tests/blockchain_sethead_test.go @@ -2082,6 +2082,7 @@ func testSetHead(t *testing.T, tt *rewindTest, snapshots bool) { // verifyNoGaps checks that there are no gaps after the initial set of blocks in // the database and errors if found. +// //nolint:gocognit func verifyNoGaps(t *testing.T, chain *core.BlockChain, canonical bool, inserted types.Blocks) { t.Helper() @@ -2135,6 +2136,7 @@ func verifyNoGaps(t *testing.T, chain *core.BlockChain, canonical bool, inserted // verifyCutoff checks that there are no chain data available in the chain after // the specified limit, but that it is available before. +// //nolint:gocognit func verifyCutoff(t *testing.T, chain *core.BlockChain, canonical bool, inserted types.Blocks, head int) { t.Helper() diff --git a/eth/backend.go b/eth/backend.go index cc65d9837f..824fec8914 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -218,6 +218,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { TrieTimeLimit: config.TrieTimeout, SnapshotLimit: config.SnapshotCache, Preimages: config.Preimages, + TriesInMemory: config.TriesInMemory, } ) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index adb36ffadd..c9272758ab 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -176,6 +176,7 @@ type Config struct { TrieTimeout time.Duration SnapshotCache int Preimages bool + TriesInMemory uint64 // Mining options Miner miner.Config From b2c125f81e633ece84895f750b40598392852bc8 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Tue, 18 Oct 2022 03:58:31 +0530 Subject: [PATCH 19/36] add : lint --- core/blockchain.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/blockchain.go b/core/blockchain.go index 5349ea8866..e1fc269759 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -230,6 +230,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par if cacheConfig == nil { cacheConfig = DefaultCacheConfig } + if cacheConfig.TriesInMemory <= 0 { cacheConfig.TriesInMemory = 128 } From 1ae3d42866db71388ca8d8e5f4c0b5948b09c5dc Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Thu, 20 Oct 2022 00:43:43 +0530 Subject: [PATCH 20/36] fix: address PR comments --- tests/bor/bor_reorg_test.go | 201 +++++------------------------------- tests/bor/helper.go | 121 ++++++++++++++++++++++ 2 files changed, 145 insertions(+), 177 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index f68566ee5f..0725881180 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -3,161 +3,27 @@ package bor import ( - "crypto/ecdsa" - "encoding/json" - "io/ioutil" - "math/big" - "os" "sync" "testing" "time" - "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/fdlimit" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/eth/downloader" - "github.com/ethereum/go-ethereum/eth/ethconfig" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/p2p/enode" - "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/assert" ) -var ( - // addr1 = 0x71562b71999873DB5b286dF957af199Ec94617F7 - pkey1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - // addr2 = 0x9fB29AAc15b9A4B7F17c3385939b007540f4d791 - pkey2, _ = crypto.HexToECDSA("9b28f36fbd67381120752d6172ecdcf10e06ab2d9a1367aac00cdcd6ac7855d3") - keys = []*ecdsa.PrivateKey{pkey1, pkey2} -) - -func initMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey) (*node.Node, *eth.Ethereum, error) { - // Define the basic configurations for the Ethereum node - datadir, _ := ioutil.TempDir("", "") - - config := &node.Config{ - Name: "geth", - Version: params.Version, - DataDir: datadir, - P2P: p2p.Config{ - ListenAddr: "0.0.0.0:0", - NoDiscovery: true, - MaxPeers: 25, - }, - UseLightweightKDF: true, - } - // Create the node and configure a full Ethereum node on it - stack, err := node.New(config) - if err != nil { - return nil, nil, err - } - ethBackend, err := eth.New(stack, ðconfig.Config{ - Genesis: genesis, - NetworkId: genesis.Config.ChainID.Uint64(), - SyncMode: downloader.FullSync, - DatabaseCache: 256, - DatabaseHandles: 256, - TxPool: core.DefaultTxPoolConfig, - GPO: ethconfig.Defaults.GPO, - Ethash: ethconfig.Defaults.Ethash, - Miner: miner.Config{ - Etherbase: crypto.PubkeyToAddress(privKey.PublicKey), - GasCeil: genesis.GasLimit * 11 / 10, - GasPrice: big.NewInt(1), - Recommit: time.Second, - }, - WithoutHeimdall: true, - }) - if err != nil { - return nil, nil, err - } - - // register backend to account manager with keystore for signing - keydir := stack.KeyStoreDir() - - n, p := keystore.StandardScryptN, keystore.StandardScryptP - kStore := keystore.NewKeyStore(keydir, n, p) - - kStore.ImportECDSA(privKey, "") - acc := kStore.Accounts()[0] - kStore.Unlock(acc, "") - // proceed to authorize the local account manager in any case - ethBackend.AccountManager().AddBackend(kStore) - - // ethBackend.AccountManager().AddBackend() - err = stack.Start() - return stack, ethBackend, err -} - -func initGenesis(t *testing.T, faucets []*ecdsa.PrivateKey) *core.Genesis { - - // sprint size = 8 in genesis - genesisData, err := ioutil.ReadFile("./testdata/genesis_2val.json") - if err != nil { - t.Fatalf("%s", err) - } - - genesis := &core.Genesis{} - - if err := json.Unmarshal(genesisData, genesis); err != nil { - t.Fatalf("%s", err) - } - - genesis.Config.ChainID = big.NewInt(15001) - genesis.Config.EIP150Hash = common.Hash{} - - return genesis -} - func TestValidatorWentOffline(t *testing.T) { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) - fdlimit.Raise(2048) - - // Generate a batch of accounts to seal and fund with - faucets := make([]*ecdsa.PrivateKey, 128) - for i := 0; i < len(faucets); i++ { - faucets[i], _ = crypto.GenerateKey() - } - // Create an Ethash network based off of the Ropsten config - genesis := initGenesis(t, faucets) + genesis := initGenesis(t) + stacks, nodes, enodes := setupMiner(t, 2, genesis) - var ( - stacks []*node.Node - nodes []*eth.Ethereum - enodes []*enode.Node - ) - for i := 0; i < 2; i++ { - // Start the node and wait until it's up - stack, ethBackend, err := initMiner(genesis, keys[i]) - if err != nil { - t.Fatal("Error occured while initialising miner", "error", err) + defer func() { + for _, stack := range stacks { + stack.Close() } - defer stack.Close() - - for stack.Server().NodeInfo().Ports.Listener == 0 { - time.Sleep(250 * time.Millisecond) - } - // Connect the node to all the previous ones - for _, n := range enodes { - stack.Server().AddPeer(n) - } - // Start tracking the node and its enode - stacks = append(stacks, stack) - nodes = append(nodes, ethBackend) - enodes = append(enodes, stack.Server().Self()) - } + }() // Iterate over all the nodes and start mining - time.Sleep(3 * time.Second) for _, node := range nodes { if err := node.StartMining(1); err != nil { t.Fatal("Error occured while starting miner", "node", node, "error", err) @@ -320,17 +186,9 @@ func TestForkWithBlockTime(t *testing.T) { forkExpected: true, }, } - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) - fdlimit.Raise(2048) - - // Generate a batch of accounts to seal and fund with - faucets := make([]*ecdsa.PrivateKey, 128) - for i := 0; i < len(faucets); i++ { - faucets[i], _ = crypto.GenerateKey() - } // Create an Ethash network based off of the Ropsten config - genesis := initGenesis(t, faucets) + genesis := initGenesis(t) for _, test := range cases { genesis.Config.Bor.Sprint = test.sprint @@ -338,35 +196,15 @@ func TestForkWithBlockTime(t *testing.T) { genesis.Config.Bor.BackupMultiplier = test.blockTime genesis.Config.Bor.ProducerDelay = test.producerDelay - var ( - stacks []*node.Node - nodes []*eth.Ethereum - enodes []*enode.Node - ) + stacks, nodes, _ := setupMiner(t, 2, genesis) - for i := 0; i < 2; i++ { - // Start the node and wait until it's up - stack, ethBackend, err := initMiner(genesis, keys[i]) - if err != nil { - t.Fatal("Error occured while initialising miner", "error", err) + defer func() { + for _, stack := range stacks { + stack.Close() } - defer stack.Close() - - for stack.Server().NodeInfo().Ports.Listener == 0 { - time.Sleep(250 * time.Millisecond) - } - // Connect the node to all the previous ones - for _, n := range enodes { - stack.Server().AddPeer(n) - } - // Start tracking the node and its enode - stacks = append(stacks, stack) - nodes = append(nodes, ethBackend) - enodes = append(enodes, stack.Server().Self()) - } + }() // Iterate over all the nodes and start mining - time.Sleep(3 * time.Second) for _, node := range nodes { if err := node.StartMining(1); err != nil { t.Fatal("Error occured while starting miner", "node", node, "error", err) @@ -375,22 +213,31 @@ func TestForkWithBlockTime(t *testing.T) { var wg sync.WaitGroup blockHeaders := make([]*types.Header, 2) + ticker := time.NewTicker(time.Duration(test.blockTime["0"]) * time.Second) for i := 0; i < 2; i++ { wg.Add(1) go func(i int) { defer wg.Done() + for { - blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) - if blockHeaders[i] != nil { - break + select { + case <-ticker.C: + blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) + if blockHeaders[i] != nil { + return + } + default: + } } + }(i) } wg.Wait() + ticker.Stop() // Before the end of sprint blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(test.sprint - 1) diff --git a/tests/bor/helper.go b/tests/bor/helper.go index ddddc97572..d9b74372cb 100644 --- a/tests/bor/helper.go +++ b/tests/bor/helper.go @@ -4,6 +4,7 @@ package bor import ( "context" + "crypto/ecdsa" "encoding/hex" "encoding/json" "fmt" @@ -16,6 +17,7 @@ import ( "github.com/golang/mock/gomock" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" @@ -32,7 +34,13 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/miner" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/tests/bor/mocks" ) @@ -46,6 +54,8 @@ var ( // This account is one the validators for 1st span (0-indexed) key2, _ = crypto.HexToECDSA(privKey2) addr2 = crypto.PubkeyToAddress(key2.PublicKey) // 0x9fB29AAc15b9A4B7F17c3385939b007540f4d791 + + keys = []*ecdsa.PrivateKey{key, key2} ) const ( @@ -66,6 +76,117 @@ type initializeData struct { ethereum *eth.Ethereum } +func setupMiner(t *testing.T, n int, genesis *core.Genesis) ([]*node.Node, []*eth.Ethereum, []*enode.Node) { + t.Helper() + + // Create an Ethash network based off of the Ropsten config + var ( + stacks []*node.Node + nodes []*eth.Ethereum + enodes []*enode.Node + ) + + for i := 0; i < n; i++ { + // Start the node and wait until it's up + stack, ethBackend, err := initMiner(genesis, keys[i]) + if err != nil { + t.Fatal("Error occured while initialising miner", "error", err) + } + + for stack.Server().NodeInfo().Ports.Listener == 0 { + time.Sleep(250 * time.Millisecond) + } + // Connect the node to all the previous ones + for _, n := range enodes { + stack.Server().AddPeer(n) + } + // Start tracking the node and its enode + stacks = append(stacks, stack) + nodes = append(nodes, ethBackend) + enodes = append(enodes, stack.Server().Self()) + } + + return stacks, nodes, enodes +} + +func initMiner(genesis *core.Genesis, privKey *ecdsa.PrivateKey) (*node.Node, *eth.Ethereum, error) { + // Define the basic configurations for the Ethereum node + datadir, _ := ioutil.TempDir("", "") + + config := &node.Config{ + Name: "geth", + Version: params.Version, + DataDir: datadir, + P2P: p2p.Config{ + ListenAddr: "0.0.0.0:0", + NoDiscovery: true, + MaxPeers: 25, + }, + UseLightweightKDF: true, + } + // Create the node and configure a full Ethereum node on it + stack, err := node.New(config) + if err != nil { + return nil, nil, err + } + ethBackend, err := eth.New(stack, ðconfig.Config{ + Genesis: genesis, + NetworkId: genesis.Config.ChainID.Uint64(), + SyncMode: downloader.FullSync, + DatabaseCache: 256, + DatabaseHandles: 256, + TxPool: core.DefaultTxPoolConfig, + GPO: ethconfig.Defaults.GPO, + Ethash: ethconfig.Defaults.Ethash, + Miner: miner.Config{ + Etherbase: crypto.PubkeyToAddress(privKey.PublicKey), + GasCeil: genesis.GasLimit * 11 / 10, + GasPrice: big.NewInt(1), + Recommit: time.Second, + }, + WithoutHeimdall: true, + }) + if err != nil { + return nil, nil, err + } + + // register backend to account manager with keystore for signing + keydir := stack.KeyStoreDir() + + n, p := keystore.StandardScryptN, keystore.StandardScryptP + kStore := keystore.NewKeyStore(keydir, n, p) + + kStore.ImportECDSA(privKey, "") + acc := kStore.Accounts()[0] + kStore.Unlock(acc, "") + // proceed to authorize the local account manager in any case + ethBackend.AccountManager().AddBackend(kStore) + + err = stack.Start() + return stack, ethBackend, err +} + +func initGenesis(t *testing.T) *core.Genesis { + t.Helper() + + // sprint size = 8 in genesis + genesisData, err := ioutil.ReadFile("./testdata/genesis_2val.json") + if err != nil { + t.Fatalf("%s", err) + } + + genesis := &core.Genesis{} + + if err := json.Unmarshal(genesisData, genesis); err != nil { + t.Fatalf("%s", err) + } + + genesis.Config.ChainID = big.NewInt(15001) + genesis.Config.EIP150Hash = common.Hash{} + + return genesis +} + func buildEthereumInstance(t *testing.T, db ethdb.Database) *initializeData { genesisData, err := ioutil.ReadFile("./testdata/genesis.json") if err != nil { From c954606250c0e05a703e41db214ef4fb804d0a34 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Thu, 20 Oct 2022 10:20:45 +0200 Subject: [PATCH 21/36] dev: fix: ci (#559) * dev: fix: ci * dev: fix: add default block configs * dev: fix: add sprintSize * dev: fix: revert * dev: fix: go-versions --- .github/matic-cli-config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/matic-cli-config.yml b/.github/matic-cli-config.yml index 2b83b684c6..8bdfe82b3b 100644 --- a/.github/matic-cli-config.yml +++ b/.github/matic-cli-config.yml @@ -3,9 +3,13 @@ defaultFee: 2000 borChainId: "15001" heimdallChainId: heimdall-15001 contractsBranch: jc/v0.3.1-backport +sprintSize: 64 +blockNumber: '0' +blockTime: '2' numOfValidators: 3 numOfNonValidators: 0 ethURL: http://ganache:9545 +ethHostUser: ubuntu devnetType: docker borDockerBuildContext: "../../bor" heimdallDockerBuildContext: "https://github.com/maticnetwork/heimdall.git#develop" From aab72143d9c51283fb74358dee69bcd7fabb21e3 Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 19 Oct 2022 14:55:31 -0700 Subject: [PATCH 22/36] Force load default tracers --- internal/cli/server/server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/cli/server/server.go b/internal/cli/server/server.go index 905de36e09..863a800e48 100644 --- a/internal/cli/server/server.go +++ b/internal/cli/server/server.go @@ -36,6 +36,10 @@ import ( "github.com/ethereum/go-ethereum/metrics/influxdb" "github.com/ethereum/go-ethereum/metrics/prometheus" "github.com/ethereum/go-ethereum/node" + + // Force-load the tracer engines to trigger registration + _ "github.com/ethereum/go-ethereum/eth/tracers/js" + _ "github.com/ethereum/go-ethereum/eth/tracers/native" ) type Server struct { From 8aab37492630a1c4d82cf3ae30a7e9e801c35b64 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Fri, 21 Oct 2022 02:15:42 +0530 Subject: [PATCH 23/36] metrics: handle values from config file (#565) * metrics: handle metrics flag from config in metrics.init() * internal/cli/server: log for metrics enabling and misconfiguration --- internal/cli/server/server.go | 10 +++++++ metrics/metrics.go | 53 ++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/internal/cli/server/server.go b/internal/cli/server/server.go index 863a800e48..8d68fd69f0 100644 --- a/internal/cli/server/server.go +++ b/internal/cli/server/server.go @@ -257,6 +257,12 @@ func (s *Server) Stop() { } func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error { + // Check the global metrics if they're matching with the provided config + if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive { + log.Warn("Metric misconfiguration, some of them might not be visible") + } + + // Update the values anyways (for services which don't need immediate attention) metrics.Enabled = config.Enabled metrics.EnabledExpensive = config.Expensive @@ -267,6 +273,10 @@ func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error log.Info("Enabling metrics collection") + if metrics.EnabledExpensive { + log.Info("Enabling expensive metrics collection") + } + // influxdb if v1Enabled, v2Enabled := config.InfluxDB.V1Enabled, config.InfluxDB.V2Enabled; v1Enabled || v2Enabled { if v1Enabled && v2Enabled { diff --git a/metrics/metrics.go b/metrics/metrics.go index 747d6471a7..1d0133e850 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/log" + "github.com/BurntSushi/toml" ) // Enabled is checked by the constructor functions for all of the @@ -32,26 +32,71 @@ var enablerFlags = []string{"metrics"} // expensiveEnablerFlags is the CLI flag names to use to enable metrics collections. var expensiveEnablerFlags = []string{"metrics.expensive"} +// configFlag is the CLI flag name to use to start node by providing a toml based config +var configFlag = "config" + // Init enables or disables the metrics system. Since we need this to run before // any other code gets to create meters and timers, we'll actually do an ugly hack // and peek into the command line args for the metrics flag. func init() { - for _, arg := range os.Args { + var configFile string + + for i := 0; i < len(os.Args); i++ { + arg := os.Args[i] + flag := strings.TrimLeft(arg, "-") + // check for existence of `config` flag + if flag == configFlag && i < len(os.Args)-1 { + configFile = strings.TrimLeft(os.Args[i+1], "-") // find the value of flag + } + for _, enabler := range enablerFlags { if !Enabled && flag == enabler { - log.Info("Enabling metrics collection") Enabled = true } } + for _, enabler := range expensiveEnablerFlags { if !EnabledExpensive && flag == enabler { - log.Info("Enabling expensive metrics collection") EnabledExpensive = true } } } + + // Update the global metrics value, if they're provided in the config file + updateMetricsFromConfig(configFile) +} + +func updateMetricsFromConfig(path string) { + // Don't act upon any errors here. They're already taken into + // consideration when the toml config file will be parsed in the cli. + data, err := os.ReadFile(path) + tomlData := string(data) + + if err != nil { + return + } + + // Create a minimal config to decode + type TelemetryConfig struct { + Enabled bool `hcl:"metrics,optional" toml:"metrics,optional"` + Expensive bool `hcl:"expensive,optional" toml:"expensive,optional"` + } + + type CliConfig struct { + Telemetry *TelemetryConfig `hcl:"telemetry,block" toml:"telemetry,block"` + } + + conf := &CliConfig{} + + if _, err := toml.Decode(tomlData, &conf); err != nil || conf == nil { + return + } + + // We have the values now, update them + Enabled = conf.Telemetry.Enabled + EnabledExpensive = conf.Telemetry.Expensive } // CollectProcessMetrics periodically collects various metrics about the running From 238d5a4f2c39bcbae44d981403648acd63f7014a Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 04:41:49 +0530 Subject: [PATCH 24/36] chg : major fix --- eth/tracers/api.go | 123 +++++++++++++++++++++++++++++----------- eth/tracers/api_test.go | 6 +- 2 files changed, 94 insertions(+), 35 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index baf9417b82..135f1156cd 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -191,9 +191,11 @@ func (api *API) getAllBlockTransactions(ctx context.Context, block *types.Block) // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { *logger.Config - Tracer *string - Timeout *string - Reexec *uint64 + Tracer *string + Timeout *string + Reexec *uint64 + BorTraceEnabled *bool + BorTx *bool } // TraceCallConfig is the config for traceCall API. It holds one more @@ -209,8 +211,9 @@ type TraceCallConfig struct { // StdTraceConfig holds extra parameters to standard-json trace functions. type StdTraceConfig struct { logger.Config - Reexec *uint64 - TxHash common.Hash + Reexec *uint64 + TxHash common.Hash + BorTrace *bool } // txTraceResult is the result of a single transaction trace. @@ -264,6 +267,11 @@ func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, conf // executes all the transactions contained within. The return value will be one item // per transaction, dependent on the requested tracer. func (api *API) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { + if config == nil { + config = &TraceConfig{ + BorTraceEnabled: newBoolPtr(false), + } + } // Tracing a chain is a **long** operation, only do with subscriptions notifier, supported := rpc.NotifierFromContext(ctx) if !supported { @@ -312,9 +320,14 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config var err error if stateSyncPresent && i == len(txs)-1 { - res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config, true) + if *config.BorTraceEnabled { + config.BorTx = newBoolPtr(true) + res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config) + } else { + break + } } else { - res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config, false) + res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config) } if err != nil { @@ -466,6 +479,11 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config return sub, nil } +func newBoolPtr(bb bool) *bool { + b := bb + return &b +} + // TraceBlockByNumber returns the structured logs created during the execution of // EVM and returns them as a JSON object. func (api *API) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error) { @@ -546,6 +564,12 @@ func prepareCallMessage(msg core.Message) statefull.Callmsg { // IntermediateRoots executes a block (bad- or canon- or side-), and returns a list // of intermediate roots: the stateroot after each transaction. func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config *TraceConfig) ([]common.Hash, error) { + if config == nil { + config = &TraceConfig{ + BorTraceEnabled: newBoolPtr(false), + } + } + block, _ := api.blockByHash(ctx, hash) if block == nil { // Check in the bad blocks @@ -587,18 +611,23 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config statedb.Prepare(tx.Hash(), i) if stateSyncPresent && i == len(txs)-1 { - callmsg := prepareCallMessage(msg) + if *config.BorTraceEnabled { + callmsg := prepareCallMessage(msg) - if _, err := statefull.ApplyMessage(ctx, callmsg, statedb, block.Header(), api.backend.ChainConfig(), api.chainContext(ctx)); err != nil { - log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) - // We intentionally don't return the error here: if we do, then the RPC server will not - // return the roots. Most likely, the caller already knows that a certain transaction fails to - // be included, but still want the intermediate roots that led to that point. - // It may happen the tx_N causes an erroneous state, which in turn causes tx_N+M to not be - // executable. - // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. - return roots, nil + if _, err := statefull.ApplyMessage(ctx, callmsg, statedb, block.Header(), api.backend.ChainConfig(), api.chainContext(ctx)); err != nil { + log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) + // We intentionally don't return the error here: if we do, then the RPC server will not + // return the roots. Most likely, the caller already knows that a certain transaction fails to + // be included, but still want the intermediate roots that led to that point. + // It may happen the tx_N causes an erroneous state, which in turn causes tx_N+M to not be + // executable. + // N.B: This should never happen while tracing canon blocks, only when tracing bad blocks. + return roots, nil + } + } else { + break } + } else { if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) @@ -635,6 +664,13 @@ func (api *API) StandardTraceBadBlockToFile(ctx context.Context, hash common.Has // executes all the transactions contained within. The return value will be one item // per transaction, dependent on the requestd tracer. func (api *API) traceBlock(ctx context.Context, block *types.Block, config *TraceConfig) ([]*txTraceResult, error) { + + if config == nil { + config = &TraceConfig{ + BorTraceEnabled: newBoolPtr(false), + } + } + if block.NumberU64() == 0 { return nil, errors.New("genesis is not traceable") } @@ -682,9 +718,14 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac var err error if stateSyncPresent && task.index == len(txs)-1 { - res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config, true) + if *config.BorTraceEnabled { + config.BorTx = newBoolPtr(true) + res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config) + } else { + break + } } else { - res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config, false) + res, err = api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config) } if err != nil { results[task.index] = &txTraceResult{Error: err.Error()} @@ -708,9 +749,13 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{}) if stateSyncPresent && i == len(txs)-1 { - callmsg := prepareCallMessage(msg) - if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { - failed = err + if *config.BorTraceEnabled { + callmsg := prepareCallMessage(msg) + if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { + failed = err + break + } + } else { break } } else { @@ -738,6 +783,11 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac // and traces either a full block or an individual transaction. The return value will // be one filename per transaction traced. func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block, config *StdTraceConfig) ([]string, error) { + if config == nil { + config = &StdTraceConfig{ + BorTrace: newBoolPtr(false), + } + } // If we're tracing a single transaction, make sure it's present if config != nil && config.TxHash != (common.Hash{}) { if !api.containsTx(ctx, block, config.TxHash) { @@ -833,11 +883,15 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block statedb.Prepare(tx.Hash(), i) if stateSyncPresent && i == len(txs)-1 { - callmsg := prepareCallMessage(msg) - _, err = statefull.ApplyBorMessage(*vmenv, callmsg) + if *config.BorTrace { + callmsg := prepareCallMessage(msg) + _, err = statefull.ApplyBorMessage(*vmenv, callmsg) - if writer != nil { - writer.Flush() + if writer != nil { + writer.Flush() + } + } else { + break } } else { _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())) @@ -879,7 +933,12 @@ func (api *API) containsTx(ctx context.Context, block *types.Block, hash common. // TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object. -func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig, borTx bool) (interface{}, error) { +func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { + if config == nil { + config = &TraceConfig{ + BorTraceEnabled: newBoolPtr(false), + } + } tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) if tx == nil { // For BorTransaction, there will be no trace available @@ -916,14 +975,14 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config * TxHash: hash, } - return api.traceTx(ctx, msg, txctx, vmctx, statedb, config, borTx) + return api.traceTx(ctx, msg, txctx, vmctx, statedb, config) } // TraceCall lets you trace a given eth_call. It collects the structured logs // created during the execution of EVM if the given transaction was added on // top of the provided block and returns them as a JSON object. // You can provide -2 as a block number to trace on top of the pending block. -func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig, borTx bool) (interface{}, error) { +func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) { // Try to retrieve the specified block var ( err error @@ -971,13 +1030,13 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc } } - return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig, borTx) + return api.traceTx(ctx, msg, new(Context), vmctx, statedb, traceConfig) } // traceTx configures a new tracer according to the provided configuration, and // executes the given message in the provided environment. The return value will // be tracer dependent. -func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, borTx bool) (interface{}, error) { +func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { // Assemble the structured logger or the JavaScript tracer var ( tracer vm.EVMLogger @@ -1019,7 +1078,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex var result *core.ExecutionResult - if borTx { + if *config.BorTx { callmsg := prepareCallMessage(message) if result, err = statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { return nil, fmt.Errorf("tracing failed: %w", err) diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 68335239e8..6dd94e4870 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -290,7 +290,7 @@ func TestTraceCall(t *testing.T) { }, } for _, testspec := range testSuite { - result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config, false) + result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config) if testspec.expectErr != nil { if err == nil { t.Errorf("Expect error %v, get nothing", testspec.expectErr) @@ -330,7 +330,7 @@ func TestTraceTransaction(t *testing.T) { b.AddTx(tx) target = tx.Hash() })) - result, err := api.TraceTransaction(context.Background(), target, nil, false) + result, err := api.TraceTransaction(context.Background(), target, nil) if err != nil { t.Errorf("Failed to trace transaction %v", err) } @@ -513,7 +513,7 @@ func TestTracingWithOverrides(t *testing.T) { }, } for i, tc := range testSuite { - result, err := api.TraceCall(context.Background(), tc.call, rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, tc.config, false) + result, err := api.TraceCall(context.Background(), tc.call, rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, tc.config) if tc.expectErr != nil { if err == nil { t.Errorf("test %d: want error %v, have nothing", i, tc.expectErr) From 7554a16c4ffb3a2d2a9cb29ab67856b251d009ae Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 04:56:21 +0530 Subject: [PATCH 25/36] chg : minor fix --- eth/tracers/api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 135f1156cd..c5ba6b9779 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -270,6 +270,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config if config == nil { config = &TraceConfig{ BorTraceEnabled: newBoolPtr(false), + BorTx: newBoolPtr(false), } } // Tracing a chain is a **long** operation, only do with subscriptions @@ -567,6 +568,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config if config == nil { config = &TraceConfig{ BorTraceEnabled: newBoolPtr(false), + BorTx: newBoolPtr(false), } } @@ -668,6 +670,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac if config == nil { config = &TraceConfig{ BorTraceEnabled: newBoolPtr(false), + BorTx: newBoolPtr(false), } } @@ -937,6 +940,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config * if config == nil { config = &TraceConfig{ BorTraceEnabled: newBoolPtr(false), + BorTx: newBoolPtr(false), } } tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) @@ -1078,6 +1082,10 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex var result *core.ExecutionResult + if config.BorTx == nil { + config.BorTx = newBoolPtr(false) + } + if *config.BorTx { callmsg := prepareCallMessage(message) if result, err = statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { From 2f648fb91c7225727aa4801e3fcda3f5f7d22d84 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 05:38:45 +0530 Subject: [PATCH 26/36] chg : fix derference error on config without borTraceEnabled --- eth/tracers/api.go | 47 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index c5ba6b9779..4534f4675f 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -65,6 +65,8 @@ const ( defaultTracechainMemLimit = common.StorageSize(500 * 1024 * 1024) ) +var defaultBorTraceEnabled = newBoolPtr(false) + // Backend interface provides the common API services (that are provided by // both full and light clients) with access to necessary functions. type Backend interface { @@ -269,10 +271,13 @@ func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, conf func (api *API) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { if config == nil { config = &TraceConfig{ - BorTraceEnabled: newBoolPtr(false), + BorTraceEnabled: defaultBorTraceEnabled, BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } // Tracing a chain is a **long** operation, only do with subscriptions notifier, supported := rpc.NotifierFromContext(ctx) if !supported { @@ -308,6 +313,10 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), nil) // Trace all the transactions contained within txs, stateSyncPresent := api.getAllBlockTransactions(ctx, task.block) + if !*config.BorTraceEnabled && stateSyncPresent { + txs = txs[:len(txs)-1] + stateSyncPresent = false + } for i, tx := range txs { msg, _ := tx.AsMessage(signer, task.block.BaseFee()) txctx := &Context{ @@ -324,8 +333,6 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config if *config.BorTraceEnabled { config.BorTx = newBoolPtr(true) res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config) - } else { - break } } else { res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config) @@ -567,10 +574,13 @@ func prepareCallMessage(msg core.Message) statefull.Callmsg { func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config *TraceConfig) ([]common.Hash, error) { if config == nil { config = &TraceConfig{ - BorTraceEnabled: newBoolPtr(false), + BorTraceEnabled: defaultBorTraceEnabled, BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } block, _ := api.blockByHash(ctx, hash) if block == nil { @@ -669,10 +679,13 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac if config == nil { config = &TraceConfig{ - BorTraceEnabled: newBoolPtr(false), + BorTraceEnabled: defaultBorTraceEnabled, BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } if block.NumberU64() == 0 { return nil, errors.New("genesis is not traceable") @@ -779,7 +792,12 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac if failed != nil { return nil, failed } - return results, nil + + if !*config.BorTraceEnabled && stateSyncPresent { + return results[:len(results)-1], nil + } else { + return results, nil + } } // standardTraceBlockToFile configures a new tracer which uses standard JSON output, @@ -939,10 +957,14 @@ func (api *API) containsTx(ctx context.Context, block *types.Block, hash common. func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { if config == nil { config = &TraceConfig{ - BorTraceEnabled: newBoolPtr(false), + BorTraceEnabled: defaultBorTraceEnabled, BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } + tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) if tx == nil { // For BorTransaction, there will be no trace available @@ -1041,6 +1063,17 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc // executes the given message in the provided environment. The return value will // be tracer dependent. func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { + + if config == nil { + config = &TraceConfig{ + BorTraceEnabled: defaultBorTraceEnabled, + BorTx: newBoolPtr(false), + } + } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } + // Assemble the structured logger or the JavaScript tracer var ( tracer vm.EVMLogger From 654f56fbcba8895190ec21781b9ea958d23e1d5a Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 06:26:43 +0530 Subject: [PATCH 27/36] chg : standardTraceBlockToFile fix --- eth/tracers/api.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 4534f4675f..ad52373038 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -213,9 +213,9 @@ type TraceCallConfig struct { // StdTraceConfig holds extra parameters to standard-json trace functions. type StdTraceConfig struct { logger.Config - Reexec *uint64 - TxHash common.Hash - BorTrace *bool + Reexec *uint64 + TxHash common.Hash + BorTraceEnabled *bool } // txTraceResult is the result of a single transaction trace. @@ -806,9 +806,12 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block, config *StdTraceConfig) ([]string, error) { if config == nil { config = &StdTraceConfig{ - BorTrace: newBoolPtr(false), + BorTraceEnabled: defaultBorTraceEnabled, } } + if config.BorTraceEnabled == nil { + config.BorTraceEnabled = defaultBorTraceEnabled + } // If we're tracing a single transaction, make sure it's present if config != nil && config.TxHash != (common.Hash{}) { if !api.containsTx(ctx, block, config.TxHash) { @@ -868,6 +871,11 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block } txs, stateSyncPresent := api.getAllBlockTransactions(ctx, block) + if !*config.BorTraceEnabled && stateSyncPresent { + txs = txs[:len(txs)-1] + stateSyncPresent = false + } + for i, tx := range txs { // Prepare the trasaction for un-traced execution var ( @@ -904,15 +912,13 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block statedb.Prepare(tx.Hash(), i) if stateSyncPresent && i == len(txs)-1 { - if *config.BorTrace { + if *config.BorTraceEnabled { callmsg := prepareCallMessage(msg) _, err = statefull.ApplyBorMessage(*vmenv, callmsg) if writer != nil { writer.Flush() } - } else { - break } } else { _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())) From 2542403048dd9d45e598bbd25a599f7153413e31 Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 06:49:01 +0530 Subject: [PATCH 28/36] add : lint --- eth/tracers/api.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index ad52373038..3fce91ac9c 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -275,6 +275,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } @@ -317,6 +318,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config txs = txs[:len(txs)-1] stateSyncPresent = false } + for i, tx := range txs { msg, _ := tx.AsMessage(signer, task.block.BaseFee()) txctx := &Context{ @@ -578,6 +580,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } @@ -621,7 +624,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config vmenv = vm.NewEVM(vmctx, txContext, statedb, chainConfig, vm.Config{}) ) statedb.Prepare(tx.Hash(), i) - + //nolint: nestif if stateSyncPresent && i == len(txs)-1 { if *config.BorTraceEnabled { callmsg := prepareCallMessage(msg) @@ -639,7 +642,6 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config } else { break } - } else { if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) @@ -683,6 +685,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } @@ -733,6 +736,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac var res interface{} var err error + if stateSyncPresent && task.index == len(txs)-1 { if *config.BorTraceEnabled { config.BorTx = newBoolPtr(true) @@ -763,7 +767,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac statedb.Prepare(tx.Hash(), i) vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{}) - + //nolint: nestif if stateSyncPresent && i == len(txs)-1 { if *config.BorTraceEnabled { callmsg := prepareCallMessage(msg) @@ -809,6 +813,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block BorTraceEnabled: defaultBorTraceEnabled, } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } @@ -910,7 +915,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block // Execute the transaction and flush any traces to disk vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf) statedb.Prepare(tx.Hash(), i) - + //nolint: nestif if stateSyncPresent && i == len(txs)-1 { if *config.BorTraceEnabled { callmsg := prepareCallMessage(msg) @@ -967,6 +972,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config * BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } @@ -1076,6 +1082,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex BorTx: newBoolPtr(false), } } + if config.BorTraceEnabled == nil { config.BorTraceEnabled = defaultBorTraceEnabled } From e17ee36ebe276c2c15adf52cec68b3e143eb6bd8 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Fri, 21 Oct 2022 08:54:38 +0530 Subject: [PATCH 29/36] Changed default value of maxpeers from 200 to 50, update docs (#555) * changed default of maxpeers from 200 to 50 * docs: update additional notes for new-cli * docs: update additional notes for new-cli * small bug fix in the script to fix shopt issue Co-authored-by: Manav Darji --- cmd/geth/config.go | 4 ++-- docs/README.md | 18 ++++++++---------- docs/config.md | 2 +- internal/cli/server/config.go | 2 +- scripts/getconfig.sh | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index e6cb36b121..80bf95b1ac 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -327,7 +327,7 @@ func setDefaultMumbaiGethConfig(ctx *cli.Context, config *gethConfig) { config.Eth.TxPool.AccountQueue = 64 config.Eth.TxPool.GlobalQueue = 131072 config.Eth.TxPool.Lifetime = 90 * time.Minute - config.Node.P2P.MaxPeers = 200 + config.Node.P2P.MaxPeers = 50 config.Metrics.Enabled = true // --pprof is enabled in 'internal/debug/flags.go' } @@ -350,7 +350,7 @@ func setDefaultBorMainnetGethConfig(ctx *cli.Context, config *gethConfig) { config.Eth.TxPool.AccountQueue = 64 config.Eth.TxPool.GlobalQueue = 131072 config.Eth.TxPool.Lifetime = 90 * time.Minute - config.Node.P2P.MaxPeers = 200 + config.Node.P2P.MaxPeers = 50 config.Metrics.Enabled = true // --pprof is enabled in 'internal/debug/flags.go' } diff --git a/docs/README.md b/docs/README.md index 95ba38b0da..5ebdbd7e26 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,18 +5,16 @@ - [Configuration file](./config.md) -## Deprecation notes +## Additional notes - The new entrypoint to run the Bor client is ```server```. -``` -$ bor server -``` + ``` + $ bor server + ``` -- Toml files to configure nodes are being deprecated. Currently, we only allow for static and trusted nodes to be configured using toml files. +- Toml files used earlier just to configure static/trusted nodes are being deprecated. Instead, a toml file now can be used instead of flags and can contain all configuration for the node to run. The link to a sample config file is given above. To simply run bor with a configuration file, the following command can be used. -``` -$ bor server --config ./legacy.toml -``` - -- ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks. + ``` + $ bor server --config + ``` diff --git a/docs/config.md b/docs/config.md index aebd9e12b9..57f4c25fef 100644 --- a/docs/config.md +++ b/docs/config.md @@ -22,7 +22,7 @@ ethstats = "" ["eth.requiredblocks"] [p2p] -maxpeers = 30 +maxpeers = 50 maxpendpeers = 50 bind = "0.0.0.0" port = 30303 diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index e5e3a8b03e..bf99f33c96 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -399,7 +399,7 @@ func DefaultConfig() *Config { LogLevel: "INFO", DataDir: DefaultDataDir(), P2P: &P2PConfig{ - MaxPeers: 30, + MaxPeers: 50, MaxPendPeers: 50, Bind: "0.0.0.0", Port: 30303, diff --git a/scripts/getconfig.sh b/scripts/getconfig.sh index 943d540a88..a2971c4f12 100755 --- a/scripts/getconfig.sh +++ b/scripts/getconfig.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/bash set -e # Instructions: From 723ff9a958180f08d7a3a44849b2e57d644a524d Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 21 Oct 2022 15:11:28 +0530 Subject: [PATCH 30/36] chg : minor change --- core/blockchain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index e1fc269759..8103e4a05e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -232,7 +232,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par } if cacheConfig.TriesInMemory <= 0 { - cacheConfig.TriesInMemory = 128 + cacheConfig.TriesInMemory = DefaultCacheConfig.TriesInMemory } bodyCache, _ := lru.New(bodyCacheLimit) bodyRLPCache, _ := lru.New(bodyCacheLimit) From 1ab225c0e47dd44278648bd620c0952d135a5e30 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Fri, 4 Nov 2022 01:24:57 +0530 Subject: [PATCH 31/36] Removed vhosts for ws and replaced cors with origins (#574) * removed vhosts for ws and added replaced cors with origins * updated script --- builder/files/config.toml | 3 +-- docs/cli/server.md | 6 +++--- internal/cli/server/config.go | 8 +++++--- internal/cli/server/flags.go | 15 ++++----------- scripts/getconfig.go | 10 ++++------ 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/builder/files/config.toml b/builder/files/config.toml index 13bf82bf93..870c164a8d 100644 --- a/builder/files/config.toml +++ b/builder/files/config.toml @@ -78,8 +78,7 @@ syncmode = "full" # prefix = "" # host = "localhost" # api = ["web3", "net"] - # vhosts = ["*"] - # corsdomain = ["*"] + # origins = ["*"] # [jsonrpc.graphql] # enabled = false # port = 0 diff --git a/docs/cli/server.md b/docs/cli/server.md index 5fe440b5fd..d52b135fa3 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -80,6 +80,8 @@ The ```bor server``` command runs the Bor client. - ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys +- ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default = 128) + - ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain) ### JsonRPC Options @@ -96,9 +98,7 @@ The ```bor server``` command runs the Bor client. - ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. -- ```ws.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) - -- ```ws.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. +- ```ws.origins```: Origins from which to accept websockets requests - ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index e71b45218d..b8310aea6f 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -266,6 +266,9 @@ type APIConfig struct { // Cors is the list of Cors endpoints Cors []string `hcl:"corsdomain,optional" toml:"corsdomain,optional"` + + // Origins is the list of endpoints to accept requests from (only consumed for websockets) + Origins []string `hcl:"origins,optional" toml:"origins,optional"` } type GpoConfig struct { @@ -473,8 +476,7 @@ func DefaultConfig() *Config { Prefix: "", Host: "localhost", API: []string{"net", "web3"}, - Cors: []string{"localhost"}, - VHost: []string{"localhost"}, + Origins: []string{"localhost"}, }, Graphql: &APIConfig{ Enabled: false, @@ -930,7 +932,7 @@ func (c *Config) buildNode() (*node.Config, error) { HTTPVirtualHosts: c.JsonRPC.Http.VHost, HTTPPathPrefix: c.JsonRPC.Http.Prefix, WSModules: c.JsonRPC.Ws.API, - WSOrigins: c.JsonRPC.Ws.Cors, + WSOrigins: c.JsonRPC.Ws.Origins, WSPathPrefix: c.JsonRPC.Ws.Prefix, GraphQLCors: c.JsonRPC.Graphql.Cors, GraphQLVirtualHosts: c.JsonRPC.Graphql.VHost, diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 025ce8c80c..ba9be13376 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -363,17 +363,10 @@ func (c *Command) Flags() *flagset.Flagset { Group: "JsonRPC", }) f.SliceStringFlag(&flagset.SliceStringFlag{ - Name: "ws.corsdomain", - Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", - Value: &c.cliConfig.JsonRPC.Ws.Cors, - Default: c.cliConfig.JsonRPC.Ws.Cors, - Group: "JsonRPC", - }) - f.SliceStringFlag(&flagset.SliceStringFlag{ - Name: "ws.vhosts", - Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", - Value: &c.cliConfig.JsonRPC.Ws.VHost, - Default: c.cliConfig.JsonRPC.Ws.VHost, + Name: "ws.origins", + Usage: "Origins from which to accept websockets requests", + Value: &c.cliConfig.JsonRPC.Ws.Origins, + Default: c.cliConfig.JsonRPC.Ws.Origins, Group: "JsonRPC", }) f.SliceStringFlag(&flagset.SliceStringFlag{ diff --git a/scripts/getconfig.go b/scripts/getconfig.go index 136b69ecab..caf3f45a8e 100644 --- a/scripts/getconfig.go +++ b/scripts/getconfig.go @@ -95,7 +95,7 @@ var flagMap = map[string][]string{ "override.arrowglacier": {"notABoolFlag", "No"}, "override.terminaltotaldifficulty": {"notABoolFlag", "No"}, "verbosity": {"notABoolFlag", "YesFV"}, - "ws.origins": {"notABoolFlag", "YesF"}, + "ws.origins": {"notABoolFlag", "No"}, } // map from cli flags to corresponding toml tags @@ -150,8 +150,7 @@ var nameTagMap = map[string]string{ "ipcpath": "ipcpath", "1-corsdomain": "http.corsdomain", "1-vhosts": "http.vhosts", - "2-corsdomain": "ws.corsdomain", - "2-vhosts": "ws.vhosts", + "origins": "ws.origins", "3-corsdomain": "graphql.corsdomain", "3-vhosts": "graphql.vhosts", "1-enabled": "http", @@ -226,9 +225,8 @@ var replacedFlagsMapFlagAndValue = map[string]map[string]map[string]string{ }, } -var replacedFlagsMapFlag = map[string]string{ - "ws.origins": "ws.corsdomain", -} +// Do not remove +var replacedFlagsMapFlag = map[string]string{} var currentBoolFlags = []string{ "snapshot", From c5569e4da9ebe0ce4e63aec571966c71234f7cfc Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Fri, 4 Nov 2022 17:09:46 +0530 Subject: [PATCH 32/36] fix : TestRemoteMultiNotifyFull --- consensus/ethash/sealer_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/sealer_test.go b/consensus/ethash/sealer_test.go index ad03fdff75..06ceae1b82 100644 --- a/consensus/ethash/sealer_test.go +++ b/consensus/ethash/sealer_test.go @@ -180,9 +180,6 @@ func TestRemoteMultiNotify(t *testing.T) { // Tests that pushing work packages fast to the miner doesn't cause any data race // issues in the notifications. Full pending block body / --miner.notify.full) func TestRemoteMultiNotifyFull(t *testing.T) { - // TODO: Understand the test case and Identify the reason for failing tests. - // Also, make it more deterministic. - t.Skip("skipping - non-deterministic test, no dependency on this test for now and not directly relevant to bor") // Start a simple web server to capture notifications. sink := make(chan map[string]interface{}, 64) @@ -197,6 +194,9 @@ func TestRemoteMultiNotifyFull(t *testing.T) { } sink <- work })) + + // Allowing the server to start listening. + time.Sleep(2 * time.Second) defer server.Close() // Create the custom ethash engine. From 3e4b872e16081c057518617d9ee803c372ec33a2 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 9 Nov 2022 16:21:05 +0530 Subject: [PATCH 33/36] pos-845: subtests --- tests/bor/bor_reorg_test.go | 154 +++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 74 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 0725881180..3978b6d046 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -148,6 +148,7 @@ func TestValidatorWentOffline(t *testing.T) { func TestForkWithBlockTime(t *testing.T) { cases := []struct { + name string sprint uint64 blockTime map[string]uint64 change uint64 @@ -155,6 +156,7 @@ func TestForkWithBlockTime(t *testing.T) { forkExpected bool }{ { + name: "No fork after 2 sprints with producer delay = max block time", sprint: 128, blockTime: map[string]uint64{ "0": 5, @@ -166,6 +168,7 @@ func TestForkWithBlockTime(t *testing.T) { forkExpected: false, }, { + name: "No Fork after 1 sprint producer delay = max block time", sprint: 64, blockTime: map[string]uint64{ "0": 5, @@ -176,6 +179,7 @@ func TestForkWithBlockTime(t *testing.T) { forkExpected: false, }, { + name: "Fork after 4 sprints with producer delay < max block time", sprint: 16, blockTime: map[string]uint64{ "0": 2, @@ -191,89 +195,91 @@ func TestForkWithBlockTime(t *testing.T) { genesis := initGenesis(t) for _, test := range cases { - genesis.Config.Bor.Sprint = test.sprint - genesis.Config.Bor.Period = test.blockTime - genesis.Config.Bor.BackupMultiplier = test.blockTime - genesis.Config.Bor.ProducerDelay = test.producerDelay + t.Run(test.name, func(t *testing.T) { + genesis.Config.Bor.Sprint = test.sprint + genesis.Config.Bor.Period = test.blockTime + genesis.Config.Bor.BackupMultiplier = test.blockTime + genesis.Config.Bor.ProducerDelay = test.producerDelay - stacks, nodes, _ := setupMiner(t, 2, genesis) + stacks, nodes, _ := setupMiner(t, 2, genesis) - defer func() { - for _, stack := range stacks { - stack.Close() - } - }() - - // Iterate over all the nodes and start mining - for _, node := range nodes { - if err := node.StartMining(1); err != nil { - t.Fatal("Error occured while starting miner", "node", node, "error", err) - } - } - - var wg sync.WaitGroup - blockHeaders := make([]*types.Header, 2) - ticker := time.NewTicker(time.Duration(test.blockTime["0"]) * time.Second) - - for i := 0; i < 2; i++ { - wg.Add(1) - - go func(i int) { - defer wg.Done() - - for { - select { - case <-ticker.C: - blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) - if blockHeaders[i] != nil { - return - } - default: - - } + defer func() { + for _, stack := range stacks { + stack.Close() } + }() - }(i) - } + // Iterate over all the nodes and start mining + for _, node := range nodes { + if err := node.StartMining(1); err != nil { + t.Fatal("Error occured while starting miner", "node", node, "error", err) + } + } + var wg sync.WaitGroup + blockHeaders := make([]*types.Header, 2) + ticker := time.NewTicker(time.Duration(test.blockTime["0"]) * time.Second) - wg.Wait() - ticker.Stop() + for i := 0; i < 2; i++ { + wg.Add(1) - // Before the end of sprint - blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(test.sprint - 1) - blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(test.sprint - 1) - assert.Equal(t, blockHeaderVal0.Hash(), blockHeaderVal1.Hash()) - assert.Equal(t, blockHeaderVal0.Time, blockHeaderVal1.Time) + go func(i int) { + defer wg.Done() - author0, err := nodes[0].Engine().Author(blockHeaderVal0) - if err != nil { - t.Error("Error occured while fetching author", "err", err) - } - author1, err := nodes[1].Engine().Author(blockHeaderVal1) - if err != nil { - t.Error("Error occured while fetching author", "err", err) - } - assert.Equal(t, author0, author1) + for { + select { + case <-ticker.C: + blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) + if blockHeaders[i] != nil { + return + } + default: - // After the end of sprint - author2, err := nodes[0].Engine().Author(blockHeaders[0]) - if err != nil { - t.Error("Error occured while fetching author", "err", err) - } - author3, err := nodes[1].Engine().Author(blockHeaders[1]) - if err != nil { - t.Error("Error occured while fetching author", "err", err) - } + } + } + + }(i) + } + + wg.Wait() + ticker.Stop() + + // Before the end of sprint + blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(test.sprint - 1) + blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(test.sprint - 1) + assert.Equal(t, blockHeaderVal0.Hash(), blockHeaderVal1.Hash()) + assert.Equal(t, blockHeaderVal0.Time, blockHeaderVal1.Time) + + author0, err := nodes[0].Engine().Author(blockHeaderVal0) + if err != nil { + t.Error("Error occured while fetching author", "err", err) + } + author1, err := nodes[1].Engine().Author(blockHeaderVal1) + if err != nil { + t.Error("Error occured while fetching author", "err", err) + } + assert.Equal(t, author0, author1) + + // After the end of sprint + author2, err := nodes[0].Engine().Author(blockHeaders[0]) + if err != nil { + t.Error("Error occured while fetching author", "err", err) + } + author3, err := nodes[1].Engine().Author(blockHeaders[1]) + if err != nil { + t.Error("Error occured while fetching author", "err", err) + } + + if test.forkExpected { + assert.NotEqual(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) + assert.NotEqual(t, blockHeaders[0].Time, blockHeaders[1].Time) + assert.NotEqual(t, author2, author3) + } else { + assert.Equal(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) + assert.Equal(t, blockHeaders[0].Time, blockHeaders[1].Time) + assert.Equal(t, author2, author3) + } + }) - if test.forkExpected { - assert.NotEqual(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) - assert.NotEqual(t, blockHeaders[0].Time, blockHeaders[1].Time) - assert.NotEqual(t, author2, author3) - } else { - assert.Equal(t, blockHeaders[0].Hash(), blockHeaders[1].Hash()) - assert.Equal(t, blockHeaders[0].Time, blockHeaders[1].Time) - assert.Equal(t, author2, author3) - } } } From 27cd2ae11ac31f052efdf4196a1eb469f7f6ac0a Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 9 Nov 2022 18:19:28 +0530 Subject: [PATCH 34/36] pos-845: parallelise subtests --- tests/bor/bor_reorg_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 3978b6d046..1460d75499 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -195,7 +195,10 @@ func TestForkWithBlockTime(t *testing.T) { genesis := initGenesis(t) for _, test := range cases { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() + genesis.Config.Bor.Sprint = test.sprint genesis.Config.Bor.Period = test.blockTime genesis.Config.Bor.BackupMultiplier = test.blockTime From 82bf6d0c37a35bc445f8dd8b8d74f8abca28ab0b Mon Sep 17 00:00:00 2001 From: Raneet Debnath <35629432+Raneet10@users.noreply.github.com> Date: Wed, 9 Nov 2022 19:32:43 +0530 Subject: [PATCH 35/36] defer ticker.Stop Co-authored-by: Evgeny Danilenko <6655321@bk.ru> --- tests/bor/bor_reorg_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 1460d75499..9615d71c1e 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -221,6 +221,7 @@ func TestForkWithBlockTime(t *testing.T) { var wg sync.WaitGroup blockHeaders := make([]*types.Header, 2) ticker := time.NewTicker(time.Duration(test.blockTime["0"]) * time.Second) + defer ticker.Stop() for i := 0; i < 2; i++ { wg.Add(1) From 41fddd6a5edef0d2ae1c124973cac8e59f9cb6d1 Mon Sep 17 00:00:00 2001 From: Raneet Debnath Date: Wed, 9 Nov 2022 21:25:30 +0530 Subject: [PATCH 36/36] pos-845: efficient ticker --- tests/bor/bor_reorg_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/bor/bor_reorg_test.go b/tests/bor/bor_reorg_test.go index 9615d71c1e..c759599c37 100644 --- a/tests/bor/bor_reorg_test.go +++ b/tests/bor/bor_reorg_test.go @@ -195,9 +195,7 @@ func TestForkWithBlockTime(t *testing.T) { genesis := initGenesis(t) for _, test := range cases { - test := test t.Run(test.name, func(t *testing.T) { - t.Parallel() genesis.Config.Bor.Sprint = test.sprint genesis.Config.Bor.Period = test.blockTime @@ -229,15 +227,10 @@ func TestForkWithBlockTime(t *testing.T) { go func(i int) { defer wg.Done() - for { - select { - case <-ticker.C: - blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) - if blockHeaders[i] != nil { - return - } - default: - + for range ticker.C { + blockHeaders[i] = nodes[i].BlockChain().GetHeaderByNumber(test.sprint*test.change + 10) + if blockHeaders[i] != nil { + break } } @@ -245,7 +238,6 @@ func TestForkWithBlockTime(t *testing.T) { } wg.Wait() - ticker.Stop() // Before the end of sprint blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(test.sprint - 1)