Adding L1MessageSender to Transaction (#4)
* Adding L1MessageSender to Transaction * Adding logic to omit L1MessageSender in encoding / decoding when nil and never use it in hash computation Co-authored-by: ben-chain <ben@pseudonym.party>
This commit is contained in:
parent
e14cfa5576
commit
67ee6f3cb0
@ -246,7 +246,7 @@ func TestSimulatedBackend_NonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -281,7 +281,7 @@ func TestSimulatedBackend_SendTransaction(t *testing.T) {
|
|||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -316,7 +316,7 @@ func TestSimulatedBackend_TransactionByHash(t *testing.T) {
|
|||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -479,7 +479,7 @@ func TestSimulatedBackend_TransactionCount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -538,7 +538,7 @@ func TestSimulatedBackend_TransactionInBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -597,7 +597,7 @@ func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -620,7 +620,7 @@ func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make a new transaction with a nonce of 1
|
// make a new transaction with a nonce of 1
|
||||||
tx = types.NewTransaction(uint64(1), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx = types.NewTransaction(uint64(1), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@ -653,7 +653,7 @@ func TestSimulatedBackend_TransactionReceipt(t *testing.T) {
|
|||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
|
@ -229,7 +229,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
|
|||||||
if contract == nil {
|
if contract == nil {
|
||||||
rawTx = types.NewContractCreation(nonce, value, gasLimit, gasPrice, input)
|
rawTx = types.NewContractCreation(nonce, value, gasLimit, gasPrice, input)
|
||||||
} else {
|
} else {
|
||||||
rawTx = types.NewTransaction(nonce, c.address, value, gasLimit, gasPrice, input)
|
rawTx = types.NewTransaction(nonce, c.address, value, gasLimit, gasPrice, input, nil)
|
||||||
}
|
}
|
||||||
if opts.Signer == nil {
|
if opts.Signer == nil {
|
||||||
return nil, errors.New("no signer to authorize the transaction with")
|
return nil, errors.New("no signer to authorize the transaction with")
|
||||||
|
@ -490,7 +490,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
amount = new(big.Int).Mul(amount, new(big.Int).Exp(big.NewInt(5), big.NewInt(int64(msg.Tier)), nil))
|
amount = new(big.Int).Mul(amount, new(big.Int).Exp(big.NewInt(5), big.NewInt(int64(msg.Tier)), nil))
|
||||||
amount = new(big.Int).Div(amount, new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(msg.Tier)), nil))
|
amount = new(big.Int).Div(amount, new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(msg.Tier)), nil))
|
||||||
|
|
||||||
tx := types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil)
|
tx := types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil, nil)
|
||||||
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainID)
|
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.lock.Unlock()
|
f.lock.Unlock()
|
||||||
|
@ -65,7 +65,7 @@ func TestReimportMirroredState(t *testing.T) {
|
|||||||
// We want to simulate an empty middle block, having the same state as the
|
// We want to simulate an empty middle block, having the same state as the
|
||||||
// first one. The last is needs a state change again to force a reorg.
|
// first one. The last is needs a state change again to force a reorg.
|
||||||
if i != 1 {
|
if i != 1 {
|
||||||
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr), common.Address{0x00}, new(big.Int), params.TxGas, nil, nil), signer, key)
|
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(addr), common.Address{0x00}, new(big.Int), params.TxGas, nil, nil, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) {
|
|||||||
toaddr := common.Address{}
|
toaddr := common.Address{}
|
||||||
data := make([]byte, nbytes)
|
data := make([]byte, nbytes)
|
||||||
gas, _ := IntrinsicGas(data, false, false, false)
|
gas, _ := IntrinsicGas(data, false, false, false)
|
||||||
tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data), types.HomesteadSigner{}, benchRootKey)
|
tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data, nil), types.HomesteadSigner{}, benchRootKey)
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,14 +119,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
to := (from + 1) % naccounts
|
to := (from + 1) % naccounts
|
||||||
tx := types.NewTransaction(
|
tx := types.NewTransaction(gen.TxNonce(ringAddrs[from]), ringAddrs[to], benchRootFunds, params.TxGas, nil, nil, nil)
|
||||||
gen.TxNonce(ringAddrs[from]),
|
|
||||||
ringAddrs[to],
|
|
||||||
benchRootFunds,
|
|
||||||
params.TxGas,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, ringKeys[from])
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, ringKeys[from])
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
from = to
|
from = to
|
||||||
|
@ -607,7 +607,7 @@ func TestFastVsFullChains(t *testing.T) {
|
|||||||
// If the block number is multiple of 3, send a few bonus transactions to the miner
|
// If the block number is multiple of 3, send a few bonus transactions to the miner
|
||||||
if i%3 == 2 {
|
if i%3 == 2 {
|
||||||
for j := 0; j < i%4+1; j++ {
|
for j := 0; j < i%4+1; j++ {
|
||||||
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, nil, nil), signer, key)
|
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{0x00}, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -840,8 +840,8 @@ func TestChainTxReorgs(t *testing.T) {
|
|||||||
// Create two transactions shared between the chains:
|
// Create two transactions shared between the chains:
|
||||||
// - postponed: transaction included at a later block in the forked chain
|
// - postponed: transaction included at a later block in the forked chain
|
||||||
// - swapped: transaction included at the same block number in the forked chain
|
// - swapped: transaction included at the same block number in the forked chain
|
||||||
postponed, _ := types.SignTx(types.NewTransaction(0, addr1, big.NewInt(1000), params.TxGas, nil, nil), signer, key1)
|
postponed, _ := types.SignTx(types.NewTransaction(0, addr1, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key1)
|
||||||
swapped, _ := types.SignTx(types.NewTransaction(1, addr1, big.NewInt(1000), params.TxGas, nil, nil), signer, key1)
|
swapped, _ := types.SignTx(types.NewTransaction(1, addr1, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key1)
|
||||||
|
|
||||||
// Create two transactions that will be dropped by the forked chain:
|
// Create two transactions that will be dropped by the forked chain:
|
||||||
// - pastDrop: transaction dropped retroactively from a past block
|
// - pastDrop: transaction dropped retroactively from a past block
|
||||||
@ -857,13 +857,13 @@ func TestChainTxReorgs(t *testing.T) {
|
|||||||
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {
|
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
pastDrop, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr2, big.NewInt(1000), params.TxGas, nil, nil), signer, key2)
|
pastDrop, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr2, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key2)
|
||||||
|
|
||||||
gen.AddTx(pastDrop) // This transaction will be dropped in the fork from below the split point
|
gen.AddTx(pastDrop) // This transaction will be dropped in the fork from below the split point
|
||||||
gen.AddTx(postponed) // This transaction will be postponed till block #3 in the fork
|
gen.AddTx(postponed) // This transaction will be postponed till block #3 in the fork
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
freshDrop, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr2, big.NewInt(1000), params.TxGas, nil, nil), signer, key2)
|
freshDrop, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr2, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key2)
|
||||||
|
|
||||||
gen.AddTx(freshDrop) // This transaction will be dropped in the fork from exactly at the split point
|
gen.AddTx(freshDrop) // This transaction will be dropped in the fork from exactly at the split point
|
||||||
gen.AddTx(swapped) // This transaction will be swapped out at the exact height
|
gen.AddTx(swapped) // This transaction will be swapped out at the exact height
|
||||||
@ -882,18 +882,18 @@ func TestChainTxReorgs(t *testing.T) {
|
|||||||
chain, _ = GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 5, func(i int, gen *BlockGen) {
|
chain, _ = GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 5, func(i int, gen *BlockGen) {
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
pastAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil), signer, key3)
|
pastAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key3)
|
||||||
gen.AddTx(pastAdd) // This transaction needs to be injected during reorg
|
gen.AddTx(pastAdd) // This transaction needs to be injected during reorg
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
gen.AddTx(postponed) // This transaction was postponed from block #1 in the original chain
|
gen.AddTx(postponed) // This transaction was postponed from block #1 in the original chain
|
||||||
gen.AddTx(swapped) // This transaction was swapped from the exact current spot in the original chain
|
gen.AddTx(swapped) // This transaction was swapped from the exact current spot in the original chain
|
||||||
|
|
||||||
freshAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil), signer, key3)
|
freshAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key3)
|
||||||
gen.AddTx(freshAdd) // This transaction will be added exactly at reorg time
|
gen.AddTx(freshAdd) // This transaction will be added exactly at reorg time
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
futureAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil), signer, key3)
|
futureAdd, _ = types.SignTx(types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key3)
|
||||||
gen.AddTx(futureAdd) // This transaction will be added after a full reorg
|
gen.AddTx(futureAdd) // This transaction will be added after a full reorg
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1338,7 +1338,7 @@ func TestEIP155Transition(t *testing.T) {
|
|||||||
tx *types.Transaction
|
tx *types.Transaction
|
||||||
err error
|
err error
|
||||||
basicTx = func(signer types.Signer) (*types.Transaction, error) {
|
basicTx = func(signer types.Signer) (*types.Transaction, error) {
|
||||||
return types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{}, new(big.Int), 21000, new(big.Int), nil), signer, key)
|
return types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{}, new(big.Int), 21000, new(big.Int), nil, nil), signer, key)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
switch i {
|
switch i {
|
||||||
@ -1401,7 +1401,7 @@ func TestEIP155Transition(t *testing.T) {
|
|||||||
tx *types.Transaction
|
tx *types.Transaction
|
||||||
err error
|
err error
|
||||||
basicTx = func(signer types.Signer) (*types.Transaction, error) {
|
basicTx = func(signer types.Signer) (*types.Transaction, error) {
|
||||||
return types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{}, new(big.Int), 21000, new(big.Int), nil), signer, key)
|
return types.SignTx(types.NewTransaction(block.TxNonce(address), common.Address{}, new(big.Int), 21000, new(big.Int), nil, nil), signer, key)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
@ -1449,11 +1449,11 @@ func TestEIP161AccountRemoval(t *testing.T) {
|
|||||||
)
|
)
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil), signer, key)
|
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil, nil), signer, key)
|
||||||
case 1:
|
case 1:
|
||||||
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil), signer, key)
|
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil, nil), signer, key)
|
||||||
case 2:
|
case 2:
|
||||||
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil), signer, key)
|
tx, err = types.SignTx(types.NewTransaction(block.TxNonce(address), theAddr, new(big.Int), 21000, new(big.Int), nil, nil), signer, key)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -2162,7 +2162,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, big.NewInt(1), nil), signer, testBankKey)
|
tx, err := types.SignTx(types.NewTransaction(uniq, recipient, big.NewInt(1), params.TxGas, big.NewInt(1), nil, nil), signer, testBankKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
@ -2342,12 +2342,10 @@ func TestDeleteCreateRevert(t *testing.T) {
|
|||||||
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 1, func(i int, b *BlockGen) {
|
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 1, func(i int, b *BlockGen) {
|
||||||
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, big.NewInt(1), nil, nil), types.HomesteadSigner{}, key)
|
||||||
big.NewInt(0), 50000, big.NewInt(1), 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, big.NewInt(1), nil, nil), types.HomesteadSigner{}, key)
|
||||||
big.NewInt(0), 100000, big.NewInt(1), nil), types.HomesteadSigner{}, key)
|
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
|
@ -54,13 +54,13 @@ func ExampleGenerateChain() {
|
|||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
// In block 1, addr1 sends addr2 some ether.
|
// In block 1, addr1 sends addr2 some ether.
|
||||||
tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1)
|
tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, key1)
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
case 1:
|
case 1:
|
||||||
// In block 2, addr1 sends some more ether to addr2.
|
// In block 2, addr1 sends some more ether to addr2.
|
||||||
// addr2 passes it on to addr3.
|
// addr2 passes it on to addr3.
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(1000), params.TxGas, nil, nil), signer, key1)
|
tx1, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key1)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr3, big.NewInt(1000), params.TxGas, nil, nil), signer, key2)
|
tx2, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr3, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, key2)
|
||||||
gen.AddTx(tx1)
|
gen.AddTx(tx1)
|
||||||
gen.AddTx(tx2)
|
gen.AddTx(tx2)
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -273,8 +273,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"), big.NewInt(1), 1, big.NewInt(1), nil, nil)
|
||||||
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil)
|
tx2 := types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil, nil)
|
||||||
|
|
||||||
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
body := &types.Body{Transactions: types.Transactions{tx1, tx2}}
|
||||||
|
|
||||||
|
@ -66,9 +66,12 @@ func TestLookupStorage(t *testing.T) {
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
db := NewMemoryDatabase()
|
db := NewMemoryDatabase()
|
||||||
|
|
||||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
sender1 := common.BytesToAddress([]byte{0x44})
|
||||||
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
sender2 := common.BytesToAddress([]byte{0x55})
|
||||||
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
|
||||||
|
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}, &sender1)
|
||||||
|
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}, &sender2)
|
||||||
|
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}, nil)
|
||||||
txs := []*types.Transaction{tx1, tx2, tx3}
|
txs := []*types.Transaction{tx1, tx2, tx3}
|
||||||
|
|
||||||
block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, nil)
|
block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, nil)
|
||||||
|
@ -73,7 +73,7 @@ func transaction(nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) *types.Tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(100), gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
|
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(100), gaslimit, gasprice, nil, nil), types.HomesteadSigner{}, key)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func pricedDataTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key
|
|||||||
data := make([]byte, bytes)
|
data := make([]byte, bytes)
|
||||||
rand.Read(data)
|
rand.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{}, big.NewInt(0), gaslimit, gasprice, data, nil), types.HomesteadSigner{}, key)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ func TestTransactionNegativeValue(t *testing.T) {
|
|||||||
pool, key := setupTxPool()
|
pool, key := setupTxPool()
|
||||||
defer pool.Stop()
|
defer pool.Stop()
|
||||||
|
|
||||||
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, big.NewInt(1), nil, nil), types.HomesteadSigner{}, key)
|
||||||
from, _ := deriveSender(tx)
|
from, _ := deriveSender(tx)
|
||||||
pool.currentState.AddBalance(from, big.NewInt(1))
|
pool.currentState.AddBalance(from, big.NewInt(1))
|
||||||
if err := pool.AddRemote(tx); err != ErrNegativeValue {
|
if err := pool.AddRemote(tx); err != ErrNegativeValue {
|
||||||
@ -383,9 +383,9 @@ func TestTransactionDoubleNonce(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, big.NewInt(1), nil, 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, big.NewInt(2), nil, 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, big.NewInt(1), nil, 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 {
|
||||||
@ -858,7 +858,9 @@ func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) {
|
|||||||
// This logic should not hold for local transactions, unless the local tracking
|
// This logic should not hold for local transactions, unless the local tracking
|
||||||
// mechanism is disabled.
|
// mechanism is disabled.
|
||||||
func TestTransactionQueueTimeLimiting(t *testing.T) { testTransactionQueueTimeLimiting(t, false) }
|
func TestTransactionQueueTimeLimiting(t *testing.T) { testTransactionQueueTimeLimiting(t, false) }
|
||||||
func TestTransactionQueueTimeLimitingNoLocals(t *testing.T) { testTransactionQueueTimeLimiting(t, true) }
|
func TestTransactionQueueTimeLimitingNoLocals(t *testing.T) {
|
||||||
|
testTransactionQueueTimeLimiting(t, true)
|
||||||
|
}
|
||||||
|
|
||||||
func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
|
func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
|
||||||
// Reduce the eviction interval to a testable amount
|
// Reduce the eviction interval to a testable amount
|
||||||
|
@ -50,7 +50,7 @@ func TestBlockEncoding(t *testing.T) {
|
|||||||
check("Time", block.Time(), uint64(1426516743))
|
check("Time", block.Time(), uint64(1426516743))
|
||||||
check("Size", block.Size(), common.StorageSize(len(blockEnc)))
|
check("Size", block.Size(), common.StorageSize(len(blockEnc)))
|
||||||
|
|
||||||
tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), 50000, big.NewInt(10), nil)
|
tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), 50000, big.NewInt(10), nil, nil)
|
||||||
tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100"))
|
tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100"))
|
||||||
check("len(Transactions)", len(block.Transactions()), 1)
|
check("len(Transactions)", len(block.Transactions()), 1)
|
||||||
check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash())
|
check("Transactions[0].Hash", block.Transactions()[0].Hash(), tx1.Hash())
|
||||||
|
@ -26,12 +26,14 @@ func (t txdata) MarshalJSON() ([]byte, error) {
|
|||||||
R *hexutil.Big `json:"r" gencodec:"required"`
|
R *hexutil.Big `json:"r" gencodec:"required"`
|
||||||
S *hexutil.Big `json:"s" gencodec:"required"`
|
S *hexutil.Big `json:"s" gencodec:"required"`
|
||||||
Hash *common.Hash `json:"hash" rlp:"-"`
|
Hash *common.Hash `json:"hash" rlp:"-"`
|
||||||
|
L1MessageSender *common.Address `json:"l1MessageSender,omitempty" rlp:"nil,?"`
|
||||||
}
|
}
|
||||||
var enc txdata
|
var enc txdata
|
||||||
enc.AccountNonce = hexutil.Uint64(t.AccountNonce)
|
enc.AccountNonce = hexutil.Uint64(t.AccountNonce)
|
||||||
enc.Price = (*hexutil.Big)(t.Price)
|
enc.Price = (*hexutil.Big)(t.Price)
|
||||||
enc.GasLimit = hexutil.Uint64(t.GasLimit)
|
enc.GasLimit = hexutil.Uint64(t.GasLimit)
|
||||||
enc.Recipient = t.Recipient
|
enc.Recipient = t.Recipient
|
||||||
|
enc.L1MessageSender = t.L1MessageSender
|
||||||
enc.Amount = (*hexutil.Big)(t.Amount)
|
enc.Amount = (*hexutil.Big)(t.Amount)
|
||||||
enc.Payload = t.Payload
|
enc.Payload = t.Payload
|
||||||
enc.V = (*hexutil.Big)(t.V)
|
enc.V = (*hexutil.Big)(t.V)
|
||||||
@ -54,6 +56,7 @@ func (t *txdata) UnmarshalJSON(input []byte) error {
|
|||||||
R *hexutil.Big `json:"r" gencodec:"required"`
|
R *hexutil.Big `json:"r" gencodec:"required"`
|
||||||
S *hexutil.Big `json:"s" gencodec:"required"`
|
S *hexutil.Big `json:"s" gencodec:"required"`
|
||||||
Hash *common.Hash `json:"hash" rlp:"-"`
|
Hash *common.Hash `json:"hash" rlp:"-"`
|
||||||
|
L1MessageSender *common.Address `json:"l1MessageSender,omitempty" rlp:"nil,?"`
|
||||||
}
|
}
|
||||||
var dec txdata
|
var dec txdata
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
@ -74,6 +77,9 @@ func (t *txdata) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.Recipient != nil {
|
if dec.Recipient != nil {
|
||||||
t.Recipient = dec.Recipient
|
t.Recipient = dec.Recipient
|
||||||
}
|
}
|
||||||
|
if dec.L1MessageSender != nil {
|
||||||
|
t.L1MessageSender = dec.L1MessageSender
|
||||||
|
}
|
||||||
if dec.Amount == nil {
|
if dec.Amount == nil {
|
||||||
return errors.New("missing required field 'value' for txdata")
|
return errors.New("missing required field 'value' for txdata")
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func TestLegacyReceiptDecoding(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil)
|
tx := NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil, nil)
|
||||||
receipt := &Receipt{
|
receipt := &Receipt{
|
||||||
Status: ReceiptStatusFailed,
|
Status: ReceiptStatusFailed,
|
||||||
CumulativeGasUsed: 1,
|
CumulativeGasUsed: 1,
|
||||||
@ -156,7 +156,7 @@ func TestDeriveFields(t *testing.T) {
|
|||||||
// Create a few transactions to have receipts for
|
// Create a few transactions to have receipts for
|
||||||
txs := Transactions{
|
txs := Transactions{
|
||||||
NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil),
|
NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil),
|
||||||
NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil),
|
NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil, nil),
|
||||||
}
|
}
|
||||||
// Create the corresponding receipts
|
// Create the corresponding receipts
|
||||||
receipts := Receipts{
|
receipts := Receipts{
|
||||||
|
@ -58,6 +58,7 @@ type txdata struct {
|
|||||||
|
|
||||||
// This is only used when marshaling to JSON.
|
// This is only used when marshaling to JSON.
|
||||||
Hash *common.Hash `json:"hash" rlp:"-"`
|
Hash *common.Hash `json:"hash" rlp:"-"`
|
||||||
|
L1MessageSender *common.Address `json:"l1MessageSender,omitempty" rlp:"nil,?"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type txdataMarshaling struct {
|
type txdataMarshaling struct {
|
||||||
@ -71,21 +72,22 @@ type txdataMarshaling struct {
|
|||||||
S *hexutil.Big
|
S *hexutil.Big
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction {
|
func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, l1MessageSender *common.Address) *Transaction {
|
||||||
return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data)
|
return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data, l1MessageSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction {
|
func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction {
|
||||||
return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data)
|
return newTransaction(nonce, nil, amount, gasLimit, gasPrice, data, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction {
|
func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, l1MessageSender *common.Address) *Transaction {
|
||||||
if len(data) > 0 {
|
if len(data) > 0 {
|
||||||
data = common.CopyBytes(data)
|
data = common.CopyBytes(data)
|
||||||
}
|
}
|
||||||
d := txdata{
|
d := txdata{
|
||||||
AccountNonce: nonce,
|
AccountNonce: nonce,
|
||||||
Recipient: to,
|
Recipient: to,
|
||||||
|
L1MessageSender: l1MessageSender,
|
||||||
Payload: data,
|
Payload: data,
|
||||||
Amount: new(big.Int),
|
Amount: new(big.Int),
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
@ -189,13 +191,33 @@ func (tx *Transaction) To() *common.Address {
|
|||||||
return &to
|
return &to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// L1MessageSender returns the L1 message sender address of the transaction if one exists.
|
||||||
|
// It returns nil if this transaction was not from an L1 contract.
|
||||||
|
func (tx *Transaction) L1MessageSender() *common.Address {
|
||||||
|
if tx.data.L1MessageSender == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
l1MessagSender := *tx.data.L1MessageSender
|
||||||
|
return &l1MessagSender
|
||||||
|
}
|
||||||
|
|
||||||
// Hash hashes the RLP encoding of tx.
|
// Hash hashes the RLP encoding of tx.
|
||||||
// It uniquely identifies the transaction.
|
// It uniquely identifies the transaction.
|
||||||
func (tx *Transaction) Hash() common.Hash {
|
func (tx *Transaction) Hash() common.Hash {
|
||||||
if hash := tx.hash.Load(); hash != nil {
|
if hash := tx.hash.Load(); hash != nil {
|
||||||
return hash.(common.Hash)
|
return hash.(common.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sender *common.Address
|
||||||
|
if tx != nil {
|
||||||
|
sender = tx.data.L1MessageSender
|
||||||
|
tx.data.L1MessageSender = nil
|
||||||
|
}
|
||||||
v := rlpHash(tx)
|
v := rlpHash(tx)
|
||||||
|
|
||||||
|
if tx != nil {
|
||||||
|
tx.data.L1MessageSender = sender
|
||||||
|
}
|
||||||
tx.hash.Store(v)
|
tx.hash.Store(v)
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -223,6 +245,7 @@ func (tx *Transaction) AsMessage(s Signer) (Message, error) {
|
|||||||
gasLimit: tx.data.GasLimit,
|
gasLimit: tx.data.GasLimit,
|
||||||
gasPrice: new(big.Int).Set(tx.data.Price),
|
gasPrice: new(big.Int).Set(tx.data.Price),
|
||||||
to: tx.data.Recipient,
|
to: tx.data.Recipient,
|
||||||
|
l1MessageSender: tx.data.L1MessageSender,
|
||||||
amount: tx.data.Amount,
|
amount: tx.data.Amount,
|
||||||
data: tx.data.Payload,
|
data: tx.data.Payload,
|
||||||
checkNonce: true,
|
checkNonce: true,
|
||||||
@ -387,6 +410,7 @@ func (t *TransactionsByPriceAndNonce) Pop() {
|
|||||||
// NOTE: In a future PR this will be removed.
|
// NOTE: In a future PR this will be removed.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
to *common.Address
|
to *common.Address
|
||||||
|
l1MessageSender *common.Address
|
||||||
from common.Address
|
from common.Address
|
||||||
nonce uint64
|
nonce uint64
|
||||||
amount *big.Int
|
amount *big.Int
|
||||||
@ -396,7 +420,7 @@ type Message struct {
|
|||||||
checkNonce bool
|
checkNonce bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool) Message {
|
func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, l1MessageSender *common.Address) Message {
|
||||||
return Message{
|
return Message{
|
||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
@ -411,6 +435,7 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
|
|||||||
|
|
||||||
func (m Message) From() common.Address { return m.from }
|
func (m Message) From() common.Address { return m.from }
|
||||||
func (m Message) To() *common.Address { return m.to }
|
func (m Message) To() *common.Address { return m.to }
|
||||||
|
func (m Message) L1MessageSender() *common.Address { return m.l1MessageSender }
|
||||||
func (m Message) GasPrice() *big.Int { return m.gasPrice }
|
func (m Message) GasPrice() *big.Int { return m.gasPrice }
|
||||||
func (m Message) Value() *big.Int { return m.amount }
|
func (m Message) Value() *big.Int { return m.amount }
|
||||||
func (m Message) Gas() uint64 { return m.gasLimit }
|
func (m Message) Gas() uint64 { return m.gasLimit }
|
||||||
|
@ -30,7 +30,7 @@ func TestEIP155Signing(t *testing.T) {
|
|||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
signer := NewEIP155Signer(big.NewInt(18))
|
signer := NewEIP155Signer(big.NewInt(18))
|
||||||
tx, err := SignTx(NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil), signer, key)
|
tx, err := SignTx(NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func TestEIP155ChainId(t *testing.T) {
|
|||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
signer := NewEIP155Signer(big.NewInt(18))
|
signer := NewEIP155Signer(big.NewInt(18))
|
||||||
tx, err := SignTx(NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil), signer, key)
|
tx, err := SignTx(NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ func TestEIP155ChainId(t *testing.T) {
|
|||||||
t.Error("expected chainId to be", signer.chainId, "got", tx.ChainId())
|
t.Error("expected chainId to be", signer.chainId, "got", tx.ChainId())
|
||||||
}
|
}
|
||||||
|
|
||||||
tx = NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil)
|
tx = NewTransaction(0, addr, new(big.Int), 0, new(big.Int), nil, nil)
|
||||||
tx, err = SignTx(tx, HomesteadSigner{}, key)
|
tx, err = SignTx(tx, HomesteadSigner{}, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -118,7 +118,7 @@ func TestEIP155SigningVitalik(t *testing.T) {
|
|||||||
func TestChainId(t *testing.T) {
|
func TestChainId(t *testing.T) {
|
||||||
key, _ := defaultTestKey()
|
key, _ := defaultTestKey()
|
||||||
|
|
||||||
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, nil)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
tx, err = SignTx(tx, NewEIP155Signer(big.NewInt(1)), key)
|
tx, err = SignTx(tx, NewEIP155Signer(big.NewInt(1)), key)
|
||||||
|
@ -31,21 +31,16 @@ import (
|
|||||||
// The values in those tests are from the Transaction Tests
|
// The values in those tests are from the Transaction Tests
|
||||||
// at github.com/ethereum/tests.
|
// at github.com/ethereum/tests.
|
||||||
var (
|
var (
|
||||||
emptyTx = NewTransaction(
|
sender = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
|
||||||
0,
|
emptyTx = NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 0, big.NewInt(0), nil, &sender)
|
||||||
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
emptyTxEmptyL1Sender = NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(0), 0, big.NewInt(0), nil, nil)
|
||||||
big.NewInt(0), 0, big.NewInt(0),
|
|
||||||
nil,
|
rightvrsTx, _ = NewTransaction(3, common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), big.NewInt(10), 2000, big.NewInt(1), common.FromHex("5544"), nil).WithSignature(
|
||||||
|
HomesteadSigner{},
|
||||||
|
common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"),
|
||||||
)
|
)
|
||||||
|
|
||||||
rightvrsTx, _ = NewTransaction(
|
rightvrsTxWithL1Sender, _ = NewTransaction(3, common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"), big.NewInt(10), 2000, big.NewInt(1), common.FromHex("5544"), &sender).WithSignature(
|
||||||
3,
|
|
||||||
common.HexToAddress("b94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
|
|
||||||
big.NewInt(10),
|
|
||||||
2000,
|
|
||||||
big.NewInt(1),
|
|
||||||
common.FromHex("5544"),
|
|
||||||
).WithSignature(
|
|
||||||
HomesteadSigner{},
|
HomesteadSigner{},
|
||||||
common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"),
|
common.Hex2Bytes("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a301"),
|
||||||
)
|
)
|
||||||
@ -70,6 +65,14 @@ func TestTransactionEncode(t *testing.T) {
|
|||||||
if !bytes.Equal(txb, should) {
|
if !bytes.Equal(txb, should) {
|
||||||
t.Errorf("encoded RLP mismatch, got %x", txb)
|
t.Errorf("encoded RLP mismatch, got %x", txb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txc, err := rlp.EncodeToBytes(rightvrsTxWithL1Sender)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("encode error: %v", err)
|
||||||
|
}
|
||||||
|
if bytes.Equal(txc, should) {
|
||||||
|
t.Errorf("RLP encoding with L1MessageSender should be different than without. Got %x", txc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeTx(data []byte) (*Transaction, error) {
|
func decodeTx(data []byte) (*Transaction, error) {
|
||||||
@ -134,7 +137,7 @@ func TestTransactionPriceNonceSort(t *testing.T) {
|
|||||||
for start, key := range keys {
|
for start, key := range keys {
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
for i := 0; i < 25; i++ {
|
for i := 0; i < 25; i++ {
|
||||||
tx, _ := SignTx(NewTransaction(uint64(start+i), common.Address{}, big.NewInt(100), 100, big.NewInt(int64(start+i)), nil), signer, key)
|
tx, _ := SignTx(NewTransaction(uint64(start+i), common.Address{}, big.NewInt(100), 100, big.NewInt(int64(start+i)), nil, nil), signer, key)
|
||||||
groups[addr] = append(groups[addr], tx)
|
groups[addr] = append(groups[addr], tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +188,7 @@ func TestTransactionJSON(t *testing.T) {
|
|||||||
var tx *Transaction
|
var tx *Transaction
|
||||||
switch i % 2 {
|
switch i % 2 {
|
||||||
case 0:
|
case 0:
|
||||||
tx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef"))
|
tx = NewTransaction(i, common.Address{1}, common.Big0, 1, common.Big2, []byte("abcdef"), &sender)
|
||||||
case 1:
|
case 1:
|
||||||
tx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef"))
|
tx = NewContractCreation(i, common.Big0, 1, common.Big2, []byte("abcdef"))
|
||||||
}
|
}
|
||||||
@ -217,5 +220,19 @@ func TestTransactionJSON(t *testing.T) {
|
|||||||
if tx.ChainId().Cmp(parsedTx.ChainId()) != 0 {
|
if tx.ChainId().Cmp(parsedTx.ChainId()) != 0 {
|
||||||
t.Errorf("invalid chain id, want %d, got %d", tx.ChainId(), parsedTx.ChainId())
|
t.Errorf("invalid chain id, want %d, got %d", tx.ChainId(), parsedTx.ChainId())
|
||||||
}
|
}
|
||||||
|
if tx.L1MessageSender() == nil && parsedTx.L1MessageSender() != nil || tx.L1MessageSender() != nil && parsedTx.L1MessageSender() == nil || (tx.L1MessageSender() != nil && parsedTx.L1MessageSender() != nil && *tx.L1MessageSender() != *parsedTx.L1MessageSender()) {
|
||||||
|
t.Errorf("invalid L1MessageSender, want %x, got %x", tx.L1MessageSender(), parsedTx.L1MessageSender())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests that L1MessageSender has no impact on hash
|
||||||
|
func TestL1MessageSenderHash(t *testing.T) {
|
||||||
|
if rightvrsTx.Hash() != rightvrsTxWithL1Sender.Hash() {
|
||||||
|
t.Errorf("L1MessageSender, should not affect the hash, want %x, got %x with L1MessageSender", rightvrsTx.Hash(), rightvrsTxWithL1Sender.Hash())
|
||||||
|
}
|
||||||
|
|
||||||
|
if emptyTx.Hash() != emptyTxEmptyL1Sender.Hash() {
|
||||||
|
t.Errorf("L1MessageSender, should not affect the hash, want %x, got %x with L1MessageSender", emptyTx.Hash(), emptyTxEmptyL1Sender.Hash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||||||
checkpoint = params.TrustedCheckpoints[genesisHash]
|
checkpoint = params.TrustedCheckpoints[genesisHash]
|
||||||
}
|
}
|
||||||
blockSubmitter := rollup.NewBlockSubmitter()
|
blockSubmitter := rollup.NewBlockSubmitter()
|
||||||
rollupBlockBuilder, e := rollup.NewTransitionBatchBuilder(chainDb, eth.blockchain, blockSubmitter, 5 * time.Minute, 100_000_000_000, 200)
|
rollupBlockBuilder, e := rollup.NewTransitionBatchBuilder(chainDb, eth.blockchain, blockSubmitter, 5*time.Minute, 100_000_000_000, 200)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,9 @@ func TestCanonicalSynchronisation63Full(t *testing.T) { testCanonicalSynchronis
|
|||||||
func TestCanonicalSynchronisation63Fast(t *testing.T) { testCanonicalSynchronisation(t, 63, FastSync) }
|
func TestCanonicalSynchronisation63Fast(t *testing.T) { testCanonicalSynchronisation(t, 63, FastSync) }
|
||||||
func TestCanonicalSynchronisation64Full(t *testing.T) { testCanonicalSynchronisation(t, 64, FullSync) }
|
func TestCanonicalSynchronisation64Full(t *testing.T) { testCanonicalSynchronisation(t, 64, FullSync) }
|
||||||
func TestCanonicalSynchronisation64Fast(t *testing.T) { testCanonicalSynchronisation(t, 64, FastSync) }
|
func TestCanonicalSynchronisation64Fast(t *testing.T) { testCanonicalSynchronisation(t, 64, FastSync) }
|
||||||
func TestCanonicalSynchronisation64Light(t *testing.T) { testCanonicalSynchronisation(t, 64, LightSync) }
|
func TestCanonicalSynchronisation64Light(t *testing.T) {
|
||||||
|
testCanonicalSynchronisation(t, 64, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func testCanonicalSynchronisation(t *testing.T, protocol int, mode SyncMode) {
|
func testCanonicalSynchronisation(t *testing.T, protocol int, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -127,7 +127,8 @@ func (tc *testChain) generate(n int, seed byte, parent *types.Block, heavy bool)
|
|||||||
// Include transactions to the miner to make blocks more interesting.
|
// Include transactions to the miner to make blocks more interesting.
|
||||||
if parent == tc.genesis && i%22 == 0 {
|
if parent == tc.genesis && i%22 == 0 {
|
||||||
signer := types.MakeSigner(params.TestChainConfig, block.Number())
|
signer := types.MakeSigner(params.TestChainConfig, block.Number())
|
||||||
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil), signer, testKey)
|
l1Sender := common.Address{seed}
|
||||||
|
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil, &l1Sender), signer, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func makeChain(n int, seed byte, parent *types.Block) ([]common.Hash, map[common
|
|||||||
// If the block number is multiple of 3, send a bonus transaction to the miner
|
// If the block number is multiple of 3, send a bonus transaction to the miner
|
||||||
if parent == genesis && i%3 == 0 {
|
if parent == genesis && i%3 == 0 {
|
||||||
signer := types.MakeSigner(params.TestChainConfig, block.Number())
|
signer := types.MakeSigner(params.TestChainConfig, block.Number())
|
||||||
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil), signer, testKey)
|
tx, err := types.SignTx(types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -218,11 +218,11 @@ func TestPendingTxFilter(t *testing.T) {
|
|||||||
api = NewPublicFilterAPI(backend, false)
|
api = NewPublicFilterAPI(backend, false)
|
||||||
|
|
||||||
transactions = []*types.Transaction{
|
transactions = []*types.Transaction{
|
||||||
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil, nil),
|
||||||
types.NewTransaction(1, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
types.NewTransaction(1, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil, nil),
|
||||||
types.NewTransaction(2, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
types.NewTransaction(2, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil, nil),
|
||||||
types.NewTransaction(3, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
types.NewTransaction(3, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil, nil),
|
||||||
types.NewTransaction(4, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
types.NewTransaction(4, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil, nil),
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes []common.Hash
|
hashes []common.Hash
|
||||||
|
@ -127,7 +127,7 @@ func TestFilters(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
gen.AddUncheckedReceipt(receipt)
|
gen.AddUncheckedReceipt(receipt)
|
||||||
gen.AddUncheckedTx(types.NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil))
|
gen.AddUncheckedTx(types.NewTransaction(1, common.HexToAddress("0x1"), big.NewInt(1), 1, big.NewInt(1), nil, nil))
|
||||||
case 2:
|
case 2:
|
||||||
receipt := types.NewReceipt(nil, false, 0)
|
receipt := types.NewReceipt(nil, false, 0)
|
||||||
receipt.Logs = []*types.Log{
|
receipt.Logs = []*types.Log{
|
||||||
@ -137,7 +137,7 @@ func TestFilters(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
gen.AddUncheckedReceipt(receipt)
|
gen.AddUncheckedReceipt(receipt)
|
||||||
gen.AddUncheckedTx(types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil))
|
gen.AddUncheckedTx(types.NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil, nil))
|
||||||
|
|
||||||
case 998:
|
case 998:
|
||||||
receipt := types.NewReceipt(nil, false, 0)
|
receipt := types.NewReceipt(nil, false, 0)
|
||||||
@ -148,7 +148,7 @@ func TestFilters(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
gen.AddUncheckedReceipt(receipt)
|
gen.AddUncheckedReceipt(receipt)
|
||||||
gen.AddUncheckedTx(types.NewTransaction(998, common.HexToAddress("0x998"), big.NewInt(998), 998, big.NewInt(998), nil))
|
gen.AddUncheckedTx(types.NewTransaction(998, common.HexToAddress("0x998"), big.NewInt(998), 998, big.NewInt(998), nil, nil))
|
||||||
case 999:
|
case 999:
|
||||||
receipt := types.NewReceipt(nil, false, 0)
|
receipt := types.NewReceipt(nil, false, 0)
|
||||||
receipt.Logs = []*types.Log{
|
receipt.Logs = []*types.Log{
|
||||||
@ -158,7 +158,7 @@ func TestFilters(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
gen.AddUncheckedReceipt(receipt)
|
gen.AddUncheckedReceipt(receipt)
|
||||||
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, big.NewInt(999), nil))
|
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, big.NewInt(999), nil, nil))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
for i, block := range chain {
|
for i, block := range chain {
|
||||||
|
@ -287,13 +287,13 @@ func testGetNodeData(t *testing.T, protocol int) {
|
|||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
// In block 1, the test bank sends account #1 some ether.
|
// In block 1, the test bank sends account #1 some ether.
|
||||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
case 1:
|
case 1:
|
||||||
// In block 2, the test bank sends some more ether to account #1.
|
// In block 2, the test bank sends some more ether to account #1.
|
||||||
// acc1Addr passes it on to account #2.
|
// acc1Addr passes it on to account #2.
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, testBankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, acc1Key)
|
tx2, _ := types.SignTx(types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, acc1Key)
|
||||||
block.AddTx(tx1)
|
block.AddTx(tx1)
|
||||||
block.AddTx(tx2)
|
block.AddTx(tx2)
|
||||||
case 2:
|
case 2:
|
||||||
@ -384,13 +384,13 @@ func testGetReceipt(t *testing.T, protocol int) {
|
|||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
// In block 1, the test bank sends account #1 some ether.
|
// In block 1, the test bank sends account #1 some ether.
|
||||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
case 1:
|
case 1:
|
||||||
// In block 2, the test bank sends some more ether to account #1.
|
// In block 2, the test bank sends some more ether to account #1.
|
||||||
// acc1Addr passes it on to account #2.
|
// acc1Addr passes it on to account #2.
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, testBankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBank), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, acc1Key)
|
tx2, _ := types.SignTx(types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, acc1Key)
|
||||||
block.AddTx(tx1)
|
block.AddTx(tx1)
|
||||||
block.AddTx(tx2)
|
block.AddTx(tx2)
|
||||||
case 2:
|
case 2:
|
||||||
@ -497,7 +497,7 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
|
|||||||
t.Fatalf("failed to create new blockchain: %v", err)
|
t.Fatalf("failed to create new blockchain: %v", err)
|
||||||
}
|
}
|
||||||
blockSubmitter := rollup.NewBlockSubmitter()
|
blockSubmitter := rollup.NewBlockSubmitter()
|
||||||
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5*time.Minute, 9_000_000_000, 200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
||||||
}
|
}
|
||||||
@ -589,7 +589,7 @@ func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) {
|
|||||||
t.Fatalf("failed to create new blockchain: %v", err)
|
t.Fatalf("failed to create new blockchain: %v", err)
|
||||||
}
|
}
|
||||||
blockSubmitter := rollup.NewBlockSubmitter()
|
blockSubmitter := rollup.NewBlockSubmitter()
|
||||||
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5*time.Minute, 9_000_000_000, 200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
||||||
}
|
}
|
||||||
@ -662,7 +662,7 @@ func TestBroadcastMalformedBlock(t *testing.T) {
|
|||||||
t.Fatalf("failed to create new blockchain: %v", err)
|
t.Fatalf("failed to create new blockchain: %v", err)
|
||||||
}
|
}
|
||||||
blockSubmitter := rollup.NewBlockSubmitter()
|
blockSubmitter := rollup.NewBlockSubmitter()
|
||||||
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5*time.Minute, 9_000_000_000, 200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
t.Fatalf("failed to create Rollup Block Builder: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ func newTestProtocolManager(mode downloader.SyncMode, blocks int, generator func
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
blockSubmitter := rollup.NewBlockSubmitter()
|
blockSubmitter := rollup.NewBlockSubmitter()
|
||||||
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilder, err := rollup.NewTransitionBatchBuilder(db, blockchain, blockSubmitter, 5*time.Minute, 9_000_000_000, 200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to create Rollup Block Builder: %v", err)
|
panic(fmt.Errorf("failed to create Rollup Block Builder: %v", err))
|
||||||
}
|
}
|
||||||
pm, err := NewProtocolManager(gspec.Config, nil, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db, 1, nil, rollupBlockBuilder)
|
pm, err := NewProtocolManager(gspec.Config, nil, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db, 1, nil, rollupBlockBuilder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -139,7 +139,8 @@ func (p *testTxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subs
|
|||||||
|
|
||||||
// newTestTransaction create a new dummy transaction.
|
// newTestTransaction create a new dummy transaction.
|
||||||
func newTestTransaction(from *ecdsa.PrivateKey, nonce uint64, datasize int) *types.Transaction {
|
func newTestTransaction(from *ecdsa.PrivateKey, nonce uint64, datasize int) *types.Transaction {
|
||||||
tx := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), 100000, big.NewInt(0), make([]byte, datasize))
|
sender := common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
|
||||||
|
tx := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), 100000, big.NewInt(0), make([]byte, datasize), &sender)
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, from)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, from)
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,8 @@ func TestForkIDSplit(t *testing.T) {
|
|||||||
blockSubmitterNoFork = rollup.NewBlockSubmitter()
|
blockSubmitterNoFork = rollup.NewBlockSubmitter()
|
||||||
blockSubmitterProFork = rollup.NewBlockSubmitter()
|
blockSubmitterProFork = rollup.NewBlockSubmitter()
|
||||||
|
|
||||||
rollupBlockBuilderNoFork, _ = rollup.NewTransitionBatchBuilder(dbNoFork, chainNoFork, blockSubmitterNoFork, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilderNoFork, _ = rollup.NewTransitionBatchBuilder(dbNoFork, chainNoFork, blockSubmitterNoFork, 5*time.Minute, 9_000_000_000, 200)
|
||||||
rollupBlockBuilderProFork, _ = rollup.NewTransitionBatchBuilder(dbProFork, chainProFork, blockSubmitterProFork, 5 * time.Minute, 9_000_000_000, 200)
|
rollupBlockBuilderProFork, _ = rollup.NewTransitionBatchBuilder(dbProFork, chainProFork, blockSubmitterProFork, 5*time.Minute, 9_000_000_000, 200)
|
||||||
|
|
||||||
ethNoFork, _ = NewProtocolManager(configNoFork, nil, downloader.FullSync, 1, new(event.TypeMux), new(testTxPool), engine, chainNoFork, dbNoFork, 1, nil, rollupBlockBuilderNoFork)
|
ethNoFork, _ = NewProtocolManager(configNoFork, nil, downloader.FullSync, 1, new(event.TypeMux), new(testTxPool), engine, chainNoFork, dbNoFork, 1, nil, rollupBlockBuilderNoFork)
|
||||||
ethProFork, _ = NewProtocolManager(configProFork, nil, downloader.FullSync, 1, new(event.TypeMux), new(testTxPool), engine, chainProFork, dbProFork, 1, nil, rollupBlockBuilderProFork)
|
ethProFork, _ = NewProtocolManager(configProFork, nil, downloader.FullSync, 1, new(event.TypeMux), new(testTxPool), engine, chainProFork, dbProFork, 1, nil, rollupBlockBuilderProFork)
|
||||||
|
@ -121,8 +121,7 @@ type callTracerTest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPrestateTracerCreate2(t *testing.T) {
|
func TestPrestateTracerCreate2(t *testing.T) {
|
||||||
unsignedTx := types.NewTransaction(1, common.HexToAddress("0x00000000000000000000000000000000deadbeef"),
|
unsignedTx := types.NewTransaction(1, common.HexToAddress("0x00000000000000000000000000000000deadbeef"), new(big.Int), 5000000, big.NewInt(1), []byte{}, nil)
|
||||||
new(big.Int), 5000000, big.NewInt(1), []byte{})
|
|
||||||
|
|
||||||
privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
|
privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -828,7 +828,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new call message
|
// Create new call message
|
||||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false)
|
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, false, nil)
|
||||||
|
|
||||||
// Setup context so it may be cancelled the call has completed
|
// Setup context so it may be cancelled the call has completed
|
||||||
// or, in case of unmetered gas, setup a context with a timeout.
|
// or, in case of unmetered gas, setup a context with a timeout.
|
||||||
@ -1369,6 +1369,7 @@ type SendTxArgs struct {
|
|||||||
// newer name and should be preferred by clients.
|
// newer name and should be preferred by clients.
|
||||||
Data *hexutil.Bytes `json:"data"`
|
Data *hexutil.Bytes `json:"data"`
|
||||||
Input *hexutil.Bytes `json:"input"`
|
Input *hexutil.Bytes `json:"input"`
|
||||||
|
L1MessageSender *common.Address `json:"l1MessageSender,omitempty" rlp:"nil,?"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// setDefaults is a helper function that fills in default values for unspecified tx fields.
|
// setDefaults is a helper function that fills in default values for unspecified tx fields.
|
||||||
@ -1441,7 +1442,7 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
|
|||||||
if args.To == nil {
|
if args.To == nil {
|
||||||
return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input)
|
return types.NewContractCreation(uint64(*args.Nonce), (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input)
|
||||||
}
|
}
|
||||||
return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input)
|
return types.NewTransaction(uint64(*args.Nonce), *args.To, (*big.Int)(args.Value), uint64(*args.Gas), (*big.Int)(args.GasPrice), input, args.L1MessageSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
|
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
|
||||||
|
@ -180,7 +180,7 @@ func (b *benchmarkTxSend) init(h *serverHandler, count int) error {
|
|||||||
for i := range b.txs {
|
for i := range b.txs {
|
||||||
data := make([]byte, txSizeCostLimit)
|
data := make([]byte, txSizeCostLimit)
|
||||||
rand.Read(data)
|
rand.Read(data)
|
||||||
tx, err := types.SignTx(types.NewTransaction(0, addr, new(big.Int), 0, new(big.Int), data), signer, key)
|
tx, err := types.SignTx(types.NewTransaction(0, addr, new(big.Int), 0, new(big.Int), data, nil), signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -538,16 +538,16 @@ func testTransactionStatus(t *testing.T, protocol int) {
|
|||||||
signer := types.HomesteadSigner{}
|
signer := types.HomesteadSigner{}
|
||||||
|
|
||||||
// test error status by sending an underpriced transaction
|
// test error status by sending an underpriced transaction
|
||||||
tx0, _ := types.SignTx(types.NewTransaction(0, userAddr1, big.NewInt(10000), params.TxGas, nil, nil), signer, bankKey)
|
tx0, _ := types.SignTx(types.NewTransaction(0, userAddr1, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, bankKey)
|
||||||
test(tx0, true, light.TxStatus{Status: core.TxStatusUnknown, Error: core.ErrUnderpriced.Error()})
|
test(tx0, true, light.TxStatus{Status: core.TxStatusUnknown, Error: core.ErrUnderpriced.Error()})
|
||||||
|
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(0, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil), signer, bankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(0, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil, nil), signer, bankKey)
|
||||||
test(tx1, false, light.TxStatus{Status: core.TxStatusUnknown}) // query before sending, should be unknown
|
test(tx1, false, light.TxStatus{Status: core.TxStatusUnknown}) // query before sending, should be unknown
|
||||||
test(tx1, true, light.TxStatus{Status: core.TxStatusPending}) // send valid processable tx, should return pending
|
test(tx1, true, light.TxStatus{Status: core.TxStatusPending}) // send valid processable tx, should return pending
|
||||||
test(tx1, true, light.TxStatus{Status: core.TxStatusPending}) // adding it again should not return an error
|
test(tx1, true, light.TxStatus{Status: core.TxStatusPending}) // adding it again should not return an error
|
||||||
|
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(1, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil), signer, bankKey)
|
tx2, _ := types.SignTx(types.NewTransaction(1, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil, nil), signer, bankKey)
|
||||||
tx3, _ := types.SignTx(types.NewTransaction(2, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil), signer, bankKey)
|
tx3, _ := types.SignTx(types.NewTransaction(2, userAddr1, big.NewInt(10000), params.TxGas, big.NewInt(100000000000), nil, nil), signer, bankKey)
|
||||||
// send transactions in the wrong order, tx3 should be queued
|
// send transactions in the wrong order, tx3 should be queued
|
||||||
test(tx3, true, light.TxStatus{Status: core.TxStatusQueued})
|
test(tx3, true, light.TxStatus{Status: core.TxStatusQueued})
|
||||||
test(tx2, true, light.TxStatus{Status: core.TxStatusPending})
|
test(tx2, true, light.TxStatus{Status: core.TxStatusPending})
|
||||||
|
@ -128,7 +128,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
|
|||||||
from := statedb.GetOrNewStateObject(bankAddr)
|
from := statedb.GetOrNewStateObject(bankAddr)
|
||||||
from.SetBalance(math.MaxBig256)
|
from.SetBalance(math.MaxBig256)
|
||||||
|
|
||||||
msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false)}
|
msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil)}
|
||||||
|
|
||||||
context := core.NewEVMContext(msg, header, bc, nil)
|
context := core.NewEVMContext(msg, header, bc, nil)
|
||||||
vmenv := vm.NewEVM(context, statedb, config, vm.Config{})
|
vmenv := vm.NewEVM(context, statedb, config, vm.Config{})
|
||||||
@ -142,7 +142,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
|
|||||||
header := lc.GetHeaderByHash(bhash)
|
header := lc.GetHeaderByHash(bhash)
|
||||||
state := light.NewState(ctx, header, lc.Odr())
|
state := light.NewState(ctx, header, lc.Odr())
|
||||||
state.SetBalance(bankAddr, math.MaxBig256)
|
state.SetBalance(bankAddr, math.MaxBig256)
|
||||||
msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false)}
|
msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, new(big.Int), data, false, nil)}
|
||||||
context := core.NewEVMContext(msg, header, lc, nil)
|
context := core.NewEVMContext(msg, header, lc, nil)
|
||||||
vmenv := vm.NewEVM(context, state, config, vm.Config{})
|
vmenv := vm.NewEVM(context, state, config, vm.Config{})
|
||||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||||
|
@ -112,18 +112,18 @@ func prepare(n int, backend *backends.SimulatedBackend) {
|
|||||||
registrarAddr, _, _, _ = contract.DeployCheckpointOracle(bind.NewKeyedTransactor(bankKey), backend, []common.Address{signerAddr}, sectionSize, processConfirms, big.NewInt(1))
|
registrarAddr, _, _, _ = contract.DeployCheckpointOracle(bind.NewKeyedTransactor(bankKey), backend, []common.Address{signerAddr}, sectionSize, processConfirms, big.NewInt(1))
|
||||||
// bankUser transfers some ether to user1
|
// bankUser transfers some ether to user1
|
||||||
nonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
nonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
||||||
tx, _ := types.SignTx(types.NewTransaction(nonce, userAddr1, big.NewInt(10000), params.TxGas, nil, nil), signer, bankKey)
|
tx, _ := types.SignTx(types.NewTransaction(nonce, userAddr1, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, bankKey)
|
||||||
backend.SendTransaction(ctx, tx)
|
backend.SendTransaction(ctx, tx)
|
||||||
case 1:
|
case 1:
|
||||||
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
||||||
userNonce1, _ := backend.PendingNonceAt(ctx, userAddr1)
|
userNonce1, _ := backend.PendingNonceAt(ctx, userAddr1)
|
||||||
|
|
||||||
// bankUser transfers more ether to user1
|
// bankUser transfers more ether to user1
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(bankNonce, userAddr1, big.NewInt(1000), params.TxGas, nil, nil), signer, bankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(bankNonce, userAddr1, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, bankKey)
|
||||||
backend.SendTransaction(ctx, tx1)
|
backend.SendTransaction(ctx, tx1)
|
||||||
|
|
||||||
// user1 relays ether to user2
|
// user1 relays ether to user2
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(userNonce1, userAddr2, big.NewInt(1000), params.TxGas, nil, nil), signer, userKey1)
|
tx2, _ := types.SignTx(types.NewTransaction(userNonce1, userAddr2, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, userKey1)
|
||||||
backend.SendTransaction(ctx, tx2)
|
backend.SendTransaction(ctx, tx2)
|
||||||
|
|
||||||
// user1 deploys a test contract
|
// user1 deploys a test contract
|
||||||
@ -137,18 +137,18 @@ func prepare(n int, backend *backends.SimulatedBackend) {
|
|||||||
case 2:
|
case 2:
|
||||||
// bankUser transfer some ether to signer
|
// bankUser transfer some ether to signer
|
||||||
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(bankNonce, signerAddr, big.NewInt(1000000000), params.TxGas, nil, nil), signer, bankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(bankNonce, signerAddr, big.NewInt(1000000000), params.TxGas, nil, nil, nil), signer, bankKey)
|
||||||
backend.SendTransaction(ctx, tx1)
|
backend.SendTransaction(ctx, tx1)
|
||||||
|
|
||||||
// invoke test contract
|
// invoke test contract
|
||||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001")
|
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001")
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(bankNonce+1, testContractAddr, big.NewInt(0), 100000, nil, data), signer, bankKey)
|
tx2, _ := types.SignTx(types.NewTransaction(bankNonce+1, testContractAddr, big.NewInt(0), 100000, nil, data, nil), signer, bankKey)
|
||||||
backend.SendTransaction(ctx, tx2)
|
backend.SendTransaction(ctx, tx2)
|
||||||
case 3:
|
case 3:
|
||||||
// invoke test contract
|
// invoke test contract
|
||||||
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
bankNonce, _ := backend.PendingNonceAt(ctx, bankAddr)
|
||||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002")
|
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002")
|
||||||
tx, _ := types.SignTx(types.NewTransaction(bankNonce, testContractAddr, big.NewInt(0), 100000, nil, data), signer, bankKey)
|
tx, _ := types.SignTx(types.NewTransaction(bankNonce, testContractAddr, big.NewInt(0), 100000, nil, data, nil), signer, bankKey)
|
||||||
backend.SendTransaction(ctx, tx)
|
backend.SendTransaction(ctx, tx)
|
||||||
}
|
}
|
||||||
backend.Commit()
|
backend.Commit()
|
||||||
|
@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
|
|||||||
|
|
||||||
// Perform read-only call.
|
// Perform read-only call.
|
||||||
st.SetBalance(testBankAddress, math.MaxBig256)
|
st.SetBalance(testBankAddress, math.MaxBig256)
|
||||||
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false)}
|
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, new(big.Int), data, false, nil)}
|
||||||
context := core.NewEVMContext(msg, header, chain, nil)
|
context := core.NewEVMContext(msg, header, chain, nil)
|
||||||
vmenv := vm.NewEVM(context, st, config, vm.Config{})
|
vmenv := vm.NewEVM(context, st, config, vm.Config{})
|
||||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||||
@ -212,15 +212,15 @@ func testChainGen(i int, block *core.BlockGen) {
|
|||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
// In block 1, the test bank sends account #1 some ether.
|
// In block 1, the test bank sends account #1 some ether.
|
||||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
case 1:
|
case 1:
|
||||||
// In block 2, the test bank sends some more ether to account #1.
|
// In block 2, the test bank sends some more ether to account #1.
|
||||||
// acc1Addr passes it on to account #2.
|
// acc1Addr passes it on to account #2.
|
||||||
// acc1Addr creates a test contract.
|
// acc1Addr creates a test contract.
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, testBankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, testBankKey)
|
||||||
nonce := block.TxNonce(acc1Addr)
|
nonce := block.TxNonce(acc1Addr)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(nonce, acc2Addr, big.NewInt(1000), params.TxGas, nil, nil), signer, acc1Key)
|
tx2, _ := types.SignTx(types.NewTransaction(nonce, acc2Addr, big.NewInt(1000), params.TxGas, nil, nil, nil), signer, acc1Key)
|
||||||
nonce++
|
nonce++
|
||||||
tx3, _ := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 1000000, big.NewInt(0), testContractCode), signer, acc1Key)
|
tx3, _ := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 1000000, big.NewInt(0), testContractCode), signer, acc1Key)
|
||||||
testContractAddr = crypto.CreateAddress(acc1Addr, nonce)
|
testContractAddr = crypto.CreateAddress(acc1Addr, nonce)
|
||||||
@ -232,7 +232,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, nil, data), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, big.NewInt(0), 100000, nil, data, nil), 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).
|
||||||
@ -243,7 +243,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, nil, data), signer, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(testBankAddress), testContractAddr, big.NewInt(0), 100000, nil, data, nil), signer, testBankKey)
|
||||||
block.AddTx(tx)
|
block.AddTx(tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func txPoolTestChainGen(i int, block *core.BlockGen) {
|
|||||||
|
|
||||||
func TestTxPool(t *testing.T) {
|
func TestTxPool(t *testing.T) {
|
||||||
for i := range testTx {
|
for i := range testTx {
|
||||||
testTx[i], _ = types.SignTx(types.NewTransaction(uint64(i), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey)
|
testTx[i], _ = types.SignTx(types.NewTransaction(uint64(i), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil, nil), types.HomesteadSigner{}, testBankKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -118,7 +118,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
// Create a self transaction and inject into the pool
|
// Create a self transaction and inject into the pool
|
||||||
tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000), nil), types.HomesteadSigner{}, faucets[index])
|
tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000), nil, nil), types.HomesteadSigner{}, faucets[index])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
// Create a self transaction and inject into the pool
|
// Create a self transaction and inject into the pool
|
||||||
tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000+rand.Int63n(65536)), nil), types.HomesteadSigner{}, faucets[index])
|
tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000+rand.Int63n(65536)), nil, nil), types.HomesteadSigner{}, faucets[index])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,9 @@ func init() {
|
|||||||
Period: 10,
|
Period: 10,
|
||||||
Epoch: 30000,
|
Epoch: 30000,
|
||||||
}
|
}
|
||||||
tx1, _ := types.SignTx(types.NewTransaction(0, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey)
|
tx1, _ := types.SignTx(types.NewTransaction(0, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil, nil), types.HomesteadSigner{}, testBankKey)
|
||||||
pendingTxs = append(pendingTxs, tx1)
|
pendingTxs = append(pendingTxs, tx1)
|
||||||
tx2, _ := types.SignTx(types.NewTransaction(1, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey)
|
tx2, _ := types.SignTx(types.NewTransaction(1, testUserAddress, big.NewInt(1000), params.TxGas, nil, nil, nil), types.HomesteadSigner{}, testBankKey)
|
||||||
newTxs = append(newTxs, tx2)
|
newTxs = append(newTxs, tx2)
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func (b *testWorkerBackend) newRandomTx(creation bool) *types.Transaction {
|
|||||||
if creation {
|
if creation {
|
||||||
tx, _ = types.SignTx(types.NewContractCreation(b.txPool.Nonce(testBankAddress), big.NewInt(0), testGas, nil, common.FromHex(testCode)), types.HomesteadSigner{}, testBankKey)
|
tx, _ = types.SignTx(types.NewContractCreation(b.txPool.Nonce(testBankAddress), big.NewInt(0), testGas, nil, common.FromHex(testCode)), types.HomesteadSigner{}, testBankKey)
|
||||||
} else {
|
} else {
|
||||||
tx, _ = types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), testUserAddress, big.NewInt(1000), params.TxGas, nil, nil), types.HomesteadSigner{}, testBankKey)
|
tx, _ = types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), testUserAddress, big.NewInt(1000), params.TxGas, nil, nil, nil), types.HomesteadSigner{}, testBankKey)
|
||||||
}
|
}
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, ga
|
|||||||
if to == nil {
|
if to == nil {
|
||||||
return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
|
return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
|
||||||
}
|
}
|
||||||
return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
|
return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data), nil)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTransactionFromRLP parses a transaction from an RLP data dump.
|
// NewTransactionFromRLP parses a transaction from an RLP data dump.
|
||||||
|
@ -409,6 +409,7 @@ func makeStructDecoder(typ reflect.Type) (decoder, error) {
|
|||||||
|
|
||||||
// makePtrDecoder creates a decoder that decodes into the pointer's element type.
|
// makePtrDecoder creates a decoder that decodes into the pointer's element type.
|
||||||
func makePtrDecoder(typ reflect.Type, tag tags) (decoder, error) {
|
func makePtrDecoder(typ reflect.Type, tag tags) (decoder, error) {
|
||||||
|
|
||||||
etype := typ.Elem()
|
etype := typ.Elem()
|
||||||
etypeinfo := cachedTypeInfo1(etype, tags{})
|
etypeinfo := cachedTypeInfo1(etype, tags{})
|
||||||
switch {
|
switch {
|
||||||
|
@ -51,6 +51,10 @@ type tags struct {
|
|||||||
|
|
||||||
// rlp:"-" ignores fields.
|
// rlp:"-" ignores fields.
|
||||||
ignored bool
|
ignored bool
|
||||||
|
|
||||||
|
// rlp:"?" means that this field is not present in the RLP-encoded object if it is nil.
|
||||||
|
// Note: fields like this must be at the end of the struct.
|
||||||
|
omittedIfNil bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// typekey is the key of a type in typeCache. It includes the struct tags because
|
// typekey is the key of a type in typeCache. It includes the struct tags because
|
||||||
@ -174,6 +178,8 @@ func parseStructTag(typ reflect.Type, fi, lastPublic int) (tags, error) {
|
|||||||
if f.Type.Kind() != reflect.Slice {
|
if f.Type.Kind() != reflect.Slice {
|
||||||
return ts, structTagError{typ, f.Name, t, "field type is not slice"}
|
return ts, structTagError{typ, f.Name, t, "field type is not slice"}
|
||||||
}
|
}
|
||||||
|
case "?":
|
||||||
|
ts.omittedIfNil = true
|
||||||
default:
|
default:
|
||||||
return ts, fmt.Errorf("rlp: unknown struct tag %q on %v.%s", t, typ, f.Name)
|
return ts, fmt.Errorf("rlp: unknown struct tag %q on %v.%s", t, typ, f.Name)
|
||||||
}
|
}
|
||||||
@ -193,7 +199,40 @@ func lastPublicField(typ reflect.Type) int {
|
|||||||
|
|
||||||
func (i *typeinfo) generate(typ reflect.Type, tags tags) {
|
func (i *typeinfo) generate(typ reflect.Type, tags tags) {
|
||||||
i.decoder, i.decoderErr = makeDecoder(typ, tags)
|
i.decoder, i.decoderErr = makeDecoder(typ, tags)
|
||||||
|
omitIfEmpty := tags.omittedIfNil && typ.Kind() == reflect.Ptr
|
||||||
|
if i.decoderErr == nil && omitIfEmpty {
|
||||||
|
i.decoder, i.decoderErr = wrapDecoderToAccountForOmitted(typ, i.decoder)
|
||||||
|
}
|
||||||
|
|
||||||
i.writer, i.writerErr = makeWriter(typ, tags)
|
i.writer, i.writerErr = makeWriter(typ, tags)
|
||||||
|
if i.writerErr == nil && omitIfEmpty {
|
||||||
|
i.writer, i.writerErr = wrapWriterToAccountForOmitted(i.writer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrapDecoderToAccountForOmitted handles decoding nullable types that are omitted when empty.
|
||||||
|
// If omitted, this decoder will set the value to nil.
|
||||||
|
func wrapDecoderToAccountForOmitted(typ reflect.Type, decoder decoder) (decoder, error) {
|
||||||
|
nilPtr := reflect.Zero(typ)
|
||||||
|
return func(s *Stream, val reflect.Value) (err error) {
|
||||||
|
if err = decoder(s, val); err != nil && err == EOL {
|
||||||
|
val.Set(nilPtr)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrapWriterToAccountForOmitted handles writing nullable types that are omitted when empty.
|
||||||
|
// If omitted, this writer omit it from the encoded buffer.
|
||||||
|
func wrapWriterToAccountForOmitted(writer writer) (writer, error) {
|
||||||
|
return func(val reflect.Value, w *encbuf) (err error) {
|
||||||
|
if val.IsNil() {
|
||||||
|
// Omit if nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return writer(val, w)
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultNilKind determines whether a nil pointer to typ encodes/decodes
|
// defaultNilKind determines whether a nil pointer to typ encodes/decodes
|
||||||
|
@ -78,7 +78,7 @@ func createBlocks(number int, startIndex int, withTx bool) types.Blocks {
|
|||||||
header := &types.Header{Number: big.NewInt(int64(i + startIndex))}
|
header := &types.Header{Number: big.NewInt(int64(i + startIndex))}
|
||||||
txs := make(types.Transactions, 0)
|
txs := make(types.Transactions, 0)
|
||||||
if withTx {
|
if withTx {
|
||||||
tx, _ := types.SignTx(types.NewTransaction(uint64(i), testUserAddress, big.NewInt(1), params.TxGas, big.NewInt(0), nil), types.HomesteadSigner{}, testBankKey)
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), testUserAddress, big.NewInt(1), params.TxGas, big.NewInt(0), nil, &testUserAddress), types.HomesteadSigner{}, testBankKey)
|
||||||
txs = append(txs, tx)
|
txs = append(txs, tx)
|
||||||
}
|
}
|
||||||
block := types.NewBlock(header, txs, make([]*types.Header, 0), make([]*types.Receipt, 0))
|
block := types.NewBlock(header, txs, make([]*types.Header, 0), make([]*types.Receipt, 0))
|
||||||
|
@ -76,6 +76,7 @@ type SendTxArgs struct {
|
|||||||
// We accept "data" and "input" for backwards-compatibility reasons.
|
// We accept "data" and "input" for backwards-compatibility reasons.
|
||||||
Data *hexutil.Bytes `json:"data"`
|
Data *hexutil.Bytes `json:"data"`
|
||||||
Input *hexutil.Bytes `json:"input,omitempty"`
|
Input *hexutil.Bytes `json:"input,omitempty"`
|
||||||
|
L1MessageSender *common.MixedcaseAddress `json:"l1MessageSender,omitempty" rlp:"nil,?"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (args SendTxArgs) String() string {
|
func (args SendTxArgs) String() string {
|
||||||
@ -96,5 +97,6 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
|
|||||||
if args.To == nil {
|
if args.To == nil {
|
||||||
return types.NewContractCreation(uint64(args.Nonce), (*big.Int)(&args.Value), uint64(args.Gas), (*big.Int)(&args.GasPrice), input)
|
return types.NewContractCreation(uint64(args.Nonce), (*big.Int)(&args.Value), uint64(args.Gas), (*big.Int)(&args.GasPrice), input)
|
||||||
}
|
}
|
||||||
return types.NewTransaction(uint64(args.Nonce), args.To.Address(), (*big.Int)(&args.Value), (uint64)(args.Gas), (*big.Int)(&args.GasPrice), input)
|
l1MessageSender := args.L1MessageSender.Address()
|
||||||
|
return types.NewTransaction(uint64(args.Nonce), args.To.Address(), (*big.Int)(&args.Value), (uint64)(args.Gas), (*big.Int)(&args.GasPrice), input, &l1MessageSender)
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ func dummySigned(value *big.Int) *types.Transaction {
|
|||||||
gas := uint64(21000)
|
gas := uint64(21000)
|
||||||
gasPrice := big.NewInt(2000000)
|
gasPrice := big.NewInt(2000000)
|
||||||
data := make([]byte, 0)
|
data := make([]byte, 0)
|
||||||
return types.NewTransaction(3, to, value, gas, gasPrice, data)
|
return types.NewTransaction(3, to, value, gas, gasPrice, data, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLimitWindow(t *testing.T) {
|
func TestLimitWindow(t *testing.T) {
|
||||||
|
@ -279,7 +279,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
|
|||||||
return nil, fmt.Errorf("invalid tx data %q", dataHex)
|
return nil, fmt.Errorf("invalid tx data %q", dataHex)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true)
|
msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, data, true, nil)
|
||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user