Skip to content

Commit

Permalink
fix(taiko-client): fix CallOpts and TestTreasuryIncome test case (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Aug 29, 2024
1 parent 7893700 commit 5707a08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/taiko-client/bindings/encoding/protocol_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
OntakeForkHeight: 2,
BaseFeeConfig: bindings.TaikoDataBaseFeeConfig{
AdjustmentQuotient: 8,
SharingPctg: 75,
GasIssuancePerSecond: 5_000_000,
MinGasExcess: 1_340_000_000,
MaxGasIssuancePerBlock: 600_000_000,
Expand Down
15 changes: 13 additions & 2 deletions packages/taiko-client/driver/chain_syncer/blob/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import (
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/metadata"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/chain_syncer/beaconsync"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/state"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/testutils"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/config"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/jwt"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/proposer"
Expand Down Expand Up @@ -153,6 +155,7 @@ func (s *BlobSyncerTestSuite) TestTreasuryIncome() {
s.True(balanceAfter.Cmp(balance) > 0)

var hasNoneAnchorTxs bool
chainConfig := config.NewChainConfig(encoding.GetProtocolConfig(s.RPCClient.L2.ChainID.Uint64()))
for i := headBefore + 1; i <= headAfter; i++ {
block, err := s.RPCClient.L2.BlockByNumber(context.Background(), new(big.Int).SetUint64(i))
s.Nil(err)
Expand All @@ -169,8 +172,16 @@ func (s *BlobSyncerTestSuite) TestTreasuryIncome() {
s.Nil(err)

fee := new(big.Int).Mul(block.BaseFee(), new(big.Int).SetUint64(receipt.GasUsed))

balance = new(big.Int).Add(balance, fee)
if chainConfig.IsOntake(block.Number()) {
feeCoinbase := new(big.Int).Div(
new(big.Int).Mul(fee, new(big.Int).SetUint64(uint64(chainConfig.ProtocolConfigs.BaseFeeConfig.SharingPctg))),
new(big.Int).SetUint64(100),
)
feeTreasury := new(big.Int).Sub(fee, feeCoinbase)
balance = new(big.Int).Add(balance, feeTreasury)
} else {
balance = new(big.Int).Add(balance, fee)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (c *Client) CalculateBaseFee(
}
}
baseFeeInfo, err = c.TaikoL2.CalculateBaseFee(
&bind.CallOpts{Context: ctx},
&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx},
*baseFeeConfig,
uint64(time.Now().Unix())-l2Head.Time,
parentGasExcess,
Expand All @@ -329,7 +329,7 @@ func (c *Client) CalculateBaseFee(
}
} else {
baseFeeInfo, err = c.TaikoL2.GetBasefee(
&bind.CallOpts{Context: ctx},
&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx},
anchorBlockID.Uint64(),
uint32(l2Head.GasUsed), // #nosec G115
)
Expand Down

0 comments on commit 5707a08

Please sign in to comment.