Skip to content

Commit 50df3af

Browse files
committed
move logic
1 parent ea56196 commit 50df3af

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

x/evm/types/tx_args.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,16 @@ 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()
141138

139+
// Ethereum block size is ~36000000, we limit this value to protect against DOS
140+
MaxGasCap := uint64(100000000)
141+
142142
// 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 {
143+
gas := MaxGasCap
144+
145+
if args.Gas != nil && uint64(*args.Gas) < MaxGasCap {
148146
gas = uint64(*args.Gas)
149147
}
150148
if globalGasCap != 0 && globalGasCap < gas {
@@ -201,11 +199,6 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
201199
nonce = uint64(*args.Nonce)
202200
}
203201

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

0 commit comments

Comments
 (0)