Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anvil backend log cleanup #1538

Closed
wants to merge 200 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
3ba5121
docker first pass
trajan0x Aug 22, 2023
810cc76
fix omnirpc port default behavior
trajan0x Aug 22, 2023
5d8803e
Merge branch 'fix/omnirpc-default-value' into feat/devnet-up
trajan0x Aug 22, 2023
055c992
Docker-compose updates
trajan0x Aug 22, 2023
3ff2c54
add guide for adding new go modules
trajan0x Aug 23, 2023
d28bd00
typo fix
trajan0x Aug 23, 2023
3103cfb
indentation fix
trajan0x Aug 23, 2023
1b7b662
kink fix
trajan0x Aug 23, 2023
65f18a4
remove vanity
trajan0x Aug 23, 2023
adc5182
devnet fix
trajan0x Aug 23, 2023
4debd76
Merge branch 'master' into feat/devnet-up
trajan0x Aug 23, 2023
788352d
backup for max attempt change
trajan0x Aug 23, 2023
60dd2b7
hi
trajan0x Aug 23, 2023
dcb10a6
make retry defaults more sensible
trajan0x Aug 23, 2023
fa75718
lint fix
trajan0x Aug 23, 2023
8103585
Revert "hi"
trajan0x Aug 23, 2023
38207af
Merge branch 'feat/retry-sane-defaults' into feat/devnet-up #1275
trajan0x Aug 23, 2023
869947a
test
trajan0x Aug 23, 2023
fab4a04
omnirpc chains endpoint
trajan0x Aug 23, 2023
259f352
close response handle
trajan0x Aug 23, 2023
a314e12
actually close response
trajan0x Aug 23, 2023
6d72362
Merge branch 'feat/omnirpc-chains-endpoint' into feat/devnet-up
trajan0x Aug 23, 2023
ee81b8c
more fixes
trajan0x Aug 24, 2023
9ffa4ce
Merge branch 'master' into feat/devnet-up
trajan0x Aug 24, 2023
e86bdf6
wip
trajan0x Aug 30, 2023
f704454
forge install: solmate
trajan0x Aug 30, 2023
a0db120
newmates
trajan0x Aug 30, 2023
e2fb52e
Merge branch 'master' into feat/devnet-up
trajan0x Aug 30, 2023
5ec4f60
create3
trajan0x Aug 30, 2023
9cc6493
create3factory
trajan0x Aug 31, 2023
47ee5f9
custom config path
trajan0x Sep 2, 2023
396c6e7
Revert "custom config path"
trajan0x Sep 2, 2023
969a6cd
deploy config defaults
trajan0x Sep 2, 2023
f778d25
Revert "deploy config defaults"
trajan0x Sep 2, 2023
e27e95b
devnet check
trajan0x Sep 2, 2023
982bbd6
basic updates
trajan0x Sep 2, 2023
3d2367e
factory fixes
trajan0x Sep 2, 2023
c4f7ba0
cleanup
trajan0x Sep 2, 2023
d9e229a
devnet up/down
trajan0x Sep 2, 2023
6973c88
first pass
trajan0x Sep 3, 2023
76418d5
Merge branch 'master' into feat/devnet-up
trajan0x Sep 3, 2023
ee6d9bd
guard it up
trajan0x Sep 3, 2023
5f97a51
guard
trajan0x Sep 3, 2023
ee7588f
1 notary
trajan0x Sep 3, 2023
e71379c
fix merge conflicts
trajan0x Sep 9, 2023
3866cd9
Merge branch 'master' into feat/devnet-up
trajan0x Sep 14, 2023
133cad4
Merge branch 'master' into feat/devnet-up
trajan0x Sep 14, 2023
7b9c09e
Merge branch 'master' into feat/devnet-up
trajan0x Sep 14, 2023
3f4da19
more updates
trajan0x Sep 14, 2023
d7f56e8
fix wrong domain in deploy script
trajan0x Sep 14, 2023
eae76f2
Merge branch 'domain-fix' into feat/devnet-up (#1376, fixes issue int…
trajan0x Sep 14, 2023
cf17957
diff fix
trajan0x Sep 14, 2023
8b8f252
comment fix
trajan0x Sep 14, 2023
380e962
Merge branch 'domain-fix' into feat/devnet-up
trajan0x Sep 14, 2023
8102b92
agent proof updates
trajan0x Sep 14, 2023
0f395bc
synapse domain fix
trajan0x Sep 14, 2023
5298a14
Merge branch 'domain-fix' into feat/devnet-up
trajan0x Sep 14, 2023
b54c0e2
generic linter fix
trajan0x Sep 14, 2023
1df2f9e
get guard to boot [goreleaser]
trajan0x Sep 14, 2023
ccbfe34
merge #1248
trajan0x Sep 15, 2023
f7c6787
more yaml lint
trajan0x Sep 15, 2023
a603db3
some nice debugging tools
trajan0x Sep 15, 2023
8d42d1b
generic linter fix
trajan0x Sep 15, 2023
44700a6
finish devnet
trajan0x Sep 15, 2023
eaca30b
fix lint commandS
trajan0x Sep 15, 2023
7992a2d
d
trajan0x Sep 15, 2023
03a8b00
wrap up rudimentary devneT
trajan0x Sep 15, 2023
1788a51
create3
trajan0x Sep 15, 2023
d57c297
deployer/create fix
trajan0x Sep 15, 2023
de82034
fix ubuntu
trajan0x Sep 15, 2023
bb71314
lowercase non-constants
trajan0x Sep 15, 2023
bcb2522
icreate3 import
trajan0x Sep 15, 2023
da76855
Revert "icreate3 import"
trajan0x Sep 15, 2023
246b504
move to internal
trajan0x Sep 15, 2023
a4bd732
another internal change
trajan0x Sep 15, 2023
00cdb48
update installs on dev containers for easier debugging
trajan0x Sep 15, 2023
46c1b61
Update packages/contracts-core/README.md
trajan0x Sep 16, 2023
6a993d7
address https://github.com/synapsecns/sanguine/pull/1381#discussion_r…
trajan0x Sep 18, 2023
a480961
Merge branch 'master' into feat/devnet-upper
trajan0x Sep 18, 2023
616c5ab
Replace Create3 with ZeframLou/create3-factory (#1387)
trajan0x Sep 18, 2023
6b100fd
Revert "Replace Create3 with ZeframLou/create3-factory (#1387)" (#1388)
trajan0x Sep 18, 2023
fc95521
Replace Create3 with ZeframLou/create3-factory
trajan0x Sep 18, 2023
305c558
Merge branch 'master' into feat/devnet-upper
trajan0x Sep 18, 2023
b64a4e6
WIP: add initial devnet script
dwasse Sep 21, 2023
b212f2b
fix package issue
trajan0x Sep 21, 2023
23c91f6
WIP: add ping pong sending logic
dwasse Sep 21, 2023
4c90604
WIP: add event listening
dwasse Sep 21, 2023
0e248ba
Cleanup: var shadowing
dwasse Sep 21, 2023
3950c35
WIP: working pings being sent
dwasse Sep 21, 2023
310404b
Config: add pingpong address to scribe indexer
dwasse Sep 22, 2023
edbf5c3
Merge branch 'feat/devnet-upper' into feat/devnet-load-script
dwasse Sep 22, 2023
78ca9f1
WIP: add makeScribeClient() helper
dwasse Sep 22, 2023
082258f
WIP: use scribe for log streaming
dwasse Sep 25, 2023
c60e94d
WIP: deployment hacks
dwasse Sep 25, 2023
c532845
WIP: parsing pingpong events
dwasse Sep 25, 2023
53d127d
Cleanup: enhanced tracing for notary
dwasse Sep 26, 2023
40dcaca
WIP: add notary logs
dwasse Sep 26, 2023
a77180a
fix scribe config
trajan0x Sep 15, 2023
d4acc27
init
nautsimon Sep 28, 2023
0fb4d0e
Update server.go
nautsimon Sep 28, 2023
3e4e1a0
Update indexer.go
nautsimon Sep 28, 2023
3549fc7
WIP: logs
dwasse Sep 28, 2023
704b75f
Merge branch 'feat/update-last-indexed-scribe' into feat/devnet-load-…
dwasse Sep 28, 2023
0c1185b
WIP: executing ping messages
dwasse Sep 28, 2023
d85d952
WIP: add agent logs
dwasse Sep 28, 2023
aca2944
Config: set anvil block time
dwasse Sep 28, 2023
1210ae1
WIP: get current block number for starting block
dwasse Sep 28, 2023
5eac57a
Notary logs
dwasse Oct 3, 2023
33682c3
WIP: working attestation submission
dwasse Oct 3, 2023
3580252
Feat: check attNonce before submitSnapshot
dwasse Oct 4, 2023
6de2ed1
Feat: add stopping condition to load script
dwasse Oct 4, 2023
b0df86c
[docker]
dwasse Oct 4, 2023
ae46c4e
[goreleaser]
dwasse Oct 4, 2023
09787d7
[goreleaser] notary still processes attNonce = 0
dwasse Oct 5, 2023
df29662
[goreleaser] add logs
dwasse Oct 5, 2023
6e5b409
[goreleaser] gasBlock logging + attempted fix
dwasse Oct 5, 2023
7fb3b83
[goreleaser] more submitter logging
dwasse Oct 5, 2023
7b882a0
[goreleaser] attempt to force no batching
dwasse Oct 6, 2023
e328ef3
[goreleaser] more notary logs
dwasse Oct 6, 2023
d7ff854
Merge branch 'master' into feat/update-last-indexed-scribe
nautsimon Oct 9, 2023
4cd1efd
update logs
nautsimon Oct 9, 2023
0433dfa
Fix: consistent construction of omnirpc url
dwasse Oct 9, 2023
c1bf0f6
Merge branch 'feat/update-last-indexed-scribe' into feat/devnet-load-…
dwasse Oct 9, 2023
9e1a967
Feat: add retry around executor contract setup
dwasse Oct 10, 2023
65029c7
Revert "[goreleaser] gasBlock logging + attempted fix"
dwasse Oct 10, 2023
806c34a
Revert "[goreleaser] attempt to force no batching"
dwasse Oct 10, 2023
a56b7e3
WIP: logs
dwasse Oct 10, 2023
94feb36
[goreleaser]
dwasse Oct 11, 2023
0f03194
[goreleaser] chain setup logging
dwasse Oct 12, 2023
a9c4b43
[goreleaser] Revert "Revert "[goreleaser] gasBlock logging + attempte…
dwasse Oct 12, 2023
b442206
[goreleaser] more logs
dwasse Oct 13, 2023
8c1d79f
Add logs for message status
dwasse Oct 13, 2023
b7e8f60
[goreleaser] add LogTx() helper
dwasse Oct 13, 2023
2c5faa2
[goreleaser] more logs with snapRoot
dwasse Oct 13, 2023
7da26a9
[goreleaser] Executor marks as executed using on-chain result
dwasse Oct 15, 2023
88bd573
Fix: set anvil block time in simulated backend
dwasse Oct 16, 2023
946918f
[goreleaser] Fix: start submitter
dwasse Oct 16, 2023
efcd0a5
[goreleaser] Revert attempted submitter fix
dwasse Oct 17, 2023
82d03a7
[goreleaser] remove all changes to submitter
dwasse Oct 17, 2023
54ab414
[goreleaser] Revert "Executor marks as executed using on-chain result"
dwasse Oct 17, 2023
60ef7e6
[goreleaser] Remove retry from guard cmd
dwasse Oct 17, 2023
7e48f29
[goreleaser] don't retry upon starting notary
dwasse Oct 17, 2023
dc0eba2
[goreleaser] add span events upon execute()
dwasse Oct 18, 2023
0360dc3
[goreleaser] More span events on submitter
dwasse Oct 18, 2023
ecdf086
[goreleaser] check for nil tx, remove extra spans
dwasse Oct 19, 2023
bb70d51
[goreleaser] Exit setGasPrice() if cannot get gas block
dwasse Oct 19, 2023
6937fb0
[goreleaser] Merge branch 'master' into feat/devnet-load-script
dwasse Oct 20, 2023
1f93d81
[goreleaser] Fix: executor build
dwasse Oct 20, 2023
da3122b
[goreleaser] enhance guard tracing
dwasse Oct 23, 2023
c4933ae
[goreleaser] retry loadOriginStates()
dwasse Oct 23, 2023
cc49a19
always capture [goreleaser]
trajan0x Oct 23, 2023
50883e4
dangerous undo me [goreleaser]
trajan0x Oct 23, 2023
d81df2d
Revert "dangerous undo me [goreleaser]"
trajan0x Oct 23, 2023
0aea8a7
[goreleaser] add ExecuteRetryInterval to executor
dwasse Oct 23, 2023
cc86fdb
Merge branch 'feat/devnet-load-script' of github.com:synapsecns/sangu…
dwasse Oct 23, 2023
f57ccd1
[goreleaser] add defaultMaxTrySeconds
dwasse Oct 23, 2023
d9a5b65
[goreleaser] set didSubmitLatestNotaryAttestation to true after submit
dwasse Oct 24, 2023
5daabd9
Add last attempt logs
dwasse Oct 24, 2023
d9672c0
[goreleaser] add tracing to executor utils
dwasse Oct 24, 2023
8015545
Feat: add testnet script
dwasse Oct 24, 2023
bf45f06
[goreleaser] add notary spans, skip attNonce == 0
dwasse Oct 25, 2023
9c3edcc
[goreleaser] only submit snapshot if nonce is not known
dwasse Oct 25, 2023
1be1518
Log with summit chain id for notary snapshots
dwasse Oct 25, 2023
8a5c473
[goreleaser] split up bumpTx spans
dwasse Oct 25, 2023
28dea84
[goreleaser] add guard logs
dwasse Oct 25, 2023
5d66e83
[goreleaser] fix: executor retry interval
dwasse Oct 26, 2023
3d468b1
[goreleaser] don't exit guard on log handling err
dwasse Oct 26, 2023
ad91d29
Working testnet load script
dwasse Oct 26, 2023
5de20c2
Parse sent events
dwasse Oct 26, 2023
c261b09
Verify messages after iteration
dwasse Oct 26, 2023
7534c5f
Add extra leaf caches
dwasse Oct 26, 2023
31bf0a9
[goreleaser] Trigger retry with checkIfExecuted()
dwasse Oct 26, 2023
ec05a58
Remove log
dwasse Oct 27, 2023
ee8a1ac
[goreleaser] Revert "[goreleaser] Trigger retry with checkIfExecuted()"
dwasse Oct 27, 2023
cd25dce
[goreleaser] order by nonce asc
dwasse Oct 27, 2023
8ac2d17
[goreleaser] add leaf to message model
dwasse Oct 27, 2023
5806e0f
[goreleaser] add originTxHash to message model
dwasse Oct 27, 2023
ab8a12a
Add snapshot root to processSnapshot tracing
dwasse Oct 27, 2023
2aa051d
[goreleaser] pass log to handlers
dwasse Oct 27, 2023
8e0f79b
[goreleaser] only update summitMyLatestStates after submitting snapshot
dwasse Oct 30, 2023
37fd9a7
[goreleaser] max execute attempts
dwasse Oct 30, 2023
7660ed5
[goreleaser] more execute() attributes
dwasse Oct 30, 2023
d8a6236
[goreleaser] only mark as executed if verified on chain
dwasse Oct 30, 2023
8d812ad
[goreleaser] sort by desc
dwasse Oct 30, 2023
b61141f
[goreleaser] add spans
dwasse Oct 30, 2023
74fb0ae
[goreleaser] add verifyOriginMerkleProof
dwasse Oct 30, 2023
328294c
[goreleaser] add span events
dwasse Oct 30, 2023
0b93543
[goreleaser] extra snapRoot state filter
dwasse Oct 31, 2023
e5a8988
[goreleaser] guard error logging
dwasse Oct 31, 2023
0645a6d
[goreleaser] filter on snapshotRoot in verifyStateMerkleProof()
dwasse Oct 31, 2023
a451ef0
[goreleaser] add spans on notary
dwasse Nov 1, 2023
05d9087
[goreleaser] notary refactor
dwasse Nov 1, 2023
1a24921
Continuously verify messages in background
dwasse Nov 1, 2023
935f422
[goreleaser] use sync.Map in script
dwasse Nov 2, 2023
3fbfe65
Fix print
dwasse Nov 2, 2023
9b9ed8d
[goreleaser] use forked version of w3 for better error msgs
dwasse Nov 2, 2023
c8845c8
[goreleaser] use errgroup ctx in guard cmd
dwasse Nov 6, 2023
3662a1f
Tx receipt error handling
dwasse Nov 6, 2023
4e4e41d
[goreleaser] all spans use snapRoot
dwasse Nov 6, 2023
c4b86ed
Fix: only log error if != nil
dwasse Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ coverage:

# from go.work file
flags:
# note: go.work flags should be in order of the directory structure
# also, if you're using multiple module names, you're doing something wrong
agents:
paths:
- agents/
Expand Down
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
.vscode

node_modules
**/node_modules
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ jobs:
with:
label: 'needs-go-generate-${{matrix.package}}'


check-generation:
name: Go Generate (Module Changes)
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/goreleaser-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
push: true
file: ./docker/goreleaser/Dockerfile
# TODO this needs to be versioned
# Note: this automatically pushes the latest tag for sanguine-goreleaser even on branched workflows. While unlikely,
# this could break local devnets that rely on working versions of this image and as such the latest tag should only be pushed on master
# additionally, tags representing a specific version rather than the hash of the file should be considered for future use.
tags: ghcr.io/synapsecns/sanguine-goreleaser:latest,${{ steps.name-export.outputs.TAG_NAME }}
cache-from: type=registry,ref=ghcr.io/synapsecns/sanguine-goreleaser:buildcache
cache-to: type=registry,ref=ghcr.io/synapsecns/sanguine-goreleaser:buildcache,mode=max
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ codecov/
# fasthttp
fastcache.tmp*

#vercel

# ignore all go built files in local dirs
main
**/.vercel
.devnet/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "services/cctp-relayer/external/synapse-contracts"]
path = services/cctp-relayer/external/synapse-contracts
url = https://github.com/synapsecns/synapse-contracts
[submodule "packages/contracts-core/lib/create3-factory"]
path = packages/contracts-core/lib/create3-factory
url = https://github.com/zeframlou/create3-factory
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,10 @@ Use the above commands to recompile the packages.
## Dealing with submodules

This repo make use of [multiple](.gitattributes) [submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). To avoid issues when checking out different branches, you can use `git submodule update --init --recursive` after switching to a branch or `git checkout feat/branch-name --recurse-submodules` when switching branches.

# Building Agents Locally

<!-- TODO: we need to move this thing into an ops docs package. Given that the docs are still a work in progress, I'm leaving this here for now. -->
<!-- Actually, it's unclear if this belongs in a contributing.md file, the docs or both. Maybe a symlink? -->

In order to minimize risks coming from extraneous dependencies or supply chain attacks in a production like enviornment, all distributed images are built as [scratch](https://hub.docker.com/_/scratch) or [distroless](https://github.com/GoogleContainerTools/distroless#distroless-container-images) images. Builder containers are also not used to restrict the build enviornment to the [goreleaser container](https://github.com/synapsecns/sanguine/pkgs/container/sanguine-goreleaser). All production images are kept in the `docker/` file as `[dir].Dockerfile`. Local
14 changes: 13 additions & 1 deletion agents/agents/executor/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ var ExecutorRunCommand = &cli.Command{

handler, err := metrics.NewFromEnv(ctx, metadata.BuildInfo())
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to create metrics handler: %w", err)
}

executorConfig, executorDB, err := createExecutorParameters(ctx, c, handler)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return err
}

Expand All @@ -125,15 +127,17 @@ var ExecutorRunCommand = &cli.Command{
false,
)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to initialize database: %w", err)
}

scribeClients := make(map[uint32][]backend.ScribeBackend)

for _, client := range executorConfig.ScribeConfig.EmbeddedScribeConfig.Chains {
for confNum := 1; confNum <= scribeCmd.MaxConfirmations; confNum++ {
backendClient, err := backend.DialBackend(ctx, fmt.Sprintf("%s/%d/rpc/%d", executorConfig.ScribeConfig.EmbeddedScribeConfig.RPCURL, confNum, client.ChainID), handler)
backendClient, err := backend.DialBackend(ctx, fmt.Sprintf("%s/confirmations/%d/rpc/%d", executorConfig.BaseOmnirpcURL, confNum, client.ChainID), handler)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("could not start client for %s", fmt.Sprintf("%s/1/rpc/%d", executorConfig.ScribeConfig.EmbeddedScribeConfig.RPCURL, client.ChainID))
}

Expand All @@ -143,12 +147,14 @@ var ExecutorRunCommand = &cli.Command{

scribe, err := service.NewScribe(eventDB, scribeClients, executorConfig.ScribeConfig.EmbeddedScribeConfig, handler)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to initialize scribe: %w", err)
}

g.Go(func() error {
err := scribe.Start(ctx)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to start scribe: %w", err)
}

Expand All @@ -164,6 +170,7 @@ var ExecutorRunCommand = &cli.Command{
g.Go(func() error {
err := embedded.Start(ctx)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to start embedded scribe: %w", err)
}

Expand All @@ -178,6 +185,7 @@ var ExecutorRunCommand = &cli.Command{
handler,
).ScribeClient
default:
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("invalid scribe type: %s", executorConfig.ScribeConfig.Type)
}

Expand All @@ -190,12 +198,14 @@ var ExecutorRunCommand = &cli.Command{

executor, err := executor.NewExecutor(ctx, executorConfig, executorDB, scribeClient, baseOmniRPCClient, handler)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to create executor: %w", err)
}

g.Go(func() error {
err := api.Start(ctx, uint16(c.Uint(metricsPortFlag.Name)))
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to start api: %w", err)
}

Expand All @@ -205,13 +215,15 @@ var ExecutorRunCommand = &cli.Command{
g.Go(func() error {
err := executor.Run(ctx)
if err != nil {
fmt.Printf("cmderr: %v\n", err)
return fmt.Errorf("failed to run executor: %w", err)
}

return nil
})

if err := g.Wait(); err != nil {
fmt.Printf("waiterr: %v\n", err)
return fmt.Errorf("failed to run executor: %w", err)
}

Expand Down
8 changes: 5 additions & 3 deletions agents/agents/executor/db/executor_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package db
import (
"context"
"encoding/json"

"github.com/ethereum/go-ethereum/common"
"github.com/synapsecns/sanguine/agents/agents/executor/types"
agentsTypes "github.com/synapsecns/sanguine/agents/types"
submitterDB "github.com/synapsecns/sanguine/ethergo/submitter/db"
Expand All @@ -11,7 +13,7 @@ import (
// ExecutorDBWriter is the interface for writing to the executor database.
type ExecutorDBWriter interface {
// StoreMessage stores a message in the database.
StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64) error
StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64, originTxHash common.Hash) error
// ExecuteMessage marks a message as executed in the database.
ExecuteMessage(ctx context.Context, messageMask DBMessage) error
// SetMinimumTime sets the minimum time of a message.
Expand Down Expand Up @@ -57,7 +59,7 @@ type ExecutorDBReader interface {
// GetState gets a state from the database.
GetState(ctx context.Context, stateMask DBState) (*agentsTypes.State, error)
// GetStateMetadata gets the snapshot root, proof, and tree height of a state from the database.
GetStateMetadata(ctx context.Context, stateMask DBState) (snapshotRoot *[32]byte, proof *json.RawMessage, stateIndex *uint32, err error)
GetStateMetadata(ctx context.Context, stateMask DBState) (proof *json.RawMessage, stateIndex *uint32, err error)
// GetPotentialSnapshotRoots gets all snapshot roots that are greater than or equal to a specified nonce and matches
// a specified chain ID.
GetPotentialSnapshotRoots(ctx context.Context, chainID uint32, nonce uint32) ([]string, error)
Expand All @@ -73,7 +75,7 @@ type ExecutorDBReader interface {
// GetEarliestStateInRange gets the earliest state with the same snapshot root as an attestation within a nonce range.
// 1. Get all states that are within a nonce range.
// 2. Get the state with the earliest attestation associated to it.
GetEarliestStateInRange(ctx context.Context, chainID, destination, startNonce, endNonce uint32) (*agentsTypes.State, error)
GetEarliestStateInRange(ctx context.Context, chainID, destination, startNonce, endNonce uint32) (*agentsTypes.State, *string, error)
}

// ExecutorDB is the interface for the executor database.
Expand Down
21 changes: 11 additions & 10 deletions agents/agents/executor/db/message_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package db_test

import (
"math/big"

"github.com/brianvoe/gofakeit/v6"
"github.com/ethereum/go-ethereum/common"
. "github.com/stretchr/testify/assert"
"github.com/synapsecns/sanguine/agents/agents/executor/db"
"github.com/synapsecns/sanguine/agents/agents/executor/types"
agentsTypes "github.com/synapsecns/sanguine/agents/types"
"math/big"
)

func (t *DBSuite) TestStoreRetrieveMessage() {
Expand All @@ -23,7 +24,7 @@ func (t *DBSuite) TestStoreRetrieveMessage() {
headerA := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainIDA, nonceA, destinationA, gofakeit.Uint32())
typesMessageA := agentsTypes.NewMessage(headerA, nil, messageA)

err := testDB.StoreMessage(t.GetTestContext(), typesMessageA, blockNumberA, minimumTimeSetA, minimumTimeA)
err := testDB.StoreMessage(t.GetTestContext(), typesMessageA, blockNumberA, minimumTimeSetA, minimumTimeA, common.Hash{})
Nil(t.T(), err)

chainIDB := gofakeit.Uint32()
Expand All @@ -37,7 +38,7 @@ func (t *DBSuite) TestStoreRetrieveMessage() {
headerB := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainIDB, nonceB, destinationB, gofakeit.Uint32())
typesMessageB := agentsTypes.NewMessage(headerB, nil, messageB)

err = testDB.StoreMessage(t.GetTestContext(), typesMessageB, blockNumberB, minimumTimeSetB, minimumTimeB)
err = testDB.StoreMessage(t.GetTestContext(), typesMessageB, blockNumberB, minimumTimeSetB, minimumTimeB, common.Hash{})
Nil(t.T(), err)

messageAMask := db.DBMessage{
Expand Down Expand Up @@ -105,7 +106,7 @@ func (t *DBSuite) TestGetLastBlockNumber() {
header := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, optimisticSeconds)
message, err := agentsTypes.NewMessageFromManagerMessage(header, messageBody)
Nil(t.T(), err)
err = testDB.StoreMessage(t.GetTestContext(), message, messageBlockNumber, false, 0)
err = testDB.StoreMessage(t.GetTestContext(), message, messageBlockNumber, false, 0, common.Hash{})
Nil(t.T(), err)

// Create and store an attestation.
Expand Down Expand Up @@ -145,7 +146,7 @@ func (t *DBSuite) TestExecuteMessage() {
header := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage := agentsTypes.NewMessage(header, nil, message)

err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 5)
err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 5, common.Hash{})
Nil(t.T(), err)

messageMask := db.DBMessage{
Expand Down Expand Up @@ -185,7 +186,7 @@ func (t *DBSuite) TestGetExecutableMessages() {
header := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage := agentsTypes.NewMessage(header, nil, message)

err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 10)
err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 10, common.Hash{})
Nil(t.T(), err)

messageMask := db.DBMessage{
Expand All @@ -206,7 +207,7 @@ func (t *DBSuite) TestGetExecutableMessages() {
header = agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage = agentsTypes.NewMessage(header, nil, message)

err = testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 20)
err = testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 20, common.Hash{})
Nil(t.T(), err)

// Check when the current time is after the minimum time, and minimum time is set to true.
Expand Down Expand Up @@ -245,7 +246,7 @@ func (t *DBSuite) TestGetUnsetMinimumTimeMessages() {
header := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage := agentsTypes.NewMessage(header, nil, message)

err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 0)
err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 0, common.Hash{})
Nil(t.T(), err)

messageMask := db.DBMessage{
Expand All @@ -264,7 +265,7 @@ func (t *DBSuite) TestGetUnsetMinimumTimeMessages() {
header = agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage = agentsTypes.NewMessage(header, nil, message)

err = testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 0)
err = testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, true, 0, common.Hash{})
Nil(t.T(), err)

messages, err = testDB.GetUnsetMinimumTimeMessages(t.GetTestContext(), messageMask, 1)
Expand All @@ -285,7 +286,7 @@ func (t *DBSuite) TestSetMinimumTime() {
header := agentsTypes.NewHeader(agentsTypes.MessageFlagManager, chainID, nonce, destination, gofakeit.Uint32())
typesMessage := agentsTypes.NewMessage(header, nil, message)

err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 0)
err := testDB.StoreMessage(t.GetTestContext(), typesMessage, blockNumber, false, 0, common.Hash{})
Nil(t.T(), err)

trueVal := true
Expand Down
14 changes: 7 additions & 7 deletions agents/agents/executor/db/sql/base/crosstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func (s Store) GetTimestampForMessage(ctx context.Context, chainID, destination,
// GetEarliestStateInRange gets the earliest state with the same snapshot root as an attestation within a nonce range.
// 1. Get all states that are within a nonce range.
// 2. Get the state with the earliest attestation associated to it.
func (s Store) GetEarliestStateInRange(ctx context.Context, chainID, destination, startNonce, endNonce uint32) (*agentsTypes.State, error) {
func (s Store) GetEarliestStateInRange(ctx context.Context, chainID, destination, startNonce, endNonce uint32) (*agentsTypes.State, *string, error) {
statesTableName, err := dbcommon.GetModelName(s.DB(), &State{})
if err != nil {
return nil, fmt.Errorf("failed to get states table name: %w", err)
return nil, nil, fmt.Errorf("failed to get states table name: %w", err)
}

attestationsTableName, err := dbcommon.GetModelName(s.DB(), &Attestation{})
if err != nil {
return nil, fmt.Errorf("failed to get attestations table name: %w", err)
return nil, nil, fmt.Errorf("failed to get attestations table name: %w", err)
}

var state State
Expand Down Expand Up @@ -108,19 +108,19 @@ func (s Store) GetEarliestStateInRange(ctx context.Context, chainID, destination
},
)
if err != nil {
return nil, fmt.Errorf("failed to interpolate GetEarliestStateInRange query: %w", err)
return nil, nil, fmt.Errorf("failed to interpolate GetEarliestStateInRange query: %w", err)
}

dbTx := s.DB().WithContext(ctx).
Raw(query, chainID, destination, startNonce, endNonce, chainID, destination).
Scan(&state)
if dbTx.Error != nil {
return nil, fmt.Errorf("failed to get earliest state in range: %w", dbTx.Error)
return nil, nil, fmt.Errorf("failed to get earliest state in range: %w", dbTx.Error)
}

if dbTx.RowsAffected == 0 {
//nolint:nilnil
return nil, nil
return nil, nil, nil
}

gasData := agentsTypes.NewGasData(
Expand All @@ -141,5 +141,5 @@ func (s Store) GetEarliestStateInRange(ctx context.Context, chainID, destination
gasData,
)

return &receivedState, nil
return &receivedState, &state.SnapshotRoot, nil
}
17 changes: 13 additions & 4 deletions agents/agents/executor/db/sql/base/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/synapsecns/sanguine/agents/agents/executor/db"
"github.com/synapsecns/sanguine/agents/agents/executor/types"
agentsTypes "github.com/synapsecns/sanguine/agents/types"
Expand All @@ -13,8 +14,8 @@ import (
)

// StoreMessage stores a message in the database.
func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64) error {
dbMessage, err := AgentsTypesMessageToMessage(message, blockNumber, minimumTimeSet, minimumTime)
func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64, originTxHash common.Hash) error {
dbMessage, err := AgentsTypesMessageToMessage(message, blockNumber, minimumTimeSet, minimumTime, originTxHash)
if err != nil {
return fmt.Errorf("failed to convert message: %w", err)
}
Expand Down Expand Up @@ -51,6 +52,7 @@ func (s Store) ExecuteMessage(ctx context.Context, messageMask db.DBMessage) err

// SetMinimumTime sets the minimum time of a message.
func (s Store) SetMinimumTime(ctx context.Context, messageMask db.DBMessage, minimumTime uint64) error {
fmt.Printf("SetMinimumTime: %v, %v\n", minimumTime, messageMask)
dbMessageMask := DBMessageToMessage(messageMask)
update := Message{MinimumTime: minimumTime, MinimumTimeSet: true}
dbTx := s.DB().WithContext(ctx).
Expand Down Expand Up @@ -153,7 +155,7 @@ func (s Store) GetLastBlockNumber(ctx context.Context, chainID uint32, contractT
Where(fmt.Sprintf("%s = ?", ChainIDFieldName), chainID).
Select(fmt.Sprintf("MAX(%s)", BlockNumberFieldName)).
Find(&lastBlockNumber)
case types.LightInboxContract, types.SummitContract:
case types.LightInboxContract, types.SummitContract, types.DestinationContract:
dbTx = preDBTx.Model(&Attestation{}).
Where(fmt.Sprintf("%s = ?", DestinationFieldName), chainID).
Select(fmt.Sprintf("MAX(%s)", DestinationBlockNumberFieldName)).
Expand Down Expand Up @@ -342,11 +344,16 @@ func MessageToDBMessage(message Message) db.DBMessage {
}

// AgentsTypesMessageToMessage converts an agentsTypes.Message to a Message.
func AgentsTypesMessageToMessage(message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64) (Message, error) {
func AgentsTypesMessageToMessage(message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64, originTxHash common.Hash) (Message, error) {
rawMessage, err := agentsTypes.EncodeMessage(message)
if err != nil {
return Message{}, fmt.Errorf("failed to encode message: %w", err)
}
leafBytes, err := message.ToLeaf()
if err != nil {
return Message{}, fmt.Errorf("failed to get message leaf: %w", err)
}
leaf := common.BytesToHash(leafBytes[:])
return Message{
ChainID: message.OriginDomain(),
Destination: message.DestinationDomain(),
Expand All @@ -356,5 +363,7 @@ func AgentsTypesMessageToMessage(message agentsTypes.Message, blockNumber uint64
Executed: false,
MinimumTimeSet: minimumTimeSet,
MinimumTime: minimumTime,
Leaf: leaf.String(),
OriginTxHash: originTxHash.String(),
}, nil
}
Loading
Loading