Skip to content

feat(pos): introduce ERC20 staking skeleton contracts, spec, scripts, and tests#65

Merged
BioMark3r merged 1 commit intomainfrom
codex/add-erc20-staking-skeleton-for-pos-migration
Mar 4, 2026
Merged

feat(pos): introduce ERC20 staking skeleton contracts, spec, scripts, and tests#65
BioMark3r merged 1 commit intomainfrom
codex/add-erc20-staking-skeleton-for-pos-migration

Conversation

@BioMark3r
Copy link
Copy Markdown
Owner

Motivation

  • Provide on-chain PoS staking state and clear interfaces as a Milestone 1 foundation for a future PoS migration without touching consensus/node runtime.
  • Deliver devnet-friendly, deterministic tooling and a simple ERC20 staking token for local/operator flows so validators can register, stake, unbond, withdraw, and snapshot active sets.
  • Keep gas-heavy/consensus integration work off-chain or for later milestones while offering concrete contract hooks and a snapshot placeholder for clients to consume.

Description

  • Add a concise PoS spec skeleton at docs/pos/erc20-pos-skeleton.md describing actors, state model, epochs, lifecycle, interfaces, events, and integration notes.
  • Implement ERC20 staking contracts under contracts/pos/: QIKToken.sol (owner-mintable devnet ERC20), ValidatorRegistry.sol (operator metadata registration), StakeManager.sol (ERC20 staking, unbonding queue, withdraw with ReentrancyGuard), and EpochManager.sol (epoch helpers and owner-submitted active-set snapshots + hash).
  • Add Foundry baseline foundry.toml, deployment and operation scripts under script/pos/ (DeployPos.s.sol, PosOps.s.sol) which output .data/pos/addresses.json, and parsing helpers for CSV operator lists.
  • Extend Makefile with PoS targets (pos-deploy, pos-mint, pos-register, pos-stake, pos-unstake, pos-withdraw, pos-snapshot, pos-info) and update README.md quickstart; add minimal Foundry tests in test/pos/staking_epoch.t.sol covering stake/unstake/withdraw, registration guard, and snapshot hashing/storage.

Testing

  • Ran make help to validate Makefile integration and target visibility, which succeeded and shows the new pos-* targets.
  • Attempted to run forge test but it could not execute in this environment because forge is not installed (bash: command not found: forge), so the added Foundry unit tests were not executed here.
  • Added deterministic Foundry unit tests under test/pos/ intended to be run with forge test in a Foundry-enabled environment; they exercise the stake/unstake/withdraw happy path and the epoch snapshot logic.

Codex Task

@BioMark3r BioMark3r merged commit b342bc0 into main Mar 4, 2026
0 of 3 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8d85ce497

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

json = vm.serializeUint("pos", "minStake", minStake);
json = vm.serializeUint("pos", "unbondingBlocks", unbondingBlocks);
json = vm.serializeUint("pos", "epochLengthBlocks", epochLengthBlocks);
vm.writeJson(json, path);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Configure Foundry fs_permissions for JSON output

DeployPos.run() writes deployment metadata using vm.createDir and vm.writeJson, but this commit does not configure fs_permissions with write access in foundry.toml; under Foundry's filesystem sandbox, write cheatcodes are blocked by default, so make pos-deploy can fail before producing .data/pos/addresses.json, which then breaks the downstream pos-* Make targets that read that file.

Useful? React with 👍 / 👎.

Comment thread foundry.toml
Comment on lines +11 to +14
remappings = [
"@openzeppelin/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/"
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include required Foundry libraries in repository setup

The new Solidity code depends on @openzeppelin and forge-std remapped to lib/openzeppelin-contracts and lib/forge-std/src, but those paths are not present in this repository, so a clean checkout cannot compile the PoS contracts/tests/scripts introduced here until manual dependency installation is done; this makes the new workflow non-reproducible unless setup instructions or install automation are added.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant