Skip to content

Commit 79aba3e

Browse files
committed
Merge testnet/donut into chore/read-state-donut-upgrade
Resolves three conflicts: - app/app.go: keep UcallbackKeeper from develop - constants.go: keep both 0xC2 = UNIVERSAL_CALLBACK and 0xCA = USigVerifier - constants_test.go: occupied set is the union of both sides
2 parents faf0173 + e0ee38f commit 79aba3e

65 files changed

Lines changed: 1908 additions & 85 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ jobs:
123123
- name: Patch chain ID for production
124124
run: |
125125
sed -i 's/"localchain_9000-1"/"push_42101-1"/' app/app.go
126+
sed -i 's/EVMChainID = uint64(9000)/EVMChainID = uint64(42101)/' app/app.go
126127
grep -n "ChainID" app/app.go
127128
128129
- name: Build Linux binary
@@ -247,6 +248,7 @@ jobs:
247248
- name: Patch chain ID for production
248249
run: |
249250
sed -i 's/"localchain_9000-1"/"push_42101-1"/' app/app.go
251+
sed -i 's/EVMChainID = uint64(9000)/EVMChainID = uint64(42101)/' app/app.go
250252
grep -n "ChainID" app/app.go
251253
252254
- name: Build Linux ARM64 binary
@@ -390,6 +392,7 @@ jobs:
390392
- name: Patch chain ID for production
391393
run: |
392394
sed -i '' 's/"localchain_9000-1"/"push_42101-1"/' app/app.go
395+
sed -i '' 's/EVMChainID = uint64(9000)/EVMChainID = uint64(42101)/' app/app.go
393396
grep -n "ChainID" app/app.go
394397
395398
- name: Build Mac Binary (ARM64 only - native build)

app/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ Push Chain ships exactly one custom precompile:
148148

149149
| Address | Name | Purpose |
150150
|---|---|---|
151-
| `0xEC00000000000000000000000000000000000001` | `usigverifier` | Ed25519 signature verification (Solana signatures over `bytes32` digests), registered at the reserved Push range |
151+
| `0x00000000000000000000000000000000000000ca` | `usigverifier` (legacy) | Ed25519 signature verification (Solana signatures over `bytes32` digests) |
152+
| `0xEC00000000000000000000000000000000000001` | `usigverifier` (v2) | Same implementation, registered at the reserved Push range |
152153

153-
Gas cost: `4000` per `verifyEd25519` call. See [`precompiles/usigverifier/README.md`](../precompiles/usigverifier/README.md).
154+
Both addresses are registered simultaneously for backward compatibility with deployed contracts that have the legacy address hardcoded. Gas cost: `4000` per `verifyEd25519` call. See [`precompiles/usigverifier/README.md`](../precompiles/usigverifier/README.md).
154155

155156
The baseline EVM precompiles (`bech32`, `p256`, `staking`, `distribution`, `ics20`, `bank`, `gov`, `slashing`, `evidence`) are wired in via `app/precompiles.go:NewAvailableStaticPrecompiles`.
156157

app/app.go

100644100755
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ const (
186186
NodeDir = ".pchain"
187187
Bech32Prefix = "push"
188188

189-
ChainID = "localchain_9000-1"
190-
EVMChainID = uint64(9000)
189+
ChainID = "push_42101-1"
190+
EVMChainID = uint64(42101)
191191
)
192192

