@@ -36,17 +36,19 @@ import (
36
36
)
37
37
38
38
type result struct {
39
- Error error
40
- Address common.Address
41
- Hash common.Hash
39
+ Error error
40
+ Address common.Address
41
+ Hash common.Hash
42
+ IntrinsicGas uint64
42
43
}
43
44
44
45
// MarshalJSON marshals as JSON with a hash.
45
46
func (r * result ) MarshalJSON () ([]byte , error ) {
46
47
type xx struct {
47
- Error string `json:"error,omitempty"`
48
- Address * common.Address `json:"address,omitempty"`
49
- Hash * common.Hash `json:"hash,omitempty"`
48
+ Error string `json:"error,omitempty"`
49
+ Address * common.Address `json:"address,omitempty"`
50
+ Hash * common.Hash `json:"hash,omitempty"`
51
+ IntrinsicGas uint64 `json:"intrinsicGas,omitempty"`
50
52
}
51
53
var out xx
52
54
if r .Error != nil {
@@ -58,6 +60,7 @@ func (r *result) MarshalJSON() ([]byte, error) {
58
60
if r .Hash != (common.Hash {}) {
59
61
out .Hash = & r .Hash
60
62
}
63
+ out .IntrinsicGas = r .IntrinsicGas
61
64
return json .Marshal (out )
62
65
}
63
66
@@ -132,12 +135,36 @@ func Transaction(ctx *cli.Context) error {
132
135
} else {
133
136
r .Address = sender
134
137
}
135
-
138
+ // Check intrinsic gas
136
139
if gas , err := core .IntrinsicGas (tx .Data (), tx .AccessList (), tx .To () == nil ,
137
140
chainConfig .IsHomestead (new (big.Int )), chainConfig .IsIstanbul (new (big.Int ))); err != nil {
138
141
r .Error = err
139
- } else if tx .Gas () < gas {
140
- r .Error = fmt .Errorf ("%w: have %d, want %d" , core .ErrIntrinsicGas , tx .Gas (), gas )
142
+ results = append (results , r )
143
+ continue
144
+ } else {
145
+ r .IntrinsicGas = gas
146
+ if tx .Gas () < gas {
147
+ r .Error = fmt .Errorf ("%w: have %d, want %d" , core .ErrIntrinsicGas , tx .Gas (), gas )
148
+ results = append (results , r )
149
+ continue
150
+ }
151
+ }
152
+ // Validate <256bit fields
153
+ switch {
154
+ case tx .Value ().BitLen () > 256 :
155
+ r .Error = errors .New ("value exceeds 256 bits" )
156
+ case tx .GasPrice ().BitLen () > 256 :
157
+ r .Error = errors .New ("gasPrice exceeds 256 bits" )
158
+ case tx .GasTipCap ().BitLen () > 256 :
159
+ r .Error = errors .New ("maxPriorityFeePerGas exceeds 256 bits" )
160
+ case tx .GasFeeCap ().BitLen () > 256 :
161
+ r .Error = errors .New ("maxFeePerGas exceeds 256 bits" )
162
+ case tx .GasFeeCap ().Cmp (tx .GasTipCap ()) < 0 :
163
+ r .Error = errors .New ("maxFeePerGas < maxPriorityFeePerGas" )
164
+ case new (big.Int ).Mul (tx .GasPrice (), new (big.Int ).SetUint64 (tx .Gas ())).BitLen () > 256 :
165
+ r .Error = errors .New ("gas * gasPrice exceeds 256 bits" )
166
+ case new (big.Int ).Mul (tx .GasFeeCap (), new (big.Int ).SetUint64 (tx .Gas ())).BitLen () > 256 :
167
+ r .Error = errors .New ("gas * maxFeePerGas exceeds 256 bits" )
141
168
}
142
169
results = append (results , r )
143
170
}
0 commit comments