Skip to content

Commit

Permalink
Merge branch 'main' into feat/499/member-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikelle authored Dec 9, 2024
2 parents 64c0383 + 81cfa8a commit aeeac1f
Show file tree
Hide file tree
Showing 45 changed files with 1,746 additions and 780 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "contracts/lib/openzeppelin-upgrades"]
path = contracts/lib/openzeppelin-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-upgrades.git
[submodule "contracts/lib/burners"]
path = contracts/lib/burners
url = https://github.com/symbioticfi/burners
5 changes: 5 additions & 0 deletions bridge/standard/cmd/user_cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/primev/mev-commit/bridge/standard/pkg/transfer"
"github.com/primev/mev-commit/contracts-abi/config"
"github.com/primev/mev-commit/x/keysigner"
"github.com/theckman/yacspin"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -49,24 +50,28 @@ var (
Usage: "URL for L1 RPC",
EnvVars: []string{"L1_RPC_URL"},
Required: true,
Value: "https://ethereum-holesky-rpc.publicnode.com",
}
optionSettlementRPCUrl = &cli.StringFlag{
Name: "settlement-rpc-url",
Usage: "URL for settlement RPC",
EnvVars: []string{"SETTLEMENT_RPC_URL"},
Required: true,
Value: "https://chainrpc.testnet.mev-commit.xyz",
}
optionL1ContractAddr = &cli.StringFlag{
Name: "l1-contract-addr",
Usage: "address of the L1 gateway contract",
EnvVars: []string{"L1_CONTRACT_ADDR"},
Required: true,
Value: config.HoleskyContracts.L1Gateway,
}
optionSettlementContractAddr = &cli.StringFlag{
Name: "settlement-contract-addr",
Usage: "address of the settlement gateway contract",
EnvVars: []string{"SETTLEMENT_CONTRACT_ADDR"},
Required: true,
Value: config.TestnetContracts.SettlementGateway,
}
optionSilent = &cli.BoolFlag{
Name: "silent",
Expand Down
31 changes: 31 additions & 0 deletions bridge/standard/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

const blockDrift uint64 = 10_000

type Options struct {
Logger *slog.Logger
HTTPPort int
Expand Down Expand Up @@ -89,6 +91,35 @@ func NewNode(opts *Options) (*Node, error) {
return nil, fmt.Errorf("failed to create settlement store: %w", err)
}

existingBlockNum, err := l1Store.LastBlock()
if err != nil {
return nil, fmt.Errorf("failed to get last block number: %w", err)
}

if existingBlockNum == 0 {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

client, err := ethclient.DialContext(ctx, opts.L1RPCURL)
if err != nil {
return nil, fmt.Errorf("failed to connect to the Ethereum node: %w", err)
}
blkNum, err := client.BlockNumber(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get block number: %w", err)
}

if blkNum > blockDrift {
// Set the last block number to 10000 blocks behind the current block number
// to avoid reprocessing all the blocks from the beginning. This will be updated
// in the database as the blocks are processed.
err = l1Store.SetLastBlock(blkNum - blockDrift)
if err != nil {
return nil, fmt.Errorf("failed to set last block number: %w", err)
}
}
}

ctx, cancel := context.WithCancel(context.Background())
err = n.createGatewayContract(
ctx,
Expand Down
24 changes: 0 additions & 24 deletions contracts-abi/abi/BidderRegistry.abi
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,6 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "bidderRegistered",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "blockTrackerContract",
Expand Down Expand Up @@ -1022,11 +1003,6 @@
}
]
},
{
"type": "error",
"name": "BidderAmountIsZero",
"inputs": []
},
{
"type": "error",
"name": "BidderWithdrawalTransferFailed",
Expand Down
Loading

0 comments on commit aeeac1f

Please sign in to comment.