mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
Revert "Consistent"
This commit is contained in:
parent
16a8d85f2e
commit
5fc30aeaac
18 changed files with 52 additions and 706 deletions
|
|
@ -883,10 +883,6 @@ func (c *Bor) changeContractCodeIfNeeded(headerNumber uint64, state *state.State
|
||||||
for addr, account := range allocs {
|
for addr, account := range allocs {
|
||||||
log.Info("change contract code", "address", addr)
|
log.Info("change contract code", "address", addr)
|
||||||
state.SetCode(addr, account.Code)
|
state.SetCode(addr, account.Code)
|
||||||
|
|
||||||
if state.GetBalance(addr).Cmp(big.NewInt(0)) == 0 {
|
|
||||||
state.SetBalance(addr, account.Balance)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,6 @@ func TestGenesisContractChange(t *testing.T) {
|
||||||
"balance": "0x1000",
|
"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()
|
root := genesis.Root()
|
||||||
|
|
||||||
// code does not change, balance remains 0
|
// code does not change
|
||||||
root, statedb = addBlock(root, 1)
|
root, statedb = addBlock(root, 1)
|
||||||
require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x1})
|
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)
|
root, statedb = addBlock(root, 2)
|
||||||
require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2})
|
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)
|
root, statedb = addBlock(root, 3)
|
||||||
require.Equal(t, statedb.GetCode(addr0), []byte{0x1, 0x2})
|
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))
|
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) {
|
func TestEncodeSigHeaderJaipur(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ var DefaultConfig = Config{
|
||||||
GlobalQueue: 1024,
|
GlobalQueue: 1024,
|
||||||
|
|
||||||
Lifetime: 3 * time.Hour,
|
Lifetime: 3 * time.Hour,
|
||||||
AllowUnprotectedTxs: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitize checks the provided user configurations and changes anything that's
|
// sanitize checks the provided user configurations and changes anything that's
|
||||||
|
|
@ -592,7 +591,6 @@ func (pool *LegacyPool) local() map[common.Address]types.Transactions {
|
||||||
func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) error {
|
func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) error {
|
||||||
opts := &txpool.ValidationOptions{
|
opts := &txpool.ValidationOptions{
|
||||||
Config: pool.chainconfig,
|
Config: pool.chainconfig,
|
||||||
AllowUnprotectedTxs: pool.config.AllowUnprotectedTxs,
|
|
||||||
Accept: 0 |
|
Accept: 0 |
|
||||||
1<<types.LegacyTxType |
|
1<<types.LegacyTxType |
|
||||||
1<<types.AccessListTxType |
|
1<<types.AccessListTxType |
|
||||||
|
|
@ -662,11 +660,6 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e
|
||||||
knownTxMeter.Mark(1)
|
knownTxMeter.Mark(1)
|
||||||
return false, ErrAlreadyKnown
|
return false, ErrAlreadyKnown
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool.config.AllowUnprotectedTxs {
|
|
||||||
pool.signer = types.NewFakeSigner(tx.ChainId())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the local flag. If it's from local source or it's from the network but
|
// Make the local flag. If it's from local source or it's from the network but
|
||||||
// the sender is marked as local previously, treat it as the local transaction.
|
// the sender is marked as local previously, treat it as the local transaction.
|
||||||
isLocal := local || pool.locals.containsTx(tx)
|
isLocal := local || pool.locals.containsTx(tx)
|
||||||
|
|
@ -989,11 +982,6 @@ func (pool *LegacyPool) addTxs(txs []*types.Transaction, local, sync bool) []err
|
||||||
knownTxMeter.Mark(1)
|
knownTxMeter.Mark(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool.config.AllowUnprotectedTxs {
|
|
||||||
pool.signer = types.NewFakeSigner(tx.ChainId())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exclude transactions with basic errors, e.g invalid signatures and
|
// Exclude transactions with basic errors, e.g invalid signatures and
|
||||||
// insufficient intrinsic gas as soon as possible and cache senders
|
// insufficient intrinsic gas as soon as possible and cache senders
|
||||||
// in transactions before obtaining lock
|
// in transactions before obtaining lock
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,6 @@ import (
|
||||||
type ValidationOptions struct {
|
type ValidationOptions struct {
|
||||||
Config *params.ChainConfig // Chain configuration to selectively validate based on current fork rules
|
Config *params.ChainConfig // Chain configuration to selectively validate based on current fork rules
|
||||||
|
|
||||||
AllowUnprotectedTxs bool // Whether to allow unprotected transactions in the pool
|
|
||||||
|
|
||||||
Accept uint8 // Bitmap of transaction types that should be accepted for the calling pool
|
Accept uint8 // Bitmap of transaction types that should be accepted for the calling pool
|
||||||
MaxSize uint64 // Maximum size of a transaction that the caller can meaningfully handle
|
MaxSize uint64 // Maximum size of a transaction that the caller can meaningfully handle
|
||||||
MinTip *big.Int // Minimum gas tip needed to allow a transaction into the caller pool
|
MinTip *big.Int // Minimum gas tip needed to allow a transaction into the caller pool
|
||||||
|
|
@ -93,7 +91,7 @@ func ValidateTransaction(tx *types.Transaction, blobs []kzg4844.Blob, commits []
|
||||||
return core.ErrTipAboveFeeCap
|
return core.ErrTipAboveFeeCap
|
||||||
}
|
}
|
||||||
// Make sure the transaction is signed properly
|
// Make sure the transaction is signed properly
|
||||||
if _, err := types.Sender(signer, tx); err != nil && !opts.AllowUnprotectedTxs {
|
if _, err := types.Sender(signer, tx); err != nil {
|
||||||
return ErrInvalidSender
|
return ErrInvalidSender
|
||||||
}
|
}
|
||||||
// Ensure the transaction has more gas than the bare minimum needed to cover
|
// Ensure the transaction has more gas than the bare minimum needed to cover
|
||||||
|
|
|
||||||
|
|
@ -594,38 +594,3 @@ func deriveChainId(v *big.Int) *big.Int {
|
||||||
v = new(big.Int).Sub(v, big.NewInt(35))
|
v = new(big.Int).Sub(v, big.NewInt(35))
|
||||||
return v.Div(v, big.NewInt(2))
|
return v.Div(v, big.NewInt(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FakeSigner implements the Signer interface and accepts unprotected transactions
|
|
||||||
type FakeSigner struct{ londonSigner }
|
|
||||||
|
|
||||||
var _ Signer = FakeSigner{}
|
|
||||||
|
|
||||||
func NewFakeSigner(chainId *big.Int) Signer {
|
|
||||||
signer := NewLondonSigner(chainId)
|
|
||||||
ls, _ := signer.(londonSigner)
|
|
||||||
return FakeSigner{londonSigner: ls}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f FakeSigner) Sender(tx *Transaction) (common.Address, error) {
|
|
||||||
return f.londonSigner.Sender(tx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f FakeSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) {
|
|
||||||
return f.londonSigner.SignatureValues(tx, sig)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f FakeSigner) ChainID() *big.Int {
|
|
||||||
return f.londonSigner.ChainID()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
|
|
||||||
// private key. This hash does not uniquely identify the transaction.
|
|
||||||
func (f FakeSigner) Hash(tx *Transaction) common.Hash {
|
|
||||||
return f.londonSigner.Hash(tx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equal returns true if the given signer is the same as the receiver.
|
|
||||||
func (f FakeSigner) Equal(Signer) bool {
|
|
||||||
// Always return true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/crypto/bls12381"
|
"github.com/ethereum/go-ethereum/crypto/bls12381"
|
||||||
"github.com/ethereum/go-ethereum/crypto/bn256"
|
"github.com/ethereum/go-ethereum/crypto/bn256"
|
||||||
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||||
"github.com/ethereum/go-ethereum/crypto/secp256r1"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"golang.org/x/crypto/ripemd160"
|
"golang.org/x/crypto/ripemd160"
|
||||||
)
|
)
|
||||||
|
|
@ -106,7 +105,6 @@ var PrecompiledContractsCancun = map[common.Address]PrecompiledContract{
|
||||||
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
|
||||||
common.BytesToAddress([]byte{9}): &blake2F{},
|
common.BytesToAddress([]byte{9}): &blake2F{},
|
||||||
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
|
common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{},
|
||||||
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
||||||
|
|
@ -1196,37 +1194,3 @@ func kZGToVersionedHash(kzg kzg4844.Commitment) common.Hash {
|
||||||
|
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
// P256VERIFY (secp256r1 signature verification)
|
|
||||||
// implemented as a native contract
|
|
||||||
type p256Verify struct{}
|
|
||||||
|
|
||||||
// RequiredGas returns the gas required to execute the precompiled contract
|
|
||||||
func (c *p256Verify) RequiredGas(input []byte) uint64 {
|
|
||||||
return params.P256VerifyGas
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run executes the precompiled contract with given 160 bytes of param, returning the output and the used gas
|
|
||||||
func (c *p256Verify) Run(input []byte) ([]byte, error) {
|
|
||||||
// Required input length is 160 bytes
|
|
||||||
const p256VerifyInputLength = 160
|
|
||||||
// Check the input length
|
|
||||||
if len(input) != p256VerifyInputLength {
|
|
||||||
// Input length is invalid
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the hash, r, s, x, y from the input
|
|
||||||
hash := input[0:32]
|
|
||||||
r, s := new(big.Int).SetBytes(input[32:64]), new(big.Int).SetBytes(input[64:96])
|
|
||||||
x, y := new(big.Int).SetBytes(input[96:128]), new(big.Int).SetBytes(input[128:160])
|
|
||||||
|
|
||||||
// Verify the secp256r1 signature
|
|
||||||
if secp256r1.Verify(hash, r, s, x, y) {
|
|
||||||
// Signature is valid
|
|
||||||
return common.LeftPadBytes(common.Big1.Bytes(), 32), nil
|
|
||||||
} else {
|
|
||||||
// Signature is invalid
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
|
||||||
common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381Pairing{},
|
common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381Pairing{},
|
||||||
common.BytesToAddress([]byte{0x0f, 0x11}): &bls12381MapG1{},
|
common.BytesToAddress([]byte{0x0f, 0x11}): &bls12381MapG1{},
|
||||||
common.BytesToAddress([]byte{0x0f, 0x12}): &bls12381MapG2{},
|
common.BytesToAddress([]byte{0x0f, 0x12}): &bls12381MapG2{},
|
||||||
common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EIP-152 test vectors
|
// EIP-152 test vectors
|
||||||
|
|
@ -416,19 +415,3 @@ func BenchmarkPrecompiledBLS12381G2MultiExpWorstCase(b *testing.B) {
|
||||||
}
|
}
|
||||||
benchmarkPrecompiled("0f", testcase, b)
|
benchmarkPrecompiled("0f", testcase, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Benchmarks the sample inputs from the P256VERIFY precompile.
|
|
||||||
func BenchmarkPrecompiledP256Verify(bench *testing.B) {
|
|
||||||
t := precompiledTest{
|
|
||||||
Input: "4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4da73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac36dbcd03009df8c59286b162af3bd7fcc0450c9aa81be5d10d312af6c66b1d604aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff37618b065f9832de4ca6ca971a7a1adc826d0f7c00181a5fb2ddf79ae00b4e10e",
|
|
||||||
Expected: "0000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
Name: "p256Verify",
|
|
||||||
}
|
|
||||||
benchmarkPrecompiled("100", t, bench)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrecompiledP256Verify(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testJson("p256Verify", "100", t)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
37
core/vm/testdata/precompiles/p256Verify.json
vendored
37
core/vm/testdata/precompiles/p256Verify.json
vendored
|
|
@ -1,37 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"Input": "4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4da73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac36dbcd03009df8c59286b162af3bd7fcc0450c9aa81be5d10d312af6c66b1d604aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff37618b065f9832de4ca6ca971a7a1adc826d0f7c00181a5fb2ddf79ae00b4e10e",
|
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
"Gas": 3450,
|
|
||||||
"Name": "CallP256Verify",
|
|
||||||
"NoBenchmark": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9414de3726ee4d237b410c1d85ebcb05553dc578561d9f7942b7250795beb9b9027b657067322fc00ab35263fde0acabf998cd9fcf1282df9555f85dba7bdbbe2dc90f74c9e210bc3e0c60aeaa03729c9e6acde4a048ee58fd2e466c1e7b0374e606b8c22ad2985df7d792ff344f03ce94a079da801006b13640bc5af7932a7b9",
|
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
"Gas": 3450,
|
|
||||||
"Name": "CallP256Verify",
|
|
||||||
"NoBenchmark": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9b35d6a4f7f6fc5620c97d4287696f5174b3d37fa537b74b5fc26997ba79c725d62fe5e5fe6da76eec924e822c5ef853ede6c17069a9e9133a38f87d61599f68e7d5f3c812a255436846ee84a262b79ec4d0783afccf2433deabdca9ecf62bef5ff24e90988c7f139d378549c3a8bc6c94e6a1c911c1e02e6f48ed65aaf3d296e",
|
|
||||||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
"Gas": 3450,
|
|
||||||
"Name": "CallP256Verify",
|
|
||||||
"NoBenchmark": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9c29c3df6ce3431b6f030b1b68b1589508ad9d1a149830489c638653aa4b08af93f6e86a9a7643403b6f5c593410d9f7234a8cd27309bce90447073ce17476850615ff147863bc8652be1e369444f90bbc5f9df05a26362e609f73ab1f1839fe3cd34fd2ae672c110671d49115825fc56b5148321aabe5ba39f2b46f71149cff9",
|
|
||||||
"Expected": "",
|
|
||||||
"Gas": 3450,
|
|
||||||
"Name": "CallP256Verify",
|
|
||||||
"NoBenchmark": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
|
|
||||||
"Expected": "",
|
|
||||||
"Gas": 3450,
|
|
||||||
"Name": "CallP256Verify",
|
|
||||||
"NoBenchmark": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package secp256r1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"crypto/elliptic"
|
|
||||||
"math/big"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generates approptiate public key format from given coordinates
|
|
||||||
func newPublicKey(x, y *big.Int) *ecdsa.PublicKey {
|
|
||||||
// Check if the given coordinates are valid
|
|
||||||
if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the given coordinates are the reference point (infinity)
|
|
||||||
if x.Sign() == 0 && y.Sign() == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &ecdsa.PublicKey{
|
|
||||||
Curve: elliptic.P256(),
|
|
||||||
X: x,
|
|
||||||
Y: y,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package secp256r1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"math/big"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Verifies the given signature (r, s) for the given hash and public key (x, y).
|
|
||||||
func Verify(hash []byte, r, s, x, y *big.Int) bool {
|
|
||||||
// Create the public key format
|
|
||||||
publicKey := newPublicKey(x, y)
|
|
||||||
|
|
||||||
// Check if they are invalid public key coordinates
|
|
||||||
if publicKey == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the signature with the public key,
|
|
||||||
// then return true if it's valid, false otherwise
|
|
||||||
return ecdsa.Verify(publicKey, hash, r, s)
|
|
||||||
}
|
|
||||||
|
|
@ -168,7 +168,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
|
|
||||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||||
if eth.APIBackend.allowUnprotectedTxs {
|
if eth.APIBackend.allowUnprotectedTxs {
|
||||||
log.Info("------Unprotected transactions allowed-------")
|
log.Debug(" ###########", "Unprotected transactions allowed")
|
||||||
|
|
||||||
config.TxPool.AllowUnprotectedTxs = true
|
config.TxPool.AllowUnprotectedTxs = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,21 @@ func (b *EthAPIBackend) GetVoteOnHash(ctx context.Context, starBlockNr uint64, e
|
||||||
return false, fmt.Errorf("Hash mismatch: localChainHash %s, milestoneHash %s", localEndBlockHash, hash)
|
return false, fmt.Errorf("Hash mismatch: localChainHash %s, milestoneHash %s", localEndBlockHash, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ethHandler := (*ethHandler)(b.eth.handler)
|
||||||
|
|
||||||
|
bor, ok := ethHandler.chain.Engine().(*bor.Bor)
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("Bor not available")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bor.HeimdallClient.FetchMilestoneID(ctx, milestoneId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
downloader.UnlockMutex(false, "", endBlockNr, common.Hash{})
|
||||||
|
return false, fmt.Errorf("Milestone ID doesn't exist in Heimdall")
|
||||||
|
}
|
||||||
|
|
||||||
downloader.UnlockMutex(true, milestoneId, endBlockNr, localEndBlock.Hash())
|
downloader.UnlockMutex(true, milestoneId, endBlockNr, localEndBlock.Hash())
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
||||||
|
|
@ -42,22 +42,3 @@ func TestConfigLegacy(t *testing.T) {
|
||||||
readFile("./testdata/test.toml")
|
readFile("./testdata/test.toml")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultConfigLegacy(t *testing.T) {
|
|
||||||
readFile := func(path string) {
|
|
||||||
expectedConfig, err := readLegacyConfig(path)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
testConfig := DefaultConfig()
|
|
||||||
|
|
||||||
testConfig.Identity = "Polygon-Devs"
|
|
||||||
testConfig.DataDir = "/var/lib/bor"
|
|
||||||
|
|
||||||
assert.Equal(t, expectedConfig, testConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
// read file in hcl format
|
|
||||||
t.Run("toml", func(t *testing.T) {
|
|
||||||
readFile("./testdata/default.toml")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
||||||
193
internal/cli/server/testdata/default.toml
vendored
193
internal/cli/server/testdata/default.toml
vendored
|
|
@ -1,193 +0,0 @@
|
||||||
chain = "mainnet"
|
|
||||||
identity = "Polygon-Devs"
|
|
||||||
verbosity = 3
|
|
||||||
log-level = ""
|
|
||||||
vmdebug = false
|
|
||||||
datadir = "/var/lib/bor"
|
|
||||||
ancient = ""
|
|
||||||
"db.engine" = "leveldb"
|
|
||||||
keystore = ""
|
|
||||||
"rpc.batchlimit" = 100
|
|
||||||
"rpc.returndatalimit" = 100000
|
|
||||||
syncmode = "full"
|
|
||||||
gcmode = "full"
|
|
||||||
snapshot = true
|
|
||||||
"bor.logs" = false
|
|
||||||
ethstats = ""
|
|
||||||
devfakeauthor = false
|
|
||||||
|
|
||||||
["eth.requiredblocks"]
|
|
||||||
|
|
||||||
[log]
|
|
||||||
vmodule = ""
|
|
||||||
json = false
|
|
||||||
backtrace = ""
|
|
||||||
debug = false
|
|
||||||
|
|
||||||
[p2p]
|
|
||||||
maxpeers = 50
|
|
||||||
maxpendpeers = 50
|
|
||||||
bind = "0.0.0.0"
|
|
||||||
port = 30303
|
|
||||||
nodiscover = false
|
|
||||||
nat = "any"
|
|
||||||
netrestrict = ""
|
|
||||||
nodekey = ""
|
|
||||||
nodekeyhex = ""
|
|
||||||
txarrivalwait = "500ms"
|
|
||||||
[p2p.discovery]
|
|
||||||
v4disc = true
|
|
||||||
v5disc = false
|
|
||||||
bootnodes = []
|
|
||||||
bootnodesv4 = []
|
|
||||||
bootnodesv5 = []
|
|
||||||
static-nodes = []
|
|
||||||
trusted-nodes = []
|
|
||||||
dns = []
|
|
||||||
|
|
||||||
[heimdall]
|
|
||||||
url = "http://localhost:1317"
|
|
||||||
"bor.without" = false
|
|
||||||
grpc-address = ""
|
|
||||||
"bor.runheimdall" = false
|
|
||||||
"bor.runheimdallargs" = ""
|
|
||||||
"bor.useheimdallapp" = false
|
|
||||||
|
|
||||||
[txpool]
|
|
||||||
locals = []
|
|
||||||
nolocals = false
|
|
||||||
journal = "transactions.rlp"
|
|
||||||
rejournal = "1h0m0s"
|
|
||||||
pricelimit = 1
|
|
||||||
pricebump = 10
|
|
||||||
accountslots = 16
|
|
||||||
globalslots = 32768
|
|
||||||
accountqueue = 16
|
|
||||||
globalqueue = 32768
|
|
||||||
lifetime = "3h0m0s"
|
|
||||||
|
|
||||||
[miner]
|
|
||||||
mine = false
|
|
||||||
etherbase = ""
|
|
||||||
extradata = ""
|
|
||||||
gaslimit = 30000000
|
|
||||||
gasprice = "1000000000"
|
|
||||||
recommit = "2m5s"
|
|
||||||
commitinterrupt = true
|
|
||||||
|
|
||||||
[jsonrpc]
|
|
||||||
ipcdisable = false
|
|
||||||
ipcpath = ""
|
|
||||||
gascap = 50000000
|
|
||||||
evmtimeout = "5s"
|
|
||||||
txfeecap = 1.0
|
|
||||||
allow-unprotected-txs = false
|
|
||||||
enabledeprecatedpersonal = false
|
|
||||||
[jsonrpc.http]
|
|
||||||
enabled = false
|
|
||||||
port = 8545
|
|
||||||
prefix = ""
|
|
||||||
host = "localhost"
|
|
||||||
api = ["eth", "net", "web3", "txpool", "bor"]
|
|
||||||
vhosts = ["localhost"]
|
|
||||||
corsdomain = ["localhost"]
|
|
||||||
ep-size = 40
|
|
||||||
ep-requesttimeout = "0s"
|
|
||||||
[jsonrpc.ws]
|
|
||||||
enabled = false
|
|
||||||
port = 8546
|
|
||||||
prefix = ""
|
|
||||||
host = "localhost"
|
|
||||||
api = ["net", "web3"]
|
|
||||||
origins = ["localhost"]
|
|
||||||
ep-size = 40
|
|
||||||
ep-requesttimeout = "0s"
|
|
||||||
[jsonrpc.graphql]
|
|
||||||
enabled = false
|
|
||||||
port = 0
|
|
||||||
prefix = ""
|
|
||||||
host = ""
|
|
||||||
vhosts = ["localhost"]
|
|
||||||
corsdomain = ["localhost"]
|
|
||||||
ep-size = 0
|
|
||||||
ep-requesttimeout = ""
|
|
||||||
[jsonrpc.auth]
|
|
||||||
jwtsecret = ""
|
|
||||||
addr = "localhost"
|
|
||||||
port = 8551
|
|
||||||
vhosts = ["localhost"]
|
|
||||||
[jsonrpc.timeouts]
|
|
||||||
read = "10s"
|
|
||||||
write = "30s"
|
|
||||||
idle = "2m0s"
|
|
||||||
|
|
||||||
[gpo]
|
|
||||||
blocks = 20
|
|
||||||
percentile = 60
|
|
||||||
maxheaderhistory = 1024
|
|
||||||
maxblockhistory = 1024
|
|
||||||
maxprice = "500000000000"
|
|
||||||
ignoreprice = "2"
|
|
||||||
|
|
||||||
[telemetry]
|
|
||||||
metrics = false
|
|
||||||
expensive = false
|
|
||||||
prometheus-addr = "127.0.0.1:7071"
|
|
||||||
opencollector-endpoint = ""
|
|
||||||
[telemetry.influx]
|
|
||||||
influxdb = false
|
|
||||||
endpoint = ""
|
|
||||||
database = ""
|
|
||||||
username = ""
|
|
||||||
password = ""
|
|
||||||
influxdbv2 = false
|
|
||||||
token = ""
|
|
||||||
bucket = ""
|
|
||||||
organization = ""
|
|
||||||
[telemetry.influx.tags]
|
|
||||||
|
|
||||||
[cache]
|
|
||||||
cache = 1024
|
|
||||||
gc = 25
|
|
||||||
snapshot = 10
|
|
||||||
database = 50
|
|
||||||
trie = 15
|
|
||||||
noprefetch = false
|
|
||||||
preimages = false
|
|
||||||
txlookuplimit = 2350000
|
|
||||||
triesinmemory = 128
|
|
||||||
blocklogs = 32
|
|
||||||
timeout = "1h0m0s"
|
|
||||||
fdlimit = 0
|
|
||||||
|
|
||||||
[leveldb]
|
|
||||||
compactiontablesize = 2
|
|
||||||
compactiontablesizemultiplier = 1.0
|
|
||||||
compactiontotalsize = 10
|
|
||||||
compactiontotalsizemultiplier = 10.0
|
|
||||||
|
|
||||||
[accounts]
|
|
||||||
unlock = []
|
|
||||||
password = ""
|
|
||||||
allow-insecure-unlock = false
|
|
||||||
lightkdf = false
|
|
||||||
disable-bor-wallet = true
|
|
||||||
|
|
||||||
[grpc]
|
|
||||||
addr = ":3131"
|
|
||||||
|
|
||||||
[developer]
|
|
||||||
dev = false
|
|
||||||
period = 0
|
|
||||||
gaslimit = 11500000
|
|
||||||
|
|
||||||
[parallelevm]
|
|
||||||
enable = true
|
|
||||||
procs = 8
|
|
||||||
|
|
||||||
[pprof]
|
|
||||||
pprof = false
|
|
||||||
port = 6060
|
|
||||||
addr = "127.0.0.1"
|
|
||||||
memprofilerate = 524288
|
|
||||||
blockprofilerate = 0
|
|
||||||
|
|
@ -702,8 +702,12 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block
|
||||||
for idx, receipt := range receipts {
|
for idx, receipt := range receipts {
|
||||||
tx := txs[idx]
|
tx := txs[idx]
|
||||||
|
|
||||||
// Derive the sender.
|
var signer types.Signer = types.FrontierSigner{}
|
||||||
signer := types.MakeSigner(s.b.ChainConfig(), block.Number(), block.Time())
|
|
||||||
|
if tx.Protected() {
|
||||||
|
signer = types.NewEIP155Signer(tx.ChainId())
|
||||||
|
}
|
||||||
|
|
||||||
from, _ := types.Sender(signer, tx)
|
from, _ := types.Sender(signer, tx)
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
|
|
@ -719,11 +723,6 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block
|
||||||
"logs": receipt.Logs,
|
"logs": receipt.Logs,
|
||||||
"logsBloom": receipt.Bloom,
|
"logsBloom": receipt.Bloom,
|
||||||
"type": hexutil.Uint(tx.Type()),
|
"type": hexutil.Uint(tx.Type()),
|
||||||
"effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice),
|
|
||||||
}
|
|
||||||
|
|
||||||
if receipt.EffectiveGasPrice == nil {
|
|
||||||
fields["effectiveGasPrice"] = new(hexutil.Big)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign receipt status or post state.
|
// Assign receipt status or post state.
|
||||||
|
|
@ -734,7 +733,7 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block
|
||||||
}
|
}
|
||||||
|
|
||||||
if receipt.Logs == nil {
|
if receipt.Logs == nil {
|
||||||
fields["logs"] = []*types.Log{}
|
fields["logs"] = [][]*types.Log{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if borReceipt != nil && idx == len(receipts)-1 {
|
if borReceipt != nil && idx == len(receipts)-1 {
|
||||||
|
|
|
||||||
|
|
@ -2146,251 +2146,3 @@ func TestRPCGetTransactionReceipt(t *testing.T) {
|
||||||
require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have)
|
require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRPCGetTransactionReceiptsByBlock(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
// Initialize test accounts
|
|
||||||
var (
|
|
||||||
acc1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
|
||||||
acc2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
|
||||||
acc1Addr = crypto.PubkeyToAddress(acc1Key.PublicKey)
|
|
||||||
acc2Addr = crypto.PubkeyToAddress(acc2Key.PublicKey)
|
|
||||||
contract = common.HexToAddress("0000000000000000000000000000000000031ec7")
|
|
||||||
genesis = &core.Genesis{
|
|
||||||
Config: params.TestChainConfig,
|
|
||||||
Alloc: core.GenesisAlloc{
|
|
||||||
acc1Addr: {Balance: big.NewInt(params.Ether)},
|
|
||||||
acc2Addr: {Balance: big.NewInt(params.Ether)},
|
|
||||||
contract: {Balance: big.NewInt(params.Ether), Code: common.FromHex("0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033")},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
genTxs = 5
|
|
||||||
genBlocks = 1
|
|
||||||
signer = types.LatestSignerForChainID(params.TestChainConfig.ChainID)
|
|
||||||
txHashes = make([]common.Hash, 0, genTxs)
|
|
||||||
)
|
|
||||||
|
|
||||||
backend := newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
|
|
||||||
switch i {
|
|
||||||
case 0:
|
|
||||||
// transfer 1000wei
|
|
||||||
tx1, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(0), To: &acc2Addr, Value: big.NewInt(1000), Gas: params.TxGas, GasPrice: b.BaseFee(), Data: nil}), types.HomesteadSigner{}, acc1Key)
|
|
||||||
b.AddTx(tx1)
|
|
||||||
txHashes = append(txHashes, tx1.Hash())
|
|
||||||
|
|
||||||
// create contract
|
|
||||||
tx2, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(1), To: nil, Gas: 53100, GasPrice: b.BaseFee(), Data: common.FromHex("0x60806040")}), signer, acc1Key)
|
|
||||||
b.AddTx(tx2)
|
|
||||||
txHashes = append(txHashes, tx2.Hash())
|
|
||||||
|
|
||||||
// with logs
|
|
||||||
// transfer(address to, uint256 value)
|
|
||||||
data3 := fmt.Sprintf("0xa9059cbb%s%s", common.HexToHash(common.BigToAddress(big.NewInt(int64(i + 1))).Hex()).String()[2:], common.BytesToHash([]byte{byte(i + 11)}).String()[2:])
|
|
||||||
tx3, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(2), To: &contract, Gas: 60000, GasPrice: b.BaseFee(), Data: common.FromHex(data3)}), signer, acc1Key)
|
|
||||||
b.AddTx(tx3)
|
|
||||||
txHashes = append(txHashes, tx3.Hash())
|
|
||||||
|
|
||||||
// dynamic fee with logs
|
|
||||||
// transfer(address to, uint256 value)
|
|
||||||
data4 := fmt.Sprintf("0xa9059cbb%s%s", common.HexToHash(common.BigToAddress(big.NewInt(int64(i + 1))).Hex()).String()[2:], common.BytesToHash([]byte{byte(i + 11)}).String()[2:])
|
|
||||||
fee := big.NewInt(500)
|
|
||||||
fee.Add(fee, b.BaseFee())
|
|
||||||
tx4, _ := types.SignTx(types.NewTx(&types.DynamicFeeTx{Nonce: uint64(3), To: &contract, Gas: 60000, Value: big.NewInt(1), GasTipCap: big.NewInt(500), GasFeeCap: fee, Data: common.FromHex(data4)}), signer, acc1Key)
|
|
||||||
b.AddTx(tx4)
|
|
||||||
txHashes = append(txHashes, tx4.Hash())
|
|
||||||
|
|
||||||
// access list with contract create
|
|
||||||
accessList := types.AccessList{{
|
|
||||||
Address: contract,
|
|
||||||
StorageKeys: []common.Hash{{0}},
|
|
||||||
}}
|
|
||||||
tx5, _ := types.SignTx(types.NewTx(&types.AccessListTx{Nonce: uint64(4), To: nil, Gas: 58100, GasPrice: b.BaseFee(), Data: common.FromHex("0x60806040"), AccessList: accessList}), signer, acc1Key)
|
|
||||||
b.AddTx(tx5)
|
|
||||||
txHashes = append(txHashes, tx5.Hash())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
api := NewBlockChainAPI(backend)
|
|
||||||
blockHashes := make([]common.Hash, genBlocks+1)
|
|
||||||
ctx := context.Background()
|
|
||||||
for i := 0; i <= genBlocks; i++ {
|
|
||||||
header, err := backend.HeaderByNumber(ctx, rpc.BlockNumber(i))
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to get block: %d err: %v", i, err)
|
|
||||||
}
|
|
||||||
blockHashes[i] = header.Hash()
|
|
||||||
}
|
|
||||||
blockNrOrHash := rpc.BlockNumberOrHashWithHash(blockHashes[1], true)
|
|
||||||
|
|
||||||
var testSuite = []struct {
|
|
||||||
txHash common.Hash
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
// 0. normal success
|
|
||||||
{
|
|
||||||
txHash: txHashes[0],
|
|
||||||
want: `{
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"contractAddress": null,
|
|
||||||
"cumulativeGasUsed": "0x5208",
|
|
||||||
"effectiveGasPrice": "0x342770c0",
|
|
||||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"gasUsed": "0x5208",
|
|
||||||
"logs": [
|
|
||||||
{
|
|
||||||
"address": "0x0000000000000000000000000000000000001010",
|
|
||||||
"topics": [
|
|
||||||
"0xe6497e3ee548a3372136af2fcb0696db31fc6cf20260707645068bd3fe97f3c4",
|
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000001010",
|
|
||||||
"0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"0x0000000000000000000000000d3ab14bbad3d99f4203bd7a11acb94882050e7e"
|
|
||||||
],
|
|
||||||
"data": "0x00000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000de0a5fd640afa000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0a5fd640af6180000000000000000000000000000000000000000000000000de0b6b3a76403e8",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"transactionHash": "0x644a31c354391520d00e95b9affbbb010fc79ac268144ab8e28207f4cf51097e",
|
|
||||||
"transactionIndex": "0x0",
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"logIndex": "0x0",
|
|
||||||
"removed": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000808000000000000000000000000000000000000000000000000000000000800000000000000000000100000020000000000000000000000000000000000802000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000800000000000000000000000800000108000000000000000000000000000000000000000000000000020000000000000000000100000",
|
|
||||||
"status": "0x1",
|
|
||||||
"to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e",
|
|
||||||
"transactionHash": "0x644a31c354391520d00e95b9affbbb010fc79ac268144ab8e28207f4cf51097e",
|
|
||||||
"transactionIndex": "0x0",
|
|
||||||
"type": "0x0"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
// 1. create contract
|
|
||||||
{
|
|
||||||
txHash: txHashes[1],
|
|
||||||
want: `{
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592",
|
|
||||||
"cumulativeGasUsed": "0x12156",
|
|
||||||
"effectiveGasPrice": "0x342770c0",
|
|
||||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"gasUsed": "0xcf4e",
|
|
||||||
"logs": [],
|
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
||||||
"status": "0x1",
|
|
||||||
"to": null,
|
|
||||||
"transactionHash": "0x705a7fca1d214002ee90d4e1c651b53e3506e6d5e3a539e9a7f7bf05b49add91",
|
|
||||||
"transactionIndex": "0x1",
|
|
||||||
"type": "0x0"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
// 2. with logs success
|
|
||||||
{
|
|
||||||
txHash: txHashes[2],
|
|
||||||
want: `{
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"contractAddress": null,
|
|
||||||
"cumulativeGasUsed": "0x17f7e",
|
|
||||||
"effectiveGasPrice": "0x342770c0",
|
|
||||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"gasUsed": "0x5e28",
|
|
||||||
"logs": [
|
|
||||||
{
|
|
||||||
"address": "0x0000000000000000000000000000000000031ec7",
|
|
||||||
"topics": [
|
|
||||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
|
||||||
"0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
||||||
],
|
|
||||||
"data": "0x000000000000000000000000000000000000000000000000000000000000000b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"transactionHash": "0xa228af0975b99799bd28331085a6966aba2fb5814a8d89aabc342462aa40429a",
|
|
||||||
"transactionIndex": "0x2",
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"logIndex": "0x1",
|
|
||||||
"removed": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"logsBloom": "0x00000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000800000000000000008000000000000000000040000000000000020000000080000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000800000000000000000000000000000000000000040000000000000000000000000000000000000000020000000000000000000000000",
|
|
||||||
"status": "0x1",
|
|
||||||
"to": "0x0000000000000000000000000000000000031ec7",
|
|
||||||
"transactionHash": "0xa228af0975b99799bd28331085a6966aba2fb5814a8d89aabc342462aa40429a",
|
|
||||||
"transactionIndex": "0x2",
|
|
||||||
"type": "0x0"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
// 3. dynamic tx with logs success
|
|
||||||
{
|
|
||||||
txHash: txHashes[3],
|
|
||||||
want: `{
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"contractAddress": null,
|
|
||||||
"cumulativeGasUsed": "0x1d30b",
|
|
||||||
"effectiveGasPrice": "0x342772b4",
|
|
||||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"gasUsed": "0x538d",
|
|
||||||
"logs": [
|
|
||||||
{
|
|
||||||
"address": "0x0000000000000000000000000000000000001010",
|
|
||||||
"topics": [
|
|
||||||
"0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63",
|
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000001010",
|
|
||||||
"0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
],
|
|
||||||
"data": "0x0000000000000000000000000000000000000000000000000000000000a32f640000000000000000000000000000000000000000000000000de06892fa4b3d9800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de06892f9a80e340000000000000000000000000000000000000000000000000000000000a32f64",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"transactionHash": "0xc2cc458a65bc96f642d4a2063cce162b0da642613d801271bdbc4aa7e775f3ed",
|
|
||||||
"transactionIndex": "0x3",
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"logIndex": "0x2",
|
|
||||||
"removed": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000020000000000000020000000000000000000800000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001800000000000000000000000000000100000000020000000000000000000000000000000000000000020000000000000000000100000",
|
|
||||||
"status": "0x0",
|
|
||||||
"to": "0x0000000000000000000000000000000000031ec7",
|
|
||||||
"transactionHash": "0xc2cc458a65bc96f642d4a2063cce162b0da642613d801271bdbc4aa7e775f3ed",
|
|
||||||
"transactionIndex": "0x3",
|
|
||||||
"type": "0x2"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
// 4. access list tx with create contract
|
|
||||||
{
|
|
||||||
txHash: txHashes[4],
|
|
||||||
want: `{
|
|
||||||
"blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b",
|
|
||||||
"blockNumber": "0x1",
|
|
||||||
"contractAddress": "0xfdaa97661a584d977b4d3abb5370766ff5b86a18",
|
|
||||||
"cumulativeGasUsed": "0x2b325",
|
|
||||||
"effectiveGasPrice": "0x342770c0",
|
|
||||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
|
||||||
"gasUsed": "0xe01a",
|
|
||||||
"logs": [],
|
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
||||||
"status": "0x1",
|
|
||||||
"to": null,
|
|
||||||
"transactionHash": "0x1e1161cf3fd01a02fc9c5ee66fc45a4805b3828bf41edd54213c20d97fc12b1d",
|
|
||||||
"transactionIndex": "0x4",
|
|
||||||
"type": "0x1"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
receipts, err := api.GetTransactionReceiptsByBlock(context.Background(), blockNrOrHash)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("api error")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, tt := range testSuite {
|
|
||||||
data, err := json.Marshal(receipts[i])
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("test %d: json marshal error", i)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
want, have := tt.want, string(data)
|
|
||||||
require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -842,17 +842,17 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
|
||||||
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 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 {
|
func (c *ChainConfig) IsShanghai(num *big.Int) bool {
|
||||||
return isBlockForked(c.ShanghaiBlock, num)
|
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 {
|
func (c *ChainConfig) IsCancun(num *big.Int) bool {
|
||||||
return isBlockForked(c.CancunBlock, num)
|
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 {
|
func (c *ChainConfig) IsPrague(num *big.Int) bool {
|
||||||
return isBlockForked(c.PragueBlock, num)
|
return isBlockForked(c.PragueBlock, num)
|
||||||
}
|
}
|
||||||
|
|
@ -912,9 +912,9 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||||
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
||||||
{name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true},
|
{name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true},
|
||||||
{name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true},
|
{name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true},
|
||||||
{name: "shanghaiBlock", block: c.ShanghaiBlock},
|
{name: "ShanghaiBlock", block: c.ShanghaiBlock},
|
||||||
{name: "cancunBlock", block: c.CancunBlock, optional: true},
|
{name: "CancunBlock", block: c.CancunBlock, optional: true},
|
||||||
{name: "pragueBlock", block: c.PragueBlock, optional: true},
|
{name: "pragueTime", block: c.PragueBlock, optional: true},
|
||||||
} {
|
} {
|
||||||
if lastFork.name != "" {
|
if lastFork.name != "" {
|
||||||
switch {
|
switch {
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,6 @@ const (
|
||||||
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
|
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
|
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,
|
// 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
|
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
|
||||||
RefundQuotient uint64 = 2
|
RefundQuotient uint64 = 2
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue