@@ -36,17 +36,19 @@ import (
3636)
3737
3838type 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
4243}
4344
4445// MarshalJSON marshals as JSON with a hash.
4546func (r * result ) MarshalJSON () ([]byte , error ) {
4647 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"`
5052 }
5153 var out xx
5254 if r .Error != nil {
@@ -58,6 +60,7 @@ func (r *result) MarshalJSON() ([]byte, error) {
5860 if r .Hash != (common.Hash {}) {
5961 out .Hash = & r .Hash
6062 }
63+ out .IntrinsicGas = r .IntrinsicGas
6164 return json .Marshal (out )
6265}
6366
@@ -132,12 +135,36 @@ func Transaction(ctx *cli.Context) error {
132135 } else {
133136 r .Address = sender
134137 }
135-
138+ // Check intrinsic gas
136139 if gas , err := core .IntrinsicGas (tx .Data (), tx .AccessList (), tx .To () == nil ,
137140 chainConfig .IsHomestead (new (big.Int )), chainConfig .IsIstanbul (new (big.Int ))); err != nil {
138141 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" )
141168 }
142169 results = append (results , r )
143170 }
0 commit comments