193193
var (
@@ -837,8 +837,17 @@ func NewChainApp(
837837
appCodec,
838838
)
839839

840-
// usigverifier precompile (0xEC..01) — core precompile range
841-
usigverifierPrecompileV2, err := usigverifierprecompile.NewPrecompile()
840+
// Add the usigverifier precompile for Ed25519 verification (old address: 0xCA)
841+
usigverifierPrecompile, err := usigverifierprecompile.NewPrecompile()
842+
if err != nil {
843+
panic(fmt.Errorf("failed to instantiate usigverifier precompile: %w", err))
844+
}
845+
corePrecompiles[usigverifierPrecompile.Address()] = usigverifierPrecompile
846+
847+
// New address (0xEC..01) — reserved Push precompile range.
848+
// Both old and new addresses are registered simultaneously for backward compatibility
849+
// with deployed contracts that have old addresses hardcoded in their bytecode.
850+
usigverifierPrecompileV2, err := usigverifierprecompile.NewPrecompileV2()
842851
if err != nil {
843852
panic(fmt.Errorf("failed to instantiate usigverifier v2 precompile: %w", err))
844853
}
@@ -1490,24 +1499,6 @@ func (a *ChainApp) DefaultGenesis() map[string]json.RawMessage {
14901499
mintGenState.Params.MintDenom = BaseDenom
14911500
genesis[minttypes.ModuleName] = a.appCodec.MustMarshalJSON(mintGenState)
14921501

1493-
// Register bank denom metadata for the EVM base denom. In cosmos/evm v0.5
1494-
// the EVM module's InitGenesis derives coin info (decimals/display) from this
1495-
// metadata via LoadEvmCoinInfo, so a fresh chain must carry it in genesis.
1496-
var bankGenState banktypes.GenesisState
1497-
a.appCodec.MustUnmarshalJSON(genesis[banktypes.ModuleName], &bankGenState)
1498-
bankGenState.DenomMetadata = append(bankGenState.DenomMetadata, banktypes.Metadata{
1499-
Description: "Native token of Push Chain",
1500-
DenomUnits: []*banktypes.DenomUnit{
1501-
{Denom: BaseDenom, Exponent: 0},
1502-
{Denom: DisplayDenom, Exponent: 18},
1503-
},
1504-
Base: BaseDenom,
1505-
Display: DisplayDenom,
1506-
Name: "Push Chain",
1507-
Symbol: "PC",
1508-
})
1509-
genesis[banktypes.ModuleName] = a.appCodec.MustMarshalJSON(&bankGenState)
1510-
15111502
evmGenState := evmtypes.DefaultGenesisState()
15121503
evmGenState.Params.ActiveStaticPrecompiles = evmtypes.AvailableStaticPrecompiles
15131504
evmGenState.Params.EvmDenom = BaseDenom
@@ -1659,7 +1650,7 @@ func BlockedAddresses() map[string]bool {
16591650
}
16601651

16611652
for _, precompile := range blockedPrecompilesHex {
1662-
blockedAddrs[cosmosevmutils.EthHexToCosmosAddr(precompile).String()] = true
1653+
blockedAddrs[cosmosevmutils.Bech32StringFromHexAddress(precompile)] = true
16631654
}
16641655

16651656
return blockedAddrs

app/config.go

100644100755
File mode changed.

app/precompiles.go

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"maps"
66

7-
"github.com/cosmos/cosmos-sdk/codec"
87
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
8+
"github.com/cosmos/cosmos-sdk/codec"
99
distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
1010
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
1111
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"

app/test_helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
4747

4848
evmtypes "github.com/cosmos/evm/x/vm/types"
49+
4950
uregistrytypes "github.com/pushchain/push-chain-node/x/uregistry/types"
5051
utsstypes "github.com/pushchain/push-chain-node/x/utss/types"
5152
uvalidatortypes "github.com/pushchain/push-chain-node/x/uvalidator/types"

app/upgrades.go

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,95 @@ import (
66
upgradetypes "cosmossdk.io/x/upgrade/types"
77

88
"github.com/pushchain/push-chain-node/app/upgrades"
9+
aiauditfixes "github.com/pushchain/push-chain-node/app/upgrades/ai-audit-fixes"
10+
aiauditfixes2 "github.com/pushchain/push-chain-node/app/upgrades/ai-audit-fixes-2"
11+
ceagasandpayload "github.com/pushchain/push-chain-node/app/upgrades/cea-gas-and-payload"
12+
ceapayloadverificationfix "github.com/pushchain/push-chain-node/app/upgrades/cea-payload-verification-fix"
13+
chainmeta "github.com/pushchain/push-chain-node/app/upgrades/chain-meta"
14+
chainmetavotegasless "github.com/pushchain/push-chain-node/app/upgrades/chain-meta-vote-gasless"
15+
contractauditchanges "github.com/pushchain/push-chain-node/app/upgrades/contract-audit-changes"
16+
ethhashfix "github.com/pushchain/push-chain-node/app/upgrades/eth-hash-fix"
17+
evmblockscoutfix "github.com/pushchain/push-chain-node/app/upgrades/evm-blockscout-fix"
18+
evmchainidffix "github.com/pushchain/push-chain-node/app/upgrades/evm-chainid-fix"
19+
evmparamsmigration "github.com/pushchain/push-chain-node/app/upgrades/evm-params-migration"
20+
evmpreinstalls "github.com/pushchain/push-chain-node/app/upgrades/evm-preinstalls"
21+
evmrpcfix "github.com/pushchain/push-chain-node/app/upgrades/evm-rpc-fix"
22+
evmv040 "github.com/pushchain/push-chain-node/app/upgrades/evm-v0-4-0"
23+
evmv050 "github.com/pushchain/push-chain-node/app/upgrades/evm-v0-5-0"
24+
evmderivedgasprice "github.com/pushchain/push-chain-node/app/upgrades/evm-derived-gas-price"
25+
evmv060 "github.com/pushchain/push-chain-node/app/upgrades/evm-v0-6-0"
26+
feeabs "github.com/pushchain/push-chain-node/app/upgrades/fee-abs"
27+
gasoracle "github.com/pushchain/push-chain-node/app/upgrades/gas-oracle"
928
"github.com/pushchain/push-chain-node/app/upgrades/noop"
29+
outbound "github.com/pushchain/push-chain-node/app/upgrades/outbound"
30+
pcmintcap "github.com/pushchain/push-chain-node/app/upgrades/pc-mint-cap"
31+
pc20 "github.com/pushchain/push-chain-node/app/upgrades/pc20"
32+
proxybytecodefix "github.com/pushchain/push-chain-node/app/upgrades/proxy-bytecode-fix"
33+
purgeexpiredoutbounds "github.com/pushchain/push-chain-node/app/upgrades/purge-expired-outbounds"
34+
removefeeabsv1 "github.com/pushchain/push-chain-node/app/upgrades/remove-fee-abs-v1"
35+
removeutxverifier "github.com/pushchain/push-chain-node/app/upgrades/remove-utxverifier"
36+
sdkv053 "github.com/pushchain/push-chain-node/app/upgrades/sdk-v0-53"
37+
securityauditfixes "github.com/pushchain/push-chain-node/app/upgrades/security-audit-fixes"
38+
solanafix "github.com/pushchain/push-chain-node/app/upgrades/solana-fix"
39+
supplyburn "github.com/pushchain/push-chain-node/app/upgrades/supply-burn"
40+
supplyslash "github.com/pushchain/push-chain-node/app/upgrades/supply-slash"
41+
tsscore "github.com/pushchain/push-chain-node/app/upgrades/tss-core"
42+
tsscoreevmparamsfix "github.com/pushchain/push-chain-node/app/upgrades/tss-core-evm-params-fix"
43+
tsscorefix "github.com/pushchain/push-chain-node/app/upgrades/tss-core-fix"
44+
tssfundmigrationfixes "github.com/pushchain/push-chain-node/app/upgrades/tss-fund-migration-fixes"
45+
tssmigration "github.com/pushchain/push-chain-node/app/upgrades/tss-migration"
46+
tssvotegasless "github.com/pushchain/push-chain-node/app/upgrades/tss-vote-gasless"
47+
ueamigration "github.com/pushchain/push-chain-node/app/upgrades/uea-migration"
48+
universaltxv1 "github.com/pushchain/push-chain-node/app/upgrades/universal-tx-v1"
1049
)
1150

1251
// Upgrades list of chain upgrades
13-
var Upgrades = []upgrades.Upgrade{}
52+
var Upgrades = []upgrades.Upgrade{
53+
feeabs.NewUpgrade(),
54+
solanafix.NewUpgrade(),
55+
ethhashfix.NewUpgrade(),
56+
gasoracle.NewUpgrade(),
57+
pcmintcap.NewUpgrade(),
58+
tsscore.NewUpgrade(),
59+
tsscorefix.NewUpgrade(),
60+
tsscoreevmparamsfix.NewUpgrade(),
61+
evmrpcfix.NewUpgrade(),
62+
evmblockscoutfix.NewUpgrade(),
63+
tssvotegasless.NewUpgrade(),
64+
removefeeabsv1.NewUpgrade(),
65+
outbound.NewUpgrade(),
66+
universaltxv1.NewUpgrade(),
67+
proxybytecodefix.NewUpgrade(),
68+
supplyslash.NewUpgrade(),
69+
supplyburn.NewUpgrade(),
70+
chainmeta.NewUpgrade(),
71+
chainmetavotegasless.NewUpgrade(),
72+
ceagasandpayload.NewUpgrade(),
73+
ceapayloadverificationfix.NewUpgrade(),
74+
aiauditfixes.NewUpgrade(),
75+
aiauditfixes2.NewUpgrade(),
76+
ueamigration.NewUpgrade(),
77+
tssmigration.NewUpgrade(),
78+
purgeexpiredoutbounds.NewUpgrade(),
79+
removeutxverifier.NewUpgrade(),
80+
tssfundmigrationfixes.NewUpgrade(),
81+
contractauditchanges.NewUpgrade(),
82+
evmv040.NewUpgrade(),
83+
evmparamsmigration.NewUpgrade(),
84+
evmchainidffix.NewUpgrade(),
85+
evmpreinstalls.NewUpgrade(),
86+
evmv050.NewUpgrade(),
87+
securityauditfixes.NewUpgrade(),
88+
// cosmos/evm v0.6.0 — runs the standard transfer module v5->v6 migration
89+
evmv060.NewUpgrade(),
90+
// pc20 — no-op binary swap; VAULT_PC/VAULT_PC20 deployed separately from EVM side
91+
pc20.NewUpgrade(),
92+
// sdk-v0.53 — Cosmos SDK v0.50.10 -> v0.53.7; no-op (no module ConsensusVersion changes)
93+
sdkv053.NewUpgrade(),
94+
// evm-derived-gas-price — cosmos/evm bump for the derived-tx gas price fix;
95+
// no-op (JSON-RPC reporting only, no module ConsensusVersion changes)
96+
evmderivedgasprice.NewUpgrade(),
97+
}
1498

1599
// RegisterUpgradeHandlers registers the chain upgrade handlers
16100
func (app *ChainApp) RegisterUpgradeHandlers() {
@@ -28,6 +112,7 @@ func (app *ChainApp) RegisterUpgradeHandlers() {
28112
Codec: app.appCodec,
29113
GetStoreKey: app.GetKey,
30114
EVMKeeper: app.EVMKeeper,
115+
Erc20Keeper: &app.Erc20Keeper,
31116
BankKeeper: app.BankKeeper,
32117

33118
// Module keepers
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package contractauditchanges
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
storetypes "cosmossdk.io/store/types"
8+
upgradetypes "cosmossdk.io/x/upgrade/types"
9+
10+
sdk "github.com/cosmos/cosmos-sdk/types"
11+
"github.com/cosmos/cosmos-sdk/types/module"
12+
13+
"github.com/pushchain/push-chain-node/app/upgrades"
14+
)
15+
16+
// Upgrade for chain contract audit changes + evm version bump to 0.3.2
17+
// UpgradeName matches the chain-side change set that adapts the chain's
18+
// UniversalCore ABI + gas-fee read path to the post-audit smart-contract
19+
// No module ConsensusVersion is bumped for this upgrade — none of the chain
20+
// changes touch module storage schemas, so RunMigrations is a no-op for the
21+
// version map; this handler exists primarily as a coordination point so all
22+
// validators flip to the new ABI / gas-fee read at the same height.
23+
24+
// Key changes in this library bump:
25+
// - AccountKeeper now requires unordered-tx methods (satisfied via authKeeperEVMWrapper stub)
26+
// - EVMKeeper constructor takes additional params: store keys map, ConsensusParamsKeeper
27+
// - go-ethereum bumped to v1.15.11-cosmos-0; statedb.Account.Balance is now uint256.Int (not big.Int)
28+
// - erc20 module: NativePrecompiles moved from Params to a top-level genesis field
29+
// - Precompile constructors now require bankKeeper; gov precompile also requires appCodec
30+
// - vm.NewAppModule signature updated to accept AddressCodec
31+
//
32+
// RunMigrations handles the erc20 state migration automatically (consensus version bump).
33+
const UpgradeName = "changes"
34+
35+
func NewUpgrade() upgrades.Upgrade {
36+
return upgrades.Upgrade{
37+
UpgradeName: UpgradeName,
38+
CreateUpgradeHandler: CreateUpgradeHandler,
39+
StoreUpgrades: storetypes.StoreUpgrades{
40+
Added: []string{},
41+
Deleted: []string{},
42+
},
43+
}
44+
}
45+
46+
func CreateUpgradeHandler(
47+
mm upgrades.ModuleManager,
48+
configurator module.Configurator,
49+
_ *upgrades.AppKeepers,
50+
) upgradetypes.UpgradeHandler {
51+
return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
52+
sdkCtx := sdk.UnwrapSDKContext(ctx)
53+
logger := sdkCtx.Logger().With("upgrade", UpgradeName)
54+
logger.Info("Starting upgrade handler")
55+
logger.Info("cosmos/evm v0.2.x → v0.3.2: erc20 NativePrecompiles field migration, go-ethereum v1.15.11-cosmos-0")
56+
logger.Info("UniversalCore audit: ABI gasLimitUsed output, setGasPrice removal, gas_fee.go reads results[5]")
57+
58+
// erc20 module's ConsensusVersion bump (from EVM 0.3.2) drives the
59+
// only on-chain state migration this upgrade requires; RunMigrations
60+
// handles it. The chain's own modules don't bump versions here.
61+
versionMap, err := mm.RunMigrations(ctx, configurator, fromVM)
62+
if err != nil {
63+
return nil, fmt.Errorf("RunMigrations: %w", err)
64+
}
65+
66+
logger.Info("Upgrade complete", "upgrade", UpgradeName)
67+
return versionMap, nil
68+
}
69+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package evmblockscoutfix
2+
3+
import (
4+
"context"
5+
6+
storetypes "cosmossdk.io/store/types"
7+
upgradetypes "cosmossdk.io/x/upgrade/types"
8+
"github.com/cosmos/cosmos-sdk/types/module"
9+
10+
"github.com/pushchain/push-chain-node/app/upgrades"
11+
)
12+
13+
const UpgradeName = "evm-blockscout-fix"
14+
15+
func NewUpgrade() upgrades.Upgrade {
16+
return upgrades.Upgrade{
17+
UpgradeName: UpgradeName,
18+
CreateUpgradeHandler: CreateUpgradeHandler,
19+
StoreUpgrades: storetypes.StoreUpgrades{
20+
Added: []string{},
21+
Deleted: []string{},
22+
},
23+
}
24+
}
25+
26+
func CreateUpgradeHandler(
27+
mm upgrades.ModuleManager,
28+
configurator module.Configurator,
29+
ak *upgrades.AppKeepers,
30+
) upgradetypes.UpgradeHandler {
31+
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
32+
return mm.RunMigrations(ctx, configurator, fromVM)
33+
}
34+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package evmchainidffix
2+
3+
import (
4+
"context"
5+
6+
storetypes "cosmossdk.io/store/types"
7+
upgradetypes "cosmossdk.io/x/upgrade/types"
8+
9+
"github.com/cosmos/cosmos-sdk/types/module"
10+
11+
"github.com/pushchain/push-chain-node/app/upgrades"
12+
)
13+
14+
const UpgradeName = "evm-chainid-fix"
15+
16+
func NewUpgrade() upgrades.Upgrade {
17+
return upgrades.Upgrade{
18+
UpgradeName: UpgradeName,
19+
CreateUpgradeHandler: CreateUpgradeHandler,
20+
StoreUpgrades: storetypes.StoreUpgrades{},
21+
}
22+
}
23+
24+
func CreateUpgradeHandler(
25+
mm upgrades.ModuleManager,
26+
configurator module.Configurator,
27+
_ *upgrades.AppKeepers,
28+
) upgradetypes.UpgradeHandler {
29+
return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
30+
return mm.RunMigrations(ctx, configurator, fromVM)
31+
}
32+
}

0 commit comments

Comments
 (0)