Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
validator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
validator
Commits
a9d24f4d
Commit
a9d24f4d
authored
Feb 02, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: gen merkle proof
parent
f0d42245
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
witness.go
core/witness.go
+1
-1
merkle_proof_test.go
tree/merkle_proof_test.go
+40
-0
No files found.
core/witness.go
View file @
a9d24f4d
...
@@ -241,7 +241,7 @@ func (w *Witness) CommitMT(objects []*witnessv1.MinerObject) (root common.Hash,
...
@@ -241,7 +241,7 @@ func (w *Witness) CommitMT(objects []*witnessv1.MinerObject) (root common.Hash,
merkleProofs
:=
make
(
tree
.
Proofs
,
0
)
merkleProofs
:=
make
(
tree
.
Proofs
,
0
)
dbProofs
:=
make
([]
byte
,
0
)
dbProofs
:=
make
([]
byte
,
0
)
for
_
,
object
:=
range
objects
{
for
_
,
object
:=
range
objects
{
payload
:=
append
(
common
.
HexToAddress
(
object
.
Miner
)
.
Bytes
(),
big
.
NewInt
(
0
)
.
SetUint64
(
object
.
Workload
)
.
Bytes
(
)
...
)
payload
:=
append
(
common
.
HexToAddress
(
object
.
Miner
)
.
Bytes
(),
common
.
LeftPadBytes
(
big
.
NewInt
(
0
)
.
SetUint64
(
object
.
Workload
)
.
Bytes
(),
32
)
...
)
_proof
:=
crypto
.
Keccak256Hash
(
payload
)
_proof
:=
crypto
.
Keccak256Hash
(
payload
)
merkleProofs
=
append
(
merkleProofs
,
_proof
)
merkleProofs
=
append
(
merkleProofs
,
_proof
)
dbProofs
=
append
(
dbProofs
,
_proof
[
:
]
...
)
dbProofs
=
append
(
dbProofs
,
_proof
[
:
]
...
)
...
...
tree/merkle_proof_test.go
0 → 100644
View file @
a9d24f4d
package
tree
import
(
"encoding/hex"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func
TestMT
(
t
*
testing
.
T
)
{
proofs
:=
make
([]
common
.
Hash
,
0
)
proofs
=
append
(
proofs
,
common
.
HexToHash
(
"0x1"
))
proofs
=
append
(
proofs
,
common
.
HexToHash
(
"0x2"
))
proofs
=
append
(
proofs
,
common
.
HexToHash
(
"0x3"
))
address
:=
common
.
HexToAddress
(
"0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326"
)
amount
:=
big
.
NewInt
(
0
)
.
SetUint64
(
10
)
payload
:=
append
(
address
.
Bytes
(),
common
.
LeftPadBytes
(
amount
.
Bytes
(),
32
)
...
)
data
:=
crypto
.
Keccak256Hash
(
payload
)
proofs
=
append
(
proofs
,
data
)
tree
,
err
:=
NewMerkleTree
(
proofs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
mproofs
,
err
:=
tree
.
GetProof
(
data
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Log
(
tree
.
GetRoot
()
.
Hex
())
for
_
,
el
:=
range
mproofs
{
t
.
Log
(
hex
.
EncodeToString
(
el
[
:
]))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment