Skip to content

Commit

Permalink
Merge branch 'master' into rest-api/worldchain
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Oct 11, 2024
2 parents c1573b6 + 34f5ff5 commit d4e6d2b
Show file tree
Hide file tree
Showing 35 changed files with 549 additions and 332 deletions.
13 changes: 12 additions & 1 deletion contrib/promexporter/internal/gql/dfk/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.4.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.3.11...@synapsecns/bridge-docs@0.4.0) (2024-10-10)


### Features

* **synapse-constants:** adds preinstall step ([#3269](https://github.com/synapsecns/sanguine/issues/3269)) ([acd61de](https://github.com/synapsecns/sanguine/commit/acd61de4846d9b23d7aa834b8f2eefcaae486c7d))





## [0.3.11](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.3.10...@synapsecns/bridge-docs@0.3.11) (2024-10-10)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.3.10](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.3.9...@synapsecns/bridge-docs@0.3.10) (2024-10-08)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
15 changes: 12 additions & 3 deletions docs/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati
## Generating API Docs

<!--TODO: needs to be done from ci to ensure regenration is done.-->

`yarn docusaurus gen-api-docs all`.

### Installation

```
```bash
$ yarn
```

### Local Development

```
```bash
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
```bash
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Serve

This step is needed to create a searchable index.

```bash
$ yarn serve
```
4 changes: 2 additions & 2 deletions docs/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/bridge-docs",
"version": "0.3.10",
"version": "0.4.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down Expand Up @@ -34,7 +34,7 @@
"@docusaurus/utils-validation": "3.5.2",
"@easyops-cn/docusaurus-search-local": "^0.44.5",
"@mdx-js/react": "^3.0.0",
"@synapsecns/synapse-constants": "^1.6.0",
"@synapsecns/synapse-constants": "^1.7.0",
"clsx": "^2.0.0",
"docusaurus-plugin-openapi-docs": "^4.0.1",
"docusaurus-theme-openapi-docs": "^4.0.1",
Expand Down
44 changes: 0 additions & 44 deletions ethergo/submitter/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,13 @@ import (
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/submitter/config"
"github.com/synapsecns/sanguine/ethergo/submitter/db"
"go.opentelemetry.io/otel/attribute"
)

// CopyTransactOpts exports copyTransactOpts for testing.
func CopyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts {
return copyTransactOpts(opts)
}

// NullFieldAttribute is a constant used to test the null field attribute.
// it exports the underlying constant for testing.
const NullFieldAttribute = nullFieldAttribute

func AddressPtrToString(address *common.Address) string {
return addressPtrToString(address)
}

// BigPtrToString converts a big.Int pointer to a string.
func BigPtrToString(num *big.Int) string {
return bigPtrToString(num)
}

// TxToAttributes exports txToAttributes for testing.
func TxToAttributes(transaction *types.Transaction, UUID string) []attribute.KeyValue {
return txToAttributes(transaction, UUID)
}

// SortTxes exports sortTxesByChainID for testing.
func SortTxes(txs []db.TX, maxPerChain int) map[uint64][]db.TX {
return sortTxesByChainID(txs, maxPerChain)
Expand All @@ -48,31 +29,6 @@ func GroupTxesByNonce(txs []db.TX) map[uint64][]db.TX {
return groupTxesByNonce(txs)
}

const (
// HashAttr exports hashAttr for testing.
HashAttr = hashAttr
// FromAttr exports fromAttr for testing.
FromAttr = fromAttr
// ToAttr exports toAttr for testing.
ToAttr = toAttr
// DataAttr exports dataAttr for testing.
DataAttr = dataAttr
// ValueAttr exports valueAttr for testing.
ValueAttr = valueAttr
// NonceAttr exports nonceAttr for testing.
NonceAttr = nonceAttr
// GasLimitAttr exports gasLimitAttr for testing.
GasLimitAttr = gasLimitAttr
// ChainIDAttr exports chainIDAttr for testing.
ChainIDAttr = chainIDAttr
// GasPriceAttr exports gasPriceAttr for testing.
GasPriceAttr = gasPriceAttr
// GasFeeCapAttr exports gasFeeCapAttr for testing.
GasFeeCapAttr = gasFeeCapAttr
// GasTipCapAttr exports gasTipCapAttr for testing.
GasTipCapAttr = gasTipCapAttr
)

// NewTestTransactionSubmitter wraps TestTransactionSubmitter in a TransactionSubmitter interface.
func NewTestTransactionSubmitter(metrics metrics.Handler, signer signer.Signer, fetcher ClientFetcher, db db.Service, config *config.Config) TestTransactionSubmitter {
txSubmitter := NewTransactionSubmitter(metrics, signer, fetcher, db, config)
Expand Down
34 changes: 17 additions & 17 deletions ethergo/submitter/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ func (t *txSubmitterImpl) setGasPrice(ctx context.Context, client client.EVM,
span.SetAttributes(
attribute.Int(metrics.ChainID, chainID),
attribute.Bool("use_dynamic", useDynamic),
attribute.String("gas_price", bigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", bigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", bigPtrToString(transactor.GasTipCap)),
attribute.String("gas_price", util.BigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", util.BigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", util.BigPtrToString(transactor.GasTipCap)),
)
metrics.EndSpanWithErr(span, err)
}()
Expand Down Expand Up @@ -501,9 +501,9 @@ func (t *txSubmitterImpl) bumpGasFromPrevTx(ctx context.Context, transactor *bin

defer func() {
span.SetAttributes(
attribute.String("gas_price", bigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", bigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", bigPtrToString(transactor.GasTipCap)),
attribute.String("gas_price", util.BigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", util.BigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", util.BigPtrToString(transactor.GasTipCap)),
)
metrics.EndSpan(span)
}()
Expand Down Expand Up @@ -537,9 +537,9 @@ func (t *txSubmitterImpl) applyGasFloor(ctx context.Context, transactor *bind.Tr

defer func() {
span.SetAttributes(
attribute.String("gas_price", bigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", bigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", bigPtrToString(transactor.GasTipCap)),
attribute.String("gas_price", util.BigPtrToString(transactor.GasPrice)),
attribute.String("gas_fee_cap", util.BigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", util.BigPtrToString(transactor.GasTipCap)),
)
metrics.EndSpan(span)
}()
Expand Down Expand Up @@ -578,10 +578,10 @@ func (t *txSubmitterImpl) applyGasFromOracle(ctx context.Context, transactor *bi
}
transactor.GasTipCap = maxOfBig(transactor.GasTipCap, suggestedGasTipCap)
span.SetAttributes(
attribute.String("suggested_gas_fee_cap", bigPtrToString(suggestedGasFeeCap)),
attribute.String("suggested_gas_tip_cap", bigPtrToString(suggestedGasTipCap)),
attribute.String("gas_fee_cap", bigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", bigPtrToString(transactor.GasTipCap)),
attribute.String("suggested_gas_fee_cap", util.BigPtrToString(suggestedGasFeeCap)),
attribute.String("suggested_gas_tip_cap", util.BigPtrToString(suggestedGasTipCap)),
attribute.String("gas_fee_cap", util.BigPtrToString(transactor.GasFeeCap)),
attribute.String("gas_tip_cap", util.BigPtrToString(transactor.GasTipCap)),
)
} else {
suggestedGasPrice, err := client.SuggestGasPrice(ctx)
Expand All @@ -590,8 +590,8 @@ func (t *txSubmitterImpl) applyGasFromOracle(ctx context.Context, transactor *bi
}
transactor.GasPrice = maxOfBig(transactor.GasPrice, suggestedGasPrice)
span.SetAttributes(
attribute.String("suggested_gas_price", bigPtrToString(suggestedGasPrice)),
attribute.String("gas_price", bigPtrToString(transactor.GasPrice)),
attribute.String("suggested_gas_price", util.BigPtrToString(suggestedGasPrice)),
attribute.String("gas_price", util.BigPtrToString(transactor.GasPrice)),
)
}
return nil
Expand All @@ -605,7 +605,7 @@ func (t *txSubmitterImpl) applyGasCeil(ctx context.Context, transactor *bind.Tra
maxPrice := t.config.GetMaxGasPrice(chainID)

defer func() {
span.SetAttributes(attribute.String("max_price", bigPtrToString(maxPrice)))
span.SetAttributes(attribute.String("max_price", util.BigPtrToString(maxPrice)))
metrics.EndSpanWithErr(span, err)
}()

Expand Down Expand Up @@ -661,7 +661,7 @@ func (t *txSubmitterImpl) getGasBlock(ctx context.Context, chainClient client.EV
if ok {
span.AddEvent("could not get gas block; using cached value", trace.WithAttributes(
attribute.String("error", err.Error()),
attribute.String("blockNumber", bigPtrToString(gasBlock.Number)),
attribute.String("blockNumber", util.BigPtrToString(gasBlock.Number)),
))
} else {
return nil, fmt.Errorf("could not get gas block: %w", err)
Expand Down
76 changes: 7 additions & 69 deletions ethergo/submitter/util.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package submitter

import (
"fmt"
"github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/ethergo/util"
"go.opentelemetry.io/otel/attribute"
"math/big"
"sort"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/ethergo/chain/gas"
"github.com/synapsecns/sanguine/ethergo/submitter/db"
"github.com/synapsecns/sanguine/ethergo/util"
"go.opentelemetry.io/otel/attribute"
)

// copyTransactOpts creates a deep copy of the given TransactOpts struct
Expand All @@ -33,74 +31,14 @@ func copyTransactOpts(opts *bind.TransactOpts) *bind.TransactOpts {
return copyOpts
}

const (
uuidAttr = "tx.UUID"
hashAttr = "tx.Hash"
fromAttr = "tx.From"
toAttr = "tx.To"
dataAttr = "tx.Data"
valueAttr = "tx.Value"
nonceAttr = "tx.Nonce"
gasLimitAttr = "tx.GasLimit"
chainIDAttr = "tx.ChainID"
gasPriceAttr = "tx.GasPrice"
gasFeeCapAttr = "tx.GasFeeCap"
gasTipCapAttr = "tx.GasTipCap"
)

// txToAttributes converts a transaction to a slice of attribute.KeyValue.
func txToAttributes(transaction *types.Transaction, uuid string) []attribute.KeyValue {
var from string
call, err := util.TxToCall(transaction)
if err != nil {
from = fmt.Sprintf("could not be detected: %v", err)
} else {
from = call.From.Hex()
}
var attributes = []attribute.KeyValue{
attribute.String(uuidAttr, uuid),
attribute.String(hashAttr, transaction.Hash().Hex()),
attribute.String(fromAttr, from),
attribute.String(toAttr, addressPtrToString(transaction.To())),
attribute.String(dataAttr, fmt.Sprintf("%x", transaction.Data())),
attribute.String(valueAttr, bigPtrToString(transaction.Value())),
// TODO: this could be downcast to int64, but it's unclear how we should handle overflows.
// since this is only for tracing, we can probably ignore it for now.
attribute.Int64(nonceAttr, int64(transaction.Nonce())),
attribute.Int64(gasLimitAttr, int64(transaction.Gas())),
attribute.String(chainIDAttr, bigPtrToString(transaction.ChainId())),
}

if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil {
attributes = append(attributes, attribute.String(gasPriceAttr, bigPtrToString(transaction.GasPrice())))
}

if transaction.Type() == types.DynamicFeeTxType && transaction.GasFeeCap() != nil {
attributes = append(attributes, attribute.String(gasFeeCapAttr, bigPtrToString(transaction.GasFeeCap())))
}

if transaction.Type() == types.DynamicFeeTxType && transaction.GasTipCap() != nil {
attributes = append(attributes, attribute.String(gasTipCapAttr, bigPtrToString(transaction.GasTipCap())))
}
func txToAttributes(transaction *types.Transaction, uuid string) (attributes []attribute.KeyValue) {
attributes = util.TxToAttributes(transaction)
attributes = append(attributes, attribute.String(uuidAttr, uuid))

return attributes
}

const nullFieldAttribute = "null"

func addressPtrToString(address *common.Address) string {
if address == nil {
return nullFieldAttribute
}
return address.Hex()
}

func bigPtrToString(num *big.Int) string {
if num == nil {
return nullFieldAttribute
}
return num.String()
}
const uuidAttr = "tx.UUID"

// sortTxesByChainID sorts a slice of transactions by nonce.
func sortTxesByChainID(txs []db.TX, maxPerChain int) map[uint64][]db.TX {
Expand Down
Loading

0 comments on commit d4e6d2b

Please sign in to comment.