Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e7a0cc1
feat: convert tx allow list npm test to go test
JonathanOppenheimer Dec 3, 2025
060eb2b
Merge branch 'master' into JonathanOppenheimer/convert-tx-allow-list-…
JonathanOppenheimer Dec 3, 2025
169f6f3
chore: delete old example
JonathanOppenheimer Dec 3, 2025
60110f8
feat: convert reward manager npm test to go test
JonathanOppenheimer Dec 3, 2025
b057b88
fix: contract formatting and import
JonathanOppenheimer Dec 3, 2025
a98b243
chore: delete old binding
JonathanOppenheimer Dec 3, 2025
fb29afb
chore: delete example contract
JonathanOppenheimer Dec 3, 2025
4eef5e6
chore: lint
JonathanOppenheimer Dec 3, 2025
bb21931
test: add should not let non-enabled address submit txs
JonathanOppenheimer Dec 4, 2025
8cfb75b
Merge branch 'master' into JonathanOppenheimer/convert-tx-allow-list-…
JonathanOppenheimer Dec 4, 2025
1e0d2fe
style: ignore lint error for now
JonathanOppenheimer Dec 4, 2025
1069395
test: add helper function for backend
JonathanOppenheimer Dec 4, 2025
7a12f05
Merge branch 'master' into JonathanOppenheimer/convert-tx-allow-list-…
JonathanOppenheimer Dec 4, 2025
f519ccc
chore: lint
JonathanOppenheimer Dec 4, 2025
de4726e
Merge branch 'master' into JonathanOppenheimer/convert-tx-allow-list-…
JonathanOppenheimer Dec 4, 2025
a8d7ebd
Merge branch 'master' into JonathanOppenheimer/convert-reward-manager…
JonathanOppenheimer Dec 4, 2025
ab29c98
Merge branch 'master' into JonathanOppenheimer/convert-reward-manager…
JonathanOppenheimer Dec 4, 2025
43ade2c
Merge branch 'master' into JonathanOppenheimer/convert-tx-allow-list-…
JonathanOppenheimer Dec 4, 2025
78fd11d
Merge branch 'JonathanOppenheimer/convert-tx-allow-list-test' into Jo…
JonathanOppenheimer Dec 4, 2025
df3d4d1
chore: delete more deprecated code
JonathanOppenheimer Dec 4, 2025
5e77010
test: use new structure
JonathanOppenheimer Dec 4, 2025
a135782
chore: delete vestigial CI
JonathanOppenheimer Dec 4, 2025
a7ea83e
chore: unused file
JonathanOppenheimer Dec 4, 2025
997ce0f
test: restore task.ts
JonathanOppenheimer Dec 4, 2025
c82ccd7
fix: restore run_ginkgo.sh
JonathanOppenheimer Dec 4, 2025
8540c62
chore: regenerate bindings
JonathanOppenheimer Dec 4, 2025
63d4aaa
chore: reduce diff
JonathanOppenheimer Dec 4, 2025
37a9e0d
chore: format
JonathanOppenheimer Dec 4, 2025
284c1fc
chore: regenerate bindings
JonathanOppenheimer Dec 4, 2025
3abde93
Merge branch 'master' into JonathanOppenheimer/convert-reward-manager…
JonathanOppenheimer Dec 4, 2025
748ca1c
Update IAllowList.sol
JonathanOppenheimer Dec 5, 2025
d7f590e
docs: add comment explaining import replace
JonathanOppenheimer Dec 5, 2025
72d5ebe
chore: regenerate bindings
JonathanOppenheimer Dec 5, 2025
0804768
test: convert warp hardhat test to go
JonathanOppenheimer Dec 5, 2025
6877bd8
reduce diff with master
ceyonur Dec 5, 2025
650bd1d
further reduce diffs
ceyonur Dec 5, 2025
ddc92e7
further reduce diffs
ceyonur Dec 5, 2025
a024dc6
fix linter
ceyonur Dec 5, 2025
9afb94c
fix
ceyonur Dec 5, 2025
8d6af33
style: move tx function
JonathanOppenheimer Dec 5, 2025
aafb6db
test: use random key for reward address test
JonathanOppenheimer Dec 5, 2025
07ab33f
test: through contract rather than interface
JonathanOppenheimer Dec 5, 2025
5ea2a0d
revert extra change
ceyonur Dec 5, 2025
8f146c6
test: add coinbase test
JonathanOppenheimer Dec 5, 2025
755449b
Ceyonur/reduce diff reward manager tests (#1909)
JonathanOppenheimer Dec 5, 2025
9ec5e25
Merge branch 'JonathanOppenheimer/convert-reward-manager-test' into J…
JonathanOppenheimer Dec 5, 2025
31edb02
feat: warp bindings test
JonathanOppenheimer Dec 5, 2025
f9deda0
chore: revert util.ts deletion
JonathanOppenheimer Dec 5, 2025
15729af
chore: move util.ts
JonathanOppenheimer Dec 5, 2025
e5631aa
chore: rename util -> utils
JonathanOppenheimer Dec 5, 2025
36eca4a
fix: export only roles
JonathanOppenheimer Dec 5, 2025
282f862
fix: verifyAndExtractWarpMessage()
JonathanOppenheimer Dec 5, 2025
8725814
chore: lint
JonathanOppenheimer Dec 5, 2025
8702753
Update precompile/contracts/testutils/simulated_helpers.go
JonathanOppenheimer Dec 5, 2025
8859053
fix: don't export sendSimpleTx
JonathanOppenheimer Dec 5, 2025
9177c3a
chore: consolidate NewBackendWithPrecompile
JonathanOppenheimer Dec 5, 2025
b2fbe9e
chore: lint
JonathanOppenheimer Dec 5, 2025
64c71f8
chore: delete warp.json
JonathanOppenheimer Dec 5, 2025
ef7c953
Merge branch 'JonathanOppenheimer/convert-reward-manager-test' into J…
JonathanOppenheimer Dec 5, 2025
97e182c
fix: revert delete warp.json
JonathanOppenheimer Dec 5, 2025
e85cc03
Merge branch 'master' into JonathanOppenheimer/convert-warp-test
JonathanOppenheimer Dec 6, 2025
473405a
test: move interfaces to top level
JonathanOppenheimer Dec 8, 2025
34023f3
chore: git track move
JonathanOppenheimer Dec 8, 2025
607a237
chore: regenerate bindings
JonathanOppenheimer Dec 8, 2025
6031f25
style: rename bindings test
JonathanOppenheimer Dec 8, 2025
e0c9b79
test: full warp bindings test
JonathanOppenheimer Dec 8, 2025
bf3ad0f
test: extract using bindings
JonathanOppenheimer Dec 8, 2025
66ae1e8
style: set addressedCallUnsignedMessage directly
JonathanOppenheimer Dec 8, 2025
2b2e3ff
chore: lint
JonathanOppenheimer Dec 8, 2025
ad6f6b9
chore: reduce diff
JonathanOppenheimer Dec 8, 2025
b11a074
style: add back blank line
JonathanOppenheimer Dec 8, 2025
9701be7
Merge branch 'JonathanOppenheimer/move-interfaces' into JonathanOppen…
JonathanOppenheimer Dec 8, 2025
d2c7704
chore: move ExampleWarp.sol to where it is used
JonathanOppenheimer Dec 8, 2025
f8af497
style: restore blank line
JonathanOppenheimer Dec 8, 2025
86ce37b
test: reuse verifyAndExtractWarpMessage helper
JonathanOppenheimer Dec 9, 2025
c2e0eb7
test: specify sender
JonathanOppenheimer Dec 9, 2025
440840f
Merge branch 'master' into JonathanOppenheimer/convert-warp-test
JonathanOppenheimer Dec 9, 2025
5e78e94
Update tests/warp/warp_test.go
JonathanOppenheimer Dec 9, 2025
9016376
Update tests/warp/warp_test.go
JonathanOppenheimer Dec 9, 2025
dfec9d9
Update tests/warp/warp_test.go
JonathanOppenheimer Dec 9, 2025
e16d112
docs: expand verifyAndExtractWarpMessage function comment
JonathanOppenheimer Dec 9, 2025
e0f9532
Update tests/warp/warp_test.go
JonathanOppenheimer Dec 9, 2025
12d27a8
chore: regenerate bindings
JonathanOppenheimer Dec 9, 2025
9be0e67
refactor: make verifyAndExtractWarpMessage a static helper
JonathanOppenheimer Dec 10, 2025
7a55db4
docs: add arran comment note
JonathanOppenheimer Dec 11, 2025
20cd6be
chore: regenerate bindings
JonathanOppenheimer Dec 11, 2025
5ab245f
Update precompile/contracts/warp/warptest/bindings/WarpTest.sol
JonathanOppenheimer Dec 11, 2025
daf8bc3
chore: regenerate bindings
JonathanOppenheimer Dec 11, 2025
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
369 changes: 0 additions & 369 deletions contracts/bindings/gen_examplewarp.go

This file was deleted.

48 changes: 0 additions & 48 deletions contracts/contracts/interfaces/IWarpMessenger.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { test } from './test/utils';
export { Roles } from './test/utils';
92 changes: 1 addition & 91 deletions contracts/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { ethers } from "hardhat"
import { Overrides } from "ethers"
import assert from "assert"

/*
*
* The `test` function is a wrapper around Mocha's `it` function. It provides a normalized framework for running the
Expand Down Expand Up @@ -37,96 +33,10 @@ import assert from "assert"
*/

// Below are the types that help define all the different ways to call `test`
type FnNameOrObject = string | string[] | MethodObject | MethodObject[]

// Limit `from` property to be a `string` instead of `string | Promise<string>`
type CallOverrides = Overrides & { from?: string }

type MethodObject = { method: string, debug?: boolean, overrides?: CallOverrides, shouldFail?: boolean }

// This type is after all default values have been applied
type MethodWithDebugAndOverrides = MethodObject & { debug: boolean, overrides: CallOverrides, shouldFail: boolean }

// `test` is used very similarly to `it` from Mocha
export const test = (name, fnNameOrObject, overrides = {}) => it(name, buildTestFn(fnNameOrObject, overrides))
// `test.only` is used very similarly to `it.only` from Mocha, it will isolate all tests marked with `test.only`
test.only = (name, fnNameOrObject, overrides = {}) => it.only(name, buildTestFn(fnNameOrObject, overrides))
// `test.debug` is used to apply `debug: true` to all DSTest contract method calls in the test
test.debug = (name, fnNameOrObject, overrides = {}) => it.only(name, buildTestFn(fnNameOrObject, overrides, true))
// `test.skip` is used very similarly to `it.skip` from Mocha, it will skip all tests marked with `test.skip`
test.skip = (name, fnNameOrObject, overrides = {}) => it.skip(name, buildTestFn(fnNameOrObject, overrides))

// `buildTestFn` is a higher-order function. It returns a function that can be used as the test function for `it`
const buildTestFn = (fnNameOrObject: FnNameOrObject, overrides = {}, debug = false) => {
// normalize the input to an array of objects
const fnObjects: MethodWithDebugAndOverrides[] = (Array.isArray(fnNameOrObject) ? fnNameOrObject : [fnNameOrObject]).map(fnNameOrObject => {
fnNameOrObject = typeof fnNameOrObject === 'string' ? { method: fnNameOrObject } : fnNameOrObject
// assign all default values and overrides
fnNameOrObject.overrides = Object.assign({}, overrides, fnNameOrObject.overrides ?? {})
fnNameOrObject.debug = fnNameOrObject.debug ?? debug
fnNameOrObject.shouldFail = fnNameOrObject.shouldFail ?? false

return fnNameOrObject as MethodWithDebugAndOverrides
})

// only `step_` prefixed functions can be called on the `DSTest` contracts to clearly separate tests and helpers
assert(fnObjects.every(({ method }) => method.startsWith('step_')), "Solidity test functions must be prefixed with 'step_'")

// return the test function that will be used by `it`
// this function must be defined with the `function` keyword so that `this` is bound to the Mocha context
return async function () {
// `Array.prototype.reduce` is used here to ensure that the test functions are called in order.
// Each test function waits for its predecessor to complete before starting
return fnObjects.reduce((p: Promise<undefined>, fn) => p.then(async () => {
const contract = fn.overrides.from
? this.testContract.connect(await ethers.getSigner(fn.overrides.from))
: this.testContract
const tx = await contract[fn.method](fn.overrides).catch(err => {
if (fn.shouldFail) {
if (fn.debug){
console.error(`smart contract call failed with error:\n${err}\n`)
}

return { failed: true }
}

console.error("smart contract call failed with error:", err)
throw err
})

// no more assertions necessary if the method-call should fail and did fail
if (tx.failed && fn.shouldFail) return

const txReceipt = await tx.wait().catch(err => {
if (fn.debug) console.error(`tx failed with error:\n${err}\n`)
return err.receipt
})

// `txReceipt.status` will be `0` if the transaction failed.
// `contract.failed` will return `true` if any of the `DSTest` assertions failed.
const failed = txReceipt.status === 0 ? true : await contract.failed.staticCall()
if (fn.debug || failed) {
console.log('')

if (!txReceipt.events) console.warn('WARNING: No parseable events found in tx-receipt\n')

// If `DSTest` assertions failed, the contract will emit logs describing the assertion failure(s).
txReceipt
.events
?.filter(event => fn.debug || event.event?.startsWith('log'))
.map(event => event.args?.forEach(arg => console.log(arg)))

console.log('')
}

assert(!failed, `${fn.method} failed`)
}), Promise.resolve())
}
}

export const Roles = {
None: 0,
Enabled: 1,
Admin: 2,
Manager: 3,
}
}
40 changes: 0 additions & 40 deletions contracts/test/warp.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.24;
pragma experimental ABIEncoderV2;

