Skip to content

Commit

Permalink
Correct gas estimation (0xPolygonHermez#1414)
Browse files Browse the repository at this point in the history
* Add test for gas refund

* add gas estimation

* Correct highend during gas estimation

* Correct highend during gas estimation

* Correct highend during gas estimation

* Correct highend during gas estimation

* Correct highend during gas estimation
  • Loading branch information
ToniRamirezM authored Nov 24, 2022
1 parent db4a520 commit c99aed3
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/test/vectors/src/**/*sh
/test/vectors/src/package.json

/test/contracts/**/*.abi
/test/contracts/**/*.bin
/test/contracts/bin/**/*.bin
/test/contracts/bin/**/*.abi

Expand Down
13 changes: 4 additions & 9 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ import (

const (
// Size of the memory in bytes reserved by the zkEVM
zkEVMReservedMemorySize int = 128
two uint = 2
three uint64 = 3
cTrue = 1
cFalse = 0
zkEVMReservedMemorySize int = 128
two uint = 2
cTrue = 1
cFalse = 0
)

var (
Expand Down Expand Up @@ -295,10 +294,6 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common
lowEnd = gasUsed
}

if gasUsed > 0 {
highEnd = (gasUsed * three) / uint64(two)
}

// Start the binary search for the lowest possible gas price
for (lowEnd < highEnd) && (highEnd-lowEnd) > 4096 {
txExecutionStart := time.Now()
Expand Down
Loading

0 comments on commit c99aed3

Please sign in to comment.