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

Commit

Permalink
feat(bindings): update go contract bindings (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Aug 7, 2023
1 parent cc1c4a7 commit b9da8f6
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 40 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1eeba9d97ed8e6e4a8d07a8b0af163a16fbc9ccf
06710eb41132f7b920d80053ed8b906d90c18bb3
4 changes: 0 additions & 4 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ var (
Name: "beneficiary",
Type: "address",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "txListByteStart",
Type: "uint24",
Expand Down
1 change: 0 additions & 1 deletion bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type TaikoL1Evidence struct {
type TaikoL1BlockMetadataInput struct {
TxListHash [32]byte
Beneficiary common.Address
GasLimit uint32
TxListByteStart *big.Int
TxListByteEnd *big.Int
CacheTxListInfo uint8
Expand Down
1 change: 0 additions & 1 deletion bindings/encoding/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
}
testMetaInput = TaikoL1BlockMetadataInput{
Beneficiary: common.BytesToAddress(randomHash().Bytes()),
GasLimit: rand.Uint32(),
TxListHash: randomHash(),
TxListByteStart: common.Big0,
TxListByteEnd: common.Big0,
Expand Down
26 changes: 13 additions & 13 deletions bindings/gen_taiko_l2.go

Large diffs are not rendered by default.

34 changes: 27 additions & 7 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func (s *Syncer) onBlockProposed(
txListBytes,
l1Origin,
)

if err != nil {
return fmt.Errorf("failed to insert new head to L2 execution engine: %w", err)
}
Expand Down Expand Up @@ -334,8 +333,7 @@ func (s *Syncer) insertNewHead(
// Get L2 baseFee
baseFee, err := s.rpc.TaikoL2.GetBasefee(
&bind.CallOpts{BlockNumber: parent.Number, Context: ctx},
uint32(event.Meta.Timestamp-parentTimestamp),
event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit()),
event.Meta.Timestamp-parentTimestamp,
uint32(parent.GasUsed),
)
if err != nil {
Expand All @@ -346,7 +344,6 @@ func (s *Syncer) insertNewHead(
"GetBasefee",
"baseFee", baseFee,
"timeSinceParent", uint32(event.Meta.Timestamp-parentTimestamp),
"gasLimit", uint64(event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit())),
"parentGasUsed", parent.GasUsed,
)

Expand Down Expand Up @@ -386,7 +383,6 @@ func (s *Syncer) insertNewHead(
baseFee,
withdrawals,
)

if err != nil {
return nil, fmt.Errorf("failed to create execution payloads: %w", err)
}
Expand Down Expand Up @@ -437,7 +433,21 @@ func (s *Syncer) createExecutionPayloads(
L1Origin: l1Origin,
}

log.Debug("PayloadAttributes", "attributes", attributes, "meta", attributes.BlockMetadata)
log.Debug(
"PayloadAttributes",
"blockID", event.BlockId,
"timestamp", attributes.Timestamp,
"random", attributes.Random,
"suggestedFeeRecipient", attributes.SuggestedFeeRecipient,
"withdrawals", len(attributes.Withdrawals),
"highestBlockID", attributes.BlockMetadata.HighestBlockID,
"gasLimit", attributes.BlockMetadata.GasLimit,
"timestamp", attributes.BlockMetadata.Timestamp,
"mixHash", attributes.BlockMetadata.MixHash,
"baseFee", attributes.BaseFeePerGas,
"l1OriginHeight", attributes.L1Origin.L1BlockHeight,
"l1OriginHash", attributes.L1Origin.L1BlockHash,
)

// Step 1, prepare a payload
fcRes, err := s.rpc.L2Engine.ForkchoiceUpdate(ctx, fc, attributes)
Expand All @@ -457,7 +467,17 @@ func (s *Syncer) createExecutionPayloads(
return nil, fmt.Errorf("failed to get payload: %w", err)
}

log.Debug("Payload", "payload", payload)
log.Debug(
"Payload",
"blockID", event.BlockId,
"baseFee", payload.BaseFeePerGas,
"number", payload.Number,
"hash", payload.BlockHash,
"gasLimit", payload.GasLimit,
"gasUsed", payload.GasUsed,
"timestamp", payload.Timestamp,
"withdrawalsHash", payload.WithdrawalsHash,
)

// Step 3, execute the payload
execStatus, err := s.rpc.L2Engine.NewPayload(ctx, payload)
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestL1ContentFrom(t *testing.T) {
l2Head, err := client.L2.HeaderByNumber(context.Background(), nil)
require.Nil(t, err)

baseFee, err := client.TaikoL2.GetBasefee(nil, 0, 60000000, uint32(l2Head.GasUsed))
baseFee, err := client.TaikoL2.GetBasefee(nil, 0, uint32(l2Head.GasUsed))
require.Nil(t, err)

testAddrPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
Expand Down
5 changes: 1 addition & 4 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {

baseFee, err := p.rpc.TaikoL2.GetBasefee(
&bind.CallOpts{Context: ctx},
uint32(time.Now().Unix()-int64(l2Head.Time)),
p.protocolConfigs.BlockMaxGasLimit,
uint64(time.Now().Unix())-l2Head.Time,
uint32(l2Head.GasUsed),
)
if err != nil {
Expand Down Expand Up @@ -289,7 +288,6 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
txNonce := nonce + uint64(i)
if err := p.ProposeTxList(ctx, &encoding.TaikoL1BlockMetadataInput{
Beneficiary: p.l2SuggestedFeeRecipient,
GasLimit: p.protocolConfigs.BlockMaxGasLimit,
TxListHash: crypto.Keccak256Hash(txListBytes),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(txListBytes))),
Expand Down Expand Up @@ -446,7 +444,6 @@ func (p *Proposer) ProposeEmptyBlockOp(ctx context.Context) error {
return p.ProposeTxList(ctx, &encoding.TaikoL1BlockMetadataInput{
TxListHash: crypto.Keccak256Hash([]byte{}),
Beneficiary: p.L2SuggestedFeeRecipient(),
GasLimit: p.protocolConfigs.BlockMaxGasLimit,
TxListByteStart: common.Big0,
TxListByteEnd: common.Big0,
CacheTxListInfo: 0,
Expand Down
3 changes: 1 addition & 2 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *ProposerTestSuite) TestProposeOp() {
parent, err := s.p.rpc.L2.BlockByNumber(context.Background(), nil)
s.Nil(err)

baseFee, err := s.p.rpc.TaikoL2.GetBasefee(nil, 1, uint32(gaslimit), uint32(parent.GasUsed()))
baseFee, err := s.p.rpc.TaikoL2.GetBasefee(nil, 1, uint32(parent.GasUsed()))
s.Nil(err)

to := common.BytesToAddress(testutils.RandomBytes(32))
Expand Down Expand Up @@ -158,7 +158,6 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() {
context.Background(),
&encoding.TaikoL1BlockMetadataInput{
Beneficiary: s.p.L2SuggestedFeeRecipient(),
GasLimit: 21000,
TxListHash: crypto.Keccak256Hash(encoded),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(encoded))),
Expand Down
7 changes: 1 addition & 6 deletions testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ import (
)

func ProposeInvalidTxListBytes(s *ClientTestSuite, proposer Proposer) {
configs, err := s.RpcClient.TaikoL1.GetConfig(nil)
s.Nil(err)

invalidTxListBytes := RandomBytes(256)

s.Nil(proposer.ProposeTxList(context.Background(), &encoding.TaikoL1BlockMetadataInput{
Beneficiary: proposer.L2SuggestedFeeRecipient(),
GasLimit: uint32(rand.Int63n(int64(configs.BlockMaxGasLimit))),
TxListHash: crypto.Keccak256Hash(invalidTxListBytes),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(invalidTxListBytes))),
Expand Down Expand Up @@ -60,7 +56,6 @@ func ProposeAndInsertEmptyBlocks(

s.Nil(proposer.ProposeTxList(context.Background(), &encoding.TaikoL1BlockMetadataInput{
Beneficiary: proposer.L2SuggestedFeeRecipient(),
GasLimit: 21000,
TxListHash: crypto.Keccak256Hash(encoded),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(encoded))),
Expand Down Expand Up @@ -117,7 +112,7 @@ func ProposeAndInsertValidBlock(
close(sink)
}()

baseFee, err := s.RpcClient.TaikoL2.GetBasefee(nil, 0, 60000000, uint32(l2Head.GasUsed))
baseFee, err := s.RpcClient.TaikoL2.GetBasefee(nil, 0, uint32(l2Head.GasUsed))
s.Nil(err)

nonce, err := s.RpcClient.L2.PendingNonceAt(context.Background(), s.TestAddr)
Expand Down

0 comments on commit b9da8f6

Please sign in to comment.