import "./interfaces/IWarpMessenger.sol";
import "precompile/contracts/warp/warpbindings/IWarpMessenger.sol";

contract ExampleWarp {
address constant WARP_ADDRESS = 0x0200000000000000000000000000000000000005;
Expand Down
56 changes: 56 additions & 0 deletions precompile/contracts/warp/warpbindings/IWarpMessenger.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.24;

struct WarpMessage {
bytes32 sourceChainID;
address originSenderAddress;
bytes payload;
}

struct WarpBlockHash {
bytes32 sourceChainID;
bytes32 blockHash;
}

interface IWarpMessenger {
event SendWarpMessage(
address indexed sender,
bytes32 indexed messageID,
bytes message
);

// sendWarpMessage emits a request for the subnet to send a warp message from [msg.sender]
// with the specified parameters.
// This emits a SendWarpMessage log from the precompile. When the corresponding block is accepted
// the Accept hook of the Warp precompile is invoked with all accepted logs emitted by the Warp
// precompile.
// Each validator then adds the UnsignedWarpMessage encoded in the log to the set of messages
// it is willing to sign for an off-chain relayer to aggregate Warp signatures.
function sendWarpMessage(
bytes calldata payload
) external returns (bytes32 messageID);

// getVerifiedWarpMessage parses the pre-verified warp message in the
// predicate storage slots as a WarpMessage and returns it to the caller.
// If the message exists and passes verification, returns the verified message
// and true.
// Otherwise, returns false and the empty value for the message.
function getVerifiedWarpMessage(
uint32 index
) external view returns (WarpMessage calldata message, bool valid);

// getVerifiedWarpBlockHash parses the pre-verified WarpBlockHash message in the
// predicate storage slots as a WarpBlockHash message and returns it to the caller.
// If the message exists and passes verification, returns the verified message
// and true.
// Otherwise, returns false and the empty value for the message.
function getVerifiedWarpBlockHash(
uint32 index
) external view returns (WarpBlockHash calldata warpBlockHash, bool valid);

// getBlockchainID returns the snow.Context BlockchainID of this chain.
// This blockchainID is the hash of the transaction that created this blockchain on the P-Chain
// and is not related to the Ethereum ChainID.
function getBlockchainID() external view returns (bytes32 blockchainID);
}
12 changes: 12 additions & 0 deletions precompile/contracts/warp/warpbindings/compile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package warpbindings

// Step 1: Compile Solidity contract to generate ABI and bin files
//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --evm-version cancun IWarpMessenger.sol
// Step 2: Generate Go bindings from the compiled artifacts
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg warpbindings --type IWarpMessenger --abi artifacts/IWarpMessenger.abi --bin artifacts/IWarpMessenger.bin --out gen_iwarpmessenger_binding.go
// Step 3: Replace import paths in generated binding to use subnet-evm instead of libevm
// This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing.
//go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_iwarpmessenger_binding.go && rm -f gen_iwarpmessenger_binding.go.bak"
Loading
Loading