Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 993d491

Browse files
feat(bindings): update Go contract bindings (#697)
1 parent 7a68a25 commit 993d491

30 files changed

+265
-261
lines changed

bindings/.githead

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b341a68d53b01087a6ce56a629b064d0b808b0bb
1+
2c63cb0c796495948f1dd887662044397394d852

bindings/encoding/input.go

+33-23
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
package encoding
22

33
import (
4+
"bytes"
5+
"encoding/binary"
46
"errors"
57
"fmt"
68

79
"github.com/ethereum/go-ethereum/accounts/abi"
810
"github.com/ethereum/go-ethereum/common"
11+
"github.com/ethereum/go-ethereum/crypto"
912
"github.com/ethereum/go-ethereum/log"
1013

1114
"github.com/taikoxyz/taiko-client/bindings"
1215
)
1316

1417
// ABI arguments marshaling components.
1518
var (
16-
blockMetadataComponents = []abi.ArgumentMarshaling{
19+
assignmentPayloadPrefix = "PROVER_ASSIGNMENT"
20+
assignmentPayloadPrefixSize = len([]byte(assignmentPayloadPrefix))
21+
paddedAssignmentPayloadPrefixBytes = common.LeftPadBytes([]byte(assignmentPayloadPrefix), assignmentPayloadPrefixSize)
22+
blockMetadataComponents = []abi.ArgumentMarshaling{
1723
{
1824
Name: "l1Hash",
1925
Type: "bytes32",
@@ -198,7 +204,6 @@ var (
198204
blockParamsComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockParams", blockParamsComponents)
199205
blockParamsComponentsArgs = abi.Arguments{{Name: "TaikoData.BlockParams", Type: blockParamsComponentsType}}
200206
// ProverAssignmentPayload
201-
stringType, _ = abi.NewType("string", "", nil)
202207
bytes32Type, _ = abi.NewType("bytes32", "", nil)
203208
addressType, _ = abi.NewType("address", "", nil)
204209
uint64Type, _ = abi.NewType("uint64", "", nil)
@@ -216,19 +221,14 @@ var (
216221
},
217222
},
218223
)
219-
proverAssignmentPayloadArgs = abi.Arguments{
220-
{Name: "PROVER_ASSIGNMENT", Type: stringType},
221-
{Name: "chainID", Type: uint64Type},
222-
{Name: "taikoAddress", Type: addressType},
223-
{Name: "assignmentHookAddress", Type: addressType},
224-
{Name: "metaHash", Type: bytes32Type},
225-
{Name: "parentMetaHash", Type: bytes32Type},
226-
{Name: "blobHash", Type: bytes32Type},
227-
{Name: "assignment.feeToken", Type: addressType},
228-
{Name: "assignment.expiry", Type: uint64Type},
229-
{Name: "assignment.maxBlockId", Type: uint64Type},
230-
{Name: "assignment.maxProposedIn", Type: uint64Type},
231-
{Name: "assignment.tierFees", Type: tierFeesType},
224+
proverAssignmentHashPayloadArgs = abi.Arguments{
225+
{Name: "_assignment.metaHash", Type: bytes32Type},
226+
{Name: "_assignment.parentMetaHash", Type: bytes32Type},
227+
{Name: "_assignment.feeToken", Type: addressType},
228+
{Name: "_assignment.expiry", Type: uint64Type},
229+
{Name: "_assignment.maxBlockId", Type: uint64Type},
230+
{Name: "_assignment.maxProposedIn", Type: uint64Type},
231+
{Name: "_assignment.tierFees", Type: tierFeesType},
232232
}
233233
blockMetadataComponentsType, _ = abi.NewType("tuple", "TaikoData.BlockMetadata", blockMetadataComponents)
234234
transitionComponentsType, _ = abi.NewType("tuple", "TaikoData.Transition", transitionComponents)
@@ -341,21 +341,18 @@ func EncodeProverAssignmentPayload(
341341
chainID uint64,
342342
taikoAddress common.Address,
343343
assignmentHookAddress common.Address,
344-
txListHash common.Hash,
344+
blockProposer common.Address,
345+
assignedProver common.Address,
346+
blobHash common.Hash,
345347
feeToken common.Address,
346348
expiry uint64,
347349
maxBlockID uint64,
348350
maxProposedIn uint64,
349351
tierFees []TierFee,
350352
) ([]byte, error) {
351-
b, err := proverAssignmentPayloadArgs.Pack(
352-
"PROVER_ASSIGNMENT",
353-
chainID,
354-
taikoAddress,
355-
assignmentHookAddress,
353+
hashBytesPayload, err := proverAssignmentHashPayloadArgs.Pack(
356354
common.Hash{},
357355
common.Hash{},
358-
txListHash,
359356
feeToken,
360357
expiry,
361358
maxBlockID,
@@ -365,7 +362,20 @@ func EncodeProverAssignmentPayload(
365362
if err != nil {
366363
return nil, fmt.Errorf("failed to abi.encode prover assignment hash payload, %w", err)
367364
}
368-
return b, nil
365+
366+
chainIDBytes := make([]byte, 8)
367+
binary.BigEndian.PutUint64(chainIDBytes, chainID)
368+
369+
return bytes.Join([][]byte{
370+
paddedAssignmentPayloadPrefixBytes[len(paddedAssignmentPayloadPrefixBytes)-assignmentPayloadPrefixSize:],
371+
chainIDBytes,
372+
taikoAddress.Bytes(),
373+
blockProposer.Bytes(),
374+
assignedProver.Bytes(),
375+
blobHash.Bytes(),
376+
crypto.Keccak256Hash(hashBytesPayload).Bytes(),
377+
assignmentHookAddress.Bytes(),
378+
}, nil), nil
369379
}
370380

371381
// EncodeProveBlockInput performs the solidity `abi.encode` for the given TaikoL1.proveBlock input.

bindings/encoding/input_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func TestEncodeProverAssignmentPayload(t *testing.T) {
2121
randomHash().Big().Uint64(),
2222
common.BytesToAddress(randomBytes(20)),
2323
common.BytesToAddress(randomBytes(20)),
24+
common.BytesToAddress(randomBytes(20)),
25+
common.BytesToAddress(randomBytes(20)),
2426
common.BytesToHash(randomBytes(32)),
2527
common.BytesToAddress(randomBytes(20)),
2628
120,

bindings/gen_address_manager.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)