/
mod_createspam.go
55 lines (48 loc) · 1.07 KB
/
mod_createspam.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"github.com/ethereum/go-ethereum/core/types"
)
// Here we create transactions that create spam contracts. These exist simply to fill up
// the state. We need a decent amount of state in the sync tests, for example.
func init() {
register("randomlogs", func() blockModifier {
return &modCreateSpam{
code: genlogsCode,
gas: 20000,
}
})
register("randomcode", func() blockModifier {
return &modCreateSpam{
code: gencodeCode,
gas: 60000,
}
})
register("randomstorage", func() blockModifier {
return &modCreateSpam{
code: genstorageCode,
gas: 80000,
}
})
}
type modCreateSpam struct {
code []byte
gas uint64
}
func (m *modCreateSpam) apply(ctx *genBlockContext) bool {
gas := ctx.TxCreateIntrinsicGas(m.code) + m.gas
if !ctx.HasGas(gas) {
return false
}
sender := ctx.TxSenderAccount()
txdata := &types.LegacyTx{
Nonce: ctx.AccountNonce(sender.addr),
Gas: gas,
GasPrice: ctx.TxGasFeeCap(),
Data: m.code,
}
ctx.AddNewTx(sender, txdata)
return true
}
func (m *modCreateSpam) txInfo() any {
return nil
}