From 5fc30aeaac2b143eb4163b12547c6bbb007c381a Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Fri, 19 Jan 2024 17:19:12 +0530 Subject: [PATCH] Revert "Consistent" --- consensus/bor/bor.go | 4 - consensus/bor/bor_test.go | 35 +-- core/txpool/legacypool/legacypool.go | 16 +- core/txpool/validation.go | 4 +- core/types/transaction_signing.go | 35 --- core/vm/contracts.go | 56 +---- core/vm/contracts_test.go | 17 -- core/vm/testdata/precompiles/p256Verify.json | 37 --- crypto/secp256r1/publickey.go | 26 -- crypto/secp256r1/verifier.go | 21 -- eth/backend.go | 3 +- eth/bor_api_backend.go | 15 ++ internal/cli/server/config_legacy_test.go | 19 -- internal/cli/server/testdata/default.toml | 193 --------------- internal/ethapi/api.go | 15 +- internal/ethapi/api_test.go | 248 ------------------- params/config.go | 12 +- params/protocol_params.go | 2 - 18 files changed, 52 insertions(+), 706 deletions(-) delete mode 100644 core/vm/testdata/precompiles/p256Verify.json delete mode 100644 crypto/secp256r1/publickey.go delete mode 100644 crypto/secp256r1/verifier.go delete mode 100644 internal/cli/server/testdata/default.toml diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index c54eef564b..24590ea516 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -883,10 +883,6 @@ func (c *Bor) changeContractCodeIfNeeded(headerNumber uint64, state *state.State for addr, account := range allocs { log.Info("change contract code", "address", addr) state.SetCode(addr, account.Code) - - if state.GetBalance(addr).Cmp(big.NewInt(0)) == 0 { - state.SetBalance(addr, account.Balance) - } } } } diff --git a/consensus/bor/bor_test.go b/consensus/bor/bor_test.go index ca60d5f66f..52c93c77ad 100644 --- a/consensus/bor/bor_test.go +++ b/consensus/bor/bor_test.go @@ -40,12 +40,6 @@ func TestGenesisContractChange(t *testing.T) { "balance": "0x1000", }, }, - "6": map[string]interface{}{ - addr0.Hex(): map[string]interface{}{ - "code": hexutil.Bytes{0x1, 0x4}, - "balance": "0x2000", - }, - }, }, }, } @@ -91,35 +85,24 @@ func TestGenesisContractChange(t *testing.T) { root := genesis.Root() - // code does not change, balance remains 0 + // code does not change root, statedb = addBlock(root, 1) require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x1}) - require.Equal(t, statedb.GetBalance(addr0), big.NewInt(0)) - // code changes 1st time, balance remains 0 + // code changes 1st time root, statedb = addBlock(root, 2) require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2}) - require.Equal(t, statedb.GetBalance(addr0), big.NewInt(0)) - // code same as 1st change, balance remains 0 + // code same as 1st change root, statedb = addBlock(root, 3) require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2}) + + // code changes 2nd time + _, statedb = addBlock(root, 4) + require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x3}) + + // make sure balance change DOES NOT take effect require.Equal(t, statedb.GetBalance(addr0), big.NewInt(0)) - - // code changes 2nd time, balance updates to 4096 - root, statedb = addBlock(root, 4) - require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x3}) - require.Equal(t, statedb.GetBalance(addr0), big.NewInt(4096)) - - // code same as 2nd change, balance remains 4096 - root, statedb = addBlock(root, 5) - require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x3}) - require.Equal(t, statedb.GetBalance(addr0), big.NewInt(4096)) - - // code changes 3rd time, balance remains 4096 - _, statedb = addBlock(root, 6) - require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x4}) - require.Equal(t, statedb.GetBalance(addr0), big.NewInt(4096)) } func TestEncodeSigHeaderJaipur(t *testing.T) { diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index d37f5ef4bc..db4af0ee8d 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -159,8 +159,7 @@ var DefaultConfig = Config{ AccountQueue: 64, GlobalQueue: 1024, - Lifetime: 3 * time.Hour, - AllowUnprotectedTxs: false, + Lifetime: 3 * time.Hour, } // sanitize checks the provided user configurations and changes anything that's @@ -591,8 +590,7 @@ func (pool *LegacyPool) local() map[common.Address]types.Transactions { // and does not require the pool mutex to be held. func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) error { opts := &txpool.ValidationOptions{ - Config: pool.chainconfig, - AllowUnprotectedTxs: pool.config.AllowUnprotectedTxs, + Config: pool.chainconfig, Accept: 0 | 1<= 0 } -// IsShanghai returns whether num is either equal to the Shanghai fork block or greater. +// IsShanghai returns whether time is either equal to the Shanghai fork time or greater. func (c *ChainConfig) IsShanghai(num *big.Int) bool { return isBlockForked(c.ShanghaiBlock, num) } -// IsCancun returns whether num is either equal to the Cancun fork block or greater. +// IsCancun returns whether num is either equal to the Cancun fork time or greater. func (c *ChainConfig) IsCancun(num *big.Int) bool { return isBlockForked(c.CancunBlock, num) } -// IsPrague returns whether num is either equal to the Prague fork block or greater. +// IsPrague returns whether num is either equal to the Prague fork time or greater. func (c *ChainConfig) IsPrague(num *big.Int) bool { return isBlockForked(c.PragueBlock, num) } @@ -912,9 +912,9 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true}, {name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true}, {name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true}, - {name: "shanghaiBlock", block: c.ShanghaiBlock}, - {name: "cancunBlock", block: c.CancunBlock, optional: true}, - {name: "pragueBlock", block: c.PragueBlock, optional: true}, + {name: "ShanghaiBlock", block: c.ShanghaiBlock}, + {name: "CancunBlock", block: c.CancunBlock, optional: true}, + {name: "pragueTime", block: c.PragueBlock, optional: true}, } { if lastFork.name != "" { switch { diff --git a/params/protocol_params.go b/params/protocol_params.go index ef5f267172..8eb5e247a9 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -160,8 +160,6 @@ const ( Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation Bls12381MapG2Gas uint64 = 110000 // Gas price for BLS12-381 mapping field element to G2 operation - P256VerifyGas uint64 = 3450 // secp256r1 elliptic curve signature verifier gas price - // The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529, // up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529 RefundQuotient uint64 = 2