forked from 0xPolygonHermez/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
etrog: synchornizer-permisionless: first version working of sync with…
… trusted state (0xPolygonHermez#2949) - state: Changed `ProcessingContextV2` to support `L1InfoTreeData` (all the leafs of L1InfoTree used in a batch) - state: removed debug logs from the `enconding_batch_v2.go` - test: upgrade Mockery from 2.22.1 to 2.39.0 to support `max` function of golang 1.21 - synchronizer: tidy up interfaces. The repeated have been grouped - synchronizer: simplified generation of mocks (stop using "mock_" prefix but are under `mocks/` folder) - synchronizer: change cache system of syncTrusted - synchronizer: to known if a trusted batch is closed stop using empty StateRoot and use `Closed` field - synchronizer: don't check batch timestamp because RPC is not providing the creational_stamp (issue 0xPolygonHermez#2953 - synchronizer: calls to executor pass the `L1InfoTreeData`
- Loading branch information
1 parent
91ceee5
commit 4290837
Showing
46 changed files
with
5,667 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
// LogComparedBytes returns a string the bytes of two []bytes, starting from the first byte that is different | ||
func LogComparedBytes(name1 string, name2 string, data1 []byte, data2 []byte, numBytesBefore int, numBytesAfter int) string { | ||
findFirstByteDifferent := findFirstByteDifferent(data1, data2) | ||
if findFirstByteDifferent == -1 { | ||
return fmt.Sprintf("%s(%d) and %s(%d) are equal", name1, len(data1), name2, len(data2)) | ||
} | ||
res := name1 + fmt.Sprintf("(%d)", len(data1)) + ": " + strSliceBytes(data1, findFirstByteDifferent, numBytesBefore, numBytesAfter) + "\n" | ||
res += name2 + fmt.Sprintf("(%d)", len(data1)) + ": " + strSliceBytes(data2, findFirstByteDifferent, numBytesBefore, numBytesAfter) | ||
return res | ||
} | ||
|
||
func strSliceBytes(data []byte, point int, before int, after int) string { | ||
res := "" | ||
startingPoint := max(0, point-before) | ||
if startingPoint > 0 { | ||
res += fmt.Sprintf("(%d)...", startingPoint) | ||
} | ||
endPoint := min(len(data), point+after) | ||
res += fmt.Sprintf("%s*%s", common.Bytes2Hex(data[startingPoint:point]), common.Bytes2Hex(data[point:endPoint])) | ||
|
||
if endPoint < len(data) { | ||
res += fmt.Sprintf("...(%d)", len(data)-endPoint) | ||
} | ||
return res | ||
} | ||
|
||
func findFirstByteDifferent(data1 []byte, data2 []byte) int { | ||
for i := 0; i < len(data1); i++ { | ||
if data1[i] != data2[i] { | ||
return i | ||
} | ||
} | ||
return -1 | ||
} |
Oops, something went wrong.