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

ci: switch from ganache to anvil #3869

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
kubectl config set-context ci --namespace=$DEPLOY_NS
kubectl config use-context ci

# temporarily set --guardiand_loglevel=info to debug https://github.com/wormhole-foundation/wormhole/issues/3052
- run: tilt ci --timeout 45m0s -- --ci --namespace=$DEPLOY_NS --num=2 --guardiand_loglevel=info
- run: tilt ci --timeout 45m0s -- --ci --namespace=$DEPLOY_NS --num=2
timeout-minutes: 60

# Clean up k8s resources
Expand Down
22 changes: 17 additions & 5 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Launch the devnet:

tilt up

By default this runs a network consisting of one guardian, two ganache (Eth) chains, a Solana test validator, an Algorand sandbox, and LocalTerra for both Terra Classic and Terra 2. If you want to work on non-consensus parts of the code, running with a single guardian is easiest since you won't have to wait for k8s to restart all pods. See the usage guide below for arguments to customize the tilt network.
By default this runs a network consisting of one guardian, two anvil (Eth) chains, a Solana test validator, an Algorand sandbox, and LocalTerra for both Terra Classic and Terra 2. If you want to work on non-consensus parts of the code, running with a single guardian is easiest since you won't have to wait for k8s to restart all pods. See the usage guide below for arguments to customize the tilt network.

## Usage

