mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
all: replace common big values with const
prevent constant value change
This commit is contained in:
parent
2a2013014c
commit
9cab527dc1
100 changed files with 1203 additions and 1193 deletions
|
|
@ -181,7 +181,7 @@ func TestConstructor(t *testing.T) {
|
||||||
t.Error("Missing expected constructor")
|
t.Error("Missing expected constructor")
|
||||||
}
|
}
|
||||||
// Test pack/unpack
|
// Test pack/unpack
|
||||||
packed, err := abi.Pack("", big.NewInt(1), big.NewInt(2))
|
packed, err := abi.Pack("", common.Big1, common.Big2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -190,10 +190,10 @@ func TestConstructor(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(unpacked[0], big.NewInt(1)) {
|
if !reflect.DeepEqual(unpacked[0], common.Big1) {
|
||||||
t.Error("Unable to pack/unpack from constructor")
|
t.Error("Unable to pack/unpack from constructor")
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(unpacked[1], big.NewInt(2)) {
|
if !reflect.DeepEqual(unpacked[1], common.Big2) {
|
||||||
t.Error("Unable to pack/unpack from constructor")
|
t.Error("Unable to pack/unpack from constructor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -483,7 +483,7 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
|
||||||
|
|
||||||
// test string, fixed array uint256[2]
|
// test string, fixed array uint256[2]
|
||||||
strin := "hello world"
|
strin := "hello world"
|
||||||
arrin := [2]*big.Int{big.NewInt(1), big.NewInt(2)}
|
arrin := [2]*big.Int{common.Big1, common.Big2}
|
||||||
fixedArrStrPack, err := abi.Pack("fixedArrStr", strin, arrin)
|
fixedArrStrPack, err := abi.Pack("fixedArrStr", strin, arrin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
@ -509,7 +509,7 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
|
||||||
|
|
||||||
// test byte array, fixed array uint256[2]
|
// test byte array, fixed array uint256[2]
|
||||||
bytesin := []byte(strin)
|
bytesin := []byte(strin)
|
||||||
arrin = [2]*big.Int{big.NewInt(1), big.NewInt(2)}
|
arrin = [2]*big.Int{common.Big1, common.Big2}
|
||||||
fixedArrBytesPack, err := abi.Pack("fixedArrBytes", bytesin, arrin)
|
fixedArrBytesPack, err := abi.Pack("fixedArrBytes", bytesin, arrin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
@ -535,8 +535,8 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
|
||||||
|
|
||||||
// test string, fixed array uint256[2], dynamic array uint256[]
|
// test string, fixed array uint256[2], dynamic array uint256[]
|
||||||
strin = "hello world"
|
strin = "hello world"
|
||||||
fixedarrin := [2]*big.Int{big.NewInt(1), big.NewInt(2)}
|
fixedarrin := [2]*big.Int{common.Big1, common.Big2}
|
||||||
dynarrin := []*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}
|
dynarrin := []*big.Int{common.Big1, common.Big2, common.Big3}
|
||||||
mixedArrStrPack, err := abi.Pack("mixedArrStr", strin, fixedarrin, dynarrin)
|
mixedArrStrPack, err := abi.Pack("mixedArrStr", strin, fixedarrin, dynarrin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
@ -574,8 +574,8 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
|
||||||
|
|
||||||
// test string, fixed array uint256[2], fixed array uint256[3]
|
// test string, fixed array uint256[2], fixed array uint256[3]
|
||||||
strin = "hello world"
|
strin = "hello world"
|
||||||
fixedarrin1 := [2]*big.Int{big.NewInt(1), big.NewInt(2)}
|
fixedarrin1 := [2]*big.Int{common.Big1, common.Big2}
|
||||||
fixedarrin2 := [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}
|
fixedarrin2 := [3]*big.Int{common.Big1, common.Big2, common.Big3}
|
||||||
doubleFixedArrStrPack, err := abi.Pack("doubleFixedArrStr", strin, fixedarrin1, fixedarrin2)
|
doubleFixedArrStrPack, err := abi.Pack("doubleFixedArrStr", strin, fixedarrin1, fixedarrin2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
@ -607,9 +607,9 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
|
||||||
|
|
||||||
// test string, fixed array uint256[2], dynamic array uint256[], fixed array uint256[3]
|
// test string, fixed array uint256[2], dynamic array uint256[], fixed array uint256[3]
|
||||||
strin = "hello world"
|
strin = "hello world"
|
||||||
fixedarrin1 = [2]*big.Int{big.NewInt(1), big.NewInt(2)}
|
fixedarrin1 = [2]*big.Int{common.Big1, common.Big2}
|
||||||
dynarrin = []*big.Int{big.NewInt(1), big.NewInt(2)}
|
dynarrin = []*big.Int{common.Big1, common.Big2}
|
||||||
fixedarrin2 = [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}
|
fixedarrin2 = [3]*big.Int{common.Big1, common.Big2, common.Big3}
|
||||||
multipleMixedArrStrPack, err := abi.Pack("multipleMixedArrStr", strin, fixedarrin1, dynarrin, fixedarrin2)
|
multipleMixedArrStrPack, err := abi.Pack("multipleMixedArrStr", strin, fixedarrin1, dynarrin, fixedarrin2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
@ -795,7 +795,7 @@ func TestUnpackEventIntoMap(t *testing.T) {
|
||||||
receivedMap := map[string]interface{}{}
|
receivedMap := map[string]interface{}{}
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
if err := abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
if err := abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
||||||
|
|
@ -858,7 +858,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
|
||||||
if len(sendMap) != 1 {
|
if len(sendMap) != 1 {
|
||||||
t.Error("unpacked `send` map expected to have length 1")
|
t.Error("unpacked `send` map expected to have length 1")
|
||||||
}
|
}
|
||||||
if sendMap["amount"].(*big.Int).Cmp(big.NewInt(1)) != 0 {
|
if sendMap["amount"].(*big.Int).Cmp(common.Big1) != 0 {
|
||||||
t.Error("unpacked `send` map expected `amount` value of 1")
|
t.Error("unpacked `send` map expected `amount` value of 1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -939,7 +939,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
|
||||||
}
|
}
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
if err = abi.UnpackIntoMap(receivedMap, "Received", data); err != nil {
|
if err = abi.UnpackIntoMap(receivedMap, "Received", data); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ func TestSimulatedBackend(t *testing.T) {
|
||||||
|
|
||||||
// generate a transaction and confirm you can retrieve it
|
// generate a transaction and confirm you can retrieve it
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
code := `6060604052600a8060106000396000f360606040526008565b00`
|
code := `6060604052600a8060106000396000f360606040526008565b00`
|
||||||
var gas uint64 = 3000000
|
var gas uint64 = 3000000
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), gas, gasPrice, common.FromHex(code))
|
tx := types.NewContractCreation(0, common.Big0, gas, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
|
||||||
|
|
||||||
err = sim.SendTransaction(context.Background(), tx)
|
err = sim.SendTransaction(context.Background(), tx)
|
||||||
|
|
@ -165,7 +165,7 @@ func TestNewAdjustTimeFail(t *testing.T) {
|
||||||
|
|
||||||
// Create tx and send
|
// Create tx and send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -265,7 +265,7 @@ func TestBlockByNumber(t *testing.T) {
|
||||||
t.Errorf("did not get most recent block, instead got block number %v", block.NumberU64())
|
t.Errorf("did not get most recent block, instead got block number %v", block.NumberU64())
|
||||||
}
|
}
|
||||||
|
|
||||||
blockByNumber, err := sim.BlockByNumber(bgCtx, big.NewInt(1))
|
blockByNumber, err := sim.BlockByNumber(bgCtx, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get block by number: %v", err)
|
t.Errorf("could not get block by number: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -281,7 +281,7 @@ func TestNonceAt(t *testing.T) {
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
nonce, err := sim.NonceAt(bgCtx, testAddr, big.NewInt(0))
|
nonce, err := sim.NonceAt(bgCtx, testAddr, common.Big0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get nonce for test addr: %v", err)
|
t.Errorf("could not get nonce for test addr: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +292,7 @@ func TestNonceAt(t *testing.T) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -307,7 +307,7 @@ func TestNonceAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
|
|
||||||
newNonce, err := sim.NonceAt(bgCtx, testAddr, big.NewInt(1))
|
newNonce, err := sim.NonceAt(bgCtx, testAddr, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get nonce for test addr: %v", err)
|
t.Errorf("could not get nonce for test addr: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ func TestNonceAt(t *testing.T) {
|
||||||
// create some more blocks
|
// create some more blocks
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
// Check that we can get data for an older block/state
|
// Check that we can get data for an older block/state
|
||||||
newNonce, err = sim.NonceAt(bgCtx, testAddr, big.NewInt(1))
|
newNonce, err = sim.NonceAt(bgCtx, testAddr, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not get nonce for test addr: %v", err)
|
t.Fatalf("could not get nonce for test addr: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ func TestSendTransaction(t *testing.T) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -351,7 +351,7 @@ func TestSendTransaction(t *testing.T) {
|
||||||
}
|
}
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
|
|
||||||
block, err := sim.BlockByNumber(bgCtx, big.NewInt(1))
|
block, err := sim.BlockByNumber(bgCtx, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get block at height 1: %v", err)
|
t.Errorf("could not get block at height 1: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -374,7 +374,7 @@ func TestTransactionByHash(t *testing.T) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -451,8 +451,8 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &addr,
|
To: &addr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, params.TxGas, nil, nil},
|
}, params.TxGas, nil, nil},
|
||||||
|
|
||||||
|
|
@ -460,8 +460,8 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 0, errors.New("execution reverted"), nil},
|
}, 0, errors.New("execution reverted"), nil},
|
||||||
|
|
||||||
|
|
@ -469,7 +469,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("d8b98391"),
|
Data: common.Hex2Bytes("d8b98391"),
|
||||||
}, 0, errors.New("execution reverted: revert reason"), "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000"},
|
}, 0, errors.New("execution reverted: revert reason"), "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000"},
|
||||||
|
|
@ -478,7 +478,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("aa8b1d30"),
|
Data: common.Hex2Bytes("aa8b1d30"),
|
||||||
}, 0, errors.New("execution reverted"), nil},
|
}, 0, errors.New("execution reverted"), nil},
|
||||||
|
|
@ -487,7 +487,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 100000,
|
Gas: 100000,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("50f6fe34"),
|
Data: common.Hex2Bytes("50f6fe34"),
|
||||||
}, 0, errors.New("gas required exceeds allowance (100000)"), nil},
|
}, 0, errors.New("gas required exceeds allowance (100000)"), nil},
|
||||||
|
|
@ -496,7 +496,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 100000,
|
Gas: 100000,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("b9b046f9"),
|
Data: common.Hex2Bytes("b9b046f9"),
|
||||||
}, 0, errors.New("invalid opcode: INVALID"), nil},
|
}, 0, errors.New("invalid opcode: INVALID"), nil},
|
||||||
|
|
@ -505,7 +505,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &contractAddr,
|
To: &contractAddr,
|
||||||
Gas: 100000,
|
Gas: 100000,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("e09fface"),
|
Data: common.Hex2Bytes("e09fface"),
|
||||||
}, 21275, nil, nil},
|
}, 21275, nil, nil},
|
||||||
|
|
@ -552,7 +552,7 @@ func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
Value: big.NewInt(100000000000),
|
Value: big.NewInt(100000000000),
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 21000, nil},
|
}, 21000, nil},
|
||||||
|
|
@ -589,7 +589,7 @@ func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
To: &addr,
|
To: &addr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
||||||
GasTipCap: big.NewInt(1),
|
GasTipCap: common.Big1,
|
||||||
Value: big.NewInt(1e17), // the remaining balance for fee is 2.1ether
|
Value: big.NewInt(1e17), // the remaining balance for fee is 2.1ether
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, params.TxGas, nil},
|
}, params.TxGas, nil},
|
||||||
|
|
@ -599,7 +599,7 @@ func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
To: &addr,
|
To: &addr,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
||||||
GasTipCap: big.NewInt(1),
|
GasTipCap: common.Big1,
|
||||||
Value: big.NewInt(1e17 + 1), // the remaining balance for fee is 2.1ether
|
Value: big.NewInt(1e17 + 1), // the remaining balance for fee is 2.1ether
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, params.TxGas, errors.New("gas required exceeds allowance (20999)")}, // 20999=(2.2ether-0.1ether-1wei)/(1e14)
|
}, params.TxGas, errors.New("gas required exceeds allowance (20999)")}, // 20999=(2.2ether-0.1ether-1wei)/(1e14)
|
||||||
|
|
@ -669,7 +669,7 @@ func TestHeaderByNumber(t *testing.T) {
|
||||||
t.Errorf("could not get header for blockheight of 1: %v", err)
|
t.Errorf("could not get header for blockheight of 1: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
blockHeader, err := sim.HeaderByNumber(bgCtx, big.NewInt(1))
|
blockHeader, err := sim.HeaderByNumber(bgCtx, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get header for blockheight of 1: %v", err)
|
t.Errorf("could not get header for blockheight of 1: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -681,7 +681,7 @@ func TestHeaderByNumber(t *testing.T) {
|
||||||
t.Errorf("did not get blockheader for block 1. instead got block %v", blockHeader.Number.Int64())
|
t.Errorf("did not get blockheader for block 1. instead got block %v", blockHeader.Number.Int64())
|
||||||
}
|
}
|
||||||
|
|
||||||
block, err := sim.BlockByNumber(bgCtx, big.NewInt(1))
|
block, err := sim.BlockByNumber(bgCtx, common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get block for blockheight of 1: %v", err)
|
t.Errorf("could not get block for blockheight of 1: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -712,7 +712,7 @@ func TestTransactionCount(t *testing.T) {
|
||||||
}
|
}
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -769,7 +769,7 @@ func TestTransactionInBlock(t *testing.T) {
|
||||||
}
|
}
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -827,7 +827,7 @@ func TestPendingNonceAt(t *testing.T) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -882,7 +882,7 @@ func TestTransactionReceipt(t *testing.T) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -1366,7 +1366,7 @@ func TestForkResendTx(t *testing.T) {
|
||||||
parent := sim.blockchain.CurrentBlock()
|
parent := sim.blockchain.CurrentBlock()
|
||||||
// 2.
|
// 2.
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
|
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
@ -1409,7 +1409,7 @@ func TestCommitReturnValue(t *testing.T) {
|
||||||
|
|
||||||
// Create a block in the original chain (containing a transaction to force different block hashes)
|
// Create a block in the original chain (containing a transaction to force different block hashes)
|
||||||
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
|
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
|
||||||
sim.SendTransaction(context.Background(), tx)
|
sim.SendTransaction(context.Background(), tx)
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"name": hash,
|
"name": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
|
|
@ -242,7 +242,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"names": hash,
|
"names": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
|
|
@ -267,7 +267,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"addresses": hash,
|
"addresses": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
|
|
@ -293,7 +293,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"function": functionTy,
|
"function": functionTy,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
|
|
@ -315,7 +315,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]interface{}{
|
||||||
"content": hash,
|
"content": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": common.Big1,
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
}
|
}
|
||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ var bindTests = []struct {
|
||||||
|
|
||||||
if str, num, _, err := getter.Getter(nil); err != nil {
|
if str, num, _, err := getter.Getter(nil); err != nil {
|
||||||
t.Fatalf("Failed to call anonymous field retriever: %v", err)
|
t.Fatalf("Failed to call anonymous field retriever: %v", err)
|
||||||
} else if str != "Hi" || num.Cmp(big.NewInt(1)) != 0 {
|
} else if str != "Hi" || num.Cmp(common.Big1) != 0 {
|
||||||
t.Fatalf("Retrieved value mismatch: have %v/%v, want %v/%v", str, num, "Hi", 1)
|
t.Fatalf("Retrieved value mismatch: have %v/%v, want %v/%v", str, num, "Hi", 1)
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|
@ -410,7 +410,7 @@ var bindTests = []struct {
|
||||||
|
|
||||||
if res, err := tupler.Tuple(nil); err != nil {
|
if res, err := tupler.Tuple(nil); err != nil {
|
||||||
t.Fatalf("Failed to call structure retriever: %v", err)
|
t.Fatalf("Failed to call structure retriever: %v", err)
|
||||||
} else if res.A != "Hi" || res.B.Cmp(big.NewInt(1)) != 0 {
|
} else if res.A != "Hi" || res.B.Cmp(common.Big1) != 0 {
|
||||||
t.Fatalf("Retrieved value mismatch: have %v/%v, want %v/%v", res.A, res.B, "Hi", 1)
|
t.Fatalf("Retrieved value mismatch: have %v/%v, want %v/%v", res.A, res.B, "Hi", 1)
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|
@ -1262,8 +1262,8 @@ var bindTests = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
a := TupleS{
|
a := TupleS{
|
||||||
A: big.NewInt(1),
|
A: common.Big1,
|
||||||
B: []*big.Int{big.NewInt(2), big.NewInt(3)},
|
B: []*big.Int{common.Big2, common.Big3},
|
||||||
C: []TupleT{
|
C: []TupleT{
|
||||||
{
|
{
|
||||||
X: big.NewInt(4),
|
X: big.NewInt(4),
|
||||||
|
|
@ -1405,11 +1405,11 @@ var bindTests = []struct {
|
||||||
res, err := testContract.Add(&bind.CallOpts{
|
res, err := testContract.Add(&bind.CallOpts{
|
||||||
From: auth.From,
|
From: auth.From,
|
||||||
Pending: false,
|
Pending: false,
|
||||||
}, big.NewInt(1), big.NewInt(2))
|
}, common.Big1, common.Big2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to call linked contract: %v", err)
|
t.Fatalf("Failed to call linked contract: %v", err)
|
||||||
}
|
}
|
||||||
if res.Cmp(big.NewInt(3)) != 0 {
|
if res.Cmp(common.Big3) != 0 {
|
||||||
t.Fatalf("Add did not return the correct result: %d != %d", res, 3)
|
t.Fatalf("Add did not return the correct result: %d != %d", res, 3)
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|
@ -1486,7 +1486,7 @@ var bindTests = []struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
contract.Foo(auth, big.NewInt(1), big.NewInt(2))
|
contract.Foo(auth, common.Big1, common.Big2)
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
select {
|
select {
|
||||||
case n := <-resCh:
|
case n := <-resCh:
|
||||||
|
|
@ -1497,7 +1497,7 @@ var bindTests = []struct {
|
||||||
t.Fatalf("Wait bar0 event timeout")
|
t.Fatalf("Wait bar0 event timeout")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Foo0(auth, big.NewInt(1))
|
contract.Foo0(auth, common.Big1)
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
select {
|
select {
|
||||||
case n := <-resCh:
|
case n := <-resCh:
|
||||||
|
|
@ -1685,7 +1685,7 @@ var bindTests = []struct {
|
||||||
}
|
}
|
||||||
if num, err := pav.ViewFunc(nil); err != nil {
|
if num, err := pav.ViewFunc(nil); err != nil {
|
||||||
t.Fatalf("Failed to call anonymous field retriever: %v", err)
|
t.Fatalf("Failed to call anonymous field retriever: %v", err)
|
||||||
} else if num.Cmp(big.NewInt(1)) != 0 {
|
} else if num.Cmp(common.Big1) != 0 {
|
||||||
t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 1)
|
t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 1)
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|
@ -1838,10 +1838,10 @@ var bindTests = []struct {
|
||||||
}
|
}
|
||||||
var count int
|
var count int
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
if it.Event.S.A.Cmp(big.NewInt(1)) != 0 {
|
if it.Event.S.A.Cmp(common.Big1) != 0 {
|
||||||
t.Fatal("Unexpected contract event")
|
t.Fatal("Unexpected contract event")
|
||||||
}
|
}
|
||||||
if it.Event.S.B.Cmp(big.NewInt(2)) != 0 {
|
if it.Event.S.B.Cmp(common.Big2) != 0 {
|
||||||
t.Fatal("Unexpected contract event")
|
t.Fatal("Unexpected contract event")
|
||||||
}
|
}
|
||||||
count += 1
|
count += 1
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ func TestWaitDeployed(t *testing.T) {
|
||||||
|
|
||||||
// Create the transaction
|
// Create the transaction
|
||||||
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, gasPrice, common.FromHex(test.code))
|
tx := types.NewContractCreation(0, common.Big0, test.gas, gasPrice, common.FromHex(test.code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
||||||
// Wait for it to get mined in the background.
|
// Wait for it to get mined in the background.
|
||||||
|
|
@ -109,11 +109,11 @@ func TestWaitDeployedCornerCases(t *testing.T) {
|
||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
|
|
||||||
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, common.Big1)
|
||||||
|
|
||||||
// Create a transaction to an account.
|
// Create a transaction to an account.
|
||||||
code := "6060604052600a8060106000396000f360606040526008565b00"
|
code := "6060604052600a8060106000396000f360606040526008565b00"
|
||||||
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
tx := types.NewTransaction(0, common.HexToAddress("0x01"), common.Big0, 3000000, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
@ -125,7 +125,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a transaction that is not mined.
|
// Create a transaction that is not mined.
|
||||||
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
tx = types.NewContractCreation(1, common.Big0, 3000000, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func TestMethodPack(t *testing.T) {
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
|
|
||||||
packed, err = abi.Pack("slice256", []*big.Int{big.NewInt(1), big.NewInt(2)})
|
packed, err = abi.Pack("slice256", []*big.Int{common.Big1, common.Big2})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ func TestMethodPack(t *testing.T) {
|
||||||
t.Errorf("expected %x got %x", sig, packed)
|
t.Errorf("expected %x got %x", sig, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
a := [2][2]*big.Int{{big.NewInt(1), big.NewInt(1)}, {big.NewInt(2), big.NewInt(0)}}
|
a := [2][2]*big.Int{{common.Big1, common.Big1}, {common.Big2, common.Big0}}
|
||||||
sig = abi.Methods["nestedArray"].ID
|
sig = abi.Methods["nestedArray"].ID
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
{
|
{
|
||||||
def: `[{"type": "uint17"}]`,
|
def: `[{"type": "uint17"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: big.NewInt(1),
|
unpacked: common.Big1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "uint32"}]`,
|
def: `[{"type": "uint32"}]`,
|
||||||
|
|
@ -100,12 +100,12 @@ var packUnpackTests = []packUnpackTest{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "uint256"}]`,
|
def: `[{"type": "uint256"}]`,
|
||||||
unpacked: big.NewInt(2),
|
unpacked: common.Big2,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000002",
|
packed: "0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "uint256[]"}]`,
|
def: `[{"type": "uint256[]"}]`,
|
||||||
unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
|
unpacked: []*big.Int{common.Big1, common.Big2},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
|
|
@ -140,7 +140,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
{
|
{
|
||||||
def: `[{"type": "int17"}]`,
|
def: `[{"type": "int17"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: big.NewInt(1),
|
unpacked: common.Big1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "int32"}]`,
|
def: `[{"type": "int32"}]`,
|
||||||
|
|
@ -175,7 +175,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "int256"}]`,
|
def: `[{"type": "int256"}]`,
|
||||||
unpacked: big.NewInt(2),
|
unpacked: common.Big2,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000002",
|
packed: "0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -185,7 +185,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "int256[]"}]`,
|
def: `[{"type": "int256[]"}]`,
|
||||||
unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
|
unpacked: []*big.Int{common.Big1, common.Big2},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
|
|
@ -470,14 +470,14 @@ var packUnpackTests = []packUnpackTest{
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002",
|
"0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
|
unpacked: []*big.Int{common.Big1, common.Big2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "int256[3]"}]`,
|
def: `[{"type": "int256[3]"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000003",
|
"0000000000000000000000000000000000000000000000000000000000000003",
|
||||||
unpacked: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
|
unpacked: [3]*big.Int{common.Big1, common.Big2, common.Big3},
|
||||||
},
|
},
|
||||||
// multi dimensional, if these pass, all types that don't require length prefix should pass
|
// multi dimensional, if these pass, all types that don't require length prefix should pass
|
||||||
{
|
{
|
||||||
|
|
@ -652,14 +652,14 @@ var packUnpackTests = []packUnpackTest{
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002",
|
"0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
|
unpacked: []*big.Int{common.Big1, common.Big2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "uint256[3]"}]`,
|
def: `[{"type": "uint256[3]"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000003",
|
"0000000000000000000000000000000000000000000000000000000000000003",
|
||||||
unpacked: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
|
unpacked: [3]*big.Int{common.Big1, common.Big2, common.Big3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "string[4]"}]`,
|
def: `[{"type": "string[4]"}]`,
|
||||||
|
|
@ -718,7 +718,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
"00000000000000000000000000000000000000000000000000000000000000c8" +
|
"00000000000000000000000000000000000000000000000000000000000000c8" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"00000000000000000000000000000000000000000000000000000000000003e8",
|
"00000000000000000000000000000000000000000000000000000000000003e8",
|
||||||
unpacked: [][][2]*big.Int{{{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}, {{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}},
|
unpacked: [][][2]*big.Int{{{common.Big1, big.NewInt(200)}, {common.Big1, big.NewInt(1000)}}, {{common.Big1, big.NewInt(200)}, {common.Big1, big.NewInt(1000)}}},
|
||||||
},
|
},
|
||||||
// struct outputs
|
// struct outputs
|
||||||
{
|
{
|
||||||
|
|
@ -728,28 +728,28 @@ var packUnpackTests = []packUnpackTest{
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
Int1 *big.Int
|
Int1 *big.Int
|
||||||
Int2 *big.Int
|
Int2 *big.Int
|
||||||
}{big.NewInt(1), big.NewInt(2)},
|
}{common.Big1, common.Big2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"components": [{"name":"int_one","type":"int256"}], "type":"tuple"}]`,
|
def: `[{"components": [{"name":"int_one","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"components": [{"name":"int__one","type":"int256"}], "type":"tuple"}]`,
|
def: `[{"components": [{"name":"int__one","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"components": [{"name":"int_one_","type":"int256"}], "type":"tuple"}]`,
|
def: `[{"components": [{"name":"int_one_","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"components": [{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}], "type":"tuple"}]`,
|
def: `[{"components": [{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}], "type":"tuple"}]`,
|
||||||
|
|
@ -758,7 +758,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
Intone *big.Int
|
Intone *big.Int
|
||||||
}{big.NewInt(1), big.NewInt(2)},
|
}{common.Big1, common.Big2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "string"}]`,
|
def: `[{"type": "string"}]`,
|
||||||
|
|
@ -842,7 +842,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
C *big.Int
|
C *big.Int
|
||||||
D bool
|
D bool
|
||||||
E [2][3][32]byte
|
E [2][3][32]byte
|
||||||
}{1, big.NewInt(1), big.NewInt(-1), true, [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}}},
|
}{1, common.Big1, big.NewInt(-1), true, [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}}},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001" + // struct[a]
|
packed: "0000000000000000000000000000000000000000000000000000000000000001" + // struct[a]
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
||||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // struct[c]
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // struct[c]
|
||||||
|
|
@ -868,7 +868,7 @@ var packUnpackTests = []packUnpackTest{
|
||||||
D []string
|
D []string
|
||||||
E []*big.Int
|
E []*big.Int
|
||||||
F []common.Address
|
F []common.Address
|
||||||
}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{big.NewInt(1), big.NewInt(-1)}, []common.Address{{1}, {2}}},
|
}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{common.Big1, big.NewInt(-1)}, []common.Address{{1}, {2}}},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
||||||
"00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
|
"00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
||||||
|
|
@ -909,8 +909,8 @@ var packUnpackTests = []packUnpackTest{
|
||||||
A: struct {
|
A: struct {
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B []*big.Int
|
B []*big.Int
|
||||||
}{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
}{common.Big1, []*big.Int{common.Big1, common.Big2}},
|
||||||
B: []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
B: []*big.Int{common.Big1, common.Big2}},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
||||||
"0000000000000000000000000000000000000000000000000000000000000040" + // a offset
|
"0000000000000000000000000000000000000000000000000000000000000040" + // a offset
|
||||||
"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
|
"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
|
||||||
|
|
@ -932,8 +932,8 @@ var packUnpackTests = []packUnpackTest{
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B []*big.Int
|
B []*big.Int
|
||||||
}{
|
}{
|
||||||
{big.NewInt(-1), []*big.Int{big.NewInt(1), big.NewInt(3)}},
|
{big.NewInt(-1), []*big.Int{common.Big1, common.Big3}},
|
||||||
{big.NewInt(1), []*big.Int{big.NewInt(2), big.NewInt(-1)}},
|
{common.Big1, []*big.Int{common.Big2, big.NewInt(-1)}},
|
||||||
},
|
},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" + // tuple length
|
"0000000000000000000000000000000000000000000000000000000000000002" + // tuple length
|
||||||
|
|
@ -958,8 +958,8 @@ var packUnpackTests = []packUnpackTest{
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B *big.Int
|
B *big.Int
|
||||||
}{
|
}{
|
||||||
{big.NewInt(-1), big.NewInt(1)},
|
{big.NewInt(-1), common.Big1},
|
||||||
{big.NewInt(1), big.NewInt(-1)},
|
{common.Big1, big.NewInt(-1)},
|
||||||
},
|
},
|
||||||
packed: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].a
|
packed: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].a
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].b
|
"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].b
|
||||||
|
|
@ -972,8 +972,8 @@ var packUnpackTests = []packUnpackTest{
|
||||||
unpacked: [2]struct {
|
unpacked: [2]struct {
|
||||||
A []*big.Int
|
A []*big.Int
|
||||||
}{
|
}{
|
||||||
{[]*big.Int{big.NewInt(-1), big.NewInt(1)}},
|
{[]*big.Int{big.NewInt(-1), common.Big1}},
|
||||||
{[]*big.Int{big.NewInt(1), big.NewInt(-1)}},
|
{[]*big.Int{common.Big1, big.NewInt(-1)}},
|
||||||
},
|
},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
|
"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type reflectTest struct {
|
type reflectTest struct {
|
||||||
|
|
@ -210,52 +212,52 @@ func TestConvertType(t *testing.T) {
|
||||||
Tag: "json:\"" + "y" + "\"",
|
Tag: "json:\"" + "y" + "\"",
|
||||||
})
|
})
|
||||||
val := reflect.New(reflect.StructOf(fields))
|
val := reflect.New(reflect.StructOf(fields))
|
||||||
val.Elem().Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
val.Elem().Field(0).Set(reflect.ValueOf(common.Big1))
|
||||||
val.Elem().Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
val.Elem().Field(1).Set(reflect.ValueOf(common.Big2))
|
||||||
// ConvertType
|
// ConvertType
|
||||||
out := *ConvertType(val.Interface(), new(T)).(*T)
|
out := *ConvertType(val.Interface(), new(T)).(*T)
|
||||||
if out.X.Cmp(big.NewInt(1)) != 0 {
|
if out.X.Cmp(common.Big1) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out.X, big.NewInt(1))
|
t.Errorf("ConvertType failed, got %v want %v", out.X, common.Big1)
|
||||||
}
|
}
|
||||||
if out.Y.Cmp(big.NewInt(2)) != 0 {
|
if out.Y.Cmp(common.Big2) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out.Y, big.NewInt(2))
|
t.Errorf("ConvertType failed, got %v want %v", out.Y, common.Big2)
|
||||||
}
|
}
|
||||||
// Slice Type
|
// Slice Type
|
||||||
val2 := reflect.MakeSlice(reflect.SliceOf(reflect.StructOf(fields)), 2, 2)
|
val2 := reflect.MakeSlice(reflect.SliceOf(reflect.StructOf(fields)), 2, 2)
|
||||||
val2.Index(0).Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
val2.Index(0).Field(0).Set(reflect.ValueOf(common.Big1))
|
||||||
val2.Index(0).Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
val2.Index(0).Field(1).Set(reflect.ValueOf(common.Big2))
|
||||||
val2.Index(1).Field(0).Set(reflect.ValueOf(big.NewInt(3)))
|
val2.Index(1).Field(0).Set(reflect.ValueOf(common.Big3))
|
||||||
val2.Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
val2.Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
||||||
out2 := *ConvertType(val2.Interface(), new([]T)).(*[]T)
|
out2 := *ConvertType(val2.Interface(), new([]T)).(*[]T)
|
||||||
if out2[0].X.Cmp(big.NewInt(1)) != 0 {
|
if out2[0].X.Cmp(common.Big1) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, big.NewInt(1))
|
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, common.Big1)
|
||||||
}
|
}
|
||||||
if out2[0].Y.Cmp(big.NewInt(2)) != 0 {
|
if out2[0].Y.Cmp(common.Big2) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, big.NewInt(2))
|
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, common.Big2)
|
||||||
}
|
}
|
||||||
if out2[1].X.Cmp(big.NewInt(3)) != 0 {
|
if out2[1].X.Cmp(common.Big3) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, big.NewInt(1))
|
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, common.Big1)
|
||||||
}
|
}
|
||||||
if out2[1].Y.Cmp(big.NewInt(4)) != 0 {
|
if out2[1].Y.Cmp(big.NewInt(4)) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, big.NewInt(2))
|
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, common.Big2)
|
||||||
}
|
}
|
||||||
// Array Type
|
// Array Type
|
||||||
val3 := reflect.New(reflect.ArrayOf(2, reflect.StructOf(fields)))
|
val3 := reflect.New(reflect.ArrayOf(2, reflect.StructOf(fields)))
|
||||||
val3.Elem().Index(0).Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
val3.Elem().Index(0).Field(0).Set(reflect.ValueOf(common.Big1))
|
||||||
val3.Elem().Index(0).Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
val3.Elem().Index(0).Field(1).Set(reflect.ValueOf(common.Big2))
|
||||||
val3.Elem().Index(1).Field(0).Set(reflect.ValueOf(big.NewInt(3)))
|
val3.Elem().Index(1).Field(0).Set(reflect.ValueOf(common.Big3))
|
||||||
val3.Elem().Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
val3.Elem().Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
||||||
out3 := *ConvertType(val3.Interface(), new([2]T)).(*[2]T)
|
out3 := *ConvertType(val3.Interface(), new([2]T)).(*[2]T)
|
||||||
if out3[0].X.Cmp(big.NewInt(1)) != 0 {
|
if out3[0].X.Cmp(common.Big1) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, big.NewInt(1))
|
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, common.Big1)
|
||||||
}
|
}
|
||||||
if out3[0].Y.Cmp(big.NewInt(2)) != 0 {
|
if out3[0].Y.Cmp(common.Big2) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, big.NewInt(2))
|
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, common.Big2)
|
||||||
}
|
}
|
||||||
if out3[1].X.Cmp(big.NewInt(3)) != 0 {
|
if out3[1].X.Cmp(common.Big3) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, big.NewInt(1))
|
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, common.Big1)
|
||||||
}
|
}
|
||||||
if out3[1].Y.Cmp(big.NewInt(4)) != 0 {
|
if out3[1].Y.Cmp(big.NewInt(4)) != 0 {
|
||||||
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, big.NewInt(2))
|
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, common.Big2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func TestMakeTopics(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support *big.Int types in topics",
|
"support *big.Int types in topics",
|
||||||
args{[][]interface{}{{big.NewInt(1).Lsh(big.NewInt(2), 254)}}},
|
args{[][]interface{}{{common.Big1.Lsh(common.Big2, 254)}}},
|
||||||
[][]common.Hash{{common.Hash{128}}},
|
[][]common.Hash{{common.Hash{128}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -123,15 +123,15 @@ func TestTypeCheck(t *testing.T) {
|
||||||
input interface{}
|
input interface{}
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
{"uint", nil, big.NewInt(1), "unsupported arg type: uint"},
|
{"uint", nil, common.Big1, "unsupported arg type: uint"},
|
||||||
{"int", nil, big.NewInt(1), "unsupported arg type: int"},
|
{"int", nil, common.Big1, "unsupported arg type: int"},
|
||||||
{"uint256", nil, big.NewInt(1), ""},
|
{"uint256", nil, common.Big1, ""},
|
||||||
{"uint256[][3][]", nil, [][3][]*big.Int{{{}}}, ""},
|
{"uint256[][3][]", nil, [][3][]*big.Int{{{}}}, ""},
|
||||||
{"uint256[][][3]", nil, [3][][]*big.Int{{{}}}, ""},
|
{"uint256[][][3]", nil, [3][][]*big.Int{{{}}}, ""},
|
||||||
{"uint256[3][][]", nil, [][][3]*big.Int{{{}}}, ""},
|
{"uint256[3][][]", nil, [][][3]*big.Int{{{}}}, ""},
|
||||||
{"uint256[3][3][3]", nil, [3][3][3]*big.Int{{{}}}, ""},
|
{"uint256[3][3][3]", nil, [3][3][3]*big.Int{{{}}}, ""},
|
||||||
{"uint8[][]", nil, [][]uint8{}, ""},
|
{"uint8[][]", nil, [][]uint8{}, ""},
|
||||||
{"int256", nil, big.NewInt(1), ""},
|
{"int256", nil, common.Big1, ""},
|
||||||
{"uint8", nil, uint8(1), ""},
|
{"uint8", nil, uint8(1), ""},
|
||||||
{"uint16", nil, uint16(1), ""},
|
{"uint16", nil, uint16(1), ""},
|
||||||
{"uint32", nil, uint32(1), ""},
|
{"uint32", nil, uint32(1), ""},
|
||||||
|
|
@ -140,60 +140,60 @@ func TestTypeCheck(t *testing.T) {
|
||||||
{"int16", nil, int16(1), ""},
|
{"int16", nil, int16(1), ""},
|
||||||
{"int32", nil, int32(1), ""},
|
{"int32", nil, int32(1), ""},
|
||||||
{"int64", nil, int64(1), ""},
|
{"int64", nil, int64(1), ""},
|
||||||
{"uint24", nil, big.NewInt(1), ""},
|
{"uint24", nil, common.Big1, ""},
|
||||||
{"uint40", nil, big.NewInt(1), ""},
|
{"uint40", nil, common.Big1, ""},
|
||||||
{"uint48", nil, big.NewInt(1), ""},
|
{"uint48", nil, common.Big1, ""},
|
||||||
{"uint56", nil, big.NewInt(1), ""},
|
{"uint56", nil, common.Big1, ""},
|
||||||
{"uint72", nil, big.NewInt(1), ""},
|
{"uint72", nil, common.Big1, ""},
|
||||||
{"uint80", nil, big.NewInt(1), ""},
|
{"uint80", nil, common.Big1, ""},
|
||||||
{"uint88", nil, big.NewInt(1), ""},
|
{"uint88", nil, common.Big1, ""},
|
||||||
{"uint96", nil, big.NewInt(1), ""},
|
{"uint96", nil, common.Big1, ""},
|
||||||
{"uint104", nil, big.NewInt(1), ""},
|
{"uint104", nil, common.Big1, ""},
|
||||||
{"uint112", nil, big.NewInt(1), ""},
|
{"uint112", nil, common.Big1, ""},
|
||||||
{"uint120", nil, big.NewInt(1), ""},
|
{"uint120", nil, common.Big1, ""},
|
||||||
{"uint128", nil, big.NewInt(1), ""},
|
{"uint128", nil, common.Big1, ""},
|
||||||
{"uint136", nil, big.NewInt(1), ""},
|
{"uint136", nil, common.Big1, ""},
|
||||||
{"uint144", nil, big.NewInt(1), ""},
|
{"uint144", nil, common.Big1, ""},
|
||||||
{"uint152", nil, big.NewInt(1), ""},
|
{"uint152", nil, common.Big1, ""},
|
||||||
{"uint160", nil, big.NewInt(1), ""},
|
{"uint160", nil, common.Big1, ""},
|
||||||
{"uint168", nil, big.NewInt(1), ""},
|
{"uint168", nil, common.Big1, ""},
|
||||||
{"uint176", nil, big.NewInt(1), ""},
|
{"uint176", nil, common.Big1, ""},
|
||||||
{"uint184", nil, big.NewInt(1), ""},
|
{"uint184", nil, common.Big1, ""},
|
||||||
{"uint192", nil, big.NewInt(1), ""},
|
{"uint192", nil, common.Big1, ""},
|
||||||
{"uint200", nil, big.NewInt(1), ""},
|
{"uint200", nil, common.Big1, ""},
|
||||||
{"uint208", nil, big.NewInt(1), ""},
|
{"uint208", nil, common.Big1, ""},
|
||||||
{"uint216", nil, big.NewInt(1), ""},
|
{"uint216", nil, common.Big1, ""},
|
||||||
{"uint224", nil, big.NewInt(1), ""},
|
{"uint224", nil, common.Big1, ""},
|
||||||
{"uint232", nil, big.NewInt(1), ""},
|
{"uint232", nil, common.Big1, ""},
|
||||||
{"uint240", nil, big.NewInt(1), ""},
|
{"uint240", nil, common.Big1, ""},
|
||||||
{"uint248", nil, big.NewInt(1), ""},
|
{"uint248", nil, common.Big1, ""},
|
||||||
{"int24", nil, big.NewInt(1), ""},
|
{"int24", nil, common.Big1, ""},
|
||||||
{"int40", nil, big.NewInt(1), ""},
|
{"int40", nil, common.Big1, ""},
|
||||||
{"int48", nil, big.NewInt(1), ""},
|
{"int48", nil, common.Big1, ""},
|
||||||
{"int56", nil, big.NewInt(1), ""},
|
{"int56", nil, common.Big1, ""},
|
||||||
{"int72", nil, big.NewInt(1), ""},
|
{"int72", nil, common.Big1, ""},
|
||||||
{"int80", nil, big.NewInt(1), ""},
|
{"int80", nil, common.Big1, ""},
|
||||||
{"int88", nil, big.NewInt(1), ""},
|
{"int88", nil, common.Big1, ""},
|
||||||
{"int96", nil, big.NewInt(1), ""},
|
{"int96", nil, common.Big1, ""},
|
||||||
{"int104", nil, big.NewInt(1), ""},
|
{"int104", nil, common.Big1, ""},
|
||||||
{"int112", nil, big.NewInt(1), ""},
|
{"int112", nil, common.Big1, ""},
|
||||||
{"int120", nil, big.NewInt(1), ""},
|
{"int120", nil, common.Big1, ""},
|
||||||
{"int128", nil, big.NewInt(1), ""},
|
{"int128", nil, common.Big1, ""},
|
||||||
{"int136", nil, big.NewInt(1), ""},
|
{"int136", nil, common.Big1, ""},
|
||||||
{"int144", nil, big.NewInt(1), ""},
|
{"int144", nil, common.Big1, ""},
|
||||||
{"int152", nil, big.NewInt(1), ""},
|
{"int152", nil, common.Big1, ""},
|
||||||
{"int160", nil, big.NewInt(1), ""},
|
{"int160", nil, common.Big1, ""},
|
||||||
{"int168", nil, big.NewInt(1), ""},
|
{"int168", nil, common.Big1, ""},
|
||||||
{"int176", nil, big.NewInt(1), ""},
|
{"int176", nil, common.Big1, ""},
|
||||||
{"int184", nil, big.NewInt(1), ""},
|
{"int184", nil, common.Big1, ""},
|
||||||
{"int192", nil, big.NewInt(1), ""},
|
{"int192", nil, common.Big1, ""},
|
||||||
{"int200", nil, big.NewInt(1), ""},
|
{"int200", nil, common.Big1, ""},
|
||||||
{"int208", nil, big.NewInt(1), ""},
|
{"int208", nil, common.Big1, ""},
|
||||||
{"int216", nil, big.NewInt(1), ""},
|
{"int216", nil, common.Big1, ""},
|
||||||
{"int224", nil, big.NewInt(1), ""},
|
{"int224", nil, common.Big1, ""},
|
||||||
{"int232", nil, big.NewInt(1), ""},
|
{"int232", nil, common.Big1, ""},
|
||||||
{"int240", nil, big.NewInt(1), ""},
|
{"int240", nil, common.Big1, ""},
|
||||||
{"int248", nil, big.NewInt(1), ""},
|
{"int248", nil, common.Big1, ""},
|
||||||
{"uint30", nil, uint8(1), "abi: cannot use uint8 as type ptr as argument"},
|
{"uint30", nil, uint8(1), "abi: cannot use uint8 as type ptr as argument"},
|
||||||
{"uint8", nil, uint16(1), "abi: cannot use uint16 as type uint8 as argument"},
|
{"uint8", nil, uint16(1), "abi: cannot use uint16 as type uint8 as argument"},
|
||||||
{"uint8", nil, uint32(1), "abi: cannot use uint32 as type uint8 as argument"},
|
{"uint8", nil, uint32(1), "abi: cannot use uint32 as type uint8 as argument"},
|
||||||
|
|
@ -279,7 +279,7 @@ func TestTypeCheck(t *testing.T) {
|
||||||
{"tuple[2]", []ArgumentMarshaling{{Name: "a", Type: "uint256"}, {Name: "b", Type: "uint256"}}, []struct {
|
{"tuple[2]", []ArgumentMarshaling{{Name: "a", Type: "uint256"}, {Name: "b", Type: "uint256"}}, []struct {
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B *big.Int
|
B *big.Int
|
||||||
}{{big.NewInt(0), big.NewInt(0)}, {big.NewInt(0), big.NewInt(0)}}, ""},
|
}{{common.Big0, common.Big0}, {common.Big0, common.Big0}}, ""},
|
||||||
} {
|
} {
|
||||||
typ, err := NewType(test.typ, "", test.components)
|
typ, err := NewType(test.typ, "", test.components)
|
||||||
if err != nil && len(test.err) == 0 {
|
if err != nil && len(test.err) == 0 {
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ var unpackTests = []unpackTest{
|
||||||
want: struct {
|
want: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
Intone *big.Int
|
Intone *big.Int
|
||||||
}{IntOne: big.NewInt(1)},
|
}{IntOne: common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int_one","type":"int256"},{"name":"IntOne","type":"int256"}]`,
|
def: `[{"name":"int_one","type":"int256"},{"name":"IntOne","type":"int256"}]`,
|
||||||
|
|
@ -186,21 +186,21 @@ var unpackTests = []unpackTest{
|
||||||
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
||||||
want: struct {
|
want: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int__one","type":"int256"}]`,
|
def: `[{"name":"int__one","type":"int256"}]`,
|
||||||
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
||||||
want: struct {
|
want: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int_one_","type":"int256"}]`,
|
def: `[{"name":"int_one_","type":"int256"}]`,
|
||||||
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
|
||||||
want: struct {
|
want: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{common.Big1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type":"bool"}]`,
|
def: `[{"type":"bool"}]`,
|
||||||
|
|
@ -307,7 +307,7 @@ type methodMultiOutput struct {
|
||||||
func methodMultiReturn(require *require.Assertions) (ABI, []byte, methodMultiOutput) {
|
func methodMultiReturn(require *require.Assertions) (ABI, []byte, methodMultiOutput) {
|
||||||
const definition = `[
|
const definition = `[
|
||||||
{ "name" : "multi", "type": "function", "outputs": [ { "name": "Int", "type": "uint256" }, { "name": "String", "type": "string" } ] }]`
|
{ "name" : "multi", "type": "function", "outputs": [ { "name": "Int", "type": "uint256" }, { "name": "String", "type": "string" } ] }]`
|
||||||
var expected = methodMultiOutput{big.NewInt(1), "hello"}
|
var expected = methodMultiOutput{common.Big1, "hello"}
|
||||||
|
|
||||||
abi, err := JSON(strings.NewReader(definition))
|
abi, err := JSON(strings.NewReader(definition))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
@ -572,7 +572,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Int == nil || Int.Cmp(big.NewInt(1)) != 0 {
|
if Int == nil || Int.Cmp(common.Big1) != 0 {
|
||||||
t.Error("expected Int to be 1 got", Int)
|
t.Error("expected Int to be 1 got", Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -696,9 +696,9 @@ func TestUnmarshal(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
var testAgainstIntArray [3]*big.Int
|
var testAgainstIntArray [3]*big.Int
|
||||||
testAgainstIntArray[0] = big.NewInt(1)
|
testAgainstIntArray[0] = common.Big1
|
||||||
testAgainstIntArray[1] = big.NewInt(2)
|
testAgainstIntArray[1] = common.Big2
|
||||||
testAgainstIntArray[2] = big.NewInt(3)
|
testAgainstIntArray[2] = common.Big3
|
||||||
|
|
||||||
for i, Int := range intArray {
|
for i, Int := range intArray {
|
||||||
if Int.Cmp(testAgainstIntArray[i]) != 0 {
|
if Int.Cmp(testAgainstIntArray[i]) != 0 {
|
||||||
|
|
@ -798,7 +798,7 @@ func TestUnpackTuple(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else {
|
} else {
|
||||||
if ret0.Result.A.Cmp(big.NewInt(1)) != 0 {
|
if ret0.Result.A.Cmp(common.Big1) != 0 {
|
||||||
t.Errorf("unexpected value unpacked: want %x, got %x", 1, ret0.Result.A)
|
t.Errorf("unexpected value unpacked: want %x, got %x", 1, ret0.Result.A)
|
||||||
}
|
}
|
||||||
if ret0.Result.B.Cmp(big.NewInt(-1)) != 0 {
|
if ret0.Result.B.Cmp(big.NewInt(-1)) != 0 {
|
||||||
|
|
@ -853,17 +853,17 @@ func TestUnpackTuple(t *testing.T) {
|
||||||
var ret Ret
|
var ret Ret
|
||||||
var expected = Ret{
|
var expected = Ret{
|
||||||
FieldS: S{
|
FieldS: S{
|
||||||
A: big.NewInt(1),
|
A: common.Big1,
|
||||||
B: []*big.Int{big.NewInt(1), big.NewInt(2)},
|
B: []*big.Int{common.Big1, common.Big2},
|
||||||
C: []T{
|
C: []T{
|
||||||
{big.NewInt(1), big.NewInt(2)},
|
{common.Big1, common.Big2},
|
||||||
{big.NewInt(2), big.NewInt(1)},
|
{common.Big2, common.Big1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
FieldT: T{
|
FieldT: T{
|
||||||
big.NewInt(0), big.NewInt(1),
|
common.Big0, common.Big1,
|
||||||
},
|
},
|
||||||
A: big.NewInt(1),
|
A: common.Big1,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = abi.UnpackIntoInterface(&ret, "tuple", buff.Bytes())
|
err = abi.UnpackIntoInterface(&ret, "tuple", buff.Bytes())
|
||||||
|
|
@ -959,7 +959,7 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("bug")
|
panic("bug")
|
||||||
}
|
}
|
||||||
maxU64Plus1 := new(big.Int).Add(maxU64, big.NewInt(1))
|
maxU64Plus1 := new(big.Int).Add(maxU64, common.Big1)
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
decodeType string
|
decodeType string
|
||||||
inputValue *big.Int
|
inputValue *big.Int
|
||||||
|
|
@ -1066,12 +1066,12 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
decodeType: "int64",
|
decodeType: "int64",
|
||||||
inputValue: new(big.Int).Add(big.NewInt(math.MaxInt64), big.NewInt(1)),
|
inputValue: new(big.Int).Add(big.NewInt(math.MaxInt64), common.Big1),
|
||||||
err: errBadInt64,
|
err: errBadInt64,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
decodeType: "int64",
|
decodeType: "int64",
|
||||||
inputValue: new(big.Int).Sub(big.NewInt(math.MinInt64), big.NewInt(1)),
|
inputValue: new(big.Int).Sub(big.NewInt(math.MinInt64), common.Big1),
|
||||||
err: errBadInt64,
|
err: errBadInt64,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, common.Big0, common.Big0}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package ethtest
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -369,7 +368,7 @@ func generateTxs(s *Suite, numTxs int) (map[common.Hash]common.Hash, []*types.Tr
|
||||||
|
|
||||||
func generateTx(chainConfig *params.ChainConfig, nonce uint64, gas uint64) *types.Transaction {
|
func generateTx(chainConfig *params.ChainConfig, nonce uint64, gas uint64) *types.Transaction {
|
||||||
var to common.Address
|
var to common.Address
|
||||||
tx := types.NewTransaction(nonce, to, big.NewInt(1), gas, big.NewInt(1), []byte{})
|
tx := types.NewTransaction(nonce, to, common.Big1, gas, common.Big1, []byte{})
|
||||||
return signWithFaucet(chainConfig, tx)
|
return signWithFaucet(chainConfig, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
var (
|
var (
|
||||||
blockReward = big.NewInt(miningReward)
|
blockReward = big.NewInt(miningReward)
|
||||||
minerReward = new(big.Int).Set(blockReward)
|
minerReward = new(big.Int).Set(blockReward)
|
||||||
perOmmer = new(big.Int).Div(blockReward, big.NewInt(32))
|
perOmmer = new(big.Int).Div(blockReward, common.Big32)
|
||||||
)
|
)
|
||||||
for _, ommer := range pre.Env.Ommers {
|
for _, ommer := range pre.Env.Ommers {
|
||||||
// Add 1/32th for each ommer included
|
// Add 1/32th for each ommer included
|
||||||
|
|
|
||||||
|
|
@ -1810,7 +1810,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
chaindb.Close()
|
chaindb.Close()
|
||||||
}
|
}
|
||||||
if !ctx.IsSet(MinerGasPriceFlag.Name) {
|
if !ctx.IsSet(MinerGasPriceFlag.Name) {
|
||||||
cfg.Miner.GasPrice = big.NewInt(1)
|
cfg.Miner.GasPrice = common.Big1
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if cfg.NetworkId == 1 {
|
if cfg.NetworkId == 1 {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package math
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -26,10 +27,10 @@ import (
|
||||||
var (
|
var (
|
||||||
tt255 = BigPow(2, 255)
|
tt255 = BigPow(2, 255)
|
||||||
tt256 = BigPow(2, 256)
|
tt256 = BigPow(2, 256)
|
||||||
tt256m1 = new(big.Int).Sub(tt256, big.NewInt(1))
|
tt256m1 = new(big.Int).Sub(tt256, common.Big1)
|
||||||
tt63 = BigPow(2, 63)
|
tt63 = BigPow(2, 63)
|
||||||
MaxBig256 = new(big.Int).Set(tt256m1)
|
MaxBig256 = new(big.Int).Set(tt256m1)
|
||||||
MaxBig63 = new(big.Int).Sub(tt63, big.NewInt(1))
|
MaxBig63 = new(big.Int).Sub(tt63, common.Big1)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -255,7 +256,7 @@ func S256(x *big.Int) *big.Int {
|
||||||
//
|
//
|
||||||
// Courtesy @karalabe and @chfast
|
// Courtesy @karalabe and @chfast
|
||||||
func Exp(base, exponent *big.Int) *big.Int {
|
func Exp(base, exponent *big.Int) *big.Int {
|
||||||
result := big.NewInt(1)
|
result := common.Big1
|
||||||
|
|
||||||
for _, word := range exponent.Bits() {
|
for _, word := range exponent.Bits() {
|
||||||
for i := 0; i < wordBits; i++ {
|
for i := 0; i < wordBits; i++ {
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,16 @@ func TestHexOrDecimal256(t *testing.T) {
|
||||||
num *big.Int
|
num *big.Int
|
||||||
ok bool
|
ok bool
|
||||||
}{
|
}{
|
||||||
{"", big.NewInt(0), true},
|
{"", common.Big0, true},
|
||||||
{"0", big.NewInt(0), true},
|
{"0", common.Big0, true},
|
||||||
{"0x0", big.NewInt(0), true},
|
{"0x0", common.Big0, true},
|
||||||
{"12345678", big.NewInt(12345678), true},
|
{"12345678", big.NewInt(12345678), true},
|
||||||
{"0x12345678", big.NewInt(0x12345678), true},
|
{"0x12345678", big.NewInt(0x12345678), true},
|
||||||
{"0X12345678", big.NewInt(0x12345678), true},
|
{"0X12345678", big.NewInt(0x12345678), true},
|
||||||
// Tests for leading zero behaviour:
|
// Tests for leading zero behaviour:
|
||||||
{"0123456789", big.NewInt(123456789), true}, // note: not octal
|
{"0123456789", big.NewInt(123456789), true}, // note: not octal
|
||||||
{"00", big.NewInt(0), true},
|
{"00", common.Big0, true},
|
||||||
{"0x00", big.NewInt(0), true},
|
{"0x00", common.Big0, true},
|
||||||
{"0x012345678abc", big.NewInt(0x12345678abc), true},
|
{"0x012345678abc", big.NewInt(0x12345678abc), true},
|
||||||
// Invalid syntax:
|
// Invalid syntax:
|
||||||
{"abcdef", nil, false},
|
{"abcdef", nil, false},
|
||||||
|
|
@ -105,9 +105,9 @@ func TestFirstBigSet(t *testing.T) {
|
||||||
num *big.Int
|
num *big.Int
|
||||||
ix int
|
ix int
|
||||||
}{
|
}{
|
||||||
{big.NewInt(0), 0},
|
{common.Big0, 0},
|
||||||
{big.NewInt(1), 0},
|
{common.Big1, 0},
|
||||||
{big.NewInt(2), 1},
|
{common.Big2, 1},
|
||||||
{big.NewInt(0x100), 8},
|
{big.NewInt(0x100), 8},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
@ -123,8 +123,8 @@ func TestPaddedBigBytes(t *testing.T) {
|
||||||
n int
|
n int
|
||||||
result []byte
|
result []byte
|
||||||
}{
|
}{
|
||||||
{num: big.NewInt(0), n: 4, result: []byte{0, 0, 0, 0}},
|
{num: common.Big0, n: 4, result: []byte{0, 0, 0, 0}},
|
||||||
{num: big.NewInt(1), n: 4, result: []byte{0, 0, 0, 1}},
|
{num: common.Big1, n: 4, result: []byte{0, 0, 0, 1}},
|
||||||
{num: big.NewInt(512), n: 4, result: []byte{0, 0, 2, 0}},
|
{num: big.NewInt(512), n: 4, result: []byte{0, 0, 2, 0}},
|
||||||
{num: BigPow(2, 32), n: 4, result: []byte{1, 0, 0, 0, 0}},
|
{num: BigPow(2, 32), n: 4, result: []byte{1, 0, 0, 0, 0}},
|
||||||
}
|
}
|
||||||
|
|
@ -194,15 +194,15 @@ func TestReadBits(t *testing.T) {
|
||||||
|
|
||||||
func TestU256(t *testing.T) {
|
func TestU256(t *testing.T) {
|
||||||
tests := []struct{ x, y *big.Int }{
|
tests := []struct{ x, y *big.Int }{
|
||||||
{x: big.NewInt(0), y: big.NewInt(0)},
|
{x: common.Big0, y: common.Big0},
|
||||||
{x: big.NewInt(1), y: big.NewInt(1)},
|
{x: common.Big1, y: common.Big1},
|
||||||
{x: BigPow(2, 255), y: BigPow(2, 255)},
|
{x: BigPow(2, 255), y: BigPow(2, 255)},
|
||||||
{x: BigPow(2, 256), y: big.NewInt(0)},
|
{x: BigPow(2, 256), y: common.Big0},
|
||||||
{x: new(big.Int).Add(BigPow(2, 256), big.NewInt(1)), y: big.NewInt(1)},
|
{x: new(big.Int).Add(BigPow(2, 256), common.Big1), y: common.Big1},
|
||||||
// negative values
|
// negative values
|
||||||
{x: big.NewInt(-1), y: new(big.Int).Sub(BigPow(2, 256), big.NewInt(1))},
|
{x: big.NewInt(-1), y: new(big.Int).Sub(BigPow(2, 256), common.Big1)},
|
||||||
{x: big.NewInt(-2), y: new(big.Int).Sub(BigPow(2, 256), big.NewInt(2))},
|
{x: big.NewInt(-2), y: new(big.Int).Sub(BigPow(2, 256), common.Big2)},
|
||||||
{x: BigPow(2, -255), y: big.NewInt(1)},
|
{x: BigPow(2, -255), y: common.Big1},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if y := U256(new(big.Int).Set(test.x)); y.Cmp(test.y) != 0 {
|
if y := U256(new(big.Int).Set(test.x)); y.Cmp(test.y) != 0 {
|
||||||
|
|
@ -215,7 +215,7 @@ func TestU256Bytes(t *testing.T) {
|
||||||
ubytes := make([]byte, 32)
|
ubytes := make([]byte, 32)
|
||||||
ubytes[31] = 1
|
ubytes[31] = 1
|
||||||
|
|
||||||
unsigned := U256Bytes(big.NewInt(1))
|
unsigned := U256Bytes(common.Big1)
|
||||||
if !bytes.Equal(unsigned, ubytes) {
|
if !bytes.Equal(unsigned, ubytes) {
|
||||||
t.Errorf("expected %x got %x", ubytes, unsigned)
|
t.Errorf("expected %x got %x", ubytes, unsigned)
|
||||||
}
|
}
|
||||||
|
|
@ -280,23 +280,23 @@ func TestLittleEndianByteAt(t *testing.T) {
|
||||||
|
|
||||||
func TestS256(t *testing.T) {
|
func TestS256(t *testing.T) {
|
||||||
tests := []struct{ x, y *big.Int }{
|
tests := []struct{ x, y *big.Int }{
|
||||||
{x: big.NewInt(0), y: big.NewInt(0)},
|
{x: common.Big0, y: common.Big0},
|
||||||
{x: big.NewInt(1), y: big.NewInt(1)},
|
{x: common.Big1, y: common.Big1},
|
||||||
{x: big.NewInt(2), y: big.NewInt(2)},
|
{x: common.Big2, y: common.Big2},
|
||||||
{
|
{
|
||||||
x: new(big.Int).Sub(BigPow(2, 255), big.NewInt(1)),
|
x: new(big.Int).Sub(BigPow(2, 255), common.Big1),
|
||||||
y: new(big.Int).Sub(BigPow(2, 255), big.NewInt(1)),
|
y: new(big.Int).Sub(BigPow(2, 255), common.Big1),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: BigPow(2, 255),
|
x: BigPow(2, 255),
|
||||||
y: new(big.Int).Neg(BigPow(2, 255)),
|
y: new(big.Int).Neg(BigPow(2, 255)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: new(big.Int).Sub(BigPow(2, 256), big.NewInt(1)),
|
x: new(big.Int).Sub(BigPow(2, 256), common.Big1),
|
||||||
y: big.NewInt(-1),
|
y: big.NewInt(-1),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: new(big.Int).Sub(BigPow(2, 256), big.NewInt(2)),
|
x: new(big.Int).Sub(BigPow(2, 256), common.Big2),
|
||||||
y: big.NewInt(-2),
|
y: big.NewInt(-2),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -309,12 +309,12 @@ func TestS256(t *testing.T) {
|
||||||
|
|
||||||
func TestExp(t *testing.T) {
|
func TestExp(t *testing.T) {
|
||||||
tests := []struct{ base, exponent, result *big.Int }{
|
tests := []struct{ base, exponent, result *big.Int }{
|
||||||
{base: big.NewInt(0), exponent: big.NewInt(0), result: big.NewInt(1)},
|
{base: common.Big0, exponent: common.Big0, result: common.Big1},
|
||||||
{base: big.NewInt(1), exponent: big.NewInt(0), result: big.NewInt(1)},
|
{base: common.Big1, exponent: common.Big0, result: common.Big1},
|
||||||
{base: big.NewInt(1), exponent: big.NewInt(1), result: big.NewInt(1)},
|
{base: common.Big1, exponent: common.Big1, result: common.Big1},
|
||||||
{base: big.NewInt(1), exponent: big.NewInt(2), result: big.NewInt(1)},
|
{base: common.Big1, exponent: common.Big2, result: common.Big1},
|
||||||
{base: big.NewInt(3), exponent: big.NewInt(144), result: MustParseBig256("507528786056415600719754159741696356908742250191663887263627442114881")},
|
{base: common.Big3, exponent: big.NewInt(144), result: MustParseBig256("507528786056415600719754159741696356908742250191663887263627442114881")},
|
||||||
{base: big.NewInt(2), exponent: big.NewInt(255), result: MustParseBig256("57896044618658097711785492504343953926634992332820282019728792003956564819968")},
|
{base: common.Big2, exponent: big.NewInt(255), result: MustParseBig256("57896044618658097711785492504343953926634992332820282019728792003956564819968")},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if result := Exp(test.base, test.exponent); result.Cmp(test.result) != 0 {
|
if result := Exp(test.base, test.exponent); result.Cmp(test.result) != 0 {
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ var (
|
||||||
|
|
||||||
uncleHash = types.CalcUncleHash(nil) // Always Keccak256(RLP([])) as uncles are meaningless outside of PoW.
|
uncleHash = types.CalcUncleHash(nil) // Always Keccak256(RLP([])) as uncles are meaningless outside of PoW.
|
||||||
|
|
||||||
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
|
diffInTurn = common.Big2 // Block difficulty for in-turn signatures
|
||||||
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
|
diffNoTurn = common.Big1 // Block difficulty for out-of-turn signatures
|
||||||
)
|
)
|
||||||
|
|
||||||
// Various error messages to mark blocks invalid. These should be private to
|
// Various error messages to mark blocks invalid. These should be private to
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Verify that the block number is parent's +1
|
// Verify that the block number is parent's +1
|
||||||
if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 {
|
if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(common.Big1) != 0 {
|
||||||
return consensus.ErrInvalidNumber
|
return consensus.ErrInvalidNumber
|
||||||
}
|
}
|
||||||
if chain.Config().IsShanghai(header.Number, header.Time) {
|
if chain.Config().IsShanghai(header.Number, header.Time) {
|
||||||
|
|
@ -318,8 +318,8 @@ func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Heade
|
||||||
// Some weird constants to avoid constant memory allocs for them.
|
// Some weird constants to avoid constant memory allocs for them.
|
||||||
var (
|
var (
|
||||||
expDiffPeriod = big.NewInt(100000)
|
expDiffPeriod = big.NewInt(100000)
|
||||||
big1 = big.NewInt(1)
|
big1 = common.Big1
|
||||||
big2 = big.NewInt(2)
|
big2 = common.Big2
|
||||||
big9 = big.NewInt(9)
|
big9 = big.NewInt(9)
|
||||||
big10 = big.NewInt(10)
|
big10 = big.NewInt(10)
|
||||||
bigMinus99 = big.NewInt(-99)
|
bigMinus99 = big.NewInt(-99)
|
||||||
|
|
@ -541,7 +541,7 @@ func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
|
||||||
// Some weird constants to avoid constant memory allocs for them.
|
// Some weird constants to avoid constant memory allocs for them.
|
||||||
var (
|
var (
|
||||||
big8 = big.NewInt(8)
|
big8 = big.NewInt(8)
|
||||||
big32 = big.NewInt(32)
|
big32 = common.Big32
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccumulateRewards credits the coinbase of the given block with the mining
|
// AccumulateRewards credits the coinbase of the given block with the mining
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ func TestCalcDifficulty(t *testing.T) {
|
||||||
config := ¶ms.ChainConfig{HomesteadBlock: big.NewInt(1150000)}
|
config := ¶ms.ChainConfig{HomesteadBlock: big.NewInt(1150000)}
|
||||||
|
|
||||||
for name, test := range tests {
|
for name, test := range tests {
|
||||||
number := new(big.Int).Sub(test.CurrentBlocknumber, big.NewInt(1))
|
number := new(big.Int).Sub(test.CurrentBlocknumber, common.Big1)
|
||||||
diff := CalcDifficulty(config, test.CurrentTimestamp, &types.Header{
|
diff := CalcDifficulty(config, test.CurrentTimestamp, &types.Header{
|
||||||
Number: number,
|
Number: number,
|
||||||
Time: test.ParentTimestamp,
|
Time: test.ParentTimestamp,
|
||||||
|
|
|
||||||
|
|
@ -85,14 +85,14 @@ func genValueTx(nbytes int) func(int, *BlockGen) {
|
||||||
data := make([]byte, nbytes)
|
data := make([]byte, nbytes)
|
||||||
gas, _ := IntrinsicGas(data, nil, false, false, false, false)
|
gas, _ := IntrinsicGas(data, nil, false, false, false, false)
|
||||||
signer := gen.Signer()
|
signer := gen.Signer()
|
||||||
gasPrice := big.NewInt(0)
|
gasPrice := common.Big0
|
||||||
if gen.header.BaseFee != nil {
|
if gen.header.BaseFee != nil {
|
||||||
gasPrice = gen.header.BaseFee
|
gasPrice = gen.header.BaseFee
|
||||||
}
|
}
|
||||||
tx, _ := types.SignNewTx(benchRootKey, signer, &types.LegacyTx{
|
tx, _ := types.SignNewTx(benchRootKey, signer, &types.LegacyTx{
|
||||||
Nonce: gen.TxNonce(benchRootAddr),
|
Nonce: gen.TxNonce(benchRootAddr),
|
||||||
To: &toaddr,
|
To: &toaddr,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Gas: gas,
|
Gas: gas,
|
||||||
Data: data,
|
Data: data,
|
||||||
GasPrice: gasPrice,
|
GasPrice: gasPrice,
|
||||||
|
|
@ -124,7 +124,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) {
|
||||||
return func(i int, gen *BlockGen) {
|
return func(i int, gen *BlockGen) {
|
||||||
block := gen.PrevBlock(i - 1)
|
block := gen.PrevBlock(i - 1)
|
||||||
gas := block.GasLimit()
|
gas := block.GasLimit()
|
||||||
gasPrice := big.NewInt(0)
|
gasPrice := common.Big0
|
||||||
if gen.header.BaseFee != nil {
|
if gen.header.BaseFee != nil {
|
||||||
gasPrice = gen.header.BaseFee
|
gasPrice = gen.header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) {
|
||||||
burn := new(big.Int).SetUint64(params.TxGas)
|
burn := new(big.Int).SetUint64(params.TxGas)
|
||||||
burn.Mul(burn, gen.header.BaseFee)
|
burn.Mul(burn, gen.header.BaseFee)
|
||||||
availableFunds.Sub(availableFunds, burn)
|
availableFunds.Sub(availableFunds, burn)
|
||||||
if availableFunds.Cmp(big.NewInt(1)) < 0 {
|
if availableFunds.Cmp(common.Big1) < 0 {
|
||||||
panic("not enough funds")
|
panic("not enough funds")
|
||||||
}
|
}
|
||||||
tx, err := types.SignNewTx(ringKeys[from], signer,
|
tx, err := types.SignNewTx(ringKeys[from], signer,
|
||||||
|
|
@ -250,7 +250,7 @@ func makeChainForBench(db ethdb.Database, full bool, count uint64) {
|
||||||
Coinbase: common.Address{},
|
Coinbase: common.Address{},
|
||||||
Number: big.NewInt(int64(n)),
|
Number: big.NewInt(int64(n)),
|
||||||
ParentHash: hash,
|
ParentHash: hash,
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: common.Big1,
|
||||||
UncleHash: types.EmptyUncleHash,
|
UncleHash: types.EmptyUncleHash,
|
||||||
TxHash: types.EmptyTxsHash,
|
TxHash: types.EmptyTxsHash,
|
||||||
ReceiptHash: types.EmptyReceiptsHash,
|
ReceiptHash: types.EmptyReceiptsHash,
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
|
||||||
Config: &config,
|
Config: &config,
|
||||||
ExtraData: make([]byte, 32+common.AddressLength+crypto.SignatureLength),
|
ExtraData: make([]byte, 32+common.AddressLength+crypto.SignatureLength),
|
||||||
Alloc: map[common.Address]GenesisAccount{
|
Alloc: map[common.Address]GenesisAccount{
|
||||||
addr: {Balance: big.NewInt(1)},
|
addr: {Balance: common.Big1},
|
||||||
},
|
},
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Difficulty: new(big.Int),
|
Difficulty: new(big.Int),
|
||||||
|
|
@ -122,7 +122,7 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
|
||||||
header.ParentHash = blocks[i-1].Hash()
|
header.ParentHash = blocks[i-1].Hash()
|
||||||
}
|
}
|
||||||
header.Extra = make([]byte, 32+crypto.SignatureLength)
|
header.Extra = make([]byte, 32+crypto.SignatureLength)
|
||||||
header.Difficulty = big.NewInt(2)
|
header.Difficulty = common.Big2
|
||||||
|
|
||||||
sig, _ := crypto.Sign(engine.SealHash(header).Bytes(), key)
|
sig, _ := crypto.Sign(engine.SealHash(header).Bytes(), key)
|
||||||
copy(header.Extra[len(header.Extra)-crypto.SignatureLength:], sig)
|
copy(header.Extra[len(header.Extra)-crypto.SignatureLength:], sig)
|
||||||
|
|
|
||||||
|
|
@ -1580,9 +1580,9 @@ func testEIP155Transition(t *testing.T, scheme string) {
|
||||||
deleteAddr = common.Address{1}
|
deleteAddr = common.Address{1}
|
||||||
gspec = &Genesis{
|
gspec = &Genesis{
|
||||||
Config: ¶ms.ChainConfig{
|
Config: ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(2),
|
EIP155Block: common.Big2,
|
||||||
HomesteadBlock: new(big.Int),
|
HomesteadBlock: new(big.Int),
|
||||||
},
|
},
|
||||||
Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}},
|
Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}},
|
||||||
|
|
@ -1654,9 +1654,9 @@ func testEIP155Transition(t *testing.T, scheme string) {
|
||||||
|
|
||||||
// generate an invalid chain id transaction
|
// generate an invalid chain id transaction
|
||||||
config := ¶ms.ChainConfig{
|
config := ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(2),
|
ChainID: common.Big2,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(2),
|
EIP155Block: common.Big2,
|
||||||
HomesteadBlock: new(big.Int),
|
HomesteadBlock: new(big.Int),
|
||||||
}
|
}
|
||||||
blocks, _ = GenerateChain(config, blocks[len(blocks)-1], ethash.NewFaker(), genDb, 4, func(i int, block *BlockGen) {
|
blocks, _ = GenerateChain(config, blocks[len(blocks)-1], ethash.NewFaker(), genDb, 4, func(i int, block *BlockGen) {
|
||||||
|
|
@ -1694,11 +1694,11 @@ func testEIP161AccountRemoval(t *testing.T, scheme string) {
|
||||||
theAddr = common.Address{1}
|
theAddr = common.Address{1}
|
||||||
gspec = &Genesis{
|
gspec = &Genesis{
|
||||||
Config: ¶ms.ChainConfig{
|
Config: ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: new(big.Int),
|
HomesteadBlock: new(big.Int),
|
||||||
EIP155Block: new(big.Int),
|
EIP155Block: new(big.Int),
|
||||||
EIP150Block: new(big.Int),
|
EIP150Block: new(big.Int),
|
||||||
EIP158Block: big.NewInt(2),
|
EIP158Block: common.Big2,
|
||||||
},
|
},
|
||||||
Alloc: GenesisAlloc{address: {Balance: funds}},
|
Alloc: GenesisAlloc{address: {Balance: funds}},
|
||||||
}
|
}
|
||||||
|
|
@ -2156,7 +2156,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
|
||||||
merger.FinalizePoS()
|
merger.FinalizePoS()
|
||||||
|
|
||||||
// Set the terminal total difficulty in the config
|
// Set the terminal total difficulty in the config
|
||||||
gspec.Config.TerminalTotalDifficulty = big.NewInt(0)
|
gspec.Config.TerminalTotalDifficulty = common.Big0
|
||||||
}
|
}
|
||||||
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2*TriesInMemory, func(i int, gen *BlockGen) {
|
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2*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)
|
tx, err := types.SignTx(types.NewTransaction(nonce, common.HexToAddress("deadbeef"), big.NewInt(100), 21000, big.NewInt(int64(i+1)*params.GWei), nil), signer, key)
|
||||||
|
|
@ -2431,7 +2431,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
)
|
)
|
||||||
// Apply merging since genesis
|
// Apply merging since genesis
|
||||||
if mergeHeight == 0 {
|
if mergeHeight == 0 {
|
||||||
genesis.Config.TerminalTotalDifficulty = big.NewInt(0)
|
genesis.Config.TerminalTotalDifficulty = common.Big0
|
||||||
mergeBlock = uint64(0)
|
mergeBlock = uint64(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2781,7 +2781,7 @@ func TestTransactionIndices(t *testing.T) {
|
||||||
for _, l := range limit {
|
for _, l := range limit {
|
||||||
frdir := t.TempDir()
|
frdir := t.TempDir()
|
||||||
ancientDb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false)
|
ancientDb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false)
|
||||||
rawdb.WriteAncientBlocks(ancientDb, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
rawdb.WriteAncientBlocks(ancientDb, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), common.Big0)
|
||||||
|
|
||||||
l := l
|
l := l
|
||||||
chain, err := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l)
|
chain, err := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l)
|
||||||
|
|
@ -2804,7 +2804,7 @@ func TestTransactionIndices(t *testing.T) {
|
||||||
ancientDb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
|
ancientDb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
|
||||||
defer ancientDb.Close()
|
defer ancientDb.Close()
|
||||||
|
|
||||||
rawdb.WriteAncientBlocks(ancientDb, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
rawdb.WriteAncientBlocks(ancientDb, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), common.Big0)
|
||||||
limit = []uint64{0, 64 /* drop stale */, 32 /* shorten history */, 64 /* extend history */, 0 /* restore all */}
|
limit = []uint64{0, 64 /* drop stale */, 32 /* shorten history */, 64 /* extend history */, 0 /* restore all */}
|
||||||
for _, l := range limit {
|
for _, l := range limit {
|
||||||
l := l
|
l := l
|
||||||
|
|
@ -2920,7 +2920,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in
|
||||||
testBankAddress: {Balance: bankFunds},
|
testBankAddress: {Balance: bankFunds},
|
||||||
common.HexToAddress("0xc0de"): {
|
common.HexToAddress("0xc0de"): {
|
||||||
Code: []byte{0x60, 0x01, 0x50},
|
Code: []byte{0x60, 0x01, 0x50},
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
}, // push 1, pop
|
}, // push 1, pop
|
||||||
},
|
},
|
||||||
GasLimit: 100e6, // 100 M
|
GasLimit: 100e6, // 100 M
|
||||||
|
|
@ -2934,7 +2934,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in
|
||||||
for txi := 0; txi < numTxs; txi++ {
|
for txi := 0; txi < numTxs; txi++ {
|
||||||
uniq := uint64(i*numTxs + txi)
|
uniq := uint64(i*numTxs + txi)
|
||||||
recipient := recipientFn(uniq)
|
recipient := recipientFn(uniq)
|
||||||
tx, err := types.SignTx(types.NewTransaction(uniq, recipient, big.NewInt(1), params.TxGas, block.header.BaseFee, nil), signer, testBankKey)
|
tx, err := types.SignTx(types.NewTransaction(uniq, recipient, common.Big1, params.TxGas, block.header.BaseFee, nil), signer, testBankKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -3101,7 +3101,7 @@ func testDeleteCreateRevert(t *testing.T, scheme string) {
|
||||||
// Code needs to just selfdestruct
|
// Code needs to just selfdestruct
|
||||||
Code: []byte{byte(vm.PC), byte(vm.SELFDESTRUCT)},
|
Code: []byte{byte(vm.PC), byte(vm.SELFDESTRUCT)},
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
// The address 0xBBBB send 1 wei to 0xAAAA, then reverts
|
// The address 0xBBBB send 1 wei to 0xAAAA, then reverts
|
||||||
bb: {
|
bb: {
|
||||||
|
|
@ -3116,7 +3116,7 @@ func testDeleteCreateRevert(t *testing.T, scheme string) {
|
||||||
byte(vm.CALL),
|
byte(vm.CALL),
|
||||||
byte(vm.REVERT),
|
byte(vm.REVERT),
|
||||||
},
|
},
|
||||||
Balance: big.NewInt(1),
|
Balance: common.Big1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3126,11 +3126,11 @@ func testDeleteCreateRevert(t *testing.T, scheme string) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
// One transaction to AAAA
|
// One transaction to AAAA
|
||||||
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
||||||
big.NewInt(0), 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
// One transaction to BBBB
|
// One transaction to BBBB
|
||||||
tx, _ = types.SignTx(types.NewTransaction(1, bb,
|
tx, _ = types.SignTx(types.NewTransaction(1, bb,
|
||||||
big.NewInt(0), 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
|
|
@ -3225,13 +3225,13 @@ func testDeleteRecreateSlots(t *testing.T, scheme string) {
|
||||||
// Code needs to just selfdestruct
|
// Code needs to just selfdestruct
|
||||||
Code: aaCode,
|
Code: aaCode,
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
Storage: aaStorage,
|
Storage: aaStorage,
|
||||||
},
|
},
|
||||||
// The contract BB recreates AA
|
// The contract BB recreates AA
|
||||||
bb: {
|
bb: {
|
||||||
Code: bbCode,
|
Code: bbCode,
|
||||||
Balance: big.NewInt(1),
|
Balance: common.Big1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3239,11 +3239,11 @@ func testDeleteRecreateSlots(t *testing.T, scheme string) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
// One transaction to AA, to kill it
|
// One transaction to AA, to kill it
|
||||||
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
||||||
big.NewInt(0), 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
// One transaction to BB, to recreate AA
|
// One transaction to BB, to recreate AA
|
||||||
tx, _ = types.SignTx(types.NewTransaction(1, bb,
|
tx, _ = types.SignTx(types.NewTransaction(1, bb,
|
||||||
big.NewInt(0), 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
|
|
@ -3311,7 +3311,7 @@ func testDeleteRecreateAccount(t *testing.T, scheme string) {
|
||||||
// Code needs to just selfdestruct
|
// Code needs to just selfdestruct
|
||||||
Code: aaCode,
|
Code: aaCode,
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
Storage: aaStorage,
|
Storage: aaStorage,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -3321,11 +3321,11 @@ func testDeleteRecreateAccount(t *testing.T, scheme string) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
// One transaction to AA, to kill it
|
// One transaction to AA, to kill it
|
||||||
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
tx, _ := types.SignTx(types.NewTransaction(0, aa,
|
||||||
big.NewInt(0), 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
// One transaction to AA, to recreate it (but without storage
|
// One transaction to AA, to recreate it (but without storage
|
||||||
tx, _ = types.SignTx(types.NewTransaction(1, aa,
|
tx, _ = types.SignTx(types.NewTransaction(1, aa,
|
||||||
big.NewInt(1), 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big1, 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
|
|
@ -3432,13 +3432,13 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
|
||||||
// Code needs to just selfdestruct
|
// Code needs to just selfdestruct
|
||||||
Code: aaCode,
|
Code: aaCode,
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
Storage: aaStorage,
|
Storage: aaStorage,
|
||||||
},
|
},
|
||||||
// The contract BB recreates AA
|
// The contract BB recreates AA
|
||||||
bb: {
|
bb: {
|
||||||
Code: bbCode,
|
Code: bbCode,
|
||||||
Balance: big.NewInt(1),
|
Balance: common.Big1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3457,7 +3457,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
|
||||||
var expectations []*expectation
|
var expectations []*expectation
|
||||||
var newDestruct = func(e *expectation, b *BlockGen) *types.Transaction {
|
var newDestruct = func(e *expectation, b *BlockGen) *types.Transaction {
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, aa,
|
tx, _ := types.SignTx(types.NewTransaction(nonce, aa,
|
||||||
big.NewInt(0), 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 50000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
nonce++
|
nonce++
|
||||||
if e.exist {
|
if e.exist {
|
||||||
e.exist = false
|
e.exist = false
|
||||||
|
|
@ -3468,7 +3468,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
|
||||||
}
|
}
|
||||||
var newResurrect = func(e *expectation, b *BlockGen) *types.Transaction {
|
var newResurrect = func(e *expectation, b *BlockGen) *types.Transaction {
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
|
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
|
||||||
big.NewInt(0), 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
nonce++
|
nonce++
|
||||||
if !e.exist {
|
if !e.exist {
|
||||||
e.exist = true
|
e.exist = true
|
||||||
|
|
@ -3627,7 +3627,7 @@ func testInitThenFailCreateContract(t *testing.T, scheme string) {
|
||||||
// The contract BB tries to create code onto AA
|
// The contract BB tries to create code onto AA
|
||||||
bb: {
|
bb: {
|
||||||
Code: bbCode,
|
Code: bbCode,
|
||||||
Balance: big.NewInt(1),
|
Balance: common.Big1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3636,7 +3636,7 @@ func testInitThenFailCreateContract(t *testing.T, scheme string) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
// One transaction to BB
|
// One transaction to BB
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
|
tx, _ := types.SignTx(types.NewTransaction(nonce, bb,
|
||||||
big.NewInt(0), 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
common.Big0, 100000, b.header.BaseFee, nil), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
nonce++
|
nonce++
|
||||||
})
|
})
|
||||||
|
|
@ -3706,7 +3706,7 @@ func testEIP2718Transition(t *testing.T, scheme string) {
|
||||||
byte(vm.SLOAD),
|
byte(vm.SLOAD),
|
||||||
},
|
},
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3792,7 +3792,7 @@ func testEIP1559Transition(t *testing.T, scheme string) {
|
||||||
byte(vm.SLOAD),
|
byte(vm.SLOAD),
|
||||||
},
|
},
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -3817,7 +3817,7 @@ func testEIP1559Transition(t *testing.T, scheme string) {
|
||||||
To: &aa,
|
To: &aa,
|
||||||
Gas: 30000,
|
Gas: 30000,
|
||||||
GasFeeCap: newGwei(5),
|
GasFeeCap: newGwei(5),
|
||||||
GasTipCap: big.NewInt(2),
|
GasTipCap: common.Big2,
|
||||||
AccessList: accesses,
|
AccessList: accesses,
|
||||||
Data: []byte{},
|
Data: []byte{},
|
||||||
}
|
}
|
||||||
|
|
@ -3950,7 +3950,7 @@ func testSetCanonical(t *testing.T, scheme string) {
|
||||||
|
|
||||||
// Generate the side chain and import them
|
// Generate the side chain and import them
|
||||||
_, side, _ := GenerateChainWithGenesis(gspec, engine, 2*TriesInMemory, func(i int, gen *BlockGen) {
|
_, side, _ := GenerateChainWithGenesis(gspec, engine, 2*TriesInMemory, func(i int, gen *BlockGen) {
|
||||||
tx, err := types.SignTx(types.NewTransaction(gen.TxNonce(address), common.Address{0x00}, big.NewInt(1), params.TxGas, gen.header.BaseFee, nil), signer, key)
|
tx, err := types.SignTx(types.NewTransaction(gen.TxNonce(address), common.Address{0x00}, common.Big1, params.TxGas, gen.header.BaseFee, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -4283,7 +4283,7 @@ func TestTxIndexer(t *testing.T) {
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
frdir := t.TempDir()
|
frdir := t.TempDir()
|
||||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false)
|
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false)
|
||||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), common.Big0)
|
||||||
|
|
||||||
// Index the initial blocks from ancient store
|
// Index the initial blocks from ancient store
|
||||||
chain, _ := NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil, &c.limitA)
|
chain, _ := NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil, &c.limitA)
|
||||||
|
|
@ -4314,9 +4314,9 @@ func TestCreateThenDeletePreByzantium(t *testing.T) {
|
||||||
// deliberate: we want to use pre-byz rules where we have intermediate state roots
|
// deliberate: we want to use pre-byz rules where we have intermediate state roots
|
||||||
// between transactions.
|
// between transactions.
|
||||||
testCreateThenDelete(t, ¶ms.ChainConfig{
|
testCreateThenDelete(t, ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(3),
|
ChainID: common.Big3,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(10),
|
EIP155Block: big.NewInt(10),
|
||||||
EIP158Block: big.NewInt(10),
|
EIP158Block: big.NewInt(10),
|
||||||
ByzantiumBlock: big.NewInt(1_700_000),
|
ByzantiumBlock: big.NewInt(1_700_000),
|
||||||
|
|
@ -4364,7 +4364,7 @@ func testCreateThenDelete(t *testing.T, config *params.ChainConfig) {
|
||||||
nonce := uint64(0)
|
nonce := uint64(0)
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2, func(i int, b *BlockGen) {
|
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2, func(i int, b *BlockGen) {
|
||||||
fee := big.NewInt(1)
|
fee := common.Big1
|
||||||
if b.header.BaseFee != nil {
|
if b.header.BaseFee != nil {
|
||||||
fee = b.header.BaseFee
|
fee = b.header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
@ -4450,7 +4450,7 @@ func TestDeleteThenCreate(t *testing.T) {
|
||||||
nonce := uint64(0)
|
nonce := uint64(0)
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2, func(i int, b *BlockGen) {
|
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2, func(i int, b *BlockGen) {
|
||||||
fee := big.NewInt(1)
|
fee := common.Big1
|
||||||
if b.header.BaseFee != nil {
|
if b.header.BaseFee != nil {
|
||||||
fee = b.header.BaseFee
|
fee = b.header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
@ -4562,7 +4562,7 @@ func TestTransientStorageReset(t *testing.T) {
|
||||||
nonce := uint64(0)
|
nonce := uint64(0)
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) {
|
_, blocks, _ := GenerateChainWithGenesis(gspec, engine, 1, func(i int, b *BlockGen) {
|
||||||
fee := big.NewInt(1)
|
fee := common.Big1
|
||||||
if b.header.BaseFee != nil {
|
if b.header.BaseFee != nil {
|
||||||
fee = b.header.BaseFee
|
fee = b.header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
@ -4635,7 +4635,7 @@ func TestEIP3651(t *testing.T) {
|
||||||
byte(vm.SLOAD),
|
byte(vm.SLOAD),
|
||||||
},
|
},
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
// The address 0xBBBB calls 0xAAAA
|
// The address 0xBBBB calls 0xAAAA
|
||||||
bb: {
|
bb: {
|
||||||
|
|
@ -4651,7 +4651,7 @@ func TestEIP3651(t *testing.T) {
|
||||||
byte(vm.DELEGATECALL),
|
byte(vm.DELEGATECALL),
|
||||||
},
|
},
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -4673,7 +4673,7 @@ func TestEIP3651(t *testing.T) {
|
||||||
To: &bb,
|
To: &bb,
|
||||||
Gas: 500000,
|
Gas: 500000,
|
||||||
GasFeeCap: newGwei(5),
|
GasFeeCap: newGwei(5),
|
||||||
GasTipCap: big.NewInt(2),
|
GasTipCap: common.Big2,
|
||||||
AccessList: nil,
|
AccessList: nil,
|
||||||
Data: []byte{},
|
Data: []byte{},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -321,10 +321,10 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
if b.header.Difficulty == nil {
|
if b.header.Difficulty == nil {
|
||||||
if config.TerminalTotalDifficulty == nil {
|
if config.TerminalTotalDifficulty == nil {
|
||||||
// Clique chain
|
// Clique chain
|
||||||
b.header.Difficulty = big.NewInt(2)
|
b.header.Difficulty = common.Big2
|
||||||
} else {
|
} else {
|
||||||
// Post-merge chain
|
// Post-merge chain
|
||||||
b.header.Difficulty = big.NewInt(0)
|
b.header.Difficulty = common.Big0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Mutate the state and block according to any hard-fork specs
|
// Mutate the state and block according to any hard-fork specs
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func TestGeneratePOSChain(t *testing.T) {
|
||||||
address = crypto.PubkeyToAddress(key.PublicKey) // 658bdf435d810c91414ec09147daa6db62406379
|
address = crypto.PubkeyToAddress(key.PublicKey) // 658bdf435d810c91414ec09147daa6db62406379
|
||||||
aa = common.Address{0xaa}
|
aa = common.Address{0xaa}
|
||||||
bb = common.Address{0xbb}
|
bb = common.Address{0xbb}
|
||||||
funds = big.NewInt(0).Mul(big.NewInt(1337), big.NewInt(params.Ether))
|
funds = common.Big0.Mul(big.NewInt(1337), big.NewInt(params.Ether))
|
||||||
config = *params.AllEthashProtocolChanges
|
config = *params.AllEthashProtocolChanges
|
||||||
asm4788 = common.Hex2Bytes("3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500")
|
asm4788 = common.Hex2Bytes("3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500")
|
||||||
gspec = &Genesis{
|
gspec = &Genesis{
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
|
@ -29,9 +30,9 @@ import (
|
||||||
// Tests that DAO-fork enabled clients can properly filter out fork-commencing
|
// Tests that DAO-fork enabled clients can properly filter out fork-commencing
|
||||||
// blocks based on their extradata fields.
|
// blocks based on their extradata fields.
|
||||||
func TestDAOForkRangeExtradata(t *testing.T) {
|
func TestDAOForkRangeExtradata(t *testing.T) {
|
||||||
forkBlock := big.NewInt(32)
|
forkBlock := common.Big32
|
||||||
chainConfig := *params.NonActivatedConfig
|
chainConfig := *params.NonActivatedConfig
|
||||||
chainConfig.HomesteadBlock = big.NewInt(0)
|
chainConfig.HomesteadBlock = common.Big0
|
||||||
|
|
||||||
// Generate a common prefix for both pro-forkers and non-forkers
|
// Generate a common prefix for both pro-forkers and non-forkers
|
||||||
gspec := &Genesis{
|
gspec := &Genesis{
|
||||||
|
|
@ -43,7 +44,7 @@ func TestDAOForkRangeExtradata(t *testing.T) {
|
||||||
// Create the concurrent, conflicting two nodes
|
// Create the concurrent, conflicting two nodes
|
||||||
proDb := rawdb.NewMemoryDatabase()
|
proDb := rawdb.NewMemoryDatabase()
|
||||||
proConf := *params.NonActivatedConfig
|
proConf := *params.NonActivatedConfig
|
||||||
proConf.HomesteadBlock = big.NewInt(0)
|
proConf.HomesteadBlock = common.Big0
|
||||||
proConf.DAOForkBlock = forkBlock
|
proConf.DAOForkBlock = forkBlock
|
||||||
proConf.DAOForkSupport = true
|
proConf.DAOForkSupport = true
|
||||||
progspec := &Genesis{
|
progspec := &Genesis{
|
||||||
|
|
@ -55,7 +56,7 @@ func TestDAOForkRangeExtradata(t *testing.T) {
|
||||||
|
|
||||||
conDb := rawdb.NewMemoryDatabase()
|
conDb := rawdb.NewMemoryDatabase()
|
||||||
conConf := *params.NonActivatedConfig
|
conConf := *params.NonActivatedConfig
|
||||||
conConf.HomesteadBlock = big.NewInt(0)
|
conConf.HomesteadBlock = common.Big0
|
||||||
conConf.DAOForkBlock = forkBlock
|
conConf.DAOForkBlock = forkBlock
|
||||||
conConf.DAOForkSupport = false
|
conConf.DAOForkSupport = false
|
||||||
congspec := &Genesis{
|
congspec := &Genesis{
|
||||||
|
|
|
||||||
|
|
@ -408,22 +408,22 @@ func TestTimeBasedForkInGenesis(t *testing.T) {
|
||||||
config = func(shanghai, cancun uint64) *params.ChainConfig {
|
config = func(shanghai, cancun uint64) *params.ChainConfig {
|
||||||
return ¶ms.ChainConfig{
|
return ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1337),
|
ChainID: big.NewInt(1337),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
ShanghaiTime: &shanghai,
|
ShanghaiTime: &shanghai,
|
||||||
CancunTime: &cancun,
|
CancunTime: &cancun,
|
||||||
Ethash: new(params.EthashConfig),
|
Ethash: new(params.EthashConfig),
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,7 @@ func DefaultGoerliGenesisBlock() *Genesis {
|
||||||
Timestamp: 1548854791,
|
Timestamp: 1548854791,
|
||||||
ExtraData: hexutil.MustDecode("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
ExtraData: hexutil.MustDecode("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
GasLimit: 10485760,
|
GasLimit: 10485760,
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: common.Big1,
|
||||||
Alloc: decodePrealloc(goerliAllocData),
|
Alloc: decodePrealloc(goerliAllocData),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -589,21 +589,21 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
|
||||||
Config: &config,
|
Config: &config,
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: common.Big1,
|
||||||
Alloc: map[common.Address]GenesisAccount{
|
Alloc: map[common.Address]GenesisAccount{
|
||||||
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
|
common.BytesToAddress([]byte{1}): {Balance: common.Big1}, // ECRecover
|
||||||
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
|
common.BytesToAddress([]byte{2}): {Balance: common.Big1}, // SHA256
|
||||||
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
|
common.BytesToAddress([]byte{3}): {Balance: common.Big1}, // RIPEMD
|
||||||
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
|
common.BytesToAddress([]byte{4}): {Balance: common.Big1}, // Identity
|
||||||
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
|
common.BytesToAddress([]byte{5}): {Balance: common.Big1}, // ModExp
|
||||||
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
|
common.BytesToAddress([]byte{6}): {Balance: common.Big1}, // ECAdd
|
||||||
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
|
common.BytesToAddress([]byte{7}): {Balance: common.Big1}, // ECScalarMul
|
||||||
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
|
common.BytesToAddress([]byte{8}): {Balance: common.Big1}, // ECPairing
|
||||||
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
|
common.BytesToAddress([]byte{9}): {Balance: common.Big1}, // BLAKE2b
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if faucet != nil {
|
if faucet != nil {
|
||||||
genesis.Alloc[*faucet] = GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}
|
genesis.Alloc[*faucet] = GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), big.NewInt(9))}
|
||||||
}
|
}
|
||||||
return genesis
|
return genesis
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,14 @@ func testSetupGenesis(t *testing.T, scheme string) {
|
||||||
var (
|
var (
|
||||||
customghash = common.HexToHash("0x89c99d90b79719238d2645c7642f2c9295246e80775b38cfd162b696817fbd50")
|
customghash = common.HexToHash("0x89c99d90b79719238d2645c7642f2c9295246e80775b38cfd162b696817fbd50")
|
||||||
customg = Genesis{
|
customg = Genesis{
|
||||||
Config: ¶ms.ChainConfig{HomesteadBlock: big.NewInt(3)},
|
Config: ¶ms.ChainConfig{HomesteadBlock: common.Big3},
|
||||||
Alloc: GenesisAlloc{
|
Alloc: GenesisAlloc{
|
||||||
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
{1}: {Balance: common.Big1, Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
oldcustomg = customg
|
oldcustomg = customg
|
||||||
)
|
)
|
||||||
oldcustomg.Config = ¶ms.ChainConfig{HomesteadBlock: big.NewInt(2)}
|
oldcustomg.Config = ¶ms.ChainConfig{HomesteadBlock: common.Big2}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
@ -145,8 +145,8 @@ func testSetupGenesis(t *testing.T, scheme string) {
|
||||||
wantConfig: customg.Config,
|
wantConfig: customg.Config,
|
||||||
wantErr: ¶ms.ConfigCompatError{
|
wantErr: ¶ms.ConfigCompatError{
|
||||||
What: "Homestead fork block",
|
What: "Homestead fork block",
|
||||||
StoredBlock: big.NewInt(2),
|
StoredBlock: common.Big2,
|
||||||
NewBlock: big.NewInt(3),
|
NewBlock: common.Big3,
|
||||||
RewindToBlock: 1,
|
RewindToBlock: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -229,8 +229,8 @@ func TestReadWriteGenesisAlloc(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
alloc = &GenesisAlloc{
|
alloc = &GenesisAlloc{
|
||||||
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
{1}: {Balance: common.Big1, Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
||||||
{2}: {Balance: big.NewInt(2), Storage: map[common.Hash]common.Hash{{2}: {2}}},
|
{2}: {Balance: common.Big2, Storage: map[common.Hash]common.Hash{{2}: {2}}},
|
||||||
}
|
}
|
||||||
hash, _ = alloc.hash(false)
|
hash, _ = alloc.hash(false)
|
||||||
)
|
)
|
||||||
|
|
@ -266,28 +266,28 @@ func newDbConfig(scheme string) *trie.Config {
|
||||||
func TestVerkleGenesisCommit(t *testing.T) {
|
func TestVerkleGenesisCommit(t *testing.T) {
|
||||||
var verkleTime uint64 = 0
|
var verkleTime uint64 = 0
|
||||||
verkleConfig := ¶ms.ChainConfig{
|
verkleConfig := ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: nil,
|
MergeNetsplitBlock: nil,
|
||||||
ShanghaiTime: &verkleTime,
|
ShanghaiTime: &verkleTime,
|
||||||
CancunTime: &verkleTime,
|
CancunTime: &verkleTime,
|
||||||
PragueTime: &verkleTime,
|
PragueTime: &verkleTime,
|
||||||
VerkleTime: &verkleTime,
|
VerkleTime: &verkleTime,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
Ethash: nil,
|
Ethash: nil,
|
||||||
Clique: nil,
|
Clique: nil,
|
||||||
|
|
@ -297,9 +297,9 @@ func TestVerkleGenesisCommit(t *testing.T) {
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Config: verkleConfig,
|
Config: verkleConfig,
|
||||||
Timestamp: verkleTime,
|
Timestamp: verkleTime,
|
||||||
Difficulty: big.NewInt(0),
|
Difficulty: common.Big0,
|
||||||
Alloc: GenesisAlloc{
|
Alloc: GenesisAlloc{
|
||||||
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
{1}: {Balance: common.Big1, Storage: map[common.Hash]common.Hash{{1}: {1}}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -646,7 +646,7 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64,
|
||||||
|
|
||||||
var baseFee *big.Int
|
var baseFee *big.Int
|
||||||
if header == nil {
|
if header == nil {
|
||||||
baseFee = big.NewInt(0)
|
baseFee = common.Big0
|
||||||
} else {
|
} else {
|
||||||
baseFee = header.BaseFee
|
baseFee = header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ func TestBadBlockStorage(t *testing.T) {
|
||||||
|
|
||||||
// Create a test block to move around the database and make sure it's really new
|
// Create a test block to move around the database and make sure it's really new
|
||||||
block := types.NewBlockWithHeader(&types.Header{
|
block := types.NewBlockWithHeader(&types.Header{
|
||||||
Number: big.NewInt(1),
|
Number: common.Big1,
|
||||||
Extra: []byte("bad block"),
|
Extra: []byte("bad block"),
|
||||||
UncleHash: types.EmptyUncleHash,
|
UncleHash: types.EmptyUncleHash,
|
||||||
TxHash: types.EmptyTxsHash,
|
TxHash: types.EmptyTxsHash,
|
||||||
|
|
@ -213,7 +213,7 @@ func TestBadBlockStorage(t *testing.T) {
|
||||||
}
|
}
|
||||||
// Write one more bad block
|
// Write one more bad block
|
||||||
blockTwo := types.NewBlockWithHeader(&types.Header{
|
blockTwo := types.NewBlockWithHeader(&types.Header{
|
||||||
Number: big.NewInt(2),
|
Number: common.Big2,
|
||||||
Extra: []byte("bad block two"),
|
Extra: []byte("bad block two"),
|
||||||
UncleHash: types.EmptyUncleHash,
|
UncleHash: types.EmptyUncleHash,
|
||||||
TxHash: types.EmptyTxsHash,
|
TxHash: types.EmptyTxsHash,
|
||||||
|
|
@ -344,8 +344,8 @@ func TestBlockReceiptStorage(t *testing.T) {
|
||||||
db := NewMemoryDatabase()
|
db := NewMemoryDatabase()
|
||||||
|
|
||||||
// Create a live block since we need metadata to reconstruct the receipt
|
// Create a live block since we need metadata to reconstruct the receipt
|
||||||
tx1 := types.NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil)
|
tx1 := types.NewTransaction(1, common.HexToAddress("0x1"), common.Big1, 1, common.Big1, nil)
|
||||||
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil)
|
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), common.Big2, 2, common.Big2, nil)
|
||||||
|
|
||||||
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
||||||
|
|
||||||
|
|
@ -443,7 +443,7 @@ func TestAncientStorage(t *testing.T) {
|
||||||
|
|
||||||
// Create a test block
|
// Create a test block
|
||||||
block := types.NewBlockWithHeader(&types.Header{
|
block := types.NewBlockWithHeader(&types.Header{
|
||||||
Number: big.NewInt(0),
|
Number: common.Big0,
|
||||||
Extra: []byte("test block"),
|
Extra: []byte("test block"),
|
||||||
UncleHash: types.EmptyUncleHash,
|
UncleHash: types.EmptyUncleHash,
|
||||||
TxHash: types.EmptyTxsHash,
|
TxHash: types.EmptyTxsHash,
|
||||||
|
|
@ -692,8 +692,8 @@ func TestReadLogs(t *testing.T) {
|
||||||
db := NewMemoryDatabase()
|
db := NewMemoryDatabase()
|
||||||
|
|
||||||
// Create a live block since we need metadata to reconstruct the receipt
|
// Create a live block since we need metadata to reconstruct the receipt
|
||||||
tx1 := types.NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil)
|
tx1 := types.NewTransaction(1, common.HexToAddress("0x1"), common.Big1, 1, common.Big1, nil)
|
||||||
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil)
|
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), common.Big2, 2, common.Big2, nil)
|
||||||
|
|
||||||
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
||||||
|
|
||||||
|
|
@ -774,23 +774,23 @@ func TestDeriveLogFields(t *testing.T) {
|
||||||
txs := types.Transactions{
|
txs := types.Transactions{
|
||||||
types.NewTx(&types.LegacyTx{
|
types.NewTx(&types.LegacyTx{
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Gas: 1,
|
Gas: 1,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: common.Big1,
|
||||||
}),
|
}),
|
||||||
types.NewTx(&types.LegacyTx{
|
types.NewTx(&types.LegacyTx{
|
||||||
To: &to2,
|
To: &to2,
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
Value: big.NewInt(2),
|
Value: common.Big2,
|
||||||
Gas: 2,
|
Gas: 2,
|
||||||
GasPrice: big.NewInt(2),
|
GasPrice: common.Big2,
|
||||||
}),
|
}),
|
||||||
types.NewTx(&types.AccessListTx{
|
types.NewTx(&types.AccessListTx{
|
||||||
To: &to3,
|
To: &to3,
|
||||||
Nonce: 3,
|
Nonce: 3,
|
||||||
Value: big.NewInt(3),
|
Value: common.Big3,
|
||||||
Gas: 3,
|
Gas: 3,
|
||||||
GasPrice: big.NewInt(3),
|
GasPrice: common.Big3,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
// Create the corresponding receipts
|
// Create the corresponding receipts
|
||||||
|
|
@ -816,7 +816,7 @@ func TestDeriveLogFields(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derive log metadata fields
|
// Derive log metadata fields
|
||||||
number := big.NewInt(1)
|
number := common.Big1
|
||||||
hash := common.BytesToHash([]byte{0x03, 0x14})
|
hash := common.BytesToHash([]byte{0x03, 0x14})
|
||||||
if err := deriveLogFields(receipts, hash, number.Uint64(), txs); err != nil {
|
if err := deriveLogFields(receipts, hash, number.Uint64(), txs); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func getBlock(transactions int, uncles int, dataSize int) *types.Block {
|
||||||
// Add transactions and stuff on the last block
|
// Add transactions and stuff on the last block
|
||||||
for i := 0; i < transactions; i++ {
|
for i := 0; i < transactions; i++ {
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), aa,
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), aa,
|
||||||
big.NewInt(0), 50000, b.header.BaseFee, make([]byte, dataSize)), types.HomesteadSigner{}, key)
|
common.Big0, 50000, b.header.BaseFee, make([]byte, dataSize)), types.HomesteadSigner{}, key)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
}
|
}
|
||||||
for i := 0; i < uncles; i++ {
|
for i := 0; i < uncles; i++ {
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ func testGeneration(t *testing.T, scheme string) {
|
||||||
var helper = newHelper(scheme)
|
var helper = newHelper(scheme)
|
||||||
stRoot := helper.makeStorageTrie(common.Hash{}, []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, false)
|
stRoot := helper.makeStorageTrie(common.Hash{}, []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, false)
|
||||||
|
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
|
|
@ -97,16 +97,16 @@ func testGenerateExistentState(t *testing.T, scheme string) {
|
||||||
var helper = newHelper(scheme)
|
var helper = newHelper(scheme)
|
||||||
|
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addSnapAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
||||||
|
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addSnapAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addSnapAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-3", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-3", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
||||||
|
|
||||||
root, snap := helper.CommitAndGenerate()
|
root, snap := helper.CommitAndGenerate()
|
||||||
|
|
@ -259,28 +259,28 @@ func testGenerateExistentStateWithWrongStorage(t *testing.T, scheme string) {
|
||||||
helper := newHelper(scheme)
|
helper := newHelper(scheme)
|
||||||
|
|
||||||
// Account one, empty root but non-empty database
|
// Account one, empty root but non-empty database
|
||||||
helper.addAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
||||||
|
|
||||||
// Account two, non empty root but empty database
|
// Account two, non empty root but empty database
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-2")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-2")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-2", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-2", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
// Miss slots
|
// Miss slots
|
||||||
{
|
{
|
||||||
// Account three, non empty root but misses slots in the beginning
|
// Account three, non empty root but misses slots in the beginning
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-3", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-3", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-3", []string{"key-2", "key-3"}, []string{"val-2", "val-3"})
|
helper.addSnapStorage("acc-3", []string{"key-2", "key-3"}, []string{"val-2", "val-3"})
|
||||||
|
|
||||||
// Account four, non empty root but misses slots in the middle
|
// Account four, non empty root but misses slots in the middle
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-4")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-4")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-4", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-4", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-4", []string{"key-1", "key-3"}, []string{"val-1", "val-3"})
|
helper.addSnapStorage("acc-4", []string{"key-1", "key-3"}, []string{"val-1", "val-3"})
|
||||||
|
|
||||||
// Account five, non empty root but misses slots in the end
|
// Account five, non empty root but misses slots in the end
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-5")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-5")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-5", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-5", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-5", []string{"key-1", "key-2"}, []string{"val-1", "val-2"})
|
helper.addSnapStorage("acc-5", []string{"key-1", "key-2"}, []string{"val-1", "val-2"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,22 +288,22 @@ func testGenerateExistentStateWithWrongStorage(t *testing.T, scheme string) {
|
||||||
{
|
{
|
||||||
// Account six, non empty root but wrong slots in the beginning
|
// Account six, non empty root but wrong slots in the beginning
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-6")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-6")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-6", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-6", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-6", []string{"key-1", "key-2", "key-3"}, []string{"badval-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-6", []string{"key-1", "key-2", "key-3"}, []string{"badval-1", "val-2", "val-3"})
|
||||||
|
|
||||||
// Account seven, non empty root but wrong slots in the middle
|
// Account seven, non empty root but wrong slots in the middle
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-7")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-7")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-7", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-7", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-7", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "badval-2", "val-3"})
|
helper.addSnapStorage("acc-7", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "badval-2", "val-3"})
|
||||||
|
|
||||||
// Account eight, non empty root but wrong slots in the end
|
// Account eight, non empty root but wrong slots in the end
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-8")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-8")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-8", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-8", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-8", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "badval-3"})
|
helper.addSnapStorage("acc-8", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "badval-3"})
|
||||||
|
|
||||||
// Account 9, non empty root but rotated slots
|
// Account 9, non empty root but rotated slots
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-9")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-9")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-9", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-9", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-9", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-3", "val-2"})
|
helper.addSnapStorage("acc-9", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-3", "val-2"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,17 +311,17 @@ func testGenerateExistentStateWithWrongStorage(t *testing.T, scheme string) {
|
||||||
{
|
{
|
||||||
// Account 10, non empty root but extra slots in the beginning
|
// Account 10, non empty root but extra slots in the beginning
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-10")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-10")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-10", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-10", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-10", []string{"key-0", "key-1", "key-2", "key-3"}, []string{"val-0", "val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-10", []string{"key-0", "key-1", "key-2", "key-3"}, []string{"val-0", "val-1", "val-2", "val-3"})
|
||||||
|
|
||||||
// Account 11, non empty root but extra slots in the middle
|
// Account 11, non empty root but extra slots in the middle
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-11")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-11")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-11", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-11", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-11", []string{"key-1", "key-2", "key-2-1", "key-3"}, []string{"val-1", "val-2", "val-2-1", "val-3"})
|
helper.addSnapStorage("acc-11", []string{"key-1", "key-2", "key-2-1", "key-3"}, []string{"val-1", "val-2", "val-2-1", "val-3"})
|
||||||
|
|
||||||
// Account 12, non empty root but extra slots in the end
|
// Account 12, non empty root but extra slots in the end
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-12")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-12")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-12", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-12", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapStorage("acc-12", []string{"key-1", "key-2", "key-3", "key-4"}, []string{"val-1", "val-2", "val-3", "val-4"})
|
helper.addSnapStorage("acc-12", []string{"key-1", "key-2", "key-3", "key-4"}, []string{"val-1", "val-2", "val-3", "val-4"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,25 +366,25 @@ func testGenerateExistentStateWithWrongAccounts(t *testing.T, scheme string) {
|
||||||
|
|
||||||
// Missing accounts, only in the trie
|
// Missing accounts, only in the trie
|
||||||
{
|
{
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // Beginning
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // Beginning
|
||||||
helper.addTrieAccount("acc-4", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // Middle
|
helper.addTrieAccount("acc-4", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // Middle
|
||||||
helper.addTrieAccount("acc-6", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // End
|
helper.addTrieAccount("acc-6", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // End
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrong accounts
|
// Wrong accounts
|
||||||
{
|
{
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapAccount("acc-2", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: common.Hex2Bytes("0x1234")})
|
helper.addSnapAccount("acc-2", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: common.Hex2Bytes("0x1234")})
|
||||||
|
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addSnapAccount("acc-3", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addSnapAccount("acc-3", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra accounts, only in the snap
|
// Extra accounts, only in the snap
|
||||||
{
|
{
|
||||||
helper.addSnapAccount("acc-0", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // before the beginning
|
helper.addSnapAccount("acc-0", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // before the beginning
|
||||||
helper.addSnapAccount("acc-5", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: common.Hex2Bytes("0x1234")}) // Middle
|
helper.addSnapAccount("acc-5", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: common.Hex2Bytes("0x1234")}) // Middle
|
||||||
helper.addSnapAccount("acc-7", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // after the end
|
helper.addSnapAccount("acc-7", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // after the end
|
||||||
}
|
}
|
||||||
|
|
||||||
root, snap := helper.CommitAndGenerate()
|
root, snap := helper.CommitAndGenerate()
|
||||||
|
|
@ -418,9 +418,9 @@ func testGenerateCorruptAccountTrie(t *testing.T, scheme string) {
|
||||||
// without any storage slots to keep the test smaller.
|
// without any storage slots to keep the test smaller.
|
||||||
helper := newHelper(scheme)
|
helper := newHelper(scheme)
|
||||||
|
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0xc7a30f39aff471c95d8a837497ad0e49b65be475cc0953540f80cfcdbdcd9074
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0xc7a30f39aff471c95d8a837497ad0e49b65be475cc0953540f80cfcdbdcd9074
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x19ead688e907b0fab07176120dceec244a72aff2f0aa51e8b827584e378772f4
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x19ead688e907b0fab07176120dceec244a72aff2f0aa51e8b827584e378772f4
|
||||||
|
|
||||||
root := helper.Commit() // Root: 0xa04693ea110a31037fb5ee814308a6f1d76bdab0b11676bdf4541d2de55ba978
|
root := helper.Commit() // Root: 0xa04693ea110a31037fb5ee814308a6f1d76bdab0b11676bdf4541d2de55ba978
|
||||||
|
|
||||||
|
|
@ -463,10 +463,10 @@ func testGenerateMissingStorageTrie(t *testing.T, scheme string) {
|
||||||
helper = newHelper(scheme)
|
helper = newHelper(scheme)
|
||||||
)
|
)
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
||||||
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
|
||||||
|
|
||||||
root := helper.Commit()
|
root := helper.Commit()
|
||||||
|
|
||||||
|
|
@ -503,10 +503,10 @@ func testGenerateCorruptStorageTrie(t *testing.T, scheme string) {
|
||||||
helper := newHelper(scheme)
|
helper := newHelper(scheme)
|
||||||
|
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) // 0xddefcd9376dd029653ef384bd2f0a126bb755fe84fdcc9e7cf421ba454f2bc67
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x65145f923027566669a1ae5ccac66f945b55ff6eaeb17d2ea8e048b7d381f2d7
|
||||||
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot = helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}) // 0x50815097425d000edfc8b3a4a13e175fc2bdcfee8bdfbf2d1ff61041d3c235b2
|
||||||
|
|
||||||
root := helper.Commit()
|
root := helper.Commit()
|
||||||
|
|
||||||
|
|
@ -546,7 +546,7 @@ func testGenerateWithExtraAccounts(t *testing.T, scheme string) {
|
||||||
[]string{"val-1", "val-2", "val-3", "val-4", "val-5"},
|
[]string{"val-1", "val-2", "val-3", "val-4", "val-5"},
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
acc := &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
acc := &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
||||||
val, _ := rlp.EncodeToBytes(acc)
|
val, _ := rlp.EncodeToBytes(acc)
|
||||||
helper.accTrie.MustUpdate([]byte("acc-1"), val) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
helper.accTrie.MustUpdate([]byte("acc-1"), val) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
||||||
|
|
||||||
|
|
@ -566,7 +566,7 @@ func testGenerateWithExtraAccounts(t *testing.T, scheme string) {
|
||||||
[]string{"val-1", "val-2", "val-3", "val-4", "val-5"},
|
[]string{"val-1", "val-2", "val-3", "val-4", "val-5"},
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
acc := &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
acc := &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
||||||
val, _ := rlp.EncodeToBytes(acc)
|
val, _ := rlp.EncodeToBytes(acc)
|
||||||
key := hashData([]byte("acc-2"))
|
key := hashData([]byte("acc-2"))
|
||||||
rawdb.WriteAccountSnapshot(helper.diskdb, key, val)
|
rawdb.WriteAccountSnapshot(helper.diskdb, key, val)
|
||||||
|
|
@ -622,7 +622,7 @@ func testGenerateWithManyExtraAccounts(t *testing.T, scheme string) {
|
||||||
[]string{"val-1", "val-2", "val-3"},
|
[]string{"val-1", "val-2", "val-3"},
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
acc := &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
acc := &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()}
|
||||||
val, _ := rlp.EncodeToBytes(acc)
|
val, _ := rlp.EncodeToBytes(acc)
|
||||||
helper.accTrie.MustUpdate([]byte("acc-1"), val) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
helper.accTrie.MustUpdate([]byte("acc-1"), val) // 0x9250573b9c18c664139f3b6a7a8081b7d8f8916a8fcc5d94feec6c29f5fd4e9e
|
||||||
|
|
||||||
|
|
@ -678,7 +678,7 @@ func testGenerateWithExtraBeforeAndAfter(t *testing.T, scheme string) {
|
||||||
}
|
}
|
||||||
helper := newHelper(scheme)
|
helper := newHelper(scheme)
|
||||||
{
|
{
|
||||||
acc := &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}
|
acc := &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}
|
||||||
val, _ := rlp.EncodeToBytes(acc)
|
val, _ := rlp.EncodeToBytes(acc)
|
||||||
helper.accTrie.MustUpdate(common.HexToHash("0x03").Bytes(), val)
|
helper.accTrie.MustUpdate(common.HexToHash("0x03").Bytes(), val)
|
||||||
helper.accTrie.MustUpdate(common.HexToHash("0x07").Bytes(), val)
|
helper.accTrie.MustUpdate(common.HexToHash("0x07").Bytes(), val)
|
||||||
|
|
@ -720,7 +720,7 @@ func testGenerateWithMalformedSnapdata(t *testing.T, scheme string) {
|
||||||
}
|
}
|
||||||
helper := newHelper(scheme)
|
helper := newHelper(scheme)
|
||||||
{
|
{
|
||||||
acc := &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}
|
acc := &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()}
|
||||||
val, _ := rlp.EncodeToBytes(acc)
|
val, _ := rlp.EncodeToBytes(acc)
|
||||||
helper.accTrie.MustUpdate(common.HexToHash("0x03").Bytes(), val)
|
helper.accTrie.MustUpdate(common.HexToHash("0x03").Bytes(), val)
|
||||||
|
|
||||||
|
|
@ -764,7 +764,7 @@ func testGenerateFromEmptySnap(t *testing.T, scheme string) {
|
||||||
for i := 0; i < 400; i++ {
|
for i := 0; i < 400; i++ {
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte(fmt.Sprintf("acc-%d", i))), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot := helper.makeStorageTrie(hashData([]byte(fmt.Sprintf("acc-%d", i))), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount(fmt.Sprintf("acc-%d", i),
|
helper.addTrieAccount(fmt.Sprintf("acc-%d", i),
|
||||||
&types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
&types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
}
|
}
|
||||||
root, snap := helper.CommitAndGenerate()
|
root, snap := helper.CommitAndGenerate()
|
||||||
t.Logf("Root: %#x\n", root) // Root: 0x6f7af6d2e1a1bf2b84a3beb3f8b64388465fbc1e274ca5d5d3fc787ca78f59e4
|
t.Logf("Root: %#x\n", root) // Root: 0x6f7af6d2e1a1bf2b84a3beb3f8b64388465fbc1e274ca5d5d3fc787ca78f59e4
|
||||||
|
|
@ -903,11 +903,11 @@ func testGenerateCompleteSnapshotWithDanglingStorage(t *testing.T, scheme string
|
||||||
var helper = newHelper(scheme)
|
var helper = newHelper(scheme)
|
||||||
|
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addAccount("acc-2", &types.StateAccount{Balance: big.NewInt(1), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-2", &types.StateAccount{Balance: common.Big1, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addAccount("acc-3", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addAccount("acc-3", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-1", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
||||||
helper.addSnapStorage("acc-3", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
helper.addSnapStorage("acc-3", []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"})
|
||||||
|
|
@ -943,11 +943,11 @@ func testGenerateBrokenSnapshotWithDanglingStorage(t *testing.T, scheme string)
|
||||||
var helper = newHelper(scheme)
|
var helper = newHelper(scheme)
|
||||||
|
|
||||||
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
stRoot := helper.makeStorageTrie(hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: big.NewInt(1), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-1", &types.StateAccount{Balance: common.Big1, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: big.NewInt(2), Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-2", &types.StateAccount{Balance: common.Big2, Root: types.EmptyRootHash, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
helper.makeStorageTrie(hashData([]byte("acc-3")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true)
|
||||||
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: big.NewInt(3), Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
helper.addTrieAccount("acc-3", &types.StateAccount{Balance: common.Big3, Root: stRoot, CodeHash: types.EmptyCodeHash.Bytes()})
|
||||||
|
|
||||||
populateDangling(helper.diskdb)
|
populateDangling(helper.diskdb)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -736,7 +736,7 @@ func TestCommitCopy(t *testing.T) {
|
||||||
// Copy the committed state database, the copied one is not functional.
|
// Copy the committed state database, the copied one is not functional.
|
||||||
state.Commit(0, true)
|
state.Commit(0, true)
|
||||||
copied := state.Copy()
|
copied := state.Copy()
|
||||||
if balance := copied.GetBalance(addr); balance.Cmp(big.NewInt(0)) != 0 {
|
if balance := copied.GetBalance(addr); balance.Cmp(common.Big0) != 0 {
|
||||||
t.Fatalf("unexpected balance: have %v", balance)
|
t.Fatalf("unexpected balance: have %v", balance)
|
||||||
}
|
}
|
||||||
if code := copied.GetCode(addr); code != nil {
|
if code := copied.GetCode(addr); code != nil {
|
||||||
|
|
@ -766,7 +766,7 @@ func TestDeleteCreateRevert(t *testing.T) {
|
||||||
state, _ := New(types.EmptyRootHash, NewDatabase(rawdb.NewMemoryDatabase()), nil)
|
state, _ := New(types.EmptyRootHash, NewDatabase(rawdb.NewMemoryDatabase()), nil)
|
||||||
|
|
||||||
addr := common.BytesToAddress([]byte("so"))
|
addr := common.BytesToAddress([]byte("so"))
|
||||||
state.SetBalance(addr, big.NewInt(1))
|
state.SetBalance(addr, common.Big1)
|
||||||
|
|
||||||
root, _ := state.Commit(0, false)
|
root, _ := state.Commit(0, false)
|
||||||
state, _ = New(root, state.db, state.snaps)
|
state, _ = New(root, state.db, state.snaps)
|
||||||
|
|
@ -776,7 +776,7 @@ func TestDeleteCreateRevert(t *testing.T) {
|
||||||
state.Finalise(true)
|
state.Finalise(true)
|
||||||
|
|
||||||
id := state.Snapshot()
|
id := state.Snapshot()
|
||||||
state.SetBalance(addr, big.NewInt(2))
|
state.SetBalance(addr, common.Big2)
|
||||||
state.RevertToSnapshot(id)
|
state.RevertToSnapshot(id)
|
||||||
|
|
||||||
// Commit the entire state and make sure we don't crash and have the correct state
|
// Commit the entire state and make sure we don't crash and have the correct state
|
||||||
|
|
@ -818,7 +818,7 @@ func testMissingTrieNodes(t *testing.T, scheme string) {
|
||||||
state, _ := New(types.EmptyRootHash, db, nil)
|
state, _ := New(types.EmptyRootHash, db, nil)
|
||||||
addr := common.BytesToAddress([]byte("so"))
|
addr := common.BytesToAddress([]byte("so"))
|
||||||
{
|
{
|
||||||
state.SetBalance(addr, big.NewInt(1))
|
state.SetBalance(addr, common.Big1)
|
||||||
state.SetCode(addr, []byte{1, 2, 3})
|
state.SetCode(addr, []byte{1, 2, 3})
|
||||||
a2 := common.BytesToAddress([]byte("another"))
|
a2 := common.BytesToAddress([]byte("another"))
|
||||||
state.SetBalance(a2, big.NewInt(100))
|
state.SetBalance(a2, big.NewInt(100))
|
||||||
|
|
@ -846,7 +846,7 @@ func testMissingTrieNodes(t *testing.T, scheme string) {
|
||||||
t.Errorf("expected %d, got %d", exp, got)
|
t.Errorf("expected %d, got %d", exp, got)
|
||||||
}
|
}
|
||||||
// Modify the state
|
// Modify the state
|
||||||
state.SetBalance(addr, big.NewInt(2))
|
state.SetBalance(addr, common.Big2)
|
||||||
root, err := state.Commit(0, false)
|
root, err := state.Commit(0, false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected error, got root :%x", root)
|
t.Fatalf("expected error, got root :%x", root)
|
||||||
|
|
@ -1114,13 +1114,13 @@ func TestResetObject(t *testing.T) {
|
||||||
slotB = common.HexToHash("0x2")
|
slotB = common.HexToHash("0x2")
|
||||||
)
|
)
|
||||||
// Initialize account with balance and storage in first transaction.
|
// Initialize account with balance and storage in first transaction.
|
||||||
state.SetBalance(addr, big.NewInt(1))
|
state.SetBalance(addr, common.Big1)
|
||||||
state.SetState(addr, slotA, common.BytesToHash([]byte{0x1}))
|
state.SetState(addr, slotA, common.BytesToHash([]byte{0x1}))
|
||||||
state.IntermediateRoot(true)
|
state.IntermediateRoot(true)
|
||||||
|
|
||||||
// Reset account and mutate balance and storages
|
// Reset account and mutate balance and storages
|
||||||
state.CreateAccount(addr)
|
state.CreateAccount(addr)
|
||||||
state.SetBalance(addr, big.NewInt(2))
|
state.SetBalance(addr, common.Big2)
|
||||||
state.SetState(addr, slotB, common.BytesToHash([]byte{0x2}))
|
state.SetState(addr, slotB, common.BytesToHash([]byte{0x2}))
|
||||||
root, _ := state.Commit(0, true)
|
root, _ := state.Commit(0, true)
|
||||||
|
|
||||||
|
|
@ -1146,7 +1146,7 @@ func TestDeleteStorage(t *testing.T) {
|
||||||
addr = common.HexToAddress("0x1")
|
addr = common.HexToAddress("0x1")
|
||||||
)
|
)
|
||||||
// Initialize account and populate storage
|
// Initialize account and populate storage
|
||||||
state.SetBalance(addr, big.NewInt(1))
|
state.SetBalance(addr, common.Big1)
|
||||||
state.CreateAccount(addr)
|
state.CreateAccount(addr)
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
slot := common.Hash(uint256.NewInt(uint64(i)).Bytes32())
|
slot := common.Hash(uint256.NewInt(uint64(i)).Bytes32())
|
||||||
|
|
|
||||||
|
|
@ -47,20 +47,20 @@ func u64(val uint64) *uint64 { return &val }
|
||||||
func TestStateProcessorErrors(t *testing.T) {
|
func TestStateProcessorErrors(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
config = ¶ms.ChainConfig{
|
config = ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
Ethash: new(params.EthashConfig),
|
Ethash: new(params.EthashConfig),
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
ShanghaiTime: new(uint64),
|
ShanghaiTime: new(uint64),
|
||||||
CancunTime: new(uint64),
|
CancunTime: new(uint64),
|
||||||
|
|
@ -80,7 +80,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
GasFeeCap: gasFeeCap,
|
GasFeeCap: gasFeeCap,
|
||||||
Gas: gasLimit,
|
Gas: gasLimit,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(0),
|
Value: common.Big0,
|
||||||
}), signer, key1)
|
}), signer, key1)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
GasTipCap: gasTipCap,
|
GasTipCap: gasTipCap,
|
||||||
GasFeeCap: gasFeeCap,
|
GasFeeCap: gasFeeCap,
|
||||||
Gas: gasLimit,
|
Gas: gasLimit,
|
||||||
Value: big.NewInt(0),
|
Value: common.Big0,
|
||||||
Data: data,
|
Data: data,
|
||||||
}), signer, key1)
|
}), signer, key1)
|
||||||
return tx
|
return tx
|
||||||
|
|
@ -142,26 +142,26 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{ // ErrNonceTooLow
|
{ // ErrNonceTooLow
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(875000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, params.TxGas, big.NewInt(875000000), nil),
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(875000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, params.TxGas, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 1 [0x0026256b3939ed97e2c4a6f3fce8ecf83bdcfa6d507c47838c308a1fb0436f62]: nonce too low: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 0 state: 1",
|
want: "could not apply tx 1 [0x0026256b3939ed97e2c4a6f3fce8ecf83bdcfa6d507c47838c308a1fb0436f62]: nonce too low: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 0 state: 1",
|
||||||
},
|
},
|
||||||
{ // ErrNonceTooHigh
|
{ // ErrNonceTooHigh
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 100, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(875000000), nil),
|
makeTx(key1, 100, common.Address{}, common.Big0, params.TxGas, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xdebad714ca7f363bd0d8121c4518ad48fa469ca81b0a081be3d10c17460f751b]: nonce too high: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 100 state: 0",
|
want: "could not apply tx 0 [0xdebad714ca7f363bd0d8121c4518ad48fa469ca81b0a081be3d10c17460f751b]: nonce too high: address 0x71562b71999873DB5b286dF957af199Ec94617F7, tx: 100 state: 0",
|
||||||
},
|
},
|
||||||
{ // ErrNonceMax
|
{ // ErrNonceMax
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key2, math.MaxUint64, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(875000000), nil),
|
makeTx(key2, math.MaxUint64, common.Address{}, common.Big0, params.TxGas, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x84ea18d60eb2bb3b040e3add0eb72f757727122cc257dd858c67cb6591a85986]: nonce has max value: address 0xfd0810DD14796680f72adf1a371963d0745BCc64, nonce: 18446744073709551615",
|
want: "could not apply tx 0 [0x84ea18d60eb2bb3b040e3add0eb72f757727122cc257dd858c67cb6591a85986]: nonce has max value: address 0xfd0810DD14796680f72adf1a371963d0745BCc64, nonce: 18446744073709551615",
|
||||||
},
|
},
|
||||||
{ // ErrGasLimitReached
|
{ // ErrGasLimitReached
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), 21000000, big.NewInt(875000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, 21000000, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
||||||
},
|
},
|
||||||
|
|
@ -173,7 +173,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
{ // ErrInsufficientFunds
|
{ // ErrInsufficientFunds
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas, big.NewInt(900000000000000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, params.TxGas, big.NewInt(900000000000000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x4a69690c4b0cd85e64d0d9ea06302455b01e10a83db964d60281739752003440]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 1000000000000000000 want 18900000000000000000000",
|
want: "could not apply tx 0 [0x4a69690c4b0cd85e64d0d9ea06302455b01e10a83db964d60281739752003440]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 1000000000000000000 want 18900000000000000000000",
|
||||||
},
|
},
|
||||||
|
|
@ -183,37 +183,37 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
// multiplication len(data) +gas_per_byte overflows uint64. Not testable at the moment
|
// multiplication len(data) +gas_per_byte overflows uint64. Not testable at the moment
|
||||||
{ // ErrIntrinsicGas
|
{ // ErrIntrinsicGas
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas-1000, big.NewInt(875000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, params.TxGas-1000, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xcf3b049a0b516cb4f9274b3e2a264359e2ba53b2fb64b7bda2c634d5c9d01fca]: intrinsic gas too low: have 20000, want 21000",
|
want: "could not apply tx 0 [0xcf3b049a0b516cb4f9274b3e2a264359e2ba53b2fb64b7bda2c634d5c9d01fca]: intrinsic gas too low: have 20000, want 21000",
|
||||||
},
|
},
|
||||||
{ // ErrGasLimitReached
|
{ // ErrGasLimitReached
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
makeTx(key1, 0, common.Address{}, big.NewInt(0), params.TxGas*1000, big.NewInt(875000000), nil),
|
makeTx(key1, 0, common.Address{}, common.Big0, params.TxGas*1000, big.NewInt(875000000), nil),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
want: "could not apply tx 0 [0xbd49d8dadfd47fb846986695f7d4da3f7b2c48c8da82dbc211a26eb124883de9]: gas limit reached",
|
||||||
},
|
},
|
||||||
{ // ErrFeeCapTooLow
|
{ // ErrFeeCapTooLow
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(0), big.NewInt(0)),
|
mkDynamicTx(0, common.Address{}, params.TxGas, common.Big0, common.Big0),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xc4ab868fef0c82ae0387b742aee87907f2d0fc528fc6ea0a021459fb0fc4a4a8]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0, baseFee: 875000000",
|
want: "could not apply tx 0 [0xc4ab868fef0c82ae0387b742aee87907f2d0fc528fc6ea0a021459fb0fc4a4a8]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0, baseFee: 875000000",
|
||||||
},
|
},
|
||||||
{ // ErrTipVeryHigh
|
{ // ErrTipVeryHigh
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, tooBigNumber, big.NewInt(1)),
|
mkDynamicTx(0, common.Address{}, params.TxGas, tooBigNumber, common.Big1),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x15b8391b9981f266b32f3ab7da564bbeb3d6c21628364ea9b32a21139f89f712]: max priority fee per gas higher than 2^256-1: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxPriorityFeePerGas bit length: 257",
|
want: "could not apply tx 0 [0x15b8391b9981f266b32f3ab7da564bbeb3d6c21628364ea9b32a21139f89f712]: max priority fee per gas higher than 2^256-1: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxPriorityFeePerGas bit length: 257",
|
||||||
},
|
},
|
||||||
{ // ErrFeeCapVeryHigh
|
{ // ErrFeeCapVeryHigh
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(1), tooBigNumber),
|
mkDynamicTx(0, common.Address{}, params.TxGas, common.Big1, tooBigNumber),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x48bc299b83fdb345c57478f239e89814bb3063eb4e4b49f3b6057a69255c16bd]: max fee per gas higher than 2^256-1: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas bit length: 257",
|
want: "could not apply tx 0 [0x48bc299b83fdb345c57478f239e89814bb3063eb4e4b49f3b6057a69255c16bd]: max fee per gas higher than 2^256-1: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas bit length: 257",
|
||||||
},
|
},
|
||||||
{ // ErrTipAboveFeeCap
|
{ // ErrTipAboveFeeCap
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(2), big.NewInt(1)),
|
mkDynamicTx(0, common.Address{}, params.TxGas, common.Big2, common.Big1),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xf987a31ff0c71895780a7612f965a0c8b056deb54e020bb44fa478092f14c9b4]: max priority fee per gas higher than max fee per gas: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxPriorityFeePerGas: 2, maxFeePerGas: 1",
|
want: "could not apply tx 0 [0xf987a31ff0c71895780a7612f965a0c8b056deb54e020bb44fa478092f14c9b4]: max priority fee per gas higher than max fee per gas: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxPriorityFeePerGas: 2, maxFeePerGas: 1",
|
||||||
},
|
},
|
||||||
|
|
@ -224,7 +224,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
// This test is designed to have the effective cost be covered by the balance, but
|
// This test is designed to have the effective cost be covered by the balance, but
|
||||||
// the extended requirement on FeeCap*gas < balance to fail
|
// the extended requirement on FeeCap*gas < balance to fail
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(1), big.NewInt(50000000000000)),
|
mkDynamicTx(0, common.Address{}, params.TxGas, common.Big1, big.NewInt(50000000000000)),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x413603cd096a87f41b1660d3ed3e27d62e1da78eac138961c0a1314ed43bd129]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 1000000000000000000 want 1050000000000000000",
|
want: "could not apply tx 0 [0x413603cd096a87f41b1660d3ed3e27d62e1da78eac138961c0a1314ed43bd129]: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 1000000000000000000 want 1050000000000000000",
|
||||||
},
|
},
|
||||||
|
|
@ -248,7 +248,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
{ // ErrBlobFeeCapTooLow
|
{ // ErrBlobFeeCapTooLow
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkBlobTx(0, common.Address{}, params.TxGas, big.NewInt(1), big.NewInt(1), big.NewInt(0), []common.Hash{(common.Hash{1})}),
|
mkBlobTx(0, common.Address{}, params.TxGas, common.Big1, common.Big1, common.Big0, []common.Hash{(common.Hash{1})}),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x6c11015985ce82db691d7b2d017acda296db88b811c3c60dc71449c76256c716]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1, baseFee: 875000000",
|
want: "could not apply tx 0 [0x6c11015985ce82db691d7b2d017acda296db88b811c3c60dc71449c76256c716]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1, baseFee: 875000000",
|
||||||
},
|
},
|
||||||
|
|
@ -270,16 +270,16 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
gspec = &Genesis{
|
gspec = &Genesis{
|
||||||
Config: ¶ms.ChainConfig{
|
Config: ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
},
|
},
|
||||||
Alloc: GenesisAlloc{
|
Alloc: GenesisAlloc{
|
||||||
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
|
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
|
||||||
|
|
@ -297,7 +297,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{ // ErrTxTypeNotSupported
|
{ // ErrTxTypeNotSupported
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas-1000, big.NewInt(0), big.NewInt(0)),
|
mkDynamicTx(0, common.Address{}, params.TxGas-1000, common.Big0, common.Big0),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: transaction type not supported",
|
want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: transaction type not supported",
|
||||||
},
|
},
|
||||||
|
|
@ -336,7 +336,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{ // ErrSenderNoEOA
|
{ // ErrSenderNoEOA
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas-1000, big.NewInt(0), big.NewInt(0)),
|
mkDynamicTx(0, common.Address{}, params.TxGas-1000, common.Big0, common.Big0),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: sender not an eoa: address 0x71562b71999873DB5b286dF957af199Ec94617F7, codehash: 0x9280914443471259d4570a8661015ae4a5b80186dbc619658fb494bebc3da3d1",
|
want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: sender not an eoa: address 0x71562b71999873DB5b286dF957af199Ec94617F7, codehash: 0x9280914443471259d4570a8661015ae4a5b80186dbc619658fb494bebc3da3d1",
|
||||||
},
|
},
|
||||||
|
|
@ -358,7 +358,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
// valid to be considered for import:
|
// valid to be considered for import:
|
||||||
// - valid pow (fake), ancestry, difficulty, gaslimit etc
|
// - valid pow (fake), ancestry, difficulty, gaslimit etc
|
||||||
func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Transactions, config *params.ChainConfig) *types.Block {
|
func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Transactions, config *params.ChainConfig) *types.Block {
|
||||||
difficulty := big.NewInt(0)
|
difficulty := common.Big0
|
||||||
if !config.TerminalTotalDifficultyPassed {
|
if !config.TerminalTotalDifficultyPassed {
|
||||||
fakeChainReader := newChainMaker(nil, config, engine)
|
fakeChainReader := newChainMaker(nil, config, engine)
|
||||||
difficulty = engine.CalcDifficulty(fakeChainReader, parent.Time()+10, &types.Header{
|
difficulty = engine.CalcDifficulty(fakeChainReader, parent.Time()+10, &types.Header{
|
||||||
|
|
|
||||||
|
|
@ -98,16 +98,16 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
|
||||||
// The base fee at 5714 ETH translates into the 21000 base gas higher than
|
// The base fee at 5714 ETH translates into the 21000 base gas higher than
|
||||||
// mainnet ether existence, use that as a cap for the tests.
|
// mainnet ether existence, use that as a cap for the tests.
|
||||||
var (
|
var (
|
||||||
blockNumber = new(big.Int).Add(bc.config.LondonBlock, big.NewInt(1))
|
blockNumber = new(big.Int).Add(bc.config.LondonBlock, common.Big1)
|
||||||
blockTime = *bc.config.CancunTime + 1
|
blockTime = *bc.config.CancunTime + 1
|
||||||
gasLimit = uint64(30_000_000)
|
gasLimit = uint64(30_000_000)
|
||||||
)
|
)
|
||||||
lo := new(big.Int)
|
lo := new(big.Int)
|
||||||
hi := new(big.Int).Mul(big.NewInt(5714), new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))
|
hi := new(big.Int).Mul(big.NewInt(5714), new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))
|
||||||
|
|
||||||
for new(big.Int).Add(lo, big.NewInt(1)).Cmp(hi) != 0 {
|
for new(big.Int).Add(lo, common.Big1).Cmp(hi) != 0 {
|
||||||
mid := new(big.Int).Add(lo, hi)
|
mid := new(big.Int).Add(lo, hi)
|
||||||
mid.Div(mid, big.NewInt(2))
|
mid.Div(mid, common.Big2)
|
||||||
|
|
||||||
if eip1559.CalcBaseFee(bc.config, &types.Header{
|
if eip1559.CalcBaseFee(bc.config, &types.Header{
|
||||||
Number: blockNumber,
|
Number: blockNumber,
|
||||||
|
|
@ -125,11 +125,11 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
|
||||||
// The excess blob gas at 2^27 translates into a blob fee higher than mainnet
|
// The excess blob gas at 2^27 translates into a blob fee higher than mainnet
|
||||||
// ether existence, use that as a cap for the tests.
|
// ether existence, use that as a cap for the tests.
|
||||||
lo = new(big.Int)
|
lo = new(big.Int)
|
||||||
hi = new(big.Int).Exp(big.NewInt(2), big.NewInt(27), nil)
|
hi = new(big.Int).Exp(common.Big2, big.NewInt(27), nil)
|
||||||
|
|
||||||
for new(big.Int).Add(lo, big.NewInt(1)).Cmp(hi) != 0 {
|
for new(big.Int).Add(lo, common.Big1).Cmp(hi) != 0 {
|
||||||
mid := new(big.Int).Add(lo, hi)
|
mid := new(big.Int).Add(lo, hi)
|
||||||
mid.Div(mid, big.NewInt(2))
|
mid.Div(mid, common.Big2)
|
||||||
|
|
||||||
if eip4844.CalcBlobFee(mid.Uint64()).Cmp(bc.blobfee.ToBig()) > 0 {
|
if eip4844.CalcBlobFee(mid.Uint64()).Cmp(bc.blobfee.ToBig()) > 0 {
|
||||||
hi = mid
|
hi = mid
|
||||||
|
|
@ -150,7 +150,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
|
||||||
|
|
||||||
func (bc *testBlockChain) CurrentFinalBlock() *types.Header {
|
func (bc *testBlockChain) CurrentFinalBlock() *types.Header {
|
||||||
return &types.Header{
|
return &types.Header{
|
||||||
Number: big.NewInt(0),
|
Number: common.Big0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,7 +532,7 @@ func TestOpenDrops(t *testing.T) {
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
if err := pool.Init(big.NewInt(1), chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
if err := pool.Init(common.Big1, chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
||||||
t.Fatalf("failed to create blob pool: %v", err)
|
t.Fatalf("failed to create blob pool: %v", err)
|
||||||
}
|
}
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
@ -647,7 +647,7 @@ func TestOpenIndex(t *testing.T) {
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
if err := pool.Init(big.NewInt(1), chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
if err := pool.Init(common.Big1, chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
||||||
t.Fatalf("failed to create blob pool: %v", err)
|
t.Fatalf("failed to create blob pool: %v", err)
|
||||||
}
|
}
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
@ -749,7 +749,7 @@ func TestOpenHeap(t *testing.T) {
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
if err := pool.Init(big.NewInt(1), chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
if err := pool.Init(common.Big1, chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
||||||
t.Fatalf("failed to create blob pool: %v", err)
|
t.Fatalf("failed to create blob pool: %v", err)
|
||||||
}
|
}
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
@ -829,7 +829,7 @@ func TestOpenCap(t *testing.T) {
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage, Datacap: datacap}, chain)
|
pool := New(Config{Datadir: storage, Datacap: datacap}, chain)
|
||||||
if err := pool.Init(big.NewInt(1), chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
if err := pool.Init(common.Big1, chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
||||||
t.Fatalf("failed to create blob pool: %v", err)
|
t.Fatalf("failed to create blob pool: %v", err)
|
||||||
}
|
}
|
||||||
// Verify that enough transactions have been dropped to get the pool's size
|
// Verify that enough transactions have been dropped to get the pool's size
|
||||||
|
|
@ -1231,7 +1231,7 @@ func TestAdd(t *testing.T) {
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
if err := pool.Init(big.NewInt(1), chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
if err := pool.Init(common.Big1, chain.CurrentBlock(), makeAddressReserver()); err != nil {
|
||||||
t.Fatalf("test %d: failed to create blob pool: %v", i, err)
|
t.Fatalf("test %d: failed to create blob pool: %v", i, err)
|
||||||
}
|
}
|
||||||
verifyPoolInternals(t, pool)
|
verifyPoolInternals(t, pool)
|
||||||
|
|
|
||||||
|
|
@ -1281,7 +1281,7 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
|
||||||
if reset != nil {
|
if reset != nil {
|
||||||
pool.demoteUnexecutables()
|
pool.demoteUnexecutables()
|
||||||
if reset.newHead != nil {
|
if reset.newHead != nil {
|
||||||
if pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) {
|
if pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, common.Big1)) {
|
||||||
pendingBaseFee := eip1559.CalcBaseFee(pool.chainconfig, reset.newHead)
|
pendingBaseFee := eip1559.CalcBaseFee(pool.chainconfig, reset.newHead)
|
||||||
pool.priced.SetBaseFee(pendingBaseFee)
|
pool.priced.SetBaseFee(pendingBaseFee)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func (bc *testBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func transaction(nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) *types.Transaction {
|
func transaction(nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) *types.Transaction {
|
||||||
return pricedTransaction(nonce, gaslimit, big.NewInt(1), key)
|
return pricedTransaction(nonce, gaslimit, common.Big1, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pricedTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
|
func pricedTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
|
||||||
|
|
@ -109,7 +109,7 @@ func pricedDataTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key
|
||||||
data := make([]byte, bytes)
|
data := make([]byte, bytes)
|
||||||
crand.Read(data)
|
crand.Read(data)
|
||||||
|
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gaslimit, gasprice, data), types.HomesteadSigner{}, key)
|
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, common.Big0, gaslimit, gasprice, data), types.HomesteadSigner{}, key)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,7 +329,7 @@ func TestInvalidTransactions(t *testing.T) {
|
||||||
from, _ := deriveSender(tx)
|
from, _ := deriveSender(tx)
|
||||||
|
|
||||||
// Intrinsic gas too low
|
// Intrinsic gas too low
|
||||||
testAddBalance(pool, from, big.NewInt(1))
|
testAddBalance(pool, from, common.Big1)
|
||||||
if err, want := pool.addRemote(tx), core.ErrIntrinsicGas; !errors.Is(err, want) {
|
if err, want := pool.addRemote(tx), core.ErrIntrinsicGas; !errors.Is(err, want) {
|
||||||
t.Errorf("want %v have %v", want, err)
|
t.Errorf("want %v have %v", want, err)
|
||||||
}
|
}
|
||||||
|
|
@ -420,9 +420,9 @@ func TestNegativeValue(t *testing.T) {
|
||||||
pool, key := setupPool()
|
pool, key := setupPool()
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
||||||
tx, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(-1), 100, big.NewInt(1), nil), types.HomesteadSigner{}, key)
|
tx, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(-1), 100, common.Big1, nil), types.HomesteadSigner{}, key)
|
||||||
from, _ := deriveSender(tx)
|
from, _ := deriveSender(tx)
|
||||||
testAddBalance(pool, from, big.NewInt(1))
|
testAddBalance(pool, from, common.Big1)
|
||||||
if err := pool.addRemote(tx); err != txpool.ErrNegativeValue {
|
if err := pool.addRemote(tx); err != txpool.ErrNegativeValue {
|
||||||
t.Error("expected", txpool.ErrNegativeValue, "got", err)
|
t.Error("expected", txpool.ErrNegativeValue, "got", err)
|
||||||
}
|
}
|
||||||
|
|
@ -434,7 +434,7 @@ func TestTipAboveFeeCap(t *testing.T) {
|
||||||
pool, key := setupPoolWithConfig(eip1559Config)
|
pool, key := setupPoolWithConfig(eip1559Config)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
||||||
tx := dynamicFeeTx(0, 100, big.NewInt(1), big.NewInt(2), key)
|
tx := dynamicFeeTx(0, 100, common.Big1, common.Big2, key)
|
||||||
|
|
||||||
if err := pool.addRemote(tx); err != core.ErrTipAboveFeeCap {
|
if err := pool.addRemote(tx); err != core.ErrTipAboveFeeCap {
|
||||||
t.Error("expected", core.ErrTipAboveFeeCap, "got", err)
|
t.Error("expected", core.ErrTipAboveFeeCap, "got", err)
|
||||||
|
|
@ -447,15 +447,15 @@ func TestVeryHighValues(t *testing.T) {
|
||||||
pool, key := setupPoolWithConfig(eip1559Config)
|
pool, key := setupPoolWithConfig(eip1559Config)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
||||||
veryBigNumber := big.NewInt(1)
|
veryBigNumber := common.Big1
|
||||||
veryBigNumber.Lsh(veryBigNumber, 300)
|
veryBigNumber.Lsh(veryBigNumber, 300)
|
||||||
|
|
||||||
tx := dynamicFeeTx(0, 100, big.NewInt(1), veryBigNumber, key)
|
tx := dynamicFeeTx(0, 100, common.Big1, veryBigNumber, key)
|
||||||
if err := pool.addRemote(tx); err != core.ErrTipVeryHigh {
|
if err := pool.addRemote(tx); err != core.ErrTipVeryHigh {
|
||||||
t.Error("expected", core.ErrTipVeryHigh, "got", err)
|
t.Error("expected", core.ErrTipVeryHigh, "got", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx2 := dynamicFeeTx(0, 100, veryBigNumber, big.NewInt(1), key)
|
tx2 := dynamicFeeTx(0, 100, veryBigNumber, common.Big1, key)
|
||||||
if err := pool.addRemote(tx2); err != core.ErrFeeCapVeryHigh {
|
if err := pool.addRemote(tx2); err != core.ErrFeeCapVeryHigh {
|
||||||
t.Error("expected", core.ErrFeeCapVeryHigh, "got", err)
|
t.Error("expected", core.ErrFeeCapVeryHigh, "got", err)
|
||||||
}
|
}
|
||||||
|
|
@ -507,9 +507,9 @@ func TestDoubleNonce(t *testing.T) {
|
||||||
resetState()
|
resetState()
|
||||||
|
|
||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 100000, big.NewInt(1), nil), signer, key)
|
tx1, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 100000, common.Big1, nil), signer, key)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, big.NewInt(2), nil), signer, key)
|
tx2, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, common.Big2, nil), signer, key)
|
||||||
tx3, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, big.NewInt(1), nil), signer, key)
|
tx3, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, common.Big1, nil), signer, key)
|
||||||
|
|
||||||
// Add the first two transaction, ensure higher priced stays only
|
// Add the first two transaction, ensure higher priced stays only
|
||||||
if replace, err := pool.add(tx1, false); err != nil || replace {
|
if replace, err := pool.add(tx1, false); err != nil || replace {
|
||||||
|
|
@ -1023,10 +1023,10 @@ func testQueueTimeLimiting(t *testing.T, nolocals bool) {
|
||||||
testAddBalance(pool, crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(1000000000))
|
testAddBalance(pool, crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(1000000000))
|
||||||
|
|
||||||
// Add the two transactions and ensure they both are queued up
|
// Add the two transactions and ensure they both are queued up
|
||||||
if err := pool.addLocal(pricedTransaction(1, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(1, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add local transaction: %v", err)
|
t.Fatalf("failed to add local transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(1, 100000, big.NewInt(1), remote)); err != nil {
|
if err := pool.addRemote(pricedTransaction(1, 100000, common.Big1, remote)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
pending, queued := pool.Stats()
|
pending, queued := pool.Stats()
|
||||||
|
|
@ -1093,19 +1093,19 @@ func testQueueTimeLimiting(t *testing.T, nolocals bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue gapped transactions
|
// Queue gapped transactions
|
||||||
if err := pool.addLocal(pricedTransaction(4, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(4, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemoteSync(pricedTransaction(4, 100000, big.NewInt(1), remote)); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(4, 100000, common.Big1, remote)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(5 * evictionInterval) // A half lifetime pass
|
time.Sleep(5 * evictionInterval) // A half lifetime pass
|
||||||
|
|
||||||
// Queue executable transactions, the life cycle should be restarted.
|
// Queue executable transactions, the life cycle should be restarted.
|
||||||
if err := pool.addLocal(pricedTransaction(2, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(2, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemoteSync(pricedTransaction(2, 100000, big.NewInt(1), remote)); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(2, 100000, common.Big1, remote)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(6 * evictionInterval)
|
time.Sleep(6 * evictionInterval)
|
||||||
|
|
@ -1258,20 +1258,20 @@ func TestAllowedTxSize(t *testing.T) {
|
||||||
baseSize := uint64(213)
|
baseSize := uint64(213)
|
||||||
dataSize := txMaxSize - baseSize
|
dataSize := txMaxSize - baseSize
|
||||||
// Try adding a transaction with maximal allowed size
|
// Try adding a transaction with maximal allowed size
|
||||||
tx := pricedDataTransaction(0, pool.currentHead.Load().GasLimit, big.NewInt(1), key, dataSize)
|
tx := pricedDataTransaction(0, pool.currentHead.Load().GasLimit, common.Big1, key, dataSize)
|
||||||
if err := pool.addRemoteSync(tx); err != nil {
|
if err := pool.addRemoteSync(tx); err != nil {
|
||||||
t.Fatalf("failed to add transaction of size %d, close to maximal: %v", int(tx.Size()), err)
|
t.Fatalf("failed to add transaction of size %d, close to maximal: %v", int(tx.Size()), err)
|
||||||
}
|
}
|
||||||
// Try adding a transaction with random allowed size
|
// Try adding a transaction with random allowed size
|
||||||
if err := pool.addRemoteSync(pricedDataTransaction(1, pool.currentHead.Load().GasLimit, big.NewInt(1), key, uint64(rand.Intn(int(dataSize))))); err != nil {
|
if err := pool.addRemoteSync(pricedDataTransaction(1, pool.currentHead.Load().GasLimit, common.Big1, key, uint64(rand.Intn(int(dataSize))))); err != nil {
|
||||||
t.Fatalf("failed to add transaction of random allowed size: %v", err)
|
t.Fatalf("failed to add transaction of random allowed size: %v", err)
|
||||||
}
|
}
|
||||||
// Try adding a transaction of minimal not allowed size
|
// Try adding a transaction of minimal not allowed size
|
||||||
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentHead.Load().GasLimit, big.NewInt(1), key, txMaxSize)); err == nil {
|
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentHead.Load().GasLimit, common.Big1, key, txMaxSize)); err == nil {
|
||||||
t.Fatalf("expected rejection on slightly oversize transaction")
|
t.Fatalf("expected rejection on slightly oversize transaction")
|
||||||
}
|
}
|
||||||
// Try adding a transaction of random not allowed size
|
// Try adding a transaction of random not allowed size
|
||||||
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentHead.Load().GasLimit, big.NewInt(1), key, dataSize+1+uint64(rand.Intn(10*txMaxSize)))); err == nil {
|
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentHead.Load().GasLimit, common.Big1, key, dataSize+1+uint64(rand.Intn(10*txMaxSize)))); err == nil {
|
||||||
t.Fatalf("expected rejection on oversize transaction")
|
t.Fatalf("expected rejection on oversize transaction")
|
||||||
}
|
}
|
||||||
// Run some sanity checks on the pool internals
|
// Run some sanity checks on the pool internals
|
||||||
|
|
@ -1397,19 +1397,19 @@ func TestRepricing(t *testing.T) {
|
||||||
// Generate and queue a batch of transactions, both pending and queued
|
// Generate and queue a batch of transactions, both pending and queued
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(0, 100000, common.Big2, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(1), keys[0]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big1, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(2, 100000, common.Big2, keys[0]))
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(1), keys[1]))
|
txs = append(txs, pricedTransaction(0, 100000, common.Big1, keys[1]))
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(2), keys[1]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big2, keys[1]))
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(2), keys[1]))
|
txs = append(txs, pricedTransaction(2, 100000, common.Big2, keys[1]))
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(2), keys[2]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big2, keys[2]))
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(1), keys[2]))
|
txs = append(txs, pricedTransaction(2, 100000, common.Big1, keys[2]))
|
||||||
txs = append(txs, pricedTransaction(3, 100000, big.NewInt(2), keys[2]))
|
txs = append(txs, pricedTransaction(3, 100000, common.Big2, keys[2]))
|
||||||
|
|
||||||
ltx := pricedTransaction(0, 100000, big.NewInt(1), keys[3])
|
ltx := pricedTransaction(0, 100000, common.Big1, keys[3])
|
||||||
|
|
||||||
// Import the batch and that both pending and queued transactions match up
|
// Import the batch and that both pending and queued transactions match up
|
||||||
pool.addRemotesSync(txs)
|
pool.addRemotesSync(txs)
|
||||||
|
|
@ -1429,7 +1429,7 @@ func TestRepricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Reprice the pool and check that underpriced transactions get dropped
|
// Reprice the pool and check that underpriced transactions get dropped
|
||||||
pool.SetGasTip(big.NewInt(2))
|
pool.SetGasTip(common.Big2)
|
||||||
|
|
||||||
pending, queued = pool.Stats()
|
pending, queued = pool.Stats()
|
||||||
if pending != 2 {
|
if pending != 2 {
|
||||||
|
|
@ -1445,13 +1445,13 @@ func TestRepricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Check that we can't add the old transactions back
|
// Check that we can't add the old transactions back
|
||||||
if err := pool.addRemote(pricedTransaction(1, 100000, big.NewInt(1), keys[0])); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(pricedTransaction(1, 100000, common.Big1, keys[0])); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(0, 100000, big.NewInt(1), keys[1])); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(pricedTransaction(0, 100000, common.Big1, keys[1])); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(2, 100000, big.NewInt(1), keys[2])); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(pricedTransaction(2, 100000, common.Big1, keys[2])); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced queued transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced queued transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
if err := validateEvents(events, 0); err != nil {
|
if err := validateEvents(events, 0); err != nil {
|
||||||
|
|
@ -1461,7 +1461,7 @@ func TestRepricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// However we can add local underpriced transactions
|
// However we can add local underpriced transactions
|
||||||
tx := pricedTransaction(1, 100000, big.NewInt(1), keys[3])
|
tx := pricedTransaction(1, 100000, common.Big1, keys[3])
|
||||||
if err := pool.addLocal(tx); err != nil {
|
if err := pool.addLocal(tx); err != nil {
|
||||||
t.Fatalf("failed to add underpriced local transaction: %v", err)
|
t.Fatalf("failed to add underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1475,13 +1475,13 @@ func TestRepricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// And we can fill gaps with properly priced transactions
|
// And we can fill gaps with properly priced transactions
|
||||||
if err := pool.addRemote(pricedTransaction(1, 100000, big.NewInt(2), keys[0])); err != nil {
|
if err := pool.addRemote(pricedTransaction(1, 100000, common.Big2, keys[0])); err != nil {
|
||||||
t.Fatalf("failed to add pending transaction: %v", err)
|
t.Fatalf("failed to add pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(0, 100000, big.NewInt(2), keys[1])); err != nil {
|
if err := pool.addRemote(pricedTransaction(0, 100000, common.Big2, keys[1])); err != nil {
|
||||||
t.Fatalf("failed to add pending transaction: %v", err)
|
t.Fatalf("failed to add pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemoteSync(pricedTransaction(2, 100000, big.NewInt(2), keys[2])); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(2, 100000, common.Big2, keys[2])); err != nil {
|
||||||
t.Fatalf("failed to add queued transaction: %v", err)
|
t.Fatalf("failed to add queued transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := validateEvents(events, 5); err != nil {
|
if err := validateEvents(events, 5); err != nil {
|
||||||
|
|
@ -1508,7 +1508,7 @@ func TestMinGasPriceEnforced(t *testing.T) {
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1000000))
|
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1000000))
|
||||||
|
|
||||||
tx := pricedTransaction(0, 100000, big.NewInt(2), key)
|
tx := pricedTransaction(0, 100000, common.Big2, key)
|
||||||
pool.SetGasTip(big.NewInt(tx.GasPrice().Int64() + 1))
|
pool.SetGasTip(big.NewInt(tx.GasPrice().Int64() + 1))
|
||||||
|
|
||||||
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
|
@ -1519,7 +1519,7 @@ func TestMinGasPriceEnforced(t *testing.T) {
|
||||||
t.Fatalf("Min tip not enforced")
|
t.Fatalf("Min tip not enforced")
|
||||||
}
|
}
|
||||||
|
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), key)
|
tx = dynamicFeeTx(0, 100000, common.Big3, common.Big2, key)
|
||||||
pool.SetGasTip(big.NewInt(tx.GasTipCap().Int64() + 1))
|
pool.SetGasTip(big.NewInt(tx.GasTipCap().Int64() + 1))
|
||||||
|
|
||||||
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
|
@ -1562,19 +1562,19 @@ func TestRepricingDynamicFee(t *testing.T) {
|
||||||
// Generate and queue a batch of transactions, both pending and queued
|
// Generate and queue a batch of transactions, both pending and queued
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(0, 100000, common.Big2, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(1), keys[0]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big1, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(2, 100000, common.Big2, keys[0]))
|
||||||
|
|
||||||
txs = append(txs, dynamicFeeTx(0, 100000, big.NewInt(2), big.NewInt(1), keys[1]))
|
txs = append(txs, dynamicFeeTx(0, 100000, common.Big2, common.Big1, keys[1]))
|
||||||
txs = append(txs, dynamicFeeTx(1, 100000, big.NewInt(3), big.NewInt(2), keys[1]))
|
txs = append(txs, dynamicFeeTx(1, 100000, common.Big3, common.Big2, keys[1]))
|
||||||
txs = append(txs, dynamicFeeTx(2, 100000, big.NewInt(3), big.NewInt(2), keys[1]))
|
txs = append(txs, dynamicFeeTx(2, 100000, common.Big3, common.Big2, keys[1]))
|
||||||
|
|
||||||
txs = append(txs, dynamicFeeTx(1, 100000, big.NewInt(2), big.NewInt(2), keys[2]))
|
txs = append(txs, dynamicFeeTx(1, 100000, common.Big2, common.Big2, keys[2]))
|
||||||
txs = append(txs, dynamicFeeTx(2, 100000, big.NewInt(1), big.NewInt(1), keys[2]))
|
txs = append(txs, dynamicFeeTx(2, 100000, common.Big1, common.Big1, keys[2]))
|
||||||
txs = append(txs, dynamicFeeTx(3, 100000, big.NewInt(2), big.NewInt(2), keys[2]))
|
txs = append(txs, dynamicFeeTx(3, 100000, common.Big2, common.Big2, keys[2]))
|
||||||
|
|
||||||
ltx := dynamicFeeTx(0, 100000, big.NewInt(2), big.NewInt(1), keys[3])
|
ltx := dynamicFeeTx(0, 100000, common.Big2, common.Big1, keys[3])
|
||||||
|
|
||||||
// Import the batch and that both pending and queued transactions match up
|
// Import the batch and that both pending and queued transactions match up
|
||||||
pool.addRemotesSync(txs)
|
pool.addRemotesSync(txs)
|
||||||
|
|
@ -1594,7 +1594,7 @@ func TestRepricingDynamicFee(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Reprice the pool and check that underpriced transactions get dropped
|
// Reprice the pool and check that underpriced transactions get dropped
|
||||||
pool.SetGasTip(big.NewInt(2))
|
pool.SetGasTip(common.Big2)
|
||||||
|
|
||||||
pending, queued = pool.Stats()
|
pending, queued = pool.Stats()
|
||||||
if pending != 2 {
|
if pending != 2 {
|
||||||
|
|
@ -1610,15 +1610,15 @@ func TestRepricingDynamicFee(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Check that we can't add the old transactions back
|
// Check that we can't add the old transactions back
|
||||||
tx := pricedTransaction(1, 100000, big.NewInt(1), keys[0])
|
tx := pricedTransaction(1, 100000, common.Big1, keys[0])
|
||||||
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(2), big.NewInt(1), keys[1])
|
tx = dynamicFeeTx(0, 100000, common.Big2, common.Big1, keys[1])
|
||||||
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
tx = dynamicFeeTx(2, 100000, big.NewInt(1), big.NewInt(1), keys[2])
|
tx = dynamicFeeTx(2, 100000, common.Big1, common.Big1, keys[2])
|
||||||
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced queued transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced queued transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
|
|
@ -1629,7 +1629,7 @@ func TestRepricingDynamicFee(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// However we can add local underpriced transactions
|
// However we can add local underpriced transactions
|
||||||
tx = dynamicFeeTx(1, 100000, big.NewInt(1), big.NewInt(1), keys[3])
|
tx = dynamicFeeTx(1, 100000, common.Big1, common.Big1, keys[3])
|
||||||
if err := pool.addLocal(tx); err != nil {
|
if err := pool.addLocal(tx); err != nil {
|
||||||
t.Fatalf("failed to add underpriced local transaction: %v", err)
|
t.Fatalf("failed to add underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1643,15 +1643,15 @@ func TestRepricingDynamicFee(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// And we can fill gaps with properly priced transactions
|
// And we can fill gaps with properly priced transactions
|
||||||
tx = pricedTransaction(1, 100000, big.NewInt(2), keys[0])
|
tx = pricedTransaction(1, 100000, common.Big2, keys[0])
|
||||||
if err := pool.addRemote(tx); err != nil {
|
if err := pool.addRemote(tx); err != nil {
|
||||||
t.Fatalf("failed to add pending transaction: %v", err)
|
t.Fatalf("failed to add pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), keys[1])
|
tx = dynamicFeeTx(0, 100000, common.Big3, common.Big2, keys[1])
|
||||||
if err := pool.addRemote(tx); err != nil {
|
if err := pool.addRemote(tx); err != nil {
|
||||||
t.Fatalf("failed to add pending transaction: %v", err)
|
t.Fatalf("failed to add pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
tx = dynamicFeeTx(2, 100000, big.NewInt(2), big.NewInt(2), keys[2])
|
tx = dynamicFeeTx(2, 100000, common.Big2, common.Big2, keys[2])
|
||||||
if err := pool.addRemoteSync(tx); err != nil {
|
if err := pool.addRemoteSync(tx); err != nil {
|
||||||
t.Fatalf("failed to add queued transaction: %v", err)
|
t.Fatalf("failed to add queued transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1724,10 +1724,10 @@ func TestRepricingKeepsLocals(t *testing.T) {
|
||||||
validate()
|
validate()
|
||||||
|
|
||||||
// Reprice the pool and check that nothing is dropped
|
// Reprice the pool and check that nothing is dropped
|
||||||
pool.SetGasTip(big.NewInt(2))
|
pool.SetGasTip(common.Big2)
|
||||||
validate()
|
validate()
|
||||||
|
|
||||||
pool.SetGasTip(big.NewInt(2))
|
pool.SetGasTip(common.Big2)
|
||||||
pool.SetGasTip(big.NewInt(4))
|
pool.SetGasTip(big.NewInt(4))
|
||||||
pool.SetGasTip(big.NewInt(8))
|
pool.SetGasTip(big.NewInt(8))
|
||||||
pool.SetGasTip(big.NewInt(100))
|
pool.SetGasTip(big.NewInt(100))
|
||||||
|
|
@ -1768,12 +1768,12 @@ func TestUnderpricing(t *testing.T) {
|
||||||
// Generate and queue a batch of transactions, both pending and queued
|
// Generate and queue a batch of transactions, both pending and queued
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(1), keys[0]))
|
txs = append(txs, pricedTransaction(0, 100000, common.Big1, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big2, keys[0]))
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(1), keys[1]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big1, keys[1]))
|
||||||
|
|
||||||
ltx := pricedTransaction(0, 100000, big.NewInt(1), keys[2])
|
ltx := pricedTransaction(0, 100000, common.Big1, keys[2])
|
||||||
|
|
||||||
// Import the batch and that both pending and queued transactions match up
|
// Import the batch and that both pending and queued transactions match up
|
||||||
pool.addRemotes(txs)
|
pool.addRemotes(txs)
|
||||||
|
|
@ -1793,15 +1793,15 @@ func TestUnderpricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Ensure that adding an underpriced transaction on block limit fails
|
// Ensure that adding an underpriced transaction on block limit fails
|
||||||
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), keys[1])); !errors.Is(err, txpool.ErrUnderpriced) {
|
if err := pool.addRemoteSync(pricedTransaction(0, 100000, common.Big1, keys[1])); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
// Replace a future transaction with a future transaction
|
// Replace a future transaction with a future transaction
|
||||||
if err := pool.addRemoteSync(pricedTransaction(1, 100000, big.NewInt(2), keys[1])); err != nil { // +K1:1 => -K1:1 => Pend K0:0, K0:1, K2:0; Que K1:1
|
if err := pool.addRemoteSync(pricedTransaction(1, 100000, common.Big2, keys[1])); err != nil { // +K1:1 => -K1:1 => Pend K0:0, K0:1, K2:0; Que K1:1
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
// Ensure that adding high priced transactions drops cheap ones, but not own
|
// Ensure that adding high priced transactions drops cheap ones, but not own
|
||||||
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(3), keys[1])); err != nil { // +K1:0 => -K1:1 => Pend K0:0, K0:1, K1:0, K2:0; Que -
|
if err := pool.addRemoteSync(pricedTransaction(0, 100000, common.Big3, keys[1])); err != nil { // +K1:0 => -K1:1 => Pend K0:0, K0:1, K1:0, K2:0; Que -
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemoteSync(pricedTransaction(2, 100000, big.NewInt(4), keys[1])); err != nil { // +K1:2 => -K0:0 => Pend K1:0, K2:0; Que K0:1 K1:2
|
if err := pool.addRemoteSync(pricedTransaction(2, 100000, big.NewInt(4), keys[1])); err != nil { // +K1:2 => -K0:0 => Pend K1:0, K2:0; Que K0:1 K1:2
|
||||||
|
|
@ -1828,11 +1828,11 @@ func TestUnderpricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Ensure that adding local transactions can push out even higher priced ones
|
// Ensure that adding local transactions can push out even higher priced ones
|
||||||
ltx = pricedTransaction(1, 100000, big.NewInt(0), keys[2])
|
ltx = pricedTransaction(1, 100000, common.Big0, keys[2])
|
||||||
if err := pool.addLocal(ltx); err != nil {
|
if err := pool.addLocal(ltx); err != nil {
|
||||||
t.Fatalf("failed to append underpriced local transaction: %v", err)
|
t.Fatalf("failed to append underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
ltx = pricedTransaction(0, 100000, big.NewInt(0), keys[3])
|
ltx = pricedTransaction(0, 100000, common.Big0, keys[3])
|
||||||
if err := pool.addLocal(ltx); err != nil {
|
if err := pool.addLocal(ltx); err != nil {
|
||||||
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1883,7 +1883,7 @@ func TestStableUnderpricing(t *testing.T) {
|
||||||
// Fill up the entire queue with the same transaction price points
|
// Fill up the entire queue with the same transaction price points
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
for i := uint64(0); i < config.GlobalSlots; i++ {
|
for i := uint64(0); i < config.GlobalSlots; i++ {
|
||||||
txs = append(txs, pricedTransaction(i, 100000, big.NewInt(1), keys[0]))
|
txs = append(txs, pricedTransaction(i, 100000, common.Big1, keys[0]))
|
||||||
}
|
}
|
||||||
pool.addRemotesSync(txs)
|
pool.addRemotesSync(txs)
|
||||||
|
|
||||||
|
|
@ -1901,7 +1901,7 @@ func TestStableUnderpricing(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Ensure that adding high priced transactions drops a cheap, but doesn't produce a gap
|
// Ensure that adding high priced transactions drops a cheap, but doesn't produce a gap
|
||||||
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(3), keys[1])); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(0, 100000, common.Big3, keys[1])); err != nil {
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
pending, queued = pool.Stats()
|
pending, queued = pool.Stats()
|
||||||
|
|
@ -1948,11 +1948,11 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
||||||
// Generate and queue a batch of transactions, both pending and queued
|
// Generate and queue a batch of transactions, both pending and queued
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
|
|
||||||
txs = append(txs, dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), keys[0]))
|
txs = append(txs, dynamicFeeTx(0, 100000, common.Big3, common.Big2, keys[0]))
|
||||||
txs = append(txs, pricedTransaction(1, 100000, big.NewInt(2), keys[0]))
|
txs = append(txs, pricedTransaction(1, 100000, common.Big2, keys[0]))
|
||||||
txs = append(txs, dynamicFeeTx(1, 100000, big.NewInt(2), big.NewInt(1), keys[1]))
|
txs = append(txs, dynamicFeeTx(1, 100000, common.Big2, common.Big1, keys[1]))
|
||||||
|
|
||||||
ltx := dynamicFeeTx(0, 100000, big.NewInt(2), big.NewInt(1), keys[2])
|
ltx := dynamicFeeTx(0, 100000, common.Big2, common.Big1, keys[2])
|
||||||
|
|
||||||
// Import the batch and that both pending and queued transactions match up
|
// Import the batch and that both pending and queued transactions match up
|
||||||
pool.addRemotes(txs) // Pend K0:0, K0:1; Que K1:1
|
pool.addRemotes(txs) // Pend K0:0, K0:1; Que K1:1
|
||||||
|
|
@ -1973,22 +1973,22 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that adding an underpriced transaction fails
|
// Ensure that adding an underpriced transaction fails
|
||||||
tx := dynamicFeeTx(0, 100000, big.NewInt(2), big.NewInt(1), keys[1])
|
tx := dynamicFeeTx(0, 100000, common.Big2, common.Big1, keys[1])
|
||||||
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) { // Pend K0:0, K0:1, K2:0; Que K1:1
|
if err := pool.addRemote(tx); !errors.Is(err, txpool.ErrUnderpriced) { // Pend K0:0, K0:1, K2:0; Que K1:1
|
||||||
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, txpool.ErrUnderpriced)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that adding high priced transactions drops cheap ones, but not own
|
// Ensure that adding high priced transactions drops cheap ones, but not own
|
||||||
tx = pricedTransaction(0, 100000, big.NewInt(2), keys[1])
|
tx = pricedTransaction(0, 100000, common.Big2, keys[1])
|
||||||
if err := pool.addRemote(tx); err != nil { // +K1:0, -K1:1 => Pend K0:0, K0:1, K1:0, K2:0; Que -
|
if err := pool.addRemote(tx); err != nil { // +K1:0, -K1:1 => Pend K0:0, K0:1, K1:0, K2:0; Que -
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx = pricedTransaction(1, 100000, big.NewInt(3), keys[1])
|
tx = pricedTransaction(1, 100000, common.Big3, keys[1])
|
||||||
if err := pool.addRemoteSync(tx); err != nil { // +K1:2, -K0:1 => Pend K0:0 K1:0, K2:0; Que K1:2
|
if err := pool.addRemoteSync(tx); err != nil { // +K1:2, -K0:1 => Pend K0:0 K1:0, K2:0; Que K1:2
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
tx = dynamicFeeTx(2, 100000, big.NewInt(4), big.NewInt(1), keys[1])
|
tx = dynamicFeeTx(2, 100000, big.NewInt(4), common.Big1, keys[1])
|
||||||
if err := pool.addRemoteSync(tx); err != nil { // +K1:3, -K1:0 => Pend K0:0 K2:0; Que K1:2 K1:3
|
if err := pool.addRemoteSync(tx); err != nil { // +K1:3, -K1:0 => Pend K0:0 K2:0; Que K1:2 K1:3
|
||||||
t.Fatalf("failed to add well priced transaction: %v", err)
|
t.Fatalf("failed to add well priced transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -2006,11 +2006,11 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
||||||
t.Fatalf("pool internal state corrupted: %v", err)
|
t.Fatalf("pool internal state corrupted: %v", err)
|
||||||
}
|
}
|
||||||
// Ensure that adding local transactions can push out even higher priced ones
|
// Ensure that adding local transactions can push out even higher priced ones
|
||||||
ltx = dynamicFeeTx(1, 100000, big.NewInt(0), big.NewInt(0), keys[2])
|
ltx = dynamicFeeTx(1, 100000, common.Big0, common.Big0, keys[2])
|
||||||
if err := pool.addLocal(ltx); err != nil {
|
if err := pool.addLocal(ltx); err != nil {
|
||||||
t.Fatalf("failed to append underpriced local transaction: %v", err)
|
t.Fatalf("failed to append underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
ltx = dynamicFeeTx(0, 100000, big.NewInt(0), big.NewInt(0), keys[3])
|
ltx = dynamicFeeTx(0, 100000, common.Big0, common.Big0, keys[3])
|
||||||
if err := pool.addLocal(ltx); err != nil {
|
if err := pool.addLocal(ltx); err != nil {
|
||||||
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -2061,7 +2061,7 @@ func TestDualHeapEviction(t *testing.T) {
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
|
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
|
||||||
highTip = tx
|
highTip = tx
|
||||||
} else {
|
} else {
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), big.NewInt(1), key)
|
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), common.Big1, key)
|
||||||
highCap = tx
|
highCap = tx
|
||||||
}
|
}
|
||||||
pool.addRemotesSync([]*types.Transaction{tx})
|
pool.addRemotesSync([]*types.Transaction{tx})
|
||||||
|
|
@ -2105,7 +2105,7 @@ func TestDeduplication(t *testing.T) {
|
||||||
// Create a batch of transactions and add a few of them
|
// Create a batch of transactions and add a few of them
|
||||||
txs := make([]*types.Transaction, 16)
|
txs := make([]*types.Transaction, 16)
|
||||||
for i := 0; i < len(txs); i++ {
|
for i := 0; i < len(txs); i++ {
|
||||||
txs[i] = pricedTransaction(uint64(i), 100000, big.NewInt(1), key)
|
txs[i] = pricedTransaction(uint64(i), 100000, common.Big1, key)
|
||||||
}
|
}
|
||||||
var firsts []*types.Transaction
|
var firsts []*types.Transaction
|
||||||
for i := 0; i < len(txs); i += 2 {
|
for i := 0; i < len(txs); i += 2 {
|
||||||
|
|
@ -2178,13 +2178,13 @@ func TestReplacement(t *testing.T) {
|
||||||
price := int64(100)
|
price := int64(100)
|
||||||
threshold := (price * (100 + int64(testTxPoolConfig.PriceBump))) / 100
|
threshold := (price * (100 + int64(testTxPoolConfig.PriceBump))) / 100
|
||||||
|
|
||||||
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), key)); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(0, 100000, common.Big1, key)); err != nil {
|
||||||
t.Fatalf("failed to add original cheap pending transaction: %v", err)
|
t.Fatalf("failed to add original cheap pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(0, 100001, big.NewInt(1), key)); err != txpool.ErrReplaceUnderpriced {
|
if err := pool.addRemote(pricedTransaction(0, 100001, common.Big1, key)); err != txpool.ErrReplaceUnderpriced {
|
||||||
t.Fatalf("original cheap pending transaction replacement error mismatch: have %v, want %v", err, txpool.ErrReplaceUnderpriced)
|
t.Fatalf("original cheap pending transaction replacement error mismatch: have %v, want %v", err, txpool.ErrReplaceUnderpriced)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(0, 100000, big.NewInt(2), key)); err != nil {
|
if err := pool.addRemote(pricedTransaction(0, 100000, common.Big2, key)); err != nil {
|
||||||
t.Fatalf("failed to replace original cheap pending transaction: %v", err)
|
t.Fatalf("failed to replace original cheap pending transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := validateEvents(events, 2); err != nil {
|
if err := validateEvents(events, 2); err != nil {
|
||||||
|
|
@ -2205,13 +2205,13 @@ func TestReplacement(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add queued transactions, ensuring the minimum price bump is enforced for replacement (for ultra low prices too)
|
// Add queued transactions, ensuring the minimum price bump is enforced for replacement (for ultra low prices too)
|
||||||
if err := pool.addRemote(pricedTransaction(2, 100000, big.NewInt(1), key)); err != nil {
|
if err := pool.addRemote(pricedTransaction(2, 100000, common.Big1, key)); err != nil {
|
||||||
t.Fatalf("failed to add original cheap queued transaction: %v", err)
|
t.Fatalf("failed to add original cheap queued transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(2, 100001, big.NewInt(1), key)); err != txpool.ErrReplaceUnderpriced {
|
if err := pool.addRemote(pricedTransaction(2, 100001, common.Big1, key)); err != txpool.ErrReplaceUnderpriced {
|
||||||
t.Fatalf("original cheap queued transaction replacement error mismatch: have %v, want %v", err, txpool.ErrReplaceUnderpriced)
|
t.Fatalf("original cheap queued transaction replacement error mismatch: have %v, want %v", err, txpool.ErrReplaceUnderpriced)
|
||||||
}
|
}
|
||||||
if err := pool.addRemote(pricedTransaction(2, 100000, big.NewInt(2), key)); err != nil {
|
if err := pool.addRemote(pricedTransaction(2, 100000, common.Big2, key)); err != nil {
|
||||||
t.Fatalf("failed to replace original cheap queued transaction: %v", err)
|
t.Fatalf("failed to replace original cheap queued transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2276,17 +2276,17 @@ func TestReplacementDynamicFee(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Send initial tx => accept
|
// 1. Send initial tx => accept
|
||||||
tx := dynamicFeeTx(nonce, 100000, big.NewInt(2), big.NewInt(1), key)
|
tx := dynamicFeeTx(nonce, 100000, common.Big2, common.Big1, key)
|
||||||
if err := pool.addRemoteSync(tx); err != nil {
|
if err := pool.addRemoteSync(tx); err != nil {
|
||||||
t.Fatalf("failed to add original cheap %s transaction: %v", stage, err)
|
t.Fatalf("failed to add original cheap %s transaction: %v", stage, err)
|
||||||
}
|
}
|
||||||
// 2. Don't bump tip or feecap => discard
|
// 2. Don't bump tip or feecap => discard
|
||||||
tx = dynamicFeeTx(nonce, 100001, big.NewInt(2), big.NewInt(1), key)
|
tx = dynamicFeeTx(nonce, 100001, common.Big2, common.Big1, key)
|
||||||
if err := pool.addRemote(tx); err != txpool.ErrReplaceUnderpriced {
|
if err := pool.addRemote(tx); err != txpool.ErrReplaceUnderpriced {
|
||||||
t.Fatalf("original cheap %s transaction replacement error mismatch: have %v, want %v", stage, err, txpool.ErrReplaceUnderpriced)
|
t.Fatalf("original cheap %s transaction replacement error mismatch: have %v, want %v", stage, err, txpool.ErrReplaceUnderpriced)
|
||||||
}
|
}
|
||||||
// 3. Bump both more than min => accept
|
// 3. Bump both more than min => accept
|
||||||
tx = dynamicFeeTx(nonce, 100000, big.NewInt(3), big.NewInt(2), key)
|
tx = dynamicFeeTx(nonce, 100000, common.Big3, common.Big2, key)
|
||||||
if err := pool.addRemote(tx); err != nil {
|
if err := pool.addRemote(tx); err != nil {
|
||||||
t.Fatalf("failed to replace original cheap %s transaction: %v", stage, err)
|
t.Fatalf("failed to replace original cheap %s transaction: %v", stage, err)
|
||||||
}
|
}
|
||||||
|
|
@ -2383,16 +2383,16 @@ func testJournaling(t *testing.T, nolocals bool) {
|
||||||
testAddBalance(pool, crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(1000000000))
|
testAddBalance(pool, crypto.PubkeyToAddress(remote.PublicKey), big.NewInt(1000000000))
|
||||||
|
|
||||||
// Add three local and a remote transactions and ensure they are queued up
|
// Add three local and a remote transactions and ensure they are queued up
|
||||||
if err := pool.addLocal(pricedTransaction(0, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(0, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add local transaction: %v", err)
|
t.Fatalf("failed to add local transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addLocal(pricedTransaction(1, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(1, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add local transaction: %v", err)
|
t.Fatalf("failed to add local transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addLocal(pricedTransaction(2, 100000, big.NewInt(1), local)); err != nil {
|
if err := pool.addLocal(pricedTransaction(2, 100000, common.Big1, local)); err != nil {
|
||||||
t.Fatalf("failed to add local transaction: %v", err)
|
t.Fatalf("failed to add local transaction: %v", err)
|
||||||
}
|
}
|
||||||
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), remote)); err != nil {
|
if err := pool.addRemoteSync(pricedTransaction(0, 100000, common.Big1, remote)); err != nil {
|
||||||
t.Fatalf("failed to add remote transaction: %v", err)
|
t.Fatalf("failed to add remote transaction: %v", err)
|
||||||
}
|
}
|
||||||
pending, queued := pool.Stats()
|
pending, queued := pool.Stats()
|
||||||
|
|
@ -2481,10 +2481,10 @@ func TestStatusCheck(t *testing.T) {
|
||||||
// Generate and queue a batch of transactions, both pending and queued
|
// Generate and queue a batch of transactions, both pending and queued
|
||||||
txs := types.Transactions{}
|
txs := types.Transactions{}
|
||||||
|
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(1), keys[0])) // Pending only
|
txs = append(txs, pricedTransaction(0, 100000, common.Big1, keys[0])) // Pending only
|
||||||
txs = append(txs, pricedTransaction(0, 100000, big.NewInt(1), keys[1])) // Pending and queued
|
txs = append(txs, pricedTransaction(0, 100000, common.Big1, keys[1])) // Pending and queued
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(1), keys[1]))
|
txs = append(txs, pricedTransaction(2, 100000, common.Big1, keys[1]))
|
||||||
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(1), keys[2])) // Queued only
|
txs = append(txs, pricedTransaction(2, 100000, common.Big1, keys[2])) // Queued only
|
||||||
|
|
||||||
// Import the transaction and ensure they are correctly added
|
// Import the transaction and ensure they are correctly added
|
||||||
pool.addRemotesSync(txs)
|
pool.addRemotesSync(txs)
|
||||||
|
|
@ -2521,12 +2521,12 @@ func TestSlotCount(t *testing.T) {
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
|
|
||||||
// Check that an empty transaction consumes a single slot
|
// Check that an empty transaction consumes a single slot
|
||||||
smallTx := pricedDataTransaction(0, 0, big.NewInt(0), key, 0)
|
smallTx := pricedDataTransaction(0, 0, common.Big0, key, 0)
|
||||||
if slots := numSlots(smallTx); slots != 1 {
|
if slots := numSlots(smallTx); slots != 1 {
|
||||||
t.Fatalf("small transactions slot count mismatch: have %d want %d", slots, 1)
|
t.Fatalf("small transactions slot count mismatch: have %d want %d", slots, 1)
|
||||||
}
|
}
|
||||||
// Check that a large transaction consumes the correct number of slots
|
// Check that a large transaction consumes the correct number of slots
|
||||||
bigTx := pricedDataTransaction(0, 0, big.NewInt(0), key, uint64(10*txSlotSize))
|
bigTx := pricedDataTransaction(0, 0, common.Big0, key, uint64(10*txSlotSize))
|
||||||
if slots := numSlots(bigTx); slots != 11 {
|
if slots := numSlots(bigTx); slots != 11 {
|
||||||
t.Fatalf("big transactions slot count mismatch: have %d want %d", slots, 11)
|
t.Fatalf("big transactions slot count mismatch: have %d want %d", slots, 11)
|
||||||
}
|
}
|
||||||
|
|
@ -2631,7 +2631,7 @@ func BenchmarkInsertRemoteWithAllLocals(b *testing.B) {
|
||||||
}
|
}
|
||||||
remotes := make([]*types.Transaction, 1000)
|
remotes := make([]*types.Transaction, 1000)
|
||||||
for i := 0; i < len(remotes); i++ {
|
for i := 0; i < len(remotes); i++ {
|
||||||
remotes[i] = pricedTransaction(uint64(i), 100000, big.NewInt(2), remoteKey) // Higher gasprice
|
remotes[i] = pricedTransaction(uint64(i), 100000, common.Big2, remoteKey) // Higher gasprice
|
||||||
}
|
}
|
||||||
// Benchmark importing the transactions into the queue
|
// Benchmark importing the transactions into the queue
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
|
||||||
|
|
@ -104,17 +104,17 @@ func TestEIP1559BlockEncoding(t *testing.T) {
|
||||||
}}
|
}}
|
||||||
to := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
|
to := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
|
||||||
txdata := &DynamicFeeTx{
|
txdata := &DynamicFeeTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
To: &to,
|
To: &to,
|
||||||
Gas: 123457,
|
Gas: 123457,
|
||||||
GasFeeCap: new(big.Int).Set(block.BaseFee()),
|
GasFeeCap: new(big.Int).Set(block.BaseFee()),
|
||||||
GasTipCap: big.NewInt(0),
|
GasTipCap: common.Big0,
|
||||||
AccessList: accesses,
|
AccessList: accesses,
|
||||||
Data: []byte{},
|
Data: []byte{},
|
||||||
}
|
}
|
||||||
tx2 := NewTx(txdata)
|
tx2 := NewTx(txdata)
|
||||||
tx2, err := tx2.WithSignature(LatestSignerForChainID(big.NewInt(1)), common.Hex2Bytes("fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a800"))
|
tx2, err := tx2.WithSignature(LatestSignerForChainID(common.Big1), common.Hex2Bytes("fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a800"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("invalid signature error: ", err)
|
t.Fatal("invalid signature error: ", err)
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ func TestEIP2718BlockEncoding(t *testing.T) {
|
||||||
// Create ACL tx.
|
// Create ACL tx.
|
||||||
addr := common.HexToAddress("0x0000000000000000000000000000000000000001")
|
addr := common.HexToAddress("0x0000000000000000000000000000000000000001")
|
||||||
tx2 := NewTx(&AccessListTx{
|
tx2 := NewTx(&AccessListTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
To: &to,
|
To: &to,
|
||||||
Gas: 123457,
|
Gas: 123457,
|
||||||
|
|
@ -177,7 +177,7 @@ func TestEIP2718BlockEncoding(t *testing.T) {
|
||||||
AccessList: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}},
|
AccessList: AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}},
|
||||||
})
|
})
|
||||||
sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401")
|
sig2 := common.Hex2Bytes("3dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef1401")
|
||||||
tx2, _ = tx2.WithSignature(NewEIP2930Signer(big.NewInt(1)), sig2)
|
tx2, _ = tx2.WithSignature(NewEIP2930Signer(common.Big1), sig2)
|
||||||
|
|
||||||
check("len(Transactions)", len(block.Transactions()), 2)
|
check("len(Transactions)", len(block.Transactions()), 2)
|
||||||
check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash())
|
check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash())
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -93,8 +92,8 @@ func BenchmarkBloom9Lookup(b *testing.B) {
|
||||||
|
|
||||||
func BenchmarkCreateBloom(b *testing.B) {
|
func BenchmarkCreateBloom(b *testing.B) {
|
||||||
var txs = Transactions{
|
var txs = Transactions{
|
||||||
NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil),
|
NewContractCreation(1, common.Big1, 1, common.Big1, nil),
|
||||||
NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil),
|
NewTransaction(2, common.HexToAddress("0x2"), common.Big2, 2, common.Big2, nil),
|
||||||
}
|
}
|
||||||
var rSmall = Receipts{
|
var rSmall = Receipts{
|
||||||
&Receipt{
|
&Receipt{
|
||||||
|
|
|
||||||
|
|
@ -93,21 +93,21 @@ var (
|
||||||
txs = Transactions{
|
txs = Transactions{
|
||||||
NewTx(&LegacyTx{
|
NewTx(&LegacyTx{
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Gas: 1,
|
Gas: 1,
|
||||||
GasPrice: big.NewInt(11),
|
GasPrice: big.NewInt(11),
|
||||||
}),
|
}),
|
||||||
NewTx(&LegacyTx{
|
NewTx(&LegacyTx{
|
||||||
To: &to2,
|
To: &to2,
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
Value: big.NewInt(2),
|
Value: common.Big2,
|
||||||
Gas: 2,
|
Gas: 2,
|
||||||
GasPrice: big.NewInt(22),
|
GasPrice: big.NewInt(22),
|
||||||
}),
|
}),
|
||||||
NewTx(&AccessListTx{
|
NewTx(&AccessListTx{
|
||||||
To: &to3,
|
To: &to3,
|
||||||
Nonce: 3,
|
Nonce: 3,
|
||||||
Value: big.NewInt(3),
|
Value: common.Big3,
|
||||||
Gas: 3,
|
Gas: 3,
|
||||||
GasPrice: big.NewInt(33),
|
GasPrice: big.NewInt(33),
|
||||||
}),
|
}),
|
||||||
|
|
@ -151,7 +151,7 @@ var (
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
blockNumber = big.NewInt(1)
|
blockNumber = common.Big1
|
||||||
blockTime = uint64(2)
|
blockTime = uint64(2)
|
||||||
blockHash = common.BytesToHash([]byte{0x03, 0x14})
|
blockHash = common.BytesToHash([]byte{0x03, 0x14})
|
||||||
|
|
||||||
|
|
@ -508,7 +508,7 @@ func clearComputedFieldsOnReceipt(receipt *Receipt) *Receipt {
|
||||||
cpy.ContractAddress = common.Address{0xff, 0xff, 0x33}
|
cpy.ContractAddress = common.Address{0xff, 0xff, 0x33}
|
||||||
cpy.GasUsed = 0xffffffff
|
cpy.GasUsed = 0xffffffff
|
||||||
cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs)
|
cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs)
|
||||||
cpy.EffectiveGasPrice = big.NewInt(0)
|
cpy.EffectiveGasPrice = common.Big0
|
||||||
cpy.BlobGasUsed = 0
|
cpy.BlobGasUsed = 0
|
||||||
cpy.BlobGasPrice = nil
|
cpy.BlobGasPrice = nil
|
||||||
return &cpy
|
return &cpy
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ func NewEIP155Signer(chainId *big.Int) EIP155Signer {
|
||||||
}
|
}
|
||||||
return EIP155Signer{
|
return EIP155Signer{
|
||||||
chainId: chainId,
|
chainId: chainId,
|
||||||
chainIdMul: new(big.Int).Mul(chainId, big.NewInt(2)),
|
chainIdMul: new(big.Int).Mul(chainId, common.Big2),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,5 +580,5 @@ func deriveChainId(v *big.Int) *big.Int {
|
||||||
return new(big.Int).SetUint64((v - 35) / 2)
|
return new(big.Int).SetUint64((v - 35) / 2)
|
||||||
}
|
}
|
||||||
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, common.Big2)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ func TestEIP155SigningVitalik(t *testing.T) {
|
||||||
{"f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10", "0x9bddad43f934d313c2b79ca28a432dd2b7281029"},
|
{"f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10", "0x9bddad43f934d313c2b79ca28a432dd2b7281029"},
|
||||||
{"f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb", "0x3c24d7329e92f84f08556ceb6df1cdb0104ca49f"},
|
{"f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb", "0x3c24d7329e92f84f08556ceb6df1cdb0104ca49f"},
|
||||||
} {
|
} {
|
||||||
signer := NewEIP155Signer(big.NewInt(1))
|
signer := NewEIP155Signer(common.Big1)
|
||||||
|
|
||||||
var tx *Transaction
|
var tx *Transaction
|
||||||
err := rlp.DecodeBytes(common.Hex2Bytes(test.txRlp), &tx)
|
err := rlp.DecodeBytes(common.Hex2Bytes(test.txRlp), &tx)
|
||||||
|
|
@ -121,17 +121,17 @@ func TestChainId(t *testing.T) {
|
||||||
tx := NewTransaction(0, common.Address{}, new(big.Int), 0, new(big.Int), nil)
|
tx := NewTransaction(0, common.Address{}, new(big.Int), 0, new(big.Int), nil)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
tx, err = SignTx(tx, NewEIP155Signer(big.NewInt(1)), key)
|
tx, err = SignTx(tx, NewEIP155Signer(common.Big1), key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = Sender(NewEIP155Signer(big.NewInt(2)), tx)
|
_, err = Sender(NewEIP155Signer(common.Big2), tx)
|
||||||
if !errors.Is(err, ErrInvalidChainId) {
|
if !errors.Is(err, ErrInvalidChainId) {
|
||||||
t.Error("expected error:", ErrInvalidChainId, err)
|
t.Error("expected error:", ErrInvalidChainId, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = Sender(NewEIP155Signer(big.NewInt(1)), tx)
|
_, err = Sender(NewEIP155Signer(common.Big1), tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("expected no error")
|
t.Error("expected no error")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ var (
|
||||||
emptyTx = NewTransaction(
|
emptyTx = NewTransaction(
|
||||||
0,
|
0,
|
||||||
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
||||||
big.NewInt(0), 0, big.NewInt(0),
|
common.Big0, 0, common.Big0,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ var (
|
||||||
testAddr,
|
testAddr,
|
||||||
big.NewInt(10),
|
big.NewInt(10),
|
||||||
2000,
|
2000,
|
||||||
big.NewInt(1),
|
common.Big1,
|
||||||
common.FromHex("5544"),
|
common.FromHex("5544"),
|
||||||
).WithSignature(
|
).WithSignature(
|
||||||
HomesteadSigner{},
|
HomesteadSigner{},
|
||||||
|
|
@ -56,17 +56,17 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
emptyEip2718Tx = NewTx(&AccessListTx{
|
emptyEip2718Tx = NewTx(&AccessListTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: 3,
|
Nonce: 3,
|
||||||
To: &testAddr,
|
To: &testAddr,
|
||||||
Value: big.NewInt(10),
|
Value: big.NewInt(10),
|
||||||
Gas: 25000,
|
Gas: 25000,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: common.Big1,
|
||||||
Data: common.FromHex("5544"),
|
Data: common.FromHex("5544"),
|
||||||
})
|
})
|
||||||
|
|
||||||
signedEip2718Tx, _ = emptyEip2718Tx.WithSignature(
|
signedEip2718Tx, _ = emptyEip2718Tx.WithSignature(
|
||||||
NewEIP2930Signer(big.NewInt(1)),
|
NewEIP2930Signer(common.Big1),
|
||||||
common.Hex2Bytes("c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b266032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d3752101"),
|
common.Hex2Bytes("c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b266032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d3752101"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -102,7 +102,7 @@ func TestTransactionEncode(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEIP2718TransactionSigHash(t *testing.T) {
|
func TestEIP2718TransactionSigHash(t *testing.T) {
|
||||||
s := NewEIP2930Signer(big.NewInt(1))
|
s := NewEIP2930Signer(common.Big1)
|
||||||
if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") {
|
if s.Hash(emptyEip2718Tx) != common.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") {
|
||||||
t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx))
|
t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", s.Hash(emptyEip2718Tx))
|
||||||
}
|
}
|
||||||
|
|
@ -116,11 +116,11 @@ func TestEIP2930Signer(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
keyAddr = crypto.PubkeyToAddress(key.PublicKey)
|
keyAddr = crypto.PubkeyToAddress(key.PublicKey)
|
||||||
signer1 = NewEIP2930Signer(big.NewInt(1))
|
signer1 = NewEIP2930Signer(common.Big1)
|
||||||
signer2 = NewEIP2930Signer(big.NewInt(2))
|
signer2 = NewEIP2930Signer(common.Big2)
|
||||||
tx0 = NewTx(&AccessListTx{Nonce: 1})
|
tx0 = NewTx(&AccessListTx{Nonce: 1})
|
||||||
tx1 = NewTx(&AccessListTx{ChainID: big.NewInt(1), Nonce: 1})
|
tx1 = NewTx(&AccessListTx{ChainID: common.Big1, Nonce: 1})
|
||||||
tx2, _ = SignNewTx(key, signer2, &AccessListTx{ChainID: big.NewInt(2), Nonce: 1})
|
tx2, _ = SignNewTx(key, signer2, &AccessListTx{ChainID: common.Big2, Nonce: 1})
|
||||||
)
|
)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
@ -278,7 +278,7 @@ func TestTransactionCoding(t *testing.T) {
|
||||||
Nonce: i,
|
Nonce: i,
|
||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 1,
|
Gas: 1,
|
||||||
GasPrice: big.NewInt(2),
|
GasPrice: common.Big2,
|
||||||
Data: []byte("abcdef"),
|
Data: []byte("abcdef"),
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -286,13 +286,13 @@ func TestTransactionCoding(t *testing.T) {
|
||||||
txdata = &LegacyTx{
|
txdata = &LegacyTx{
|
||||||
Nonce: i,
|
Nonce: i,
|
||||||
Gas: 1,
|
Gas: 1,
|
||||||
GasPrice: big.NewInt(2),
|
GasPrice: common.Big2,
|
||||||
Data: []byte("abcdef"),
|
Data: []byte("abcdef"),
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
// Tx with non-zero access list.
|
// Tx with non-zero access list.
|
||||||
txdata = &AccessListTx{
|
txdata = &AccessListTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: i,
|
Nonce: i,
|
||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 123457,
|
Gas: 123457,
|
||||||
|
|
@ -303,7 +303,7 @@ func TestTransactionCoding(t *testing.T) {
|
||||||
case 3:
|
case 3:
|
||||||
// Tx with empty access list.
|
// Tx with empty access list.
|
||||||
txdata = &AccessListTx{
|
txdata = &AccessListTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: i,
|
Nonce: i,
|
||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 123457,
|
Gas: 123457,
|
||||||
|
|
@ -313,7 +313,7 @@ func TestTransactionCoding(t *testing.T) {
|
||||||
case 4:
|
case 4:
|
||||||
// Contract creation with access list.
|
// Contract creation with access list.
|
||||||
txdata = &AccessListTx{
|
txdata = &AccessListTx{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
Nonce: i,
|
Nonce: i,
|
||||||
Gas: 123457,
|
Gas: 123457,
|
||||||
GasPrice: big.NewInt(10),
|
GasPrice: big.NewInt(10),
|
||||||
|
|
@ -402,7 +402,7 @@ func TestTransactionSizes(t *testing.T) {
|
||||||
GasPrice: big.NewInt(500),
|
GasPrice: big.NewInt(500),
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
},
|
},
|
||||||
&AccessListTx{
|
&AccessListTx{
|
||||||
ChainID: big.NewInt(123),
|
ChainID: big.NewInt(123),
|
||||||
|
|
@ -410,7 +410,7 @@ func TestTransactionSizes(t *testing.T) {
|
||||||
GasPrice: big.NewInt(500),
|
GasPrice: big.NewInt(500),
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
AccessList: AccessList{
|
AccessList: AccessList{
|
||||||
AccessTuple{
|
AccessTuple{
|
||||||
Address: common.HexToAddress("0x01"),
|
Address: common.HexToAddress("0x01"),
|
||||||
|
|
@ -422,7 +422,7 @@ func TestTransactionSizes(t *testing.T) {
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
GasTipCap: big.NewInt(500),
|
GasTipCap: big.NewInt(500),
|
||||||
GasFeeCap: big.NewInt(500),
|
GasFeeCap: big.NewInt(500),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ func benchRLP(b *testing.B, encode bool) {
|
||||||
GasPrice: big.NewInt(500),
|
GasPrice: big.NewInt(500),
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +106,7 @@ func benchRLP(b *testing.B, encode bool) {
|
||||||
GasPrice: big.NewInt(500),
|
GasPrice: big.NewInt(500),
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +116,7 @@ func benchRLP(b *testing.B, encode bool) {
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Gas: 1000000,
|
Gas: 1000000,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
GasTipCap: big.NewInt(500),
|
GasTipCap: big.NewInt(500),
|
||||||
GasFeeCap: big.NewInt(500),
|
GasFeeCap: big.NewInt(500),
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -267,15 +267,15 @@ type bigModExp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
big0 = big.NewInt(0)
|
big0 = common.Big0
|
||||||
big1 = big.NewInt(1)
|
big1 = common.Big1
|
||||||
big3 = big.NewInt(3)
|
big3 = common.Big3
|
||||||
big4 = big.NewInt(4)
|
big4 = big.NewInt(4)
|
||||||
big7 = big.NewInt(7)
|
big7 = big.NewInt(7)
|
||||||
big8 = big.NewInt(8)
|
big8 = big.NewInt(8)
|
||||||
big16 = big.NewInt(16)
|
big16 = big.NewInt(16)
|
||||||
big20 = big.NewInt(20)
|
big20 = big.NewInt(20)
|
||||||
big32 = big.NewInt(32)
|
big32 = common.Big32
|
||||||
big64 = big.NewInt(64)
|
big64 = big.NewInt(64)
|
||||||
big96 = big.NewInt(96)
|
big96 = big.NewInt(96)
|
||||||
big480 = big.NewInt(480)
|
big480 = big.NewInt(480)
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ func TestCreateGas(t *testing.T) {
|
||||||
vmctx := BlockContext{
|
vmctx := BlockContext{
|
||||||
CanTransfer: func(StateDB, common.Address, *big.Int) bool { return true },
|
CanTransfer: func(StateDB, common.Address, *big.Int) bool { return true },
|
||||||
Transfer: func(StateDB, common.Address, common.Address, *big.Int) {},
|
Transfer: func(StateDB, common.Address, common.Address, *big.Int) {},
|
||||||
BlockNumber: big.NewInt(0),
|
BlockNumber: common.Big0,
|
||||||
}
|
}
|
||||||
config := Config{}
|
config := Config{}
|
||||||
if tt.eip3860 {
|
if tt.eip3860 {
|
||||||
|
|
|
||||||
|
|
@ -704,8 +704,8 @@ func TestCreate2Addreses(t *testing.T) {
|
||||||
stack := newstack()
|
stack := newstack()
|
||||||
// salt, but we don't need that for this test
|
// salt, but we don't need that for this test
|
||||||
stack.push(big.NewInt(int64(len(code)))) //size
|
stack.push(big.NewInt(int64(len(code)))) //size
|
||||||
stack.push(big.NewInt(0)) // memstart
|
stack.push(common.Big0) // memstart
|
||||||
stack.push(big.NewInt(0)) // value
|
stack.push(common.Big0) // value
|
||||||
gas, _ := gasCreate2(params.GasTable{}, nil, nil, stack, nil, 0)
|
gas, _ := gasCreate2(params.GasTable{}, nil, nil, stack, nil, 0)
|
||||||
fmt.Printf("Example %d\n* address `0x%x`\n* salt `0x%x`\n* init_code `0x%x`\n* gas (assuming no mem expansion): `%v`\n* result: `%s`\n\n", i,origin, salt, code, gas, address.String())
|
fmt.Printf("Example %d\n* address `0x%x`\n* salt `0x%x`\n* init_code `0x%x`\n* gas (assuming no mem expansion): `%v`\n* result: `%s`\n\n", i,origin, salt, code, gas, address.String())
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ type Config struct {
|
||||||
func setDefaults(cfg *Config) {
|
func setDefaults(cfg *Config) {
|
||||||
if cfg.ChainConfig == nil {
|
if cfg.ChainConfig == nil {
|
||||||
cfg.ChainConfig = ¶ms.ChainConfig{
|
cfg.ChainConfig = ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: new(big.Int),
|
HomesteadBlock: new(big.Int),
|
||||||
DAOForkBlock: new(big.Int),
|
DAOForkBlock: new(big.Int),
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ func benchmarkEVM_Create(bench *testing.B, code string) {
|
||||||
Coinbase: common.Address{},
|
Coinbase: common.Address{},
|
||||||
BlockNumber: new(big.Int).SetUint64(1),
|
BlockNumber: new(big.Int).SetUint64(1),
|
||||||
ChainConfig: ¶ms.ChainConfig{
|
ChainConfig: ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: new(big.Int),
|
HomesteadBlock: new(big.Int),
|
||||||
ByzantiumBlock: new(big.Int),
|
ByzantiumBlock: new(big.Int),
|
||||||
ConstantinopleBlock: new(big.Int),
|
ConstantinopleBlock: new(big.Int),
|
||||||
|
|
@ -220,7 +220,7 @@ func fakeHeader(n uint64, parentHash common.Hash) *types.Header {
|
||||||
Time: 1000,
|
Time: 1000,
|
||||||
Nonce: types.BlockNonce{0x1},
|
Nonce: types.BlockNonce{0x1},
|
||||||
Extra: []byte{},
|
Extra: []byte{},
|
||||||
Difficulty: big.NewInt(0),
|
Difficulty: common.Big0,
|
||||||
GasLimit: 100000,
|
GasLimit: 100000,
|
||||||
}
|
}
|
||||||
return &header
|
return &header
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package bls12381
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"math/big"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ func TestFieldElementValidation(t *testing.T) {
|
||||||
t.Fatal("modulus must be invalid")
|
t.Fatal("modulus must be invalid")
|
||||||
}
|
}
|
||||||
n := modulus.big()
|
n := modulus.big()
|
||||||
n.Add(n, big.NewInt(1))
|
n.Add(n, common.Big1)
|
||||||
if new(fe).setBig(n).isValid() {
|
if new(fe).setBig(n).isValid() {
|
||||||
t.Fatal("number greater than modulus must be invalid")
|
t.Fatal("number greater than modulus must be invalid")
|
||||||
}
|
}
|
||||||
|
|
@ -114,14 +114,14 @@ func TestFieldElementHelpers(t *testing.T) {
|
||||||
if !one.isOne() {
|
if !one.isOne() {
|
||||||
t.Fatal("'one' is not one")
|
t.Fatal("'one' is not one")
|
||||||
}
|
}
|
||||||
odd := new(fe).setBig(big.NewInt(1))
|
odd := new(fe).setBig(common.Big1)
|
||||||
if !odd.isOdd() {
|
if !odd.isOdd() {
|
||||||
t.Fatal("1 must be odd")
|
t.Fatal("1 must be odd")
|
||||||
}
|
}
|
||||||
if odd.isEven() {
|
if odd.isEven() {
|
||||||
t.Fatal("1 must not be even")
|
t.Fatal("1 must not be even")
|
||||||
}
|
}
|
||||||
even := new(fe).setBig(big.NewInt(2))
|
even := new(fe).setBig(common.Big2)
|
||||||
if !even.isEven() {
|
if !even.isEven() {
|
||||||
t.Fatal("2 must be even")
|
t.Fatal("2 must be even")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFpSerialization(t *testing.T) {
|
func TestFpSerialization(t *testing.T) {
|
||||||
|
|
@ -363,11 +365,11 @@ func TestFpExponentiation(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a, _ := new(fe).rand(rand.Reader)
|
a, _ := new(fe).rand(rand.Reader)
|
||||||
u := new(fe)
|
u := new(fe)
|
||||||
exp(u, a, big.NewInt(0))
|
exp(u, a, common.Big0)
|
||||||
if !u.isOne() {
|
if !u.isOne() {
|
||||||
t.Fatal("a^0 == 1")
|
t.Fatal("a^0 == 1")
|
||||||
}
|
}
|
||||||
exp(u, a, big.NewInt(1))
|
exp(u, a, common.Big1)
|
||||||
if !u.equal(a) {
|
if !u.equal(a) {
|
||||||
t.Fatal("a^1 == a")
|
t.Fatal("a^1 == a")
|
||||||
}
|
}
|
||||||
|
|
@ -384,7 +386,7 @@ func TestFpExponentiation(t *testing.T) {
|
||||||
if !u.equal(a) {
|
if !u.equal(a) {
|
||||||
t.Fatal("a^p == a")
|
t.Fatal("a^p == a")
|
||||||
}
|
}
|
||||||
exp(u, a, p.Sub(p, big.NewInt(1)))
|
exp(u, a, p.Sub(p, common.Big1))
|
||||||
if !u.isOne() {
|
if !u.isOne() {
|
||||||
t.Fatal("a^(p-1) == 1")
|
t.Fatal("a^(p-1) == 1")
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +413,7 @@ func TestFpInversion(t *testing.T) {
|
||||||
}
|
}
|
||||||
v := new(fe)
|
v := new(fe)
|
||||||
p := modulus.big()
|
p := modulus.big()
|
||||||
exp(u, a, p.Sub(p, big.NewInt(2)))
|
exp(u, a, p.Sub(p, common.Big2))
|
||||||
inverse(v, a)
|
inverse(v, a)
|
||||||
if !v.equal(u) {
|
if !v.equal(u) {
|
||||||
t.Fatal("a^(p-2) == a^-1")
|
t.Fatal("a^(p-2) == a^-1")
|
||||||
|
|
@ -738,11 +740,11 @@ func TestFp2Exponentiation(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a, _ := new(fe2).rand(rand.Reader)
|
a, _ := new(fe2).rand(rand.Reader)
|
||||||
u := field.new()
|
u := field.new()
|
||||||
field.exp(u, a, big.NewInt(0))
|
field.exp(u, a, common.Big0)
|
||||||
if !u.equal(field.one()) {
|
if !u.equal(field.one()) {
|
||||||
t.Fatal("a^0 == 1")
|
t.Fatal("a^0 == 1")
|
||||||
}
|
}
|
||||||
field.exp(u, a, big.NewInt(1))
|
field.exp(u, a, common.Big1)
|
||||||
if !u.equal(a) {
|
if !u.equal(a) {
|
||||||
t.Fatal("a^1 == a")
|
t.Fatal("a^1 == a")
|
||||||
}
|
}
|
||||||
|
|
@ -1117,11 +1119,11 @@ func TestFp6Exponentiation(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a, _ := new(fe6).rand(rand.Reader)
|
a, _ := new(fe6).rand(rand.Reader)
|
||||||
u := field.new()
|
u := field.new()
|
||||||
field.exp(u, a, big.NewInt(0))
|
field.exp(u, a, common.Big0)
|
||||||
if !u.equal(field.one()) {
|
if !u.equal(field.one()) {
|
||||||
t.Fatal("a^0 == 1")
|
t.Fatal("a^0 == 1")
|
||||||
}
|
}
|
||||||
field.exp(u, a, big.NewInt(1))
|
field.exp(u, a, common.Big1)
|
||||||
if !u.equal(a) {
|
if !u.equal(a) {
|
||||||
t.Fatal("a^1 == a")
|
t.Fatal("a^1 == a")
|
||||||
}
|
}
|
||||||
|
|
@ -1340,11 +1342,11 @@ func TestFp12Exponentiation(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a, _ := new(fe12).rand(rand.Reader)
|
a, _ := new(fe12).rand(rand.Reader)
|
||||||
u := field.new()
|
u := field.new()
|
||||||
field.exp(u, a, big.NewInt(0))
|
field.exp(u, a, common.Big0)
|
||||||
if !u.equal(field.one()) {
|
if !u.equal(field.one()) {
|
||||||
t.Fatal("a^0 == 1")
|
t.Fatal("a^0 == 1")
|
||||||
}
|
}
|
||||||
field.exp(u, a, big.NewInt(1))
|
field.exp(u, a, common.Big1)
|
||||||
if !u.equal(a) {
|
if !u.equal(a) {
|
||||||
t.Fatal("a^1 == a")
|
t.Fatal("a^1 == a")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func TestG1MultiplicativeProperties(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a := g.rand()
|
a := g.rand()
|
||||||
s1, s2, s3 := randScalar(q), randScalar(q), randScalar(q)
|
s1, s2, s3 := randScalar(q), randScalar(q), randScalar(q)
|
||||||
sone := big.NewInt(1)
|
sone := common.Big1
|
||||||
g.MulScalar(t0, zero, s1)
|
g.MulScalar(t0, zero, s1)
|
||||||
if !g.Equal(t0, zero) {
|
if !g.Equal(t0, zero) {
|
||||||
t.Fatal(" 0 ^ s == 0")
|
t.Fatal(" 0 ^ s == 0")
|
||||||
|
|
@ -178,8 +178,8 @@ func TestG1MultiExpExpected(t *testing.T) {
|
||||||
one := g.one()
|
one := g.one()
|
||||||
var scalars [2]*big.Int
|
var scalars [2]*big.Int
|
||||||
var bases [2]*PointG1
|
var bases [2]*PointG1
|
||||||
scalars[0] = big.NewInt(2)
|
scalars[0] = common.Big2
|
||||||
scalars[1] = big.NewInt(3)
|
scalars[1] = common.Big3
|
||||||
bases[0], bases[1] = new(PointG1).Set(one), new(PointG1).Set(one)
|
bases[0], bases[1] = new(PointG1).Set(one), new(PointG1).Set(one)
|
||||||
expected, result := g.New(), g.New()
|
expected, result := g.New(), g.New()
|
||||||
g.MulScalar(expected, one, big.NewInt(5))
|
g.MulScalar(expected, one, big.NewInt(5))
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ func TestG2MultiplicativeProperties(t *testing.T) {
|
||||||
for i := 0; i < fuz; i++ {
|
for i := 0; i < fuz; i++ {
|
||||||
a := g.rand()
|
a := g.rand()
|
||||||
s1, s2, s3 := randScalar(q), randScalar(q), randScalar(q)
|
s1, s2, s3 := randScalar(q), randScalar(q), randScalar(q)
|
||||||
sone := big.NewInt(1)
|
sone := common.Big1
|
||||||
g.MulScalar(t0, zero, s1)
|
g.MulScalar(t0, zero, s1)
|
||||||
if !g.Equal(t0, zero) {
|
if !g.Equal(t0, zero) {
|
||||||
t.Fatal(" 0 ^ s == 0")
|
t.Fatal(" 0 ^ s == 0")
|
||||||
|
|
@ -181,8 +181,8 @@ func TestG2MultiExpExpected(t *testing.T) {
|
||||||
one := g.one()
|
one := g.one()
|
||||||
var scalars [2]*big.Int
|
var scalars [2]*big.Int
|
||||||
var bases [2]*PointG2
|
var bases [2]*PointG2
|
||||||
scalars[0] = big.NewInt(2)
|
scalars[0] = common.Big2
|
||||||
scalars[1] = big.NewInt(3)
|
scalars[1] = common.Big3
|
||||||
bases[0], bases[1] = new(PointG2).Set(one), new(PointG2).Set(one)
|
bases[0], bases[1] = new(PointG2).Set(one), new(PointG2).Set(one)
|
||||||
expected, result := g.New(), g.New()
|
expected, result := g.New(), g.New()
|
||||||
g.MulScalar(expected, one, big.NewInt(5))
|
g.MulScalar(expected, one, big.NewInt(5))
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package bn256
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var half = new(big.Int).Rsh(Order, 1)
|
var half = new(big.Int).Rsh(Order, 1)
|
||||||
|
|
@ -110,6 +112,6 @@ func round(num, denom *big.Int) {
|
||||||
num.DivMod(num, denom, r)
|
num.DivMod(num, denom, r)
|
||||||
|
|
||||||
if r.Cmp(half) == 1 {
|
if r.Cmp(half) == 1 {
|
||||||
num.Add(num, big.NewInt(1))
|
num.Add(num, common.Big1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ const DigestLength = 32
|
||||||
|
|
||||||
var (
|
var (
|
||||||
secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
|
secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
|
||||||
secp256k1halfN = new(big.Int).Div(secp256k1N, big.NewInt(2))
|
secp256k1halfN = new(big.Int).Div(secp256k1N, common.Big2)
|
||||||
)
|
)
|
||||||
|
|
||||||
var errInvalidPubkey = errors.New("invalid secp256k1 public key")
|
var errInvalidPubkey = errors.New("invalid secp256k1 public key")
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ package secp256k1
|
||||||
import (
|
import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -224,12 +226,12 @@ func (BitCurve *BitCurve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int,
|
||||||
d.Mul(d, d) //(X1+B)²
|
d.Mul(d, d) //(X1+B)²
|
||||||
d.Sub(d, a) //(X1+B)²-A
|
d.Sub(d, a) //(X1+B)²-A
|
||||||
d.Sub(d, c) //(X1+B)²-A-C
|
d.Sub(d, c) //(X1+B)²-A-C
|
||||||
d.Mul(d, big.NewInt(2)) //2*((X1+B)²-A-C)
|
d.Mul(d, common.Big2) //2*((X1+B)²-A-C)
|
||||||
|
|
||||||
e := new(big.Int).Mul(big.NewInt(3), a) //3*A
|
e := new(big.Int).Mul(common.Big3, a) //3*A
|
||||||
f := new(big.Int).Mul(e, e) //E²
|
f := new(big.Int).Mul(e, e) //E²
|
||||||
|
|
||||||
x3 := new(big.Int).Mul(big.NewInt(2), d) //2*D
|
x3 := new(big.Int).Mul(common.Big2, d) //2*D
|
||||||
x3.Sub(f, x3) //F-2*D
|
x3.Sub(f, x3) //F-2*D
|
||||||
x3.Mod(x3, BitCurve.P)
|
x3.Mod(x3, BitCurve.P)
|
||||||
|
|
||||||
|
|
@ -239,7 +241,7 @@ func (BitCurve *BitCurve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int,
|
||||||
y3.Mod(y3, BitCurve.P)
|
y3.Mod(y3, BitCurve.P)
|
||||||
|
|
||||||
z3 := new(big.Int).Mul(y, z) //Y1*Z1
|
z3 := new(big.Int).Mul(y, z) //Y1*Z1
|
||||||
z3.Mul(big.NewInt(2), z3) //3*Y1*Z1
|
z3.Mul(common.Big2, z3) //3*Y1*Z1
|
||||||
z3.Mod(z3, BitCurve.P)
|
z3.Mod(z3, BitCurve.P)
|
||||||
|
|
||||||
return x3, y3, z3
|
return x3, y3, z3
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package eth
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -72,7 +71,7 @@ func TestAccountRange(t *testing.T) {
|
||||||
hash := common.HexToHash(fmt.Sprintf("%x", i))
|
hash := common.HexToHash(fmt.Sprintf("%x", i))
|
||||||
addr := common.BytesToAddress(crypto.Keccak256Hash(hash.Bytes()).Bytes())
|
addr := common.BytesToAddress(crypto.Keccak256Hash(hash.Bytes()).Bytes())
|
||||||
addrs[i] = addr
|
addrs[i] = addr
|
||||||
sdb.SetBalance(addrs[i], big.NewInt(1))
|
sdb.SetBalance(addrs[i], common.Big1)
|
||||||
if _, ok := m[addr]; ok {
|
if _, ok := m[addr]; ok {
|
||||||
t.Fatalf("bad")
|
t.Fatalf("bad")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -78,20 +78,20 @@ func generateMergeChain(n int, merged bool) (*core.Genesis, []*types.Block) {
|
||||||
ExtraData: []byte("test genesis"),
|
ExtraData: []byte("test genesis"),
|
||||||
Timestamp: 9000,
|
Timestamp: 9000,
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Difficulty: big.NewInt(0),
|
Difficulty: common.Big0,
|
||||||
}
|
}
|
||||||
testNonce := uint64(0)
|
testNonce := uint64(0)
|
||||||
generate := func(i int, g *core.BlockGen) {
|
generate := func(i int, g *core.BlockGen) {
|
||||||
g.OffsetTime(5)
|
g.OffsetTime(5)
|
||||||
g.SetExtra([]byte("test"))
|
g.SetExtra([]byte("test"))
|
||||||
tx, _ := types.SignTx(types.NewTransaction(testNonce, common.HexToAddress("0x9a9070028361F7AAbeB3f2F2Dc07F82C4a98A02a"), big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil), types.LatestSigner(&config), testKey)
|
tx, _ := types.SignTx(types.NewTransaction(testNonce, common.HexToAddress("0x9a9070028361F7AAbeB3f2F2Dc07F82C4a98A02a"), common.Big1, params.TxGas, big.NewInt(params.InitialBaseFee*2), nil), types.LatestSigner(&config), testKey)
|
||||||
g.AddTx(tx)
|
g.AddTx(tx)
|
||||||
testNonce++
|
testNonce++
|
||||||
}
|
}
|
||||||
_, blocks, _ := core.GenerateChainWithGenesis(genesis, engine, n, generate)
|
_, blocks, _ := core.GenerateChainWithGenesis(genesis, engine, n, generate)
|
||||||
|
|
||||||
if !merged {
|
if !merged {
|
||||||
totalDifficulty := big.NewInt(0)
|
totalDifficulty := common.Big0
|
||||||
for _, b := range blocks {
|
for _, b := range blocks {
|
||||||
totalDifficulty.Add(totalDifficulty, b.Difficulty())
|
totalDifficulty.Add(totalDifficulty, b.Difficulty())
|
||||||
}
|
}
|
||||||
|
|
@ -533,7 +533,7 @@ func TestExchangeTransitionConfig(t *testing.T) {
|
||||||
// invalid ttd
|
// invalid ttd
|
||||||
api := NewConsensusAPI(ethservice)
|
api := NewConsensusAPI(ethservice)
|
||||||
config := engine.TransitionConfigurationV1{
|
config := engine.TransitionConfigurationV1{
|
||||||
TerminalTotalDifficulty: (*hexutil.Big)(big.NewInt(0)),
|
TerminalTotalDifficulty: (*hexutil.Big)(common.Big0),
|
||||||
TerminalBlockHash: common.Hash{},
|
TerminalBlockHash: common.Hash{},
|
||||||
TerminalBlockNumber: 0,
|
TerminalBlockNumber: 0,
|
||||||
}
|
}
|
||||||
|
|
@ -761,7 +761,7 @@ func getNewPayload(t *testing.T, api *ConsensusAPI, parent *types.Header, withdr
|
||||||
// Can be used to make modified payloads look valid.
|
// Can be used to make modified payloads look valid.
|
||||||
func setBlockhash(data *engine.ExecutableData) *engine.ExecutableData {
|
func setBlockhash(data *engine.ExecutableData) *engine.ExecutableData {
|
||||||
txs, _ := decodeTransactions(data.Transactions)
|
txs, _ := decodeTransactions(data.Transactions)
|
||||||
number := big.NewInt(0)
|
number := common.Big0
|
||||||
number.SetUint64(data.Number)
|
number.SetUint64(data.Number)
|
||||||
header := &types.Header{
|
header := &types.Header{
|
||||||
ParentHash: data.ParentHash,
|
ParentHash: data.ParentHash,
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func TestSimulatedBeaconSendWithdrawals(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure all withdrawals/txs included. this will take two blocks b/c number of withdrawals > 10
|
// ensure all withdrawals/txs included. this will take two blocks b/c number of withdrawals > 10
|
||||||
if len(includedTxs) == len(txs) && len(includedWithdrawals) == len(withdrawals) && evt.Block.Number().Cmp(big.NewInt(2)) == 0 {
|
if len(includedTxs) == len(txs) && len(includedWithdrawals) == len(withdrawals) && evt.Block.Number().Cmp(common.Big2) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ func (p *skeletonTestPeer) RequestReceipts([]common.Hash, chan *eth.Response) (*
|
||||||
func TestSkeletonSyncInit(t *testing.T) {
|
func TestSkeletonSyncInit(t *testing.T) {
|
||||||
// Create a few key headers
|
// Create a few key headers
|
||||||
var (
|
var (
|
||||||
genesis = &types.Header{Number: big.NewInt(0)}
|
genesis = &types.Header{Number: common.Big0}
|
||||||
block49 = &types.Header{Number: big.NewInt(49)}
|
block49 = &types.Header{Number: big.NewInt(49)}
|
||||||
block49B = &types.Header{Number: big.NewInt(49), Extra: []byte("B")}
|
block49B = &types.Header{Number: big.NewInt(49), Extra: []byte("B")}
|
||||||
block50 = &types.Header{Number: big.NewInt(50), ParentHash: block49.Hash()}
|
block50 = &types.Header{Number: big.NewInt(50), ParentHash: block49.Hash()}
|
||||||
|
|
@ -399,7 +399,7 @@ func TestSkeletonSyncInit(t *testing.T) {
|
||||||
func TestSkeletonSyncExtend(t *testing.T) {
|
func TestSkeletonSyncExtend(t *testing.T) {
|
||||||
// Create a few key headers
|
// Create a few key headers
|
||||||
var (
|
var (
|
||||||
genesis = &types.Header{Number: big.NewInt(0)}
|
genesis = &types.Header{Number: common.Big0}
|
||||||
block49 = &types.Header{Number: big.NewInt(49)}
|
block49 = &types.Header{Number: big.NewInt(49)}
|
||||||
block49B = &types.Header{Number: big.NewInt(49), Extra: []byte("B")}
|
block49B = &types.Header{Number: big.NewInt(49), Extra: []byte("B")}
|
||||||
block50 = &types.Header{Number: big.NewInt(50), ParentHash: block49.Hash()}
|
block50 = &types.Header{Number: big.NewInt(50), ParentHash: block49.Hash()}
|
||||||
|
|
@ -518,7 +518,7 @@ func TestSkeletonSyncRetrievals(t *testing.T) {
|
||||||
|
|
||||||
// Since skeleton headers don't need to be meaningful, beyond a parent hash
|
// Since skeleton headers don't need to be meaningful, beyond a parent hash
|
||||||
// progression, create a long fake chain to test with.
|
// progression, create a long fake chain to test with.
|
||||||
chain := []*types.Header{{Number: big.NewInt(0)}}
|
chain := []*types.Header{{Number: common.Big0}}
|
||||||
for i := 1; i < 10000; i++ {
|
for i := 1; i < 10000; i++ {
|
||||||
chain = append(chain, &types.Header{
|
chain = append(chain, &types.Header{
|
||||||
ParentHash: chain[i-1].Hash(),
|
ParentHash: chain[i-1].Hash(),
|
||||||
|
|
|
||||||
|
|
@ -373,13 +373,13 @@ func TestLogFilterCreation(t *testing.T) {
|
||||||
// defaults
|
// defaults
|
||||||
{FilterCriteria{}, true},
|
{FilterCriteria{}, true},
|
||||||
// valid block number range
|
// valid block number range
|
||||||
{FilterCriteria{FromBlock: big.NewInt(1), ToBlock: big.NewInt(2)}, true},
|
{FilterCriteria{FromBlock: common.Big1, ToBlock: common.Big2}, true},
|
||||||
// "mined" block range to pending
|
// "mined" block range to pending
|
||||||
{FilterCriteria{FromBlock: big.NewInt(1), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, true},
|
{FilterCriteria{FromBlock: common.Big1, ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, true},
|
||||||
// new mined and pending blocks
|
// new mined and pending blocks
|
||||||
{FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, true},
|
{FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, true},
|
||||||
// from block "higher" than to block
|
// from block "higher" than to block
|
||||||
{FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(1)}, false},
|
{FilterCriteria{FromBlock: common.Big2, ToBlock: common.Big1}, false},
|
||||||
// from block "higher" than to block
|
// from block "higher" than to block
|
||||||
{FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(100)}, false},
|
{FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(100)}, false},
|
||||||
// from block "higher" than to block
|
// from block "higher" than to block
|
||||||
|
|
@ -468,7 +468,7 @@ func TestInvalidGetRangeLogsRequest(t *testing.T) {
|
||||||
api = NewFilterAPI(sys, false)
|
api = NewFilterAPI(sys, false)
|
||||||
)
|
)
|
||||||
|
|
||||||
if _, err := api.GetLogs(context.Background(), FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(1)}); err != errInvalidBlockRange {
|
if _, err := api.GetLogs(context.Background(), FilterCriteria{FromBlock: common.Big2, ToBlock: common.Big1}); err != errInvalidBlockRange {
|
||||||
t.Errorf("Expected Logs for invalid range return error, but got: %v", err)
|
t.Errorf("Expected Logs for invalid range return error, but got: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -522,13 +522,13 @@ func TestLogFilter(t *testing.T) {
|
||||||
// logs in the pending block
|
// logs in the pending block
|
||||||
6: {FilterCriteria{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, allLogs[:2], ""},
|
6: {FilterCriteria{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, allLogs[:2], ""},
|
||||||
// mined logs with block num >= 2 or pending logs
|
// mined logs with block num >= 2 or pending logs
|
||||||
7: {FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, expectedCase7, ""},
|
7: {FilterCriteria{FromBlock: common.Big2, ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, expectedCase7, ""},
|
||||||
// all "mined" logs with block num >= 2
|
// all "mined" logs with block num >= 2
|
||||||
8: {FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, allLogs[3:], ""},
|
8: {FilterCriteria{FromBlock: common.Big2, ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, allLogs[3:], ""},
|
||||||
// all "mined" logs
|
// all "mined" logs
|
||||||
9: {FilterCriteria{ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, allLogs, ""},
|
9: {FilterCriteria{ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, allLogs, ""},
|
||||||
// all "mined" logs with 1>= block num <=2 and topic secondTopic
|
// all "mined" logs with 1>= block num <=2 and topic secondTopic
|
||||||
10: {FilterCriteria{FromBlock: big.NewInt(1), ToBlock: big.NewInt(2), Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""},
|
10: {FilterCriteria{FromBlock: common.Big1, ToBlock: common.Big2, Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""},
|
||||||
// all "mined" and pending logs with topic firstTopic
|
// all "mined" and pending logs with topic firstTopic
|
||||||
11: {FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), Topics: [][]common.Hash{{firstTopic}}}, expectedCase11, ""},
|
11: {FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), Topics: [][]common.Hash{{firstTopic}}}, expectedCase11, ""},
|
||||||
// match all logs due to wildcard topic
|
// match all logs due to wildcard topic
|
||||||
|
|
@ -679,7 +679,7 @@ func TestPendingLogsSubscription(t *testing.T) {
|
||||||
},
|
},
|
||||||
// match none due to only matching mined logs within a specific block range
|
// match none due to only matching mined logs within a specific block range
|
||||||
{
|
{
|
||||||
ethereum.FilterQuery{FromBlock: big.NewInt(1), ToBlock: big.NewInt(2)},
|
ethereum.FilterQuery{FromBlock: common.Big1, ToBlock: common.Big2},
|
||||||
nil,
|
nil,
|
||||||
nil, nil, nil,
|
nil, nil, nil,
|
||||||
},
|
},
|
||||||
|
|
@ -691,7 +691,7 @@ func TestPendingLogsSubscription(t *testing.T) {
|
||||||
},
|
},
|
||||||
// match none due to matching logs from a specific block number to new mined blocks
|
// match none due to matching logs from a specific block number to new mined blocks
|
||||||
{
|
{
|
||||||
ethereum.FilterQuery{FromBlock: big.NewInt(1), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
|
ethereum.FilterQuery{FromBlock: common.Big1, ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
|
||||||
nil,
|
nil,
|
||||||
nil, nil, nil,
|
nil, nil, nil,
|
||||||
},
|
},
|
||||||
|
|
@ -810,11 +810,11 @@ func TestLightFilterLogs(t *testing.T) {
|
||||||
// match logs based on addresses and topics
|
// match logs based on addresses and topics
|
||||||
3: {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, allLogs[3:5], ""},
|
3: {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, allLogs[3:5], ""},
|
||||||
// all logs with block num >= 3
|
// all logs with block num >= 3
|
||||||
4: {FilterCriteria{FromBlock: big.NewInt(3), ToBlock: big.NewInt(5)}, allLogs[1:], ""},
|
4: {FilterCriteria{FromBlock: common.Big3, ToBlock: big.NewInt(5)}, allLogs[1:], ""},
|
||||||
// all logs
|
// all logs
|
||||||
5: {FilterCriteria{FromBlock: big.NewInt(0), ToBlock: big.NewInt(5)}, allLogs, ""},
|
5: {FilterCriteria{FromBlock: common.Big0, ToBlock: big.NewInt(5)}, allLogs, ""},
|
||||||
// all logs with 1>= block num <=2 and topic secondTopic
|
// all logs with 1>= block num <=2 and topic secondTopic
|
||||||
6: {FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(3), Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""},
|
6: {FilterCriteria{FromBlock: common.Big2, ToBlock: common.Big3, Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""},
|
||||||
}
|
}
|
||||||
|
|
||||||
key, _ = crypto.GenerateKey()
|
key, _ = crypto.GenerateKey()
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func TestFilters(t *testing.T) {
|
||||||
// Sender account
|
// Sender account
|
||||||
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
addr = crypto.PubkeyToAddress(key1.PublicKey)
|
addr = crypto.PubkeyToAddress(key1.PublicKey)
|
||||||
signer = types.NewLondonSigner(big.NewInt(1))
|
signer = types.NewLondonSigner(common.Big1)
|
||||||
// Logging contract
|
// Logging contract
|
||||||
contract = common.Address{0xfe}
|
contract = common.Address{0xfe}
|
||||||
contract2 = common.Address{0xff}
|
contract2 = common.Address{0xff}
|
||||||
|
|
@ -165,9 +165,9 @@ func TestFilters(t *testing.T) {
|
||||||
gspec = &core.Genesis{
|
gspec = &core.Genesis{
|
||||||
Config: params.TestChainConfig,
|
Config: params.TestChainConfig,
|
||||||
Alloc: core.GenesisAlloc{
|
Alloc: core.GenesisAlloc{
|
||||||
addr: {Balance: big.NewInt(0).Mul(big.NewInt(100), big.NewInt(params.Ether))},
|
addr: {Balance: common.Big0.Mul(big.NewInt(100), big.NewInt(params.Ether))},
|
||||||
contract: {Balance: big.NewInt(0), Code: bytecode},
|
contract: {Balance: common.Big0, Code: bytecode},
|
||||||
contract2: {Balance: big.NewInt(0), Code: bytecode},
|
contract2: {Balance: common.Big0, Code: bytecode},
|
||||||
},
|
},
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,9 +193,9 @@ func TestSuggestTipCap(t *testing.T) {
|
||||||
expect *big.Int // Expected gasprice suggestion
|
expect *big.Int // Expected gasprice suggestion
|
||||||
}{
|
}{
|
||||||
{nil, big.NewInt(params.GWei * int64(30))},
|
{nil, big.NewInt(params.GWei * int64(30))},
|
||||||
{big.NewInt(0), big.NewInt(params.GWei * int64(30))}, // Fork point in genesis
|
{common.Big0, big.NewInt(params.GWei * int64(30))}, // Fork point in genesis
|
||||||
{big.NewInt(1), big.NewInt(params.GWei * int64(30))}, // Fork point in first block
|
{common.Big1, big.NewInt(params.GWei * int64(30))}, // Fork point in first block
|
||||||
{big.NewInt(32), big.NewInt(params.GWei * int64(30))}, // Fork point in last block
|
{common.Big32, big.NewInt(params.GWei * int64(30))}, // Fork point in last block
|
||||||
{big.NewInt(33), big.NewInt(params.GWei * int64(30))}, // Fork point in the future
|
{big.NewInt(33), big.NewInt(params.GWei * int64(30))}, // Fork point in the future
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,13 @@ func testForkIDSplit(t *testing.T, protocol uint) {
|
||||||
var (
|
var (
|
||||||
engine = ethash.NewFaker()
|
engine = ethash.NewFaker()
|
||||||
|
|
||||||
configNoFork = ¶ms.ChainConfig{HomesteadBlock: big.NewInt(1)}
|
configNoFork = ¶ms.ChainConfig{HomesteadBlock: common.Big1}
|
||||||
configProFork = ¶ms.ChainConfig{
|
configProFork = ¶ms.ChainConfig{
|
||||||
HomesteadBlock: big.NewInt(1),
|
HomesteadBlock: common.Big1,
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: common.Big2,
|
||||||
EIP155Block: big.NewInt(2),
|
EIP155Block: common.Big2,
|
||||||
EIP158Block: big.NewInt(2),
|
EIP158Block: common.Big2,
|
||||||
ByzantiumBlock: big.NewInt(3),
|
ByzantiumBlock: common.Big3,
|
||||||
}
|
}
|
||||||
dbNoFork = rawdb.NewMemoryDatabase()
|
dbNoFork = rawdb.NewMemoryDatabase()
|
||||||
dbProFork = rawdb.NewMemoryDatabase()
|
dbProFork = rawdb.NewMemoryDatabase()
|
||||||
|
|
@ -275,7 +275,7 @@ func testRecvTransactions(t *testing.T, protocol uint) {
|
||||||
t.Fatalf("failed to run protocol handshake")
|
t.Fatalf("failed to run protocol handshake")
|
||||||
}
|
}
|
||||||
// Send the transaction to the sink and verify that it's added to the tx pool
|
// Send the transaction to the sink and verify that it's added to the tx pool
|
||||||
tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 100000, big.NewInt(0), nil)
|
tx := types.NewTransaction(0, common.Address{}, common.Big0, 100000, common.Big0, nil)
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
||||||
if err := src.SendTransactions([]*types.Transaction{tx}); err != nil {
|
if err := src.SendTransactions([]*types.Transaction{tx}); err != nil {
|
||||||
|
|
@ -306,7 +306,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
|
||||||
|
|
||||||
insert := make([]*types.Transaction, 100)
|
insert := make([]*types.Transaction, 100)
|
||||||
for nonce := range insert {
|
for nonce := range insert {
|
||||||
tx := types.NewTransaction(uint64(nonce), common.Address{}, big.NewInt(0), 100000, big.NewInt(0), make([]byte, 10240))
|
tx := types.NewTransaction(uint64(nonce), common.Address{}, common.Big0, 100000, common.Big0, make([]byte, 10240))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
insert[nonce] = tx
|
insert[nonce] = tx
|
||||||
}
|
}
|
||||||
|
|
@ -430,7 +430,7 @@ func testTransactionPropagation(t *testing.T, protocol uint) {
|
||||||
// Fill the source pool with transactions and wait for them at the sinks
|
// Fill the source pool with transactions and wait for them at the sinks
|
||||||
txs := make([]*types.Transaction, 1024)
|
txs := make([]*types.Transaction, 1024)
|
||||||
for nonce := range txs {
|
for nonce := range txs {
|
||||||
tx := types.NewTransaction(uint64(nonce), common.Address{}, big.NewInt(0), 100000, big.NewInt(0), nil)
|
tx := types.NewTransaction(uint64(nonce), common.Address{}, common.Big0, 100000, common.Big0, nil)
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
txs[nonce] = tx
|
txs[nonce] = tx
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,25 +75,25 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
|
||||||
|
|
||||||
if shanghai {
|
if shanghai {
|
||||||
config = ¶ms.ChainConfig{
|
config = ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
ShanghaiTime: u64(0),
|
ShanghaiTime: u64(0),
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
Ethash: new(params.EthashConfig),
|
Ethash: new(params.EthashConfig),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ func TestTracingWithOverrides(t *testing.T) {
|
||||||
},
|
},
|
||||||
config: &TraceCallConfig{
|
config: &TraceCallConfig{
|
||||||
StateOverrides: ðapi.StateOverride{
|
StateOverrides: ðapi.StateOverride{
|
||||||
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(big.NewInt(1), big.NewInt(params.Ether)))},
|
randomAccounts[0].addr: ethapi.OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)))},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: `{"gas":21000,"failed":false,"returnValue":""}`,
|
want: `{"gas":21000,"failed":false,"returnValue":""}`,
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ func TestInternals(t *testing.T) {
|
||||||
origin = common.HexToAddress("0x00000000000000000000000000000000feed")
|
origin = common.HexToAddress("0x00000000000000000000000000000000feed")
|
||||||
txContext = vm.TxContext{
|
txContext = vm.TxContext{
|
||||||
Origin: origin,
|
Origin: origin,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: common.Big1,
|
||||||
}
|
}
|
||||||
context = vm.BlockContext{
|
context = vm.BlockContext{
|
||||||
CanTransfer: core.CanTransfer,
|
CanTransfer: core.CanTransfer,
|
||||||
|
|
@ -382,11 +382,11 @@ func TestInternals(t *testing.T) {
|
||||||
msg := &core.Message{
|
msg := &core.Message{
|
||||||
To: &to,
|
To: &to,
|
||||||
From: origin,
|
From: origin,
|
||||||
Value: big.NewInt(0),
|
Value: common.Big0,
|
||||||
GasLimit: 80000,
|
GasLimit: 80000,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: common.Big0,
|
||||||
GasFeeCap: big.NewInt(0),
|
GasFeeCap: common.Big0,
|
||||||
GasTipCap: big.NewInt(0),
|
GasTipCap: common.Big0,
|
||||||
SkipAccountChecks: false,
|
SkipAccountChecks: false,
|
||||||
}
|
}
|
||||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ type vmContext struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCtx() *vmContext {
|
func testCtx() *vmContext {
|
||||||
return &vmContext{blockCtx: vm.BlockContext{BlockNumber: big.NewInt(1)}, txCtx: vm.TxContext{GasPrice: big.NewInt(100000)}}
|
return &vmContext{blockCtx: vm.BlockContext{BlockNumber: common.Big1}, txCtx: vm.TxContext{GasPrice: big.NewInt(100000)}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTrace(tracer tracers.Tracer, vmctx *vmContext, chaincfg *params.ChainConfig, contractCode []byte) (json.RawMessage, error) {
|
func runTrace(tracer tracers.Tracer, vmctx *vmContext, chaincfg *params.ChainConfig, contractCode []byte) (json.RawMessage, error) {
|
||||||
|
|
@ -65,7 +65,7 @@ func runTrace(tracer tracers.Tracer, vmctx *vmContext, chaincfg *params.ChainCon
|
||||||
env = vm.NewEVM(vmctx.blockCtx, vmctx.txCtx, &dummyStatedb{}, chaincfg, vm.Config{Tracer: tracer})
|
env = vm.NewEVM(vmctx.blockCtx, vmctx.txCtx, &dummyStatedb{}, chaincfg, vm.Config{Tracer: tracer})
|
||||||
gasLimit uint64 = 31000
|
gasLimit uint64 = 31000
|
||||||
startGas uint64 = 10000
|
startGas uint64 = 10000
|
||||||
value = big.NewInt(0)
|
value = common.Big0
|
||||||
contract = vm.NewContract(account{}, account{}, value, startGas)
|
contract = vm.NewContract(account{}, account{}, value, startGas)
|
||||||
)
|
)
|
||||||
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
||||||
|
|
@ -180,11 +180,11 @@ func TestHaltBetweenSteps(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(1)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer})
|
env := vm.NewEVM(vm.BlockContext{BlockNumber: common.Big1}, vm.TxContext{GasPrice: common.Big1}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer})
|
||||||
scope := &vm.ScopeContext{
|
scope := &vm.ScopeContext{
|
||||||
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
Contract: vm.NewContract(&account{}, &account{}, common.Big0, 0),
|
||||||
}
|
}
|
||||||
tracer.CaptureStart(env, common.Address{}, common.Address{}, false, []byte{}, 0, big.NewInt(0))
|
tracer.CaptureStart(env, common.Address{}, common.Address{}, false, []byte{}, 0, common.Big0)
|
||||||
tracer.CaptureState(0, 0, 0, 0, scope, nil, 0, nil)
|
tracer.CaptureState(0, 0, 0, 0, scope, nil, 0, nil)
|
||||||
timeout := errors.New("stahp")
|
timeout := errors.New("stahp")
|
||||||
tracer.Stop(timeout)
|
tracer.Stop(timeout)
|
||||||
|
|
@ -204,8 +204,8 @@ func TestNoStepExec(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(100)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer})
|
env := vm.NewEVM(vm.BlockContext{BlockNumber: common.Big1}, vm.TxContext{GasPrice: big.NewInt(100)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer})
|
||||||
tracer.CaptureStart(env, common.Address{}, common.Address{}, false, []byte{}, 1000, big.NewInt(0))
|
tracer.CaptureStart(env, common.Address{}, common.Address{}, false, []byte{}, 1000, common.Big0)
|
||||||
tracer.CaptureEnd(nil, 0, nil)
|
tracer.CaptureEnd(nil, 0, nil)
|
||||||
ret, err := tracer.GetResult()
|
ret, err := tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -229,7 +229,7 @@ func TestNoStepExec(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsPrecompile(t *testing.T) {
|
func TestIsPrecompile(t *testing.T) {
|
||||||
chaincfg := ¶ms.ChainConfig{ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), TerminalTotalDifficulty: nil, Ethash: new(params.EthashConfig), Clique: nil}
|
chaincfg := ¶ms.ChainConfig{ChainID: common.Big1, HomesteadBlock: common.Big0, DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: common.Big0, EIP155Block: common.Big0, EIP158Block: common.Big0, ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: common.Big0, PetersburgBlock: common.Big0, IstanbulBlock: big.NewInt(200), MuirGlacierBlock: common.Big0, BerlinBlock: big.NewInt(300), LondonBlock: common.Big0, TerminalTotalDifficulty: nil, Ethash: new(params.EthashConfig), Clique: nil}
|
||||||
chaincfg.ByzantiumBlock = big.NewInt(100)
|
chaincfg.ByzantiumBlock = big.NewInt(100)
|
||||||
chaincfg.IstanbulBlock = big.NewInt(200)
|
chaincfg.IstanbulBlock = big.NewInt(200)
|
||||||
chaincfg.BerlinBlock = big.NewInt(300)
|
chaincfg.BerlinBlock = big.NewInt(300)
|
||||||
|
|
@ -273,7 +273,7 @@ func TestEnterExit(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
scope := &vm.ScopeContext{
|
scope := &vm.ScopeContext{
|
||||||
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
Contract: vm.NewContract(&account{}, &account{}, common.Big0, 0),
|
||||||
}
|
}
|
||||||
tracer.CaptureEnter(vm.CALL, scope.Contract.Caller(), scope.Contract.Address(), []byte{}, 1000, new(big.Int))
|
tracer.CaptureEnter(vm.CALL, scope.Contract.Caller(), scope.Contract.Address(), []byte{}, 1000, new(big.Int))
|
||||||
tracer.CaptureExit([]byte{}, 400, nil)
|
tracer.CaptureExit([]byte{}, 400, nil)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ func TestStoreCapture(t *testing.T) {
|
||||||
t.Fatalf("expected exactly 1 changed value on address %x, got %d", contract.Address(),
|
t.Fatalf("expected exactly 1 changed value on address %x, got %d", contract.Address(),
|
||||||
len(logger.storage[contract.Address()]))
|
len(logger.storage[contract.Address()]))
|
||||||
}
|
}
|
||||||
exp := common.BigToHash(big.NewInt(1))
|
exp := common.BigToHash(common.Big1)
|
||||||
if logger.storage[contract.Address()][index] != exp {
|
if logger.storage[contract.Address()][index] != exp {
|
||||||
t.Errorf("expected %x, got %x", exp, logger.storage[contract.Address()][index])
|
t.Errorf("expected %x, got %x", exp, logger.storage[contract.Address()][index])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ func (t *flatCallTracer) CaptureEnter(typ vm.OpCode, from common.Address, to com
|
||||||
// Child calls must have a value, even if it's zero.
|
// Child calls must have a value, even if it's zero.
|
||||||
// Practically speaking, only STATICCALL has nil value. Set it to zero.
|
// Practically speaking, only STATICCALL has nil value. Set it to zero.
|
||||||
if t.tracer.callstack[len(t.tracer.callstack)-1].Value == nil && value == nil {
|
if t.tracer.callstack[len(t.tracer.callstack)-1].Value == nil && value == nil {
|
||||||
t.tracer.callstack[len(t.tracer.callstack)-1].Value = big.NewInt(0)
|
t.tracer.callstack[len(t.tracer.callstack)-1].Value = common.Big0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
|
||||||
alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = core.GenesisAccount{
|
alloc[common.HexToAddress("0x00000000000000000000000000000000deadbeef")] = core.GenesisAccount{
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
Code: loop,
|
Code: loop,
|
||||||
Balance: big.NewInt(1),
|
Balance: common.Big1,
|
||||||
}
|
}
|
||||||
alloc[from] = core.GenesisAccount{
|
alloc[from] = core.GenesisAccount{
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ func TestToFilterArg(t *testing.T) {
|
||||||
"without BlockHash",
|
"without BlockHash",
|
||||||
ethereum.FilterQuery{
|
ethereum.FilterQuery{
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
FromBlock: big.NewInt(1),
|
FromBlock: common.Big1,
|
||||||
ToBlock: big.NewInt(2),
|
ToBlock: common.Big2,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|
@ -133,7 +133,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
ethereum.FilterQuery{
|
ethereum.FilterQuery{
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
BlockHash: &blockHash,
|
BlockHash: &blockHash,
|
||||||
FromBlock: big.NewInt(1),
|
FromBlock: common.Big1,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
|
|
@ -144,7 +144,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
ethereum.FilterQuery{
|
ethereum.FilterQuery{
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
BlockHash: &blockHash,
|
BlockHash: &blockHash,
|
||||||
ToBlock: big.NewInt(1),
|
ToBlock: common.Big1,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
|
|
@ -155,8 +155,8 @@ func TestToFilterArg(t *testing.T) {
|
||||||
ethereum.FilterQuery{
|
ethereum.FilterQuery{
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
BlockHash: &blockHash,
|
BlockHash: &blockHash,
|
||||||
FromBlock: big.NewInt(1),
|
FromBlock: common.Big1,
|
||||||
ToBlock: big.NewInt(2),
|
ToBlock: common.Big2,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
|
|
@ -302,11 +302,11 @@ func testHeader(t *testing.T, chain []*types.Block, client *rpc.Client) {
|
||||||
wantErr error
|
wantErr error
|
||||||
}{
|
}{
|
||||||
"genesis": {
|
"genesis": {
|
||||||
block: big.NewInt(0),
|
block: common.Big0,
|
||||||
want: chain[0].Header(),
|
want: chain[0].Header(),
|
||||||
},
|
},
|
||||||
"first_block": {
|
"first_block": {
|
||||||
block: big.NewInt(1),
|
block: common.Big1,
|
||||||
want: chain[1].Header(),
|
want: chain[1].Header(),
|
||||||
},
|
},
|
||||||
"future_block": {
|
"future_block": {
|
||||||
|
|
@ -326,7 +326,7 @@ func testHeader(t *testing.T, chain []*types.Block, client *rpc.Client) {
|
||||||
t.Fatalf("HeaderByNumber(%v) error = %q, want %q", tt.block, err, tt.wantErr)
|
t.Fatalf("HeaderByNumber(%v) error = %q, want %q", tt.block, err, tt.wantErr)
|
||||||
}
|
}
|
||||||
if got != nil && got.Number != nil && got.Number.Sign() == 0 {
|
if got != nil && got.Number != nil && got.Number.Sign() == 0 {
|
||||||
got.Number = big.NewInt(0) // hack to make DeepEqual work
|
got.Number = common.Big0 // hack to make DeepEqual work
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Fatalf("HeaderByNumber(%v)\n = %v\nwant %v", tt.block, got, tt.want)
|
t.Fatalf("HeaderByNumber(%v)\n = %v\nwant %v", tt.block, got, tt.want)
|
||||||
|
|
@ -344,23 +344,23 @@ func testBalanceAt(t *testing.T, client *rpc.Client) {
|
||||||
}{
|
}{
|
||||||
"valid_account_genesis": {
|
"valid_account_genesis": {
|
||||||
account: testAddr,
|
account: testAddr,
|
||||||
block: big.NewInt(0),
|
block: common.Big0,
|
||||||
want: testBalance,
|
want: testBalance,
|
||||||
},
|
},
|
||||||
"valid_account": {
|
"valid_account": {
|
||||||
account: testAddr,
|
account: testAddr,
|
||||||
block: big.NewInt(1),
|
block: common.Big1,
|
||||||
want: testBalance,
|
want: testBalance,
|
||||||
},
|
},
|
||||||
"non_existent_account": {
|
"non_existent_account": {
|
||||||
account: common.Address{1},
|
account: common.Address{1},
|
||||||
block: big.NewInt(1),
|
block: common.Big1,
|
||||||
want: big.NewInt(0),
|
want: common.Big0,
|
||||||
},
|
},
|
||||||
"future_block": {
|
"future_block": {
|
||||||
account: testAddr,
|
account: testAddr,
|
||||||
block: big.NewInt(1000000000),
|
block: big.NewInt(1000000000),
|
||||||
want: big.NewInt(0),
|
want: common.Big0,
|
||||||
wantErr: errors.New("header not found"),
|
wantErr: errors.New("header not found"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -504,12 +504,12 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeeHistory
|
// FeeHistory
|
||||||
history, err := ec.FeeHistory(context.Background(), 1, big.NewInt(2), []float64{95, 99})
|
history, err := ec.FeeHistory(context.Background(), 1, common.Big2, []float64{95, 99})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
want := ðereum.FeeHistory{
|
want := ðereum.FeeHistory{
|
||||||
OldestBlock: big.NewInt(2),
|
OldestBlock: common.Big2,
|
||||||
Reward: [][]*big.Int{
|
Reward: [][]*big.Int{
|
||||||
{
|
{
|
||||||
big.NewInt(234375000),
|
big.NewInt(234375000),
|
||||||
|
|
@ -535,7 +535,7 @@ func testCallContractAtHash(t *testing.T, client *rpc.Client) {
|
||||||
From: testAddr,
|
From: testAddr,
|
||||||
To: &common.Address{},
|
To: &common.Address{},
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}
|
}
|
||||||
gas, err := ec.EstimateGas(context.Background(), msg)
|
gas, err := ec.EstimateGas(context.Background(), msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -544,7 +544,7 @@ func testCallContractAtHash(t *testing.T, client *rpc.Client) {
|
||||||
if gas != 21000 {
|
if gas != 21000 {
|
||||||
t.Fatalf("unexpected gas price: %v", gas)
|
t.Fatalf("unexpected gas price: %v", gas)
|
||||||
}
|
}
|
||||||
block, err := ec.HeaderByNumber(context.Background(), big.NewInt(1))
|
block, err := ec.HeaderByNumber(context.Background(), common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("BlockByNumber error: %v", err)
|
t.Fatalf("BlockByNumber error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -562,7 +562,7 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||||
From: testAddr,
|
From: testAddr,
|
||||||
To: &common.Address{},
|
To: &common.Address{},
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}
|
}
|
||||||
gas, err := ec.EstimateGas(context.Background(), msg)
|
gas, err := ec.EstimateGas(context.Background(), msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -572,7 +572,7 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||||
t.Fatalf("unexpected gas price: %v", gas)
|
t.Fatalf("unexpected gas price: %v", gas)
|
||||||
}
|
}
|
||||||
// CallContract
|
// CallContract
|
||||||
if _, err := ec.CallContract(context.Background(), msg, big.NewInt(1)); err != nil {
|
if _, err := ec.CallContract(context.Background(), msg, common.Big1); err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
// PendingCallContract
|
// PendingCallContract
|
||||||
|
|
@ -584,7 +584,7 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||||
func testAtFunctions(t *testing.T, client *rpc.Client) {
|
func testAtFunctions(t *testing.T, client *rpc.Client) {
|
||||||
ec := NewClient(client)
|
ec := NewClient(client)
|
||||||
|
|
||||||
block, err := ec.HeaderByNumber(context.Background(), big.NewInt(1))
|
block, err := ec.HeaderByNumber(context.Background(), common.Big1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("BlockByNumber error: %v", err)
|
t.Fatalf("BlockByNumber error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -684,7 +684,7 @@ func testTransactionSender(t *testing.T, client *rpc.Client) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Retrieve testTx1 via RPC.
|
// Retrieve testTx1 via RPC.
|
||||||
block2, err := ec.HeaderByNumber(ctx, big.NewInt(2))
|
block2, err := ec.HeaderByNumber(ctx, common.Big2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("can't get block 1:", err)
|
t.Fatal("can't get block 1:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -734,7 +734,7 @@ func sendTransaction(ec *Client) error {
|
||||||
tx, err := types.SignNewTx(testKey, signer, &types.LegacyTx{
|
tx, err := types.SignNewTx(testKey, signer, &types.LegacyTx{
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
To: &common.Address{2},
|
To: &common.Address{2},
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Gas: 22000,
|
Gas: 22000,
|
||||||
GasPrice: big.NewInt(params.InitialBaseFee),
|
GasPrice: big.NewInt(params.InitialBaseFee),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
|
||||||
Alloc: core.GenesisAlloc{
|
Alloc: core.GenesisAlloc{
|
||||||
testAddr: {Balance: testBalance, Storage: map[common.Hash]common.Hash{testSlot: testValue}},
|
testAddr: {Balance: testBalance, Storage: map[common.Hash]common.Hash{testSlot: testValue}},
|
||||||
testContract: {Nonce: 1, Code: []byte{0x13, 0x37}},
|
testContract: {Nonce: 1, Code: []byte{0x13, 0x37}},
|
||||||
testEmpty: {Balance: big.NewInt(1)},
|
testEmpty: {Balance: common.Big1},
|
||||||
},
|
},
|
||||||
ExtraData: []byte("test genesis"),
|
ExtraData: []byte("test genesis"),
|
||||||
Timestamp: 9000,
|
Timestamp: 9000,
|
||||||
|
|
@ -170,7 +170,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
|
||||||
To: &common.Address{},
|
To: &common.Address{},
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
GasPrice: big.NewInt(765625000),
|
GasPrice: big.NewInt(765625000),
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}
|
}
|
||||||
al, gas, vmErr, err := ec.CreateAccessList(context.Background(), msg)
|
al, gas, vmErr, err := ec.CreateAccessList(context.Background(), msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -191,7 +191,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
|
||||||
To: nil,
|
To: nil,
|
||||||
Gas: 100000,
|
Gas: 100000,
|
||||||
GasPrice: big.NewInt(1000000000),
|
GasPrice: big.NewInt(1000000000),
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
Data: common.FromHex("0x608060806080608155fd"),
|
Data: common.FromHex("0x608060806080608155fd"),
|
||||||
}
|
}
|
||||||
al, gas, vmErr, err = ec.CreateAccessList(context.Background(), msg)
|
al, gas, vmErr, err = ec.CreateAccessList(context.Background(), msg)
|
||||||
|
|
@ -299,7 +299,7 @@ func testGetProofNonExistent(t *testing.T, client *rpc.Client) {
|
||||||
t.Fatalf("invalid nonce, want: %v got: %v", 0, result.Nonce)
|
t.Fatalf("invalid nonce, want: %v got: %v", 0, result.Nonce)
|
||||||
}
|
}
|
||||||
// test balance
|
// test balance
|
||||||
if result.Balance.Cmp(big.NewInt(0)) != 0 {
|
if result.Balance.Cmp(common.Big0) != 0 {
|
||||||
t.Fatalf("invalid balance, want: %v got: %v", 0, result.Balance)
|
t.Fatalf("invalid balance, want: %v got: %v", 0, result.Balance)
|
||||||
}
|
}
|
||||||
// test storage
|
// test storage
|
||||||
|
|
@ -349,7 +349,7 @@ func testGetNodeInfo(t *testing.T, client *rpc.Client) {
|
||||||
|
|
||||||
func testSetHead(t *testing.T, client *rpc.Client) {
|
func testSetHead(t *testing.T, client *rpc.Client) {
|
||||||
ec := New(client)
|
ec := New(client)
|
||||||
err := ec.SetHead(context.Background(), big.NewInt(0))
|
err := ec.SetHead(context.Background(), common.Big0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +367,7 @@ func testSubscribePendingTransactions(t *testing.T, client *rpc.Client) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Create transaction
|
// Create transaction
|
||||||
tx := types.NewTransaction(0, common.Address{1}, big.NewInt(1), 22000, big.NewInt(1), nil)
|
tx := types.NewTransaction(0, common.Address{1}, common.Big1, 22000, common.Big1, nil)
|
||||||
signer := types.LatestSignerForChainID(chainID)
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey)
|
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -401,7 +401,7 @@ func testSubscribeFullPendingTransactions(t *testing.T, client *rpc.Client) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Create transaction
|
// Create transaction
|
||||||
tx := types.NewTransaction(1, common.Address{1}, big.NewInt(1), 22000, big.NewInt(1), nil)
|
tx := types.NewTransaction(1, common.Address{1}, common.Big1, 22000, common.Big1, nil)
|
||||||
signer := types.LatestSignerForChainID(chainID)
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey)
|
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -430,10 +430,10 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||||
To: &common.Address{},
|
To: &common.Address{},
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
GasPrice: big.NewInt(1000000000),
|
GasPrice: big.NewInt(1000000000),
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}
|
}
|
||||||
// CallContract without override
|
// CallContract without override
|
||||||
if _, err := ec.CallContract(context.Background(), msg, big.NewInt(0), nil); err != nil {
|
if _, err := ec.CallContract(context.Background(), msg, common.Big0, nil); err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
// CallContract with override
|
// CallContract with override
|
||||||
|
|
@ -442,7 +442,7 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
||||||
}
|
}
|
||||||
mapAcc := make(map[common.Address]OverrideAccount)
|
mapAcc := make(map[common.Address]OverrideAccount)
|
||||||
mapAcc[testAddr] = override
|
mapAcc[testAddr] = override
|
||||||
if _, err := ec.CallContract(context.Background(), msg, big.NewInt(0), &mapAcc); err != nil {
|
if _, err := ec.CallContract(context.Background(), msg, common.Big0, &mapAcc); err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -463,7 +463,7 @@ func TestOverrideAccountMarshal(t *testing.T) {
|
||||||
// 'code', 'balance', 'state' should be set when input is
|
// 'code', 'balance', 'state' should be set when input is
|
||||||
// a non-nil but empty value.
|
// a non-nil but empty value.
|
||||||
Code: []byte{},
|
Code: []byte{},
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
State: map[common.Hash]common.Hash{},
|
State: map[common.Hash]common.Hash{},
|
||||||
// For 'stateDiff' the behavior is different, empty map
|
// For 'stateDiff' the behavior is different, empty map
|
||||||
// is ignored because it makes no difference.
|
// is ignored because it makes no difference.
|
||||||
|
|
@ -514,8 +514,8 @@ func TestBlockOverridesMarshal(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bo: BlockOverrides{
|
bo: BlockOverrides{
|
||||||
Number: big.NewInt(1),
|
Number: common.Big1,
|
||||||
Difficulty: big.NewInt(2),
|
Difficulty: common.Big2,
|
||||||
Time: 3,
|
Time: 3,
|
||||||
GasLimit: 4,
|
GasLimit: 4,
|
||||||
BaseFee: big.NewInt(5),
|
BaseFee: big.NewInt(5),
|
||||||
|
|
@ -540,7 +540,7 @@ func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
|
||||||
To: &common.Address{},
|
To: &common.Address{},
|
||||||
Gas: 50000,
|
Gas: 50000,
|
||||||
GasPrice: big.NewInt(1000000000),
|
GasPrice: big.NewInt(1000000000),
|
||||||
Value: big.NewInt(1),
|
Value: common.Big1,
|
||||||
}
|
}
|
||||||
override := OverrideAccount{
|
override := OverrideAccount{
|
||||||
// Returns coinbase address.
|
// Returns coinbase address.
|
||||||
|
|
@ -548,7 +548,7 @@ func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
|
||||||
}
|
}
|
||||||
mapAcc := make(map[common.Address]OverrideAccount)
|
mapAcc := make(map[common.Address]OverrideAccount)
|
||||||
mapAcc[common.Address{}] = override
|
mapAcc[common.Address{}] = override
|
||||||
res, err := ec.CallContract(context.Background(), msg, big.NewInt(0), &mapAcc)
|
res, err := ec.CallContract(context.Background(), msg, common.Big0, &mapAcc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -560,7 +560,7 @@ func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
|
||||||
bo := BlockOverrides{
|
bo := BlockOverrides{
|
||||||
Coinbase: common.HexToAddress("0x1111111111111111111111111111111111111111"),
|
Coinbase: common.HexToAddress("0x1111111111111111111111111111111111111111"),
|
||||||
}
|
}
|
||||||
res, err = ec.CallContractWithBlockOverrides(context.Background(), msg, big.NewInt(0), &mapAcc, bo)
|
res, err = ec.CallContractWithBlockOverrides(context.Background(), msg, common.Big0, &mapAcc, bo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ func TestGraphQLBlockSerializationEIP2718(t *testing.T) {
|
||||||
dad: {
|
dad: {
|
||||||
Code: []byte{byte(vm.PC), byte(vm.PC), byte(vm.SLOAD), byte(vm.SLOAD)},
|
Code: []byte{byte(vm.PC), byte(vm.PC), byte(vm.SLOAD), byte(vm.SLOAD)},
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
|
|
@ -292,7 +292,7 @@ func TestGraphQLConcurrentResolvers(t *testing.T) {
|
||||||
// LOG0(0, 0), LOG0(0, 0), RETURN(0, 0)
|
// LOG0(0, 0), LOG0(0, 0), RETURN(0, 0)
|
||||||
Code: common.Hex2Bytes("60006000a060006000a060006000f3"),
|
Code: common.Hex2Bytes("60006000a060006000a060006000f3"),
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.NewInt(0),
|
Balance: common.Big0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
||||||
To: nil,
|
To: nil,
|
||||||
Value: big.NewInt(8),
|
Value: big.NewInt(8),
|
||||||
Data: []byte{0, 1, 2, 3, 4},
|
Data: []byte{0, 1, 2, 3, 4},
|
||||||
V: big.NewInt(32),
|
V: common.Big32,
|
||||||
R: big.NewInt(10),
|
R: big.NewInt(10),
|
||||||
S: big.NewInt(11),
|
S: big.NewInt(11),
|
||||||
},
|
},
|
||||||
|
|
@ -190,7 +190,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
||||||
StorageKeys: []common.Hash{types.EmptyRootHash},
|
StorageKeys: []common.Hash{types.EmptyRootHash},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
V: big.NewInt(32),
|
V: common.Big32,
|
||||||
R: big.NewInt(10),
|
R: big.NewInt(10),
|
||||||
S: big.NewInt(11),
|
S: big.NewInt(11),
|
||||||
},
|
},
|
||||||
|
|
@ -236,7 +236,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
||||||
StorageKeys: []common.Hash{types.EmptyRootHash},
|
StorageKeys: []common.Hash{types.EmptyRootHash},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
V: big.NewInt(32),
|
V: common.Big32,
|
||||||
R: big.NewInt(10),
|
R: big.NewInt(10),
|
||||||
S: big.NewInt(11),
|
S: big.NewInt(11),
|
||||||
},
|
},
|
||||||
|
|
@ -283,7 +283,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
||||||
StorageKeys: []common.Hash{types.EmptyRootHash},
|
StorageKeys: []common.Hash{types.EmptyRootHash},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
V: big.NewInt(32),
|
V: common.Big32,
|
||||||
R: big.NewInt(10),
|
R: big.NewInt(10),
|
||||||
S: big.NewInt(11),
|
S: big.NewInt(11),
|
||||||
},
|
},
|
||||||
|
|
@ -327,7 +327,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
||||||
Value: big.NewInt(8),
|
Value: big.NewInt(8),
|
||||||
Data: []byte{0, 1, 2, 3, 4},
|
Data: []byte{0, 1, 2, 3, 4},
|
||||||
AccessList: types.AccessList{},
|
AccessList: types.AccessList{},
|
||||||
V: big.NewInt(32),
|
V: common.Big32,
|
||||||
R: big.NewInt(10),
|
R: big.NewInt(10),
|
||||||
S: big.NewInt(11),
|
S: big.NewInt(11),
|
||||||
},
|
},
|
||||||
|
|
@ -440,7 +440,7 @@ func (b *testBackend) setPendingBlock(block *types.Block) {
|
||||||
|
|
||||||
func (b testBackend) SyncProgress() ethereum.SyncProgress { return ethereum.SyncProgress{} }
|
func (b testBackend) SyncProgress() ethereum.SyncProgress { return ethereum.SyncProgress{} }
|
||||||
func (b testBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
func (b testBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
return big.NewInt(0), nil
|
return common.Big0, nil
|
||||||
}
|
}
|
||||||
func (b testBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
func (b testBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
||||||
return nil, nil, nil, nil, nil
|
return nil, nil, nil, nil, nil
|
||||||
|
|
@ -534,7 +534,7 @@ func (b testBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int {
|
||||||
if b.pending != nil && hash == b.pending.Hash() {
|
if b.pending != nil && hash == b.pending.Hash() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return big.NewInt(1)
|
return common.Big1
|
||||||
}
|
}
|
||||||
func (b testBackend) GetEVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockContext *vm.BlockContext) *vm.EVM {
|
func (b testBackend) GetEVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockContext *vm.BlockContext) *vm.EVM {
|
||||||
if vmConfig == nil {
|
if vmConfig == nil {
|
||||||
|
|
@ -660,7 +660,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
blockNumber: rpc.LatestBlockNumber,
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
call: TransactionArgs{},
|
call: TransactionArgs{},
|
||||||
overrides: StateOverride{
|
overrides: StateOverride{
|
||||||
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(big.NewInt(1), big.NewInt(params.Ether)))},
|
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)))},
|
||||||
},
|
},
|
||||||
expectErr: nil,
|
expectErr: nil,
|
||||||
want: 53000,
|
want: 53000,
|
||||||
|
|
@ -673,7 +673,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
Value: (*hexutil.Big)(big.NewInt(1000)),
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
},
|
},
|
||||||
overrides: StateOverride{
|
overrides: StateOverride{
|
||||||
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(big.NewInt(0))},
|
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(common.Big0)},
|
||||||
},
|
},
|
||||||
expectErr: core.ErrInsufficientFunds,
|
expectErr: core.ErrInsufficientFunds,
|
||||||
},
|
},
|
||||||
|
|
@ -825,7 +825,7 @@ func TestCall(t *testing.T) {
|
||||||
Value: (*hexutil.Big)(big.NewInt(1000)),
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
},
|
},
|
||||||
overrides: StateOverride{
|
overrides: StateOverride{
|
||||||
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(big.NewInt(1), big.NewInt(params.Ether)))},
|
randomAccounts[0].addr: OverrideAccount{Balance: newRPCBalance(new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)))},
|
||||||
},
|
},
|
||||||
want: "0x",
|
want: "0x",
|
||||||
},
|
},
|
||||||
|
|
@ -1433,7 +1433,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
||||||
)
|
)
|
||||||
|
|
||||||
// Set the terminal total difficulty in the config
|
// Set the terminal total difficulty in the config
|
||||||
genesis.Config.TerminalTotalDifficulty = big.NewInt(0)
|
genesis.Config.TerminalTotalDifficulty = common.Big0
|
||||||
genesis.Config.TerminalTotalDifficultyPassed = true
|
genesis.Config.TerminalTotalDifficultyPassed = true
|
||||||
backend := newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
|
backend := newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
|
||||||
var (
|
var (
|
||||||
|
|
@ -1458,7 +1458,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
||||||
data := 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:])
|
data := 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 := big.NewInt(500)
|
||||||
fee.Add(fee, b.BaseFee())
|
fee.Add(fee, b.BaseFee())
|
||||||
tx, err = types.SignTx(types.NewTx(&types.DynamicFeeTx{Nonce: uint64(i), To: &contract, Gas: 60000, Value: big.NewInt(1), GasTipCap: big.NewInt(500), GasFeeCap: fee, Data: common.FromHex(data)}), signer, acc1Key)
|
tx, err = types.SignTx(types.NewTx(&types.DynamicFeeTx{Nonce: uint64(i), To: &contract, Gas: 60000, Value: common.Big1, GasTipCap: big.NewInt(500), GasFeeCap: fee, Data: common.FromHex(data)}), signer, acc1Key)
|
||||||
case 4:
|
case 4:
|
||||||
// access list with contract create
|
// access list with contract create
|
||||||
accessList := types.AccessList{{
|
accessList := types.AccessList{{
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ func (args *TransactionArgs) setLondonFeeDefaults(ctx context.Context, head *typ
|
||||||
// fee is rising.
|
// fee is rising.
|
||||||
val := new(big.Int).Add(
|
val := new(big.Int).Add(
|
||||||
args.MaxPriorityFeePerGas.ToInt(),
|
args.MaxPriorityFeePerGas.ToInt(),
|
||||||
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
|
new(big.Int).Mul(head.BaseFee, common.Big2),
|
||||||
)
|
)
|
||||||
args.MaxFeePerGas = (*hexutil.Big)(val)
|
args.MaxFeePerGas = (*hexutil.Big)(val)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func TestSetFeeDefaults(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
b = newBackendMock()
|
b = newBackendMock()
|
||||||
fortytwo = (*hexutil.Big)(big.NewInt(42))
|
fortytwo = (*hexutil.Big)(big.NewInt(42))
|
||||||
maxFee = (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(b.current.BaseFee, big.NewInt(2)), fortytwo.ToInt()))
|
maxFee = (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(b.current.BaseFee, common.Big2), fortytwo.ToInt()))
|
||||||
al = &types.AccessList{types.AccessTuple{Address: common.Address{0xaa}, StorageKeys: []common.Hash{{0x01}}}}
|
al = &types.AccessList{types.AccessTuple{Address: common.Address{0xaa}, StorageKeys: []common.Hash{{0x01}}}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -215,18 +215,18 @@ type backendMock struct {
|
||||||
func newBackendMock() *backendMock {
|
func newBackendMock() *backendMock {
|
||||||
config := ¶ms.ChainConfig{
|
config := ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(42),
|
ChainID: big.NewInt(42),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(1000),
|
LondonBlock: big.NewInt(1000),
|
||||||
}
|
}
|
||||||
return &backendMock{
|
return &backendMock{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
package guide
|
package guide
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -70,8 +69,8 @@ func TestAccountManagement(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create signer account: %v", err)
|
t.Fatalf("Failed to create signer account: %v", err)
|
||||||
}
|
}
|
||||||
tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil)
|
tx := types.NewTransaction(0, common.Address{}, common.Big0, 0, common.Big0, nil)
|
||||||
chain := big.NewInt(1)
|
chain := common.Big1
|
||||||
|
|
||||||
// Sign a transaction with a single authorization
|
// Sign a transaction with a single authorization
|
||||||
if _, err := ks.SignTxWithPassphrase(signer, "Signer password", tx, chain); err != nil {
|
if _, err := ks.SignTxWithPassphrase(signer, "Signer password", tx, chain); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func newCanonical(n int) (ethdb.Database, *LightChain, error) {
|
||||||
func newTestLightChain() *LightChain {
|
func newTestLightChain() *LightChain {
|
||||||
db := rawdb.NewMemoryDatabase()
|
db := rawdb.NewMemoryDatabase()
|
||||||
gspec := &core.Genesis{
|
gspec := &core.Genesis{
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: common.Big1,
|
||||||
Config: params.TestChainConfig,
|
Config: params.TestChainConfig,
|
||||||
}
|
}
|
||||||
gspec.MustCommit(db, trie.NewDatabase(db, trie.HashDefaults))
|
gspec.MustCommit(db, trie.NewDatabase(db, trie.HashDefaults))
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||||
nonce := block.TxNonce(acc1Addr)
|
nonce := block.TxNonce(acc1Addr)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(nonce, acc2Addr, big.NewInt(1_000_000_000_000_000), params.TxGas, block.BaseFee(), nil), signer, acc1Key)
|
tx2, _ := types.SignTx(types.NewTransaction(nonce, acc2Addr, big.NewInt(1_000_000_000_000_000), params.TxGas, block.BaseFee(), nil), signer, acc1Key)
|
||||||
nonce++
|
nonce++
|
||||||
tx3, _ := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 1000000, block.BaseFee(), testContractCode), signer, acc1Key)
|
tx3, _ := types.SignTx(types.NewContractCreation(nonce, common.Big0, 1000000, block.BaseFee(), testContractCode), signer, acc1Key)
|
||||||
testContractAddr = crypto.CreateAddress(acc1Addr, nonce)
|
testContractAddr = crypto.CreateAddress(acc1Addr, nonce)
|
||||||
block.AddTx(tx1)
|
block.AddTx(tx1)
|
||||||
block.AddTx(tx2)
|
block.AddTx(tx2)
|
||||||
|
|
@ -251,7 +251,7 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||||
block.SetCoinbase(acc2Addr)
|
block.SetCoinbase(acc2Addr)
|
||||||
block.SetExtra([]byte("yeehaw"))
|
block.SetExtra([]byte("yeehaw"))
|
||||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001")
|
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001")
|
||||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, big.NewInt(0), 100000, block.BaseFee(), data), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, common.Big0, 100000, block.BaseFee(), data), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
case 3:
|
case 3:
|
||||||
// Block 4 includes blocks 2 and 3 as uncle headers (with modified extra data).
|
// Block 4 includes blocks 2 and 3 as uncle headers (with modified extra data).
|
||||||
|
|
@ -262,7 +262,7 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||||
b3.Extra = []byte("foo")
|
b3.Extra = []byte("foo")
|
||||||
block.AddUncle(b3)
|
block.AddUncle(b3)
|
||||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002")
|
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002")
|
||||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, big.NewInt(0), 100000, block.BaseFee(), data), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, common.Big0, 100000, block.BaseFee(), data), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,7 @@ func (pool *TxPool) setNewHead(head *types.Header) {
|
||||||
pool.relay.NewHead(pool.head, m, r)
|
pool.relay.NewHead(pool.head, m, r)
|
||||||
|
|
||||||
// Update fork indicator by next pending block number
|
// Update fork indicator by next pending block number
|
||||||
next := new(big.Int).Add(head.Number, big.NewInt(1))
|
next := new(big.Int).Add(head.Number, common.Big1)
|
||||||
pool.istanbul = pool.config.IsIstanbul(next)
|
pool.istanbul = pool.config.IsIstanbul(next)
|
||||||
pool.eip2718 = pool.config.IsBerlin(next)
|
pool.eip2718 = pool.config.IsBerlin(next)
|
||||||
pool.shanghai = pool.config.IsShanghai(next, uint64(time.Now().Unix()))
|
pool.shanghai = pool.config.IsShanghai(next, uint64(time.Now().Unix()))
|
||||||
|
|
|
||||||
|
|
@ -278,18 +278,18 @@ func minerTestGenesisBlock(period uint64, gasLimit uint64, faucet common.Address
|
||||||
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
|
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: common.Big1,
|
||||||
Alloc: map[common.Address]core.GenesisAccount{
|
Alloc: map[common.Address]core.GenesisAccount{
|
||||||
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
|
common.BytesToAddress([]byte{1}): {Balance: common.Big1}, // ECRecover
|
||||||
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
|
common.BytesToAddress([]byte{2}): {Balance: common.Big1}, // SHA256
|
||||||
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
|
common.BytesToAddress([]byte{3}): {Balance: common.Big1}, // RIPEMD
|
||||||
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
|
common.BytesToAddress([]byte{4}): {Balance: common.Big1}, // Identity
|
||||||
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
|
common.BytesToAddress([]byte{5}): {Balance: common.Big1}, // ModExp
|
||||||
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
|
common.BytesToAddress([]byte{6}): {Balance: common.Big1}, // ECAdd
|
||||||
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
|
common.BytesToAddress([]byte{7}): {Balance: common.Big1}, // ECScalarMul
|
||||||
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
|
common.BytesToAddress([]byte{8}): {Balance: common.Big1}, // ECPairing
|
||||||
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
|
common.BytesToAddress([]byte{9}): {Balance: common.Big1}, // BLAKE2b
|
||||||
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
|
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), big.NewInt(9))},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func TestTransactionPriceNonceSortLegacy(t *testing.T) {
|
||||||
|
|
||||||
func TestTransactionPriceNonceSort1559(t *testing.T) {
|
func TestTransactionPriceNonceSort1559(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(0))
|
testTransactionPriceNonceSort(t, common.Big0)
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(5))
|
testTransactionPriceNonceSort(t, big.NewInt(5))
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(50))
|
testTransactionPriceNonceSort(t, big.NewInt(50))
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ func TestTransactionTimeSort(t *testing.T) {
|
||||||
for start, key := range keys {
|
for start, key := range keys {
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
tx, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 100, big.NewInt(1), nil), signer, key)
|
tx, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 100, common.Big1, nil), signer, key)
|
||||||
tx.SetTime(time.Unix(0, int64(len(keys)-start)))
|
tx.SetTime(time.Unix(0, int64(len(keys)-start)))
|
||||||
|
|
||||||
groups[addr] = append(groups[addr], &txpool.LazyTransaction{
|
groups[addr] = append(groups[addr], &txpool.LazyTransaction{
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ func (payload *Payload) Resolve() *engine.ExecutionPayloadEnvelope {
|
||||||
if payload.full != nil {
|
if payload.full != nil {
|
||||||
return engine.BlockToExecutableData(payload.full, payload.fullFees, payload.sidecars)
|
return engine.BlockToExecutableData(payload.full, payload.fullFees, payload.sidecars)
|
||||||
}
|
}
|
||||||
return engine.BlockToExecutableData(payload.empty, big.NewInt(0), nil)
|
return engine.BlockToExecutableData(payload.empty, common.Big0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveEmpty is basically identical to Resolve, but it expects empty block only.
|
// ResolveEmpty is basically identical to Resolve, but it expects empty block only.
|
||||||
|
|
@ -145,7 +145,7 @@ func (payload *Payload) ResolveEmpty() *engine.ExecutionPayloadEnvelope {
|
||||||
payload.lock.Lock()
|
payload.lock.Lock()
|
||||||
defer payload.lock.Unlock()
|
defer payload.lock.Unlock()
|
||||||
|
|
||||||
return engine.BlockToExecutableData(payload.empty, big.NewInt(0), nil)
|
return engine.BlockToExecutableData(payload.empty, common.Big0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveFull is basically identical to Resolve, but it expects full block only.
|
// ResolveFull is basically identical to Resolve, but it expects full block only.
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ func makeGenesis(faucets []*ecdsa.PrivateKey, sealers []*ecdsa.PrivateKey) *core
|
||||||
genesis.Alloc = core.GenesisAlloc{}
|
genesis.Alloc = core.GenesisAlloc{}
|
||||||
for _, faucet := range faucets {
|
for _, faucet := range faucets {
|
||||||
genesis.Alloc[crypto.PubkeyToAddress(faucet.PublicKey)] = core.GenesisAccount{
|
genesis.Alloc[crypto.PubkeyToAddress(faucet.PublicKey)] = core.GenesisAccount{
|
||||||
Balance: new(big.Int).Exp(big.NewInt(2), big.NewInt(128), nil),
|
Balance: new(big.Int).Exp(common.Big2, big.NewInt(128), nil),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort the signers and embed into the extra-data section
|
// Sort the signers and embed into the extra-data section
|
||||||
|
|
@ -210,7 +210,7 @@ func makeSealer(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
||||||
GPO: ethconfig.Defaults.GPO,
|
GPO: ethconfig.Defaults.GPO,
|
||||||
Miner: miner.Config{
|
Miner: miner.Config{
|
||||||
GasCeil: genesis.GasLimit * 11 / 10,
|
GasCeil: genesis.GasLimit * 11 / 10,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: common.Big1,
|
||||||
Recommit: time.Second,
|
Recommit: time.Second,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ func (b *testWorkerBackend) newRandomTx(creation bool) *types.Transaction {
|
||||||
var tx *types.Transaction
|
var tx *types.Transaction
|
||||||
gasPrice := big.NewInt(10 * params.InitialBaseFee)
|
gasPrice := big.NewInt(10 * params.InitialBaseFee)
|
||||||
if creation {
|
if creation {
|
||||||
tx, _ = types.SignTx(types.NewContractCreation(b.txPool.Nonce(testBankAddress), big.NewInt(0), testGas, gasPrice, common.FromHex(testCode)), types.HomesteadSigner{}, testBankKey)
|
tx, _ = types.SignTx(types.NewContractCreation(b.txPool.Nonce(testBankAddress), common.Big0, testGas, gasPrice, common.FromHex(testCode)), types.HomesteadSigner{}, testBankKey)
|
||||||
} else {
|
} else {
|
||||||
tx, _ = types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), testUserAddress, big.NewInt(1000), params.TxGas, gasPrice, nil), types.HomesteadSigner{}, testBankKey)
|
tx, _ = types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), testUserAddress, big.NewInt(1000), params.TxGas, gasPrice, nil), types.HomesteadSigner{}, testBankKey)
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +364,7 @@ func TestGetSealingWorkPostMerge(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
local := new(params.ChainConfig)
|
local := new(params.ChainConfig)
|
||||||
*local = *ethashChainConfig
|
*local = *ethashChainConfig
|
||||||
local.TerminalTotalDifficulty = big.NewInt(0)
|
local.TerminalTotalDifficulty = common.Big0
|
||||||
testGetSealingWork(t, local, ethash.NewFaker())
|
testGetSealingWork(t, local, ethash.NewFaker())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
166
params/config.go
166
params/config.go
|
|
@ -38,7 +38,7 @@ var (
|
||||||
|
|
||||||
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
||||||
MainnetChainConfig = &ChainConfig{
|
MainnetChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(1_150_000),
|
HomesteadBlock: big.NewInt(1_150_000),
|
||||||
DAOForkBlock: big.NewInt(1_920_000),
|
DAOForkBlock: big.NewInt(1_920_000),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
|
|
@ -62,22 +62,22 @@ var (
|
||||||
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
|
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
|
||||||
HoleskyChainConfig = &ChainConfig{
|
HoleskyChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(17000),
|
ChainID: big.NewInt(17000),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: nil,
|
MuirGlacierBlock: nil,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
GrayGlacierBlock: nil,
|
GrayGlacierBlock: nil,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
MergeNetsplitBlock: nil,
|
MergeNetsplitBlock: nil,
|
||||||
ShanghaiTime: newUint64(1696000704),
|
ShanghaiTime: newUint64(1696000704),
|
||||||
|
|
@ -86,19 +86,19 @@ var (
|
||||||
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
|
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
|
||||||
SepoliaChainConfig = &ChainConfig{
|
SepoliaChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(11155111),
|
ChainID: big.NewInt(11155111),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
GrayGlacierBlock: nil,
|
GrayGlacierBlock: nil,
|
||||||
TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000),
|
TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000),
|
||||||
|
|
@ -110,15 +110,15 @@ var (
|
||||||
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
|
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
|
||||||
GoerliChainConfig = &ChainConfig{
|
GoerliChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(5),
|
ChainID: big.NewInt(5),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(1_561_651),
|
IstanbulBlock: big.NewInt(1_561_651),
|
||||||
MuirGlacierBlock: nil,
|
MuirGlacierBlock: nil,
|
||||||
BerlinBlock: big.NewInt(4_460_644),
|
BerlinBlock: big.NewInt(4_460_644),
|
||||||
|
|
@ -136,21 +136,21 @@ var (
|
||||||
// and accepted by the Ethereum core developers into the Ethash consensus.
|
// and accepted by the Ethereum core developers into the Ethash consensus.
|
||||||
AllEthashProtocolChanges = &ChainConfig{
|
AllEthashProtocolChanges = &ChainConfig{
|
||||||
ChainID: big.NewInt(1337),
|
ChainID: big.NewInt(1337),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: nil,
|
MergeNetsplitBlock: nil,
|
||||||
ShanghaiTime: nil,
|
ShanghaiTime: nil,
|
||||||
CancunTime: nil,
|
CancunTime: nil,
|
||||||
|
|
@ -164,21 +164,21 @@ var (
|
||||||
|
|
||||||
AllDevChainProtocolChanges = &ChainConfig{
|
AllDevChainProtocolChanges = &ChainConfig{
|
||||||
ChainID: big.NewInt(1337),
|
ChainID: big.NewInt(1337),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
ShanghaiTime: newUint64(0),
|
ShanghaiTime: newUint64(0),
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,19 +186,19 @@ var (
|
||||||
// and accepted by the Ethereum core developers into the Clique consensus.
|
// and accepted by the Ethereum core developers into the Clique consensus.
|
||||||
AllCliqueProtocolChanges = &ChainConfig{
|
AllCliqueProtocolChanges = &ChainConfig{
|
||||||
ChainID: big.NewInt(1337),
|
ChainID: big.NewInt(1337),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: nil,
|
ArrowGlacierBlock: nil,
|
||||||
GrayGlacierBlock: nil,
|
GrayGlacierBlock: nil,
|
||||||
MergeNetsplitBlock: nil,
|
MergeNetsplitBlock: nil,
|
||||||
|
|
@ -215,22 +215,22 @@ var (
|
||||||
// TestChainConfig contains every protocol change (EIPs) introduced
|
// TestChainConfig contains every protocol change (EIPs) introduced
|
||||||
// and accepted by the Ethereum core developers for testing purposes.
|
// and accepted by the Ethereum core developers for testing purposes.
|
||||||
TestChainConfig = &ChainConfig{
|
TestChainConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: nil,
|
MergeNetsplitBlock: nil,
|
||||||
ShanghaiTime: nil,
|
ShanghaiTime: nil,
|
||||||
CancunTime: nil,
|
CancunTime: nil,
|
||||||
|
|
@ -245,7 +245,7 @@ var (
|
||||||
// NonActivatedConfig defines the chain configuration without activating
|
// NonActivatedConfig defines the chain configuration without activating
|
||||||
// any protocol change (EIPs).
|
// any protocol change (EIPs).
|
||||||
NonActivatedConfig = &ChainConfig{
|
NonActivatedConfig = &ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: nil,
|
HomesteadBlock: nil,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -48,19 +49,19 @@ func TestCheckCompatible(t *testing.T) {
|
||||||
headBlock: 3,
|
headBlock: 3,
|
||||||
wantErr: &ConfigCompatError{
|
wantErr: &ConfigCompatError{
|
||||||
What: "Homestead fork block",
|
What: "Homestead fork block",
|
||||||
StoredBlock: big.NewInt(0),
|
StoredBlock: common.Big0,
|
||||||
NewBlock: nil,
|
NewBlock: nil,
|
||||||
RewindToBlock: 0,
|
RewindToBlock: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stored: AllEthashProtocolChanges,
|
stored: AllEthashProtocolChanges,
|
||||||
new: &ChainConfig{HomesteadBlock: big.NewInt(1)},
|
new: &ChainConfig{HomesteadBlock: common.Big1},
|
||||||
headBlock: 3,
|
headBlock: 3,
|
||||||
wantErr: &ConfigCompatError{
|
wantErr: &ConfigCompatError{
|
||||||
What: "Homestead fork block",
|
What: "Homestead fork block",
|
||||||
StoredBlock: big.NewInt(0),
|
StoredBlock: common.Big0,
|
||||||
NewBlock: big.NewInt(1),
|
NewBlock: common.Big1,
|
||||||
RewindToBlock: 0,
|
RewindToBlock: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -125,15 +126,15 @@ func TestConfigRules(t *testing.T) {
|
||||||
ShanghaiTime: newUint64(500),
|
ShanghaiTime: newUint64(500),
|
||||||
}
|
}
|
||||||
var stamp uint64
|
var stamp uint64
|
||||||
if r := c.Rules(big.NewInt(0), true, stamp); r.IsShanghai {
|
if r := c.Rules(common.Big0, true, stamp); r.IsShanghai {
|
||||||
t.Errorf("expected %v to not be shanghai", stamp)
|
t.Errorf("expected %v to not be shanghai", stamp)
|
||||||
}
|
}
|
||||||
stamp = 500
|
stamp = 500
|
||||||
if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai {
|
if r := c.Rules(common.Big0, true, stamp); !r.IsShanghai {
|
||||||
t.Errorf("expected %v to be shanghai", stamp)
|
t.Errorf("expected %v to be shanghai", stamp)
|
||||||
}
|
}
|
||||||
stamp = math.MaxInt64
|
stamp = math.MaxInt64
|
||||||
if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai {
|
if r := c.Rules(common.Big0, true, stamp); !r.IsShanghai {
|
||||||
t.Errorf("expected %v to be shanghai", stamp)
|
t.Errorf("expected %v to be shanghai", stamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
@ -541,8 +542,8 @@ var decodeTests = []decodeTest{
|
||||||
{input: "C0", ptr: new(string), error: "rlp: expected input string or byte for string"},
|
{input: "C0", ptr: new(string), error: "rlp: expected input string or byte for string"},
|
||||||
|
|
||||||
// big ints
|
// big ints
|
||||||
{input: "80", ptr: new(*big.Int), value: big.NewInt(0)},
|
{input: "80", ptr: new(*big.Int), value: common.Big0},
|
||||||
{input: "01", ptr: new(*big.Int), value: big.NewInt(1)},
|
{input: "01", ptr: new(*big.Int), value: common.Big1},
|
||||||
{input: "89FFFFFFFFFFFFFFFFFF", ptr: new(*big.Int), value: veryBigInt},
|
{input: "89FFFFFFFFFFFFFFFFFF", ptr: new(*big.Int), value: veryBigInt},
|
||||||
{input: "B848FFFFFFFFFFFFFFFFF800000000000000001BFFFFFFFFFFFFFFFFC8000000000000000045FFFFFFFFFFFFFFFFC800000000000000001BFFFFFFFFFFFFFFFFF8000000000000000001", ptr: new(*big.Int), value: veryVeryBigInt},
|
{input: "B848FFFFFFFFFFFFFFFFF800000000000000001BFFFFFFFFFFFFFFFFC8000000000000000045FFFFFFFFFFFFFFFFC800000000000000001BFFFFFFFFFFFFFFFFF8000000000000000001", ptr: new(*big.Int), value: veryVeryBigInt},
|
||||||
{input: "10", ptr: new(big.Int), value: *big.NewInt(16)}, // non-pointer also works
|
{input: "10", ptr: new(big.Int), value: *big.NewInt(16)}, // non-pointer also works
|
||||||
|
|
@ -753,7 +754,7 @@ var decodeTests = []decodeTest{
|
||||||
{
|
{
|
||||||
input: "C20102",
|
input: "C20102",
|
||||||
ptr: new(optionalBigIntField),
|
ptr: new(optionalBigIntField),
|
||||||
value: optionalBigIntField{A: 1, B: big.NewInt(2)},
|
value: optionalBigIntField{A: 1, B: common.Big2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "C101",
|
input: "C101",
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
@ -108,11 +109,11 @@ var encTests = []encTest{
|
||||||
{val: uint64(0xFFFFFFFFFFFFFFFF), output: "88FFFFFFFFFFFFFFFF"},
|
{val: uint64(0xFFFFFFFFFFFFFFFF), output: "88FFFFFFFFFFFFFFFF"},
|
||||||
|
|
||||||
// big integers (should match uint for small values)
|
// big integers (should match uint for small values)
|
||||||
{val: big.NewInt(0), output: "80"},
|
{val: common.Big0, output: "80"},
|
||||||
{val: big.NewInt(1), output: "01"},
|
{val: common.Big1, output: "01"},
|
||||||
{val: big.NewInt(127), output: "7F"},
|
{val: big.NewInt(127), output: "7F"},
|
||||||
{val: big.NewInt(128), output: "8180"},
|
{val: big.NewInt(128), output: "8180"},
|
||||||
{val: big.NewInt(256), output: "820100"},
|
{val: common.Big256, output: "820100"},
|
||||||
{val: big.NewInt(1024), output: "820400"},
|
{val: big.NewInt(1024), output: "820400"},
|
||||||
{val: big.NewInt(0xFFFFFF), output: "83FFFFFF"},
|
{val: big.NewInt(0xFFFFFF), output: "83FFFFFF"},
|
||||||
{val: big.NewInt(0xFFFFFFFF), output: "84FFFFFFFF"},
|
{val: big.NewInt(0xFFFFFFFF), output: "84FFFFFFFF"},
|
||||||
|
|
@ -141,7 +142,7 @@ var encTests = []encTest{
|
||||||
},
|
},
|
||||||
|
|
||||||
// non-pointer big.Int
|
// non-pointer big.Int
|
||||||
{val: *big.NewInt(0), output: "80"},
|
{val: *common.Big0, output: "80"},
|
||||||
{val: *big.NewInt(0xFFFFFF), output: "83FFFFFF"},
|
{val: *big.NewInt(0xFFFFFF), output: "83FFFFFF"},
|
||||||
|
|
||||||
// negative ints are not supported
|
// negative ints are not supported
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func (ui *headlessUi) ApproveTx(request *core.SignTxRequest) (core.SignTxRespons
|
||||||
case "M": // modify
|
case "M": // modify
|
||||||
// The headless UI always modifies the transaction
|
// The headless UI always modifies the transaction
|
||||||
old := big.Int(request.Transaction.Value)
|
old := big.Int(request.Transaction.Value)
|
||||||
newVal := new(big.Int).Add(&old, big.NewInt(1))
|
newVal := new(big.Int).Add(&old, common.Big1)
|
||||||
request.Transaction.Value = hexutil.Big(*newVal)
|
request.Transaction.Value = hexutil.Big(*newVal)
|
||||||
return core.SignTxResponse{request.Transaction, true}, nil
|
return core.SignTxResponse{request.Transaction, true}, nil
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -857,7 +856,7 @@ func TestGnosisSafe(t *testing.T) {
|
||||||
if bytes.Equal(sighash, gnosisTx.InputExpHash.Bytes()) {
|
if bytes.Equal(sighash, gnosisTx.InputExpHash.Bytes()) {
|
||||||
t.Fatal("expected inequality")
|
t.Fatal("expected inequality")
|
||||||
}
|
}
|
||||||
gnosisTx.ChainId = (*math.HexOrDecimal256)(big.NewInt(1))
|
gnosisTx.ChainId = (*math.HexOrDecimal256)(common.Big1)
|
||||||
sighash, _, _ = apitypes.TypedDataAndHash(gnosisTx.ToTypedData())
|
sighash, _, _ = apitypes.TypedDataAndHash(gnosisTx.ToTypedData())
|
||||||
if !bytes.Equal(sighash, gnosisTx.InputExpHash.Bytes()) {
|
if !bytes.Equal(sighash, gnosisTx.InputExpHash.Bytes()) {
|
||||||
t.Fatal("expected equality")
|
t.Fatal("expected equality")
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func TestNewUnpacker(t *testing.T) {
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
[]byte{0x64, 0x61, 0x76, 0x65},
|
[]byte{0x64, 0x61, 0x76, 0x65},
|
||||||
true,
|
true,
|
||||||
[]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
|
[]*big.Int{common.Big1, common.Big2, common.Big3},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
`[{"type":"function","name":"send","inputs":[{"type":"uint256"}]}]`,
|
`[{"type":"function","name":"send","inputs":[{"type":"uint256"}]}]`,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||||
|
|
@ -52,7 +51,7 @@ func (db *Database) ValidateTransaction(selector *string, tx *apitypes.SendTxArg
|
||||||
// e.g. https://github.com/ethereum/go-ethereum/issues/16106.
|
// e.g. https://github.com/ethereum/go-ethereum/issues/16106.
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
// Prevent sending ether into black hole (show stopper)
|
// Prevent sending ether into black hole (show stopper)
|
||||||
if tx.Value.ToInt().Cmp(big.NewInt(0)) > 0 {
|
if tx.Value.ToInt().Cmp(common.Big0) > 0 {
|
||||||
return nil, errors.New("transaction will create a contract with value but empty code")
|
return nil, errors.New("transaction will create a contract with value but empty code")
|
||||||
}
|
}
|
||||||
// No value submitted at least, critically Warn, but don't blow up
|
// No value submitted at least, critically Warn, but don't blow up
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,13 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mainnetChainConfig = params.ChainConfig{
|
mainnetChainConfig = params.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(1150000),
|
HomesteadBlock: big.NewInt(1150000),
|
||||||
DAOForkBlock: big.NewInt(1920000),
|
DAOForkBlock: big.NewInt(1920000),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
|
|
@ -36,11 +37,11 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
ropstenChainConfig = params.ChainConfig{
|
ropstenChainConfig = params.ChainConfig{
|
||||||
ChainID: big.NewInt(3),
|
ChainID: common.Big3,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(10),
|
EIP155Block: big.NewInt(10),
|
||||||
EIP158Block: big.NewInt(10),
|
EIP158Block: big.NewInt(10),
|
||||||
ByzantiumBlock: big.NewInt(1_700_000),
|
ByzantiumBlock: big.NewInt(1_700_000),
|
||||||
|
|
@ -74,27 +75,27 @@ func TestDifficulty(t *testing.T) {
|
||||||
dt.config("Frontier", params.ChainConfig{})
|
dt.config("Frontier", params.ChainConfig{})
|
||||||
|
|
||||||
dt.config("Homestead", params.ChainConfig{
|
dt.config("Homestead", params.ChainConfig{
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
})
|
})
|
||||||
|
|
||||||
dt.config("Byzantium", params.ChainConfig{
|
dt.config("Byzantium", params.ChainConfig{
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
})
|
})
|
||||||
|
|
||||||
dt.config("Frontier", ropstenChainConfig)
|
dt.config("Frontier", ropstenChainConfig)
|
||||||
dt.config("MainNetwork", mainnetChainConfig)
|
dt.config("MainNetwork", mainnetChainConfig)
|
||||||
dt.config("CustomMainNetwork", mainnetChainConfig)
|
dt.config("CustomMainNetwork", mainnetChainConfig)
|
||||||
dt.config("Constantinople", params.ChainConfig{
|
dt.config("Constantinople", params.ChainConfig{
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
})
|
})
|
||||||
dt.config("EIP2384", params.ChainConfig{
|
dt.config("EIP2384", params.ChainConfig{
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
})
|
})
|
||||||
dt.config("EIP4345", params.ChainConfig{
|
dt.config("EIP4345", params.ChainConfig{
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
})
|
})
|
||||||
dt.config("EIP5133", params.ChainConfig{
|
dt.config("EIP5133", params.ChainConfig{
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
})
|
})
|
||||||
dt.config("difficulty.json", mainnetChainConfig)
|
dt.config("difficulty.json", mainnetChainConfig)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
cloudflare "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
cloudflare "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
||||||
google "github.com/ethereum/go-ethereum/crypto/bn256/google"
|
google "github.com/ethereum/go-ethereum/crypto/bn256/google"
|
||||||
)
|
)
|
||||||
|
|
@ -162,12 +163,12 @@ func fuzzPair(data []byte) int {
|
||||||
// different but also correct outputs, we need to scale the output by s
|
// different but also correct outputs, we need to scale the output by s
|
||||||
|
|
||||||
u, _ := new(big.Int).SetString("0x44e992b44a6909f1", 0)
|
u, _ := new(big.Int).SetString("0x44e992b44a6909f1", 0)
|
||||||
u_exp2 := new(big.Int).Exp(u, big.NewInt(2), nil) // u^2
|
u_exp2 := new(big.Int).Exp(u, common.Big2, nil) // u^2
|
||||||
u_6_exp2 := new(big.Int).Mul(big.NewInt(6), u_exp2) // 6*u^2
|
u_6_exp2 := new(big.Int).Mul(big.NewInt(6), u_exp2) // 6*u^2
|
||||||
u_3 := new(big.Int).Mul(big.NewInt(3), u) // 3*u
|
u_3 := new(big.Int).Mul(common.Big3, u) // 3*u
|
||||||
inner := u_6_exp2.Add(u_6_exp2, u_3) // 6*u^2 + 3*u
|
inner := u_6_exp2.Add(u_6_exp2, u_3) // 6*u^2 + 3*u
|
||||||
inner.Add(inner, big.NewInt(1)) // 6*u^2 + 3*u + 1
|
inner.Add(inner, common.Big1) // 6*u^2 + 3*u + 1
|
||||||
u_2 := new(big.Int).Mul(big.NewInt(2), u) // 2*u
|
u_2 := new(big.Int).Mul(common.Big2, u) // 2*u
|
||||||
s := u_2.Mul(u_2, inner) // 2*u(6*u^2 + 3*u + 1)
|
s := u_2.Mul(u_2, inner) // 2*u(6*u^2 + 3*u + 1)
|
||||||
|
|
||||||
gRes := new(bn254.GT)
|
gRes := new(bn254.GT)
|
||||||
|
|
|
||||||
475
tests/init.go
475
tests/init.go
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -29,311 +30,311 @@ func u64(val uint64) *uint64 { return &val }
|
||||||
// Forks table defines supported forks and their chain config.
|
// Forks table defines supported forks and their chain config.
|
||||||
var Forks = map[string]*params.ChainConfig{
|
var Forks = map[string]*params.ChainConfig{
|
||||||
"Frontier": {
|
"Frontier": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
},
|
},
|
||||||
"Homestead": {
|
"Homestead": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"EIP150": {
|
"EIP150": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
},
|
},
|
||||||
"EIP158": {
|
"EIP158": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
},
|
},
|
||||||
"Byzantium": {
|
"Byzantium": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(0),
|
DAOForkBlock: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"Constantinople": {
|
"Constantinople": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(0),
|
DAOForkBlock: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(10000000),
|
PetersburgBlock: big.NewInt(10000000),
|
||||||
},
|
},
|
||||||
"ConstantinopleFix": {
|
"ConstantinopleFix": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(0),
|
DAOForkBlock: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"Istanbul": {
|
"Istanbul": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(0),
|
DAOForkBlock: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"MuirGlacier": {
|
"MuirGlacier": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(0),
|
DAOForkBlock: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"FrontierToHomesteadAt5": {
|
"FrontierToHomesteadAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(5),
|
HomesteadBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"HomesteadToEIP150At5": {
|
"HomesteadToEIP150At5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(5),
|
EIP150Block: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"HomesteadToDaoAt5": {
|
"HomesteadToDaoAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
DAOForkBlock: big.NewInt(5),
|
DAOForkBlock: big.NewInt(5),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
},
|
},
|
||||||
"EIP158ToByzantiumAt5": {
|
"EIP158ToByzantiumAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(5),
|
ByzantiumBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"ByzantiumToConstantinopleAt5": {
|
"ByzantiumToConstantinopleAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(5),
|
ConstantinopleBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"ByzantiumToConstantinopleFixAt5": {
|
"ByzantiumToConstantinopleFixAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(5),
|
ConstantinopleBlock: big.NewInt(5),
|
||||||
PetersburgBlock: big.NewInt(5),
|
PetersburgBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"ConstantinopleFixToIstanbulAt5": {
|
"ConstantinopleFixToIstanbulAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(5),
|
IstanbulBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"Berlin": {
|
"Berlin": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"BerlinToLondonAt5": {
|
"BerlinToLondonAt5": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(5),
|
LondonBlock: big.NewInt(5),
|
||||||
},
|
},
|
||||||
"London": {
|
"London": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"ArrowGlacier": {
|
"ArrowGlacier": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"ArrowGlacierToMergeAtDiffC0000": {
|
"ArrowGlacierToMergeAtDiffC0000": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0xC0000),
|
TerminalTotalDifficulty: big.NewInt(0xC0000),
|
||||||
},
|
},
|
||||||
"GrayGlacier": {
|
"GrayGlacier": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: common.Big0,
|
||||||
},
|
},
|
||||||
"Merge": {
|
"Merge": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
},
|
},
|
||||||
"Shanghai": {
|
"Shanghai": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
ShanghaiTime: u64(0),
|
ShanghaiTime: u64(0),
|
||||||
},
|
},
|
||||||
"MergeToShanghaiAtTime15k": {
|
"MergeToShanghaiAtTime15k": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
ShanghaiTime: u64(15_000),
|
ShanghaiTime: u64(15_000),
|
||||||
},
|
},
|
||||||
"Cancun": {
|
"Cancun": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
ShanghaiTime: u64(0),
|
ShanghaiTime: u64(0),
|
||||||
CancunTime: u64(0),
|
CancunTime: u64(0),
|
||||||
},
|
},
|
||||||
"ShanghaiToCancunAtTime15k": {
|
"ShanghaiToCancunAtTime15k": {
|
||||||
ChainID: big.NewInt(1),
|
ChainID: common.Big1,
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: common.Big0,
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: common.Big0,
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: common.Big0,
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: common.Big0,
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: common.Big0,
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: common.Big0,
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: common.Big0,
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: common.Big0,
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: common.Big0,
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: common.Big0,
|
||||||
MergeNetsplitBlock: big.NewInt(0),
|
MergeNetsplitBlock: common.Big0,
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: common.Big0,
|
||||||
ShanghaiTime: u64(0),
|
ShanghaiTime: u64(0),
|
||||||
CancunTime: u64(15_000),
|
CancunTime: u64(15_000),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
||||||
if config.IsLondon(new(big.Int)) && t.json.Env.Random != nil {
|
if config.IsLondon(new(big.Int)) && t.json.Env.Random != nil {
|
||||||
rnd := common.BigToHash(t.json.Env.Random)
|
rnd := common.BigToHash(t.json.Env.Random)
|
||||||
context.Random = &rnd
|
context.Random = &rnd
|
||||||
context.Difficulty = big.NewInt(0)
|
context.Difficulty = common.Big0
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, config, vmconfig)
|
evm := vm.NewEVM(context, txContext, statedb, config, vmconfig)
|
||||||
|
|
||||||
|
|
@ -357,7 +357,7 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
|
||||||
if t.json.Env.Random != nil {
|
if t.json.Env.Random != nil {
|
||||||
// Post-Merge
|
// Post-Merge
|
||||||
genesis.Mixhash = common.BigToHash(t.json.Env.Random)
|
genesis.Mixhash = common.BigToHash(t.json.Env.Random)
|
||||||
genesis.Difficulty = big.NewInt(0)
|
genesis.Difficulty = common.Big0
|
||||||
}
|
}
|
||||||
return genesis
|
return genesis
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -352,8 +352,8 @@ func TestStacktrieNotModifyValues(t *testing.T) {
|
||||||
st = NewStackTrie(nil)
|
st = NewStackTrie(nil)
|
||||||
}
|
}
|
||||||
// Test with a larger trie
|
// Test with a larger trie
|
||||||
keyB := big.NewInt(1)
|
keyB := common.Big1
|
||||||
keyDelta := big.NewInt(1)
|
keyDelta := common.Big1
|
||||||
var vals [][]byte
|
var vals [][]byte
|
||||||
getValue := func(i int) []byte {
|
getValue := func(i int) []byte {
|
||||||
if i%2 == 0 { // large
|
if i%2 == 0 { // large
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue