Skip to content

Commit bf350e8

Browse files
committed
move logic
1 parent ea56196 commit bf350e8

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

x/evm/types/tx_args.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,13 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
133133
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
134134
}
135135

136-
// Ethereum block size is ~36000000
137-
MaxGasCap := uint64(100000000)
138-
139136
// Set sender address or use zero address if none specified.
140137
addr := args.GetFrom()
141-
138+
// Ethereum block size is ~36000000, we limit this value to protect against DOS
139+
MaxGasCap := uint64(100000000)
142140
// Set default gas & gas price if none were set
143-
gas := globalGasCap
144-
if gas == 0 {
145-
gas = MaxGasCap
146-
}
147-
if args.Gas != nil {
141+
gas := MaxGasCap
142+
if args.Gas != nil && uint64(*args.Gas) < MaxGasCap {
148143
gas = uint64(*args.Gas)
149144
}
150145
if globalGasCap != 0 && globalGasCap < gas {
@@ -201,11 +196,6 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
201196
nonce = uint64(*args.Nonce)
202197
}
203198

204-
// Limit gas cap to avoid DOS during simulation
205-
if gas > MaxGasCap {
206-
gas = MaxGasCap
207-
}
208-
209199
msg := &core.Message{
210200
From: addr,
211201
To: args.To,

0 commit comments

Comments
 (0)