Expand Down Expand Up @@ -140,28 +140,40 @@ To re-generate these files run `rm -rf node/pkg/proto && docker build --target g

### Call gRPC services

<!-- cspell:disable-next-line -->
<!-- cspell:disable -->

tools/bin/grpcurl -protoset <(tools/bin/buf build -o -) -plaintext localhost:7072 spy.v1.SpyRPCService/SubscribeSignedVAA

<!-- cspell:enable -->

With parameters (using proto json encoding):

<!-- cspell:disable-next-line -->
<!-- cspell:disable -->

tools/bin/grpcurl -protoset <(tools/bin/buf build -o -) \
-d '{"filters": [{"emitter_filter": {"emitter_address": "574108aed69daf7e625a361864b1f74d13702f2ca56de9660e566d1d8691848d", "chain_id": "CHAIN_ID_SOLANA"}}]}' \
-plaintext localhost:7072 spy.v1.SpyRPCService/SubscribeSignedVAA

<!-- cspell:enable -->

### Post messages

To Solana:

<!-- cspell:disable-next-line -->
<!-- cspell:disable -->

kubectl exec solana-devnet-0 -c setup -- client post-message Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o 1 confirmed ffff

<!-- cspell:enable -->

To Solana as CPI instruction:

<!-- cspell:disable-next-line -->
<!-- cspell:disable -->

kubectl exec solana-devnet-0 -c setup -- client post-message --proxy CP1co2QMMoDPbsmV7PGcUTLFwyhgCgTXt25gLQ5LewE1 Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o 1 confirmed ffff

<!-- cspell:enable -->

### Observation Requests

kubectl exec -it guardian-0 -- /guardiand admin send-observation-request --socket /tmp/admin.sock 1 4636d8f7593c78a5092bed13dec765cc705752653db5eb1498168c92345cd389
Expand Down
4 changes: 2 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ k8s_yaml_with_ns("devnet/eth-devnet.yaml")
k8s_resource(
"eth-devnet",
port_forwards = [
port_forward(8545, name = "Ganache RPC [:8545]", host = webHost),
port_forward(8545, name = "Anvil RPC [:8545]", host = webHost),
],
labels = ["evm"],
trigger_mode = trigger_mode,
Expand All @@ -546,7 +546,7 @@ if evm2:
k8s_resource(
"eth-devnet2",
port_forwards = [
port_forward(8546, name = "Ganache RPC [:8546]", host = webHost),
port_forward(8546, 8545, name = "Anvil RPC [:8546]", host = webHost),
],
labels = ["evm"],
trigger_mode = trigger_mode,
Expand Down
23 changes: 7 additions & 16 deletions devnet/eth-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ spec:
spec:
terminationGracePeriodSeconds: 1
containers:
- name: ganache
- name: anvil
image: eth-node
command:
- npx
- ganache-cli
- --logging.quiet
- --wallet.defaultBalance=10000
- --wallet.deterministic
- --chain.time="1970-01-01T00:00:00+00:00"
- anvil
- --silent
- --mnemonic=myth like bonus scare over problem client lizard pioneer submit female collect
- --block-time=1
- --host=0.0.0.0
- --wallet.totalAccounts=13
- --chain.chainId=1337
- --chain.asyncRequestProcessing=false
- --accounts=13
- --chain-id=1337
ports:
- containerPort: 8545
name: rpc
Expand All @@ -64,11 +61,5 @@ spec:
initialDelaySeconds: 90
tcpSocket:
port: 2000
- name: mine
image: eth-node
command:
- /bin/sh
- -c
- "cd ../../ethereum && npx truffle exec mine.js"
---

23 changes: 7 additions & 16 deletions devnet/eth-devnet2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ spec:
spec:
terminationGracePeriodSeconds: 1
containers:
- name: ganache
- name: anvil
image: eth-node
command:
- npx
- ganache-cli
- --logging.quiet
- --wallet.defaultBalance=10000
- --wallet.deterministic
- --chain.time="1970-01-01T00:00:00+00:00"
- anvil
- --silent
- --mnemonic=myth like bonus scare over problem client lizard pioneer submit female collect
- --block-time=1
- --host=0.0.0.0
- --wallet.totalAccounts=13
- --chain.chainId=1397
- --chain.asyncRequestProcessing=false
- --accounts=13
- --chain-id=1397
ports:
- containerPort: 8545
name: rpc
Expand All @@ -65,9 +62,3 @@ spec:
initialDelaySeconds: 90
tcpSocket:
port: 2000
- name: mine
image: eth-node
command:
- /bin/sh
- -c
- "cd ../../ethereum && npx truffle exec mine.js"
1 change: 1 addition & 0 deletions ethereum/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN $HOME/.foundry/bin/foundryup
RUN ls $HOME/.foundry/bin

# Run as user, otherwise, npx explodes.
RUN mv /root/.foundry/bin/anvil /bin/anvil
RUN mv /root/.foundry/bin/forge /bin/forge
USER 1000

Expand Down
6 changes: 0 additions & 6 deletions ethereum/copy-from-container.sh

This file was deleted.

36 changes: 0 additions & 36 deletions ethereum/mine.js

This file was deleted.

25 changes: 16 additions & 9 deletions node/pkg/watchers/evm/blocks_by_timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type (
// maxCacheSize is used to trim the cache.
maxCacheSize int

// unsafeDevMode is used to suppress warnings in dev mode.
unsafeDevMode bool

// mutex is used to protect the cache.
mutex sync.Mutex
}
Expand All @@ -32,10 +35,11 @@ type (
)

// NewBlocksByTimestamp creates an empty cache of blocks by timestamp.
func NewBlocksByTimestamp(maxCacheSize int) *BlocksByTimestamp {
func NewBlocksByTimestamp(maxCacheSize int, unsafeDevMode bool) *BlocksByTimestamp {
return &BlocksByTimestamp{
cache: Blocks{},
maxCacheSize: maxCacheSize,
cache: Blocks{},
maxCacheSize: maxCacheSize,
unsafeDevMode: unsafeDevMode,
}
}

Expand All @@ -55,12 +59,15 @@ func (bts *BlocksByTimestamp) AddLatest(logger *zap.Logger, timestamp uint64, bl
}
}

logger.Warn("rollback detected in timestamp cache",
zap.Uint64("oldLatestBlockNum", bts.cache[l-1].BlockNum),
zap.Uint64("oldLatestTimestamp", bts.cache[l-1].Timestamp),
zap.Uint64("newLatestBlockNum", blockNum),
zap.Uint64("newLatestTimestamp", timestamp),
)
// Anvil trips this when using `anvil_mine`
if !bts.unsafeDevMode {
logger.Warn("rollback detected in timestamp cache",
zap.Uint64("oldLatestBlockNum", bts.cache[l-1].BlockNum),
zap.Uint64("oldLatestTimestamp", bts.cache[l-1].Timestamp),
zap.Uint64("newLatestBlockNum", blockNum),
zap.Uint64("newLatestTimestamp", timestamp),
)
}
bts.cache = bts.cache[:idx+1]
}

Expand Down
14 changes: 7 additions & 7 deletions node/pkg/watchers/evm/blocks_by_timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func cacheIsValid(t *testing.T, bts *BlocksByTimestamp) bool {
}

func TestBlocksByTimestamp_TestCacheIsValid(t *testing.T) {
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS)
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS, false)

// Empty cache is valid.
assert.True(t, cacheIsValid(t, bts))
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestBlocksByTimestamp_TestCacheIsValid(t *testing.T) {

func TestBlocksByTimestamp_AddLatest(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS)
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS, false)

bts.AddLatest(logger, 1698621628, 420)
bts.AddLatest(logger, 1698621628, 421)
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestBlocksByTimestamp_AddLatest(t *testing.T) {

func TestBlocksByTimestamp_AddLatestRollbackEverything(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS)
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS, false)

bts.AddLatest(logger, 1698621628, 420)
require.Equal(t, 1, len(bts.cache))
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestBlocksByTimestamp_AddLatestRollbackEverything(t *testing.T) {

func TestBlocksByTimestamp_AddLatestShouldTrimTheCache(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(5)
bts := NewBlocksByTimestamp(5, false)

bts.AddLatest(logger, 1698621628, 420)
bts.AddLatest(logger, 1698621628, 421)
Expand All @@ -161,7 +161,7 @@ func TestBlocksByTimestamp_AddLatestShouldTrimTheCache(t *testing.T) {

func TestBlocksByTimestamp_AddBatch(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS)
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS, false)

// First create a cache with some gaps in it.
bts.AddLatest(logger, 1698621628, 420)
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestBlocksByTimestamp_AddBatch(t *testing.T) {

func TestBlocksByTimestamp_AddBatchShouldTrim(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(8)
bts := NewBlocksByTimestamp(8, false)

// First create a cache with some gaps in it.
bts.AddLatest(logger, 1698621628, 420)
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestBlocksByTimestamp_SearchForTimestamp(t *testing.T) {

func TestBlocksByTimestamp_LookUp(t *testing.T) {
logger := zap.NewNop()
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS)
bts := NewBlocksByTimestamp(BTS_MAX_BLOCKS, false)

// Empty cache.
prev, next, found := bts.LookUp(1698621627)
Expand Down
3 changes: 1 addition & 2 deletions node/pkg/watchers/evm/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (w *Watcher) Run(parentCtx context.Context) error {
}

if w.ccqConfig.TimestampCacheSupported {
w.ccqTimestampCache = NewBlocksByTimestamp(BTS_MAX_BLOCKS)
w.ccqTimestampCache = NewBlocksByTimestamp(BTS_MAX_BLOCKS, w.unsafeDevMode)
}

errC := make(chan error)
Expand Down Expand Up @@ -702,7 +702,6 @@ func (w *Watcher) getFinality(ctx context.Context) (bool, bool, error) {
finalized := false
safe := false
if w.unsafeDevMode {
// Devnet supports finalized and safe (although they returns the same value as latest).
finalized = true
safe = true
} else if w.chainID == vaa.ChainIDAcala ||
Expand Down
10 changes: 10 additions & 0 deletions sdk/js-query/ci-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
process.env.CI = true;

const warn = console.warn;
console.warn = function (x) {
if (
x !==
"bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)"
) {
warn(x);
}
};

module.exports = {};
Loading
Loading